From ea118db49984e16c640ec6d6cbdc31a7762b0d09 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 11 May 2022 00:18:46 -0500 Subject: [PATCH] X1-010: implement linear pitch (part 6) --- src/engine/platform/x1_010.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index 35226f50..f1711243 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -260,20 +260,19 @@ void DivPlatformX1_010::acquire(short* bufL, short* bufR, size_t start, size_t l } } -// TODO: linear pitch stuff double DivPlatformX1_010::NoteX1_010(int ch, int note) { if (chan[ch].pcm) { // PCM note - double off=1.0; + double off=8192.0; int sample=chan[ch].sample; if (sample>=0 && samplesong.sampleLen) { DivSample* s=parent->getSample(sample); if (s->centerRate<1) { - off=1.0; + off=8192.0; } else { - off=s->centerRate/8363.0; + off=8192.0*(s->centerRate/8363.0); } } - return off*parent->calcBaseFreq(chipClock,8192,note,false); + return parent->calcBaseFreq(chipClock,off,note,false); } // Wavetable note return NOTE_FREQUENCY(note); @@ -488,7 +487,19 @@ void DivPlatformX1_010::tick(bool sysTick) { 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,2,chan[i].pitch2,chipClock,CHIP_FREQBASE); + double off=8192.0; + if (chan[i].pcm) { + int sample=chan[i].sample; + if (sample>=0 && samplesong.sampleLen) { + DivSample* s=parent->getSample(sample); + if (s->centerRate<1) { + off=8192.0; + } else { + off=8192.0*(s->centerRate/8363.0); + } + } + } + chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,2,chan[i].pitch2,chipClock,chan[i].pcm?off:CHIP_FREQBASE); if (chan[i].pcm) { if (chan[i].freq<1) chan[i].freq=1; if (chan[i].freq>255) chan[i].freq=255;