Tempo ramps - audio-locked meters have a bbt of 1|1|0
- possibly lots going wrong with this due to multiple occurences of 1|1|0.
This commit is contained in:
parent
6ecef52d76
commit
a0558694df
|
@ -3185,11 +3185,9 @@ MeterMarkerDrag::motion (GdkEvent* event, bool first_move)
|
|||
}
|
||||
|
||||
framepos_t const pf = adjusted_current_frame (event);
|
||||
/* moving a meter doesn't change beat locations, so this shuld be ok */
|
||||
double const baf = _editor->session()->tempo_map().beat_at_frame (pf);
|
||||
|
||||
_marker->set_position (pf);
|
||||
_editor->session()->tempo_map().gui_move_meter (_real_section, _marker->meter(), baf);
|
||||
_editor->session()->tempo_map().gui_move_meter (_real_section, _marker->meter(), pf);
|
||||
|
||||
show_verbose_cursor_time (pf);
|
||||
}
|
||||
|
|
|
@ -1109,11 +1109,15 @@ Editor::compute_bbt_ruler_scale (std::vector<ARDOUR::TempoMap::BBTPoint>& grid,
|
|||
i--;
|
||||
|
||||
/* XX ?? */
|
||||
/*
|
||||
if ((*i).beat >= (*grid.begin()).beat) {
|
||||
bbt_bars = (*i).bar - (*grid.begin()).bar;
|
||||
} else {
|
||||
bbt_bars = (*i).bar - (*grid.begin()).bar;
|
||||
}
|
||||
*/
|
||||
/*XXX totally wrong */
|
||||
bbt_bars = (floor (_session->tempo_map().beat_at_frame (upper)) - floor (_session->tempo_map().beat_at_frame (lower))) / 4;
|
||||
|
||||
beats = distance (grid.begin(), grid.end()) - bbt_bars;
|
||||
|
||||
|
@ -1123,7 +1127,7 @@ Editor::compute_bbt_ruler_scale (std::vector<ARDOUR::TempoMap::BBTPoint>& grid,
|
|||
}
|
||||
|
||||
if (bbt_bars > 8192) {
|
||||
bbt_ruler_scale = bbt_show_many;
|
||||
bbt_ruler_scale = bbt_show_many;
|
||||
} else if (bbt_bars > 1024) {
|
||||
bbt_ruler_scale = bbt_show_64;
|
||||
} else if (bbt_bars > 256) {
|
||||
|
|
|
@ -380,8 +380,8 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
|||
void replace_tempo (const TempoSection&, const Tempo&, const double& where, TempoSection::Type type);
|
||||
void replace_tempo (const TempoSection&, const Tempo&, const framepos_t& frame, TempoSection::Type type);
|
||||
|
||||
void gui_move_tempo (TempoSection*, const Tempo& bpm, const framepos_t& where);
|
||||
void gui_move_meter (MeterSection*, const Meter& mt, const double& beat);
|
||||
void gui_move_tempo (TempoSection*, const Tempo& bpm, const framepos_t& frame);
|
||||
void gui_move_meter (MeterSection*, const Meter& mt, const framepos_t& frame);
|
||||
|
||||
void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where);
|
||||
void replace_meter (const MeterSection&, const Meter&, const framepos_t& frame);
|
||||
|
@ -434,6 +434,7 @@ private:
|
|||
|
||||
Metrics get_new_order (TempoSection* section, const Tempo& bpm, const framepos_t& frame);
|
||||
Metrics get_new_order (TempoSection* section, const Tempo& bpm, const double& beat);
|
||||
Metrics get_new_order (MeterSection* section, const Meter& mt, const framepos_t& frame);
|
||||
Metrics get_new_order (MeterSection* section, const Meter& mt, const double& beat);
|
||||
|
||||
friend class ::BBTTest;
|
||||
|
|
|
@ -1063,6 +1063,44 @@ TempoMap::get_new_order(MeterSection* section, const Meter& mt, const double& be
|
|||
return imaginary;
|
||||
}
|
||||
|
||||
Metrics
|
||||
TempoMap::get_new_order(MeterSection* section, const Meter& mt, const framepos_t& frame)
|
||||
{
|
||||
Metrics imaginary (metrics);
|
||||
MeterSection* prev_ms = 0;
|
||||
|
||||
section->set_frame (frame);
|
||||
MetricSectionFrameSorter fcmp;
|
||||
imaginary.sort (fcmp);
|
||||
|
||||
for (Metrics::iterator i = imaginary.begin(); i != imaginary.end(); ++i) {
|
||||
MeterSection* m;
|
||||
if ((m = dynamic_cast<MeterSection*> (*i)) != 0) {
|
||||
if (prev_ms) {
|
||||
if (m->frame() > frame){
|
||||
pair<double, BBT_Time> b_bbt = make_pair (beat_at_frame_locked (frame), BBT_Time (1, 1, 0));
|
||||
|
||||
section->set_beat (b_bbt);
|
||||
prev_ms = section;
|
||||
continue;
|
||||
}
|
||||
if (m->position_lock_style() == MusicTime) {
|
||||
m->set_frame (frame_at_beat_locked (m->beat()));
|
||||
} else {
|
||||
pair<double, BBT_Time> b_bbt = make_pair (beat_at_frame_locked (m->frame()), BBT_Time (1, 1, 0));
|
||||
m->set_beat (b_bbt);
|
||||
}
|
||||
}
|
||||
prev_ms = m;
|
||||
}
|
||||
}
|
||||
|
||||
MetricSectionSorter cmp;
|
||||
imaginary.sort (cmp);
|
||||
|
||||
return imaginary;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for a gui that needs to know the frame of an audio-locked tempo section if it were to be placed at some beat.
|
||||
* It actually reorders and partially recomputes tha ramps, so calling this commits you to replacing the section immediately.
|
||||
|
@ -1097,11 +1135,11 @@ TempoMap::gui_move_tempo (TempoSection* ts, const Tempo& bpm, const framepos_t&
|
|||
}
|
||||
|
||||
void
|
||||
TempoMap::gui_move_meter (MeterSection* ms, const Meter& mt, const double& beat_where)
|
||||
TempoMap::gui_move_meter (MeterSection* ms, const Meter& mt, const framepos_t& frame)
|
||||
{
|
||||
{
|
||||
Glib::Threads::RWLock::WriterLock lm (lock);
|
||||
Metrics new_order = get_new_order (ms, mt, beat_where);
|
||||
Metrics new_order = get_new_order (ms, mt, frame);
|
||||
|
||||
metrics.clear();
|
||||
metrics = new_order;
|
||||
|
@ -1585,6 +1623,7 @@ TempoMap::bbt_to_beats_locked (Timecode::BBT_Time bbt)
|
|||
|
||||
double accumulated_beats = 0.0;
|
||||
double accumulated_bars = 0.0;
|
||||
double bars_offset = 0.0;
|
||||
MeterSection* prev_ms = 0;
|
||||
|
||||
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
||||
|
@ -1598,16 +1637,24 @@ TempoMap::bbt_to_beats_locked (Timecode::BBT_Time bbt)
|
|||
break;
|
||||
}
|
||||
if (prev_ms) {
|
||||
accumulated_beats += m->beat() - prev_ms->beat();
|
||||
accumulated_bars += bars_to_m;
|
||||
if (m->position_lock_style() == AudioTime) {
|
||||
accumulated_beats = 0.0;
|
||||
accumulated_bars = 0;
|
||||
bars_offset += bars_to_m;
|
||||
} else {
|
||||
accumulated_beats += m->beat() - prev_ms->beat();
|
||||
accumulated_bars += bars_to_m;
|
||||
}
|
||||
}
|
||||
prev_ms = m;
|
||||
}
|
||||
}
|
||||
|
||||
double const remaining_bars = (bbt.bars - 1) - accumulated_bars;
|
||||
double const remaining_bars = (bbt.bars - bars_offset - 1) - accumulated_bars;
|
||||
double const remaining_bars_in_beats = remaining_bars * prev_ms->divisions_per_bar();
|
||||
double const ret = remaining_bars_in_beats + accumulated_beats + (bbt.beats - 1) + (bbt.ticks / BBT_Time::ticks_per_beat);
|
||||
std::cerr << "ret : " << ret << " bbt : " << bbt.bars << "|" << bbt.beats << "|" << bbt.ticks << std::endl;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1631,14 +1678,18 @@ TempoMap::beats_to_bbt_locked (double beats)
|
|||
|
||||
if ((m = dynamic_cast<MeterSection*> (*i)) != 0) {
|
||||
|
||||
if (beats < m->beat()) {
|
||||
if (m->beat() > beats) {
|
||||
/* this is the meter after the one our beat is on*/
|
||||
break;
|
||||
}
|
||||
|
||||
if (prev_ms) {
|
||||
/* we need a whole number of bars. */
|
||||
accumulated_bars += ((m->beat() - prev_ms->beat()) + 1) / prev_ms->divisions_per_bar();
|
||||
if(m->position_lock_style() == AudioTime) {
|
||||
accumulated_bars = 0;
|
||||
} else {
|
||||
/* we need a whole number of bars. */
|
||||
accumulated_bars += ((m->beat() - prev_ms->beat()) + 1) / prev_ms->divisions_per_bar();
|
||||
}
|
||||
}
|
||||
|
||||
prev_ms = m;
|
||||
|
|
Loading…
Reference in New Issue
Block a user