Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

per-channel arpeggio speeds #2244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/engine/cmdStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ bool DivCSPlayer::tick() {
chan[i].arp=(((unsigned char)arg0)<<4)|(arg1&15);
break;
case DIV_CMD_HINT_ARP_TIME:
arpSpeed=arg0;
if (e->song.arpSpeedGlobal) {
arpSpeed=arg0;
} else {
chan[i].arpLen=arg0;
}
break;
default: // dispatch it
e->dispatchCmd(DivCommand((DivDispatchCmds)command,i,arg0,arg1));
Expand Down Expand Up @@ -422,7 +426,7 @@ bool DivCSPlayer::tick() {
}
chan[i].arpStage++;
if (chan[i].arpStage>=3) chan[i].arpStage=0;
chan[i].arpTicks=arpSpeed;
chan[i].arpTicks=(e->song.arpSpeedGlobal)?arpSpeed:chan[i].arpLen;
}
chan[i].arpTicks--;
}
Expand Down Expand Up @@ -460,6 +464,7 @@ bool DivCSPlayer::init() {
for (int i=0; i<e->getTotalChannelCount(); i++) {
chan[i].volMax=(e->getDispatch(e->dispatchOfChan[i])->dispatch(DivCommand(DIV_CMD_GET_VOLMAX,e->dispatchChanOfChan[i]))<<8)|0xff;
chan[i].volume=chan[i].volMax;
chan[i].arpLen=1;
}

for (int i=0; i<64; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/engine/cmdStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct DivCSChannelState {
int volume, volMax, volSpeed, volSpeedTarget;
int vibratoDepth, vibratoRate, vibratoPos;
int portaTarget, portaSpeed;
unsigned char arp, arpStage, arpTicks;
unsigned char arp, arpStage, arpTicks, arpLen;

unsigned int callStack[8];
unsigned char callStackPos;
Expand Down Expand Up @@ -65,6 +65,7 @@ struct DivCSChannelState {
arp(0),
arpStage(0),
arpTicks(0),
arpLen(1),
callStackPos(0),
tracePos(0) {
for (int i=0; i<DIV_MAX_CSTRACE; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct DivChannelState {
int tremoloDepth, tremoloRate, tremoloPos;
int panDepth, panRate, panPos, panSpeed;
int sampleOff;
unsigned char arp, arpStage, arpTicks, panL, panR, panRL, panRR, lastVibrato, lastPorta, cutType;
unsigned char arp, arpStage, arpTicks, arpLen, panL, panR, panRL, panRR, lastVibrato, lastPorta, cutType;
bool doNote, legato, portaStop, keyOn, keyOff, nowYouCanStop, stopOnOff, releasing;
bool arpYield, delayLocked, inPorta, scheduledSlideReset, shorthandPorta, wasShorthandPorta, noteOnInhibit, resetArp, sampleOffSet;
bool wentThroughNote, goneThroughNote;
Expand Down Expand Up @@ -185,6 +185,7 @@ struct DivChannelState {
arp(0),
arpStage(-1),
arpTicks(1),
arpLen(1),
panL(255),
panR(255),
panRL(0),
Expand Down
1 change: 1 addition & 0 deletions src/engine/fileOps/dmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
ds.delayBehavior=0;
ds.jumpTreatment=2;
ds.oldAlwaysSetVolume=true;
ds.arpSpeedGlobal=true;

// 1.1 compat flags
if (ds.version>24) {
Expand Down
3 changes: 3 additions & 0 deletions src/engine/fileOps/fur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
if (ds.version<200) {
ds.oldSampleOffset=true;
}
if (ds.version<224) {
ds.arpSpeedGlobal=true;
}
ds.isDMF=false;

reader.readS(); // reserved
Expand Down
10 changes: 7 additions & 3 deletions src/engine/playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,12 @@ void DivEngine::processRow(int i, bool afterDelay) {
break;
case 0xe0: // arp speed
if (effectVal>0) {
curSubSong->arpLen=effectVal;
dispatchCmd(DivCommand(DIV_CMD_HINT_ARP_TIME,i,curSubSong->arpLen));
if (song.arpSpeedGlobal) {
curSubSong->arpLen=effectVal;
} else {
chan[i].arpLen=effectVal;
}
dispatchCmd(DivCommand(DIV_CMD_HINT_ARP_TIME,i,effectVal));
}
break;
case 0xe1: // portamento up
Expand Down Expand Up @@ -1933,7 +1937,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
}
if (chan[i].arp!=0 && !chan[i].arpYield && chan[i].portaSpeed<1) {
if (--chan[i].arpTicks<1) {
chan[i].arpTicks=curSubSong->arpLen;
chan[i].arpTicks=song.arpSpeedGlobal?curSubSong->arpLen:chan[i].arpLen;
chan[i].arpStage++;
if (chan[i].arpStage>2) chan[i].arpStage=0;
switch (chan[i].arpStage) {
Expand Down
4 changes: 3 additions & 1 deletion src/engine/song.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ struct DivSong {
bool ceilVolumeScaling;
bool oldAlwaysSetVolume;
bool oldSampleOffset;
bool arpSpeedGlobal;

std::vector<DivInstrument*> ins;
std::vector<DivWavetable*> wave;
Expand Down Expand Up @@ -478,7 +479,8 @@ struct DivSong {
resetArpPhaseOnNewNote(false),
ceilVolumeScaling(false),
oldAlwaysSetVolume(false),
oldSampleOffset(false) {
oldSampleOffset(false),
arpSpeedGlobal(false) {
for (int i=0; i<DIV_MAX_CHIPS; i++) {
system[i]=DIV_SYSTEM_NULL;
systemVol[i]=1.0;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/compatFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ void FurnaceGUI::drawCompatFlags() {
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("behavior changed in 0.6.3"));
}
ImGui::Checkbox(_("Global arpeggio speed (E0xx)"),&e->song.arpSpeedGlobal);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_("when enabled, E0xx will affect all channels simultaneously."));
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem(_(".mod import"))) {
Expand Down