implement the linear pitch flag

This commit is contained in:
tildearrow 2022-02-03 02:24:11 -05:00
parent d638af2017
commit 5086bc1097
6 changed files with 8 additions and 8 deletions

View file

@ -4748,7 +4748,7 @@ int DivEngine::calcBaseFreq(double clock, double divider, int note, bool period)
base*(divider/clock);
}
int DivEngine::calcFreq(int base, int pitch, bool period) {
int DivEngine::calcFreq(int base, int pitch, bool period, int octave) {
if (song.linearPitch) {
return period?
int(base*pow(2,-(double)pitch/(12.0*128.0))/(98.0+globalPitch*6.0)*98.0):
@ -4756,7 +4756,7 @@ int DivEngine::calcFreq(int base, int pitch, bool period) {
}
return period?
base-pitch:
base+pitch;
base+((pitch*octave)>>1);
}
void DivEngine::play() {

View file

@ -266,7 +266,7 @@ class DivEngine {
int calcBaseFreq(double clock, double divider, int note, bool period);
// calculate frequency/period
int calcFreq(int base, int pitch, bool period=false);
int calcFreq(int base, int pitch, bool period=false, int octave=0);
// find song loop position
void walkSong(int& loopOrder, int& loopRow, int& loopEnd);

View file

@ -111,7 +111,7 @@ void DivPlatformC64::tick() {
rWrite(i*7+4,(isMuted[i]?0:(chan[i].wave<<4))|(chan[i].ring<<2)|(chan[i].sync<<1)|chan[i].active);
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8);
if (chan[i].freq>0xffff) chan[i].freq=0xffff;
if (chan[i].keyOn) {
rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));

View file

@ -294,7 +294,7 @@ void DivPlatformGenesis::tick() {
for (int i=0; i<6; i++) {
if (i==2 && extMode) continue;
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
int freqt=toFreq(chan[i].freq);
immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8);
immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff);

View file

@ -266,7 +266,7 @@ void DivPlatformYM2610::tick() {
for (int i=0; i<4; i++) {
if (i==1 && extMode) continue;
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
int freqt=toFreq(chan[i].freq);
immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8);
immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff);

View file

@ -537,7 +537,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
chan[i].portaSpeed=-1;
chan[i].inPorta=false;
} else {
chan[i].portaNote=0x60;
chan[i].portaNote=song.limitSlides?0x60:255;
chan[i].portaSpeed=effectVal;
chan[i].portaStop=true;
chan[i].nowYouCanStop=false;
@ -552,7 +552,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
chan[i].portaSpeed=-1;
chan[i].inPorta=false;
} else {
chan[i].portaNote=disCont[dispatchOfChan[i]].dispatch->getPortaFloor(dispatchChanOfChan[i]);
chan[i].portaNote=song.limitSlides?disCont[dispatchOfChan[i]].dispatch->getPortaFloor(dispatchChanOfChan[i]):-255;
chan[i].portaSpeed=effectVal;
chan[i].portaStop=true;
chan[i].nowYouCanStop=false;