total extinction of legacy sample mode, part 7
finish the conversion method
This commit is contained in:
parent
0ac7106e0e
commit
69ae4f56bd
4 changed files with 67 additions and 1 deletions
|
|
@ -948,6 +948,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
if (ds.version<=0x08) {
|
||||
sample->centerRate=ymuSampleRate*400;
|
||||
}
|
||||
sample->legacyRate=sample->centerRate;
|
||||
if (ds.version>0x15) {
|
||||
sample->depth=(DivSampleDepth)reader.readC();
|
||||
if (sample->depth!=DIV_SAMPLE_DEPTH_8BIT && sample->depth!=DIV_SAMPLE_DEPTH_16BIT) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,61 @@ bool DivEngine::convertLegacySampleMode() {
|
|||
return false;
|
||||
}
|
||||
|
||||
// check which samples are used by instruments so we don't touch them
|
||||
bool* isUsedByIns=new bool[MAX(1,song.sample.size())];
|
||||
memset(isUsedByIns,0,MAX(1,song.sample.size())*sizeof(bool));
|
||||
for (DivInstrument* ins: song.ins) {
|
||||
bool canUse=false;
|
||||
if (ins->type==DIV_INS_MSM6258 ||
|
||||
ins->type==DIV_INS_MSM6295 ||
|
||||
ins->type==DIV_INS_ADPCMA ||
|
||||
ins->type==DIV_INS_ADPCMB ||
|
||||
ins->type==DIV_INS_SEGAPCM ||
|
||||
ins->type==DIV_INS_QSOUND ||
|
||||
ins->type==DIV_INS_YMZ280B ||
|
||||
ins->type==DIV_INS_RF5C68 ||
|
||||
ins->type==DIV_INS_AMIGA ||
|
||||
ins->type==DIV_INS_MULTIPCM ||
|
||||
ins->type==DIV_INS_SNES ||
|
||||
ins->type==DIV_INS_ES5506 ||
|
||||
ins->type==DIV_INS_K007232 ||
|
||||
ins->type==DIV_INS_GA20 ||
|
||||
ins->type==DIV_INS_K053260 ||
|
||||
ins->type==DIV_INS_C140 ||
|
||||
ins->type==DIV_INS_C219 ||
|
||||
ins->type==DIV_INS_NDS ||
|
||||
ins->type==DIV_INS_GBA_DMA ||
|
||||
ins->type==DIV_INS_GBA_MINMOD ||
|
||||
ins->type==DIV_INS_NES ||
|
||||
ins->type==DIV_INS_SUPERVISION) {
|
||||
canUse=true;
|
||||
}
|
||||
if (ins->type==DIV_INS_SU ||
|
||||
ins->type==DIV_INS_AY ||
|
||||
ins->type==DIV_INS_AY8930 ||
|
||||
ins->type==DIV_INS_MIKEY ||
|
||||
ins->type==DIV_INS_PCE ||
|
||||
ins->type==DIV_INS_X1_010 ||
|
||||
ins->type==DIV_INS_SWAN ||
|
||||
ins->type==DIV_INS_VRC6) {
|
||||
if (ins->amiga.useSample) canUse=true;
|
||||
}
|
||||
|
||||
if (canUse) {
|
||||
if (ins->amiga.useNoteMap) {
|
||||
for (int i=0; i<120; i++) {
|
||||
if (ins->amiga.noteMap[i].map>=0 && ins->amiga.noteMap[i].map<(int)song.sample.size()) {
|
||||
isUsedByIns[ins->amiga.noteMap[i].map]=true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ins->amiga.initSample>=0 && ins->amiga.initSample<(int)song.sample.size()) {
|
||||
isUsedByIns[ins->amiga.initSample]=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto initSampleInsIfNeeded=[this,&legacyInsInit]() {
|
||||
if (legacyInsInit==-1) {
|
||||
legacyInsInit=(int)song.ins.size();
|
||||
|
|
@ -293,8 +348,15 @@ bool DivEngine::convertLegacySampleMode() {
|
|||
// we've got a note
|
||||
if (sampleMode==1) {
|
||||
initSampleInsIfNeeded();
|
||||
//p->newData[k][DIV_PAT_NOTE]=60+12*sampleBank+(p->newData[k][DIV_PAT_NOTE]%12);
|
||||
p->newData[k][DIV_PAT_INS]=MIN(0xff,legacyInsInit+sampleBank);
|
||||
|
||||
int involvedSample=12*sampleBank+(p->newData[k][DIV_PAT_NOTE]%12);
|
||||
if (involvedSample>=0 && involvedSample<song.sampleLen) {
|
||||
if (!isUsedByIns[involvedSample]) {
|
||||
DivSample* sample=song.sample[involvedSample];
|
||||
sample->centerRate=sample->legacyRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (p->newData[k][DIV_PAT_NOTE]==DIV_NOTE_OFF && noteOffDisablesSampleMode) {
|
||||
sampleMode=0;
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ DivDataErrors DivSample::readSampleData(SafeReader& reader, short version) {
|
|||
}
|
||||
// just in case it's not new sample, it's a very old version and we gotta read a rate.
|
||||
centerRate=reader.readI();
|
||||
legacyRate=centerRate;
|
||||
|
||||
if (isNewSample) {
|
||||
centerRate=reader.readI();
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ struct DivSampleHistory {
|
|||
struct DivSample {
|
||||
String name;
|
||||
int centerRate, loopStart, loopEnd;
|
||||
int legacyRate;
|
||||
// valid values are:
|
||||
// - 0: ZX Spectrum overlay drum (1-bit)
|
||||
// - 1: 1-bit NES DPCM (1-bit)
|
||||
|
|
@ -338,6 +339,7 @@ struct DivSample {
|
|||
centerRate(8363),
|
||||
loopStart(-1),
|
||||
loopEnd(-1),
|
||||
legacyRate(32000),
|
||||
depth(DIV_SAMPLE_DEPTH_16BIT),
|
||||
loop(false),
|
||||
brrEmphasis(true),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue