/* length = 1 bar */
- /* now we want frames per beat.
+ /* We're going to deliver a constant tempo here,
+ so we can use frames per beat to determine length.
+ now we want frames per beat.
we have frames per bar, and beats per bar, so ...
*/
} else {
Timecode::BBT_Time bbt;
_session->tempo_map().bbt_time (start, bbt);
- _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), bbt, TempoSection::TempoSectionType::Ramp);
+ _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), bbt, TempoSection::Type::Constant);
}
XMLNode& after (_session->tempo_map().get_state());
strings.clear();
- tempo_types.insert (make_pair (_("ramped"), TempoSection::TempoSectionType::Ramp));
+ tempo_types.insert (make_pair (_("ramped"), TempoSection::Type::Ramp));
strings.push_back (_("ramped"));
- tempo_types.insert (make_pair (_("constant"), TempoSection::TempoSectionType::Constant));
+ tempo_types.insert (make_pair (_("constant"), TempoSection::Type::Constant));
strings.push_back (_("constant"));
set_popdown_strings (tempo_type, strings);
tempo_type.set_active_text (strings[0]); // "ramped"
return x->second;
}
-TempoSection::TempoSectionType
+TempoSection::Type
TempoDialog::get_tempo_type ()
{
TempoTypes::iterator x = tempo_types.find (tempo_type.get_active_text());
if (x == tempo_types.end()) {
error << string_compose(_("incomprehensible pulse note type (%1)"), tempo_type.get_active_text()) << endmsg;
- return TempoSection::TempoSectionType::Constant;
+ return TempoSection::Type::Constant;
}
return x->second;
double get_bpm ();
double get_note_type ();
bool get_bbt_time (Timecode::BBT_Time&);
- ARDOUR::TempoSection::TempoSectionType get_tempo_type ();
+ ARDOUR::TempoSection::Type get_tempo_type ();
private:
void init (const Timecode::BBT_Time& start, double, double, bool);
typedef std::map<std::string,float> NoteTypes;
NoteTypes note_types;
- typedef std::map<std::string, ARDOUR::TempoSection::TempoSectionType> TempoTypes;
+ typedef std::map<std::string, ARDOUR::TempoSection::Type> TempoTypes;
TempoTypes tempo_types;
bool tapped; // whether the tap-tempo button has been clicked
/** A section of timeline with a certain Tempo. */
class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
public:
- enum TempoSectionType {
+ enum Type {
Ramp,
Constant,
};
- TempoSection (const Timecode::BBT_Time& start, double qpm, double note_type, TempoSectionType tempo_type)
+ TempoSection (const Timecode::BBT_Time& start, double qpm, double note_type, Type tempo_type)
: MetricSection (start), Tempo (qpm, note_type), _bar_offset (-1.0), _type (tempo_type) {}
- TempoSection (framepos_t start, double qpm, double note_type, TempoSectionType tempo_type)
+ TempoSection (framepos_t start, double qpm, double note_type, Type tempo_type)
: MetricSection (start), Tempo (qpm, note_type), _bar_offset (-1.0), _type (tempo_type) {}
TempoSection (const XMLNode&);
void update_bbt_time_from_bar_offset (const Meter&);
double bar_offset() const { return _bar_offset; }
- void set_type (TempoSectionType type);
- TempoSectionType type () const { return _type; }
+ void set_type (Type type);
+ Type type () const { return _type; }
double tempo_at_frame (framepos_t frame, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const;
framepos_t frame_at_tempo (double tempo, double end_bpm, framepos_t end_frame, framecnt_t frame_rate) const;
position within the bar if/when the meter changes.
*/
double _bar_offset;
- TempoSectionType _type;
+ Type _type;
};
typedef std::list<MetricSection*> Metrics;
TempoSection* tempo_section_after (framepos_t) const;
const MeterSection& meter_section_at (framepos_t) const;
- void add_tempo (const Tempo&, Timecode::BBT_Time where, TempoSection::TempoSectionType type);
+ void add_tempo (const Tempo&, Timecode::BBT_Time where, TempoSection::Type type);
void add_meter (const Meter&, Timecode::BBT_Time where);
void remove_tempo (const TempoSection&, bool send_signal);
void remove_meter (const MeterSection&, bool send_signal);
- void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where, TempoSection::TempoSectionType type);
+ void replace_tempo (const TempoSection&, const Tempo&, const Timecode::BBT_Time& where, TempoSection::Type type);
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
framepos_t round_to_bar (framepos_t frame, RoundMode dir);
void do_insert (MetricSection* section);
- void add_tempo_locked (const Tempo&, Timecode::BBT_Time where, bool recompute, TempoSection::TempoSectionType type);
+ void add_tempo_locked (const Tempo&, Timecode::BBT_Time where, bool recompute, TempoSection::Type type);
void add_meter_locked (const Meter&, Timecode::BBT_Time where, bool recompute);
bool remove_tempo_locked (const TempoSection&);
*outDeltaSampleOffsetToNextBeat = 0;
} else {
*outDeltaSampleOffsetToNextBeat = (UInt32)
- double beat_frac_to_next = (Timecode::BBT_Time::ticks_per_beat - bbt.ticks) / Timecode::BBT_Time::ticks_per_beat ;
+ double const beat_frac_to_next = (Timecode::BBT_Time::ticks_per_beat - bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
tmap.frame_at_beat (tmap.beat_at_frame (_session.transport_frame() + input_offset) + beat_frac_to_next);
}
}
MIDIClock_Slave::calculate_one_ppqn_in_frames_at(framepos_t time)
{
const Tempo& current_tempo = session->tempo_map().tempo_at(time);
- double frames_per_beat = session->tempo_map().frames_per_beat_at (time, session->frame_rate());
+ double const frames_per_beat = session->tempo_map().frames_per_beat_at (time, session->frame_rate());
double quarter_notes_per_beat = 4.0 / current_tempo.note_type();
double frames_per_quarter_note = frames_per_beat / quarter_notes_per_beat;
}
if ((prop = node.property ("tempo-type")) == 0) {
- _type = TempoSectionType::Constant;
+ _type = Type::Constant;
} else {
if (strstr(prop->value().c_str(),"Constant")) {
- _type = TempoSectionType::Constant;
+ _type = Type::Constant;
} else {
- _type = TempoSectionType::Ramp;
+ _type = Type::Ramp;
}
}
}
}
void
-TempoSection::set_type (TempoSectionType type)
+TempoSection::set_type (Type type)
{
_type = type;
}
start.beats = 1;
start.ticks = 0;
- TempoSection *t = new TempoSection (start, _default_tempo.beats_per_minute(), _default_tempo.note_type(), TempoSection::TempoSectionType::Ramp);
+ TempoSection *t = new TempoSection (start, _default_tempo.beats_per_minute(), _default_tempo.note_type(), TempoSection::Type::Ramp);
MeterSection *m = new MeterSection (start, _default_meter.divisions_per_bar(), _default_meter.note_divisor());
t->set_movable (false);
}
void
-TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const BBT_Time& where, TempoSection::TempoSectionType type)
+TempoMap::replace_tempo (const TempoSection& ts, const Tempo& tempo, const BBT_Time& where, TempoSection::Type type)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
}
void
-TempoMap::add_tempo (const Tempo& tempo, BBT_Time where, ARDOUR::TempoSection::TempoSectionType type)
+TempoMap::add_tempo (const Tempo& tempo, BBT_Time where, ARDOUR::TempoSection::Type type)
{
{
Glib::Threads::RWLock::WriterLock lm (lock);
}
void
-TempoMap::add_tempo_locked (const Tempo& tempo, BBT_Time where, bool recompute, ARDOUR::TempoSection::TempoSectionType type)
+TempoMap::add_tempo_locked (const Tempo& tempo, BBT_Time where, bool recompute, ARDOUR::TempoSection::Type type)
{
/* new tempos always start on a beat */
where.ticks = 0;
double ticks_relative_to_prev_ts = ticks_at_ts - ticks_at_prev_ts;
/* assume (falsely) that the target tempo is constant */
double length_estimate = (ticks_relative_to_prev_ts / BBT_Time::ticks_per_beat) * meter->frames_per_grid (*t, _frame_rate);
- if (prev_ts->type() == TempoSection::TempoSectionType::Constant) {
+ if (prev_ts->type() == TempoSection::Type::Constant) {
cerr << "constant type " << endl;
length_estimate = (ticks_relative_to_prev_ts / BBT_Time::ticks_per_beat) * prev_ts->frames_per_beat (_frame_rate);
}
Meter meter (4, 4);
map.add_meter (meter, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
/* Subtract 1 beat from beat 3 of the first bar */
framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, Beats(1));
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
/* Now some tests */
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
Meter meterB (3, 4);
map.add_meter (meterB, BBT_Time (4, 1, 0));
Meter meter (4, 4);
map.add_meter (meter, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
/* Add 1 beat to beat 3 of the first bar */
framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1));
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
/* Now some tests */
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
Meter meterB (3, 4);
map.add_meter (meterB, BBT_Time (4, 1, 0));
Meter meter (4, 4);
map.add_meter (meter, BBT_Time (1, 1, 0));
- map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempo, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
/* Walk 1 beats-worth of frames from beat 3 */
double r = map.framewalk_to_beats (frames_per_beat * 2, frames_per_beat * 1).to_double();
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
/* Now some tests */
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (2, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (2, 1, 0), TempoSection::Type::Constant);
Tempo tempoC (160);
- map.add_tempo (tempoC, BBT_Time (3, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoC, BBT_Time (3, 1, 0), TempoSection::Type::Constant);
/* Walk from 1|3 to 4|1 */
double r = map.framewalk_to_beats (2 * 24e3, (2 * 24e3) + (4 * 12e3) + (4 * 18e3)).to_double();
meter (4.0, 4.0)
{
_tempo_map = new TempoMap (FRAME_RATE);
- _tempo_map->add_tempo (tempo, Timecode::BBT_Time(1, 1, 0), TempoSection::TempoSectionType::Constant);
+ _tempo_map->add_tempo (tempo, Timecode::BBT_Time(1, 1, 0), TempoSection::Type::Constant);
_tempo_map->add_meter (meter, Timecode::BBT_Time(1, 1, 0));
}
*/
Tempo tempoA (120);
- map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoA, BBT_Time (1, 1, 0), TempoSection::Type::Constant);
Tempo tempoB (240);
- map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::TempoSectionType::Constant);
+ map.add_tempo (tempoB, BBT_Time (4, 1, 0), TempoSection::Type::Constant);
Meter meterB (3, 4);
map.add_meter (meterB, BBT_Time (4, 1, 0));