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 last_wheel_motion = 0;
67 } else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
69 if (_datawheel < WheelDirectionThreshold) {
75 last_wheel_motion = 0;
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 last_wheel_motion = 0;
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 ()
155 now = g_get_monotonic_time();
157 if (_datawheel < WheelDirectionThreshold) {
163 if (dir != last_wheel_dir) {
164 /* changed direction, start over */
167 if (last_wheel_motion != 0) {
168 /* 10 clicks per second => speed == 1.0 */
170 speed = 100000.0f / (float) (now - last_wheel_motion)
174 /* start at half-speed and see where we go from there */
180 last_wheel_motion = now;
181 last_wheel_dir = dir;
183 set_transport_speed (speed * dir);
187 TranzportControlProtocol::shuttle ()
189 if (_datawheel < WheelDirectionThreshold) {
190 if (session->transport_speed() < 0) {
191 session->request_transport_speed (1.0);
193 session->request_transport_speed_nonzero (session->transport_speed() + 0.1);
196 if (session->transport_speed() > 0) {
197 session->request_transport_speed (-1.0);
199 session->request_transport_speed_nonzero (session->transport_speed() - 0.1);