a lot of work
- round to nearest instead of round to zero in SMS period calc - implement arpeggio - implement arp macro (kinda) - polish the SMS platform - correct the DIV_CMD_PITCH range to 1 semitone - fix PSG volume in Genesis - use a better register write strat in Genesis - fix a bug caused by legacy code - implement ECxx command - implement EDxx command - implement SN noise mode command - vibrato table is now 64 positions long (instead of 60)
This commit is contained in:
parent
f2c70df4a8
commit
dbc2e6285f
|
@ -1,6 +1,8 @@
|
|||
#ifndef _DISPATCH_H
|
||||
#define _DISPATCH_H
|
||||
|
||||
#define ONE_SEMITONE 2200
|
||||
|
||||
enum DivDispatchCmds {
|
||||
DIV_CMD_NOTE_ON=0,
|
||||
DIV_CMD_NOTE_OFF,
|
||||
|
@ -64,7 +66,7 @@ class DivDispatch {
|
|||
* the engine shall resample to the output rate.
|
||||
*/
|
||||
int rate;
|
||||
virtual void acquire(short& l, short& r);
|
||||
virtual void acquire(int& l, int& r);
|
||||
virtual int dispatch(DivCommand c);
|
||||
virtual void tick();
|
||||
|
||||
|
|
|
@ -668,8 +668,8 @@ bool DivEngine::init() {
|
|||
bbOut[0]=new short[got.bufsize];
|
||||
bbOut[1]=new short[got.bufsize];
|
||||
|
||||
for (int i=0; i<60; i++) {
|
||||
vibTable[i]=127*sin(((double)i/60.0)*(2*M_PI));
|
||||
for (int i=0; i<64; i++) {
|
||||
vibTable[i]=127*sin(((double)i/64.0)*(2*M_PI));
|
||||
}
|
||||
|
||||
switch (song.system) {
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
struct DivChannelState {
|
||||
std::vector<DivDelayedCommand> delayed;
|
||||
int note, pitch, portaSpeed, portaNote;
|
||||
int volume, volSpeed;
|
||||
int volume, volSpeed, cut, rowDelay;
|
||||
int vibratoDepth, vibratoRate, vibratoPos;
|
||||
int tremoloDepth, tremoloRate, tremoloPos;
|
||||
unsigned char arp, arpStage;
|
||||
bool doNote, legato;
|
||||
|
||||
DivChannelState():
|
||||
|
@ -20,12 +21,16 @@ struct DivChannelState {
|
|||
portaNote(-1),
|
||||
volume(0x7f00),
|
||||
volSpeed(0),
|
||||
cut(-1),
|
||||
rowDelay(0),
|
||||
vibratoDepth(0),
|
||||
vibratoRate(0),
|
||||
vibratoPos(0),
|
||||
tremoloDepth(0),
|
||||
tremoloRate(0),
|
||||
tremoloPos(0),
|
||||
arp(0),
|
||||
arpStage(-1),
|
||||
doNote(false), legato(false) {}
|
||||
};
|
||||
|
||||
|
@ -40,12 +45,13 @@ class DivEngine {
|
|||
int changeOrd, changePos;
|
||||
DivChannelState chan[17];
|
||||
|
||||
short vibTable[60];
|
||||
short vibTable[64];
|
||||
|
||||
blip_buffer_t* bb[2];
|
||||
short temp[2], prevSample[2];
|
||||
int temp[2], prevSample[2];
|
||||
short* bbOut[2];
|
||||
|
||||
void processRow(int i, bool afterDelay);
|
||||
void nextOrder();
|
||||
void nextRow();
|
||||
void nextTick();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "../dispatch.h"
|
||||
|
||||
void DivDispatch::acquire(short& l, short& r) {
|
||||
void DivDispatch::acquire(int& l, int& r) {
|
||||
l=0;
|
||||
r=0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "dummy.h"
|
||||
#include <math.h>
|
||||
|
||||
void DivPlatformDummy::acquire(short& l, short& r) {
|
||||
void DivPlatformDummy::acquire(int& l, int& r) {
|
||||
l=0;
|
||||
for (unsigned char i=0; i<chans; i++) {
|
||||
if (chan[i].active) {
|
||||
|
|
|
@ -13,7 +13,7 @@ class DivPlatformDummy: public DivDispatch {
|
|||
Channel chan[17];
|
||||
unsigned char chans;
|
||||
public:
|
||||
void acquire(short& l, short& r);
|
||||
void acquire(int& l, int& r);
|
||||
int dispatch(DivCommand c);
|
||||
void tick();
|
||||
int init(DivEngine* parent, int channels, int sugRate);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// TODO fix all the writes.
|
||||
// i think there is no wait for data writes, just for ON/OFF writes
|
||||
void DivPlatformGenesis::acquire(short& l, short& r) {
|
||||
void DivPlatformGenesis::acquire(int& l, int& r) {
|
||||
static short o[2];
|
||||
|
||||
if (dacMode && dacSample!=-1) {
|
||||
|
@ -43,7 +43,7 @@ void DivPlatformGenesis::acquire(short& l, short& r) {
|
|||
if (psgClocks>=rate) {
|
||||
psg.acquire(psgOut,psgOut);
|
||||
psgClocks-=rate;
|
||||
psgOut>>=2;
|
||||
psgOut=(psgOut>>2)+(psgOut>>3);
|
||||
}
|
||||
|
||||
l=(o[0]<<7)+psgOut;
|
||||
|
@ -89,9 +89,9 @@ void DivPlatformGenesis::tick() {
|
|||
}
|
||||
|
||||
for (int i=0; i<512; i++) {
|
||||
if (pendingWrites[i]!=-1) {
|
||||
if (pendingWrites[i]!=oldWrites[i]) {
|
||||
writes.emplace(i,pendingWrites[i]&0xff);
|
||||
pendingWrites[i]=-1;
|
||||
oldWrites[i]=pendingWrites[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,8 +156,6 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
DivInstrument* ins=parent->song.ins[chan[c.chan].ins];
|
||||
|
||||
if (chan[c.chan].insChanged) {
|
||||
chan[c.chan].insChanged=false;
|
||||
for (int i=0; i<4; i++) {
|
||||
unsigned short baseAddr=chanOffs[c.chan]|opOffs[i];
|
||||
DivInstrumentFM::Operator op=ins->fm.op[i];
|
||||
|
@ -175,9 +173,8 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
rWrite(chanOffs[c.chan]+0xb0,(ins->fm.alg&7)|(ins->fm.fb<<3));
|
||||
rWrite(chanOffs[c.chan]+0xb4,(chan[c.chan].pan<<6)|(ins->fm.fms&7)|((ins->fm.ams&3)<<4));
|
||||
}
|
||||
chan[c.chan].baseFreq=644.0f*pow(2.0f,((float)c.value/12.0f));
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(2048+chan[c.chan].pitch))>>11;
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(ONE_SEMITONE+chan[c.chan].pitch))/ONE_SEMITONE;
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].keyOn=true;
|
||||
chan[c.chan].active=true;
|
||||
|
@ -225,7 +222,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_PITCH: {
|
||||
chan[c.chan].pitch=c.value;
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(2048+chan[c.chan].pitch))>>11;
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(ONE_SEMITONE+chan[c.chan].pitch))/ONE_SEMITONE;
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
}
|
||||
|
@ -245,7 +242,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
return2=true;
|
||||
}
|
||||
}
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(2048+chan[c.chan].pitch))>>11;
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(ONE_SEMITONE+chan[c.chan].pitch))/ONE_SEMITONE;
|
||||
chan[c.chan].freqChanged=true;
|
||||
if (return2) return 2;
|
||||
break;
|
||||
|
@ -259,7 +256,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
case DIV_CMD_LEGATO: {
|
||||
chan[c.chan].baseFreq=644.0f*pow(2.0f,((float)c.value/12.0f));
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(2048+chan[c.chan].pitch))>>11;
|
||||
chan[c.chan].freq=(chan[c.chan].baseFreq*(ONE_SEMITONE+chan[c.chan].pitch))/ONE_SEMITONE;
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
}
|
||||
|
@ -312,6 +309,7 @@ int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate) {
|
|||
}
|
||||
|
||||
for (int i=0; i<512; i++) {
|
||||
oldWrites[i]=-1;
|
||||
pendingWrites[i]=-1;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class DivPlatformGenesis: public DivDispatch {
|
|||
ym3438_t fm;
|
||||
DivPlatformSMS psg;
|
||||
int psgClocks;
|
||||
short psgOut;
|
||||
int psgOut;
|
||||
int delay;
|
||||
unsigned char lastBusy;
|
||||
|
||||
|
@ -36,10 +36,11 @@ class DivPlatformGenesis: public DivDispatch {
|
|||
int dacPos;
|
||||
int dacSample;
|
||||
|
||||
short oldWrites[512];
|
||||
short pendingWrites[512];
|
||||
|
||||
public:
|
||||
void acquire(short& l, short& r);
|
||||
void acquire(int& l, int& r);
|
||||
int dispatch(DivCommand c);
|
||||
void tick();
|
||||
int init(DivEngine* parent, int channels, int sugRate);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "../engine.h"
|
||||
#include <math.h>
|
||||
|
||||
void DivPlatformSMS::acquire(short& l, short& r) {
|
||||
void DivPlatformSMS::acquire(int& l, int& r) {
|
||||
short v;
|
||||
sn->sound_stream_update(&v,1);
|
||||
l=v;
|
||||
|
@ -13,10 +13,14 @@ void DivPlatformSMS::tick() {
|
|||
for (int i=0; i<4; i++) {
|
||||
chan[i].std.next();
|
||||
if (chan[i].std.hadVol) sn->write(0x90|(i<<5)|(15-((chan[i].vol*chan[i].std.vol)>>4)));
|
||||
if (chan[i].std.hadArp) {
|
||||
chan[i].baseFreq=round(1712.0f/pow(2.0f,((float)(chan[i].note+chan[i].std.arp-12)/12.0f)));
|
||||
chan[i].freqChanged=true;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<3; i++) {
|
||||
if (chan[i].freqChanged) {
|
||||
chan[i].freq=(chan[i].baseFreq*(2048-chan[i].pitch))>>11;
|
||||
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
|
||||
sn->write(0x80|i<<5|(chan[i].freq&15));
|
||||
sn->write(chan[i].freq>>4);
|
||||
chan[i].freqChanged=false;
|
||||
|
@ -24,7 +28,7 @@ void DivPlatformSMS::tick() {
|
|||
}
|
||||
if (chan[3].freqChanged || updateSNMode) {
|
||||
updateSNMode=false;
|
||||
chan[3].freq=(chan[3].baseFreq*(2048-chan[3].pitch))>>11;
|
||||
chan[3].freq=(chan[3].baseFreq*(ONE_SEMITONE-chan[3].pitch))/ONE_SEMITONE;
|
||||
chan[3].freqChanged=false;
|
||||
if (snNoiseMode&2) { // take period from channel 3
|
||||
if (snNoiseMode&1) {
|
||||
|
@ -47,7 +51,7 @@ void DivPlatformSMS::tick() {
|
|||
int DivPlatformSMS::dispatch(DivCommand c) {
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON:
|
||||
chan[c.chan].baseFreq=1712/pow(2.0f,((float)c.value/12.0f));
|
||||
chan[c.chan].baseFreq=round(1712.0f/pow(2.0f,((float)c.value/12.0f)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
chan[c.chan].active=true;
|
||||
|
@ -61,7 +65,7 @@ int DivPlatformSMS::dispatch(DivCommand c) {
|
|||
break;
|
||||
case DIV_CMD_INSTRUMENT:
|
||||
chan[c.chan].ins=c.value;
|
||||
chan[c.chan].std.init(parent->song.ins[chan[c.chan].ins]);
|
||||
//chan[c.chan].std.init(parent->song.ins[chan[c.chan].ins]);
|
||||
break;
|
||||
case DIV_CMD_VOLUME:
|
||||
chan[c.chan].vol=c.value;
|
||||
|
@ -71,10 +75,35 @@ int DivPlatformSMS::dispatch(DivCommand c) {
|
|||
chan[c.chan].pitch=c.value;
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
case DIV_CMD_NOTE_PORTA: {
|
||||
int destFreq=round(1712.0f/pow(2.0f,((float)c.value2/12.0f)));
|
||||
bool return2=false;
|
||||
if (destFreq>chan[c.chan].baseFreq) {
|
||||
chan[c.chan].baseFreq+=c.value;
|
||||
if (chan[c.chan].baseFreq>=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
} else {
|
||||
chan[c.chan].baseFreq-=c.value;
|
||||
if (chan[c.chan].baseFreq<=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
}
|
||||
chan[c.chan].freqChanged=true;
|
||||
if (return2) return 2;
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_STD_NOISE_MODE:
|
||||
snNoiseMode=(c.value&1)|((c.value&16)>>3);
|
||||
updateSNMode=true;
|
||||
break;
|
||||
case DIV_CMD_LEGATO:
|
||||
chan[c.chan].baseFreq=round(1712.0f/pow(2.0f,((float)c.value/12.0f)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class DivPlatformSMS: public DivDispatch {
|
|||
bool updateSNMode;
|
||||
sn76496_device* sn;
|
||||
public:
|
||||
void acquire(short& l, short& r);
|
||||
void acquire(int& l, int& r);
|
||||
int dispatch(DivCommand c);
|
||||
void tick();
|
||||
int init(DivEngine* parent, int channels, int sugRate);
|
||||
|
|
|
@ -29,6 +29,9 @@ bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effe
|
|||
case 0x17: // DAC enable
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_SAMPLE_MODE,ch,(effectVal>0)));
|
||||
break;
|
||||
case 0x20: // SN noise mode
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_STD_NOISE_MODE,ch,effectVal));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -100,63 +103,19 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char
|
|||
return true;
|
||||
}
|
||||
|
||||
void DivEngine::nextRow() {
|
||||
static char pb[4096];
|
||||
static char pb1[4096];
|
||||
static char pb2[4096];
|
||||
static char pb3[4096];
|
||||
if (++curRow>=song.patLen) {
|
||||
nextOrder();
|
||||
}
|
||||
if (changeOrd>=0) {
|
||||
curRow=changePos;
|
||||
curOrder=changeOrd;
|
||||
if (curOrder>=song.ordersLen) {
|
||||
curOrder=0;
|
||||
}
|
||||
changeOrd=-1;
|
||||
}
|
||||
strcpy(pb1,"");
|
||||
strcpy(pb3,"");
|
||||
for (int i=0; i<chans; i++) {
|
||||
snprintf(pb,4095," %.2x",song.orders.ord[i][curOrder]);
|
||||
strcat(pb1,pb);
|
||||
|
||||
void DivEngine::processRow(int i, bool afterDelay) {
|
||||
DivPattern* pat=song.pat[i]->data[curOrder];
|
||||
snprintf(pb2,4095,"\x1b[37m %s",
|
||||
formatNote(pat->data[curRow][0],pat->data[curRow][1]));
|
||||
strcat(pb3,pb2);
|
||||
if (pat->data[curRow][3]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;32m%.2x",pat->data[curRow][3]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
if (pat->data[curRow][2]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[0;36m%.2x",pat->data[curRow][2]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
for (int j=0; j<song.pat[i]->effectRows; j++) {
|
||||
if (pat->data[curRow][4+(j<<1)]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;31m%.2x",pat->data[curRow][4+(j<<1)]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
if (pat->data[curRow][5+(j<<1)]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;37m%.2x",pat->data[curRow][5+(j<<1)]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3);
|
||||
// pre effects
|
||||
if (!afterDelay) for (int j=0; j<song.pat[i]->effectRows; j++) {
|
||||
short effect=pat->data[curRow][4+(j<<1)];
|
||||
short effectVal=pat->data[curRow][5+(j<<1)];
|
||||
|
||||
for (int i=0; i<chans; i++) {
|
||||
DivPattern* pat=song.pat[i]->data[curOrder];
|
||||
if (effectVal==-1) effectVal=0;
|
||||
if (effect==0xed) {
|
||||
chan[i].rowDelay=effectVal+1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// instrument
|
||||
if (pat->data[curRow][2]!=-1) {
|
||||
|
@ -247,6 +206,9 @@ void DivEngine::nextRow() {
|
|||
chan[i].volSpeed=0;
|
||||
}
|
||||
break;
|
||||
case 0x00: // arpeggio
|
||||
chan[i].arp=effectVal;
|
||||
break;
|
||||
|
||||
case 0xe1: // portamento up
|
||||
chan[i].portaNote=chan[i].note+(effectVal&15);
|
||||
|
@ -263,6 +225,9 @@ void DivEngine::nextRow() {
|
|||
case 0xea: // legato mode
|
||||
chan[i].legato=effectVal;
|
||||
break;
|
||||
case 0xec: // delayed note cut
|
||||
chan[i].cut=effectVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,6 +250,65 @@ void DivEngine::nextRow() {
|
|||
if (effectVal==-1) effectVal=0;
|
||||
perSystemPostEffect(i,effect,effectVal);
|
||||
}
|
||||
}
|
||||
|
||||
void DivEngine::nextRow() {
|
||||
static char pb[4096];
|
||||
static char pb1[4096];
|
||||
static char pb2[4096];
|
||||
static char pb3[4096];
|
||||
if (++curRow>=song.patLen) {
|
||||
nextOrder();
|
||||
}
|
||||
if (changeOrd>=0) {
|
||||
curRow=changePos;
|
||||
curOrder=changeOrd;
|
||||
if (curOrder>=song.ordersLen) {
|
||||
curOrder=0;
|
||||
}
|
||||
changeOrd=-1;
|
||||
}
|
||||
strcpy(pb1,"");
|
||||
strcpy(pb3,"");
|
||||
for (int i=0; i<chans; i++) {
|
||||
snprintf(pb,4095," %.2x",song.orders.ord[i][curOrder]);
|
||||
strcat(pb1,pb);
|
||||
|
||||
DivPattern* pat=song.pat[i]->data[curOrder];
|
||||
snprintf(pb2,4095,"\x1b[37m %s",
|
||||
formatNote(pat->data[curRow][0],pat->data[curRow][1]));
|
||||
strcat(pb3,pb2);
|
||||
if (pat->data[curRow][3]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;32m%.2x",pat->data[curRow][3]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
if (pat->data[curRow][2]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[0;36m%.2x",pat->data[curRow][2]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
for (int j=0; j<song.pat[i]->effectRows; j++) {
|
||||
if (pat->data[curRow][4+(j<<1)]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;31m%.2x",pat->data[curRow][4+(j<<1)]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
if (pat->data[curRow][5+(j<<1)]==-1) {
|
||||
strcat(pb3,"\x1b[m--");
|
||||
} else {
|
||||
snprintf(pb2,4095,"\x1b[1;37m%.2x",pat->data[curRow][5+(j<<1)]);
|
||||
strcat(pb3,pb2);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("| %.2x:%s | \x1b[1;33m%3d%s\x1b[m\n",curOrder,pb1,curRow,pb3);
|
||||
|
||||
for (int i=0; i<chans; i++) {
|
||||
processRow(i,false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,6 +333,11 @@ void DivEngine::nextTick() {
|
|||
}
|
||||
// process stuff
|
||||
for (int i=0; i<chans; i++) {
|
||||
if (chan[i].rowDelay>0) {
|
||||
if (--chan[i].rowDelay==0) {
|
||||
processRow(i,true);
|
||||
}
|
||||
}
|
||||
if (chan[i].volSpeed!=0) {
|
||||
chan[i].volume+=chan[i].volSpeed;
|
||||
if (chan[i].volume>0x7f00) chan[i].volume=0x7f00;
|
||||
|
@ -317,7 +346,7 @@ void DivEngine::nextTick() {
|
|||
}
|
||||
if (chan[i].vibratoDepth>0) {
|
||||
chan[i].vibratoPos+=chan[i].vibratoRate;
|
||||
if (chan[i].vibratoPos>=60) chan[i].vibratoPos-=60;
|
||||
if (chan[i].vibratoPos>=64) chan[i].vibratoPos-=64;
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_PITCH,i,chan[i].pitch+((chan[i].vibratoDepth*vibTable[chan[i].vibratoPos])>>4)));
|
||||
}
|
||||
if (chan[i].portaSpeed>0) {
|
||||
|
@ -325,6 +354,27 @@ void DivEngine::nextTick() {
|
|||
chan[i].portaSpeed=0;
|
||||
}
|
||||
}
|
||||
if (chan[i].cut>0) {
|
||||
if (--chan[i].cut<1) {
|
||||
chan[i].note=-1;
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_NOTE_OFF,i));
|
||||
}
|
||||
}
|
||||
if (chan[i].arp!=0) {
|
||||
chan[i].arpStage++;
|
||||
if (chan[i].arpStage>2) chan[i].arpStage=0;
|
||||
switch (chan[i].arpStage) {
|
||||
case 0:
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note));
|
||||
break;
|
||||
case 1:
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp>>4)));
|
||||
break;
|
||||
case 2:
|
||||
dispatch->dispatch(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp&15)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// system tick
|
||||
|
|
|
@ -27,6 +27,11 @@ int main(int argc, char** argv) {
|
|||
return 1;
|
||||
}
|
||||
ssize_t len=ftell(f);
|
||||
if (len==0x7fffffffffffffff) {
|
||||
perror("could not get file length");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
if (len<1) {
|
||||
if (len==0) {
|
||||
printf("that file is empty!\n");
|
||||
|
|
Loading…
Reference in a new issue