2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2015-10-04 14:51:05 -04:00
|
|
|
* Copyright (C) 2006 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
* Copyright (C) 2007 Michael Taht
|
|
|
|
*
|
|
|
|
* 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.
|
2015-10-04 14:51:05 -04:00
|
|
|
*
|
2008-06-02 17:41:35 -04:00
|
|
|
* */
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <float.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/location.h"
|
|
|
|
#include "ardour/dB.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
using namespace sigc;
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "pbd/abstract_ui.cc"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
BaseUI::RequestType LEDChange = BaseUI::new_request_type ();
|
|
|
|
BaseUI::RequestType Print = BaseUI::new_request_type ();
|
|
|
|
BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type ();
|
|
|
|
|
|
|
|
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "tranzport_control_protocol.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::datawheel ()
|
|
|
|
{
|
|
|
|
if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) {
|
|
|
|
|
|
|
|
/* track scrolling */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
next_track ();
|
|
|
|
} else {
|
|
|
|
prev_track ();
|
|
|
|
}
|
|
|
|
|
2014-05-16 13:58:46 -04:00
|
|
|
last_wheel_motion = 0;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
} else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
|
|
|
|
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
next_marker ();
|
|
|
|
} else {
|
|
|
|
prev_marker ();
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-05-16 13:58:46 -04:00
|
|
|
last_wheel_motion = 0;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
} else if (buttonmask & ButtonShift) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
/* parameter control */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (route_table[0]) {
|
|
|
|
switch (wheel_shift_mode) {
|
|
|
|
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;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
case WheelShiftMarker:
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
case WheelShiftMaster:
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-05-16 13:58:46 -04:00
|
|
|
last_wheel_motion = 0;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
} else {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
switch (wheel_mode) {
|
|
|
|
case WheelTimeline:
|
|
|
|
scroll ();
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
case WheelScrub:
|
|
|
|
scrub ();
|
|
|
|
break;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
case WheelShuttle:
|
|
|
|
shuttle ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::scroll ()
|
|
|
|
{
|
|
|
|
float m = 1.0;
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
m = 1.0;
|
|
|
|
} else {
|
|
|
|
m = -1.0;
|
|
|
|
}
|
|
|
|
switch(wheel_increment) {
|
|
|
|
case WheelIncrScreen: ScrollTimeline (0.2*m); break;
|
|
|
|
case WheelIncrSlave:
|
|
|
|
case WheelIncrSample:
|
|
|
|
case WheelIncrBeat:
|
|
|
|
case WheelIncrBar:
|
|
|
|
case WheelIncrSecond:
|
|
|
|
case WheelIncrMinute:
|
|
|
|
default: break; // other modes unimplemented as yet
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::scrub ()
|
|
|
|
{
|
|
|
|
float speed;
|
2014-05-16 13:58:46 -04:00
|
|
|
uint64_t now;
|
2008-06-02 17:41:35 -04:00
|
|
|
int dir;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-05-16 13:58:46 -04:00
|
|
|
now = g_get_monotonic_time();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
dir = 1;
|
|
|
|
} else {
|
|
|
|
dir = -1;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (dir != last_wheel_dir) {
|
|
|
|
/* changed direction, start over */
|
|
|
|
speed = 0.1f;
|
|
|
|
} else {
|
2014-05-16 13:58:46 -04:00
|
|
|
if (last_wheel_motion != 0) {
|
2008-06-02 17:41:35 -04:00
|
|
|
/* 10 clicks per second => speed == 1.0 */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-05-16 13:58:46 -04:00
|
|
|
speed = 100000.0f / (float) (now - last_wheel_motion)
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
} else {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
/* start at half-speed and see where we go from there */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
speed = 0.5f;
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
last_wheel_motion = now;
|
|
|
|
last_wheel_dir = dir;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
set_transport_speed (speed * dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TranzportControlProtocol::shuttle ()
|
|
|
|
{
|
|
|
|
if (_datawheel < WheelDirectionThreshold) {
|
|
|
|
if (session->transport_speed() < 0) {
|
|
|
|
session->request_transport_speed (1.0);
|
|
|
|
} else {
|
2011-02-06 20:12:47 -05:00
|
|
|
session->request_transport_speed_nonzero (session->transport_speed() + 0.1);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (session->transport_speed() > 0) {
|
|
|
|
session->request_transport_speed (-1.0);
|
|
|
|
} else {
|
2011-02-06 20:12:47 -05:00
|
|
|
session->request_transport_speed_nonzero (session->transport_speed() - 0.1);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|