#include <jack/jack.h>
+#include "ardour/midi_state_tracker.h"
+
typedef uint64_t superclock_t;
static const superclock_t superclock_ticks_per_second = 508032000; // 2^10 * 3^4 * 5^3 * 7^2
inline superclock_t superclock_to_samples (superclock_t s, int sr) { return (s * sr) / superclock_ticks_per_second; }
inline superclock_t samples_to_superclock (int samples, int sr) { return (samples * superclock_ticks_per_second) / sr; }
+namespace ARDOUR {
+class Session;
+}
+
class BeatBox {
public:
BeatBox (int sample_rate);
void set_quantize (int divisor);
+ float tempo() const { return _tempo; }
+ int meter_beats() const { return _meter_beats; }
+ int meter_beat_type() const { return _meter_beat_type; }
+
private:
bool _start_requested;
bool _running;
int _measures;
float _tempo;
+ float _tempo_request;
int _meter_beats;
int _meter_beat_type;
jack_port_t* _input;
superclock_t measure_superclocks;
int _quantize_divisor;
bool clear_pending;
+ ARDOUR::MidiStateTracker inbound_tracker;
+ ARDOUR::MidiStateTracker outbound_tracker;
struct Event {
superclock_t time;
+ superclock_t whole_note_superclocks;
size_t size;
unsigned char buf[24];
bool operator () (Event const * a, Event const * b) const;
};
+ typedef std::vector<Event*> IncompleteNotes;
+ IncompleteNotes _incomplete_notes;
+
typedef std::set<Event*,EventComparator> Events;
Events _current_events;
typedef std::vector<Event*> EventPool;
EventPool event_pool;
+
+ void compute_tempo_clocks ();
};