furnace/src/engine/platform/dummy.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

#include "dummy.h"
2021-05-17 05:36:09 +00:00
#include <stdio.h>
#include <math.h>
void DivPlatformDummy::acquire(int& l, int& r) {
l=0;
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() {
}
int DivPlatformDummy::dispatch(DivCommand c) {
2021-05-17 05:36:09 +00:00
printf("command: %d %d %d %d\n",c.cmd,c.chan,c.value,c.value2);
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;
case DIV_CMD_GET_VOLUME:
return chan[c.chan].vol;
break;
case DIV_CMD_GET_VOLMAX:
return 15;
break;
default:
break;
}
return 1;
}
int DivPlatformDummy::init(DivEngine* p, int channels, int sugRate) {
parent=p;
rate=65536;
chans=channels;
2021-05-12 22:19:18 +00:00
for (int i=0; i<chans; i++) {
chan[i].vol=0x0f;
}
return channels;
}