prepare to add file out - does not compile!
This commit is contained in:
parent
7d24b10da4
commit
45b202b85b
7 changed files with 196 additions and 12 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#ifdef HAVE_JACK
|
||||
#include "../audio/jack.h"
|
||||
#endif
|
||||
#include "../audio/file.h"
|
||||
#include "platform/genesis.h"
|
||||
#include "platform/genesisext.h"
|
||||
#include "platform/sms.h"
|
||||
|
|
@ -678,6 +679,10 @@ DivWavetable* DivEngine::getWave(int index) {
|
|||
return song.wave[index];
|
||||
}
|
||||
|
||||
void DivEngine::setLoops(int loops) {
|
||||
remainingLoops=loops;
|
||||
}
|
||||
|
||||
void DivEngine::play() {
|
||||
|
||||
}
|
||||
|
|
@ -703,6 +708,9 @@ bool DivEngine::init() {
|
|||
case DIV_AUDIO_SDL:
|
||||
output=new TAAudioSDL;
|
||||
break;
|
||||
case DIV_AUDIO_FILE:
|
||||
output=new TAAudioFile;
|
||||
break;
|
||||
default:
|
||||
logE("invalid audio engine!\n");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ enum DivStatusView {
|
|||
|
||||
enum DivAudioEngines {
|
||||
DIV_AUDIO_JACK=0,
|
||||
DIV_AUDIO_SDL
|
||||
DIV_AUDIO_SDL,
|
||||
DIV_AUDIO_FILE
|
||||
};
|
||||
|
||||
struct DivChannelState {
|
||||
|
|
@ -58,12 +59,15 @@ class DivEngine {
|
|||
int chans;
|
||||
bool playing;
|
||||
bool speedAB;
|
||||
int ticks, cycles, curRow, curOrder;
|
||||
bool endOfSong;
|
||||
int ticks, cycles, curRow, curOrder, remainingLoops;
|
||||
int changeOrd, changePos, totalTicks, totalCmds, lastCmds, cmdsPerSecond;
|
||||
DivStatusView view;
|
||||
DivChannelState chan[17];
|
||||
DivAudioEngines audioEngine;
|
||||
|
||||
String outName;
|
||||
|
||||
short vibTable[64];
|
||||
|
||||
blip_buffer_t* bb[2];
|
||||
|
|
@ -76,7 +80,8 @@ class DivEngine {
|
|||
void processRow(int i, bool afterDelay);
|
||||
void nextOrder();
|
||||
void nextRow();
|
||||
void nextTick();
|
||||
// returns true if end of song.
|
||||
bool nextTick();
|
||||
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);
|
||||
bool perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal);
|
||||
void renderSamples();
|
||||
|
|
@ -94,12 +99,18 @@ class DivEngine {
|
|||
// play
|
||||
void play();
|
||||
|
||||
// set remaining loops. -1 means loop forever.
|
||||
void setLoops(int loops);
|
||||
|
||||
// set the audio system.
|
||||
void setAudio(DivAudioEngines which);
|
||||
|
||||
// set the view mode.
|
||||
void setView(DivStatusView which);
|
||||
|
||||
// open audio output file.
|
||||
bool openAudioOut(String filename);
|
||||
|
||||
// initialize the engine.
|
||||
bool init();
|
||||
|
||||
|
|
@ -107,10 +118,12 @@ class DivEngine {
|
|||
chans(0),
|
||||
playing(false),
|
||||
speedAB(false),
|
||||
endOfSong(false),
|
||||
ticks(0),
|
||||
cycles(0),
|
||||
curRow(0),
|
||||
curOrder(0),
|
||||
remainingLoops(-1),
|
||||
changeOrd(-1),
|
||||
changePos(0),
|
||||
totalTicks(0),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#include "dispatch.h"
|
||||
#include "engine.h"
|
||||
#include "../ta-log.h"
|
||||
|
||||
void DivEngine::nextOrder() {
|
||||
curRow=0;
|
||||
if (++curOrder>=song.ordersLen) {
|
||||
endOfSong=true;
|
||||
curOrder=0;
|
||||
}
|
||||
}
|
||||
|
|
@ -518,9 +520,11 @@ void DivEngine::nextRow() {
|
|||
}
|
||||
if (changeOrd>=0) {
|
||||
curRow=changePos;
|
||||
if (changeOrd<=curOrder) endOfSong=true;
|
||||
curOrder=changeOrd;
|
||||
if (curOrder>=song.ordersLen) {
|
||||
curOrder=0;
|
||||
endOfSong=true;
|
||||
}
|
||||
changeOrd=-1;
|
||||
}
|
||||
|
|
@ -543,7 +547,8 @@ void DivEngine::nextRow() {
|
|||
}
|
||||
}
|
||||
|
||||
void DivEngine::nextTick() {
|
||||
bool DivEngine::nextTick() {
|
||||
bool ret=false;
|
||||
if (song.customTempo) {
|
||||
cycles=dispatch->rate/song.hz;
|
||||
} else {
|
||||
|
|
@ -648,6 +653,10 @@ void DivEngine::nextTick() {
|
|||
cmdsPerSecond=totalCmds-lastCmds;
|
||||
lastCmds=totalCmds;
|
||||
}
|
||||
|
||||
ret=endOfSong;
|
||||
endOfSong=false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size) {
|
||||
|
|
@ -664,15 +673,26 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
size_t runLeft=runtotal;
|
||||
size_t runPos=0;
|
||||
while (runLeft) {
|
||||
if (runLeft>=cycles) {
|
||||
runLeft-=cycles;
|
||||
dispatch->acquire(bbIn[0],bbIn[1],runPos,cycles);
|
||||
runPos+=cycles;
|
||||
nextTick();
|
||||
} else {
|
||||
dispatch->acquire(bbIn[0],bbIn[1],runPos,runLeft);
|
||||
cycles-=runLeft;
|
||||
if (!remainingLoops) {
|
||||
memset(bbIn[0]+runPos,0,runLeft*sizeof(short));
|
||||
memset(bbIn[1]+runPos,0,runLeft*sizeof(short));
|
||||
break;
|
||||
} else {
|
||||
if (runLeft>=cycles) {
|
||||
runLeft-=cycles;
|
||||
dispatch->acquire(bbIn[0],bbIn[1],runPos,cycles);
|
||||
runPos+=cycles;
|
||||
if (nextTick()) {
|
||||
if (remainingLoops>0) {
|
||||
remainingLoops--;
|
||||
if (!remainingLoops) logI("end of song!\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dispatch->acquire(bbIn[0],bbIn[1],runPos,runLeft);
|
||||
cycles-=runLeft;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue