2006-04-24 18:45:19 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
/* Design notes: The tranzport is a unique device, basically a
|
|
|
|
20 lcd gui with 22 shift keys and 8 blinking lights.
|
|
|
|
|
|
|
|
As such it has several unique constraints. The device exerts flow control
|
|
|
|
by having a usb write fail. It is pointless to retry madly at that point,
|
|
|
|
the device is busy, and it's not going to become unbusy very quickly.
|
|
|
|
|
|
|
|
So writes need to be either "mandatory" or "unreliable", and therein
|
|
|
|
lies the rub, as the kernel can also drop writes, and missing an
|
|
|
|
interrupt in userspace is also generally bad.
|
|
|
|
|
|
|
|
It will be good one day, to break the gui, keyboard, and blinking light
|
|
|
|
components into separate parts, but for now, this remains monolithic.
|
|
|
|
|
|
|
|
A more complex surface might have hundreds of lights and several displays.
|
|
|
|
|
|
|
|
mike.taht@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFAULT_USB_TIMEOUT 10
|
|
|
|
#define MAX_RETRY 1
|
|
|
|
#define MAX_TRANZPORT_INFLIGHT 4
|
|
|
|
#define DEBUG_TRANZPORT 0
|
|
|
|
#define HAVE_TRANZPORT_KERNEL_DRIVER 0
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
#include <iostream>
|
2006-04-05 21:52:45 -04:00
|
|
|
#include <algorithm>
|
2006-04-29 11:40:52 -04:00
|
|
|
#include <cmath>
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-05-23 23:45:32 -04:00
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#include <inttypes.h>
|
2006-04-24 18:45:19 -04:00
|
|
|
#include <float.h>
|
2006-04-04 20:21:43 -04:00
|
|
|
#include <sys/time.h>
|
2006-04-24 18:45:19 -04:00
|
|
|
#include <errno.h>
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
#include <pbd/pthread_utils.h>
|
|
|
|
|
|
|
|
#include <ardour/route.h>
|
2006-04-04 23:05:30 -04:00
|
|
|
#include <ardour/audio_track.h>
|
2006-04-03 23:26:08 -04:00
|
|
|
#include <ardour/session.h>
|
2006-12-29 14:13:18 -05:00
|
|
|
#include <ardour/tempo.h>
|
2006-04-04 23:05:30 -04:00
|
|
|
#include <ardour/location.h>
|
2006-04-05 21:52:45 -04:00
|
|
|
#include <ardour/dB.h>
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-04 20:21:43 -04:00
|
|
|
#include "tranzport_control_protocol.h"
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
2006-04-04 23:05:30 -04:00
|
|
|
using namespace sigc;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
#include <pbd/abstract_ui.cc>
|
|
|
|
|
|
|
|
BaseUI::RequestType LEDChange = BaseUI::new_request_type ();
|
|
|
|
BaseUI::RequestType Print = BaseUI::new_request_type ();
|
|
|
|
BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type ();
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
/* Base Tranzport cmd strings */
|
|
|
|
|
|
|
|
static const uint8_t cmd_light_on[] = { 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00 };
|
|
|
|
static const uint8_t cmd_light_off[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
|
|
|
static const uint8_t cmd_write_screen[] = { 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00 };
|
|
|
|
|
2006-04-29 11:40:52 -04:00
|
|
|
static inline double
|
|
|
|
gain_to_slider_position (ARDOUR::gain_t g)
|
|
|
|
{
|
|
|
|
if (g == 0) return 0;
|
|
|
|
return pow((6.0*log(g)/log(2.0)+192.0)/198.0, 8.0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ARDOUR::gain_t
|
|
|
|
slider_position_to_gain (double pos)
|
|
|
|
{
|
|
|
|
/* XXX Marcus writes: this doesn't seem right to me. but i don't have a better answer ... */
|
|
|
|
if (pos == 0.0) return 0;
|
|
|
|
return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
TranzportControlProtocol::TranzportControlProtocol (Session& s)
|
2006-05-23 15:54:52 -04:00
|
|
|
: ControlProtocol (s, X_("Tranzport"))
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-05-17 22:19:27 -04:00
|
|
|
/* tranzport controls one track at a time */
|
|
|
|
|
|
|
|
set_route_table_size (1);
|
2006-12-29 14:13:18 -05:00
|
|
|
timeout = 6000; // what is this for?
|
2006-04-03 23:26:08 -04:00
|
|
|
buttonmask = 0;
|
|
|
|
_datawheel = 0;
|
|
|
|
_device_status = STATUS_OFFLINE;
|
|
|
|
udev = 0;
|
|
|
|
current_track_id = 0;
|
|
|
|
last_where = max_frames;
|
2006-04-06 12:51:27 -04:00
|
|
|
wheel_mode = WheelTimeline;
|
|
|
|
wheel_shift_mode = WheelShiftGain;
|
2006-12-29 14:13:18 -05:00
|
|
|
wheel_increment = WheelIncrScreen;
|
|
|
|
bling_mode = BlingOff;
|
2006-04-05 21:52:45 -04:00
|
|
|
timerclear (&last_wheel_motion);
|
|
|
|
last_wheel_dir = 1;
|
2006-04-24 18:45:19 -04:00
|
|
|
last_track_gain = FLT_MAX;
|
2006-04-09 23:54:00 -04:00
|
|
|
display_mode = DisplayNormal;
|
2006-04-29 11:40:52 -04:00
|
|
|
gain_fraction = 0.0;
|
2006-12-29 14:13:18 -05:00
|
|
|
invalidate();
|
|
|
|
screen_init();
|
|
|
|
lights_init();
|
|
|
|
print(0,0,"!!Welcome to Ardour!!");
|
|
|
|
print(1,0,"!Peace through Music!");
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::light_validate (LightID light)
|
|
|
|
{
|
|
|
|
lights_invalid[light] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranzportControlProtocol::light_invalidate (LightID light)
|
|
|
|
{
|
|
|
|
lights_invalid[light] = 1;
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::lights_validate ()
|
|
|
|
{
|
|
|
|
memset (lights_invalid, 0, sizeof (lights_invalid));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranzportControlProtocol::lights_invalidate ()
|
|
|
|
{
|
|
|
|
memset (lights_invalid, 1, sizeof (lights_invalid));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranzportControlProtocol::lights_init()
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < sizeof(lights_current)/sizeof(lights_current[0]); i++) {
|
|
|
|
lights_invalid[i] = lights_current[i] =
|
|
|
|
lights_pending[i] = lights_flash[i] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::lights_flush ()
|
|
|
|
{
|
|
|
|
if ( _device_status == STATUS_OFFLINE) { return (0); }
|
|
|
|
|
|
|
|
// Figure out iterators one day soon
|
|
|
|
// for (LightID i = i.start(), i = i.end(); i++) {
|
|
|
|
// if (lights_pending[i] != lights_current[i] || lights_invalid[i]) {
|
|
|
|
// if (light_set(i, lights_pending[i])) {
|
|
|
|
// return i-1;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
if ((lights_pending[LightRecord] != lights_current[LightRecord]) || lights_invalid[LightRecord]) {
|
|
|
|
if (light_set(LightRecord,lights_pending[LightRecord])) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((lights_pending[LightTrackrec] != lights_current[LightTrackrec]) || lights_invalid[LightTrackrec]) {
|
|
|
|
if (light_set(LightTrackrec,lights_pending[LightTrackrec])) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lights_pending[LightTrackmute] != lights_current[LightTrackmute]) || lights_invalid[LightTrackmute]) {
|
|
|
|
if (light_set(LightTrackmute,lights_pending[LightTrackmute])) {
|
|
|
|
return 1;
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if ((lights_pending[LightTracksolo] != lights_current[LightTracksolo]) || lights_invalid[LightTracksolo]) {
|
|
|
|
if (light_set(LightTracksolo,lights_pending[LightTracksolo])) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((lights_pending[LightAnysolo] != lights_current[LightAnysolo]) || lights_invalid[LightAnysolo]) {
|
|
|
|
if (light_set(LightAnysolo,lights_pending[LightAnysolo])) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((lights_pending[LightLoop] != lights_current[LightLoop]) || lights_invalid[LightLoop]) {
|
|
|
|
if (light_set(LightLoop,lights_pending[LightLoop])) {
|
|
|
|
return 1;
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
if ((lights_pending[LightPunch] != lights_current[LightPunch]) || lights_invalid[LightPunch]) {
|
|
|
|
if (light_set(LightPunch,lights_pending[LightPunch])) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// Screen specific commands
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::screen_clear ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
const char *blank = " ";
|
|
|
|
print(0,0,blank);
|
|
|
|
print(1,0,blank);
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::screen_invalidate ()
|
2006-05-23 15:54:52 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
for(int row = 0; row < 2; row++) {
|
|
|
|
for(int col = 0; col < 20; col++) {
|
|
|
|
screen_invalid[row][col] = true;
|
|
|
|
screen_current[row][col] = 0x7f;
|
|
|
|
screen_pending[row][col] = ' ';
|
|
|
|
// screen_flash[row][col] = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// memset (&screen_invalid, 1, sizeof(screen_invalid));
|
|
|
|
// memset (&screen_current, 0x7F, sizeof (screen_current)); // fill cache with a character we otherwise never use
|
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::screen_validate ()
|
|
|
|
{
|
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::screen_init ()
|
|
|
|
{
|
|
|
|
screen_invalidate();
|
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::screen_flush ()
|
|
|
|
{
|
|
|
|
int cell = 0, row, col_base, col, pending = 0;
|
|
|
|
if ( _device_status == STATUS_OFFLINE) { return (-1); }
|
|
|
|
|
|
|
|
for (row = 0; row < 2 && pending == 0; row++) {
|
|
|
|
for (col_base = 0, col = 0; col < 20 && pending == 0; ) {
|
|
|
|
if ((screen_pending[row][col] != screen_current[row][col])
|
|
|
|
|| screen_invalid[row][col]) {
|
|
|
|
|
|
|
|
/* something in this cell is different, so dump the cell to the device. */
|
|
|
|
|
|
|
|
uint8_t cmd[8];
|
|
|
|
cmd[0] = 0x00;
|
|
|
|
cmd[1] = 0x01;
|
|
|
|
cmd[2] = cell;
|
|
|
|
cmd[3] = screen_pending[row][col_base];
|
|
|
|
cmd[4] = screen_pending[row][col_base+1];
|
|
|
|
cmd[5] = screen_pending[row][col_base+2];
|
|
|
|
cmd[6] = screen_pending[row][col_base+3];
|
|
|
|
cmd[7] = 0x00;
|
|
|
|
|
|
|
|
if(write(cmd) != 0) {
|
|
|
|
/* try to update this cell on the next go-round */
|
|
|
|
#if DEBUG_TRANZPORT > 4
|
|
|
|
printf("usb screen update failed for some reason... why? \ncmd and data were %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
|
|
cmd[0],cmd[1],cmd[2], cmd[3], cmd[4], cmd[5],cmd[6],cmd[7]);
|
|
|
|
#endif
|
|
|
|
pending += 1;
|
|
|
|
// Shouldn't need to do this
|
|
|
|
// screen_invalid[row][col_base] = screen_invalid[row][col_base+1] =
|
|
|
|
// screen_invalid[row][col_base+2] = screen_invalid[row][col_base+3] = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* successful write: copy to current cached display */
|
|
|
|
screen_invalid[row][col_base] = screen_invalid[row][col_base+1] =
|
|
|
|
screen_invalid[row][col_base+2] = screen_invalid[row][col_base+3] = false;
|
|
|
|
memcpy (&screen_current[row][col_base], &screen_pending[row][col_base], 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skip the rest of the 4 character cell since we wrote+copied it already */
|
|
|
|
|
|
|
|
col_base += 4;
|
|
|
|
col = col_base;
|
|
|
|
cell++;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
col++;
|
|
|
|
|
|
|
|
if (col && col % 4 == 0) {
|
|
|
|
cell++;
|
|
|
|
col_base += 4;
|
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
return pending;
|
|
|
|
}
|
2006-05-23 15:54:52 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
|
|
|
|
// Tranzport specific
|
|
|
|
|
|
|
|
void TranzportControlProtocol::invalidate()
|
|
|
|
{
|
|
|
|
lcd_damage(); lights_invalidate(); screen_invalidate(); // one of these days lcds can be fine but screens not
|
|
|
|
}
|
|
|
|
|
|
|
|
TranzportControlProtocol::~TranzportControlProtocol ()
|
|
|
|
{
|
|
|
|
set_active (false);
|
2006-05-23 15:54:52 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
int
|
2006-04-24 18:45:19 -04:00
|
|
|
TranzportControlProtocol::set_active (bool yn)
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-04-24 18:45:19 -04:00
|
|
|
if (yn != _active) {
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
if (yn) {
|
2006-04-09 23:54:00 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
if (open ()) {
|
|
|
|
return -1;
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
if (pthread_create_and_store (X_("tranzport monitor"), &thread, 0, _monitor_work, this) == 0) {
|
|
|
|
_active = true;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
2006-04-04 20:21:43 -04:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
} else {
|
2006-04-29 11:40:52 -04:00
|
|
|
cerr << "Begin tranzport shutdown\n";
|
2006-12-29 14:13:18 -05:00
|
|
|
screen_clear ();
|
|
|
|
lcd_damage();
|
|
|
|
lights_off ();
|
|
|
|
for(int x = 0; x < 10 && flush(); x++) { usleep(1000); }
|
2006-04-24 18:45:19 -04:00
|
|
|
pthread_cancel_one (thread);
|
2006-12-29 14:13:18 -05:00
|
|
|
cerr << "Tranzport Thread dead\n";
|
2006-04-24 18:45:19 -04:00
|
|
|
close ();
|
|
|
|
_active = false;
|
2006-04-29 11:40:52 -04:00
|
|
|
cerr << "End tranzport shutdown\n";
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-24 18:45:19 -04:00
|
|
|
TranzportControlProtocol::show_track_gain ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-05-17 22:19:27 -04:00
|
|
|
if (route_table[0]) {
|
|
|
|
gain_t g = route_get_gain (0);
|
2006-12-29 14:13:18 -05:00
|
|
|
if ((g != last_track_gain) || lcd_isdamaged(0,9,8)) {
|
|
|
|
char buf[16];
|
2006-05-17 22:19:27 -04:00
|
|
|
snprintf (buf, sizeof (buf), "%6.1fdB", coefficient_to_dB (route_get_effective_gain (0)));
|
2006-04-24 18:45:19 -04:00
|
|
|
print (0, 9, buf);
|
|
|
|
last_track_gain = g;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print (0, 9, " ");
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-24 18:45:19 -04:00
|
|
|
TranzportControlProtocol::normal_update ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-04-24 18:45:19 -04:00
|
|
|
show_current_track ();
|
|
|
|
show_transport_time ();
|
|
|
|
show_track_gain ();
|
|
|
|
show_wheel_mode ();
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::next_display_mode ()
|
|
|
|
{
|
|
|
|
switch (display_mode) {
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayNormal:
|
|
|
|
enter_big_meter_mode();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DisplayBigMeter:
|
|
|
|
enter_normal_display_mode();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DisplayRecording:
|
|
|
|
enter_normal_display_mode();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DisplayRecordingMeter:
|
|
|
|
enter_big_meter_mode();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DisplayConfig:
|
|
|
|
case DisplayBling:
|
|
|
|
case DisplayBlingMeter:
|
|
|
|
enter_normal_display_mode();
|
|
|
|
break;
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// FIXME, these 3 aren't done yet
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::enter_recording_mode ()
|
|
|
|
{
|
|
|
|
lcd_damage(); // excessive
|
|
|
|
screen_clear ();
|
|
|
|
lights_off ();
|
|
|
|
display_mode = DisplayRecording;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::enter_bling_mode ()
|
|
|
|
{
|
|
|
|
lcd_damage();
|
|
|
|
screen_clear ();
|
|
|
|
lights_off ();
|
|
|
|
display_mode = DisplayBling;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::enter_config_mode ()
|
|
|
|
{
|
|
|
|
lcd_damage();
|
|
|
|
screen_clear ();
|
|
|
|
lights_off ();
|
|
|
|
display_mode = DisplayConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::enter_big_meter_mode ()
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
screen_clear ();
|
|
|
|
lcd_damage();
|
2006-04-09 23:54:00 -04:00
|
|
|
lights_off ();
|
2006-04-18 22:11:39 -04:00
|
|
|
last_meter_fill = 0;
|
2006-04-09 23:54:00 -04:00
|
|
|
display_mode = DisplayBigMeter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::enter_normal_display_mode ()
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
screen_clear ();
|
|
|
|
lcd_damage();
|
2006-04-09 23:54:00 -04:00
|
|
|
lights_off ();
|
|
|
|
display_mode = DisplayNormal;
|
2006-12-29 14:13:18 -05:00
|
|
|
// normal_update();
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
log_meter (float db)
|
|
|
|
{
|
|
|
|
float def = 0.0f; /* Meter deflection %age */
|
2006-12-29 14:13:18 -05:00
|
|
|
|
|
|
|
if (db < -70.0f) return 0.0f;
|
|
|
|
if (db > 6.0f) return 1.0f;
|
|
|
|
|
|
|
|
if (db < -60.0f) {
|
2006-04-09 23:54:00 -04:00
|
|
|
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;
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
/* 115 is the deflection %age that would be
|
|
|
|
when db=6.0. this is an arbitrary
|
|
|
|
endpoint for our scaling.
|
2006-12-29 14:13:18 -05:00
|
|
|
*/
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
return def/115.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_meter ()
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
// you only seem to get a route_table[0] on moving forward - bug elsewhere
|
2006-05-17 22:19:27 -04:00
|
|
|
if (route_table[0] == 0) {
|
2006-12-29 14:13:18 -05:00
|
|
|
// Principle of least surprise
|
|
|
|
print (0, 0, "No audio to meter!!!");
|
|
|
|
print (1, 0, "Select another track");
|
2006-04-09 23:54:00 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
float level = route_get_peak_input_power (0, 0);
|
2006-04-09 23:54:00 -04:00
|
|
|
float fraction = log_meter (level);
|
2006-04-18 22:11:39 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
/* Someday add a peak bar*/
|
|
|
|
|
2006-04-18 22:11:39 -04:00
|
|
|
/* we draw using a choice of a sort of double colon-like character ("::") or a single, left-aligned ":".
|
|
|
|
the screen is 20 chars wide, so we can display 40 different levels. compute the level,
|
|
|
|
then figure out how many "::" to fill. if the answer is odd, make the last one a ":"
|
2006-12-29 14:13:18 -05:00
|
|
|
*/
|
2006-04-18 22:11:39 -04:00
|
|
|
|
|
|
|
uint32_t fill = (uint32_t) floor (fraction * 40);
|
2006-04-09 23:54:00 -04:00
|
|
|
char buf[21];
|
2006-04-24 18:45:19 -04:00
|
|
|
uint32_t i;
|
2006-04-09 23:54:00 -04:00
|
|
|
|
2006-04-18 22:11:39 -04:00
|
|
|
if (fill == last_meter_fill) {
|
|
|
|
/* nothing to do */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_meter_fill = fill;
|
|
|
|
|
|
|
|
bool add_single_level = (fill % 2 != 0);
|
|
|
|
fill /= 2;
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-18 22:11:39 -04:00
|
|
|
if (fraction > 0.98) {
|
|
|
|
light_on (LightAnysolo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add all full steps */
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
for (i = 0; i < fill; ++i) {
|
2006-04-18 22:11:39 -04:00
|
|
|
buf[i] = 0x07; /* tranzport special code for 4 quadrant LCD block */
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
2006-04-18 22:11:39 -04:00
|
|
|
|
|
|
|
/* add a possible half-step */
|
|
|
|
|
|
|
|
if (i < 20 && add_single_level) {
|
|
|
|
buf[i] = 0x03; /* tranzport special code for 2 left quadrant LCD block */
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill rest with space */
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
for (; i < 20; ++i) {
|
|
|
|
buf[i] = ' ';
|
|
|
|
}
|
|
|
|
|
2006-04-18 22:11:39 -04:00
|
|
|
/* print() requires this */
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
buf[21] = '\0';
|
|
|
|
|
|
|
|
print (0, 0, buf);
|
|
|
|
print (1, 0, buf);
|
2006-04-04 20:21:43 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_bbt (nframes_t where)
|
|
|
|
{
|
|
|
|
if ((where != last_where) || lcd_isdamaged(1,9,8)) {
|
|
|
|
char buf[16];
|
|
|
|
BBT_Time bbt;
|
|
|
|
session->tempo_map().bbt_time (where, bbt);
|
|
|
|
sprintf (buf, "%03" PRIu32 "|%02" PRIu32 "|%04" PRIu32, bbt.bars,bbt.beats,bbt.ticks);
|
|
|
|
last_bars = bbt.bars;
|
|
|
|
last_beats = bbt.beats;
|
|
|
|
last_ticks = bbt.ticks;
|
|
|
|
last_where = where;
|
|
|
|
|
|
|
|
if(last_ticks < 1960) { print (1, 9, buf); } // save a write so we can do leds
|
|
|
|
|
|
|
|
// if displaymode is recordmode show beats but not yet
|
|
|
|
lights_pending[LightRecord] = false;
|
|
|
|
lights_pending[LightAnysolo] = false;
|
|
|
|
switch(last_beats) {
|
|
|
|
case 1: if(last_ticks < 500 || last_ticks > 1960) lights_pending[LightRecord] = true; break;
|
|
|
|
default: if(last_ticks < 250) lights_pending[LightAnysolo] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update lights for tempo one day
|
|
|
|
// if (bbt_upper_info_label) {
|
|
|
|
// TempoMap::Metric m (session->tempo_map().metric_at (when));
|
|
|
|
// sprintf (buf, "%-5.2f", m.tempo().beats_per_minute());
|
|
|
|
// bbt_lower_info_label->set_text (buf);
|
|
|
|
// sprintf (buf, "%g|%g", m.meter().beats_per_bar(), m.meter().note_divisor());
|
|
|
|
// bbt_upper_info_label->set_text (buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-04 20:21:43 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_transport_time ()
|
|
|
|
{
|
2006-09-28 13:23:52 -04:00
|
|
|
nframes_t where = session->transport_frame();
|
2006-12-29 14:13:18 -05:00
|
|
|
show_bbt(where);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_smpte (nframes_t where)
|
|
|
|
{
|
|
|
|
if ((where != last_where) || lcd_isdamaged(1,9,10)) {
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
char buf[5];
|
2006-06-15 17:54:26 -04:00
|
|
|
SMPTE::Time smpte;
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-05-18 12:44:07 -04:00
|
|
|
session->smpte_time (where, smpte);
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
if (smpte.negative) {
|
2006-05-23 23:45:32 -04:00
|
|
|
sprintf (buf, "-%02" PRIu32 ":", smpte.hours);
|
2006-04-03 23:26:08 -04:00
|
|
|
} else {
|
2006-05-23 23:45:32 -04:00
|
|
|
sprintf (buf, " %02" PRIu32 ":", smpte.hours);
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
print (1, 8, buf);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-05-23 23:45:32 -04:00
|
|
|
sprintf (buf, "%02" PRIu32 ":", smpte.minutes);
|
2006-04-05 21:52:45 -04:00
|
|
|
print (1, 12, buf);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-05-23 23:45:32 -04:00
|
|
|
sprintf (buf, "%02" PRIu32 ":", smpte.seconds);
|
2006-04-05 21:52:45 -04:00
|
|
|
print (1, 15, buf);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-05-23 23:45:32 -04:00
|
|
|
sprintf (buf, "%02" PRIu32, smpte.frames);
|
2006-12-29 14:13:18 -05:00
|
|
|
print_noretry (1, 18, buf);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
last_where = where;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2006-04-18 22:11:39 -04:00
|
|
|
TranzportControlProtocol::_monitor_work (void* arg)
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-04-18 22:11:39 -04:00
|
|
|
return static_cast<TranzportControlProtocol*>(arg)->monitor_work ();
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// I note that these usb specific open, close, probe, read routines are basically
|
|
|
|
// pure boilerplate and could easily be abstracted elsewhere
|
|
|
|
|
|
|
|
#if !HAVE_TRANZPORT_KERNEL_DRIVER
|
|
|
|
|
|
|
|
bool
|
|
|
|
TranzportControlProtocol::probe ()
|
|
|
|
{
|
|
|
|
struct usb_bus *bus;
|
|
|
|
struct usb_device *dev;
|
|
|
|
|
|
|
|
usb_init();
|
|
|
|
usb_find_busses();
|
|
|
|
usb_find_devices();
|
|
|
|
|
|
|
|
for (bus = usb_busses; bus; bus = bus->next) {
|
|
|
|
|
|
|
|
for(dev = bus->devices; dev; dev = dev->next) {
|
|
|
|
if (dev->descriptor.idVendor == VENDORID && dev->descriptor.idProduct == PRODUCTID) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::open ()
|
|
|
|
{
|
|
|
|
struct usb_bus *bus;
|
|
|
|
struct usb_device *dev;
|
|
|
|
|
|
|
|
usb_init();
|
|
|
|
usb_find_busses();
|
|
|
|
usb_find_devices();
|
|
|
|
|
|
|
|
for (bus = usb_busses; bus; bus = bus->next) {
|
|
|
|
|
|
|
|
for(dev = bus->devices; dev; dev = dev->next) {
|
|
|
|
if (dev->descriptor.idVendor != VENDORID)
|
|
|
|
continue;
|
|
|
|
if (dev->descriptor.idProduct != PRODUCTID)
|
|
|
|
continue;
|
|
|
|
return open_core (dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error << _("Tranzport: no device detected") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::open_core (struct usb_device* dev)
|
|
|
|
{
|
|
|
|
if (!(udev = usb_open (dev))) {
|
|
|
|
error << _("Tranzport: cannot open USB transport") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usb_claim_interface (udev, 0) < 0) {
|
|
|
|
error << _("Tranzport: cannot claim USB interface") << endmsg;
|
|
|
|
usb_close (udev);
|
|
|
|
udev = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
if (usb_set_configuration (udev, 1) < 0) {
|
2006-06-15 16:55:54 -04:00
|
|
|
cerr << _("Tranzport: cannot configure USB interface") << endmsg;
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::close ()
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (udev == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usb_release_interface (udev, 0) < 0) {
|
|
|
|
error << _("Tranzport: cannot release interface") << endmsg;
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (usb_close (udev)) {
|
|
|
|
error << _("Tranzport: cannot close device") << endmsg;
|
2006-04-24 18:45:19 -04:00
|
|
|
udev = 0;
|
2006-04-03 23:26:08 -04:00
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
|
|
|
int TranzportControlProtocol::read(uint8_t *buf, uint32_t timeout_override)
|
|
|
|
{
|
|
|
|
int val;
|
|
|
|
// Get smarter about handling usb errors soon. Like disconnect
|
|
|
|
// pthread_testcancel();
|
|
|
|
val = usb_interrupt_read (udev, READ_ENDPOINT, (char *) buf, 8, 10);
|
|
|
|
// pthread_testcancel();
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
int
|
2006-12-29 14:13:18 -05:00
|
|
|
TranzportControlProtocol::write_noretry (uint8_t* cmd, uint32_t timeout_override)
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
|
|
|
int val;
|
2006-12-29 14:13:18 -05:00
|
|
|
if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); }
|
2006-04-24 18:45:19 -04:00
|
|
|
val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout);
|
2006-04-06 12:51:27 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if (val < 0) {
|
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("usb_interrupt_write failed: %d\n", val);
|
|
|
|
#endif
|
2006-04-03 23:26:08 -04:00
|
|
|
return val;
|
2006-12-29 14:13:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (val != 8) {
|
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("usb_interrupt_write failed: %d\n", val);
|
|
|
|
#endif
|
2006-04-03 23:26:08 -04:00
|
|
|
return -1;
|
2006-12-29 14:13:18 -05:00
|
|
|
}
|
|
|
|
++inflight;
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::write (uint8_t* cmd, uint32_t timeout_override)
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
#if MAX_RETRY > 1
|
|
|
|
int val;
|
|
|
|
int retry = 0;
|
|
|
|
if(inflight > MAX_TRANZPORT_INFLIGHT) { return (-1); }
|
2006-04-06 12:51:27 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
while((val = usb_interrupt_write (udev, WRITE_ENDPOINT, (char*) cmd, 8, timeout_override ? timeout_override : timeout))!=8 && retry++ < MAX_RETRY) {
|
|
|
|
printf("usb_interrupt_write failed, retrying: %d\n", val);
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if (retry == MAX_RETRY) {
|
|
|
|
printf("Too many retries on a tranzport write, aborting\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val < 0) {
|
|
|
|
printf("usb_interrupt_write failed: %d\n", val);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
if (val != 8) {
|
|
|
|
printf("usb_interrupt_write failed: %d\n", val);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
++inflight;
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return (write_noretry(cmd,timeout_override));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error Kernel API not defined yet for Tranzport
|
|
|
|
// Something like open(/dev/surface/tranzport/event) for reading and raw for writing)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// We have a state "Unknown" - STOP USING SPACES FOR IT - switching to arrow character
|
|
|
|
// We have another state - no_retry. Misleading, as we still retry on the next pass
|
|
|
|
// I think it's pointless to keep no_retry and instead we should throttle writes
|
|
|
|
// We have an "displayed" screen
|
|
|
|
// We always draw into the pending screen, which could be any of several screens
|
|
|
|
// We have an active screen
|
|
|
|
// Print arg - we have
|
|
|
|
// setactive
|
|
|
|
// so someday I think we need a screen object.
|
|
|
|
|
|
|
|
/*
|
|
|
|
screen_flash.clear();
|
|
|
|
screen_flash.print(0,0,"Undone:"); // Someday pull the undo stack from somewhere
|
|
|
|
screen_flash.print(1,0,"Nextup:");
|
|
|
|
|
|
|
|
if(flash_messages && lcd.getactive() != screen_flash) lcd.setactive(screen_flash,2000);
|
|
|
|
|
|
|
|
screen::setactive(screen_name,duration); // duration in ms
|
|
|
|
screen::getactive();
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::flush ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
int pending = 0;
|
|
|
|
if(!(pending = lights_flush())) {
|
|
|
|
pending = screen_flush();
|
|
|
|
}
|
|
|
|
return pending;
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// doing these functions made me realize that screen_invalid should be lcd_isdamaged FIXME soon
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
bool TranzportControlProtocol::lcd_damage()
|
|
|
|
{
|
|
|
|
screen_invalidate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TranzportControlProtocol::lcd_damage (int row, int col, int length)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
int endcol = col+length-1;
|
|
|
|
if((endcol > 19)) { endcol = 19; }
|
|
|
|
if((row >= 0 && row < 2) && (col >=0 && col < 20)) {
|
|
|
|
for(int c = col; c < endcol; c++) {
|
|
|
|
screen_invalid[row][c] = true;
|
|
|
|
}
|
|
|
|
result = true;
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gotta switch to bitfields, this is collossally dumb
|
|
|
|
// Still working on the layering, arguably screen_invalid should be lcd_invalid
|
|
|
|
|
|
|
|
bool TranzportControlProtocol::lcd_isdamaged ()
|
|
|
|
{
|
|
|
|
for(int r = 0; r < 2; r++) {
|
|
|
|
for(int c = 0; c < 20; c++) {
|
|
|
|
if(screen_invalid[r][c]) {
|
|
|
|
#if DEBUG_TRANZPORT > 5
|
|
|
|
printf("row: %d,col: %d is damaged, should redraw it\n", r,c);
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TranzportControlProtocol::lcd_isdamaged (int row, int col, int length)
|
|
|
|
{
|
|
|
|
bool result = 0;
|
|
|
|
int endcol = col+length;
|
|
|
|
if((endcol > 19)) { endcol = 19; }
|
|
|
|
if((row >= 0 && row < 2) && (col >=0 && col < 20)) {
|
|
|
|
for(int c = col; c < endcol; c++) {
|
|
|
|
if(screen_invalid[row][c]) {
|
|
|
|
#if DEBUG_TRANZPORT > 5
|
|
|
|
printf("row: %d,col: %d is damaged, should redraw it\n", row,c);
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
return result;
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// lcd_clear would be a separate function for a smart display
|
|
|
|
// here it does nothing, but for the sake of completeness it should
|
|
|
|
// probably write the lcd, and while I'm on the topic it should probably
|
|
|
|
// take a row, col, length argument....
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::lcd_clear ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// These lcd commands are not universally used yet and may drop out of the api
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
int
|
2006-12-29 14:13:18 -05:00
|
|
|
TranzportControlProtocol::lcd_flush ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::lcd_write(uint8_t* cmd, uint32_t timeout_override)
|
|
|
|
{
|
|
|
|
return write(cmd,timeout_override);
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::lcd_fill (uint8_t fill_char)
|
|
|
|
{
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::lcd_print (int row, int col, const char* text)
|
|
|
|
{
|
|
|
|
print(row,col,text);
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void TranzportControlProtocol::lcd_print_noretry (int row, int col, const char* text)
|
|
|
|
{
|
|
|
|
print(row,col,text);
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// Lights are buffered
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::lights_on ()
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
lights_pending[LightRecord] = lights_pending[LightTrackrec] =
|
|
|
|
lights_pending[LightTrackmute] = lights_pending[LightTracksolo] =
|
|
|
|
lights_pending[LightAnysolo] = lights_pending[LightLoop] =
|
|
|
|
lights_pending[LightPunch] = true;
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::lights_off ()
|
|
|
|
{
|
|
|
|
lights_pending[LightRecord] = lights_pending[LightTrackrec] =
|
|
|
|
lights_pending[LightTrackmute] = lights_pending[LightTracksolo] =
|
|
|
|
lights_pending[LightAnysolo] = lights_pending[LightLoop] =
|
|
|
|
lights_pending[LightPunch] = false;
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_on (LightID light)
|
|
|
|
{
|
|
|
|
lights_pending[light] = true;
|
|
|
|
return 0;
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_off (LightID light)
|
|
|
|
{
|
|
|
|
lights_pending[light] = false;
|
|
|
|
return 0;
|
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::light_set (LightID light, bool offon)
|
|
|
|
{
|
|
|
|
uint8_t cmd[8];
|
|
|
|
cmd[0] = 0x00; cmd[1] = 0x00; cmd[2] = light; cmd[3] = offon;
|
|
|
|
cmd[4] = 0x00; cmd[5] = 0x00; cmd[6] = 0x00; cmd[7] = 0x00;
|
|
|
|
|
|
|
|
if (write (cmd) == 0) {
|
|
|
|
lights_current[light] = offon;
|
|
|
|
lights_invalid[light] = false;
|
2006-04-04 23:05:30 -04:00
|
|
|
return 0;
|
2006-12-29 14:13:18 -05:00
|
|
|
} else {
|
|
|
|
return -1;
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::rtpriority_set(int priority)
|
2006-04-03 23:26:08 -04:00
|
|
|
{
|
2006-04-24 18:45:19 -04:00
|
|
|
struct sched_param rtparam;
|
|
|
|
int err;
|
2006-12-29 14:13:18 -05:00
|
|
|
// preallocate and memlock some stack with memlock?
|
|
|
|
char *a = (char*) alloca(4096*2); a[0] = 'a'; a[4096] = 'b';
|
|
|
|
memset (&rtparam, 0, sizeof (rtparam));
|
|
|
|
rtparam.sched_priority = priority; /* XXX should be relative to audio (JACK) thread */
|
|
|
|
// Note - try SCHED_RR with a low limit
|
|
|
|
// - we don't care if we can't write everything this ms
|
|
|
|
// and it will help if we lose the device
|
|
|
|
if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) {
|
|
|
|
PBD::info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), name(), strerror (errno)) << endmsg;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// Running with realtime privs is bad when you have problems
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::rtpriority_unset(int priority)
|
|
|
|
{
|
|
|
|
struct sched_param rtparam;
|
|
|
|
int err;
|
2006-04-24 18:45:19 -04:00
|
|
|
memset (&rtparam, 0, sizeof (rtparam));
|
2006-12-29 14:13:18 -05:00
|
|
|
rtparam.sched_priority = priority;
|
2006-04-24 18:45:19 -04:00
|
|
|
if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) {
|
2006-12-29 14:13:18 -05:00
|
|
|
PBD::info << string_compose (_("%1: can't stop realtime scheduling (%2)"), name(), strerror (errno)) << endmsg;
|
|
|
|
return 1;
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
PBD::info << string_compose (_("%1: realtime scheduling stopped (%2)"), name(), strerror (errno)) << endmsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Slowly breaking this into where I can make usb processing it's own thread.
|
|
|
|
|
|
|
|
void*
|
|
|
|
TranzportControlProtocol::monitor_work ()
|
|
|
|
{
|
|
|
|
uint8_t buf[8];
|
|
|
|
int val = 0, pending = 0;
|
|
|
|
bool first_time = true;
|
|
|
|
uint8_t offline = 0;
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
PBD::ThreadCreated (pthread_self(), X_("Tranzport"));
|
2006-04-24 18:45:19 -04:00
|
|
|
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
|
|
|
|
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
|
|
|
next_track ();
|
2006-12-29 14:13:18 -05:00
|
|
|
rtpriority_set();
|
|
|
|
inflight=0;
|
|
|
|
flush();
|
2006-04-24 18:45:19 -04:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
/* bInterval for this beastie is 10ms */
|
|
|
|
|
2006-04-29 11:40:52 -04:00
|
|
|
if (_device_status == STATUS_OFFLINE) {
|
2006-12-29 14:13:18 -05:00
|
|
|
first_time = true;
|
|
|
|
if(offline++ == 1) {
|
|
|
|
cerr << "Transport has gone offline\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
offline = 0; // hate writing this
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
val = read(buf);
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if (val == 8) {
|
|
|
|
process (buf);
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
#if DEBUG_TRANZPORT > 2
|
|
|
|
if(inflight > 1) printf("Inflight: %d\n", inflight);
|
|
|
|
#endif
|
2006-04-24 18:45:19 -04:00
|
|
|
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if (_device_status != STATUS_OFFLINE) {
|
|
|
|
if (first_time) {
|
|
|
|
invalidate();
|
|
|
|
lcd_clear ();
|
|
|
|
lights_off ();
|
|
|
|
first_time = false;
|
|
|
|
offline = 0;
|
|
|
|
pending = 3; // Give some time for the device to recover
|
|
|
|
}
|
|
|
|
/* update whatever needs updating */
|
|
|
|
update_state ();
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
/* still struggling with a good means of exerting flow control */
|
|
|
|
// pending = flush();
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if(pending == 0) {
|
|
|
|
pending = flush();
|
2006-04-24 18:45:19 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
if(inflight > 0) {
|
|
|
|
pending = --inflight; // we just did a whole bunch of writes so wait
|
|
|
|
} else {
|
|
|
|
pending = 0;
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
// pending = 0;
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
return (void*) 0;
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::lights_show_recording()
|
|
|
|
{
|
|
|
|
// FIXME, flash recording light when recording and transport is moving
|
|
|
|
return lights_show_normal();
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// gotta do bling next!
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::lights_show_bling()
|
|
|
|
{
|
|
|
|
switch (bling_mode) {
|
|
|
|
case BlingOff: break;
|
|
|
|
case BlingKit: break; // rotate rec/mute/solo/any solo back and forth
|
|
|
|
case BlingRotating: break; // switch between lights
|
|
|
|
case BlingPairs: break; // Show pairs of lights
|
|
|
|
case BlingRows: break; // light each row in sequence
|
|
|
|
case BlingFlashAll: break; // Flash everything randomly
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::lights_show_normal()
|
|
|
|
{
|
|
|
|
/* Track only */
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
if (route_table[0]) {
|
|
|
|
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (route_table[0]);
|
|
|
|
lights_pending[LightTrackrec] = at && at->record_enabled();
|
|
|
|
lights_pending[LightTrackmute] = route_get_muted(0);
|
|
|
|
lights_pending[LightTracksolo] = route_get_soloed(0);
|
2006-04-24 18:45:19 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
lights_pending[LightTrackrec] = false;
|
|
|
|
lights_pending[LightTracksolo] = false;
|
|
|
|
lights_pending[LightTrackmute] = false;
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
/* Global settings */
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
lights_pending[LightLoop] = session->get_play_loop();
|
|
|
|
lights_pending[LightPunch] = Config->get_punch_in() || Config->get_punch_out();
|
|
|
|
lights_pending[LightRecord] = session->get_record_enabled();
|
|
|
|
lights_pending[LightAnysolo] = session->soloing();
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int TranzportControlProtocol::lights_show_tempo()
|
|
|
|
{
|
|
|
|
// someday soon fiddle with the lights based on the tempo
|
|
|
|
return lights_show_normal();
|
|
|
|
}
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::update_state ()
|
|
|
|
{
|
|
|
|
/* do the text and light updates */
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
switch (display_mode) {
|
|
|
|
case DisplayBigMeter:
|
|
|
|
lights_show_tempo();
|
|
|
|
show_meter ();
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayNormal:
|
|
|
|
lights_show_normal();
|
|
|
|
normal_update ();
|
|
|
|
break;
|
2006-10-26 14:13:54 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayConfig:
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayRecording:
|
|
|
|
lights_show_recording();
|
|
|
|
normal_update();
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayRecordingMeter:
|
|
|
|
lights_show_recording();
|
|
|
|
show_meter();
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayBling:
|
|
|
|
lights_show_bling();
|
|
|
|
normal_update();
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case DisplayBlingMeter:
|
|
|
|
lights_show_bling();
|
|
|
|
show_meter();
|
|
|
|
break;
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
|
|
|
return 0;
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
#define TRANZPORT_BUTTON_HANDLER(callback, button_arg) if (button_changes & button_arg) { \
|
|
|
|
if (buttonmask & button_arg) { \
|
|
|
|
callback##_press (buttonmask&ButtonShift); } else { callback##_release (buttonmask&ButtonShift); } }
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
int
|
|
|
|
TranzportControlProtocol::process (uint8_t* buf)
|
|
|
|
{
|
2006-04-04 23:05:30 -04:00
|
|
|
// printf("read: %02x %02x %02x %02x %02x %02x %02x %02x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
|
2006-04-03 23:26:08 -04:00
|
|
|
|
|
|
|
uint32_t this_button_mask;
|
|
|
|
uint32_t button_changes;
|
|
|
|
|
|
|
|
_device_status = buf[1];
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
this_button_mask = 0;
|
|
|
|
this_button_mask |= buf[2] << 24;
|
|
|
|
this_button_mask |= buf[3] << 16;
|
|
|
|
this_button_mask |= buf[4] << 8;
|
|
|
|
this_button_mask |= buf[5];
|
|
|
|
_datawheel = buf[6];
|
|
|
|
|
|
|
|
button_changes = (this_button_mask ^ buttonmask);
|
|
|
|
buttonmask = this_button_mask;
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
if (_datawheel) {
|
|
|
|
datawheel ();
|
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// SHIFT + STOP + PLAY for bling mode?
|
|
|
|
// if (button_changes & ButtonPlay & ButtonStop) {
|
|
|
|
// bling_mode_toggle();
|
|
|
|
// } or something like that
|
|
|
|
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_battery,ButtonBattery);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_backlight,ButtonBacklight);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_trackleft,ButtonTrackLeft);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_trackright,ButtonTrackRight);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_trackrec,ButtonTrackRec);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_trackmute,ButtonTrackMute);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_tracksolo,ButtonTrackSolo);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_undo,ButtonUndo);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_in,ButtonIn);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_out,ButtonOut);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_punch,ButtonPunch);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_loop,ButtonLoop);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_prev,ButtonPrev);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_add,ButtonAdd);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_next,ButtonNext);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_rewind,ButtonRewind);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_fastforward,ButtonFastForward);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_stop,ButtonStop);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_play,ButtonPlay);
|
|
|
|
TRANZPORT_BUTTON_HANDLER(button_event_record,ButtonRecord);
|
2006-04-03 23:26:08 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_current_track ()
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
char pad[11];
|
|
|
|
char *v;
|
|
|
|
int len;
|
2006-05-17 22:19:27 -04:00
|
|
|
if (route_table[0] == 0) {
|
2006-12-29 14:13:18 -05:00
|
|
|
print (0, 0, "----------");
|
|
|
|
last_track_gain = FLT_MAX;
|
2006-04-04 23:05:30 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
strcpy(pad," ");
|
|
|
|
v = (char *)route_get_name (0).substr (0, 10).c_str();
|
|
|
|
if((len = strlen(v)) > 0) {
|
|
|
|
strncpy(pad,(char *)v,len);
|
|
|
|
}
|
|
|
|
print (0, 0, pad);
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
2006-04-04 23:05:30 -04:00
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_battery_press (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_battery_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_backlight_press (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("backlight pressed\n");
|
|
|
|
#endif
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_backlight_release (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("backlight released\n\n");
|
|
|
|
#endif
|
|
|
|
if (shifted) {
|
|
|
|
lcd_damage();
|
|
|
|
lcd_clear();
|
|
|
|
last_where += 1; /* force time redisplay */
|
|
|
|
last_track_gain = FLT_MAX;
|
|
|
|
normal_update(); // redraw_screen();
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackleft_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
prev_track ();
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackleft_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackright_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
next_track ();
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackright_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackrec_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-04-24 18:45:19 -04:00
|
|
|
toggle_all_rec_enables ();
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
2006-05-17 22:19:27 -04:00
|
|
|
route_set_rec_enable (0, !route_get_rec_enable (0));
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackrec_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackmute_press (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
if (shifted) {
|
|
|
|
// Mute ALL? Something useful when a phone call comes in. Mute master?
|
|
|
|
} else {
|
|
|
|
route_set_muted (0, !route_get_muted (0));
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_trackmute_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_tracksolo_press (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("solo pressed\n");
|
|
|
|
#endif
|
2006-04-18 22:11:39 -04:00
|
|
|
if (display_mode == DisplayBigMeter) {
|
|
|
|
light_off (LightAnysolo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-05-18 12:44:07 -04:00
|
|
|
session->set_all_solo (!session->soloing());
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
2006-05-17 22:19:27 -04:00
|
|
|
route_set_soloed (0, !route_get_soloed (0));
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_tracksolo_release (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
#if DEBUG_TRANZPORT
|
|
|
|
printf("solo released\n");
|
|
|
|
#endif
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_undo_press (bool shifted)
|
|
|
|
{
|
2006-04-04 23:05:30 -04:00
|
|
|
if (shifted) {
|
2006-12-29 14:13:18 -05:00
|
|
|
redo (); // someday flash the screen with what was redone
|
2006-04-04 23:05:30 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
undo (); // someday flash the screen with what was undone
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_undo_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_in_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-04-29 11:40:52 -04:00
|
|
|
toggle_punch_in ();
|
|
|
|
} else {
|
2006-04-05 21:52:45 -04:00
|
|
|
ControlProtocol::ZoomIn (); /* EMIT SIGNAL */
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_in_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_out_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-04-29 11:40:52 -04:00
|
|
|
toggle_punch_out ();
|
|
|
|
} else {
|
2006-04-05 21:52:45 -04:00
|
|
|
ControlProtocol::ZoomOut (); /* EMIT SIGNAL */
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_out_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_punch_press (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_punch_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_loop_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-04-06 12:51:27 -04:00
|
|
|
next_wheel_shift_mode ();
|
2006-04-24 18:45:19 -04:00
|
|
|
} else {
|
|
|
|
loop_toggle ();
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_loop_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_prev_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
|
|
|
ControlProtocol::ZoomToSession (); /* EMIT SIGNAL */
|
|
|
|
} else {
|
|
|
|
prev_marker ();
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_prev_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_add_press (bool shifted)
|
|
|
|
{
|
2006-04-24 18:45:19 -04:00
|
|
|
add_marker ();
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_add_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_next_press (bool shifted)
|
|
|
|
{
|
2006-04-06 12:51:27 -04:00
|
|
|
if (shifted) {
|
|
|
|
next_wheel_mode ();
|
|
|
|
} else {
|
|
|
|
next_marker ();
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_next_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_rewind_press (bool shifted)
|
|
|
|
{
|
2006-04-04 23:05:30 -04:00
|
|
|
if (shifted) {
|
2006-04-24 18:45:19 -04:00
|
|
|
goto_start ();
|
2006-04-04 23:05:30 -04:00
|
|
|
} else {
|
2006-04-24 18:45:19 -04:00
|
|
|
rewind ();
|
2006-04-04 23:05:30 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_rewind_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_fastforward_press (bool shifted)
|
|
|
|
{
|
2006-04-04 23:05:30 -04:00
|
|
|
if (shifted) {
|
2006-04-24 18:45:19 -04:00
|
|
|
goto_end ();
|
2006-04-04 23:05:30 -04:00
|
|
|
} else {
|
2006-04-24 18:45:19 -04:00
|
|
|
ffwd ();
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_fastforward_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_stop_press (bool shifted)
|
|
|
|
{
|
2006-04-09 23:54:00 -04:00
|
|
|
if (shifted) {
|
|
|
|
next_display_mode ();
|
|
|
|
} else {
|
2006-04-24 18:45:19 -04:00
|
|
|
transport_stop ();
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_stop_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_play_press (bool shifted)
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
if (shifted) {
|
|
|
|
set_transport_speed (1.0f);
|
|
|
|
} else {
|
|
|
|
transport_play ();
|
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_play_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_record_press (bool shifted)
|
|
|
|
{
|
2006-04-05 21:52:45 -04:00
|
|
|
if (shifted) {
|
2006-04-24 18:45:19 -04:00
|
|
|
save_state ();
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
2006-04-24 18:45:19 -04:00
|
|
|
rec_enable_toggle ();
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::button_event_record_release (bool shifted)
|
|
|
|
{
|
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void button_event_mute (bool pressed, bool shifted)
|
|
|
|
{
|
|
|
|
static int was_pressed = 0;
|
|
|
|
// if(pressed) { }
|
|
|
|
}
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::datawheel ()
|
|
|
|
{
|
|
|
|
if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) {
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
/* track scrolling */
|
|
|
|
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
next_track ();
|
|
|
|
} else {
|
|
|
|
prev_track ();
|
|
|
|
}
|
|
|
|
|
|
|
|
timerclear (&last_wheel_motion);
|
|
|
|
|
|
|
|
} else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
next_marker ();
|
|
|
|
} else {
|
|
|
|
prev_marker ();
|
|
|
|
}
|
|
|
|
|
|
|
|
timerclear (&last_wheel_motion);
|
|
|
|
|
|
|
|
} else if (buttonmask & ButtonShift) {
|
|
|
|
|
|
|
|
/* parameter control */
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
if (route_table[0]) {
|
2006-04-06 12:51:27 -04:00
|
|
|
switch (wheel_shift_mode) {
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelShiftGain:
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
step_gain_up ();
|
|
|
|
} else {
|
|
|
|
step_gain_down ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WheelShiftPan:
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
step_pan_right ();
|
|
|
|
} else {
|
|
|
|
step_pan_left ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WheelShiftMarker:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WheelShiftMaster:
|
|
|
|
break;
|
2006-04-05 21:52:45 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timerclear (&last_wheel_motion);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
switch (wheel_mode) {
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelTimeline:
|
|
|
|
scroll ();
|
|
|
|
break;
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelScrub:
|
|
|
|
scrub ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WheelShuttle:
|
|
|
|
shuttle ();
|
|
|
|
break;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::scroll ()
|
|
|
|
{
|
2006-12-29 14:13:18 -05:00
|
|
|
float m = 1.0;
|
2006-04-06 12:51:27 -04:00
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
2006-12-29 14:13:18 -05:00
|
|
|
m = 1.0;
|
2006-04-06 12:51:27 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
m = -1.0;
|
|
|
|
}
|
|
|
|
switch(wheel_increment) {
|
|
|
|
case WheelIncrScreen: ScrollTimeline (0.2*m); break;
|
|
|
|
default: break; // other modes unimplemented as yet
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::scrub ()
|
|
|
|
{
|
|
|
|
float speed;
|
|
|
|
struct timeval now;
|
|
|
|
struct timeval delta;
|
|
|
|
int dir;
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
gettimeofday (&now, 0);
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
dir = 1;
|
|
|
|
} else {
|
|
|
|
dir = -1;
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
if (dir != last_wheel_dir) {
|
|
|
|
/* changed direction, start over */
|
2006-04-24 18:45:19 -04:00
|
|
|
speed = 0.1f;
|
2006-04-06 12:51:27 -04:00
|
|
|
} else {
|
|
|
|
if (timerisset (&last_wheel_motion)) {
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
timersub (&now, &last_wheel_motion, &delta);
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
/* 10 clicks per second => speed == 1.0 */
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
} else {
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
/* start at half-speed and see where we go from there */
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
speed = 0.5f;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
last_wheel_motion = now;
|
|
|
|
last_wheel_dir = dir;
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
set_transport_speed (speed * dir);
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::config ()
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::shuttle ()
|
|
|
|
{
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
2006-05-18 12:44:07 -04:00
|
|
|
if (session->transport_speed() < 0) {
|
|
|
|
session->request_transport_speed (1.0);
|
2006-04-09 23:54:00 -04:00
|
|
|
} else {
|
2006-05-18 12:44:07 -04:00
|
|
|
session->request_transport_speed (session->transport_speed() + 0.1);
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
2006-04-06 12:51:27 -04:00
|
|
|
} else {
|
2006-05-18 12:44:07 -04:00
|
|
|
if (session->transport_speed() > 0) {
|
|
|
|
session->request_transport_speed (-1.0);
|
2006-04-09 23:54:00 -04:00
|
|
|
} else {
|
2006-05-18 12:44:07 -04:00
|
|
|
session->request_transport_speed (session->transport_speed() - 0.1);
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::step_gain_up ()
|
|
|
|
{
|
|
|
|
if (buttonmask & ButtonStop) {
|
2006-04-29 11:40:52 -04:00
|
|
|
gain_fraction += 0.001;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
2006-04-29 11:40:52 -04:00
|
|
|
gain_fraction += 0.01;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gain_fraction > 2.0) {
|
|
|
|
gain_fraction = 2.0;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-29 11:40:52 -04:00
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
route_set_gain (0, slider_position_to_gain (gain_fraction));
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::step_gain_down ()
|
|
|
|
{
|
|
|
|
if (buttonmask & ButtonStop) {
|
2006-04-29 11:40:52 -04:00
|
|
|
gain_fraction -= 0.001;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
2006-04-29 11:40:52 -04:00
|
|
|
gain_fraction -= 0.01;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gain_fraction < 0.0) {
|
|
|
|
gain_fraction = 0.0;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-04-29 11:40:52 -04:00
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
route_set_gain (0, slider_position_to_gain (gain_fraction));
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::step_pan_right ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::step_pan_left ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
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;
|
2006-12-29 14:13:18 -05:00
|
|
|
break;
|
|
|
|
case WheelShiftMarker: // Not done yet, disabled
|
|
|
|
wheel_shift_mode = WheelShiftGain;
|
|
|
|
break;
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
show_wheel_mode ();
|
|
|
|
}
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
void
|
|
|
|
TranzportControlProtocol::next_wheel_mode ()
|
|
|
|
{
|
|
|
|
switch (wheel_mode) {
|
2006-04-06 12:51:27 -04:00
|
|
|
case WheelTimeline:
|
|
|
|
wheel_mode = WheelScrub;
|
2006-04-05 21:52:45 -04:00
|
|
|
break;
|
2006-04-06 12:51:27 -04:00
|
|
|
case WheelScrub:
|
|
|
|
wheel_mode = WheelShuttle;
|
2006-04-05 21:52:45 -04:00
|
|
|
break;
|
2006-04-06 12:51:27 -04:00
|
|
|
case WheelShuttle:
|
|
|
|
wheel_mode = WheelTimeline;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
show_wheel_mode ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::next_track ()
|
|
|
|
{
|
2006-05-17 22:19:27 -04:00
|
|
|
ControlProtocol::next_track (current_track_id);
|
|
|
|
gain_fraction = gain_to_slider_position (route_get_effective_gain (0));
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::prev_track ()
|
|
|
|
{
|
2006-05-17 22:19:27 -04:00
|
|
|
ControlProtocol::prev_track (current_track_id);
|
|
|
|
gain_fraction = gain_to_slider_position (route_get_effective_gain (0));
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::show_wheel_mode ()
|
|
|
|
{
|
2006-04-06 12:51:27 -04:00
|
|
|
string text;
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
switch (wheel_mode) {
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelTimeline:
|
|
|
|
text = "Time";
|
|
|
|
break;
|
|
|
|
case WheelScrub:
|
|
|
|
text = "Scrb";
|
|
|
|
break;
|
|
|
|
case WheelShuttle:
|
|
|
|
text = "Shtl";
|
|
|
|
break;
|
2006-04-06 12:51:27 -04:00
|
|
|
}
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
switch (wheel_shift_mode) {
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelShiftGain:
|
|
|
|
text += ":Gain";
|
|
|
|
break;
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelShiftPan:
|
|
|
|
text += ":Pan ";
|
|
|
|
break;
|
2006-04-06 12:51:27 -04:00
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
case WheelShiftMaster:
|
|
|
|
text += ":Mstr";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WheelShiftMarker:
|
|
|
|
text += ":Mrkr";
|
|
|
|
break;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
2006-04-06 12:51:27 -04:00
|
|
|
print (1, 0, text.c_str());
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
// Was going to keep state around saying to retry or not
|
|
|
|
// haven't got to it yet, still not sure it's a good idea
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::print (int row, int col, const char *text) {
|
|
|
|
print_noretry(row,col,text);
|
|
|
|
}
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
void
|
2006-12-29 14:13:18 -05:00
|
|
|
TranzportControlProtocol::print_noretry (int row, int col, const char *text)
|
2006-04-05 21:52:45 -04:00
|
|
|
{
|
|
|
|
int cell;
|
|
|
|
uint32_t left = strlen (text);
|
|
|
|
char tmp[5];
|
2006-04-05 22:17:58 -04:00
|
|
|
int base_col;
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
if (row < 0 || row > 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (col < 0 || col > 19) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (left) {
|
|
|
|
|
|
|
|
if (col >= 0 && col < 4) {
|
|
|
|
cell = 0;
|
2006-04-05 22:17:58 -04:00
|
|
|
base_col = 0;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else if (col >= 4 && col < 8) {
|
|
|
|
cell = 1;
|
2006-04-05 22:17:58 -04:00
|
|
|
base_col = 4;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else if (col >= 8 && col < 12) {
|
|
|
|
cell = 2;
|
2006-04-05 22:17:58 -04:00
|
|
|
base_col = 8;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else if (col >= 12 && col < 16) {
|
|
|
|
cell = 3;
|
2006-04-05 22:17:58 -04:00
|
|
|
base_col = 12;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else if (col >= 16 && col < 20) {
|
|
|
|
cell = 4;
|
2006-04-05 22:17:58 -04:00
|
|
|
base_col = 16;
|
2006-04-05 21:52:45 -04:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2006-04-05 22:17:58 -04:00
|
|
|
|
|
|
|
int offset = col % 4;
|
|
|
|
|
2006-04-24 18:45:19 -04:00
|
|
|
/* copy current cell contents into tmp */
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
memcpy (tmp, &screen_pending[row][base_col], 4);
|
2006-04-24 18:45:19 -04:00
|
|
|
|
|
|
|
/* overwrite with new text */
|
|
|
|
|
|
|
|
uint32_t tocopy = min ((4U - offset), left);
|
|
|
|
|
|
|
|
memcpy (tmp+offset, text, tocopy);
|
|
|
|
|
|
|
|
/* copy it back to pending */
|
|
|
|
|
2006-12-29 14:13:18 -05:00
|
|
|
memcpy (&screen_pending[row][base_col], tmp, 4);
|
2006-04-24 18:45:19 -04:00
|
|
|
|
|
|
|
text += tocopy;
|
|
|
|
left -= tocopy;
|
|
|
|
col += tocopy;
|
2006-04-05 21:52:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-10 16:01:47 -04:00
|
|
|
XMLNode&
|
|
|
|
TranzportControlProtocol::get_state ()
|
|
|
|
{
|
2006-10-04 21:49:32 -04:00
|
|
|
XMLNode* node = new XMLNode (X_("Protocol"));
|
|
|
|
node->add_property (X_("name"), _name);
|
2006-07-10 16:01:47 -04:00
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::set_state (const XMLNode& node)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-29 14:13:18 -05:00
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::save (char *name)
|
|
|
|
{
|
|
|
|
// Presently unimplemented
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TranzportControlProtocol::load (char *name)
|
|
|
|
{
|
|
|
|
// Presently unimplemented
|
|
|
|
return 0;
|
|
|
|
}
|