summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-12-30 19:33:52 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-12-30 19:33:52 +0000
commitd9c9acaa80d1701b210eae82f5a365cb3e63c56a (patch)
tree663f947531ab835854df2386f57549b62db2255a
parent4927f54300d0df934e9da6b90e9586853242df86 (diff)
provide access to Send + Plugins from MIDI binding maps
git-svn-id: svn://localhost/ardour2/branches/3.0@6416 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/route.h3
-rw-r--r--libs/ardour/route.cc40
-rw-r--r--libs/ardour/session_state.cc62
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc14
4 files changed, 113 insertions, 6 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index ac945703fd..22ca95d4ec 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -181,6 +181,9 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
}
}
+ boost::shared_ptr<Processor> nth_plugin (uint32_t n);
+ boost::shared_ptr<Processor> nth_send (uint32_t n);
+
bool processor_is_prefader (boost::shared_ptr<Processor> p);
ChanCount max_processor_streams () const { return processor_max_streams; }
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index c5d26f7b7c..69b37fb7c3 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -141,6 +141,9 @@ Route::init ()
/* add standard controls */
+ _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
+ _mute_master->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
+
add_control (_solo_control);
add_control (_mute_master);
@@ -3105,3 +3108,40 @@ Route::get_control (const Evoral::Parameter& param)
return c;
}
+
+boost::shared_ptr<Processor>
+Route::nth_plugin (uint32_t n)
+{
+ Glib::RWLock::ReaderLock lm (_processor_lock);
+ ProcessorList::iterator i;
+
+ for (i = _processors.begin(); i != _processors.end(); ++i) {
+ if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
+ if (n-- == 0) {
+ return *i;
+ }
+ }
+ }
+
+ return boost::shared_ptr<Processor> ();
+}
+
+boost::shared_ptr<Processor>
+Route::nth_send (uint32_t n)
+{
+ Glib::RWLock::ReaderLock lm (_processor_lock);
+ ProcessorList::iterator i;
+
+ for (i = _processors.begin(); i != _processors.end(); ++i) {
+ cerr << "check " << (*i)->name() << endl;
+ if (boost::dynamic_pointer_cast<Send> (*i)) {
+ if (n-- == 0) {
+ return *i;
+ }
+ } else {
+ cerr << "\tnot a send\n";
+ }
+ }
+
+ return boost::shared_ptr<Processor> ();
+}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 6a72777c7c..3c8fe86c13 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -64,6 +64,7 @@
#include "pbd/search_path.h"
#include "pbd/stacktrace.h"
+#include "ardour/amp.h"
#include "ardour/audio_diskstream.h"
#include "ardour/audio_track.h"
#include "ardour/audioengine.h"
@@ -2695,9 +2696,70 @@ Session::controllable_by_rid_and_name (uint32_t rid, const char* const what)
} else if (strncmp (what, "mute", 4) == 0) {
c = r->mute_control();
} else if (strncmp (what, "pan", 3) == 0) {
+
+ /* XXX pan control */
+
} else if (strncmp (what, "plugin", 6) == 0) {
+
+ /* parse to identify plugin & parameter */
+
+ uint32_t plugin;
+ uint32_t parameter_index;
+
+ if (sscanf (what, "plugin%" PRIu32 ":%" PRIu32, &plugin, &parameter_index) == 2) {
+
+ /* revert to zero based counting */
+
+ if (plugin > 0) {
+ --plugin;
+ }
+
+ if (parameter_index > 0) {
+ --parameter_index;
+ }
+
+ boost::shared_ptr<Processor> p = r->nth_plugin (plugin);
+
+ if (p) {
+ c = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
+ p->data().control(Evoral::Parameter(PluginAutomation, 0, parameter_index)));
+ }
+ }
+
+ } else if (strncmp (what, "send", 4) == 0) {
+
+ /* parse to identify send & property */
+
+ uint32_t send;
+ char property[64];
+
+ if (sscanf (what, "send%" PRIu32 ":%63s", &send, property) == 2) {
+
+ /* revert to zero-based counting */
+
+ if (send > 0) {
+ --send;
+ }
+
+ boost::shared_ptr<Processor> p = r->nth_send (send);
+
+ if (p) {
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+
+ if (strcmp (property, "gain") == 0) {
+ boost::shared_ptr<Amp> a = s->amp();
+ if (a) {
+ c = s->amp()->gain_control();
+ }
+ }
+ /* XXX pan control */
+ }
+ }
+
} else if (strncmp (what, "recenable", 9) == 0) {
+
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(r);
+
if (t) {
c = t->rec_enable_control ();
}
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index 5c23628a64..2942a94ad2 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -192,17 +192,19 @@ MIDIControllable::midi_to_control(float val)
float control_min = 0.0f;
float control_max = 1.0f;
ARDOUR::AutomationControl* ac = dynamic_cast<ARDOUR::AutomationControl*>(controllable);
+
+ const float midi_range = 127.0f; // TODO: NRPN etc.
+
if (ac) {
+
+ if (ac->is_gain_like()) {
+ return slider_position_to_gain (val/midi_range);
+ }
+
control_min = ac->parameter().min();
control_max = ac->parameter().max();
}
- const float midi_range = 127.0f; // TODO: NRPN etc.
-
- if (ac->is_gain_like()) {
- return slider_position_to_gain (val/midi_range);
- }
-
const float control_range = control_max - control_min;
return val / midi_range * control_range + control_min;
}