Skip to content

Commit

Permalink
Fix issue #18 Fluida loses GUI state on hide/show window, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Dec 24, 2022
1 parent 7a551f9 commit babba2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Fluida/fluida.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class Fluida_ {
int channel;
int doit;
int sflist_counter;
int current_instrument;
std::atomic<bool> restore_send;
std::atomic<bool> re_send;
std::thread::id dsp_id;
Expand Down Expand Up @@ -263,6 +264,7 @@ Fluida_::Fluida_() :
channel = 0;
doit = 0;
sflist_counter = 0;
current_instrument = 0;
restore_send.store(false, std::memory_order_release);
re_send.store(false, std::memory_order_release);
use_worker.store(true, std::memory_order_release);
Expand Down Expand Up @@ -469,6 +471,8 @@ void Fluida_::send_next_instrument_state() {
lv2_atom_forge_int(&forge, sflist_counter);
lv2_atom_forge_pop(&forge, &frame);
flags &= ~SEND_INSTRUMENTS;
lv2_atom_forge_frame_time(&forge, 0);
write_set_instrument(&forge, uris, current_instrument);
}
}

Expand Down Expand Up @@ -539,7 +543,9 @@ void Fluida_::send_all_controller_state() {
write_float_value(uris->fluida_chorus_lev, (float)xsynth.chorus_level);
write_int_value(uris->fluida_chorus_voices, (float)xsynth.chorus_voices);
write_bool_value(uris->fluida_chorus_on, (float)xsynth.chorus_on);

write_int_value(uris->fluida_channel_pressure, (float)xsynth.channel_pressure);

}

void Fluida_::retrieve_ctrl_values(const LV2_Atom_Object* obj) {
Expand Down Expand Up @@ -650,6 +656,7 @@ void Fluida_::run_dsp_(uint32_t n_samples) {
const LV2_Atom* value = read_set_instrument(uris, obj);
if (value) {
int* uri = (int*)LV2_ATOM_BODY(value);
current_instrument = (*uri);
xsynth.synth_pgm_changed(channel,(*uri));
}
} else if (obj->body.otype == uris->fluida_state) {
Expand Down Expand Up @@ -706,6 +713,7 @@ void Fluida_::run_dsp_(uint32_t n_samples) {
case LV2_MIDI_MSG_PGM_CHANGE:
{
xsynth.synth_pgm_changed(msg[0]&0x0f,msg[1]);
current_instrument = msg[1];
lv2_atom_forge_frame_time(&forge, 0);
write_set_instrument(&forge, uris,msg[1]);
}
Expand Down
3 changes: 1 addition & 2 deletions Fluida/fluida_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ void send_controller_message(Widget_t *w, const LV2_URID control) {
break;
}
lv2_atom_forge_pop(&ps->forge, &frame);

ui->write_function(ui->controller, MIDI_IN, lv2_atom_total_size(msg),
ps->uris.atom_eventTransfer, msg);
}
Expand Down Expand Up @@ -431,7 +430,7 @@ void plugin_create_controller_widgets(X11_UI *ui, const char * plugin_uri) {

ps->control[10] = add_combobox(ui->win, _("MODE"), 430, 230, 100, 30);
ps->control[10]->parent_struct = (void*)&uris->fluida_chorus_type;
ps->control[9]->data = 2;
ps->control[10]->data = 2;
combobox_add_entry(ps->control[10], _("SINE"));
combobox_add_entry(ps->control[10], _("TRIANGLE"));
combobox_set_active_entry(ps->control[10], 0);
Expand Down

0 comments on commit babba2b

Please sign in to comment.