13
0

Fix the tempo note-type hallucination.

- after reports that a tempo with non-4.0 note type
	  would produce a ramp in the preceding section, an incorrect
	  assumption was made leading to a bogus 'fix' that redefined
	  Tempo's pulses_per_minute().
	  the real fix was simple:
	  the ramp's function constant was calculated using the note type
	  of the proceding tempo rather than the current one.

	- this patch reverts e82482e8e9 and a4d67279e0
	  and maintains the old definition of Tempo::pulses_per_minute()
This commit is contained in:
nick_m 2016-09-05 16:28:46 +10:00
parent dd7c0cca6c
commit 74a604d261
3 changed files with 24 additions and 24 deletions

View File

@ -121,7 +121,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
points->push_back (ArdourCanvas::Duple (0.0, curve_height));
if (end_frame == UINT32_MAX) {
const double tempo_at = _tempo.tempo_at_frame (frame, editor.session()->frame_rate()) * 4.0;
const double tempo_at = _tempo.tempo_at_frame (frame, editor.session()->frame_rate()) * _tempo.note_type();
const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
points->push_back (ArdourCanvas::Duple (0.0, y_pos));
@ -133,7 +133,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
framepos_t current_frame = frame;
while (current_frame < (end_frame - frame_step)) {
const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate()) * 4.0;
const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate()) * _tempo.note_type();
const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (current_frame - frame), min (y_pos, curve_height)));
@ -141,7 +141,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
current_frame += frame_step;
}
const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate()) * 4.0;
const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate()) * _tempo.note_type();
const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel ((end_frame - 1) - frame), min (y_pos, curve_height)));

View File

