compensate for sample movement/deletion
This commit is contained in:
parent
ec52eb524d
commit
5c861ca36e
|
@ -3851,6 +3851,23 @@ void DivEngine::delSample(int index) {
|
|||
song.sampleLen=song.sample.size();
|
||||
removeAsset(song.sampleDir,index);
|
||||
checkAssetDir(song.sampleDir,song.sample.size());
|
||||
|
||||
// compensate
|
||||
for (DivInstrument* i: song.ins) {
|
||||
if (i->amiga.initSample==index) {
|
||||
i->amiga.initSample=-1;
|
||||
} else if (i->amiga.initSample>index) {
|
||||
i->amiga.initSample--;
|
||||
}
|
||||
for (int j=0; j<120; j++) {
|
||||
if (i->amiga.noteMap[j].map==index) {
|
||||
i->amiga.noteMap[j].map=-1;
|
||||
} else if (i->amiga.noteMap[j].map>index) {
|
||||
i->amiga.noteMap[j].map--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderSamples();
|
||||
}
|
||||
saveLock.unlock();
|
||||
|
@ -4042,6 +4059,27 @@ void DivEngine::exchangeIns(int one, int two) {
|
|||
}
|
||||
}
|
||||
|
||||
void DivEngine::exchangeWave(int one, int two) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void DivEngine::exchangeSample(int one, int two) {
|
||||
for (DivInstrument* i: song.ins) {
|
||||
if (i->amiga.initSample==one) {
|
||||
i->amiga.initSample=two;
|
||||
} else if (i->amiga.initSample==two) {
|
||||
i->amiga.initSample=one;
|
||||
}
|
||||
for (int j=0; j<120; j++) {
|
||||
if (i->amiga.noteMap[j].map==one) {
|
||||
i->amiga.noteMap[j].map=two;
|
||||
} else if (i->amiga.noteMap[j].map==two) {
|
||||
i->amiga.noteMap[j].map=one;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DivEngine::moveInsUp(int which) {
|
||||
if (which<1 || which>=(int)song.ins.size()) return false;
|
||||
BUSY_BEGIN;
|
||||
|
@ -4064,6 +4102,7 @@ bool DivEngine::moveWaveUp(int which) {
|
|||
song.wave[which]=song.wave[which-1];
|
||||
song.wave[which-1]=prev;
|
||||
moveAsset(song.waveDir,which,which-1);
|
||||
exchangeWave(which,which-1);
|
||||
saveLock.unlock();
|
||||
BUSY_END;
|
||||
return true;
|
||||
|
@ -4080,6 +4119,7 @@ bool DivEngine::moveSampleUp(int which) {
|
|||
song.sample[which]=song.sample[which-1];
|
||||
song.sample[which-1]=prev;
|
||||
moveAsset(song.sampleDir,which,which-1);
|
||||
exchangeSample(which,which-1);
|
||||
saveLock.unlock();
|
||||
renderSamples();
|
||||
BUSY_END;
|
||||
|
@ -4107,6 +4147,7 @@ bool DivEngine::moveWaveDown(int which) {
|
|||
saveLock.lock();
|
||||
song.wave[which]=song.wave[which+1];
|
||||
song.wave[which+1]=prev;
|
||||
exchangeWave(which,which+1);
|
||||
moveAsset(song.waveDir,which,which+1);
|
||||
saveLock.unlock();
|
||||
BUSY_END;
|
||||
|
@ -4123,6 +4164,7 @@ bool DivEngine::moveSampleDown(int which) {
|
|||
saveLock.lock();
|
||||
song.sample[which]=song.sample[which+1];
|
||||
song.sample[which+1]=prev;
|
||||
exchangeSample(which,which+1);
|
||||
moveAsset(song.sampleDir,which,which+1);
|
||||
saveLock.unlock();
|
||||
renderSamples();
|
||||
|
|
|
@ -531,6 +531,9 @@ class DivEngine {
|
|||
void initSongWithDesc(const char* description, bool inBase64=true, bool oldVol=false);
|
||||
|
||||
void exchangeIns(int one, int two);
|
||||
void exchangeWave(int one, int two);
|
||||
void exchangeSample(int one, int two);
|
||||
|
||||
void swapChannels(int src, int dest);
|
||||
void stompChannel(int ch);
|
||||
|
||||
|
|
Loading…
Reference in New Issue