#include "pbd/abstract_ui.cc" // instantiate template
+#define NUCLEUS_DEBUG 1
+
MackieMidiBuilder builder;
#define midi_ui_context() MidiControlUI::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
MackieControlProtocol::port_for_id (uint32_t index)
{
uint32_t current_max = 0;
+
for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) {
current_max += (*it)->strips();
- if (index < current_max) return **it;
+ if (index < current_max) {
+ return **it;
+ }
}
// oops - no matching port
ostringstream os;
os << "No port for index " << index;
+ cerr << "No port for index " << index << endl;
throw MackieControlException (os.str());
}
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("switch to %1, %2\n", _current_initial_bank, end_pos));
- // clear out routes from our table in case any have been deleted
- for (vector<boost::shared_ptr<Route> >::iterator i = route_table.begin(); i != route_table.end(); ++i) {
- i->reset ();
- }
+ route_table.clear ();
+ set_route_table_size (surface().strips.size());
// link routes to strips
uint32_t i = 0;
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("remote id %1 connecting %2 to %3 with port %4\n",
route->remote_control_id(), route->name(), strip.name(), port_for_id(i)));
- route_table[i] = route;
+ set_route_table (1, route);
RouteSignal * rs = new RouteSignal (route, *this, strip, port_for_id(i));
route_signals.push_back (rs);
// update strip from route
}
void
-MackieControlProtocol::add_port (MIDI::Port & midi_input_port, MIDI::Port & midi_output_port, int number)
+MackieControlProtocol::add_port (MIDI::Port & midi_input_port, MIDI::Port & midi_output_port, int number, MackiePort::port_type_t port_type)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("add port %1 %2\n", midi_input_port.name(), midi_output_port.name()));
- MackiePort * sport = new MackiePort (*this, midi_input_port, midi_output_port, number);
+ MackiePort * sport = new MackiePort (*this, midi_input_port, midi_output_port, number, port_type);
_ports.push_back (sport);
sport->init_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_port_init, this, sport));
throw MackieControlException (os.str());
}
- add_port (*midi_input_port, *midi_output_port, 0);
+ add_port (*midi_input_port, *midi_output_port, 0, MackiePort::mcu);
/* Create extender ports */
new MIDI::Port (string_compose (_("mcu_xt_%1 out"), index), MIDI::Port::IsOutput, session->engine().jack())
);
if (midi_input_port->ok() && midi_output_port->ok()) {
- add_port (*midi_input_port, *midi_output_port, index);
+ add_port (*midi_input_port, *midi_output_port, index, MackiePort::ext);
}
}
}
}
_surface->init();
-
- // Connect events. Must be after route table otherwise there will be trouble
-
- for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) {
- (*it)->control_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3));
- }
}
void
{
// find the route for the control, if there is one
boost::shared_ptr<Route> route;
+
if (control.group().is_strip()) {
if (control.group().is_master()) {
+ DEBUG_TRACE (DEBUG::MackieControl, "master strip control event\n");
route = master_route();
} else {
uint32_t index = control.ordinal() - 1 + (port.number() * port.strips());
- if (index < route_table.size())
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip control event, index = %1, rt size = %2\n",
+ index, route_table.size()));
+ if (index < route_table.size()) {
route = route_table[index];
- else
+ if (route) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("modifying %1\n", route->name()));
+ } else {
+ DEBUG_TRACE (DEBUG::MackieControl, "no route found!\n");
+ }
+ } else {
cerr << "Warning: index is " << index << " which is not in the route table, size: " << route_table.size() << endl;
+ DEBUG_TRACE (DEBUG::MackieControl, "illegal route index found!\n");
+ }
}
}
// at which point the fader should just reset itself
if (route != 0)
{
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", state.pos));
+
route->gain_control()->set_value (slider_position_to_gain (state.pos));
if (ARDOUR::Config->get_mackie_emulation() == "bcf") {
case Control::type_button:
if (control.group().is_strip()) {
// strips
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip button %1\n", control.id()));
if (route != 0) {
handle_strip_button (port, control, state.button_state, route);
} else {
}
} else if (control.group().is_master()) {
// master fader touch
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("master strip button %1\n", control.id()));
if (route != 0) {
handle_strip_button (port, control, state.button_state, route);
}
} else {
// handle all non-strip buttons
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("global button %1\n", control.id()));
surface().handle_button (*this, state.button_state, dynamic_cast<Button&> (control));
}
break;
// pot (jog wheel, external control)
case Control::type_pot:
if (control.group().is_strip()) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip pot %1\n", control.id()));
if (route) {
boost::shared_ptr<Panner> panner = route->panner_shell()->panner();
// pan for mono input routes, or stereo linked panners
// it's a pot for an umnapped route, so turn all the lights off
port.write (builder.build_led_ring (dynamic_cast<Pot &> (control), off));
}
- }
- else
- {
+ } else {
if (control.is_jog()) {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Jog wheel moved %1\n", state.ticks));
_jog_wheel.jog_event (port, control, state);
} else {
+ DEBUG_TRACE (DEBUG::MackieControl, string_compose ("External controller moved %1\n", state.ticks));
cout << "external controller" << state.ticks * state.sign << endl;
}
}
try {
Strip & strip = route_signal->strip();
- /* XXX: not sure about this check to only display stuff for strips of index < 8 */
- if (!strip.is_master() && strip.index() < 8) {
+ if (!strip.is_master()) {
string line1;
string fullname = route_signal->route()->name();
line1 = PBD::short_version (fullname, 6);
}
+#ifdef NUCLEUS_DEBUG
+ cerr << "show strip name from " << fullname << " as " << line1 << endl;
+#endif
+
SurfacePort & port = route_signal->port();
port.write (builder.strip_display (port, strip, 0, line1));
port.write (builder.strip_display_blank (port, strip, 1));
subdiv = 3;
}
- uint32_t subdivisions = bbt_time.ticks / uint32_t (Timecode::BBT_Time::ticks_per_bar_division / subdiv);
- uint32_t ticks = bbt_time.ticks % uint32_t (Timecode::BBT_Time::ticks_per_bar_division / subdiv);
+ uint32_t subdivisions = bbt_time.ticks / uint32_t (Timecode::BBT_Time::ticks_per_beat / subdiv);
+ uint32_t ticks = bbt_time.ticks % uint32_t (Timecode::BBT_Time::ticks_per_beat / subdiv);
os << setw(2) << setfill('0') << subdivisions + 1;
os << setw(3) << setfill('0') << ticks;