dev104 - add "is sample" flag to Sound Unit ins

This commit is contained in:
tildearrow 2022-08-06 04:04:18 -05:00
parent 0946d23883
commit 5534f55f7a
6 changed files with 42 additions and 14 deletions

View file

@ -810,6 +810,9 @@ size | description
1 | vib depth 1 | vib depth
1 | am depth 1 | am depth
23 | reserved 23 | reserved
--- | **Sound Unit data** (>=104)
1 | use sample
1 | switch roles of phase reset timer and frequency
``` ```
# wavetable # wavetable

View file

@ -45,8 +45,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false; #define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev103" #define DIV_VERSION "dev104"
#define DIV_ENGINE_VERSION 103 #define DIV_ENGINE_VERSION 104
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01

View file

@ -528,6 +528,10 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(0); w->writeC(0);
} }
// Sound Unit
w->writeC(su.useSample);
w->writeC(su.switchRoles);
blockEndSeek=w->tell(); blockEndSeek=w->tell();
w->seek(blockStartSeek,SEEK_SET); w->seek(blockStartSeek,SEEK_SET);
w->writeI(blockEndSeek-blockStartSeek-4); w->writeI(blockEndSeek-blockStartSeek-4);
@ -1075,6 +1079,12 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
for (int k=0; k<23; k++) reader.readC(); for (int k=0; k<23; k++) reader.readC();
} }
// Sound Unit
if (version>=104) {
su.useSample=reader.readC();
su.switchRoles=reader.readC();
}
return DIV_DATA_SUCCESS; return DIV_DATA_SUCCESS;
} }

View file

@ -437,6 +437,14 @@ struct DivInstrumentWaveSynth {
param4(0) {} param4(0) {}
}; };
struct DivInstrumentSoundUnit {
bool useSample;
bool switchRoles;
DivInstrumentSoundUnit():
useSample(false),
switchRoles(false) {}
};
struct DivInstrument { struct DivInstrument {
String name; String name;
bool mode; bool mode;
@ -450,6 +458,7 @@ struct DivInstrument {
DivInstrumentFDS fds; DivInstrumentFDS fds;
DivInstrumentMultiPCM multipcm; DivInstrumentMultiPCM multipcm;
DivInstrumentWaveSynth ws; DivInstrumentWaveSynth ws;
DivInstrumentSoundUnit su;
/** /**
* save the instrument to a SafeWriter. * save the instrument to a SafeWriter.

View file

@ -256,12 +256,12 @@ int DivPlatformSoundUnit::dispatch(DivCommand c) {
switch (c.cmd) { switch (c.cmd) {
case DIV_CMD_NOTE_ON: { case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_SU); DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_SU);
if (chan[c.chan].pcm && ins->type!=DIV_INS_AMIGA) { if (chan[c.chan].pcm && !(ins->type==DIV_INS_AMIGA || ins->su.useSample)) {
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA); chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA || ins->su.useSample);
writeControl(c.chan); writeControl(c.chan);
writeControlUpper(c.chan); writeControlUpper(c.chan);
} }
chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA); chan[c.chan].pcm=(ins->type==DIV_INS_AMIGA || ins->su.useSample);
if (c.value!=DIV_NOTE_NULL) { if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value); chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].freqChanged=true; chan[c.chan].freqChanged=true;

View file

@ -3093,13 +3093,17 @@ void FurnaceGUI::drawInsEdit() {
P(ImGui::Checkbox("Don't test/gate before new note",&ins->c64.noTest)); P(ImGui::Checkbox("Don't test/gate before new note",&ins->c64.noTest));
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ins->type==DIV_INS_AMIGA) if (ImGui::BeginTabItem("Sample")) { if (ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_SU) if (ImGui::BeginTabItem((ins->type==DIV_INS_SU)?"Sound Unit":"Sample")) {
String sName; String sName;
if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) { if (ins->amiga.initSample<0 || ins->amiga.initSample>=e->song.sampleLen) {
sName="none selected"; sName="none selected";
} else { } else {
sName=e->song.sample[ins->amiga.initSample]->name; sName=e->song.sample[ins->amiga.initSample]->name;
} }
if (ins->type==DIV_INS_SU) {
P(ImGui::Checkbox("Use sample",&ins->su.useSample));
P(ImGui::Checkbox("Switch roles of frequency and phase reset timer",&ins->su.switchRoles));
}
if (ImGui::BeginCombo("Initial Sample",sName.c_str())) { if (ImGui::BeginCombo("Initial Sample",sName.c_str())) {
String id; String id;
for (int i=0; i<e->song.sampleLen; i++) { for (int i=0; i<e->song.sampleLen; i++) {
@ -3110,14 +3114,16 @@ void FurnaceGUI::drawInsEdit() {
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
P(ImGui::Checkbox("Use wavetable (Amiga only)",&ins->amiga.useWave)); if (ins->type==DIV_INS_AMIGA) {
if (ins->amiga.useWave) { P(ImGui::Checkbox("Use wavetable (Amiga only)",&ins->amiga.useWave));
int len=ins->amiga.waveLen+1; if (ins->amiga.useWave) {
if (ImGui::InputInt("Width",&len,2,16)) { int len=ins->amiga.waveLen+1;
if (len<2) len=2; if (ImGui::InputInt("Width",&len,2,16)) {
if (len>256) len=256; if (len<2) len=2;
ins->amiga.waveLen=(len&(~1))-1; if (len>256) len=256;
PARAMETER ins->amiga.waveLen=(len&(~1))-1;
PARAMETER
}
} }
} }
ImGui::BeginDisabled(ins->amiga.useWave); ImGui::BeginDisabled(ins->amiga.useWave);