summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/generic_midi/SConscript9
-rw-r--r--libs/surfaces/generic_midi/generic_midi_control_protocol.cc26
-rw-r--r--libs/surfaces/generic_midi/generic_midi_control_protocol.h4
-rw-r--r--libs/surfaces/generic_midi/interface.cc10
-rw-r--r--libs/surfaces/tranzport/interface.cc12
-rw-r--r--libs/surfaces/tranzport/tranzport_control_protocol.cc275
-rw-r--r--libs/surfaces/tranzport/tranzport_control_protocol.h15
7 files changed, 259 insertions, 92 deletions
diff --git a/libs/surfaces/generic_midi/SConscript b/libs/surfaces/generic_midi/SConscript
index abede3f4d7..51e0ff88c8 100644
--- a/libs/surfaces/generic_midi/SConscript
+++ b/libs/surfaces/generic_midi/SConscript
@@ -29,12 +29,13 @@ genericmidi.Append(CXXFLAGS="-DDATA_DIR=\\\""+final_prefix+"/share\\\"")
genericmidi.Append(CXXFLAGS="-DCONFIG_DIR=\\\""+final_config_prefix+"\\\"")
genericmidi.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
+genericmidi.Append(CPPPATH=libraries['ardour'].get ('CPPPATH', []))
+genericmidi.Append(CPPPATH=libraries['sigc2'].get ('CPPPATH', []))
+genericmidi.Append(CPPPATH=libraries['pbd3'].get ('CPPPATH', []))
+genericmidi.Append(CPPPATH=libraries['midi++2'].get ('CPPPATH', []))
+
genericmidi.Merge ([
libraries['usb'],
- libraries['ardour'],
- libraries['sigc2'],
- libraries['pbd3'],
- libraries['midi++2'],
libraries['xml']
])
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
index 4d64c6ce23..61a8b7974e 100644
--- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
+++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
@@ -1,3 +1,5 @@
+#include <midi++/port.h>
+
#include <ardour/route.h>
#include <ardour/session.h>
@@ -10,13 +12,28 @@ using namespace ARDOUR;
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
: ControlProtocol (s, _("GenericMIDI"))
{
- _port = 0;
+ _port = s.midi_port();
+ s.MIDI_PortChanged.connect (mem_fun (*this, &GenericMidiControlProtocol::port_change));
+
}
GenericMidiControlProtocol::~GenericMidiControlProtocol ()
{
}
+int
+GenericMidiControlProtocol::init ()
+{
+ /* start delivery/outbound thread */
+ return init_thread ();
+}
+
+void
+GenericMidiControlProtocol::port_change ()
+{
+ _port = session.midi_port ();
+}
+
void
GenericMidiControlProtocol::set_port (MIDI::Port* p)
{
@@ -29,20 +46,19 @@ GenericMidiControlProtocol::send_route_feedback (list<Route*>& routes)
if (_port != 0) {
const int32_t bufsize = 16 * 1024;
+ MIDI::byte buf[bufsize];
int32_t bsize = bufsize;
- MIDI::byte* buf = new MIDI::byte[bufsize];
MIDI::byte* end = buf;
for (list<Route*>::iterator r = routes.begin(); r != routes.end(); ++r) {
- end = (*r)->write_midi_feedback (end, bsize);
+ end = (*r)->write_midi_feedback (end, bsize);
}
if (end == buf) {
- delete [] buf;
return;
}
- session.deliver_midi (_port, buf, (int32_t) (end - buf));
+ _port->write (buf, (int32_t) (end - buf));
//cerr << "MIDI feedback: wrote " << (int32_t) (end - buf) << " to midi port\n";
}
}
diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h
index 75b514f016..54831b2982 100644
--- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h
+++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h
@@ -14,6 +14,8 @@ class GenericMidiControlProtocol : public ControlProtocol {
GenericMidiControlProtocol (Session&);
virtual ~GenericMidiControlProtocol();
+ int init ();
+
bool active() const;
void set_port (MIDI::Port*);
@@ -24,6 +26,8 @@ class GenericMidiControlProtocol : public ControlProtocol {
private:
void route_feedback (ARDOUR::Route&, bool);
MIDI::Port* _port;
+
+ void port_change ();
};
}
diff --git a/libs/surfaces/generic_midi/interface.cc b/libs/surfaces/generic_midi/interface.cc
index 8283b92e6f..500d745deb 100644
--- a/libs/surfaces/generic_midi/interface.cc
+++ b/libs/surfaces/generic_midi/interface.cc
@@ -7,7 +7,14 @@ using namespace ARDOUR;
ControlProtocol*
new_generic_midi_protocol (ControlProtocolDescriptor* descriptor, Session* s)
{
- return new GenericMidiControlProtocol (*s);
+ GenericMidiControlProtocol* gmcp = new GenericMidiControlProtocol (*s);
+
+ if (gmcp->init ()) {
+ delete gmcp;
+ return 0;
+ }
+
+ return gmcp;
}
void
@@ -18,6 +25,7 @@ delete_generic_midi_protocol (ControlProtocolDescriptor* descriptor, ControlProt
static ControlProtocolDescriptor generic_midi_descriptor = {
name : "Generic MIDI",
+ id : "uri://ardour.org/surfaces/generic_midi:0",
ptr : 0,
module : 0,
initialize : new_generic_midi_protocol,
diff --git a/libs/surfaces/tranzport/interface.cc b/libs/surfaces/tranzport/interface.cc
index a731be2ddf..f2160c3144 100644
--- a/libs/surfaces/tranzport/interface.cc
+++ b/libs/surfaces/tranzport/interface.cc
@@ -7,7 +7,15 @@ using namespace ARDOUR;
ControlProtocol*
new_tranzport_protocol (ControlProtocolDescriptor* descriptor, Session* s)
{
- return new TranzportControlProtocol (*s);
+ TranzportControlProtocol* tcp = new TranzportControlProtocol (*s);
+
+ if (tcp->init ()) {
+ delete tcp;
+ return 0;
+ }
+
+ return tcp;
+
}
void
@@ -18,10 +26,12 @@ delete_tranzport_protocol (ControlProtocolDescriptor* descriptor, ControlProtoco
static ControlProtocolDescriptor tranzport_descriptor = {
name : "Tranzport",
+ id : "uri://ardour.org/surfaces/tranzport:0",
ptr : 0,
module : 0,
initialize : new_tranzport_protocol,
destroy : delete_tranzport_protocol
+
};
diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.cc b/libs/surfaces/tranzport/tranzport_control_protocol.cc
index eee60c43eb..34ba54c8b6 100644
--- a/libs/surfaces/tranzport/tranzport_control_protocol.cc
+++ b/libs/surfaces/tranzport/tranzport_control_protocol.cc
@@ -34,6 +34,8 @@ TranzportControlProtocol::TranzportControlProtocol (Session& s)
wheel_shift_mode = WheelShiftGain;
timerclear (&last_wheel_motion);
last_wheel_dir = 1;
+ display_mode = DisplayNormal;
+ requested_display_mode = display_mode;
memset (current_screen, 0, sizeof (current_screen));
@@ -60,6 +62,15 @@ TranzportControlProtocol::init ()
return -1;
}
+ lcd_clear ();
+
+ print (0, 0, "Welcome to");
+ print (1, 0, "Ardour");
+
+ show_wheel_mode();
+ next_track ();
+ show_transport_time ();
+
/* outbound thread */
init_thread ();
@@ -85,17 +96,124 @@ TranzportControlProtocol::send_route_feedback (list<Route*>& routes)
void
TranzportControlProtocol::send_global_feedback ()
{
- if (_device_status == STATUS_OFFLINE) {
- return;
+ if (requested_display_mode != display_mode) {
+ switch (requested_display_mode) {
+ case DisplayNormal:
+ enter_normal_display_mode ();
+ break;
+ case DisplayBigMeter:
+ enter_big_meter_mode ();
+ break;
+ }
}
- show_transport_time ();
+ switch (display_mode) {
+ case DisplayBigMeter:
+ show_meter ();
+ break;
+
+ case DisplayNormal:
+ show_transport_time ();
+ if (session.soloing()) {
+ light_on (LightAnysolo);
+ } else {
+ light_off (LightAnysolo);
+ }
+ break;
+ }
+}
+
+void
+TranzportControlProtocol::next_display_mode ()
+{
+ cerr << "Next display mode\n";
+
+ switch (display_mode) {
+ case DisplayNormal:
+ requested_display_mode = DisplayBigMeter;
+ break;
+
+ case DisplayBigMeter:
+ requested_display_mode = DisplayNormal;
+ break;
+ }
+}
- if (session.soloing()) {
- light_on (LightAnysolo);
+void
+TranzportControlProtocol::enter_big_meter_mode ()
+{
+ lcd_clear ();
+ lights_off ();
+ display_mode = DisplayBigMeter;
+}
+
+void
+TranzportControlProtocol::enter_normal_display_mode ()
+{
+ lcd_clear ();
+ lights_off ();
+ show_current_track ();
+ show_wheel_mode ();
+ show_transport_time ();
+ display_mode = DisplayNormal;
+}
+
+
+float
+log_meter (float db)
+{
+ float def = 0.0f; /* Meter deflection %age */
+
+ if (db < -70.0f) {
+ def = 0.0f;
+ } else if (db < -60.0f) {
+ def = (db + 70.0f) * 0.25f;
+ } else if (db < -50.0f) {
+ def = (db + 60.0f) * 0.5f + 2.5f;
+ } else if (db < -40.0f) {
+ def = (db + 50.0f) * 0.75f + 7.5f;
+ } else if (db < -30.0f) {
+ def = (db + 40.0f) * 1.5f + 15.0f;
+ } else if (db < -20.0f) {
+ def = (db + 30.0f) * 2.0f + 30.0f;
+ } else if (db < 6.0f) {
+ def = (db + 20.0f) * 2.5f + 50.0f;
} else {
- light_off (LightAnysolo);
+ def = 115.0f;
}
+
+ /* 115 is the deflection %age that would be
+ when db=6.0. this is an arbitrary
+ endpoint for our scaling.
+ */
+
+ return def/115.0f;
+}
+
+void
+TranzportControlProtocol::show_meter ()
+{
+ if (current_route == 0) {
+ return;
+ }
+
+ float level = current_route->peak_input_power (0);
+ float fraction = log_meter (level);
+ int fill = (int) floor (fraction * 20);
+ char buf[21];
+ int i;
+
+ for (i = 0; i < fill; ++i) {
+ buf[i] = 0x70; /* tranzport special code for 4 quadrant LCD block */
+ }
+ for (; i < 20; ++i) {
+ buf[i] = ' ';
+ }
+
+ buf[21] = '\0';
+
+ print (0, 0, buf);
+ print (1, 0, buf);
}
void
@@ -141,33 +259,6 @@ TranzportControlProtocol::thread_work ()
{
PBD::ThreadCreated (pthread_self(), X_("tranzport monitor"));
- /* wait for the device to go online */
-
- while (true) {
- if (read()) {
- return 0;
- }
- switch (_device_status) {
- case STATUS_OFFLINE:
- cerr << "tranzport offline\n";
- break;
- case STATUS_ONLINE:
- case 0:
- cerr << "tranzport online\n";
- break;
- default:
- cerr << "tranzport: unknown status\n";
- break;
- }
-
- if (_device_status == STATUS_ONLINE || _device_status == 0) {
- break;
- }
- }
-
- lcd_clear ();
- show_wheel_mode();
-
while (true) {
if (read ()) {
break;
@@ -217,6 +308,13 @@ TranzportControlProtocol::open_core (struct usb_device* dev)
return -1;
}
+ if (usb_set_configuration (udev, 1) < 0) {
+ error << _("Tranzport: cannot configure USB interface") << endmsg;
+ usb_close (udev);
+ udev = 0;
+ return -1;
+ }
+
return 0;
}
@@ -276,7 +374,8 @@ TranzportControlProtocol::lcd_clear ()
cmd[7] = 0x00;
{
- LockMonitor lm (write_lock, __LINE__, __FILE__);
+ LockMonitor lp (print_lock, __LINE__, __FILE__);
+ LockMonitor lw (write_lock, __LINE__, __FILE__);
for (uint8_t i = 0; i < 10; ++i) {
cmd[2] = i;
@@ -287,35 +386,16 @@ TranzportControlProtocol::lcd_clear ()
}
}
-int
-TranzportControlProtocol::lcd_write (int row, int col, uint8_t cell, const char* text)
+void
+TranzportControlProtocol::lights_off ()
{
- uint8_t cmd[8];
-
- if (cell > 9) {
- return -1;
- }
-
- if (memcmp (text, &current_screen[row][col], 4)) {
-
- current_screen[row][col] = text[0];
- current_screen[row][col+1] = text[1];
- current_screen[row][col+2] = text[2];
- current_screen[row][col+3] = text[3];
-
- cmd[0] = 0x00;
- cmd[1] = 0x01;
- cmd[2] = cell;
- cmd[3] = text[0];
- cmd[4] = text[1];
- cmd[5] = text[2];
- cmd[6] = text[3];
- cmd[7] = 0x00;
-
- return write (cmd, 500);
- }
-
- return 0;
+ light_off (LightRecord);
+ light_off (LightTrackrec);
+ light_off (LightTrackmute);
+ light_off (LightTracksolo);
+ light_off (LightAnysolo);
+ light_off (LightLoop);
+ light_off (LightPunch);
}
int
@@ -865,7 +945,11 @@ TranzportControlProtocol::button_event_fastforward_release (bool shifted)
void
TranzportControlProtocol::button_event_stop_press (bool shifted)
{
- session.request_transport_speed (0.0);
+ if (shifted) {
+ next_display_mode ();
+ } else {
+ session.request_transport_speed (0.0);
+ }
}
void
@@ -1039,9 +1123,17 @@ void
TranzportControlProtocol::shuttle ()
{
if (_datawheel < WheelDirectionThreshold) {
- session.request_transport_speed (session.transport_speed() + 0.1);
+ if (session.transport_speed() < 0) {
+ session.request_transport_speed (1.0);
+ } else {
+ session.request_transport_speed (session.transport_speed() + 0.1);
+ }
} else {
- session.request_transport_speed (session.transport_speed() - 0.1);
+ if (session.transport_speed() > 0) {
+ session.request_transport_speed (-1.0);
+ } else {
+ session.request_transport_speed (session.transport_speed() - 0.1);
+ }
}
}
@@ -1254,23 +1346,46 @@ TranzportControlProtocol::print (int row, int col, const char *text)
int offset = col % 4;
- /* copy current cell contents into tmp */
-
- memcpy (tmp, &current_screen[row][base_col], 4);
-
- /* overwrite with new text */
+ {
- uint32_t tocopy = min ((4U - offset), left);
+ LockMonitor lm (print_lock, __LINE__, __FILE__);
- memcpy (tmp+offset, text, tocopy);
-
- cell += (row * 5);
-
- lcd_write (row, base_col, cell, tmp);
-
- text += tocopy;
- left -= tocopy;
- col += tocopy;
+ /* copy current cell contents into tmp */
+
+ memcpy (tmp, &current_screen[row][base_col], 4);
+
+ /* overwrite with new text */
+
+ uint32_t tocopy = min ((4U - offset), left);
+
+ memcpy (tmp+offset, text, tocopy);
+
+ uint8_t cmd[8];
+
+ /* compare with current screen */
+
+ if (memcmp (tmp, &current_screen[row][base_col], 4)) {
+
+ /* different, so update */
+
+ memcpy (&current_screen[row][base_col], tmp, 4);
+
+ cmd[0] = 0x00;
+ cmd[1] = 0x01;
+ cmd[2] = cell + (row * 5);
+ cmd[3] = tmp[0];
+ cmd[4] = tmp[1];
+ cmd[5] = tmp[2];
+ cmd[6] = tmp[3];
+ cmd[7] = 0x00;
+
+ write (cmd, 500);
+ }
+
+ text += tocopy;
+ left -= tocopy;
+ col += tocopy;
+ }
}
}
diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.h b/libs/surfaces/tranzport/tranzport_control_protocol.h
index c5aa5f90e0..d460a6c74a 100644
--- a/libs/surfaces/tranzport/tranzport_control_protocol.h
+++ b/libs/surfaces/tranzport/tranzport_control_protocol.h
@@ -77,6 +77,11 @@ class TranzportControlProtocol : public ControlProtocol {
WheelScrub,
WheelShuttle
};
+
+ enum DisplayMode {
+ DisplayNormal,
+ DisplayBigMeter
+ };
pthread_t thread;
uint32_t buttonmask;
@@ -92,6 +97,8 @@ class TranzportControlProtocol : public ControlProtocol {
WheelShiftMode wheel_shift_mode;
struct timeval last_wheel_motion;
int last_wheel_dir;
+ DisplayMode display_mode;
+ DisplayMode requested_display_mode;
std::vector<sigc::connection> track_connections;
@@ -103,6 +110,7 @@ class TranzportControlProtocol : public ControlProtocol {
jack_nframes_t last_where;
PBD::Lock write_lock;
+ PBD::Lock print_lock;
int open ();
int read (uint32_t timeout_override = 0);
@@ -112,16 +120,21 @@ class TranzportControlProtocol : public ControlProtocol {
int open_core (struct usb_device*);
void lcd_clear ();
- int lcd_write (int row, int col, uint8_t cell, const char *text);
void print (int row, int col, const char* text);
int light_on (LightID);
int light_off (LightID);
+ void lights_off ();
+
+ void enter_big_meter_mode ();
+ void enter_normal_display_mode ();
+ void next_display_mode ();
void show_current_track ();
void show_transport_time ();
void show_wheel_mode ();
void show_gain ();
void show_pan ();
+ void show_meter ();
void track_solo_changed (void*);
void track_rec_changed (void*);