summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/debug.h1
-rw-r--r--libs/ardour/debug.cc1
-rw-r--r--libs/surfaces/generic_midi/generic_midi_control_protocol.cc8
-rw-r--r--libs/surfaces/generic_midi/midiaction.cc4
-rw-r--r--libs/surfaces/generic_midi/midicontrollable.cc24
-rw-r--r--libs/surfaces/generic_midi/midifunction.cc18
6 files changed, 52 insertions, 4 deletions
diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h
index 1c19d855bc..94974a1dcd 100644
--- a/libs/ardour/ardour/debug.h
+++ b/libs/ardour/ardour/debug.h
@@ -69,6 +69,7 @@ namespace PBD {
LIBARDOUR_API extern DebugBits AudioEngine;
LIBARDOUR_API extern DebugBits Soundcloud;
LIBARDOUR_API extern DebugBits Butler;
+ LIBARDOUR_API extern DebugBits GenericMidi;
}
}
diff --git a/libs/ardour/debug.cc b/libs/ardour/debug.cc
index 0a00e896d9..d7b7269e25 100644
--- a/libs/ardour/debug.cc
+++ b/libs/ardour/debug.cc
@@ -65,5 +65,6 @@ PBD::DebugBits PBD::DEBUG::Ports = PBD::new_debug_bit ("Ports");
PBD::DebugBits PBD::DEBUG::AudioEngine = PBD::new_debug_bit ("AudioEngine");
PBD::DebugBits PBD::DEBUG::Soundcloud = PBD::new_debug_bit ("Soundcloud");
PBD::DebugBits PBD::DEBUG::Butler = PBD::new_debug_bit ("Butler");
+PBD::DebugBits PBD::DEBUG::GenericMidi = PBD::new_debug_bit ("genericmidi");
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
index 85a81400c4..c13fee0e4f 100644
--- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
+++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
@@ -30,6 +30,7 @@
#include "pbd/failed_constructor.h"
#include "pbd/file_utils.h"
#include "pbd/xml++.h"
+#include "pbd/compose.h"
#include "midi++/port.h"
@@ -40,6 +41,7 @@
#include "ardour/midi_ui.h"
#include "ardour/rc_configuration.h"
#include "ardour/midiport_manager.h"
+#include "ardour/debug.h"
#include "generic_midi_control_protocol.h"
#include "midicontrollable.h"
@@ -174,6 +176,7 @@ GenericMidiControlProtocol::reload_maps ()
void
GenericMidiControlProtocol::drop_all ()
{
+ DEBUG_TRACE (DEBUG::GenericMidi, "Drop all bindings\n");
Glib::Threads::Mutex::Lock lm (pending_lock);
Glib::Threads::Mutex::Lock lm2 (controllables_lock);
@@ -201,6 +204,7 @@ GenericMidiControlProtocol::drop_all ()
void
GenericMidiControlProtocol::drop_bindings ()
{
+ DEBUG_TRACE (DEBUG::GenericMidi, "Drop bindings, leave learned\n");
Glib::Threads::Mutex::Lock lm2 (controllables_lock);
for (MIDIControllables::iterator i = controllables.begin(); i != controllables.end(); ) {
@@ -453,7 +457,7 @@ GenericMidiControlProtocol::create_binding (PBD::Controllable* control, int pos,
// Update the MIDI Controllable based on the the pos param
// Here is where a table lookup for user mappings could go; for now we'll just wing it...
mc->bind_midi(channel, MIDI::controller, value);
-
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Create binding: Channel: %1 Controller: %2 Value: %3 \n", channel, MIDI::controller, value));
controllables.push_back (mc);
}
}
@@ -597,6 +601,7 @@ GenericMidiControlProtocol::get_feedback () const
int
GenericMidiControlProtocol::load_bindings (const string& xmlpath)
{
+ DEBUG_TRACE (DEBUG::GenericMidi, "Load bindings: Reading midi map\n");
XMLTree state_tree;
if (!state_tree.read (xmlpath.c_str())) {
@@ -632,6 +637,7 @@ GenericMidiControlProtocol::load_bindings (const string& xmlpath)
drop_all ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Loading bindings\n");
for (citer = children.begin(); citer != children.end(); ++citer) {
if ((*citer)->name() == "DeviceInfo") {
diff --git a/libs/surfaces/generic_midi/midiaction.cc b/libs/surfaces/generic_midi/midiaction.cc
index e537122e9c..8dfbef9716 100644
--- a/libs/surfaces/generic_midi/midiaction.cc
+++ b/libs/surfaces/generic_midi/midiaction.cc
@@ -19,11 +19,14 @@
#include <cstring>
#include "midi++/port.h"
+#include "pbd/compose.h"
+#include "ardour/debug.h"
#include "midiaction.h"
#include "generic_midi_control_protocol.h"
using namespace MIDI;
+using namespace PBD;
MIDIAction::MIDIAction (MIDI::Parser& p)
: MIDIInvokable (p)
@@ -44,6 +47,7 @@ MIDIAction::init (GenericMidiControlProtocol& ui, const std::string& invokable_n
void
MIDIAction::execute ()
{
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Action: '%1'\n", _invokable_name));
_ui->access_action (_invokable_name);
}
diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc
index 1d96a073b0..b427bef03b 100644
--- a/libs/surfaces/generic_midi/midicontrollable.cc
+++ b/libs/surfaces/generic_midi/midicontrollable.cc
@@ -26,6 +26,7 @@
#include "pbd/controllable_descriptor.h"
#include "pbd/xml++.h"
#include "pbd/stacktrace.h"
+#include "pbd/compose.h"
#include "midi++/types.h" // Added by JE - 06-01-2009. All instances of 'byte' changed to 'MIDI::byte' (for clarification)
#include "midi++/port.h"
@@ -35,6 +36,7 @@
#include "ardour/automation_control.h"
#include "ardour/midi_ui.h"
#include "ardour/utils.h"
+#include "ardour/debug.h"
#include "midicontrollable.h"
#include "generic_midi_control_protocol.h"
@@ -268,10 +270,13 @@ MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /*is_on*/)
if (!controllable->is_toggle()) {
if (control_additional == msg->note_number) {
controllable->set_value (midi_to_control (msg->velocity));
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Note %1 value %2 %3\n", (int) msg->note_number, (float) midi_to_control (msg->velocity), current_uri() ));
}
} else {
if (control_additional == msg->note_number) {
- controllable->set_value (controllable->get_value() > 0.5f ? 0.0f : 1.0f);
+ float new_value = controllable->get_value() > 0.5f ? 0.0f : 1.0f;
+ controllable->set_value (new_value);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Note %1 Value %2 %3\n", (int) msg->note_number, (float) new_value, current_uri()));
}
}
@@ -317,13 +322,16 @@ MIDIControllable::midi_sense_controller (Parser &, EventTwoBytes *msg)
if (in_sync || _surface->motorised ()) {
controllable->set_value (midi_to_control (new_value));
}
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI CC %1 value %2 %3\n", (int) msg->controller_number, (float) midi_to_control(new_value), current_uri() ));
last_controllable_value = new_value;
} else {
if (msg->value > 64.0f) {
controllable->set_value (1);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 1 %2\n", (int) msg->controller_number, current_uri()));
} else {
controllable->set_value (0);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Midi CC %1 value 0 %2\n", (int) msg->controller_number, current_uri()));
}
}
@@ -342,8 +350,11 @@ MIDIControllable::midi_sense_program_change (Parser &, MIDI::byte msg)
if (!controllable->is_toggle()) {
controllable->set_value (midi_to_control (msg));
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI program %1 value %2 %3\n", (int) msg, (float) midi_to_control (msg), current_uri() ));
} else if (msg == control_additional) {
- controllable->set_value (controllable->get_value() > 0.5f ? 0.0f : 1.0f);
+ float new_value = controllable->get_value() > 0.5f ? 0.0f : 1.0f;
+ controllable->set_value (new_value);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI program %1 value %2 %3\n", (int) msg, (float) new_value, current_uri()));
}
last_value = (MIDI::byte) (controllable->get_value() * 127.0); // to prevent feedback fights
@@ -360,8 +371,11 @@ MIDIControllable::midi_sense_pitchbend (Parser &, pitchbend_t pb)
if (!controllable->is_toggle()) {
controllable->set_value (midi_to_control (pb));
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI pitchbend %1 value %2 %3\n", (int) control_channel, (float) midi_to_control (pb), current_uri() ));
} else {
- controllable->set_value (controllable->get_value() > 0.5f ? 0.0f : 1.0f);
+ float new_value = controllable->get_value() > 0.5f ? 0.0f : 1.0f;
+ controllable->set_value (new_value);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI pitchbend %1 value %2 %3\n", (int) control_channel, (float) new_value, current_uri()));
}
last_value = control_to_midi (controllable->get_value ());
@@ -437,6 +451,7 @@ MIDIControllable::bind_midi (channel_t chn, eventType ev, MIDI::byte additional)
default:
break;
}
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Controlable: bind_midi: %1 on Channel %2 value %3 \n", _control_description, chn_i + 1, (int) additional));
}
MIDI::byte*
@@ -452,6 +467,8 @@ MIDIControllable::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool /*forc
return buf;
}
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Feedback: %1 %2\n", control_description(), current_uri()));
+
*buf++ = (0xF0 & control_type) | (0xF & control_channel);
switch (control_type) {
@@ -464,6 +481,7 @@ MIDIControllable::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool /*forc
*buf++ = gm;
break;
}
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("MIDI out: Type %1 Channel %2 Bytes %3 %4\n", (int) control_type, (int) control_channel , (int) *(buf - 2), (int) *(buf - 1)));
last_value = gm;
bufsize -= 3;
diff --git a/libs/surfaces/generic_midi/midifunction.cc b/libs/surfaces/generic_midi/midifunction.cc
index b0dc95e4fc..e2fb317605 100644
--- a/libs/surfaces/generic_midi/midifunction.cc
+++ b/libs/surfaces/generic_midi/midifunction.cc
@@ -23,7 +23,12 @@
#include "midifunction.h"
#include "generic_midi_control_protocol.h"
+#include "pbd/compose.h"
+
+#include "ardour/debug.h"
+
using namespace MIDI;
+using namespace PBD;
MIDIFunction::MIDIFunction (MIDI::Parser& p)
: MIDIInvokable (p)
@@ -94,10 +99,12 @@ MIDIFunction::execute ()
switch (_function) {
case NextBank:
_ui->next_bank();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: next_bank\n");
break;
case PrevBank:
_ui->prev_bank();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: prev_bank\n");
break;
case SetBank:
@@ -105,39 +112,48 @@ MIDIFunction::execute ()
uint32_t bank;
sscanf (_argument.c_str(), "%d", &bank);
_ui->set_current_bank (bank);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: set_current_bank = %1\n", (int) bank));
}
break;
case TransportStop:
_ui->transport_stop ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_stop\n");
break;
case TransportRoll:
_ui->transport_play ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: transport_play\n");
break;
case TransportStart:
_ui->goto_start ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_start\n");
break;
case TransportZero:
// need this in BasicUI
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_zero-not implemented\n");
break;
case TransportEnd:
_ui->goto_end ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: goto_end\n");
break;
case TransportLoopToggle:
_ui->loop_toggle ();
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: loop_toggle\n");
break;
case TransportRecordEnable:
_ui->set_record_enable (true);
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = true\n");
break;
case TransportRecordDisable:
_ui->set_record_enable (false);
+ DEBUG_TRACE (DEBUG::GenericMidi, "Function: set_record_enable = false\n");
break;
case Select:
@@ -145,6 +161,7 @@ MIDIFunction::execute ()
uint32_t rid;
sscanf (_argument.c_str(), "%d", &rid);
_ui->SetRouteSelection (rid);
+ DEBUG_TRACE (DEBUG::GenericMidi, string_compose ("Function: SetRouteSelection = %1\n", rid));
}
break;
case TrackSetMute:
@@ -165,6 +182,7 @@ MIDIFunction::execute ()
XMLNode&
MIDIFunction::get_state ()
{
+
XMLNode* node = new XMLNode ("MIDIFunction");
return *node;
}