diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-27 02:24:56 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-27 02:24:56 +0000 |
commit | 68a3144344ab0e103539ee27b9f95324f45dcbe7 (patch) | |
tree | e554abed86f8821ddd90c3ca9c905a6c25290785 /libs/ardour | |
parent | 9ad08bfe973c72f2d73fae2be786d99efdc20a26 (diff) |
new SnapBBT debug option, split out BBT_time and start work on BBT arithmetic framework. this will cause a full recompile, so find something else to do
git-svn-id: svn://localhost/ardour2/branches/3.0@5936 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/debug.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/session_configuration_vars.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/tempo.h | 54 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 33 | ||||
-rw-r--r-- | libs/ardour/enums.cc | 4 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_time.cc | 2 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 36 | ||||
-rw-r--r-- | libs/ardour/wscript | 1 |
9 files changed, 57 insertions, 80 deletions
diff --git a/libs/ardour/ardour/debug.h b/libs/ardour/ardour/debug.h index bc0fefb428..a8f826babe 100644 --- a/libs/ardour/ardour/debug.h +++ b/libs/ardour/ardour/debug.h @@ -37,7 +37,8 @@ namespace ARDOUR { enum DebugBits { MidiSourceIO = 0x1, MidiPlaylistIO = 0x2, - MidiDiskstreamIO = 0x4 + MidiDiskstreamIO = 0x4, + SnapBBT = 0x8 }; } diff --git a/libs/ardour/ardour/session_configuration_vars.h b/libs/ardour/ardour/session_configuration_vars.h index 8c1dffc884..fd85993a29 100644 --- a/libs/ardour/ardour/session_configuration_vars.h +++ b/libs/ardour/ardour/session_configuration_vars.h @@ -33,7 +33,7 @@ CONFIG_VARIABLE (bool, auto_input, "auto-input", true) CONFIG_VARIABLE (bool, punch_in, "punch-in", false) CONFIG_VARIABLE (bool, punch_out, "punch-out", false) CONFIG_VARIABLE (uint32_t, subframes_per_frame, "subframes-per-frame", 100) -CONFIG_VARIABLE (SmpteFormat, timecode_format, "timecode-format", timecode_30) +CONFIG_VARIABLE (TimecodeFormat, timecode_format, "timecode-format", timecode_30) CONFIG_VARIABLE_SPECIAL(Glib::ustring, raid_path, "raid-path", "", path_expand) CONFIG_VARIABLE (std::string, bwf_country_code, "bwf-country-code", "US") CONFIG_VARIABLE (std::string, bwf_organization_code, "bwf-organization-code", "US") diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 613339ff0b..147c6a64e6 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -140,6 +140,30 @@ class TempoSection : public MetricSection, public Tempo { typedef std::list<MetricSection*> Metrics; +/** Helper class that we use to be able to keep track of which + meter *AND* tempo are 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 (nframes_t f) { _frame = f; } + void set_start (const BBT_Time& t) { _start = t; } + + const Meter& meter() const { return *_meter; } + const Tempo& tempo() const { return *_tempo; } + nframes_t frame() const { return _frame; } + const BBT_Time& start() const { return _start; } + + private: + const Meter* _meter; + const Tempo* _tempo; + nframes_t _frame; + BBT_Time _start; +}; + class TempoMap : public PBD::StatefulDestructible { public: @@ -217,33 +241,9 @@ class TempoMap : public PBD::StatefulDestructible void dump (std::ostream&) const; void clear (); - /** Helper class that we use to be able to keep track of which - meter *AND* tempo are in effect at a given point in time. - */ - class Metric { - public: - Metric (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 (nframes_t f) { _frame = f; } - void set_start (const BBT_Time& t) { _start = t; } - - const Meter& meter() const { return *_meter; } - const Tempo& tempo() const { return *_tempo; } - nframes_t frame() const { return _frame; } - const BBT_Time& start() const { return _start; } - - private: - const Meter* _meter; - const Tempo* _tempo; - nframes_t _frame; - BBT_Time _start; - }; - - Metric metric_at (BBT_Time bbt) const; - Metric metric_at (nframes_t) const; - void bbt_time_with_metric (nframes_t, BBT_Time&, const Metric&) const; + TempoMetric metric_at (BBT_Time bbt) const; + TempoMetric metric_at (nframes_t) const; + void bbt_time_with_metric (nframes_t, BBT_Time&, const TempoMetric&) const; void change_existing_tempo_at (nframes_t, double bpm, double note_type); void change_initial_tempo (double bpm, double note_type); diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 1cc619424e..c6fc2419b2 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -34,6 +34,8 @@ #include "control_protocol/timecode.h" #include "pbd/id.h" +#include "ardour/bbt_time.h" + #include <map> #if __GNUC__ < 3 @@ -156,34 +158,7 @@ namespace ARDOUR { TrackColor }; - struct BBT_Time { - uint32_t bars; - uint32_t beats; - uint32_t ticks; - - BBT_Time() { - bars = 1; - beats = 1; - ticks = 0; - } - - /* we can't define arithmetic operators for BBT_Time, because - the results depend on a TempoMap, but we can define - a useful check on the less-than condition. - */ - - bool operator< (const BBT_Time& other) const { - return bars < other.bars || - (bars == other.bars && beats < other.beats) || - (bars == other.bars && beats == other.beats && ticks < other.ticks); - } - - bool operator== (const BBT_Time& other) const { - return bars == other.bars && beats == other.beats && ticks == other.ticks; - } - - }; - enum SmpteFormat { + enum TimecodeFormat { timecode_23976, timecode_24, timecode_24976, @@ -467,7 +442,7 @@ std::istream& operator>>(std::istream& o, ARDOUR::CrossfadeModel& sf); std::istream& operator>>(std::istream& o, ARDOUR::SlaveSource& sf); std::istream& operator>>(std::istream& o, ARDOUR::ShuttleBehaviour& sf); std::istream& operator>>(std::istream& o, ARDOUR::ShuttleUnits& sf); -std::istream& operator>>(std::istream& o, ARDOUR::SmpteFormat& sf); +std::istream& operator>>(std::istream& o, ARDOUR::TimecodeFormat& sf); std::istream& operator>>(std::istream& o, ARDOUR::DenormalModel& sf); std::istream& operator>>(std::istream& o, ARDOUR::WaveformScale& sf); std::istream& operator>>(std::istream& o, ARDOUR::WaveformShape& sf); diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index e2ba2bd6a5..af0ca7e14c 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -75,7 +75,7 @@ setup_enum_writer () ShuttleUnits _ShuttleUnits; Session::RecordState _Session_RecordState; Session::Event::Type _Session_Event_Type; - SmpteFormat _Session_SmpteFormat; + TimecodeFormat _Session_TimecodeFormat; Session::PullupFormat _Session_PullupFormat; AudioRegion::FadeShape _AudioRegion_FadeShape; Panner::LinkDirection _Panner_LinkDirection; @@ -321,7 +321,7 @@ setup_enum_writer () REGISTER_ENUM (timecode_30drop); REGISTER_ENUM (timecode_5994); REGISTER_ENUM (timecode_60); - REGISTER (_Session_SmpteFormat); + REGISTER (_Session_TimecodeFormat); REGISTER_CLASS_ENUM (Session, pullup_Plus4Plus1); REGISTER_CLASS_ENUM (Session, pullup_Plus4); diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index a8e28c1c5c..471924811a 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -637,7 +637,7 @@ std::istream& operator>>(std::istream& o, CrossfadeModel& var) { return int_to_t std::istream& operator>>(std::istream& o, SlaveSource& var) { return int_to_type<SlaveSource> (o, var); } std::istream& operator>>(std::istream& o, ShuttleBehaviour& var) { return int_to_type<ShuttleBehaviour> (o, var); } std::istream& operator>>(std::istream& o, ShuttleUnits& var) { return int_to_type<ShuttleUnits> (o, var); } -std::istream& operator>>(std::istream& o, SmpteFormat& var) { return int_to_type<SmpteFormat> (o, var); } +std::istream& operator>>(std::istream& o, TimecodeFormat& var) { return int_to_type<TimecodeFormat> (o, var); } std::istream& operator>>(std::istream& o, DenormalModel& var) { return int_to_type<DenormalModel> (o, var); } std::istream& operator>>(std::istream& o, WaveformScale& var) { return int_to_type<WaveformScale> (o, var); } std::istream& operator>>(std::istream& o, WaveformShape& var) { return int_to_type<WaveformShape> (o, var); } diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc index 167d936f50..9a6eebbaf8 100644 --- a/libs/ardour/session_time.cc +++ b/libs/ardour/session_time.cc @@ -501,7 +501,7 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/, if (_tempo_map) { - TempoMap::Metric metric (_tempo_map->metric_at (_transport_frame)); + TempoMetric metric (_tempo_map->metric_at (_transport_frame)); _tempo_map->bbt_time_with_metric (_transport_frame, bbt, metric); pos->bar = bbt.bars; diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 2f9f7b79f1..a79dc2eb41 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -26,6 +26,7 @@ #include <glibmm/thread.h> #include "pbd/xml++.h" +#include "ardour/debug.h" #include "ardour/tempo.h" #include "ardour/utils.h" @@ -656,7 +657,7 @@ TempoMap::timestamp_metrics (bool use_bbt) for (i = metrics->begin(); i != metrics->end(); ++i) { BBT_Time bbt; - Metric metric (*meter, *tempo); + TempoMetric metric (*meter, *tempo); if (prev) { metric.set_start (prev->start()); @@ -713,10 +714,10 @@ TempoMap::timestamp_metrics (bool use_bbt) } -TempoMap::Metric +TempoMetric TempoMap::metric_at (nframes_t frame) const { - Metric m (first_meter(), first_tempo()); + TempoMetric m (first_meter(), first_tempo()); const Meter* meter; const Tempo* tempo; @@ -746,10 +747,10 @@ TempoMap::metric_at (nframes_t frame) const return m; } -TempoMap::Metric +TempoMetric TempoMap::metric_at (BBT_Time bbt) const { - Metric m (first_meter(), first_tempo()); + TempoMetric m (first_meter(), first_tempo()); const Meter* meter; const Tempo* tempo; @@ -797,7 +798,7 @@ TempoMap::bbt_time_unlocked (nframes_t frame, BBT_Time& bbt) const } void -TempoMap::bbt_time_with_metric (nframes_t frame, BBT_Time& bbt, const Metric& metric) const +TempoMap::bbt_time_with_metric (nframes_t frame, BBT_Time& bbt, const TempoMetric& metric) const { nframes_t frame_diff; @@ -853,7 +854,7 @@ TempoMap::count_frames_between ( const BBT_Time& start, const BBT_Time& end) con nframes_t start_frame = 0; nframes_t end_frame = 0; - Metric m = metric_at (start); + TempoMetric m = metric_at (start); uint32_t bar_offset = start.bars - m.start().bars; @@ -965,7 +966,7 @@ TempoMap::bbt_duration_at_unlocked (const BBT_Time& when, const BBT_Time& bbt, i result.beats = 1; result.ticks = 0; - Metric metric = metric_at(result); + TempoMetric metric = metric_at(result); beats_per_bar = metric.meter().beats_per_bar(); @@ -1192,13 +1193,15 @@ TempoMap::round_to_beat_subdivision (nframes_t fr, int sub_num, int dir) nframes_t TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type) { - Metric metric = metric_at (frame); + TempoMetric metric = metric_at (frame); BBT_Time bbt; BBT_Time start; bbt_time_with_metric (frame, bbt, metric); + switch (type) { case Bar: + DEBUG_TRACE(DEBUG::SnapBBT, string_compose ("round from %1 (%3) to bars in direction %2\n", frame, (dir < 0 ? "back" : "forward"), bbt)); if (dir < 0) { if (bbt.bars > 1) { bbt.bars--; @@ -1219,10 +1222,12 @@ TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type) break; case Beat: + DEBUG_TRACE(DEBUG::SnapBBT, string_compose ("round from %1 (%3) to beat in direction %2\n", frame, (dir < 0 ? "back" : "forward"), bbt)); if (dir < 0) { if (bbt.beats > 1) { bbt.beats--; - } + } + } else if (dir > 0) { if (bbt.ticks > 0) { bbt.beats++; @@ -1243,12 +1248,7 @@ TempoMap::round_to_type (nframes_t frame, int dir, BBTPointType type) } - /* - cerr << "for " << frame << " round to " << bbt << " using " - << metric.start() - << endl; - */ - + DEBUG_TRACE(DEBUG::SnapBBT, string_compose ("\tat %1 count frames from %2 to %3 = %4\n", metric.frame(), metric.start(), bbt, count_frames_between (metric.start(), bbt))); return metric.frame() + count_frames_between (metric.start(), bbt); } @@ -1471,7 +1471,7 @@ TempoMap::tempo_section_at (nframes_t frame) const Tempo& TempoMap::tempo_at (nframes_t frame) const { - Metric m (metric_at (frame)); + TempoMetric m (metric_at (frame)); return m.tempo(); } @@ -1479,7 +1479,7 @@ TempoMap::tempo_at (nframes_t frame) const const Meter& TempoMap::meter_at (nframes_t frame) const { - Metric m (metric_at (frame)); + TempoMetric m (metric_at (frame)); return m.meter(); } diff --git a/libs/ardour/wscript b/libs/ardour/wscript index bb6869b048..5176ac6d00 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -55,6 +55,7 @@ libardour_sources = [ 'automation.cc', 'automation_control.cc', 'automation_list.cc', + 'bbt_time.cc', 'beats_frames_converter.cc', 'broadcast_info.cc', 'buffer.cc', |