@ -62,7 +62,7 @@ class LIBARDOUR_API Tempo {
double beats_per_minute () const { return _beats_per_minute; }
void set_beats_per_minute (double bpm) { _beats_per_minute = bpm; }
double note_type () const { return _note_type; }
double pulses_per_minute () const { return _beats_per_minute / 4.0; }
double pulses_per_minute () const { return _beats_per_minute / _note_type; }
/** audio samples per beat
* @param sr samplerate
*/

View File

@ -231,7 +231,7 @@ TempoSection::frame_at_tempo (const double& ppm, const double& p, const framecnt
return minute_to_frame (time_at_pulse_tempo (ppm), frame_rate) + frame();
}
/** returns the tempo in pulses per minute at the zero-based (relative to session) beat.
/** returns the tempo in whole pulses per minute at the zero-based (relative to session) beat.
*/
double
TempoSection::tempo_at_pulse (const double& p) const
@ -420,14 +420,14 @@ TempoSection::time_at_pulse_tempo (const double& pulse_tempo) const
return log (pulse_tempo / pulses_per_minute()) / _c_func;
}
/* tick at tempo in ppm */
/* pulse at tempo in ppm */
double
TempoSection::pulse_at_pulse_tempo (const double& pulse_tempo) const
{
return (pulse_tempo - pulses_per_minute()) / _c_func;
}
/* tempo in ppm at tick */
/* tempo in ppm at pulse */
double
TempoSection::pulse_tempo_at_pulse (const double& pulse) const
{
@ -1269,14 +1269,14 @@ TempoMap::recompute_tempi (Metrics& metrics)
}
if (prev_t) {
if (t->position_lock_style() == AudioTime) {
prev_t->set_c_func (prev_t->compute_c_func_frame (t->pulses_per_minute(), t->frame(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_frame (t->beats_per_minute() / prev_t->note_type(), t->frame(), _frame_rate));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_tempo (t->pulses_per_minute(), t->frame(), _frame_rate));
t->set_pulse (prev_t->pulse_at_tempo (t->beats_per_minute() / prev_t->note_type(), t->frame(), _frame_rate));
}
} else {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->pulses_per_minute(), t->pulse(), _frame_rate));
t->set_frame (prev_t->frame_at_tempo (t->pulses_per_minute(), t->pulse(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->beats_per_minute() / prev_t->note_type(), t->pulse(), _frame_rate));
t->set_frame (prev_t->frame_at_tempo (t->beats_per_minute() / prev_t->note_type(), t->pulse(), _frame_rate));
}
}
@ -1559,7 +1559,7 @@ TempoMap::tempo_at_frame_locked (const Metrics& metrics, const framepos_t& frame
}
if ((prev_t) && t->frame() > frame) {
/* t is the section past frame */
const double ret_bpm = prev_t->tempo_at_frame (frame, _frame_rate) * 4.0;
const double ret_bpm = prev_t->tempo_at_frame (frame, _frame_rate) * prev_t->note_type();
const Tempo ret_tempo (ret_bpm, prev_t->note_type());
return ret_tempo;
}
@ -1590,7 +1590,7 @@ framepos_t
TempoMap::frame_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) const
{
TempoSection* prev_t = 0;
const double tempo_ppm = tempo.beats_per_minute() / 4.0;
const double tempo_ppm = tempo.beats_per_minute() / tempo.note_type();
Metrics::const_iterator i;
@ -1603,14 +1603,14 @@ TempoMap::frame_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) con
continue;
}
const double t_ppm = t->beats_per_minute() / 4.0;
const double t_ppm = t->beats_per_minute() / t->note_type();
if (t_ppm == tempo_ppm) {
return t->frame();
}
if (prev_t) {
const double prev_t_ppm = prev_t->beats_per_minute() / 4.0;
const double prev_t_ppm = prev_t->beats_per_minute() / prev_t->note_type();
if ((t_ppm > tempo_ppm && prev_t_ppm < tempo_ppm) || (t_ppm < tempo_ppm && prev_t_ppm > tempo_ppm)) {
return prev_t->frame_at_tempo (tempo_ppm, prev_t->pulse(), _frame_rate);
@ -1634,7 +1634,7 @@ TempoMap::tempo_at_beat (const double& beat) const
const TempoSection* prev_t = &tempo_section_at_beat_locked (_metrics, beat);
const double note_type = prev_t->note_type();
return Tempo (prev_t->tempo_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse()) * 4.0, note_type);
return Tempo (prev_t->tempo_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse()) * note_type, note_type);
}
double
@ -2208,7 +2208,7 @@ TempoMap::check_solved (const Metrics& metrics) const
}
/* precision check ensures tempo and frames align.*/
if (t->frame() != prev_t->frame_at_tempo (t->pulses_per_minute(), t->pulse(), _frame_rate)) {
if (t->frame() != prev_t->frame_at_tempo (t->beats_per_minute() / prev_t->note_type(), t->pulse(), _frame_rate)) {
if (!t->locked_to_meter()) {
return false;
}
@ -2318,10 +2318,10 @@ TempoMap::solve_map_frame (Metrics& imaginary, TempoSection* section, const fram
continue;
}
if (t->position_lock_style() == MusicTime) {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->pulses_per_minute(), t->pulse(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->beats_per_minute() / prev_t->note_type(), t->pulse(), _frame_rate));
t->set_frame (prev_t->frame_at_pulse (t->pulse(), _frame_rate));
} else {
prev_t->set_c_func (prev_t->compute_c_func_frame (t->pulses_per_minute(), t->frame(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_frame (t->beats_per_minute() / prev_t->note_type(), t->frame(), _frame_rate));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_frame (t->frame(), _frame_rate));
}
@ -2332,7 +2332,7 @@ TempoMap::solve_map_frame (Metrics& imaginary, TempoSection* section, const fram
}
if (section_prev) {
section_prev->set_c_func (section_prev->compute_c_func_frame (section->pulses_per_minute(), frame, _frame_rate));
section_prev->set_c_func (section_prev->compute_c_func_frame (section->beats_per_minute() / section_prev->note_type(), frame, _frame_rate));
if (!section->locked_to_meter()) {
section->set_pulse (section_prev->pulse_at_frame (frame, _frame_rate));
}
@ -2386,10 +2386,10 @@ TempoMap::solve_map_pulse (Metrics& imaginary, TempoSection* section, const doub
continue;
}
if (t->position_lock_style() == MusicTime) {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->pulses_per_minute(), t->pulse(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->beats_per_minute() / prev_t->note_type(), t->pulse(), _frame_rate));
t->set_frame (prev_t->frame_at_pulse (t->pulse(), _frame_rate));
} else {
prev_t->set_c_func (prev_t->compute_c_func_frame (t->pulses_per_minute(), t->frame(), _frame_rate));
prev_t->set_c_func (prev_t->compute_c_func_frame (t->beats_per_minute() / prev_t->note_type(), t->frame(), _frame_rate));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_frame (t->frame(), _frame_rate));
}
@ -2400,7 +2400,7 @@ TempoMap::solve_map_pulse (Metrics& imaginary, TempoSection* section, const doub
}
if (section_prev) {
section_prev->set_c_func (section_prev->compute_c_func_pulse (section->pulses_per_minute(), pulse, _frame_rate));
section_prev->set_c_func (section_prev->compute_c_func_pulse (section->beats_per_minute() / section_prev->note_type(), pulse, _frame_rate));
section->set_frame (section_prev->frame_at_pulse (pulse, _frame_rate));
}
@ -3571,7 +3571,7 @@ TempoMap::frames_per_beat_at (const framepos_t& frame, const framecnt_t& sr) con
}
if (ts_after) {
return (60.0 * _frame_rate) / (ts_at->tempo_at_frame (frame, _frame_rate) * 4.0);
return (60.0 * _frame_rate) / (ts_at->tempo_at_frame (frame, _frame_rate) * ts_at->note_type());
}
/* must be treated as constant tempo */
return ts_at->frames_per_beat (_frame_rate);