From d47a59f5f01c9451aa22b8709b1083c78010f292 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 15 Apr 2022 03:37:16 -0500 Subject: [PATCH] implement pitch macro TODO: test! --- TODO.md | 2 -- src/engine/macroInt.h | 2 ++ src/engine/platform/amiga.cpp | 6 +++++- src/engine/platform/arcade.cpp | 2 +- src/engine/platform/ay.cpp | 2 +- src/engine/platform/ay8930.cpp | 2 +- src/engine/platform/bubsyswsg.cpp | 2 +- src/engine/platform/c64.cpp | 2 +- src/engine/platform/fds.cpp | 4 ++-- src/engine/platform/gb.cpp | 3 ++- src/engine/platform/genesis.cpp | 2 +- src/engine/platform/lynx.cpp | 2 +- src/engine/platform/mmc5.cpp | 2 +- src/engine/platform/n163.cpp | 2 +- src/engine/platform/nes.cpp | 2 +- src/engine/platform/opl.cpp | 2 +- src/engine/platform/opll.cpp | 2 +- src/engine/platform/pce.cpp | 2 +- src/engine/platform/pcspkr.cpp | 2 +- src/engine/platform/pet.cpp | 2 +- src/engine/platform/qsound.cpp | 2 +- src/engine/platform/saa.cpp | 2 +- src/engine/platform/segapcm.cpp | 2 +- src/engine/platform/sms.cpp | 4 ++-- src/engine/platform/swan.cpp | 2 +- src/engine/platform/tia.cpp | 6 +++--- src/engine/platform/tx81z.cpp | 2 +- src/engine/platform/vera.cpp | 4 ++-- src/engine/platform/vic20.cpp | 2 +- src/engine/platform/vrc6.cpp | 4 ++-- src/engine/platform/x1_010.cpp | 2 +- src/engine/platform/ym2610.cpp | 2 +- src/engine/platform/ym2610b.cpp | 2 +- 33 files changed, 44 insertions(+), 39 deletions(-) diff --git a/TODO.md b/TODO.md index 22efa331b..d9817937e 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,6 @@ - panning macro - pitch macro -- phase reset macro - piano/input pad - note input via piano - input pad @@ -41,7 +40,6 @@ - add ability to select a column by double clicking - add ability to move selection by dragging - NSFPlay core for NES -- option for standard waveform names in OPL - settings: OK/Cancel buttons should be always visible - Apply button in settings - better FM chip names (number and codename) diff --git a/src/engine/macroInt.h b/src/engine/macroInt.h index 3c26eb659..5dc30aa06 100644 --- a/src/engine/macroInt.h +++ b/src/engine/macroInt.h @@ -31,6 +31,8 @@ struct DivMacroStruct { void init() { pos=mode=0; has=had=will=false; + // TODO: test whether this breaks anything? + val=0; } void prepare(DivInstrumentMacro& source) { has=had=will=true; diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index ff938e9b8..d0b1f4417 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -195,6 +195,9 @@ void DivPlatformAmiga::tick() { if (chan[i].useWave && chan[i].active) { chan[i].ws.tick(); } + if (chan[i].std.pitch.had) { + chan[i].freqChanged=true; + } if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.val==1) { chan[i].audPos=0; @@ -202,8 +205,9 @@ void DivPlatformAmiga::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { //DivInstrument* ins=parent->getIns(chan[i].ins); - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>4095) chan[i].freq=4095; + if (chan[i].freq<0) chan[i].freq=0; if (chan[i].keyOn) { } if (chan[i].keyOff) { diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 061f40c67..3885619b1 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -406,7 +406,7 @@ void DivPlatformArcade::tick() { for (int i=0; i<8; i++) { if (chan[i].freqChanged) { - chan[i].freq=chan[i].baseFreq+(chan[i].pitch>>1)-64; + chan[i].freq=chan[i].baseFreq+(chan[i].pitch>>1)-64+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>=(95<<6)) chan[i].freq=(95<<6)-1; immWrite(i+0x28,hScale(chan[i].freq>>6)); diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index a33902efc..f096b1e6c 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -236,7 +236,7 @@ void DivPlatformAY8910::tick() { if (!chan[i].std.ex3.will) chan[i].autoEnvNum=1; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>4095) chan[i].freq=4095; if (chan[i].keyOn) { //rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63))); diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index c32957d71..8237876b9 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -258,7 +258,7 @@ void DivPlatformAY8930::tick() { immWrite(0x1a,ayNoiseOr); } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>65535) chan[i].freq=65535; if (chan[i].keyOn) { if (chan[i].insChanged) { diff --git a/src/engine/platform/bubsyswsg.cpp b/src/engine/platform/bubsyswsg.cpp index 712496c1c..2c2bebbd3 100644 --- a/src/engine/platform/bubsyswsg.cpp +++ b/src/engine/platform/bubsyswsg.cpp @@ -117,7 +117,7 @@ void DivPlatformBubSysWSG::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { //DivInstrument* ins=parent->getIns(chan[i].ins); - chan[i].freq=0x1000-parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=0x1000-parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>4095) chan[i].freq=4095; k005289->load(i,chan[i].freq); diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index f8b014c8a..d230c1402 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -194,7 +194,7 @@ void DivPlatformC64::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8)+chan[i].std.pitch.val; if (chan[i].freq>0xffff) chan[i].freq=0xffff; if (chan[i].keyOn) { rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index 9960a0d74..e039e38a6 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -184,7 +184,7 @@ void DivPlatformFDS::tick() { } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false)+chan[i].std.pitch.val; if (chan[i].freq>4095) chan[i].freq=4095; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].keyOn) { @@ -439,7 +439,7 @@ void DivPlatformFDS::setFlags(unsigned int flags) { } void DivPlatformFDS::notifyInsDeletion(void* ins) { - for (int i=0; i<5; i++) { + for (int i=0; i<1; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); } } diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index 56a8fa45e..a84173189 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -219,8 +219,9 @@ void DivPlatformGB::tick() { if (ntPos>255) ntPos=255; chan[i].freq=noiseTable[ntPos]; } else { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>2047) chan[i].freq=2047; + if (chan[i].freq<0) chan[i].freq=0; } if (chan[i].keyOn) { if (i==2) { // wave diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 03288a37e..aacc31243 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -387,7 +387,7 @@ void DivPlatformGenesis::tick() { if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>262143) chan[i].freq=262143; - int freqt=toFreq(chan[i].freq); + int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val; immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8); immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff); if (chan[i].furnaceDac && dacMode) { diff --git a/src/engine/platform/lynx.cpp b/src/engine/platform/lynx.cpp index 70e7bc413..9ef121594 100644 --- a/src/engine/platform/lynx.cpp +++ b/src/engine/platform/lynx.cpp @@ -177,7 +177,7 @@ void DivPlatformLynx::tick() { WRITE_OTHER(i, ((chan[i].lfsr&0xf00)>>4)); chan[i].lfsr=-1; } - chan[i].fd=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].fd=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].std.duty.had) { chan[i].duty=chan[i].std.duty.val; WRITE_FEEDBACK(i, chan[i].duty.feedback); diff --git a/src/engine/platform/mmc5.cpp b/src/engine/platform/mmc5.cpp index 28706ce6e..e23e242bd 100644 --- a/src/engine/platform/mmc5.cpp +++ b/src/engine/platform/mmc5.cpp @@ -130,7 +130,7 @@ void DivPlatformMMC5::tick() { } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1; + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; if (chan[i].freq>2047) chan[i].freq=2047; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].keyOn) { diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index b7234a4ba..5de55ef0b 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -344,7 +344,7 @@ void DivPlatformN163::tick() { chan[i].waveUpdated=false; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq((((chan[i].baseFreq*chan[i].waveLen)*(chanMax+1))/16),chan[i].pitch,false,0); + chan[i].freq=parent->calcFreq((((chan[i].baseFreq*chan[i].waveLen)*(chanMax+1))/16),chan[i].pitch,false,0)+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>0x3ffff) chan[i].freq=0x3ffff; if (chan[i].keyOn) { diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index 89467a88f..532f9f23c 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -214,7 +214,7 @@ void DivPlatformNES::tick() { if (ntPos>252) ntPos=252; chan[i].freq=(parent->song.properNoiseLayout)?(15-(chan[i].baseFreq&15)):(noiseTable[ntPos]); } else { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1; + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; if (chan[i].freq>2047) chan[i].freq=2047; if (chan[i].freq<0) chan[i].freq=0; } diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 9f77350c5..006afc472 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -411,7 +411,7 @@ void DivPlatformOPL::tick() { if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>131071) chan[i].freq=131071; - int freqt=toFreq(chan[i].freq); + int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val; chan[i].freqH=freqt>>8; chan[i].freqL=freqt&0xff; immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL); diff --git a/src/engine/platform/opll.cpp b/src/engine/platform/opll.cpp index 617972764..479fce455 100644 --- a/src/engine/platform/opll.cpp +++ b/src/engine/platform/opll.cpp @@ -259,7 +259,7 @@ void DivPlatformOPLL::tick() { if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>262143) chan[i].freq=262143; - int freqt=toFreq(chan[i].freq); + int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val; chan[i].freqL=freqt&0xff; if (i>=6 && properDrums) { immWrite(0x10+drumSlot[i],freqt&0xff); diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index 7a601ca59..f41e32008 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -203,7 +203,7 @@ void DivPlatformPCE::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { //DivInstrument* ins=parent->getIns(chan[i].ins); - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].furnaceDac) { double off=1.0; if (chan[i].dacSample>=0 && chan[i].dacSamplesong.sampleLen) { diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index ee6ba7ef8..c20687300 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -187,7 +187,7 @@ void DivPlatformPCSpeaker::tick() { } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1; + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>65535) chan[i].freq=65535; if (chan[i].keyOn) { diff --git a/src/engine/platform/pet.cpp b/src/engine/platform/pet.cpp index e46277e0a..22eee4578 100644 --- a/src/engine/platform/pet.cpp +++ b/src/engine/platform/pet.cpp @@ -113,7 +113,7 @@ void DivPlatformPET::tick() { } } if (chan.freqChanged || chan.keyOn || chan.keyOff) { - chan.freq=parent->calcFreq(chan.baseFreq,chan.pitch,true); + chan.freq=parent->calcFreq(chan.baseFreq,chan.pitch,true)+chan.std.pitch.val; if (chan.freq>257) chan.freq=257; if (chan.freq<2) chan.freq=2; rWrite(8,chan.freq-2); diff --git a/src/engine/platform/qsound.cpp b/src/engine/platform/qsound.cpp index 0fd25ec72..ef443e5e6 100644 --- a/src/engine/platform/qsound.cpp +++ b/src/engine/platform/qsound.cpp @@ -328,7 +328,7 @@ void DivPlatformQSound::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { //DivInstrument* ins=parent->getIns(chan[i].ins); - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false)+chan[i].std.pitch.val; if (chan[i].freq>0xffff) chan[i].freq=0xffff; if (chan[i].keyOn) { rWrite(q1_reg_map[Q1V_BANK][i], qsound_bank); diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index 708fbc7ab..4a9e1d580 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -171,7 +171,7 @@ void DivPlatformSAA1099::tick() { rWrite(0x18+(i/3),saaEnv[i/3]); } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>65535) chan[i].freq=65535; if (chan[i].freq>=32768) { chan[i].freqH=7; diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index 84ec00c37..2abdcd463 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -113,7 +113,7 @@ void DivPlatformSegaPCM::tick() { DivSample* s=parent->getSample(chan[i].pcm.sample); off=(double)s->centerRate/8363.0; } - chan[i].pcm.freq=MIN(255,(15625+(off*parent->song.tuning*pow(2.0,double(chan[i].freq+256)/(64.0*12.0)))*255)/31250); + chan[i].pcm.freq=MIN(255,(15625+(off*parent->song.tuning*pow(2.0,double(chan[i].freq+256)/(64.0*12.0)))*255)/31250)+chan[i].std.pitch.val; if (dumpWrites) { addWrite(0x10007+(i<<3),chan[i].pcm.freq); } diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index 528901f0f..60361dd83 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -101,7 +101,7 @@ void DivPlatformSMS::tick() { } for (int i=0; i<3; i++) { if (chan[i].freqChanged) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (chan[i].freq>1023) chan[i].freq=1023; if (chan[i].freq<8) chan[i].freq=1; //if (chan[i].actualNote>0x5d) chan[i].freq=0x01; @@ -117,7 +117,7 @@ void DivPlatformSMS::tick() { } if (chan[3].freqChanged || updateSNMode) { // seems arbitrary huh? - chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch-1-(isRealSN?127:0),true); + chan[3].freq=parent->calcFreq(chan[3].baseFreq,chan[3].pitch-1-(isRealSN?127:0),true)+chan[3].std.pitch.val; if (chan[3].freq>1023) chan[3].freq=1023; if (chan[3].actualNote>0x5d) chan[3].freq=0x01; if (snNoiseMode&2) { // take period from channel 3 diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index 802f27b86..563606a94 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -180,7 +180,7 @@ void DivPlatformSwan::tick() { } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (i==1 && pcm && furnaceDac) { double off=1.0; if (dacSample>=0 && dacSamplesong.sampleLen) { diff --git a/src/engine/platform/tia.cpp b/src/engine/platform/tia.cpp index e06c5c74f..1e6f84879 100644 --- a/src/engine/platform/tia.cpp +++ b/src/engine/platform/tia.cpp @@ -124,14 +124,14 @@ void DivPlatformTIA::tick() { } chan[i].insChanged=false; } - chan[i].freq=dealWithFreq(chan[i].shape,chan[i].baseFreq,chan[i].pitch); + chan[i].freq=dealWithFreq(chan[i].shape,chan[i].baseFreq,chan[i].pitch)+chan[i].std.pitch.val; if ((chan[i].shape==4 || chan[i].shape==5) && !(chan[i].baseFreq&0x80000000 && ((chan[i].baseFreq&0x7fffffff)<32))) { if (chan[i].baseFreq<39*256) { rWrite(0x15+i,6); - chan[i].freq=dealWithFreq(6,chan[i].baseFreq,chan[i].pitch); + chan[i].freq=dealWithFreq(6,chan[i].baseFreq,chan[i].pitch)+chan[i].std.pitch.val; } else if (chan[i].baseFreq<59*256) { rWrite(0x15+i,12); - chan[i].freq=dealWithFreq(12,chan[i].baseFreq,chan[i].pitch); + chan[i].freq=dealWithFreq(12,chan[i].baseFreq,chan[i].pitch)+chan[i].std.pitch.val; } else { rWrite(0x15+i,chan[i].shape); } diff --git a/src/engine/platform/tx81z.cpp b/src/engine/platform/tx81z.cpp index 8cbfa039b..d50830e71 100644 --- a/src/engine/platform/tx81z.cpp +++ b/src/engine/platform/tx81z.cpp @@ -387,7 +387,7 @@ void DivPlatformTX81Z::tick() { for (int i=0; i<8; i++) { if (chan[i].freqChanged) { - chan[i].freq=chan[i].baseFreq+(chan[i].pitch>>1)-64; + chan[i].freq=chan[i].baseFreq+(chan[i].pitch>>1)-64+chan[i].std.pitch.val; if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>=(95<<6)) chan[i].freq=(95<<6)-1; immWrite(i+0x28,hScale(chan[i].freq>>6)); diff --git a/src/engine/platform/vera.cpp b/src/engine/platform/vera.cpp index 593c1a0c7..0c0b3f71e 100644 --- a/src/engine/platform/vera.cpp +++ b/src/engine/platform/vera.cpp @@ -184,7 +184,7 @@ void DivPlatformVERA::tick() { rWriteHi(i,3,chan[i].std.wave.val); } if (chan[i].freqChanged) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8)+chan[i].std.pitch.val; if (chan[i].freq>65535) chan[i].freq=65535; rWrite(i,0,chan[i].freq&0xff); rWrite(i,1,(chan[i].freq>>8)&0xff); @@ -213,7 +213,7 @@ void DivPlatformVERA::tick() { } } if (chan[16].freqChanged) { - chan[16].freq=parent->calcFreq(chan[16].baseFreq,chan[16].pitch,false,8); + chan[16].freq=parent->calcFreq(chan[16].baseFreq,chan[16].pitch,false,8)+chan[16].std.pitch.val; if (chan[16].freq>128) chan[16].freq=128; rWritePCMRate(chan[16].freq&0xff); chan[16].freqChanged=false; diff --git a/src/engine/platform/vic20.cpp b/src/engine/platform/vic20.cpp index b45fecfc3..29ce7106b 100644 --- a/src/engine/platform/vic20.cpp +++ b/src/engine/platform/vic20.cpp @@ -120,7 +120,7 @@ void DivPlatformVIC20::tick() { } } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)+chan[i].std.pitch.val; if (i<3) { chan[i].freq>>=(2-i); } else { diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index 31694a62c..0342bd67c 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -180,9 +180,9 @@ void DivPlatformVRC6::tick() { } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { if (i==2) { // sawtooth - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1; + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; } else { // pulse - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1; + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true)-1+chan[i].std.pitch.val; if (chan[i].furnaceDac) { double off=1.0; if (chan[i].dacSample>=0 && chan[i].dacSamplesong.sampleLen) { diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index 124e0ace6..02632b874 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -463,7 +463,7 @@ void DivPlatformX1_010::tick() { chan[i].envChanged=false; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { - chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false); + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false)+chan[i].std.pitch.val; if (chan[i].pcm) { if (chan[i].freq<1) chan[i].freq=1; if (chan[i].freq>255) chan[i].freq=255; diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 3098c935b..c52b34281 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -565,7 +565,7 @@ void DivPlatformYM2610::tick() { if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>262143) chan[i].freq=262143; - int freqt=toFreq(chan[i].freq); + int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val; immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8); immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff); chan[i].freqChanged=false; diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index b28852e43..ade5a9d80 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -628,7 +628,7 @@ void DivPlatformYM2610B::tick() { if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)); if (chan[i].freq>262143) chan[i].freq=262143; - int freqt=toFreq(chan[i].freq); + int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val; immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8); immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff); chan[i].freqChanged=false;