Merge pull request #1054 from paulfd/lv2-midi-rollback
Lv2 midi rollback
This commit is contained in:
commit
8993426bf3
8 changed files with 24 additions and 42 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
# This option is for MIDI CC support in absence of host midi:binding support
|
# This option is for MIDI CC support in absence of host midi:binding support
|
||||||
option(SFIZZ_LV2_PSA "Enable plugin-side MIDI automations" OFF)
|
option(SFIZZ_LV2_PSA "Enable plugin-side MIDI automations" ON)
|
||||||
|
|
||||||
# Configuration for this plugin
|
# Configuration for this plugin
|
||||||
# TODO: generate version from git
|
# TODO: generate version from git
|
||||||
|
|
@ -57,6 +57,10 @@ function(sfizz_lv2_generate_controllers_ttl FILE)
|
||||||
")
|
")
|
||||||
math(EXPR _j "${SFIZZ_NUM_CCS}-1")
|
math(EXPR _j "${SFIZZ_NUM_CCS}-1")
|
||||||
foreach(_i RANGE "${_j}")
|
foreach(_i RANGE "${_j}")
|
||||||
|
if(_i LESS 128 AND SFIZZ_LV2_PSA)
|
||||||
|
continue() # Don't generate automation parameters for CCs with plugin-side automation
|
||||||
|
endif()
|
||||||
|
|
||||||
string_left_pad(_i "${_i}" 3 0)
|
string_left_pad(_i "${_i}" 3 0)
|
||||||
file(APPEND "${FILE}" "
|
file(APPEND "${FILE}" "
|
||||||
sfizz:cc${_i}
|
sfizz:cc${_i}
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ Release asserts: ${SFIZZ_RELEASE_ASSERTS}
|
||||||
|
|
||||||
Install prefix: ${CMAKE_INSTALL_PREFIX}
|
Install prefix: ${CMAKE_INSTALL_PREFIX}
|
||||||
LV2 destination directory: ${LV2PLUGIN_INSTALL_DIR}
|
LV2 destination directory: ${LV2PLUGIN_INSTALL_DIR}
|
||||||
|
LV2 plugin-side CC automation ${SFIZZ_LV2_PSA}
|
||||||
|
|
||||||
Compiler CXX debug flags: ${CMAKE_CXX_FLAGS_DEBUG}
|
Compiler CXX debug flags: ${CMAKE_CXX_FLAGS_DEBUG}
|
||||||
Compiler CXX release flags: ${CMAKE_CXX_FLAGS_RELEASE}
|
Compiler CXX release flags: ${CMAKE_CXX_FLAGS_RELEASE}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ endif()
|
||||||
|
|
||||||
if(SFIZZ_LV2_PSA)
|
if(SFIZZ_LV2_PSA)
|
||||||
target_compile_definitions(${LV2PLUGIN_PRJ_NAME} PRIVATE "SFIZZ_LV2_PSA=1")
|
target_compile_definitions(${LV2PLUGIN_PRJ_NAME} PRIVATE "SFIZZ_LV2_PSA=1")
|
||||||
target_compile_definitions(${LV2PLUGIN_PRJ_NAME}_ui PRIVATE "SFIZZ_LV2_PSA=1")
|
if(SFIZZ_LV2_UI)
|
||||||
|
target_compile_definitions(${LV2PLUGIN_PRJ_NAME}_ui PRIVATE "SFIZZ_LV2_PSA=1")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Explicitely strip all symbols on Linux but lv2_descriptor()
|
# Explicitely strip all symbols on Linux but lv2_descriptor()
|
||||||
|
|
|
||||||
|
|
@ -644,7 +644,6 @@ instantiate(const LV2_Descriptor *descriptor,
|
||||||
|
|
||||||
self->ccmap = sfizz_lv2_ccmap_create(self->map);
|
self->ccmap = sfizz_lv2_ccmap_create(self->map);
|
||||||
self->cc_current = new float[sfz::config::numCCs]();
|
self->cc_current = new float[sfz::config::numCCs]();
|
||||||
self->ccauto = new absl::optional<float>[sfz::config::numCCs];
|
|
||||||
|
|
||||||
self->synth = sfizz_create_synth();
|
self->synth = sfizz_create_synth();
|
||||||
self->client = sfizz_create_client(self);
|
self->client = sfizz_create_client(self);
|
||||||
|
|
@ -678,7 +677,6 @@ cleanup(LV2_Handle instance)
|
||||||
spin_mutex_destroy(self->synth_mutex);
|
spin_mutex_destroy(self->synth_mutex);
|
||||||
sfizz_delete_client(self->client);
|
sfizz_delete_client(self->client);
|
||||||
sfizz_free(self->synth);
|
sfizz_free(self->synth);
|
||||||
delete[] self->ccauto;
|
|
||||||
delete[] self->cc_current;
|
delete[] self->cc_current;
|
||||||
sfizz_lv2_ccmap_free(self->ccmap);
|
sfizz_lv2_ccmap_free(self->ccmap);
|
||||||
delete self;
|
delete self;
|
||||||
|
|
@ -806,7 +804,6 @@ sfizz_lv2_handle_atom_object(sfizz_plugin_t *self, int delay, const LV2_Atom_Obj
|
||||||
float value = *(const float *)LV2_ATOM_BODY_CONST(atom);
|
float value = *(const float *)LV2_ATOM_BODY_CONST(atom);
|
||||||
sfizz_automate_hdcc(self->synth, delay, cc, value);
|
sfizz_automate_hdcc(self->synth, delay, cc, value);
|
||||||
self->cc_current[cc] = value;
|
self->cc_current[cc] = value;
|
||||||
self->ccauto[cc] = absl::nullopt;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (key == self->sfizz_sfz_file_uri)
|
else if (key == self->sfizz_sfz_file_uri)
|
||||||
|
|
@ -874,15 +871,6 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
|
||||||
unsigned cc = msg[1];
|
unsigned cc = msg[1];
|
||||||
float value = float(msg[2]) * (1.0f / 127.0f);
|
float value = float(msg[2]) * (1.0f / 127.0f);
|
||||||
|
|
||||||
// Send
|
|
||||||
if (sfizz_is_sustain_or_sostenuto(self, cc)) {
|
|
||||||
sfizz_automate_hdcc(self->synth,
|
|
||||||
(int)ev->time.frames,
|
|
||||||
(int)cc,
|
|
||||||
value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note(jpc) CC must be mapped by host, not handled here.
|
// Note(jpc) CC must be mapped by host, not handled here.
|
||||||
// See LV2 midi:binding.
|
// See LV2 midi:binding.
|
||||||
#if defined(SFIZZ_LV2_PSA)
|
#if defined(SFIZZ_LV2_PSA)
|
||||||
|
|
@ -894,9 +882,6 @@ sfizz_lv2_process_midi_event(sfizz_plugin_t *self, const LV2_Atom_Event *ev)
|
||||||
(int)ev->time.frames,
|
(int)ev->time.frames,
|
||||||
(int)cc,
|
(int)cc,
|
||||||
value);
|
value);
|
||||||
self->cc_current[cc] = value;
|
|
||||||
self->ccauto[cc] = value;
|
|
||||||
self->have_ccauto = true;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LV2_MIDI_CTL_ALL_NOTES_OFF:
|
case LV2_MIDI_CTL_ALL_NOTES_OFF:
|
||||||
|
|
@ -1249,18 +1234,6 @@ run(LV2_Handle instance, uint32_t sample_count)
|
||||||
self->midnam->update(self->midnam->handle);
|
self->midnam->update(self->midnam->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->have_ccauto)
|
|
||||||
{
|
|
||||||
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
|
|
||||||
absl::optional<float> value = self->ccauto[cc];
|
|
||||||
if (value) {
|
|
||||||
sfizz_lv2_send_controller(self, self->patch_set_uri, cc, *value);
|
|
||||||
self->ccauto[cc] = absl::nullopt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self->have_ccauto = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_mutex_unlock(self->synth_mutex);
|
spin_mutex_unlock(self->synth_mutex);
|
||||||
|
|
||||||
#if defined(SFIZZ_LV2_UI)
|
#if defined(SFIZZ_LV2_UI)
|
||||||
|
|
@ -1408,9 +1381,6 @@ sfizz_lv2_update_sfz_info(sfizz_plugin_t *self)
|
||||||
const InstrumentDescription desc = parseDescriptionBlob(blob);
|
const InstrumentDescription desc = parseDescriptionBlob(blob);
|
||||||
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
|
for (unsigned cc = 0; cc < sfz::config::numCCs; ++cc) {
|
||||||
if (desc.ccUsed.test(cc) && !desc.sustainOrSostenuto.test(cc)) {
|
if (desc.ccUsed.test(cc) && !desc.sustainOrSostenuto.test(cc)) {
|
||||||
// Mark all the used CCs for automation with default values
|
|
||||||
self->ccauto[cc] = desc.ccValue[cc];
|
|
||||||
self->have_ccauto = true;
|
|
||||||
// Update the current CCs
|
// Update the current CCs
|
||||||
self->cc_current[cc] = desc.ccValue[cc];
|
self->cc_current[cc] = desc.ccValue[cc];
|
||||||
}
|
}
|
||||||
|
|
@ -1579,9 +1549,6 @@ restore(LV2_Handle instance,
|
||||||
if (value) {
|
if (value) {
|
||||||
// Set CC in the synth
|
// Set CC in the synth
|
||||||
sfizz_automate_hdcc(self->synth, 0, int(cc), *value);
|
sfizz_automate_hdcc(self->synth, 0, int(cc), *value);
|
||||||
// Mark CCs for automation with state values
|
|
||||||
self->ccauto[cc] = *value;
|
|
||||||
self->have_ccauto = true;
|
|
||||||
// Update the current CCs
|
// Update the current CCs
|
||||||
self->cc_current[cc] = *value;
|
self->cc_current[cc] = *value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,10 +140,6 @@ struct sfizz_plugin_t
|
||||||
// updated by hdcc or file load
|
// updated by hdcc or file load
|
||||||
float *cc_current {};
|
float *cc_current {};
|
||||||
|
|
||||||
// CC queued for automation on next run(). (synchronized by `synth_mutex`)
|
|
||||||
absl::optional<float>* ccauto {};
|
|
||||||
volatile bool have_ccauto {};
|
|
||||||
|
|
||||||
// Timing data
|
// Timing data
|
||||||
int bar {};
|
int bar {};
|
||||||
double bar_beat {};
|
double bar_beat {};
|
||||||
|
|
|
||||||
|
|
@ -761,6 +761,17 @@ void sfizz_ui_t::uiSendValue(EditId id, const EditValue& v)
|
||||||
default:
|
default:
|
||||||
if (editIdIsCC(id)) {
|
if (editIdIsCC(id)) {
|
||||||
int cc = ccForEditId(id);
|
int cc = ccForEditId(id);
|
||||||
|
#if defined(SFIZZ_LV2_PSA)
|
||||||
|
if (cc >= 0 && cc < 128) {
|
||||||
|
// Send MIDI message
|
||||||
|
uint8_t msg[3];
|
||||||
|
msg[0] = 0xB0;
|
||||||
|
msg[1] = static_cast<uint8_t>(cc);
|
||||||
|
msg[2] = static_cast<uint8_t>(v.to_float() * 127);
|
||||||
|
uiSendMIDI(msg, 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
LV2_URID urid = sfizz_lv2_ccmap_map(ccmap.get(), cc);
|
LV2_URID urid = sfizz_lv2_ccmap_map(ccmap.get(), cc);
|
||||||
sendController(urid, v.to_float());
|
sendController(urid, v.to_float());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,8 @@ bool Layer::registerCC(int ccNumber, float ccValue, float randValue) noexcept
|
||||||
|
|
||||||
sequenceSwitched_ =
|
sequenceSwitched_ =
|
||||||
((sequenceCounter_++ % region.sequenceLength) == region.sequencePosition - 1);
|
((sequenceCounter_++ % region.sequenceLength) == region.sequencePosition - 1);
|
||||||
if (isSwitchedOn())
|
|
||||||
|
if (isSwitchedOn() && (ccValue != midiState_.getCCValue(ccNumber)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1983,10 +1983,10 @@ TEST_CASE("[Synth] Sequences also work on cc triggers")
|
||||||
synth.cc(0, 61, 20);
|
synth.cc(0, 61, 20);
|
||||||
synth.renderBlock(buffer);
|
synth.renderBlock(buffer);
|
||||||
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw" } );
|
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw" } );
|
||||||
synth.cc(0, 61, 20);
|
synth.cc(0, 61, 21);
|
||||||
synth.renderBlock(buffer);
|
synth.renderBlock(buffer);
|
||||||
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw" } );
|
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw" } );
|
||||||
synth.cc(0, 61, 20);
|
synth.cc(0, 61, 22);
|
||||||
synth.renderBlock(buffer);
|
synth.renderBlock(buffer);
|
||||||
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw", "*sine" } );
|
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine", "*saw", "*sine" } );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue