2021-05-12 08:58:55 +00:00
|
|
|
#include "dummy.h"
|
2021-05-12 10:22:01 +00:00
|
|
|
#include <math.h>
|
2021-05-12 08:58:55 +00:00
|
|
|
|
2021-05-16 08:03:23 +00:00
|
|
|
void DivPlatformDummy::acquire(int& l, int& r) {
|
2021-05-12 08:58:55 +00:00
|
|
|
l=0;
|
2021-05-12 10:22:01 +00:00
|
|
|
for (unsigned char i=0; i<chans; i++) {
|
|
|
|
if (chan[i].active) {
|
|
|
|
l+=((chan[i].pos>=0x8000)?chan[i].vol:-chan[i].vol)<<5;
|
|
|
|
chan[i].pos+=chan[i].freq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
r=l;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DivPlatformDummy::tick() {
|
2021-05-12 08:58:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int DivPlatformDummy::dispatch(DivCommand c) {
|
2021-05-12 10:22:01 +00:00
|
|
|
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].active=true;
|
|
|
|
break;
|
|
|
|
case DIV_CMD_NOTE_OFF:
|
|
|
|
chan[c.chan].active=false;
|
|
|
|
break;
|
2021-05-12 22:19:18 +00:00
|
|
|
case DIV_CMD_VOLUME:
|
|
|
|
chan[c.chan].vol=c.value;
|
|
|
|
break;
|
2021-05-12 10:22:01 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-05-12 08:58:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DivPlatformDummy::init(DivEngine* p, int channels, int sugRate) {
|
|
|
|
parent=p;
|
2021-05-12 10:22:01 +00:00
|
|
|
rate=65536;
|
|
|
|
chans=channels;
|
2021-05-12 22:19:18 +00:00
|
|
|
for (int i=0; i<chans; i++) {
|
|
|
|
chan[i].vol=0x0f;
|
|
|
|
}
|
2021-05-12 08:58:55 +00:00
|
|
|
return channels;
|
2021-05-12 10:22:01 +00:00
|
|
|
}
|