+/** Helper class to keep track of the Meter *AND* Tempo in effect
+ at a given point in time.
+*/
+class TempoMetric {
+ public:
+ TempoMetric (const Meter& m, const Tempo& t)
+ : _meter (&m), _tempo (&t), _frame (0) {}
+
+ void set_tempo (const Tempo& t) { _tempo = &t; }
+ void set_meter (const Meter& m) { _meter = &m; }
+ void set_frame (framepos_t f) { _frame = f; }
+ void set_start (const Timecode::BBT_Time& t) { _start = t; }
+
+ void set_metric (const MetricSection* section) {
+ const MeterSection* meter;
+ const TempoSection* tempo;
+ if ((meter = dynamic_cast<const MeterSection*>(section))) {
+ set_meter(*meter);
+ } else if ((tempo = dynamic_cast<const TempoSection*>(section))) {
+ set_tempo(*tempo);
+ }
+
+ set_frame(section->frame());
+ set_start(section->start());
+ }
+
+ const Meter& meter() const { return *_meter; }
+ const Tempo& tempo() const { return *_tempo; }
+ framepos_t frame() const { return _frame; }
+ const Timecode::BBT_Time& start() const { return _start; }
+
+ private:
+ const Meter* _meter;
+ const Tempo* _tempo;
+ framepos_t _frame;
+ Timecode::BBT_Time _start;
+};
+