command stream arps

This commit is contained in:
tildearrow 2023-03-27 03:29:43 -05:00
parent da7d67fa85
commit 88654e26fc
5 changed files with 37 additions and 1 deletions

View file

@ -18,6 +18,7 @@
*/ */
#include "cmdStream.h" #include "cmdStream.h"
#include "dispatch.h"
#include "engine.h" #include "engine.h"
#include "../ta-log.h" #include "../ta-log.h"
@ -58,7 +59,7 @@ bool DivCSPlayer::tick() {
if (next<0xb3) { // note if (next<0xb3) { // note
e->dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,i,(int)next-60)); e->dispatchCmd(DivCommand(DIV_CMD_NOTE_ON,i,(int)next-60));
logV("%d: note on (%d)",i,(int)next-60); chan[i].note=(int)next-60;
chan[i].vibratoPos=0; chan[i].vibratoPos=0;
} else if (next>=0xd0 && next<=0xdf) { } else if (next>=0xd0 && next<=0xdf) {
command=fastCmds[next&15]; command=fastCmds[next&15];
@ -156,6 +157,7 @@ bool DivCSPlayer::tick() {
case DIV_CMD_HINT_VIBRATO_RANGE: case DIV_CMD_HINT_VIBRATO_RANGE:
case DIV_CMD_HINT_VIBRATO_SHAPE: case DIV_CMD_HINT_VIBRATO_SHAPE:
case DIV_CMD_HINT_VOLUME: case DIV_CMD_HINT_VOLUME:
case DIV_CMD_HINT_ARP_TIME:
arg0=(unsigned char)stream.readC(); arg0=(unsigned char)stream.readC();
break; break;
case DIV_CMD_HINT_PITCH: case DIV_CMD_HINT_PITCH:
@ -299,6 +301,12 @@ bool DivCSPlayer::tick() {
chan[i].note=arg0; chan[i].note=arg0;
e->dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note)); e->dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note));
break; break;
case DIV_CMD_HINT_ARPEGGIO:
chan[i].arp=(((unsigned char)arg0)<<4)|(arg1&15);
break;
case DIV_CMD_HINT_ARP_TIME:
arpSpeed=arg0;
break;
default: // dispatch it default: // dispatch it
e->dispatchCmd(DivCommand((DivDispatchCmds)command,i,arg0,arg1)); e->dispatchCmd(DivCommand((DivDispatchCmds)command,i,arg0,arg1));
break; break;
@ -331,6 +339,25 @@ bool DivCSPlayer::tick() {
if (chan[i].portaSpeed) { if (chan[i].portaSpeed) {
e->dispatchCmd(DivCommand(DIV_CMD_NOTE_PORTA,i,chan[i].portaSpeed*(e->song.linearPitch==2?e->song.pitchSlideSpeed:1),chan[i].portaTarget)); e->dispatchCmd(DivCommand(DIV_CMD_NOTE_PORTA,i,chan[i].portaSpeed*(e->song.linearPitch==2?e->song.pitchSlideSpeed:1),chan[i].portaTarget));
} }
if (chan[i].arp && !chan[i].portaSpeed) {
if (chan[i].arpTicks==0) {
switch (chan[i].arpStage) {
case 0:
e->dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note));
break;
case 1:
e->dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp>>4)));
break;
case 2:
e->dispatchCmd(DivCommand(DIV_CMD_LEGATO,i,chan[i].note+(chan[i].arp&15)));
break;
}
chan[i].arpStage++;
if (chan[i].arpStage>=3) chan[i].arpStage=0;
chan[i].arpTicks=arpSpeed;
}
chan[i].arpTicks--;
}
} }
return ticked; return ticked;
@ -370,6 +397,8 @@ bool DivCSPlayer::init() {
vibTable[i]=127*sin(((double)i/64.0)*(2*M_PI)); vibTable[i]=127*sin(((double)i/64.0)*(2*M_PI));
} }
arpSpeed=1;
return true; return true;
} }

View file

@ -73,6 +73,7 @@ class DivCSPlayer {
DivCSChannelState chan[DIV_MAX_CHANS]; DivCSChannelState chan[DIV_MAX_CHANS];
unsigned char fastDelays[16]; unsigned char fastDelays[16];
unsigned char fastCmds[16]; unsigned char fastCmds[16];
unsigned char arpSpeed;
short vibTable[64]; short vibTable[64];
public: public:

View file

@ -229,6 +229,8 @@ enum DivDispatchCmds {
DIV_CMD_ES5506_ENVELOPE_K2RAMP, // (ramp, slowdown) DIV_CMD_ES5506_ENVELOPE_K2RAMP, // (ramp, slowdown)
DIV_CMD_ES5506_PAUSE, // (value) DIV_CMD_ES5506_PAUSE, // (value)
DIV_CMD_HINT_ARP_TIME, // (value)
DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol
DIV_CMD_MAX DIV_CMD_MAX

View file

@ -418,6 +418,7 @@ void writePackedCommandValues(SafeWriter* w, const DivCommand& c) {
case DIV_CMD_AMIGA_PM: case DIV_CMD_AMIGA_PM:
case DIV_CMD_MACRO_OFF: case DIV_CMD_MACRO_OFF:
case DIV_CMD_MACRO_ON: case DIV_CMD_MACRO_ON:
case DIV_CMD_HINT_ARP_TIME:
w->writeC(1); // length w->writeC(1); // length
w->writeC(c.value); w->writeC(c.value);
break; break;

View file

@ -229,6 +229,8 @@ const char* cmdName[]={
"ES5506_ENVELOPE_K2RAMP", "ES5506_ENVELOPE_K2RAMP",
"ES5506_PAUSE", "ES5506_PAUSE",
"HINT_ARP_TIME",
"ALWAYS_SET_VOLUME" "ALWAYS_SET_VOLUME"
}; };
@ -765,6 +767,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
case 0xe0: // arp speed case 0xe0: // arp speed
if (effectVal>0) { if (effectVal>0) {
curSubSong->arpLen=effectVal; curSubSong->arpLen=effectVal;
dispatchCmd(DivCommand(DIV_CMD_HINT_ARP_TIME,i,curSubSong->arpLen));
} }
break; break;
case 0xe1: // portamento up case 0xe1: // portamento up