1 #ifndef mackie_jog_wheel
2 #define mackie_jog_wheel
10 class MackieControlProtocol;
20 A jog wheel can be used to control many things. This
21 handles all of the states and state transitions.
23 Mainly it exists to avoid putting a bunch of messy
24 stuff in MackieControlProtocol.
26 But it doesn't really know who it is, with stacks, queues and various
27 boolean state variables.
32 enum State { scroll, zoom, speed, scrub, shuttle, select };
34 JogWheel( MackieControlProtocol & mcp );
36 /// As the wheel turns...
37 void jog_event( SurfacePort & port, Control & control, const ControlState & state );
39 // These are for incoming button presses that change the internal state
40 // but they're not actually used at the moment.
41 void zoom_event( SurfacePort & port, Control & control, const ControlState & state );
42 void scrub_event( SurfacePort & port, Control & control, const ControlState & state );
43 void speed_event( SurfacePort & port, Control & control, const ControlState & state );
44 void scroll_event( SurfacePort & port, Control & control, const ControlState & state );
46 /// Return the current jog wheel mode, which defaults to Scroll
47 State jog_wheel_state() const;
49 /// The current transport speed for ffwd and rew. Can be
50 /// set by wheel when they're pressed.
51 float transport_speed() const { return _transport_speed; }
54 int transport_direction() const { return _transport_direction; }
55 void transport_direction( int rhs ) { _transport_direction = rhs; }
57 void push( State state );
60 /// Turn zoom mode on and off
61 void zoom_state_toggle();
64 Cycle scrub -> shuttle -> previous
66 State scrub_state_cycle();
68 /// Check to see when the last scrub event was
69 /// And stop scrubbing if it was too long ago.
70 /// Intended to be called from a periodic timer of
72 void check_scrubbing();
75 void add_scrub_interval( unsigned long elapsed );
76 float average_scrub_interval();
77 float std_dev_scrub_interval();
80 MackieControlProtocol & _mcp;
82 /// transport speed for ffwd and rew, controller by jog
83 float _transport_speed;
84 int _transport_direction;
89 /// a stack for keeping track of states
90 std::stack<State> _jog_wheel_states;
92 /// So we know how fast to set the transport speed while scrubbing
95 /// to keep track of what the current scrub rate is
96 /// so we can calculate a moving average
97 std::deque<unsigned long> _scrub_intervals;