/*
- * Copyright (C) 2006 Paul Davis
+ * Copyright (C) 2006 Paul Davis
* Copyright (C) 2007 Michael Taht
*
* This program is free software; you can redistribute it and/or modify
* 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.
- *
+ *
* */
#include <iostream>
#include <float.h>
#include <sys/time.h>
#include <errno.h>
-#include <ardour/route.h>
-#include <ardour/audio_track.h>
-#include <ardour/session.h>
-#include <ardour/location.h>
-#include <ardour/dB.h>
+#include "ardour/route.h"
+#include "ardour/audio_track.h"
+#include "ardour/session.h"
+#include "ardour/location.h"
+#include "ardour/dB.h"
using namespace ARDOUR;
using namespace std;
#include "i18n.h"
-#include <pbd/abstract_ui.cc>
+#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 ();
-#include <tranzport_control_protocol.h>
+#include "tranzport_control_protocol.h"
void
TranzportControlProtocol::datawheel ()
if ((buttonmask & ButtonTrackRight) || (buttonmask & ButtonTrackLeft)) {
/* track scrolling */
-
+
if (_datawheel < WheelDirectionThreshold) {
next_track ();
} else {
prev_track ();
}
- timerclear (&last_wheel_motion);
-
+ last_wheel_motion = 0;
+
} else if ((buttonmask & ButtonPrev) || (buttonmask & ButtonNext)) {
if (_datawheel < WheelDirectionThreshold) {
} else {
prev_marker ();
}
-
- timerclear (&last_wheel_motion);
-
+
+ last_wheel_motion = 0;
+
} else if (buttonmask & ButtonShift) {
-
+
/* parameter control */
-
+
if (route_table[0]) {
switch (wheel_shift_mode) {
case WheelShiftGain:
step_pan_left ();
}
break;
-
+
case WheelShiftMarker:
break;
-
+
case WheelShiftMaster:
break;
-
+
}
}
-
- timerclear (&last_wheel_motion);
-
+
+ last_wheel_motion = 0;
+
} else {
-
+
switch (wheel_mode) {
case WheelTimeline:
scroll ();
break;
-
+
case WheelScrub:
scrub ();
break;
-
+
case WheelShuttle:
shuttle ();
break;
TranzportControlProtocol::scrub ()
{
float speed;
- struct timeval now;
- struct timeval delta;
+ uint64_t now;
int dir;
-
- gettimeofday (&now, 0);
-
+
+ now = g_get_monotonic_time();
+
if (_datawheel < WheelDirectionThreshold) {
dir = 1;
} else {
dir = -1;
}
-
+
if (dir != last_wheel_dir) {
/* changed direction, start over */
speed = 0.1f;
} else {
- if (timerisset (&last_wheel_motion)) {
-
- timersub (&now, &last_wheel_motion, &delta);
-
+ if (last_wheel_motion != 0) {
/* 10 clicks per second => speed == 1.0 */
-
- speed = 100000.0f / (delta.tv_sec * 1000000 + delta.tv_usec);
-
+
+ speed = 100000.0f / (float) (now - last_wheel_motion)
+
} else {
-
+
/* start at half-speed and see where we go from there */
-
+
speed = 0.5f;
}
}
-
+
last_wheel_motion = now;
last_wheel_dir = dir;
-
+
set_transport_speed (speed * dir);
}
if (session->transport_speed() < 0) {
session->request_transport_speed (1.0);
} else {
- session->request_transport_speed (session->transport_speed() + 0.1);
+ session->request_transport_speed_nonzero (session->transport_speed() + 0.1);
}
} else {
if (session->transport_speed() > 0) {
session->request_transport_speed (-1.0);
} else {
- session->request_transport_speed (session->transport_speed() - 0.1);
+ session->request_transport_speed_nonzero (session->transport_speed() - 0.1);
}
}
}