rename TempoSection::c_func() -> c(). ensure constant tempi have this set to 0.

This commit is contained in:
nick_m 2017-01-07 01:27:06 +11:00
parent 4cb0090583
commit d855ad2856
4 changed files with 40 additions and 40 deletions

View File

@ -120,7 +120,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
points->push_back (ArdourCanvas::Duple (0.0, y_pos));
points->push_back (ArdourCanvas::Duple (1.0, y_pos));
} else if (_tempo.type() == ARDOUR::TempoSection::Constant || _tempo.c_func() == 0.0) {
} else if (_tempo.type() == ARDOUR::TempoSection::Constant || _tempo.c() == 0.0) {
const double tempo_at = _tempo.note_types_per_minute();
const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);

View File

@ -190,7 +190,7 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
};
TempoSection (const double& pulse, const double& minute, double qpm, double note_type, Type tempo_type, PositionLockStyle pls, framecnt_t sr)
: MetricSection (pulse, minute, pls, true, sr), Tempo (qpm, note_type), _type (tempo_type), _c_func (0.0), _active (true), _locked_to_meter (false) {}
: MetricSection (pulse, minute, pls, true, sr), Tempo (qpm, note_type), _type (tempo_type), _c (0.0), _active (true), _locked_to_meter (false) {}
TempoSection (const XMLNode&, const framecnt_t sample_rate);
@ -198,8 +198,8 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
XMLNode& get_state() const;
double c_func () const { return _c_func; }
void set_c_func (double c_func) { _c_func = c_func; }
double c () const { return _c; }
void set_c (double c) { _c = c; }
void set_type (Type type);
Type type () const { return _type; }
@ -254,7 +254,7 @@ class LIBARDOUR_API TempoSection : public MetricSection, public Tempo {
position within the bar if/when the meter changes.
*/
Type _type;
double _c_func;
double _c;
bool _active;
bool _locked_to_meter;
Timecode::BBT_Time _legacy_bbt;

View File

@ -1471,7 +1471,7 @@ LuaBindings::common (lua_State* L)
.endClass ()
.deriveClass <TempoSection, MetricSection> ("TempoSection")
.addFunction ("c_func", (double(TempoSection::*)()const)&TempoSection::c_func)
.addFunction ("c", (double(TempoSection::*)()const)&TempoSection::c)
.endClass ()
.deriveClass <MeterSection, MetricSection> ("MeterSection")

View File

@ -87,7 +87,7 @@ const string TempoSection::xml_state_node_name = "Tempo";
TempoSection::TempoSection (const XMLNode& node, framecnt_t sample_rate)
: MetricSection (0.0, 0, MusicTime, true, sample_rate)
, Tempo (TempoMap::default_tempo())
, _c_func (0.0)
, _c (0.0)
, _active (true)
, _locked_to_meter (false)
{
@ -220,7 +220,7 @@ TempoSection::set_type (Type type)
Tempo
TempoSection::tempo_at_minute (const double& m) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && m < minute());
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return Tempo (note_types_per_minute(), note_type());
}
@ -246,7 +246,7 @@ TempoSection::tempo_at_minute (const double& m) const
double
TempoSection::minute_at_ntpm (const double& ntpm, const double& p) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && p < pulse());
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return ((p - pulse()) / pulses_per_minute()) + minute();
}
@ -259,7 +259,7 @@ TempoSection::minute_at_ntpm (const double& ntpm, const double& p) const
Tempo
TempoSection::tempo_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && p < pulse());
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return Tempo (note_types_per_minute(), note_type());
@ -281,7 +281,7 @@ TempoSection::tempo_at_pulse (const double& p) const
double
TempoSection::pulse_at_ntpm (const double& ntpm, const double& m) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && m < minute());
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return ((m - minute()) * pulses_per_minute()) + pulse();
}
@ -294,7 +294,7 @@ TempoSection::pulse_at_ntpm (const double& ntpm, const double& m) const
double
TempoSection::pulse_at_minute (const double& m) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && m < minute());
const bool constant = _type == Constant || _c == 0.0 || (initial() && m < minute());
if (constant) {
return ((m - minute()) * pulses_per_minute()) + pulse();
}
@ -307,7 +307,7 @@ TempoSection::pulse_at_minute (const double& m) const
double
TempoSection::minute_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && p < pulse());
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return ((p - pulse()) / pulses_per_minute()) + minute();
}
@ -324,7 +324,7 @@ TempoSection::minute_at_pulse (const double& p) const
double
TempoSection::pulse_at_frame (const framepos_t& f) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && f < frame());
const bool constant = _type == Constant || _c == 0.0 || (initial() && f < frame());
if (constant) {
return (minute_at_frame (f - frame()) * pulses_per_minute()) + pulse();
}
@ -335,7 +335,7 @@ TempoSection::pulse_at_frame (const framepos_t& f) const
framepos_t
TempoSection::frame_at_pulse (const double& p) const
{
const bool constant = _type == Constant || _c_func == 0.0 || (initial() && p < pulse());
const bool constant = _type == Constant || _c == 0.0 || (initial() && p < pulse());
if (constant) {
return frame_at_minute (((p - pulse()) / pulses_per_minute()) + minute());
}
@ -426,7 +426,7 @@ https://www.zhdk.ch/fileadmin/data_subsites/data_icst/Downloads/Timegrid/ICST_Te
double
TempoSection::compute_c_func_pulse (const double& end_npm, const double& end_pulse) const
{
if (note_types_per_minute() == end_npm) {
if (note_types_per_minute() == end_npm || _type == Constant) {
return 0.0;
}
@ -442,7 +442,7 @@ TempoSection::compute_c_func_pulse (const double& end_npm, const double& end_pul
double
TempoSection::compute_c_func_minute (const double& end_npm, const double& end_minute) const
{
if (note_types_per_minute() == end_npm) {
if (note_types_per_minute() == end_npm || _type == Constant) {
return 0.0;
}
@ -451,9 +451,9 @@ TempoSection::compute_c_func_minute (const double& end_npm, const double& end_mi
/* position function */
double
TempoSection::a_func (double end_npm, double c_func) const
TempoSection::a_func (double end_npm, double c) const
{
return log (end_npm / note_types_per_minute()) / c_func;
return log (end_npm / note_types_per_minute()) / c;
}
/*function constant*/
@ -467,42 +467,42 @@ TempoSection::c_func (double end_npm, double end_time) const
double
TempoSection::_tempo_at_time (const double& time) const
{
return exp (_c_func * time) * note_types_per_minute();
return exp (_c * time) * note_types_per_minute();
}
/* time in minutes at tempo in note types per minute */
double
TempoSection::_time_at_tempo (const double& npm) const
{
return log (npm / note_types_per_minute()) / _c_func;
return log (npm / note_types_per_minute()) / _c;
}
/* pulse at tempo in note types per minute */
double
TempoSection::_pulse_at_tempo (const double& npm) const
{
return ((npm - note_types_per_minute()) / _c_func) / _note_type;
return ((npm - note_types_per_minute()) / _c) / _note_type;
}
/* tempo in note types per minute at pulse */
double
TempoSection::_tempo_at_pulse (const double& pulse) const
{
return (pulse * _note_type * _c_func) + note_types_per_minute();
return (pulse * _note_type * _c) + note_types_per_minute();
}
/* pulse at time in minutes */
double
TempoSection::_pulse_at_time (const double& time) const
{
return (expm1 (_c_func * time) * (note_types_per_minute() / _c_func)) / _note_type;
return (expm1 (_c * time) * (note_types_per_minute() / _c)) / _note_type;
}
/* time in minutes at pulse */
double
TempoSection::_time_at_pulse (const double& pulse) const
{
return log1p ((_c_func * pulse * _note_type) / note_types_per_minute()) / _c_func;
return log1p ((_c * pulse * _note_type) / note_types_per_minute()) / _c;
}
/***********************************************************************/
@ -1422,13 +1422,13 @@ TempoMap::recompute_tempi (Metrics& metrics)
}
if (prev_t) {
if (t->position_lock_style() == AudioTime) {
prev_t->set_c_func (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
prev_t->set_c (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_ntpm (t->note_types_per_minute(), t->minute()));
}
} else {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
prev_t->set_c (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
t->set_minute (prev_t->minute_at_ntpm (t->note_types_per_minute(), t->pulse()));
}
@ -1437,7 +1437,7 @@ TempoMap::recompute_tempi (Metrics& metrics)
}
}
assert (prev_t);
prev_t->set_c_func (0.0);
prev_t->set_c (0.0);
}
/* tempos must be positioned correctly.
@ -2576,8 +2576,8 @@ TempoMap::check_solved (const Metrics& metrics) const
/* gradient limit - who knows what it should be?
things are also ok (if a little chaotic) without this
*/
if (fabs (prev_t->c_func()) > 1000.0) {
//std::cout << "c : " << prev_t->c_func() << std::endl;
if (fabs (prev_t->c()) > 1000.0) {
//std::cout << "c : " << prev_t->c() << std::endl;
return false;
}
}
@ -2678,7 +2678,7 @@ TempoMap::solve_map_minute (Metrics& imaginary, TempoSection* section, const dou
if (prev_t && !section_prev && ((sml && tlm && t->pulse() > section->pulse()) || (!tlm && t->minute() > minute))) {
section_prev = prev_t;
section_prev->set_c_func (section_prev->compute_c_func_minute (section->note_types_per_minute(), minute));
section_prev->set_c (section_prev->compute_c_func_minute (section->note_types_per_minute(), minute));
if (!section->locked_to_meter()) {
section->set_pulse (section_prev->pulse_at_ntpm (section->note_types_per_minute(), minute));
}
@ -2686,10 +2686,10 @@ TempoMap::solve_map_minute (Metrics& imaginary, TempoSection* section, const dou
}
if (t->position_lock_style() == MusicTime) {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
prev_t->set_c (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
t->set_minute (prev_t->minute_at_ntpm (t->note_types_per_minute(), t->pulse()));
} else {
prev_t->set_c_func (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
prev_t->set_c (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_ntpm (t->note_types_per_minute(), t->minute()));
}
@ -2746,11 +2746,12 @@ TempoMap::solve_map_pulse (Metrics& imaginary, TempoSection* section, const doub
section_prev = prev_t;
continue;
}
if (t->position_lock_style() == MusicTime) {
prev_t->set_c_func (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
prev_t->set_c (prev_t->compute_c_func_pulse (t->note_types_per_minute(), t->pulse()));
t->set_minute (prev_t->minute_at_ntpm (t->note_types_per_minute(), t->pulse()));
} else {
prev_t->set_c_func (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
prev_t->set_c (prev_t->compute_c_func_minute (t->note_types_per_minute(), t->minute()));
if (!t->locked_to_meter()) {
t->set_pulse (prev_t->pulse_at_ntpm (t->note_types_per_minute(), t->minute()));
}
@ -2761,7 +2762,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->note_types_per_minute(), pulse));
section_prev->set_c (section_prev->compute_c_func_pulse (section->note_types_per_minute(), pulse));
section->set_minute (section_prev->minute_at_ntpm (section->note_types_per_minute(), pulse));
}
@ -3422,7 +3423,7 @@ TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t& frame, const fr
double new_bpm;
if (prev_t->type() == TempoSection::Constant || prev_t->c_func() == 0.0) {
if (prev_t->type() == TempoSection::Constant || prev_t->c() == 0.0) {
if (prev_t->position_lock_style() == MusicTime) {
if (prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) {
@ -3969,9 +3970,8 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
const TempoSection tempo = tempo_section_at_minute_locked (_metrics, minute_at_frame (pos));
const MeterSection meter = meter_section_at_minute_locked (_metrics, minute_at_frame (pos));
const BBT_Time bbt = bbt_at_beat_locked (_metrics, cnt);
const double c = (tempo.type() == TempoSection::Constant) ? 0.0 : tempo.c_func();
points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, c));
points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, tempo.c()));
++cnt;
}
} else {
@ -3988,7 +3988,7 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
pos = frame_at_minute (minute_at_bbt_locked (_metrics, bbt));
const TempoSection tempo = tempo_section_at_minute_locked (_metrics, minute_at_frame (pos));
const MeterSection meter = meter_section_at_minute_locked (_metrics, minute_at_frame (pos));
points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, tempo.c_func()));
points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, tempo.c()));
bbt.bars += bar_mod;
}
}