PCE: kind of implement LFO

This commit is contained in:
tildearrow 2021-06-09 01:08:42 -05:00
parent 480ddf489a
commit 99e59278ad
5 changed files with 37 additions and 4 deletions

View file

@ -18,13 +18,19 @@ void DivPlatformDummy::tick() {
for (unsigned char i=0; i<chans; i++) {
chan[i].amp--;
if (chan[i].amp<0) chan[i].amp=0;
if (chan[i].freqChanged) {
chan[i].freqChanged=false;
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE+chan[i].pitch))/ONE_SEMITONE;
}
}
}
int DivPlatformDummy::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON:
chan[c.chan].freq=16.4f*pow(2.0f,((float)c.value/12.0f));
chan[c.chan].baseFreq=16.4f*pow(2.0f,((float)c.value/12.0f));
chan[c.chan].freqChanged=true;
chan[c.chan].active=true;
chan[c.chan].amp=64;
break;
@ -38,6 +44,14 @@ int DivPlatformDummy::dispatch(DivCommand c) {
case DIV_CMD_GET_VOLUME:
return chan[c.chan].vol;
break;
case DIV_CMD_PITCH:
chan[c.chan].pitch=c.value;
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_LEGATO:
chan[c.chan].baseFreq=16.4f*pow(2.0f,((float)c.value/12.0f));
chan[c.chan].freqChanged=true;
break;
case DIV_CMD_GET_VOLMAX:
return 15;
break;

View file

@ -4,12 +4,13 @@
// used when a DivDispatch for a system is not found.
class DivPlatformDummy: public DivDispatch {
struct Channel {
unsigned short freq;
unsigned short freq, baseFreq;
short pitch;
unsigned short pos;
bool active;
bool active, freqChanged;
unsigned char vol;
signed char amp;
Channel(): freq(0), pos(0), active(false), vol(0), amp(64) {}
Channel(): freq(0), baseFreq(0), pitch(0), pos(0), active(false), freqChanged(false), vol(0), amp(64) {}
};
Channel chan[17];
unsigned char chans;

View file

@ -186,6 +186,12 @@ int DivPlatformPCE::dispatch(DivCommand c) {
updateWave(c.chan);
chan[c.chan].keyOn=true;
break;
case DIV_CMD_PCE_LFO_MODE:
rWrite(0x09,c.value);
break;
case DIV_CMD_PCE_LFO_SPEED:
rWrite(0x08,c.value);
break;
case DIV_CMD_NOTE_PORTA: {
int destFreq=round(FREQ_BASE/pow(2.0f,((float)c.value2/12.0f)));
bool return2=false;