lv2: Add option to enable plugin-side CC automation

This commit is contained in:
Jean Pierre Cimalando 2021-04-06 13:12:19 +02:00
parent 38e07c3729
commit 30234fa8cf
3 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,6 @@
# This option is for MIDI CC support in absence of host midi:binding support
option(SFIZZ_LV2_PSA "Enable plugin-side MIDI automations" OFF)
# Configuration for this plugin
# TODO: generate version from git
set(LV2PLUGIN_VERSION_MINOR 6)
@ -61,7 +64,7 @@ sfizz:cc${_i}
rdfs:label \"Controller ${_i}\" ;
rdfs:range atom:Float")
if(_i LESS 128)
if(_i LESS 128 AND NOT SFIZZ_LV2_PSA)
math(EXPR _digit1 "${_i}>>4")
math(EXPR _digit2 "${_i}&15")
string(SUBSTRING "0123456789ABCDEF" "${_digit1}" 1 _digit1)

View file

@ -33,6 +33,11 @@ if(SFIZZ_LV2_UI)
target_link_libraries(${LV2PLUGIN_PRJ_NAME}_ui PRIVATE sfizz::editor sfizz::vstgui sfizz::plugins-common)
endif()
if(SFIZZ_LV2_PSA)
target_compile_definitions(${LV2PLUGIN_PRJ_NAME} PRIVATE "SFIZZ_LV2_PSA=1")
target_compile_definitions(${LV2PLUGIN_PRJ_NAME}_ui PRIVATE "SFIZZ_LV2_PSA=1")
endif()
# Explicitely strip all symbols on Linux but lv2_descriptor()
# MacOS linker does not support this apparently https://bugs.webkit.org/show_bug.cgi?id=144555
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

View file

@ -613,6 +613,7 @@ sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, int delay, const LV2_Atom_Obj
float value = *(const float *)LV2_ATOM_BODY_CONST(atom);
sfizz_send_hdcc(self->synth, delay, cc, value);
self->cc_current[cc] = value;
self->ccauto[cc] = absl::nullopt;
}
}
else if (key == self->sfizz_sfz_file_uri)
@ -671,12 +672,21 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
break;
// Note(jpc) CC must be mapped by host, not handled here.
// See LV2 midi:binding.
/*case LV2_MIDI_MSG_CONTROLLER:
sfizz_send_cc(self->synth,
(int)ev->time.frames,
(int)msg[1],
msg[2]);
break;*/
#if defined(SFIZZ_LV2_PSA)
case LV2_MIDI_MSG_CONTROLLER:
{
unsigned cc = msg[1];
float value = float(msg[2]) * (1.0f / 127.0f);
sfizz_send_hdcc(self->synth,
(int)ev->time.frames,
(int)cc,
value);
self->cc_current[cc] = value;
self->ccauto[cc] = value;
self->have_ccauto = true;
}
break;
#endif
case LV2_MIDI_MSG_CHANNEL_PRESSURE:
sfizz_send_aftertouch(self->synth,
(int)ev->time.frames,