2 * Copyright (C) 2006 Paul Davis
3 * Copyright (C) 2007 Michael Taht
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define __STDC_FORMAT_MACROS
30 #include <ardour/route.h>
31 #include <ardour/audio_track.h>
32 #include <ardour/session.h>
33 #include <ardour/location.h>
34 #include <ardour/dB.h>
36 using namespace ARDOUR;
43 #include <pbd/abstract_ui.cc>
45 BaseUI::RequestType LEDChange = BaseUI::new_request_type ();
46 BaseUI::RequestType Print = BaseUI::new_request_type ();
47 BaseUI::RequestType SetCurrentTrack = BaseUI::new_request_type ();
50 #include <tranzport_control_protocol.h>
53 TranzportControlProtocol::datawheel ()
55 if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) {
59 if (_datawheel < WheelDirectionThreshold) {
65 timerclear (&last_wheel_motion);
67 } else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
69 if (_datawheel < WheelDirectionThreshold) {
75 timerclear (&last_wheel_motion);
77 } else if (buttonmask & ButtonShift) {
79 /* parameter control */
82 switch (wheel_shift_mode) {
84 if (_datawheel < WheelDirectionThreshold) {
91 if (_datawheel < WheelDirectionThreshold) {
98 case WheelShiftMarker:
101 case WheelShiftMaster:
107 timerclear (&last_wheel_motion);
111 switch (wheel_mode) {
128 TranzportControlProtocol::scroll ()
131 if (_datawheel < WheelDirectionThreshold) {
136 switch(wheel_increment) {
137 case WheelIncrScreen: ScrollTimeline (0.2*m); break;
139 case WheelIncrSample:
142 case WheelIncrSecond:
143 case WheelIncrMinute:
144 default: break; // other modes unimplemented as yet
149 TranzportControlProtocol::scrub ()
153 struct timeval delta;
156 gettimeofday (&now, 0);
158 if (_datawheel < WheelDirectionThreshold) {
164 if (dir != last_wheel_dir) {
165 /* changed direction, start over */
168 if (timerisset (&last_wheel_motion)) {
170 timersub (&now, &last_wheel_motion, &delta);
172 /* 10 clicks per second => speed == 1.0 */
174 speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
178 /* start at half-speed and see where we go from there */
184 last_wheel_motion = now;
185 last_wheel_dir = dir;
187 set_transport_speed (speed * dir);
191 TranzportControlProtocol::shuttle ()
193 if (_datawheel < WheelDirectionThreshold) {
194 if (session->transport_speed() < 0) {
195 session->request_transport_speed (1.0);
197 session->request_transport_speed (session->transport_speed() + 0.1);
200 if (session->transport_speed() > 0) {
201 session->request_transport_speed (-1.0);
203 session->request_transport_speed (session->transport_speed() - 0.1);