better pitch slides
now digital warmth doesn't choke at the toms
This commit is contained in:
parent
79f15fcbd8
commit
26463fd8d9
|
@ -74,33 +74,9 @@ void DivPlatformGenesis::tick() {
|
||||||
if (i==2 && extMode) continue;
|
if (i==2 && extMode) continue;
|
||||||
if (chan[i].freqChanged) {
|
if (chan[i].freqChanged) {
|
||||||
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
|
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
|
||||||
if (chan[i].freq>=82432) {
|
int freqt=toFreq(chan[i].freq);
|
||||||
chan[i].freqH=((chan[i].freq>>15)&7)|0x38;
|
writes.emplace(chanOffs[i]+0xa4,freqt>>8);
|
||||||
chan[i].freqL=(chan[i].freq>>7)&0xff;
|
writes.emplace(chanOffs[i]+0xa0,freqt&0xff);
|
||||||
} else if (chan[i].freq>=41216) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>14)&7)|0x30;
|
|
||||||
chan[i].freqL=(chan[i].freq>>6)&0xff;
|
|
||||||
} else if (chan[i].freq>=20608) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>13)&7)|0x28;
|
|
||||||
chan[i].freqL=(chan[i].freq>>5)&0xff;
|
|
||||||
} else if (chan[i].freq>=10304) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>12)&7)|0x20;
|
|
||||||
chan[i].freqL=(chan[i].freq>>4)&0xff;
|
|
||||||
} else if (chan[i].freq>=5152) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>11)&7)|0x18;
|
|
||||||
chan[i].freqL=(chan[i].freq>>3)&0xff;
|
|
||||||
} else if (chan[i].freq>=2576) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>10)&7)|0x10;
|
|
||||||
chan[i].freqL=(chan[i].freq>>2)&0xff;
|
|
||||||
} else if (chan[i].freq>=1288) {
|
|
||||||
chan[i].freqH=((chan[i].freq>>9)&7)|0x08;
|
|
||||||
chan[i].freqL=(chan[i].freq>>1)&0xff;
|
|
||||||
} else {
|
|
||||||
chan[i].freqH=(chan[i].freq>>8)&7;
|
|
||||||
chan[i].freqL=chan[i].freq&0xff;
|
|
||||||
}
|
|
||||||
writes.emplace(chanOffs[i]+0xa4,chan[i].freqH);
|
|
||||||
writes.emplace(chanOffs[i]+0xa0,chan[i].freqL);
|
|
||||||
}
|
}
|
||||||
if (chan[i].keyOn) {
|
if (chan[i].keyOn) {
|
||||||
writes.emplace(0x28,0xf0|konOffs[i]);
|
writes.emplace(0x28,0xf0|konOffs[i]);
|
||||||
|
@ -132,6 +108,26 @@ int DivPlatformGenesis::octave(int freq) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DivPlatformGenesis::toFreq(int freq) {
|
||||||
|
if (freq>=82432) {
|
||||||
|
return 0x3800|((freq>>7)&0x7ff);
|
||||||
|
} else if (freq>=41216) {
|
||||||
|
return 0x3000|((freq>>6)&0x7ff);
|
||||||
|
} else if (freq>=20608) {
|
||||||
|
return 0x2800|((freq>>5)&0x7ff);
|
||||||
|
} else if (freq>=10304) {
|
||||||
|
return 0x2000|((freq>>4)&0x7ff);
|
||||||
|
} else if (freq>=5152) {
|
||||||
|
return 0x1800|((freq>>3)&0x7ff);
|
||||||
|
} else if (freq>=2576) {
|
||||||
|
return 0x1000|((freq>>2)&0x7ff);
|
||||||
|
} else if (freq>=1288) {
|
||||||
|
return 0x800|((freq>>1)&0x7ff);
|
||||||
|
} else {
|
||||||
|
return freq&0x7ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int DivPlatformGenesis::dispatch(DivCommand c) {
|
int DivPlatformGenesis::dispatch(DivCommand c) {
|
||||||
if (c.chan>5) {
|
if (c.chan>5) {
|
||||||
c.chan-=6;
|
c.chan-=6;
|
||||||
|
@ -237,20 +233,29 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
case DIV_CMD_NOTE_PORTA: {
|
case DIV_CMD_NOTE_PORTA: {
|
||||||
int destFreq=644.0f*pow(2.0f,((float)c.value2/12.0f));
|
int destFreq=644.0f*pow(2.0f,((float)c.value2/12.0f));
|
||||||
|
int newFreq;
|
||||||
bool return2=false;
|
bool return2=false;
|
||||||
if (destFreq>chan[c.chan].baseFreq) {
|
if (destFreq>chan[c.chan].baseFreq) {
|
||||||
chan[c.chan].baseFreq=chan[c.chan].baseFreq+c.value*octave(chan[c.chan].baseFreq);
|
newFreq=chan[c.chan].baseFreq+c.value*octave(chan[c.chan].baseFreq);
|
||||||
if (chan[c.chan].baseFreq>=destFreq) {
|
if (newFreq>=destFreq) {
|
||||||
chan[c.chan].baseFreq=destFreq;
|
newFreq=destFreq;
|
||||||
return2=true;
|
return2=true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chan[c.chan].baseFreq=chan[c.chan].baseFreq-c.value*octave(chan[c.chan].baseFreq);
|
newFreq=chan[c.chan].baseFreq-c.value*octave(chan[c.chan].baseFreq);
|
||||||
if (chan[c.chan].baseFreq<=destFreq) {
|
if (newFreq<=destFreq) {
|
||||||
chan[c.chan].baseFreq=destFreq;
|
newFreq=destFreq;
|
||||||
return2=true;
|
return2=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!chan[c.chan].portaPause) {
|
||||||
|
if (octave(chan[c.chan].baseFreq)!=octave(newFreq)) {
|
||||||
|
chan[c.chan].portaPause=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chan[c.chan].baseFreq=newFreq;
|
||||||
|
chan[c.chan].portaPause=false;
|
||||||
chan[c.chan].freqChanged=true;
|
chan[c.chan].freqChanged=true;
|
||||||
if (return2) return 2;
|
if (return2) return 2;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,10 +13,10 @@ class DivPlatformGenesis: public DivDispatch {
|
||||||
int freq, baseFreq, pitch;
|
int freq, baseFreq, pitch;
|
||||||
unsigned char ins;
|
unsigned char ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), vol(0), pan(3) {}
|
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
Channel chan[10];
|
Channel chan[10];
|
||||||
struct QueuedWrite {
|
struct QueuedWrite {
|
||||||
|
@ -45,6 +45,7 @@ class DivPlatformGenesis: public DivDispatch {
|
||||||
short pendingWrites[512];
|
short pendingWrites[512];
|
||||||
|
|
||||||
int octave(int freq);
|
int octave(int freq);
|
||||||
|
int toFreq(int freq);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void acquire(int& l, int& r);
|
void acquire(int& l, int& r);
|
||||||
|
|
|
@ -99,20 +99,29 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
|
||||||
}
|
}
|
||||||
case DIV_CMD_NOTE_PORTA: {
|
case DIV_CMD_NOTE_PORTA: {
|
||||||
int destFreq=644.0f*pow(2.0f,((float)c.value2/12.0f));
|
int destFreq=644.0f*pow(2.0f,((float)c.value2/12.0f));
|
||||||
|
int newFreq;
|
||||||
bool return2=false;
|
bool return2=false;
|
||||||
if (destFreq>opChan[ch].baseFreq) {
|
if (destFreq>opChan[ch].baseFreq) {
|
||||||
opChan[ch].baseFreq=opChan[ch].baseFreq+c.value*octave(opChan[ch].baseFreq);
|
newFreq=opChan[ch].baseFreq+c.value*octave(opChan[ch].baseFreq);
|
||||||
if (opChan[ch].baseFreq>=destFreq) {
|
if (newFreq>=destFreq) {
|
||||||
opChan[ch].baseFreq=destFreq;
|
newFreq=destFreq;
|
||||||
return2=true;
|
return2=true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
opChan[ch].baseFreq=opChan[ch].baseFreq-c.value*octave(opChan[ch].baseFreq);
|
newFreq=opChan[ch].baseFreq-c.value*octave(opChan[ch].baseFreq);
|
||||||
if (opChan[ch].baseFreq<=destFreq) {
|
if (newFreq<=destFreq) {
|
||||||
opChan[ch].baseFreq=destFreq;
|
newFreq=destFreq;
|
||||||
return2=true;
|
return2=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!opChan[ch].portaPause) {
|
||||||
|
if (octave(opChan[ch].baseFreq)!=octave(newFreq)) {
|
||||||
|
opChan[ch].portaPause=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opChan[ch].baseFreq=newFreq;
|
||||||
|
opChan[ch].portaPause=false;
|
||||||
opChan[ch].freqChanged=true;
|
opChan[ch].freqChanged=true;
|
||||||
if (return2) return 2;
|
if (return2) return 2;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -8,10 +8,10 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
|
||||||
int freq, baseFreq, pitch;
|
int freq, baseFreq, pitch;
|
||||||
unsigned char ins;
|
unsigned char ins;
|
||||||
signed char konCycles;
|
signed char konCycles;
|
||||||
bool active, insChanged, freqChanged, keyOn, keyOff;
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
|
||||||
int vol;
|
int vol;
|
||||||
unsigned char pan;
|
unsigned char pan;
|
||||||
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), vol(0), pan(3) {}
|
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
|
||||||
};
|
};
|
||||||
OpChannel opChan[4];
|
OpChannel opChan[4];
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue