Prepare to add hasSamplePtrHeader and hasSampleInstHeader in dispatch (WIP)

for refresh sample memory when loop/end pointer and instrument parameter changed. Also, this PR has minor code style fixes and add warning in MultiPCM sample map usage.
This commit is contained in:
cam900 2025-08-27 22:52:19 +09:00
parent 4ed40d37d6
commit bd8d9a56a0
10 changed files with 141 additions and 28 deletions

View file

@ -2648,6 +2648,15 @@ int DivEngine::addInstrument(int refChan, DivInstrumentType fallbackType) {
song.insLen=insCount+1;
checkAssetDir(song.insDir,song.ins.size());
saveLock.unlock();
bool hasSampleInst=false;
for (int s=0; s<song.systemLen; s++) {
if (disCont[s].dispatch->hasSampleInstHeader()) {
hasSampleInst=true;
}
}
if (hasSampleInst) {
renderSamplesP();
}
BUSY_END;
return insCount;
}
@ -2665,6 +2674,15 @@ int DivEngine::addInstrumentPtr(DivInstrument* which) {
checkAssetDir(song.waveDir,song.wave.size());
checkAssetDir(song.sampleDir,song.sample.size());
saveLock.unlock();
bool hasSampleInst=false;
for (int s=0; s<song.systemLen; s++) {
if (disCont[s].dispatch->hasSampleInstHeader()) {
hasSampleInst=true;
}
}
if (hasSampleInst) {
renderSamplesP();
}
BUSY_END;
return song.insLen;
}
@ -2700,6 +2718,15 @@ void DivEngine::delInstrumentUnsafe(int index) {
}
removeAsset(song.insDir,index);
checkAssetDir(song.insDir,song.ins.size());
bool hasSampleInst=false;
for (int s=0; s<song.systemLen; s++) {
if (disCont[s].dispatch->hasSampleInstHeader()) {
hasSampleInst=true;
}
}
if (hasSampleInst) {
renderSamplesP();
}
}
}