2021-05-12 08:58:55 +00:00
|
|
|
#ifndef _DISPATCH_H
|
|
|
|
#define _DISPATCH_H
|
|
|
|
|
2021-05-16 08:03:23 +00:00
|
|
|
#define ONE_SEMITONE 2200
|
|
|
|
|
2021-05-11 20:08:08 +00:00
|
|
|
enum DivDispatchCmds {
|
|
|
|
DIV_CMD_NOTE_ON=0,
|
|
|
|
DIV_CMD_NOTE_OFF,
|
|
|
|
DIV_CMD_INSTRUMENT,
|
|
|
|
DIV_CMD_VOLUME,
|
2021-05-17 08:06:45 +00:00
|
|
|
DIV_CMD_GET_VOLUME,
|
2021-05-17 20:06:11 +00:00
|
|
|
DIV_CMD_GET_VOLMAX,
|
2021-05-14 08:23:40 +00:00
|
|
|
DIV_CMD_NOTE_PORTA,
|
|
|
|
DIV_CMD_PITCH,
|
2021-05-13 07:39:26 +00:00
|
|
|
DIV_CMD_PANNING,
|
2021-05-15 08:13:21 +00:00
|
|
|
DIV_CMD_LEGATO,
|
2021-05-17 06:51:14 +00:00
|
|
|
DIV_CMD_PRE_PORTA,
|
2021-05-13 07:39:26 +00:00
|
|
|
|
2021-05-15 08:13:21 +00:00
|
|
|
DIV_CMD_SAMPLE_MODE,
|
|
|
|
|
|
|
|
DIV_CMD_FM_TL,
|
|
|
|
DIV_CMD_FM_AR,
|
|
|
|
DIV_CMD_FM_FB,
|
|
|
|
DIV_CMD_FM_MULT,
|
|
|
|
DIV_CMD_FM_EXTCH,
|
|
|
|
|
|
|
|
DIV_CMD_GENESIS_LFO,
|
|
|
|
|
|
|
|
DIV_CMD_ARCADE_LFO,
|
|
|
|
|
|
|
|
DIV_CMD_STD_NOISE_FREQ,
|
2021-05-19 07:05:24 +00:00
|
|
|
DIV_CMD_STD_NOISE_MODE,
|
|
|
|
|
|
|
|
DIV_CMD_MAX
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DivCommand {
|
|
|
|
DivDispatchCmds cmd;
|
2021-05-14 19:16:48 +00:00
|
|
|
unsigned char chan;
|
|
|
|
int value, value2;
|
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch, int val, int val2):
|
2021-05-12 10:22:01 +00:00
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
2021-05-14 19:16:48 +00:00
|
|
|
value(val),
|
|
|
|
value2(val2) {}
|
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch, int val):
|
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
|
|
|
value(val),
|
|
|
|
value2(0) {}
|
2021-05-12 10:22:01 +00:00
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch):
|
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
2021-05-14 19:16:48 +00:00
|
|
|
value(0),
|
|
|
|
value2(0) {}
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DivDelayedCommand {
|
|
|
|
int ticks;
|
|
|
|
DivCommand cmd;
|
|
|
|
};
|
|
|
|
|
2021-05-12 08:58:55 +00:00
|
|
|
class DivEngine;
|
|
|
|
|
2021-05-11 20:08:08 +00:00
|
|
|
class DivDispatch {
|
2021-05-12 08:58:55 +00:00
|
|
|
protected:
|
|
|
|
DivEngine* parent;
|
2021-05-11 20:08:08 +00:00
|
|
|
public:
|
2021-05-12 08:58:55 +00:00
|
|
|
/**
|
|
|
|
* the rate the samples are provided.
|
|
|
|
* the engine shall resample to the output rate.
|
|
|
|
*/
|
|
|
|
int rate;
|
2021-05-16 08:03:23 +00:00
|
|
|
virtual void acquire(int& l, int& r);
|
2021-05-11 20:08:08 +00:00
|
|
|
virtual int dispatch(DivCommand c);
|
2021-05-12 10:22:01 +00:00
|
|
|
virtual void tick();
|
2021-05-11 20:08:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize this DivDispatch.
|
2021-05-12 08:58:55 +00:00
|
|
|
* @param parent the parent DivEngine.
|
2021-05-11 20:08:08 +00:00
|
|
|
* @param channels the number of channels to acquire.
|
2021-05-12 08:58:55 +00:00
|
|
|
* @param sugRate the suggested rate. this may change, so don't rely on it.
|
2021-05-11 20:08:08 +00:00
|
|
|
* @return the number of channels allocated.
|
|
|
|
*/
|
2021-05-12 08:58:55 +00:00
|
|
|
virtual int init(DivEngine* parent, int channels, int sugRate);
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
2021-05-12 10:22:01 +00:00
|
|
|
#endif
|