aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/eg-sampler.lv2/sampler.c26
-rw-r--r--plugins/eg-sampler.lv2/uris.h28
2 files changed, 46 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;
}
diff --git a/plugins/eg-sampler.lv2/uris.h b/plugins/eg-sampler.lv2/uris.h
index 5837402..8a0eb6f 100644
--- a/plugins/eg-sampler.lv2/uris.h
+++ b/plugins/eg-sampler.lv2/uris.h
@@ -80,6 +80,34 @@ map_sampler_uris(LV2_URID_Map* map, SamplerURIs* uris)
----
[]
a patch:Set ;
+ patch:property param:gain ;
+ patch:value 0.0f .
+ ----
+*/
+static inline LV2_Atom_Forge_Ref
+write_set_gain(LV2_Atom_Forge* forge,
+ const SamplerURIs* uris,
+ const float gain)
+{
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom_Forge_Ref set = lv2_atom_forge_object(
+ forge, &frame, 0, uris->patch_Set);
+
+ lv2_atom_forge_key(forge, uris->patch_property);
+ lv2_atom_forge_urid(forge, uris->param_gain);
+ lv2_atom_forge_key(forge, uris->patch_value);
+ lv2_atom_forge_float(forge, gain);
+
+ lv2_atom_forge_pop(forge, &frame);
+ return set;
+}
+
+/**
+ Write a message like the following to `forge`:
+ [source,turtle]
+ ----
+ []
+ a patch:Set ;
patch:property eg:sample ;
patch:value </home/me/foo.wav> .
----