summaryrefslogtreecommitdiff
path: root/libs/surfaces/tranzport
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-04-06 16:51:27 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-04-06 16:51:27 +0000
commite9f9ca5278c6bcafd6a22ad273185c31664c32a5 (patch)
tree6000ae75223bfa5b2f476337558e3a20923641bd /libs/surfaces/tranzport
parent06764a3b0704e06ec8de42533938b1b50ab1ad4d (diff)
3 different data wheel modes for tranzport, plus lock on writes, and more
git-svn-id: svn://localhost/trunk/ardour2@448 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces/tranzport')
-rw-r--r--libs/surfaces/tranzport/tranzport_control_protocol.cc208
-rw-r--r--libs/surfaces/tranzport/tranzport_control_protocol.h23
2 files changed, 172 insertions, 59 deletions
diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.cc b/libs/surfaces/tranzport/tranzport_control_protocol.cc
index d179f16bf4..eee60c43eb 100644
--- a/libs/surfaces/tranzport/tranzport_control_protocol.cc
+++ b/libs/surfaces/tranzport/tranzport_control_protocol.cc
@@ -30,7 +30,8 @@ TranzportControlProtocol::TranzportControlProtocol (Session& s)
current_route = 0;
current_track_id = 0;
last_where = max_frames;
- wheel_mode = WheelGain;
+ wheel_mode = WheelTimeline;
+ wheel_shift_mode = WheelShiftGain;
timerclear (&last_wheel_motion);
last_wheel_dir = 1;
@@ -246,7 +247,11 @@ TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override)
{
int val;
- val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout);
+ {
+ LockMonitor lm (write_lock, __LINE__, __FILE__);
+ val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout);
+ }
+
if (val < 0)
return val;
if (val != 8)
@@ -258,8 +263,28 @@ TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override)
void
TranzportControlProtocol::lcd_clear ()
{
- print (0, 0, " ");
- print (1, 0, " ");
+ /* special case this for speed and atomicity */
+
+ uint8_t cmd[8];
+
+ cmd[0] = 0x00;
+ cmd[1] = 0x01;
+ cmd[3] = ' ';
+ cmd[4] = ' ';
+ cmd[5] = ' ';
+ cmd[6] = ' ';
+ cmd[7] = 0x00;
+
+ {
+ LockMonitor lm (write_lock, __LINE__, __FILE__);
+
+ for (uint8_t i = 0; i < 10; ++i) {
+ cmd[2] = i;
+ usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, 500);
+ }
+
+ memset (current_screen, ' ', sizeof (current_screen));
+ }
}
int
@@ -573,7 +598,7 @@ void
TranzportControlProtocol::track_gain_changed (void* ignored)
{
char buf[8];
- snprintf (buf, sizeof (buf), "%.1f", coefficient_to_dB (current_route->gain()));
+ snprintf (buf, sizeof (buf), "%.1fdB", coefficient_to_dB (current_route->gain()));
print (0, 9, buf);
}
@@ -757,7 +782,7 @@ void
TranzportControlProtocol::button_event_loop_press (bool shifted)
{
if (shifted) {
- next_wheel_mode ();
+ next_wheel_shift_mode ();
}
}
@@ -796,7 +821,11 @@ TranzportControlProtocol::button_event_add_release (bool shifted)
void
TranzportControlProtocol::button_event_next_press (bool shifted)
{
- next_marker ();
+ if (shifted) {
+ next_wheel_mode ();
+ } else {
+ next_marker ();
+ }
}
void
@@ -913,15 +942,15 @@ TranzportControlProtocol::datawheel ()
/* parameter control */
if (current_route) {
- switch (wheel_mode) {
- case WheelGain:
+ switch (wheel_shift_mode) {
+ case WheelShiftGain:
if (_datawheel < WheelDirectionThreshold) {
step_gain_up ();
} else {
step_gain_down ();
}
break;
- case WheelPan:
+ case WheelShiftPan:
if (_datawheel < WheelDirectionThreshold) {
step_pan_right ();
} else {
@@ -929,7 +958,7 @@ TranzportControlProtocol::datawheel ()
}
break;
- case WheelMaster:
+ case WheelShiftMaster:
break;
}
}
@@ -938,43 +967,81 @@ TranzportControlProtocol::datawheel ()
} else {
- float speed;
- struct timeval now;
- struct timeval delta;
- int dir;
+ switch (wheel_mode) {
+ case WheelTimeline:
+ scroll ();
+ break;
+
+ case WheelScrub:
+ scrub ();
+ break;
- gettimeofday (&now, 0);
-
- if (_datawheel < WheelDirectionThreshold) {
- dir = 1;
- } else {
- dir = -1;
+ case WheelShuttle:
+ shuttle ();
+ break;
}
+ }
+}
- if (dir != last_wheel_dir) {
- /* changed direction, start over */
- speed = 1.0f;
- } else {
- if (timerisset (&last_wheel_motion)) {
-
- timersub (&now, &last_wheel_motion, &delta);
-
- /* 10 clicks per second => speed == 1.0 */
-
- speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
-
- } else {
-
- /* start at half-speed and see where we go from there */
+void
+TranzportControlProtocol::scroll ()
+{
+ if (_datawheel < WheelDirectionThreshold) {
+ ScrollTimeline (0.2);
+ } else {
+ ScrollTimeline (-0.2);
+ }
+}
- speed = 0.5f;
- }
+void
+TranzportControlProtocol::scrub ()
+{
+ float speed;
+ struct timeval now;
+ struct timeval delta;
+ int dir;
+
+ gettimeofday (&now, 0);
+
+ if (_datawheel < WheelDirectionThreshold) {
+ dir = 1;
+ } else {
+ dir = -1;
+ }
+
+ if (dir != last_wheel_dir) {
+ /* changed direction, start over */
+ speed = 1.0f;
+ } else {
+ if (timerisset (&last_wheel_motion)) {
+
+ timersub (&now, &last_wheel_motion, &delta);
+
+ /* 10 clicks per second => speed == 1.0 */
+
+ speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
+
+ } else {
+
+ /* start at half-speed and see where we go from there */
+
+ speed = 0.5f;
}
+ }
+
+ last_wheel_motion = now;
+ last_wheel_dir = dir;
+
+ session.request_transport_speed (speed * dir);
+}
- last_wheel_motion = now;
- last_wheel_dir = dir;
-
- session.request_transport_speed (speed * dir);
+void
+TranzportControlProtocol::shuttle ()
+{
+ if (_datawheel < WheelDirectionThreshold) {
+ session.request_transport_speed (session.transport_speed() + 0.1);
+ } else {
+ session.request_transport_speed (session.transport_speed() - 0.1);
}
}
@@ -1009,17 +1076,34 @@ TranzportControlProtocol::step_pan_left ()
}
void
+TranzportControlProtocol::next_wheel_shift_mode ()
+{
+ switch (wheel_shift_mode) {
+ case WheelShiftGain:
+ wheel_shift_mode = WheelShiftPan;
+ break;
+ case WheelShiftPan:
+ wheel_shift_mode = WheelShiftMaster;
+ break;
+ case WheelShiftMaster:
+ wheel_shift_mode = WheelShiftGain;
+ }
+
+ show_wheel_mode ();
+}
+
+void
TranzportControlProtocol::next_wheel_mode ()
{
switch (wheel_mode) {
- case WheelGain:
- wheel_mode = WheelPan;
+ case WheelTimeline:
+ wheel_mode = WheelScrub;
break;
- case WheelPan:
- wheel_mode = WheelMaster;
+ case WheelScrub:
+ wheel_mode = WheelShuttle;
break;
- case WheelMaster:
- wheel_mode = WheelGain;
+ case WheelShuttle:
+ wheel_mode = WheelTimeline;
}
show_wheel_mode ();
@@ -1100,19 +1184,35 @@ TranzportControlProtocol::prev_track ()
void
TranzportControlProtocol::show_wheel_mode ()
{
+ string text;
+
switch (wheel_mode) {
- case WheelGain:
- print (1, 0, _("Wh: gain"));
+ case WheelTimeline:
+ text = "Time";
+ break;
+ case WheelScrub:
+ text = "Scrb";
break;
+ case WheelShuttle:
+ text = "Shtl";
+ break;
+ }
- case WheelPan:
- print (1, 0, _("Wh: pan "));
+ switch (wheel_shift_mode) {
+ case WheelShiftGain:
+ text += ":Gain";
break;
- case WheelMaster:
- print (1, 0, _("Wh: mstr"));
+ case WheelShiftPan:
+ text += ":Pan";
+ break;
+
+ case WheelShiftMaster:
+ text += ":Mstr";
break;
}
+
+ print (1, 0, text.c_str());
}
void
diff --git a/libs/surfaces/tranzport/tranzport_control_protocol.h b/libs/surfaces/tranzport/tranzport_control_protocol.h
index a655463bc1..c5aa5f90e0 100644
--- a/libs/surfaces/tranzport/tranzport_control_protocol.h
+++ b/libs/surfaces/tranzport/tranzport_control_protocol.h
@@ -4,7 +4,7 @@
#include <vector>
#include <sys/time.h>
-
+#include <pbd/lockmonitor.h>
#include <pthread.h>
#include <usb.h>
#include <ardour/control_protocol.h>
@@ -66,12 +66,18 @@ class TranzportControlProtocol : public ControlProtocol {
ButtonShift = 0x08000000
};
- enum WheelMode {
- WheelGain,
- WheelPan,
- WheelMaster
+ enum WheelShiftMode {
+ WheelShiftGain,
+ WheelShiftPan,
+ WheelShiftMaster
};
+ enum WheelMode {
+ WheelTimeline,
+ WheelScrub,
+ WheelShuttle
+ };
+
pthread_t thread;
uint32_t buttonmask;
uint32_t timeout;
@@ -83,6 +89,7 @@ class TranzportControlProtocol : public ControlProtocol {
char current_screen[2][20];
bool lights[7];
WheelMode wheel_mode;
+ WheelShiftMode wheel_shift_mode;
struct timeval last_wheel_motion;
int last_wheel_dir;
@@ -95,6 +102,8 @@ class TranzportControlProtocol : public ControlProtocol {
uint32_t last_frames;
jack_nframes_t last_where;
+ PBD::Lock write_lock;
+
int open ();
int read (uint32_t timeout_override = 0);
int write (uint8_t* cmd, uint32_t timeout_override = 0);
@@ -121,8 +130,12 @@ class TranzportControlProtocol : public ControlProtocol {
void record_status_changed ();
void datawheel ();
+ void scrub ();
+ void scroll ();
+ void shuttle ();
void next_wheel_mode ();
+ void next_wheel_shift_mode ();
void next_track ();
void prev_track ();