From 8ad30bb76ed9d90ce3f8e4698ec68a425067a3a9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 22 Jan 2014 23:59:24 +0100 Subject: configurable midi audition synth --- libs/ardour/ardour/auditioner.h | 3 +++ libs/ardour/ardour/rc_configuration_vars.h | 2 +- libs/ardour/auditioner.cc | 36 +++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 6 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h index fdebc8a931..e73824b669 100644 --- a/libs/ardour/ardour/auditioner.h +++ b/libs/ardour/ardour/auditioner.h @@ -123,6 +123,7 @@ class Auditioner : public Track bool via_monitor; bool _midi_audition; bool _synth_added; + bool _synth_changed; bool _queue_panic; boost::shared_ptr _diskstream_audio; @@ -130,6 +131,8 @@ class Auditioner : public Track boost::shared_ptr asynth; void drop_ports (); + void lookup_synth (); + void config_changed (std::string); static void *_drop_ports (void *); void actually_drop_ports (); void output_changed (IOChange, void*); diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index 431ef84a59..3c74f067ae 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -114,7 +114,7 @@ CONFIG_VARIABLE (std::string, monitor_bus_preferred_bundle, "monitor-bus-preferr CONFIG_VARIABLE (bool, quieten_at_speed, "quieten-at-speed", true) CONFIG_VARIABLE (bool, link_send_and_route_panner, "link-send-and-route-panner", true) -CONFIG_VARIABLE (std::string, midi_audition_synth_uri, "midi-audition-synth-uri,", "https://community.ardour.org/node/7596") +CONFIG_VARIABLE (std::string, midi_audition_synth_uri, "midi-audition-synth-uri", "https://community.ardour.org/node/7596") /* click */ diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index fd640f8e3e..3e382625a0 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -51,6 +51,7 @@ Auditioner::Auditioner (Session& s) , via_monitor (false) , _midi_audition (false) , _synth_added (false) + , _synth_changed (false) , _queue_panic (false) { } @@ -68,6 +69,21 @@ Auditioner::init () _output->add_port ("Midiaudition", this, DataType::MIDI); + lookup_synth(); + + _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2)); + Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Auditioner::config_changed, this, _1)); + + return 0; +} + +Auditioner::~Auditioner () +{ +} + +void +Auditioner::lookup_synth () +{ string plugin_id = Config->get_midi_audition_synth_uri(); boost::shared_ptr p; if (!plugin_id.empty()) { @@ -84,14 +100,14 @@ Auditioner::init () if (p) { asynth = boost::shared_ptr (new PluginInsert (_session, p)); } - - _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2)); - - return 0; } -Auditioner::~Auditioner () +void +Auditioner::config_changed (std::string p) { + if (p == "midi-audition-synth-uri") { + _synth_changed = true; + } } int @@ -393,6 +409,16 @@ Auditioner::audition_region (boost::shared_ptr region) ProcessorStreams ps; + if (_synth_changed && _synth_added) { + remove_processor(asynth); + _synth_added = false; + } + if (_synth_changed && !_synth_added) { + _synth_added = false; + lookup_synth(); + } + + if (!_synth_added && asynth) { int rv = add_processor_by_index(asynth, PreFader, &ps, true); if (rv) { -- cgit v1.2.3