diff options
author | nick_m <mainsbridge@gmail.com> | 2015-12-28 05:33:04 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-05-27 23:38:09 +1000 |
commit | 5c6e18e6a087823e4a3719177c92238b206e3aeb (patch) | |
tree | 25f7faefa65e630e68da70bf4378b825e7c29312 /gtk2_ardour | |
parent | 41c8b534b70e220b4d4b940aed8a98d9a57003ab (diff) |
Tempo ramps - remove the concept of bars from tempo sections.
- this helps where tempo and meter have a somewhat circular
dependency.
MetricSection now has a musical position expressed in beats (a double).
MeterSection still has a bbt, but it really isn't needed as we have
enough information to discover the number of bars at a given beat without it.
TempoSection now has a hack to enable loading of legacy sessions, which will
ultimately be a lot cleaner than the current code.
Removing bars from tempo sections also allows us to place them
at arbitrary frames (implemented here).
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 24 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_tempodisplay.cc | 10 |
3 files changed, 15 insertions, 23 deletions
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index dccb6cac51..dfd6407a6e 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3210,7 +3210,7 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred) if (_copy == true) { _editor->begin_reversible_command (_("copy meter mark")); XMLNode &before = map.get_state(); - map.add_meter (_marker->meter(), when); + map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when); XMLNode &after = map.get_state(); _editor->session()->add_command(new MementoCommand<TempoMap>(map, &before, &after)); _editor->commit_reversible_command (); @@ -3220,7 +3220,7 @@ MeterMarkerDrag::finished (GdkEvent* event, bool movement_occurred) /* we removed it before, so add it back now */ - map.add_meter (_marker->meter(), when); + map.add_meter (_marker->meter(), map.beat_at_frame (_marker->position()), when); XMLNode &after = map.get_state(); _editor->session()->add_command(new MementoCommand<TempoMap>(map, before_state, &after)); _editor->commit_reversible_command (); @@ -3239,7 +3239,7 @@ MeterMarkerDrag::aborted (bool moved) if (moved) { TempoMap& map (_editor->session()->tempo_map()); /* we removed it before, so add it back now */ - map.add_meter (_marker->meter(), _marker->meter().frame()); + map.add_meter (_marker->meter(), map.beat_at_frame (_marker->meter().frame()), _marker->meter().bbt()); // delete the dummy marker we used for visual representation while moving. // a new visual marker will show up automatically. delete _marker; @@ -3309,15 +3309,15 @@ TempoMarkerDrag::motion (GdkEvent* event, bool first_move) TempoMap& map (_editor->session()->tempo_map()); /* get current state */ before_state = &map.get_state(); - /* remove the section while we drag it */ - //map.remove_tempo (section, true); } + _marker->hide(); } framepos_t const pf = adjusted_current_frame (event, false); - TempoMap& map (_editor->session()->tempo_map()); - _marker->set_position (pf); - map.gui_set_tempo_frame (*_real_section, pf); + double const baf = _editor->session()->tempo_map().beat_at_frame (pf); + + _marker->set_position (adjusted_current_frame (event, false)); + _editor->session()->tempo_map().gui_set_tempo_frame (*_real_section, pf, baf); show_verbose_cursor_time (pf); } @@ -3339,22 +3339,18 @@ TempoMarkerDrag::finished (GdkEvent* event, bool movement_occurred) motion (event, false); TempoMap& map (_editor->session()->tempo_map()); - framepos_t beat_time = map.round_to_beat (_marker->position(), RoundNearest); - Timecode::BBT_Time when; - - map.bbt_time (beat_time, when); if (_copy == true) { _editor->begin_reversible_command (_("copy tempo mark")); XMLNode &before = map.get_state(); - map.add_tempo (_marker->tempo(), when, _marker->tempo().type()); + map.add_tempo (_marker->tempo(), map.beat_at_frame (_marker->position()), _marker->tempo().type()); XMLNode &after = map.get_state(); _editor->session()->add_command (new MementoCommand<TempoMap>(map, &before, &after)); _editor->commit_reversible_command (); } else { /* we removed it before, so add it back now */ - map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , when, _marker->tempo().type()); + map.replace_tempo (*_real_section, _marker->tempo().beats_per_minute() , map.beat_at_frame (_marker->position()), _marker->tempo().type()); XMLNode &after = map.get_state(); _editor->session()->add_command (new MementoCommand<TempoMap>(map, before_state, &after)); _editor->commit_reversible_command (); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index f094c793ac..59a5e8d6db 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -6552,9 +6552,7 @@ Editor::define_one_bar (framepos_t start, framepos_t end) } else if (t.frame() == start) { _session->tempo_map().change_existing_tempo_at (start, beats_per_minute, t.note_type()); } 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::Type::Constant); + _session->tempo_map().add_tempo (Tempo (beats_per_minute, t.note_type()), _session->tempo_map().beat_at_frame (start), TempoSection::Type::Constant); } XMLNode& after (_session->tempo_map().get_state()); diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 3dad29ef51..0cb53ee5b4 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -143,13 +143,11 @@ Editor::marker_position_changed () for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) { if ((tempo_marker = dynamic_cast<TempoMarker*> (*x)) != 0) { if ((ts = &tempo_marker->tempo()) != 0) { - cerr << "tempo section found for tempo marker " << endl; tempo_marker->set_position (ts->frame ()); } } if ((meter_marker = dynamic_cast<MeterMarker*> (*x)) != 0) { if ((ms = &meter_marker->meter()) != 0) { - cerr << "meter section found for meter marker " << endl; meter_marker->set_position (ms->frame ()); } } @@ -249,7 +247,7 @@ Editor::mouse_add_new_tempo_event (framepos_t frame) begin_reversible_command (_("add tempo mark")); XMLNode &before = map.get_state(); - map.add_tempo (Tempo (bpm,nt), requested, tempo_dialog.get_tempo_type()); + map.add_tempo (Tempo (bpm,nt), map.bbt_to_beats (requested), tempo_dialog.get_tempo_type()); XMLNode &after = map.get_state(); _session->add_command(new MementoCommand<TempoMap>(map, &before, &after)); commit_reversible_command (); @@ -288,7 +286,7 @@ Editor::mouse_add_new_meter_event (framepos_t frame) begin_reversible_command (_("add meter mark")); XMLNode &before = map.get_state(); - map.add_meter (Meter (bpb, note_type), requested); + map.add_meter (Meter (bpb, note_type), map.bbt_to_beats (requested), requested); _session->add_command(new MementoCommand<TempoMap>(map, &before, &map.get_state())); commit_reversible_command (); @@ -338,7 +336,7 @@ Editor::edit_meter_section (MeterSection* section) begin_reversible_command (_("replace tempo mark")); XMLNode &before = _session->tempo_map().get_state(); - _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when); + _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), _session->tempo_map().bbt_to_beats (when), when); XMLNode &after = _session->tempo_map().get_state(); _session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after)); commit_reversible_command (); @@ -364,7 +362,7 @@ Editor::edit_tempo_section (TempoSection* section) begin_reversible_command (_("replace tempo mark")); XMLNode &before = _session->tempo_map().get_state(); - _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), when, tempo_dialog.get_tempo_type()); + _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), _session->tempo_map().bbt_to_beats (when), tempo_dialog.get_tempo_type()); XMLNode &after = _session->tempo_map().get_state(); _session->add_command (new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after)); commit_reversible_command (); |