OPL: fix fixed frequency drums

This commit is contained in:
tildearrow 2022-05-16 21:06:49 -05:00
parent 5a0c715ba0
commit 34d0925569
3 changed files with 8 additions and 5 deletions

View file

@ -1,6 +1,5 @@
# to-do for 0.6pre1
- fix an OPLL/OPL fixed drum freq regression caused by full linear pitch
- piano/input pad
- note input via piano
- input pad

View file

@ -595,6 +595,7 @@ void DivPlatformOPL::tick(bool sysTick) {
for (int i=0; i<totalChans; i++) {
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq),chan[i].pitch2,chipClock,CHIP_FREQBASE);
if (chan[i].fixedFreq>0) chan[i].freq=chan[i].fixedFreq;
if (chan[i].freq>131071) chan[i].freq=131071;
int freqt=toFreq(chan[i].freq)+chan[i].pitch2;
chan[i].freqH=freqt>>8;
@ -844,16 +845,18 @@ int DivPlatformOPL::dispatch(DivCommand c) {
if (c.value!=DIV_NOTE_NULL) {
if (c.chan>=melodicChans && chan[c.chan].state.opllPreset==16 && chan[c.chan].state.fixedDrums) { // drums
if (c.chan==melodicChans) {
chan[c.chan].baseFreq=(chan[c.chan].state.kickFreq&1023)<<(chan[c.chan].state.kickFreq>>10);
chan[c.chan].fixedFreq=(chan[c.chan].state.kickFreq&1023)<<(chan[c.chan].state.kickFreq>>10);
} else if (c.chan==melodicChans+1 || c.chan==melodicChans+4) {
chan[c.chan].baseFreq=(chan[c.chan].state.snareHatFreq&1023)<<(chan[c.chan].state.snareHatFreq>>10);
chan[c.chan].fixedFreq=(chan[c.chan].state.snareHatFreq&1023)<<(chan[c.chan].state.snareHatFreq>>10);
} else if (c.chan==melodicChans+2 || c.chan==melodicChans+3) {
chan[c.chan].baseFreq=(chan[c.chan].state.tomTopFreq&1023)<<(chan[c.chan].state.tomTopFreq>>10);
chan[c.chan].fixedFreq=(chan[c.chan].state.tomTopFreq&1023)<<(chan[c.chan].state.tomTopFreq>>10);
} else {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].fixedFreq=0;
}
} else {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].fixedFreq=0;
}
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;

View file

@ -40,7 +40,7 @@ class DivPlatformOPL: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note, ins, sample;
int freq, baseFreq, pitch, pitch2, note, ins, sample, fixedFreq;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnacePCM, inPorta, fourOp, hardReset;
int vol, outVol;
unsigned char pan;
@ -58,6 +58,7 @@ class DivPlatformOPL: public DivDispatch {
note(0),
ins(-1),
sample(-1),
fixedFreq(0),
active(false),
insChanged(true),
freqChanged(false),