X1-010: implement linear pitch (part 6)

This commit is contained in:
tildearrow 2022-05-11 00:18:46 -05:00
parent 90ac64f1d4
commit ea118db499

View file

@ -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) { double DivPlatformX1_010::NoteX1_010(int ch, int note) {
if (chan[ch].pcm) { // PCM note if (chan[ch].pcm) { // PCM note
double off=1.0; double off=8192.0;
int sample=chan[ch].sample; int sample=chan[ch].sample;
if (sample>=0 && sample<parent->song.sampleLen) { if (sample>=0 && sample<parent->song.sampleLen) {
DivSample* s=parent->getSample(sample); DivSample* s=parent->getSample(sample);
if (s->centerRate<1) { if (s->centerRate<1) {
off=1.0; off=8192.0;
} else { } 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 // Wavetable note
return NOTE_FREQUENCY(note); return NOTE_FREQUENCY(note);
@ -488,7 +487,19 @@ void DivPlatformX1_010::tick(bool sysTick) {
chan[i].envChanged=false; chan[i].envChanged=false;
} }
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { 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 && sample<parent->song.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].pcm) {
if (chan[i].freq<1) chan[i].freq=1; if (chan[i].freq<1) chan[i].freq=1;
if (chan[i].freq>255) chan[i].freq=255; if (chan[i].freq>255) chan[i].freq=255;