BBTRulerDrag::BBTRulerDrag (Editor* e, ArdourCanvas::Item* i)
: Drag (e, i)
- , _pulse (0.0)
+ , _grab_qn (0.0)
, _tempo (0)
, before_state (0)
{
beat = floor (beat_at_frame) + (floor (((beat_at_frame - floor (beat_at_frame)) * 4)) / 4);
}
- _pulse = map.pulse_at_beat (beat);
+ _grab_qn = map.quarter_note_at_beat (beat);
- _pointer_frame_offset = raw_grab_frame() - map.frame_at_pulse (_pulse);
+ _pointer_frame_offset = raw_grab_frame() - map.frame_at_quarter_note (_grab_qn);
}
if (ArdourKeyboard::indicates_constraint (event->button.state)) {
/* adjust previous tempo to match pointer frame */
- _editor->session()->tempo_map().gui_dilate_tempo (_tempo, map.frame_at_pulse (_pulse), pf, _pulse);
+ _editor->session()->tempo_map().gui_dilate_tempo (_tempo, map.frame_at_quarter_note (_grab_qn), pf);
}
ostringstream sstr;
sstr << "^" << fixed << setprecision(3) << map.tempo_at_frame (pf).beats_per_minute() << "\n";
void setup_pointer_frame_offset ();
private:
- double _pulse;
+ double _grab_qn;
ARDOUR::TempoSection* _tempo;
XMLNode* before_state;
};
const Meter& meter_at_frame (framepos_t) const;
- double pulse_at_beat (const double& beat) const;
- double beat_at_pulse (const double& pulse) const;
-
- double pulse_at_frame (const framecnt_t& frame) const;
- framepos_t frame_at_pulse (const double& pulse) const;
-
/* bbt - it's nearly always better to use beats.*/
Timecode::BBT_Time bbt_at_frame (framepos_t when);
Timecode::BBT_Time bbt_at_frame_rt (framepos_t when);
double beat_at_bbt (const Timecode::BBT_Time& bbt);
Timecode::BBT_Time bbt_at_beat (const double& beats);
- double pulse_at_bbt (const Timecode::BBT_Time& bbt);
- double pulse_at_bbt_rt (const Timecode::BBT_Time& bbt);
- Timecode::BBT_Time bbt_at_pulse (const double& pulse);
+ double quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt);
framecnt_t bbt_duration_at (framepos_t, const Timecode::BBT_Time&, int dir);
double quarter_note_at_frame (const framepos_t frame);
double quarter_note_at_frame_rt (const framepos_t frame);
framepos_t frame_at_quarter_note (const double quarter_note);
+
double quarter_note_at_beat (const double beat);
double beat_at_quarter_note (const double beat);
void gui_move_tempo (TempoSection*, const framepos_t& frame, const int& sub_num);
void gui_move_meter (MeterSection*, const framepos_t& frame);
bool gui_change_tempo (TempoSection*, const Tempo& bpm);
- void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame, const double& pulse);
+ void gui_dilate_tempo (TempoSection* tempo, const framepos_t& frame, const framepos_t& end_frame);
double exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num);
double exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num);
} else {
tmetric.set_metric(metric);
Timecode::BBT_Time bbt;
- bbt = tmap.bbt_at_pulse (metric->pulse());
+ bbt = tmap.bbt_at_frame (metric->frame());
double bpm = tmap.tempo_at_frame (start/*XXX*/).beats_per_minute();
write_position(&_impl->forge, _ev_buffers[port_index],
tmetric, bbt, speed, bpm,
bbt.beats = 1;
bbt.ticks = 0;
/* exact quarter note */
- double ppqBar = session->tempo_map().pulse_at_bbt_rt (bbt) * 4.0;
+ double ppqBar = session->tempo_map().quarter_note_at_bbt_rt (bbt);
/* quarter note at frame position (not rounded to note subdivision) */
double ppqPos = session->tempo_map().quarter_note_at_frame_rt (now);
if (value & (kVstPpqPosValid)) {
return prev_t->minute_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse());
}
-/** Returns a Tempo corresponding to the supplied frame.
+/** Returns a Tempo corresponding to the supplied frame position.
* @param frame The audio frame.
* @return a Tempo according to the tempo map at the supplied frame.
*
/** Returns a Tempo corresponding to the supplied BBT (meter-based) beat.
* @param beat The BBT (meter-based) beat.
+ * @return the Tempo at the supplied BBT (meter-based) beat.
*/
Tempo
TempoMap::tempo_at_beat (const double& beat) const
/** Returns a BBT (meter-based) beat corresponding to the supplied Tempo.
* @param tempo The tempo.
+ * @return the BBT (meter-based) beat at the supplied Tempo.
*/
double
TempoMap::beat_at_tempo (const Tempo& tempo) const
return beat_at_pulse_locked (_metrics, pulse);
}
+
/** Returns the whole-note pulse corresponding to the supplied BBT (meter-based) beat.
+ * @param metrics the list of metric sections used to calculate the pulse.
* @param beat The BBT (meter-based) beat.
+ * @return the whole-note pulse at the supplied BBT (meter-based) beat.
*
* a pulse or whole note is the base musical position of a MetricSection.
* it is equivalent to four quarter notes.
*
*/
-double
-TempoMap::pulse_at_beat (const double& beat) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return pulse_at_beat_locked (_metrics, beat);
-}
-
double
TempoMap::pulse_at_beat_locked (const Metrics& metrics, const double& beat) const
{
}
/** Returns the BBT (meter-based) beat corresponding to the supplied whole-note pulse .
+ * @param metrics the list of metric sections used to calculate the beat.
* @param pulse the whole-note pulse.
+ * @return the meter-based beat at the supplied whole-note pulse.
*
* a pulse or whole note is the base musical position of a MetricSection.
* it is equivalent to four quarter notes.
*/
-double
-TempoMap::beat_at_pulse (const double& pulse) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return beat_at_pulse_locked (_metrics, pulse);
-}
-
double
TempoMap::beat_at_pulse_locked (const Metrics& metrics, const double& pulse) const
{
return ret;
}
-double
-TempoMap::pulse_at_frame (const framepos_t& frame) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
- return pulse_at_minute_locked (_metrics, minute_at_frame (frame));
-}
-
/* tempo section based */
double
TempoMap::pulse_at_minute_locked (const Metrics& metrics, const double& minute) const
return pulses_in_section + prev_t->pulse();
}
-framepos_t
-TempoMap::frame_at_pulse (const double& pulse) const
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return frame_at_minute (minute_at_pulse_locked (_metrics, pulse));
-}
-
/* tempo section based */
double
TempoMap::minute_at_pulse_locked (const Metrics& metrics, const double& pulse) const
/** Returns the BBT (meter-based) beat corresponding to the supplied BBT time.
* @param bbt The BBT time (meter-based).
+ * @return bbt The BBT beat (meter-based) at the supplied BBT time.
*
*/
double
/** Returns the BBT time corresponding to the supplied BBT (meter-based) beat.
* @param beat The BBT (meter-based) beat.
+ * @return The BBT time (meter-based) at the supplied meter-based beat.
*
*/
Timecode::BBT_Time
return ret;
}
-/** Returns the whole-note pulse corresponding to the supplied BBT time (meter-based).
+/** Returns the quarter-note beat corresponding to the supplied BBT time (meter-based).
* @param bbt The BBT time (meter-based).
+ * @return the quarter note beat at the supplied BBT time
+ *
+ * quarter-notes ignore meter and are based on pulse (the musical unit of MetricSection).
*
- * a pulse or whole note is the basic musical position of a MetricSection.
- * it is equivalent to four quarter notes.
* while the input uses meter, the output does not.
*/
double
-TempoMap::pulse_at_bbt (const Timecode::BBT_Time& bbt)
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return pulse_at_bbt_locked (_metrics, bbt);
-}
-
-double
-TempoMap::pulse_at_bbt_rt (const Timecode::BBT_Time& bbt)
+TempoMap::quarter_note_at_bbt_rt (const Timecode::BBT_Time& bbt)
{
Glib::Threads::RWLock::ReaderLock lm (lock);
if (!lm.locked()) {
- throw std::logic_error ("TempoMap::pulse_at_bbt_rt() could not lock tempo map");
+ throw std::logic_error ("TempoMap::quarter_note_at_bbt_rt() could not lock tempo map");
}
- return pulse_at_bbt_locked (_metrics, bbt);
+ return pulse_at_bbt_locked (_metrics, bbt) * 4.0;
}
double
return ret;
}
-/** Returns the BBT time (meter-based) corresponding to the supplied whole-note pulse.
+
+/** Returns the BBT time (meter-based) corresponding to the supplied whole-note pulse position.
+ * @param metrics The list of metric sections used to determine the result.
* @param pulse The whole-note pulse.
+ * @return The BBT time at the supplied whole-note pulse.
*
* a pulse or whole note is the basic musical position of a MetricSection.
* it is equivalent to four quarter notes.
- * while the input uses meter, the output does not.
+ * while the output uses meter, the input does not.
*/
-Timecode::BBT_Time
-TempoMap::bbt_at_pulse (const double& pulse)
-{
- Glib::Threads::RWLock::ReaderLock lm (lock);
-
- return bbt_at_pulse_locked (_metrics, pulse);
-}
-
Timecode::BBT_Time
TempoMap::bbt_at_pulse_locked (const Metrics& metrics, const double& pulse) const
{
}
void
-TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const framepos_t& end_frame, const double& pulse)
+TempoMap::gui_dilate_tempo (TempoSection* ts, const framepos_t& frame, const framepos_t& end_frame)
{
/*
Ts (future prev_t) Tnext
| |
| [drag^] |
|----------|----------
- e_f pulse(frame)
+ e_f qn_beats(frame)
*/
Metrics future_map;
double frame_ratio = 1.0;
double pulse_ratio = 1.0;
- const double pulse_pos = prev_t->frame_at_pulse (pulse);
+ const double pulse_pos = frame;
if (prev_to_prev_t) {
if (pulse_pos > prev_to_prev_t->frame() + min_dframe && (pulse_pos - fr_off) > prev_to_prev_t->frame() + min_dframe) {
/* pulse */
/* pulse - frame*/
- CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), map.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (144e3), map.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (96e3), map.frame_at_pulse (1.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (288e3), map.frame_at_quarter_note (12.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (144e3), map.frame_at_quarter_note (6.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (96e3), map.frame_at_quarter_note (4.0));
/* frame - pulse*/
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, map.pulse_at_frame (288e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, map.pulse_at_frame (144e3), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, map.pulse_at_frame (96e3), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_frame (288e3), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarter_note_at_frame (144e3), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarter_note_at_frame (96e3), 1e-17);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
/* pulse */
/* pulse - frame*/
- CPPUNIT_ASSERT_EQUAL (framepos_t (264600), map.frame_at_pulse (3.0));
- CPPUNIT_ASSERT_EQUAL (framepos_t (132300), map.frame_at_pulse (1.5));
- CPPUNIT_ASSERT_EQUAL (framepos_t (88200), map.frame_at_pulse (1.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (264600), map.frame_at_quarter_note (12.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (132300), map.frame_at_quarter_note (6.0));
+ CPPUNIT_ASSERT_EQUAL (framepos_t (88200), map.frame_at_quarter_note (4.0));
/* frame - pulse*/
- CPPUNIT_ASSERT_DOUBLES_EQUAL (3.0, map.pulse_at_frame (264600), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.5, map.pulse_at_frame (132300), 1e-17);
- CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, map.pulse_at_frame (88200), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, map.quarter_note_at_frame (264600), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (6.0, map.quarter_note_at_frame (132300), 1e-17);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL (4.0, map.quarter_note_at_frame (88200), 1e-17);
/* pulse - internal minute based interface */
CPPUNIT_ASSERT_DOUBLES_EQUAL (0.1, map.minute_at_pulse_locked (map._metrics, 3.0), 1e-17);
TempoMap& map (source->session().tempo_map());
for (Evoral::Sequence<MidiModel::TimeType>::const_iterator i = bbt_source->model()->begin(MidiModel::TimeType(), true); i != bbt_source->model()->end(); ++i) {
- const double new_time = map.quarter_note_at_beat ((*i).time().to_double() + map.beat_at_pulse (session_offset)) - (session_offset * 4.0);
+ const double new_time = map.quarter_note_at_beat ((*i).time().to_double() + map.beat_at_quarter_note (session_offset * 4.0)) - (session_offset * 4.0);
Evoral::Event<Evoral::Beats> new_ev (*i, true);
new_ev.set_time (Evoral::Beats (new_time));
source->append_event_beats (source_lock, new_ev);
{
/* set start_beats to quarter note value from incorrect bbt*/
TempoMap& tmap (session->tempo_map());
- double new_start_qn = (tmap.pulse_at_beat (region->beat()) - tmap.pulse_at_beat (region->beat() - region->start_beats())) * 4.0;
+ double new_start_qn = tmap.quarter_note_at_beat (region->beat()) - tmap.quarter_note_at_beat (region->beat() - region->start_beats());
/* force a change to start and start_beats */
PositionLockStyle old_pls = region->position_lock_style();
{
/* set length_beats to quarter note value */
TempoMap& tmap (session->tempo_map());
- double new_length_qn = (tmap.pulse_at_beat (region->beat() + region->length_beats())
- - tmap.pulse_at_beat (region->beat())) * 4.0;
+ double new_length_qn = tmap.quarter_note_at_beat (region->beat() + region->length_beats())
+ - tmap.quarter_note_at_beat (region->beat());
/* force a change to length and length_beats */
PositionLockStyle old_pls = region->position_lock_style();