Skip to content

Commit

Permalink
Fix issue #18 Fluida loses GUI state on hide/show window
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Dec 23, 2022
1 parent 76449f1 commit 7a551f9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
23 changes: 21 additions & 2 deletions Fluida/fluida.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Fluida_ {
inline void retrieve_ctrl_values(const LV2_Atom_Object* obj);
inline void send_filebrowser_state();
inline void send_controller_state();
inline void send_all_controller_state();
inline void send_instrument_state();
inline void send_next_instrument_state();
inline void do_non_rt_work_f();
Expand Down Expand Up @@ -274,7 +275,7 @@ Fluida_::Fluida_() :

// destructor
Fluida_::~Fluida_() {
xsynth.unload_synth();
//xsynth.unload_synth();
flworker.stop();
};

Expand Down Expand Up @@ -524,6 +525,23 @@ void Fluida_::send_controller_state() {
}
}

void Fluida_::send_all_controller_state() {
FluidaLV2URIs* uris = &this->uris;
write_float_value(uris->fluida_rev_lev,(float)xsynth.reverb_level);
write_float_value(uris->fluida_rev_width, (float)xsynth.reverb_width);
write_float_value(uris->fluida_rev_damp, (float)xsynth.reverb_damp);
write_float_value(uris->fluida_rev_size, (float)xsynth.reverb_roomsize);
write_bool_value(uris->fluida_rev_on, (float)xsynth.reverb_on);

write_int_value(uris->fluida_chorus_type, (float)xsynth.chorus_type);
write_float_value(uris->fluida_chorus_depth, (float)xsynth.chorus_depth);
write_float_value(uris->fluida_chorus_speed, (float)xsynth.chorus_speed);
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) {
FluidaLV2URIs* uris = &this->uris;
const LV2_Atom* value = NULL;
Expand Down Expand Up @@ -638,9 +656,10 @@ void Fluida_::run_dsp_(uint32_t n_samples) {
const LV2_Atom* value = read_set_gui(uris, obj);
if (value) {
//flags = ~(-1 << 15);
flags |= SEND_SOUNDFONT | SEND_INSTRUMENTS;
send_filebrowser_state();
send_instrument_state();
send_controller_state();
send_all_controller_state();
}
} else if (obj->body.otype == uris->fluida_sflist_next) {
send_next_instrument_state();
Expand Down
1 change: 1 addition & 0 deletions Fluida/fluida_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ void plugin_cleanup(X11_UI *ui) {
}
free(ps->instruments);
free(ps);
ps = NULL;
ui->private_ptr = NULL;
}

Expand Down
7 changes: 4 additions & 3 deletions Fluida/lv2_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ static LV2UI_Handle instantiate(const LV2UI_Descriptor * descriptor,
ui->controller = controller;
// store pointer to the host write function
ui->write_function = write_function;

return (LV2UI_Handle)ui;
}

Expand Down Expand Up @@ -181,8 +180,10 @@ static int ui_idle(LV2UI_Handle handle) {
X11_UI* ui = (X11_UI*)handle;
// Xputty event loop setup to run one cycle when called
run_embedded(&ui->main);
if (!ui->first_loop) first_loop(ui);
ui->first_loop = 1;
if (!ui->first_loop) {
first_loop(ui);
ui->first_loop = 1;
}
return 0;
}

Expand Down

0 comments on commit 7a551f9

Please sign in to comment.