diff options
author | nick_m <mainsbridge@gmail.com> | 2016-02-21 05:26:16 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-05-27 23:38:10 +1000 |
commit | f72eef1651132f642f53446b4440c1696be2bd2c (patch) | |
tree | cfe5113eba02b391c16bf57544ee27dd35348f9f | |
parent | a2495cdff33c152ce1255f9ab9a5ba178db29fef (diff) |
Tempo ramps - use consistent naming for _locked methods, use enum_2_string for TempoSection::Type.
-rw-r--r-- | libs/ardour/ardour/tempo.h | 4 | ||||
-rw-r--r-- | libs/ardour/enums.cc | 6 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 37 |
3 files changed, 25 insertions, 22 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 8712578e54..bc52c48902 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -403,8 +403,8 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible Timecode::BBT_Time beats_to_bbt (double beats); private: - double bbt_to_beats_unlocked (Timecode::BBT_Time bbt); - Timecode::BBT_Time beats_to_bbt_unlocked (double beats); + double bbt_to_beats_locked (Timecode::BBT_Time bbt); + Timecode::BBT_Time beats_to_bbt_locked (double beats); friend class ::BBTTest; friend class ::FrameposPlusBeatsTest; diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index fa83780727..b7e77952cb 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -34,6 +34,7 @@ #include "ardour/mute_master.h" #include "ardour/session.h" #include "ardour/source.h" +#include "ardour/tempo.h" #include "ardour/track.h" #include "ardour/types.h" @@ -103,6 +104,7 @@ setup_enum_writer () Diskstream::Flag _Diskstream_Flag; Location::Flags _Location_Flags; PositionLockStyle _PositionLockStyle; + TempoSection::Type _TempoSection_Type; Track::FreezeState _Track_FreezeState; AutomationList::InterpolationStyle _AutomationList_InterpolationStyle; AnyTime::Type _AnyTime_Type; @@ -528,6 +530,10 @@ setup_enum_writer () REGISTER_CLASS_ENUM (Location, IsSkip); REGISTER_BITS (_Location_Flags); + REGISTER_CLASS_ENUM (TempoSection, Ramp); + REGISTER_CLASS_ENUM (TempoSection, Constant); + REGISTER (_TempoSection_Type); + REGISTER_CLASS_ENUM (Track, NoFreeze); REGISTER_CLASS_ENUM (Track, Frozen); REGISTER_CLASS_ENUM (Track, UnFrozen); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 430e52d77a..08a70c4574 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -24,8 +24,11 @@ #include <unistd.h> #include <glibmm/threads.h> + +#include "pbd/enumwriter.h" #include "pbd/xml++.h" #include "evoral/Beats.hpp" + #include "ardour/debug.h" #include "ardour/lmath.h" #include "ardour/tempo.h" @@ -89,7 +92,7 @@ TempoSection::TempoSection (const XMLNode& node) set_beat (beat); } } else { - error << _("TempoSection XML node has no \"start\" property") << endmsg; + warning << _("TempoSection XML node has no \"start\" property") << endmsg; } @@ -143,11 +146,7 @@ TempoSection::TempoSection (const XMLNode& node) if ((prop = node.property ("tempo-type")) == 0) { _type = Constant; } else { - if (strstr(prop->value().c_str(),"Constant")) { - _type = Constant; - } else { - _type = Ramp; - } + _type = Type (string_2_enum (prop->value(), _type)); } } @@ -168,9 +167,7 @@ TempoSection::get_state() const // root->add_property ("bar-offset", buf); snprintf (buf, sizeof (buf), "%s", movable()?"yes":"no"); root->add_property ("movable", buf); - - snprintf (buf, sizeof (buf), "%s", _type == Constant?"Constant":"Ramp"); - root->add_property ("tempo-type", buf); + root->add_property ("tempo-type", enum_2_string (_type)); return *root; } @@ -601,7 +598,7 @@ TempoMap::do_insert (MetricSection* section) pair<double, BBT_Time> corrected = make_pair (m->beat(), m->bbt()); corrected.second.beats = 1; corrected.second.ticks = 0; - corrected.first = bbt_to_beats_unlocked (corrected.second); + corrected.first = bbt_to_beats_locked (corrected.second); warning << string_compose (_("Meter changes can only be positioned on the first beat of a bar. Moving from %1 to %2"), m->bbt(), corrected.second) << endmsg; m->set_beat (corrected); @@ -838,7 +835,7 @@ TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_T MeterSection& first (first_meter()); if (ms.beat() != first.beat()) { remove_meter_locked (ms); - add_meter_locked (meter, bbt_to_beats_unlocked (where), where, true); + add_meter_locked (meter, bbt_to_beats_locked (where), where, true); } else { /* cannot move the first meter section */ *static_cast<Meter*>(&first) = meter; @@ -1173,18 +1170,18 @@ TempoMap::bbt_time (framepos_t frame, BBT_Time& bbt) warning << string_compose (_("tempo map asked for BBT time at frame %1\n"), frame) << endmsg; return; } - bbt = beats_to_bbt_unlocked (beat_at_frame (frame)); + bbt = beats_to_bbt_locked (beat_at_frame (frame)); } double TempoMap::bbt_to_beats (Timecode::BBT_Time bbt) { Glib::Threads::RWLock::ReaderLock lm (lock); - return bbt_to_beats_unlocked (bbt); + return bbt_to_beats_locked (bbt); } double -TempoMap::bbt_to_beats_unlocked (Timecode::BBT_Time bbt) +TempoMap::bbt_to_beats_locked (Timecode::BBT_Time bbt) { /* CALLER HOLDS READ LOCK */ @@ -1222,11 +1219,11 @@ Timecode::BBT_Time TempoMap::beats_to_bbt (double beats) { Glib::Threads::RWLock::ReaderLock lm (lock); - return beats_to_bbt_unlocked (beats); + return beats_to_bbt_locked (beats); } Timecode::BBT_Time -TempoMap::beats_to_bbt_unlocked (double beats) +TempoMap::beats_to_bbt_locked (double beats) { /* CALLER HOLDS READ LOCK */ @@ -1393,7 +1390,7 @@ TempoMap::frame_time (const BBT_Time& bbt) } Glib::Threads::RWLock::ReaderLock lm (lock); - framepos_t const ret = frame_at_beat (bbt_to_beats_unlocked (bbt)); + framepos_t const ret = frame_at_beat (bbt_to_beats_locked (bbt)); return ret; } @@ -1552,7 +1549,7 @@ TempoMap::round_to_type (framepos_t frame, RoundMode dir, BBTPointType type) double const beat_at_framepos = beat_at_frame (frame); - BBT_Time bbt (beats_to_bbt_unlocked (beat_at_framepos)); + BBT_Time bbt (beats_to_bbt_locked (beat_at_framepos)); switch (type) { case Bar: @@ -1612,7 +1609,7 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points, framecnt_t const pos = frame_at_beat (cnt); MeterSection const meter = meter_section_at (pos); Tempo const tempo = tempo_at (pos); - BBT_Time const bbt = beats_to_bbt_unlocked ((double) cnt); + BBT_Time const bbt = beats_to_bbt_locked ((double) cnt); points.push_back (BBTPoint (meter, tempo, pos, bbt.bars, bbt.beats)); ++cnt; @@ -1975,7 +1972,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount) ms->set_beat (start); } if ((t = dynamic_cast<TempoSection*>(prev)) != 0) { - pair<double, BBT_Time> start = make_pair (t->beat(), beats_to_bbt_unlocked (t->beat())); + pair<double, BBT_Time> start = make_pair (t->beat(), beats_to_bbt_locked (t->beat())); ms->set_beat (start); } ms->set_frame (prev->frame()); |