provide access to Send + Plugins from MIDI binding maps

git-svn-id: svn://localhost/ardour2/branches/3.0@6416 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-12-30 19:33:52 +00:00
parent 4927f54300
commit d9c9acaa80
4 changed files with 113 additions and 6 deletions

View file

@ -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; }

View file

@ -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> ();
}

View file

@ -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 ();
}

View file

@ -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;
}