add some basic playback code!
here it begins
This commit is contained in:
parent
4a08adf224
commit
a68f8d0dec
6 changed files with 103 additions and 9 deletions
|
|
@ -5,10 +5,13 @@ void DivDispatch::acquire(short& l, short& r) {
|
|||
r=0;
|
||||
}
|
||||
|
||||
void DivDispatch::tick() {
|
||||
}
|
||||
|
||||
int DivDispatch::dispatch(DivCommand c) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DivDispatch::init(DivEngine* p, int channels, int sugRate) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,42 @@
|
|||
#include "dummy.h"
|
||||
#include <math.h>
|
||||
|
||||
void DivPlatformDummy::acquire(short& l, short& r) {
|
||||
l=0;
|
||||
r=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() {
|
||||
for (unsigned char i=0; i<chans; i++) {
|
||||
chan[i].vol=chan[i].vol-(chan[i].vol>>3);
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformDummy::dispatch(DivCommand c) {
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON:
|
||||
chan[c.chan].vol=0x7f;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DivPlatformDummy::init(DivEngine* p, int channels, int sugRate) {
|
||||
parent=p;
|
||||
rate=sugRate;
|
||||
rate=65536;
|
||||
chans=channels;
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,18 @@
|
|||
// the dummy platform outputs square waves, interprets STD instruments and plays samples.
|
||||
// used when a DivDispatch for a system is not found.
|
||||
class DivPlatformDummy: public DivDispatch {
|
||||
struct Channel {
|
||||
unsigned short freq;
|
||||
unsigned short pos;
|
||||
bool active;
|
||||
unsigned char vol;
|
||||
Channel(): freq(0), pos(0), active(false), vol(0) {}
|
||||
};
|
||||
Channel chan[17];
|
||||
unsigned char chans;
|
||||
public:
|
||||
void acquire(short& l, short& r);
|
||||
int dispatch(DivCommand c);
|
||||
void tick();
|
||||
int init(DivEngine* parent, int channels, int sugRate);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue