diff options
author | Carl Hetherington <carl@carlh.net> | 2010-07-28 00:43:15 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-07-28 00:43:15 +0000 |
commit | 922488427a09fdfd4f4685bb114bdc992680a39f (patch) | |
tree | b87e10f738e9d7a91b96a6fca708a5fbbfad0fcd /libs/ardour | |
parent | 623f37fd36d71c1f676e97cc8614b7d14e70c56b (diff) |
Add session MIDI bundles to enable connection of MIDI tracks from the right-click I/O menus.
git-svn-id: svn://localhost/ardour2/branches/3.0@7517 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 7 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 10 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 81 | ||||
-rw-r--r-- | libs/ardour/session.cc | 48 |
4 files changed, 78 insertions, 68 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 9a0104b8fe..78d0a03e6a 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -44,6 +44,7 @@ #include "ardour/data_type.h" #include "ardour/session_handle.h" #include "ardour/types.h" +#include "ardour/chan_count.h" #ifdef HAVE_JACK_SESSION #include <jack/session.h> @@ -162,8 +163,8 @@ class AudioEngine : public SessionHandlePtr bool can_request_hardware_monitoring (); - uint32_t n_physical_outputs (DataType type) const; - uint32_t n_physical_inputs (DataType type) const; + ChanCount n_physical_outputs () const; + ChanCount n_physical_inputs () const; void get_physical_outputs (DataType type, std::vector<std::string>&); void get_physical_inputs (DataType type, std::vector<std::string>&); @@ -282,6 +283,8 @@ _ the regular process() call to session->process() is not made. void remove_all_ports (); std::string get_nth_physical (DataType type, uint32_t n, int flags); + ChanCount n_physical (unsigned long) const; + void get_physical (DataType, unsigned long, std::vector<std::string> &); void port_registration_failure (const std::string& portname); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 4627204888..0b26444bce 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1367,14 +1367,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi based on max (requested,available) */ - uint32_t n_physical_outputs; - uint32_t n_physical_inputs; - - uint32_t n_physical_audio_outputs; - uint32_t n_physical_audio_inputs; - - uint32_t n_physical_midi_outputs; - uint32_t n_physical_midi_inputs; + ChanCount n_physical_outputs; + ChanCount n_physical_inputs; int find_all_sources (std::string path, std::set<std::string>& result); int find_all_sources_across_snapshots (std::set<std::string>& result, bool exclude_this_snapshot); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index b2a18e2750..39c8d71534 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1109,58 +1109,49 @@ AudioEngine::can_request_hardware_monitoring () return true; } - -uint32_t -AudioEngine::n_physical_outputs (DataType type) const +ChanCount +AudioEngine::n_physical (unsigned long flags) const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); - const char ** ports; - uint32_t cnt = 0; + ChanCount c; + + GET_PRIVATE_JACK_POINTER_RET (_jack, c); - if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsInput)) == 0) { - return 0; + const char ** ports = jack_get_ports (_priv_jack, NULL, NULL, JackPortIsPhysical | flags); + if (ports == 0) { + return c; } for (uint32_t i = 0; ports[i]; ++i) { - if (!strstr (ports[i], "Midi-Through")) { - cnt++; - } - } + if (!strstr (ports[i], "Midi-Through")) { + DataType t (jack_port_type (jack_port_by_name (_jack, ports[i]))); + c.set (t, c.get (t) + 1); + } + } free (ports); - return cnt; + return c; } -uint32_t -AudioEngine::n_physical_inputs (DataType type) const +ChanCount +AudioEngine::n_physical_inputs () const { - GET_PRIVATE_JACK_POINTER_RET (_jack,0); - const char ** ports; - uint32_t cnt = 0; - - if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsOutput)) == 0) { - return 0; - } - - for (uint32_t i = 0; ports[i]; ++i) { - if (!strstr (ports[i], "Midi-Through")) { - cnt++; - } - } - - free (ports); + return n_physical (JackPortIsInput); +} - return cnt; +ChanCount +AudioEngine::n_physical_outputs () const +{ + return n_physical (JackPortIsOutput); } void -AudioEngine::get_physical_inputs (DataType type, vector<string>& ins) +AudioEngine::get_physical (DataType type, unsigned long flags, vector<string>& phy) { GET_PRIVATE_JACK_POINTER (_jack); const char ** ports; - if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsOutput)) == 0) { + if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical | flags)) == 0) { return; } @@ -1169,30 +1160,22 @@ AudioEngine::get_physical_inputs (DataType type, vector<string>& ins) if (strstr (ports[i], "Midi-Through")) { continue; } - ins.push_back (ports[i]); + phy.push_back (ports[i]); } free (ports); } } void -AudioEngine::get_physical_outputs (DataType type, vector<string>& outs) +AudioEngine::get_physical_inputs (DataType type, vector<string>& ins) { - GET_PRIVATE_JACK_POINTER (_jack); - const char ** ports; - uint32_t i = 0; - - if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|JackPortIsInput)) == 0) { - return; - } + get_physical (type, JackPortIsInput, ins); +} - for (i = 0; ports[i]; ++i) { - if (strstr (ports[i], "Midi-Through")) { - continue; - } - outs.push_back (ports[i]); - } - free (ports); +void +AudioEngine::get_physical_outputs (DataType type, vector<string>& outs) +{ + get_physical (type, JackPortIsOutput, outs); } string diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 71277fa3cf..5485924f4a 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -35,6 +35,8 @@ #include <glibmm/miscutils.h> #include <glibmm/fileutils.h> +#include <boost/algorithm/string/erase.hpp> + #include "pbd/error.h" #include "pbd/boost_debug.h" #include "pbd/pathscanner.h" @@ -163,8 +165,8 @@ Session::Session (AudioEngine &eng, throw failed_constructor(); } - n_physical_outputs = _engine.n_physical_outputs(DataType::AUDIO); - n_physical_inputs = _engine.n_physical_inputs(DataType::AUDIO); + n_physical_outputs = _engine.n_physical_outputs (); + n_physical_inputs = _engine.n_physical_inputs (); first_stage_init (fullpath, snapshot_name); @@ -435,7 +437,7 @@ Session::when_engine_running () /* mono output bundles */ - for (uint32_t np = 0; np < n_physical_outputs; ++np) { + for (uint32_t np = 0; np < n_physical_outputs.n_audio(); ++np) { char buf[32]; snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1); @@ -448,8 +450,8 @@ Session::when_engine_running () /* stereo output bundles */ - for (uint32_t np = 0; np < n_physical_outputs; np += 2) { - if (np + 1 < n_physical_outputs) { + for (uint32_t np = 0; np < n_physical_outputs.n_audio(); np += 2) { + if (np + 1 < n_physical_outputs.n_audio ()) { char buf[32]; snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2); shared_ptr<Bundle> c (new Bundle (buf, true)); @@ -464,7 +466,7 @@ Session::when_engine_running () /* mono input bundles */ - for (uint32_t np = 0; np < n_physical_inputs; ++np) { + for (uint32_t np = 0; np < n_physical_inputs.n_audio(); ++np) { char buf[32]; snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1); @@ -477,8 +479,8 @@ Session::when_engine_running () /* stereo input bundles */ - for (uint32_t np = 0; np < n_physical_inputs; np += 2) { - if (np + 1 < n_physical_inputs) { + for (uint32_t np = 0; np < n_physical_inputs.n_audio(); np += 2) { + if (np + 1 < n_physical_inputs.n_audio()) { char buf[32]; snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2); @@ -492,6 +494,34 @@ Session::when_engine_running () } } + /* MIDI input bundles */ + + for (uint32_t np = 0; np < n_physical_inputs.n_midi(); ++np) { + string const p = _engine.get_nth_physical_input (DataType::MIDI, np); + + string n = p; + boost::erase_first (n, X_("alsa_pcm:")); + + shared_ptr<Bundle> c (new Bundle (n, false)); + c->add_channel ("", DataType::MIDI); + c->set_port (0, p); + add_bundle (c); + } + + /* MIDI output bundles */ + + for (uint32_t np = 0; np < n_physical_outputs.n_midi(); ++np) { + string const p = _engine.get_nth_physical_output (DataType::MIDI, np); + + string n = p; + boost::erase_first (n, X_("alsa_pcm:")); + + shared_ptr<Bundle> c (new Bundle (n, true)); + c->add_channel ("", DataType::MIDI); + c->set_port (0, p); + add_bundle (c); + } + BootMessage (_("Setup signal flow and plugins")); hookup_io (); @@ -569,7 +599,7 @@ Session::when_engine_running () } else { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { - uint32_t mod = _engine.n_physical_outputs (*t); + uint32_t mod = n_physical_outputs.get (*t); uint32_t limit = _monitor_out->n_outputs().get(*t); for (uint32_t n = 0; n < limit; ++n) { |