Have UI receive CC by parameter

This commit is contained in:
Jean Pierre Cimalando 2021-04-05 02:51:40 +02:00
parent b40e8f4476
commit 803c4f296e
2 changed files with 11 additions and 2 deletions

View file

@ -983,7 +983,6 @@ run(LV2_Handle instance, uint32_t sample_count)
sfizz_render_block(self->synth, self->output_buffers, 2, (int)sample_count);
// Request OSC updates
sfizz_send_message(self->synth, self->client, 0, "/cc/changed~", "", nullptr);
sfizz_send_message(self->synth, self->client, 0, "/sw/last/current", "", nullptr);
spin_mutex_unlock(self->synth_mutex);

View file

@ -102,6 +102,7 @@ struct sfizz_ui_t : EditorController, VSTGUIEditorInterface {
LV2_Atom_Forge atom_forge;
LV2_URID atom_event_transfer_uri;
LV2_URID atom_object_uri;
LV2_URID atom_float_uri;
LV2_URID atom_path_uri;
LV2_URID atom_urid_uri;
LV2_URID midi_event_uri;
@ -202,6 +203,7 @@ instantiate(const LV2UI_Descriptor *descriptor,
lv2_atom_forge_init(forge, map);
self->atom_event_transfer_uri = map->map(map->handle, LV2_ATOM__eventTransfer);
self->atom_object_uri = map->map(map->handle, LV2_ATOM__Object);
self->atom_float_uri = map->map(map->handle, LV2_ATOM__Float);
self->atom_path_uri = map->map(map->handle, LV2_ATOM__Path);
self->atom_urid_uri = map->map(map->handle, LV2_ATOM__URID);
self->midi_event_uri = map->map(map->handle, LV2_MIDI__MidiEvent);
@ -350,7 +352,15 @@ port_event(LV2UI_Handle ui,
const LV2_URID prop_uri = reinterpret_cast<const LV2_Atom_URID *>(prop)->body;
auto *value_body = reinterpret_cast<const char *>(LV2_ATOM_BODY_CONST(value));
if (prop_uri == self->sfizz_sfz_file_uri && value->type == self->atom_path_uri) {
int cc = sfizz_lv2_ccmap_unmap(self->ccmap.get(), prop_uri);
if (cc != -1) {
if (value->type == self->atom_float_uri) {
float ccvalue = *reinterpret_cast<const float*>(value_body);
self->uiReceiveValue(editIdForCC(cc), ccvalue);
}
}
else if (prop_uri == self->sfizz_sfz_file_uri && value->type == self->atom_path_uri) {
std::string path(value_body, strnlen(value_body, value->size));
self->uiReceiveValue(EditId::SfzFile, path);
}