diff options
author | Filipe Coelho <falktx@falktx.com> | 2020-12-08 17:15:00 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-18 10:15:28 +0100 |
commit | 64d4a4a46901b1b1ab4eaac4f3f57f8d353e42c5 (patch) | |
tree | 273a990a924bfc06d8c0b36037401f1edf55a534 /plugins/eg-sampler.lv2/sampler.c | |
parent | d6301787b3bc3192788bc428a75f4895111dc8bd (diff) | |
download | lv2-64d4a4a46901b1b1ab4eaac4f3f57f8d353e42c5.tar.xz |
eg-sampler: Send update to UI if gain parameter changes
Diffstat (limited to 'plugins/eg-sampler.lv2/sampler.c')
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index b85bb38..1a13a92 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -82,6 +82,7 @@ typedef struct { sf_count_t frame; bool play; bool activated; + bool gain_changed; bool sample_changed; } Sampler; @@ -435,13 +436,21 @@ run(LV2_Handle instance, uint32_t sample_count) // Start a sequence in the notify output port. lv2_atom_forge_sequence_head(&self->forge, &self->notify_frame, 0); - // Send update to UI if sample has changed due to state restore - if (self->sample_changed) { + // Send update to UI if gain or sample has changed due to state restore + if (self->gain_changed || self->sample_changed) { lv2_atom_forge_frame_time(&self->forge, 0); - write_set_file(&self->forge, &self->uris, - self->sample->path, - self->sample->path_len); - self->sample_changed = false; + + if (self->gain_changed) { + write_set_gain(&self->forge, &self->uris, self->gain_dB); + self->gain_changed = false; + } + + if (self->sample_changed) { + write_set_file(&self->forge, &self->uris, + self->sample->path, + self->sample->path_len); + self->sample_changed = false; + } } // Iterate over incoming events, emitting audio along the way @@ -587,8 +596,9 @@ restore(LV2_Handle instance, return LV2_STATE_ERR_BAD_TYPE; } - self->gain_dB = *(const float*)value; - self->gain = DB_CO(self->gain_dB); + self->gain_dB = *(const float*)value; + self->gain = DB_CO(self->gain_dB); + self->gain_changed = true; return LV2_STATE_SUCCESS; } |