dummy: more work

This commit is contained in:
tildearrow 2021-06-09 00:10:23 -05:00
parent 7745913722
commit 480ddf489a
2 changed files with 10 additions and 3 deletions

View file

@ -6,7 +6,8 @@ void DivPlatformDummy::acquire(int& l, int& r) {
l=0; l=0;
for (unsigned char i=0; i<chans; i++) { for (unsigned char i=0; i<chans; i++) {
if (chan[i].active) { if (chan[i].active) {
l+=((chan[i].pos>=0x8000)?chan[i].vol:-chan[i].vol)<<5; l+=((chan[i].pos>=0x8000)?chan[i].vol:-chan[i].vol)*chan[i].amp;
chan[i].pos+=chan[i].freq; chan[i].pos+=chan[i].freq;
} }
} }
@ -14,20 +15,25 @@ void DivPlatformDummy::acquire(int& l, int& r) {
} }
void DivPlatformDummy::tick() { void DivPlatformDummy::tick() {
for (unsigned char i=0; i<chans; i++) {
chan[i].amp--;
if (chan[i].amp<0) chan[i].amp=0;
}
} }
int DivPlatformDummy::dispatch(DivCommand c) { int DivPlatformDummy::dispatch(DivCommand c) {
printf("command: %d %d %d %d\n",c.cmd,c.chan,c.value,c.value2);
switch (c.cmd) { switch (c.cmd) {
case DIV_CMD_NOTE_ON: case DIV_CMD_NOTE_ON:
chan[c.chan].freq=16.4f*pow(2.0f,((float)c.value/12.0f)); chan[c.chan].freq=16.4f*pow(2.0f,((float)c.value/12.0f));
chan[c.chan].active=true; chan[c.chan].active=true;
chan[c.chan].amp=64;
break; break;
case DIV_CMD_NOTE_OFF: case DIV_CMD_NOTE_OFF:
chan[c.chan].active=false; chan[c.chan].active=false;
break; break;
case DIV_CMD_VOLUME: case DIV_CMD_VOLUME:
chan[c.chan].vol=c.value; chan[c.chan].vol=c.value;
if (chan[c.chan].vol>15) chan[c.chan].vol=15;
break; break;
case DIV_CMD_GET_VOLUME: case DIV_CMD_GET_VOLUME:
return chan[c.chan].vol; return chan[c.chan].vol;

View file

@ -8,7 +8,8 @@ class DivPlatformDummy: public DivDispatch {
unsigned short pos; unsigned short pos;
bool active; bool active;
unsigned char vol; unsigned char vol;
Channel(): freq(0), pos(0), active(false), vol(0) {} signed char amp;
Channel(): freq(0), pos(0), active(false), vol(0), amp(64) {}
}; };
Channel chan[17]; Channel chan[17];
unsigned char chans; unsigned char chans;