add notifyWaveChange

fixes #8
This commit is contained in:
tildearrow 2022-01-18 00:25:10 -05:00
parent af30d4990a
commit 345962092e
11 changed files with 49 additions and 0 deletions

View file

@ -220,6 +220,11 @@ class DivDispatch {
*/
virtual void notifyInsChange(int ins);
/**
* notify wavetable change.
*/
virtual void notifyWaveChange(int wave);
/**
* notify deletion of an instrument.
*/

View file

@ -2214,6 +2214,14 @@ void DivEngine::notifyInsChange(int ins) {
isBusy.unlock();
}
void DivEngine::notifyWaveChange(int wave) {
isBusy.lock();
for (int i=0; i<song.systemLen; i++) {
disCont[i].dispatch->notifyWaveChange(wave);
}
isBusy.unlock();
}
#ifdef _WIN32
#define CONFIG_FILE "\\furnace.cfg"
#else

View file

@ -221,6 +221,8 @@ class DivEngine {
bool haltAudioFile();
// notify instrument parameter change
void notifyInsChange(int ins);
// notify wavetable change
void notifyWaveChange(int wave);
// save config
bool saveConf();

View file

@ -50,6 +50,10 @@ void DivDispatch::notifyInsChange(int ins) {
}
void DivDispatch::notifyWaveChange(int ins) {
}
void DivDispatch::notifyInsDeletion(void* ins) {
}

View file

@ -219,6 +219,10 @@ void DivPlatformAmiga::notifyInsChange(int ins) {
}
}
void DivPlatformAmiga::notifyWaveChange(int wave) {
// TODO when wavetables are added
}
void DivPlatformAmiga::notifyInsDeletion(void* ins) {
for (int i=0; i<4; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);

View file

@ -55,6 +55,7 @@ class DivPlatformAmiga: public DivDispatch {
bool keyOffAffectsArp(int ch);
void setPAL(bool pal);
void notifyInsChange(int ins);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, bool pal);
void quit();

View file

@ -324,6 +324,13 @@ void DivPlatformGB::notifyInsChange(int ins) {
}
}
void DivPlatformGB::notifyWaveChange(int wave) {
if (chan[2].wave==wave) {
updateWave();
if (!chan[2].keyOff) chan[2].keyOn=true;
}
}
void DivPlatformGB::notifyInsDeletion(void* ins) {
for (int i=0; i<4; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);

View file

@ -46,6 +46,7 @@ class DivPlatformGB: public DivDispatch {
void muteChannel(int ch, bool mute);
bool isStereo();
void notifyInsChange(int ins);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, bool pal);
void quit();

View file

@ -313,6 +313,14 @@ bool DivPlatformPCE::keyOffAffectsArp(int ch) {
return true;
}
void DivPlatformPCE::notifyWaveChange(int wave) {
for (int i=0; i<6; i++) {
if (chan[i].wave==wave) {
updateWave(i);
}
}
}
void DivPlatformPCE::notifyInsDeletion(void* ins) {
for (int i=0; i<6; i++) {
chan[i].std.notifyInsDeletion((DivInstrument*)ins);

View file

@ -65,6 +65,7 @@ class DivPlatformPCE: public DivDispatch {
bool isStereo();
bool keyOffAffectsArp(int ch);
void setPAL(bool pal);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
int init(DivEngine* parent, int channels, int sugRate, bool pal);
void quit();

View file

@ -1132,6 +1132,8 @@ void FurnaceGUI::drawWaveEdit() {
if (ImGui::InputInt("##_WTW",&wave->len,1,2)) {
if (wave->len>256) wave->len=256;
if (wave->len<1) wave->len=1;
e->notifyWaveChange(curWave);
modified=true;
}
ImGui::SameLine();
ImGui::Text("Height");
@ -1143,6 +1145,8 @@ void FurnaceGUI::drawWaveEdit() {
if (ImGui::InputInt("##_WTH",&wave->max,1,2)) {
if (wave->max>255) wave->max=255;
if (wave->max<1) wave->max=1;
e->notifyWaveChange(curWave);
modified=true;
}
for (int i=0; i<wave->len; i++) {
wavePreview[i]=wave->data[i];
@ -1160,6 +1164,8 @@ void FurnaceGUI::drawWaveEdit() {
waveDragActive=true;
waveDragTarget=wave->data;
processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y);
e->notifyWaveChange(curWave);
modified=true;
}
ImGui::PopStyleVar();
}
@ -3026,6 +3032,8 @@ void FurnaceGUI::processDrags(int dragX, int dragY) {
if (y>waveDragMax) y=waveDragMax;
if (y<waveDragMin) y=waveDragMin;
waveDragTarget[x]=y;
e->notifyWaveChange(curWave);
modified=true;
}
}
}