mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-20 21:56:30 +01:00
Tempo ramps - use consistent naming for _locked methods, use enum_2_string for TempoSection::Type.
This commit is contained in:
parent
a2495cdff3
commit
f72eef1651
3 changed files with 25 additions and 22 deletions
|
|
@ -403,8 +403,8 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||||
Timecode::BBT_Time beats_to_bbt (double beats);
|
Timecode::BBT_Time beats_to_bbt (double beats);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double bbt_to_beats_unlocked (Timecode::BBT_Time bbt);
|
double bbt_to_beats_locked (Timecode::BBT_Time bbt);
|
||||||
Timecode::BBT_Time beats_to_bbt_unlocked (double beats);
|
Timecode::BBT_Time beats_to_bbt_locked (double beats);
|
||||||
|
|
||||||
friend class ::BBTTest;
|
friend class ::BBTTest;
|
||||||
friend class ::FrameposPlusBeatsTest;
|
friend class ::FrameposPlusBeatsTest;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "ardour/mute_master.h"
|
#include "ardour/mute_master.h"
|
||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "ardour/source.h"
|
#include "ardour/source.h"
|
||||||
|
#include "ardour/tempo.h"
|
||||||
#include "ardour/track.h"
|
#include "ardour/track.h"
|
||||||
#include "ardour/types.h"
|
#include "ardour/types.h"
|
||||||
|
|
||||||
|
|
@ -103,6 +104,7 @@ setup_enum_writer ()
|
||||||
Diskstream::Flag _Diskstream_Flag;
|
Diskstream::Flag _Diskstream_Flag;
|
||||||
Location::Flags _Location_Flags;
|
Location::Flags _Location_Flags;
|
||||||
PositionLockStyle _PositionLockStyle;
|
PositionLockStyle _PositionLockStyle;
|
||||||
|
TempoSection::Type _TempoSection_Type;
|
||||||
Track::FreezeState _Track_FreezeState;
|
Track::FreezeState _Track_FreezeState;
|
||||||
AutomationList::InterpolationStyle _AutomationList_InterpolationStyle;
|
AutomationList::InterpolationStyle _AutomationList_InterpolationStyle;
|
||||||
AnyTime::Type _AnyTime_Type;
|
AnyTime::Type _AnyTime_Type;
|
||||||
|
|
@ -528,6 +530,10 @@ setup_enum_writer ()
|
||||||
REGISTER_CLASS_ENUM (Location, IsSkip);
|
REGISTER_CLASS_ENUM (Location, IsSkip);
|
||||||
REGISTER_BITS (_Location_Flags);
|
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, NoFreeze);
|
||||||
REGISTER_CLASS_ENUM (Track, Frozen);
|
REGISTER_CLASS_ENUM (Track, Frozen);
|
||||||
REGISTER_CLASS_ENUM (Track, UnFrozen);
|
REGISTER_CLASS_ENUM (Track, UnFrozen);
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,11 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <glibmm/threads.h>
|
#include <glibmm/threads.h>
|
||||||
|
|
||||||
|
#include "pbd/enumwriter.h"
|
||||||
#include "pbd/xml++.h"
|
#include "pbd/xml++.h"
|
||||||
#include "evoral/Beats.hpp"
|
#include "evoral/Beats.hpp"
|
||||||
|
|
||||||
#include "ardour/debug.h"
|
#include "ardour/debug.h"
|
||||||
#include "ardour/lmath.h"
|
#include "ardour/lmath.h"
|
||||||
#include "ardour/tempo.h"
|
#include "ardour/tempo.h"
|
||||||
|
|
@ -89,7 +92,7 @@ TempoSection::TempoSection (const XMLNode& node)
|
||||||
set_beat (beat);
|
set_beat (beat);
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if ((prop = node.property ("tempo-type")) == 0) {
|
||||||
_type = Constant;
|
_type = Constant;
|
||||||
} else {
|
} else {
|
||||||
if (strstr(prop->value().c_str(),"Constant")) {
|
_type = Type (string_2_enum (prop->value(), _type));
|
||||||
_type = Constant;
|
|
||||||
} else {
|
|
||||||
_type = Ramp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,9 +167,7 @@ TempoSection::get_state() const
|
||||||
// root->add_property ("bar-offset", buf);
|
// root->add_property ("bar-offset", buf);
|
||||||
snprintf (buf, sizeof (buf), "%s", movable()?"yes":"no");
|
snprintf (buf, sizeof (buf), "%s", movable()?"yes":"no");
|
||||||
root->add_property ("movable", buf);
|
root->add_property ("movable", buf);
|
||||||
|
root->add_property ("tempo-type", enum_2_string (_type));
|
||||||
snprintf (buf, sizeof (buf), "%s", _type == Constant?"Constant":"Ramp");
|
|
||||||
root->add_property ("tempo-type", buf);
|
|
||||||
|
|
||||||
return *root;
|
return *root;
|
||||||
}
|
}
|
||||||
|
|
@ -601,7 +598,7 @@ TempoMap::do_insert (MetricSection* section)
|
||||||
pair<double, BBT_Time> corrected = make_pair (m->beat(), m->bbt());
|
pair<double, BBT_Time> corrected = make_pair (m->beat(), m->bbt());
|
||||||
corrected.second.beats = 1;
|
corrected.second.beats = 1;
|
||||||
corrected.second.ticks = 0;
|
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"),
|
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->bbt(), corrected.second) << endmsg;
|
||||||
m->set_beat (corrected);
|
m->set_beat (corrected);
|
||||||
|
|
@ -838,7 +835,7 @@ TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_T
|
||||||
MeterSection& first (first_meter());
|
MeterSection& first (first_meter());
|
||||||
if (ms.beat() != first.beat()) {
|
if (ms.beat() != first.beat()) {
|
||||||
remove_meter_locked (ms);
|
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 {
|
} else {
|
||||||
/* cannot move the first meter section */
|
/* cannot move the first meter section */
|
||||||
*static_cast<Meter*>(&first) = meter;
|
*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;
|
warning << string_compose (_("tempo map asked for BBT time at frame %1\n"), frame) << endmsg;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bbt = beats_to_bbt_unlocked (beat_at_frame (frame));
|
bbt = beats_to_bbt_locked (beat_at_frame (frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
TempoMap::bbt_to_beats (Timecode::BBT_Time bbt)
|
TempoMap::bbt_to_beats (Timecode::BBT_Time bbt)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
return bbt_to_beats_unlocked (bbt);
|
return bbt_to_beats_locked (bbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
TempoMap::bbt_to_beats_unlocked (Timecode::BBT_Time bbt)
|
TempoMap::bbt_to_beats_locked (Timecode::BBT_Time bbt)
|
||||||
{
|
{
|
||||||
/* CALLER HOLDS READ LOCK */
|
/* CALLER HOLDS READ LOCK */
|
||||||
|
|
||||||
|
|
@ -1222,11 +1219,11 @@ Timecode::BBT_Time
|
||||||
TempoMap::beats_to_bbt (double beats)
|
TempoMap::beats_to_bbt (double beats)
|
||||||
{
|
{
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||||
return beats_to_bbt_unlocked (beats);
|
return beats_to_bbt_locked (beats);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timecode::BBT_Time
|
Timecode::BBT_Time
|
||||||
TempoMap::beats_to_bbt_unlocked (double beats)
|
TempoMap::beats_to_bbt_locked (double beats)
|
||||||
{
|
{
|
||||||
/* CALLER HOLDS READ LOCK */
|
/* CALLER HOLDS READ LOCK */
|
||||||
|
|
||||||
|
|
@ -1393,7 +1390,7 @@ TempoMap::frame_time (const BBT_Time& bbt)
|
||||||
}
|
}
|
||||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
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;
|
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);
|
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) {
|
switch (type) {
|
||||||
case Bar:
|
case Bar:
|
||||||
|
|
@ -1612,7 +1609,7 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
|
||||||
framecnt_t const pos = frame_at_beat (cnt);
|
framecnt_t const pos = frame_at_beat (cnt);
|
||||||
MeterSection const meter = meter_section_at (pos);
|
MeterSection const meter = meter_section_at (pos);
|
||||||
Tempo const tempo = tempo_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));
|
points.push_back (BBTPoint (meter, tempo, pos, bbt.bars, bbt.beats));
|
||||||
++cnt;
|
++cnt;
|
||||||
|
|
@ -1975,7 +1972,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount)
|
||||||
ms->set_beat (start);
|
ms->set_beat (start);
|
||||||
}
|
}
|
||||||
if ((t = dynamic_cast<TempoSection*>(prev)) != 0) {
|
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_beat (start);
|
||||||
}
|
}
|
||||||
ms->set_frame (prev->frame());
|
ms->set_frame (prev->frame());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue