+ if (_route) {
+ _surface->write (display (1, vpot_mode_string()));
+ } else {
+ _surface->write (blank_display (1));
+ }
+
+ clear_display_reset ();
+}
+
+struct RouteCompareByName {
+ bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
+ return a->name().compare (b->name()) < 0;
+ }
+};
+
+void
+Strip::maybe_add_to_bundle_map (BundleMap& bm, boost::shared_ptr<Bundle> b, bool for_input, const ChanCount& channels)
+{
+ if (b->ports_are_outputs() == !for_input || b->nchannels() != channels) {
+ return;
+ }
+
+ bm[b->name()] = b;
+}
+
+void
+Strip::build_input_list (const ChanCount& channels)
+{
+ boost::shared_ptr<ARDOUR::BundleList> b = _surface->mcp().get_session().bundles ();
+
+ input_bundles.clear ();
+
+ /* give user bundles first chance at being in the menu */
+
+ for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
+ maybe_add_to_bundle_map (input_bundles, *i, true, channels);
+ }
+ }
+
+ for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
+ maybe_add_to_bundle_map (input_bundles, *i, true, channels);
+ }
+ }
+
+ boost::shared_ptr<ARDOUR::RouteList> routes = _surface->mcp().get_session().get_routes ();
+ RouteList copy = *routes;
+ copy.sort (RouteCompareByName ());
+
+ for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
+ maybe_add_to_bundle_map (input_bundles, (*i)->output()->bundle(), true, channels);
+ }
+
+}
+
+void
+Strip::build_output_list (const ChanCount& channels)
+{
+ boost::shared_ptr<ARDOUR::BundleList> b = _surface->mcp().get_session().bundles ();
+
+ output_bundles.clear ();
+
+ /* give user bundles first chance at being in the menu */
+
+ for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
+ maybe_add_to_bundle_map (output_bundles, *i, false, channels);
+ }
+ }
+
+ for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
+ if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
+ maybe_add_to_bundle_map (output_bundles, *i, false, channels);
+ }
+ }
+
+ boost::shared_ptr<ARDOUR::RouteList> routes = _surface->mcp().get_session().get_routes ();
+ RouteList copy = *routes;
+ copy.sort (RouteCompareByName ());
+
+ for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
+ maybe_add_to_bundle_map (output_bundles, (*i)->input()->bundle(), false, channels);
+ }
+}
+
+void
+Strip::next_pot_mode ()
+{
+ vector<PotMode>::iterator i;
+
+ if (_surface->mcp().flip_mode()) {
+ /* do not change vpot mode while in flipped mode */
+ DEBUG_TRACE (DEBUG::MackieControl, "not stepping pot mode - in flip mode\n");
+ _surface->write (display (1, "Flip"));
+ queue_display_reset (1000);
+ return;
+ }
+
+ for (i = current_pot_modes.begin(); i != current_pot_modes.end(); ++i) {
+ if ((*i) == _vpot_mode) {
+ break;
+ }
+ }
+
+ /* move to the next mode in the list, or back to the start (which will
+ also happen if the current mode is not in the current pot mode list)
+ */
+
+ if (i != current_pot_modes.end()) {
+ ++i;
+ }
+
+ if (i == current_pot_modes.end()) {
+ i = current_pot_modes.begin();
+ }
+
+ set_vpot_mode (*i);
+}
+
+void
+Strip::set_vpot_mode (PotMode m)
+{
+ boost::shared_ptr<Send> send;
+ boost::shared_ptr<Pannable> pannable;
+
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to vpot mode %1\n", m));
+
+ if (!_route) {
+ return;
+ }
+
+ _vpot_mode = m;
+
+ /* one of these is unnecessary, but its not worth trying to find
+ out which - it will just cause one additional message to be
+ sent to the surface.
+ */
+
+ _last_pan_position_written = -1;
+ _last_gain_position_written = -1;
+
+ switch (_vpot_mode) {
+ case Gain:
+ break;
+ case PanAzimuth:
+ pannable = _route->pannable ();
+ if (pannable) {
+ if (_surface->mcp().flip_mode()) {
+ /* gain to vpot, pan azi to fader */
+ _vpot->set_control (_route->gain_control());
+ if (pannable) {
+ _fader->set_control (pannable->pan_azimuth_control);
+ }
+ _vpot_mode = Gain;
+ } else {
+ /* gain to fader, pan azi to vpot */
+ _fader->set_control (_route->gain_control());
+ if (pannable) {
+ _vpot->set_control (pannable->pan_azimuth_control);
+ }
+ }
+ }
+ break;
+ case PanWidth:
+ pannable = _route->pannable ();
+ if (pannable) {
+ if (_surface->mcp().flip_mode()) {
+ /* gain to vpot, pan width to fader */
+ _vpot->set_control (_route->gain_control());
+ if (pannable) {
+ _fader->set_control (pannable->pan_width_control);
+ }
+ _vpot_mode = Gain;
+ } else {
+ /* gain to fader, pan width to vpot */
+ _fader->set_control (_route->gain_control());
+ if (pannable) {
+ _vpot->set_control (pannable->pan_width_control);
+ }
+ }
+ }
+ break;
+ case PanElevation:
+ break;
+ case PanFrontBack:
+ break;
+ case PanLFE:
+ break;
+ case Input:
+ break;
+ case Output:
+ break;
+ case Send1:
+ send = boost::dynamic_pointer_cast<Send> (_route->nth_send (0));
+ if (send) {
+ if (_surface->mcp().flip_mode()) {
+ /* route gain to vpot, send gain to fader */
+ _fader->set_control (send->amp()->gain_control());
+ _vpot->set_control (_route->gain_control());
+ _vpot_mode = Gain;
+ } else {
+ /* route gain to fader, send gain to vpot */
+ _vpot->set_control (send->amp()->gain_control());
+ _fader->set_control (_route->gain_control());
+ }
+ }
+ break;
+ case Send2:
+ break;
+ case Send3:
+ break;
+ case Send4:
+ break;
+ case Send5:
+ break;
+ case Send6:
+ break;
+ case Send7:
+ break;
+ case Send8:
+ break;
+ };
+
+ _surface->write (display (1, vpot_mode_string()));