furnace/src/engine/engine.h

84 lines
1.7 KiB
C
Raw Normal View History

#ifndef _ENGINE_H
#define _ENGINE_H
#include "song.h"
#include "dispatch.h"
#include "../audio/taAudio.h"
#include "blip_buf.h"
struct DivChannelState {
std::vector<DivDelayedCommand> delayed;
2021-05-14 08:23:40 +00:00
int note, pitch, portaSpeed, portaNote;
int volume, volSpeed;
int vibratoDepth, vibratoRate, vibratoPos;
int tremoloDepth, tremoloRate, tremoloPos;
bool doNote, legato;
2021-05-14 08:23:40 +00:00
DivChannelState():
note(-1),
pitch(0),
portaSpeed(-1),
portaNote(-1),
volume(0x7f00),
volSpeed(0),
vibratoDepth(0),
vibratoRate(0),
vibratoPos(0),
2021-05-14 08:23:40 +00:00
tremoloDepth(0),
tremoloRate(0),
tremoloPos(0),
doNote(false), legato(false) {}
};
class DivEngine {
DivDispatch* dispatch;
TAAudio* output;
TAAudioDesc want, got;
int chans;
bool playing;
bool speedAB;
int ticks, cycles, curRow, curOrder;
int changeOrd, changePos;
2021-05-14 08:23:40 +00:00
DivChannelState chan[17];
short vibTable[60];
blip_buffer_t* bb[2];
short temp[2], prevSample[2];
short* bbOut[2];
void nextOrder();
void nextRow();
void nextTick();
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);
bool perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal);
void renderSamples();
public:
2021-05-12 22:19:18 +00:00
DivSong song;
void nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size);
// load a .dmf.
bool load(void* f, size_t length);
// save as .dmf.
bool save(FILE* f);
// play
void play();
// initialize the engine.
bool init();
DivEngine():
chans(0),
playing(false),
speedAB(false),
ticks(0),
cycles(0),
curRow(-1),
curOrder(0),
changeOrd(-1),
changePos(0),
temp{0,0},
prevSample{0,0} {}
};
#endif