- Position() : speed(0.0f), frame(0) { }
- ~Position() { }
-
- /** Sync timing information taken from the given Session
- @return True if timings differed */
- bool sync (Session* s) {
-
- bool didit = false;
-
- double sp = s->transport_speed();
- framecnt_t fr = s->transport_frame();
-
- if (speed != sp) {
- speed = sp;
- didit = true;
- }
-
- if (frame != fr) {
- frame = fr;
-
- s->bbt_time (this->frame, *this);
-
- const TempoMap& tempo = s->tempo_map();
-
- const double divisions = tempo.meter_at(frame).divisions_per_bar();
- const double divisor = tempo.meter_at(frame).note_divisor();
- const double qnote_scale = divisor * 0.25f;
-
- /* Midi Beats in terms of Song Position Pointer is equivalent to total
- sixteenth notes at 'time' */
-
- midi_beats = (((bars - 1) * divisions) + beats - 1);
- midi_beats += (double)ticks / (double)Position::ticks_per_beat * qnote_scale;
- midi_beats *= 16.0f / divisor;
-
- midi_clocks = midi_beats * 6.0f;
-
- didit = true;
- }
-
- return didit;
- }
-
- double speed;
- framecnt_t frame;
- double midi_beats;
- double midi_clocks;
-
- void print (std::ostream& s) {
- s << "frames: " << frame << " midi beats: " << midi_beats << " speed: " << speed;
- }
+ Position() : speed(0.0f), frame(0), midi_beats(0) { }
+ ~Position() { }
+
+ /** Sync timing information taken from the given Session
+ * @return True if timings differed
+ */
+
+ bool sync (Session* s) {
+
+ bool changed = false;
+
+ double sp = s->transport_speed();
+ framecnt_t fr = s->transport_frame();
+
+ if (speed != sp) {
+ speed = sp;
+ changed = true;
+ }
+
+ if (frame != fr) {
+ frame = fr;
+ changed = true;
+ }
+
+ /* Midi beats and clocks always gets updated for now */
+
+ s->bbt_time (this->frame, *this);
+
+ const TempoMap& tempo = s->tempo_map();
+
+ const double divisions = tempo.meter_at(frame).divisions_per_bar();
+ const double divisor = tempo.meter_at(frame).note_divisor();
+ const double qnote_scale = divisor * 0.25f;
+ double mb;
+
+ /** Midi Beats in terms of Song Position Pointer is equivalent to total
+ * sixteenth notes at 'time'
+ */
+
+ mb = (((bars - 1) * divisions) + beats - 1);
+ mb += (double)ticks / (double)Position::ticks_per_beat * qnote_scale;
+ mb *= 16.0f / divisor;
+
+ if (mb != midi_beats) {
+ midi_beats = mb;
+ midi_clocks = midi_beats * 6.0f;
+ changed = true;
+ }
+
+ return changed;
+ }
+
+ double speed;
+ framecnt_t frame;
+ double midi_beats;
+ double midi_clocks;
+
+ void print (std::ostream& s) {
+ s << "frames: " << frame << " midi beats: " << midi_beats << " speed: " << speed;
+ }