From f0d055ad4d3484e288ce0c297ccd840fceb41315 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 23 Nov 2020 18:04:37 -0700 Subject: [PATCH] more updates for new tempo map API --- gtk2_ardour/editor.cc | 27 +++++++++++---------------- gtk2_ardour/editor_drag.cc | 9 ++------- gtk2_ardour/editor_ops.cc | 3 --- gtk2_ardour/main_clock.cc | 8 ++------ gtk2_ardour/tempo_dialog.cc | 19 +++++++------------ gtk2_ardour/tempo_dialog.h | 4 ++-- 6 files changed, 24 insertions(+), 46 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index e54df9baf5..4d29786102 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2809,8 +2809,6 @@ Editor::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, S { timepos_t ret(presnap); -#warning NUTEMPO FIXME needs complete rethink for nutempo - prenap may be in beatime -#if 0 if (gpref != SnapToGrid_Unscaled) { // use the visual grid lines which are limited by the zoom scale that the user selected int divisor = 2; @@ -2842,19 +2840,19 @@ Editor::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, S case bbt_show_16: case bbt_show_4: case bbt_show_1: - ret = _session->tempo_map().round_to_bar (presnap.sample, direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (_session->tempo_map().round_to_bar (_session->tempo_map().bbt_at (presnap)))); break; case bbt_show_quarters: - ret = _session->tempo_map().round_to_beat (presnap.sample, direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (presnap).round_to_beat ()); break; case bbt_show_eighths: - ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 1 * divisor, direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (presnap).round_to_subdivision (1 * divisor, direction)); break; case bbt_show_sixteenths: - ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 2 * divisor, direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (presnap).round_to_subdivision (2 * divisor, direction)); break; case bbt_show_thirtyseconds: - ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 4 * divisor, direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (presnap).round_to_subdivision (4 * divisor, direction)); break; case bbt_show_sixtyfourths: ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, 8 * divisor, direction); @@ -2864,10 +2862,9 @@ Editor::snap_to_bbt (timepos_t const & presnap, Temporal::RoundMode direction, S break; } } else { -#warning NUTEMPO FIXME new tempo map API required - //ret = _session->tempo_map().round_to_quarter_note_subdivision (presnap.sample, get_grid_beat_divisions(_grid_type), direction); + ret = timepos_t (_session->tempo_map().quarter_note_at (presnap).round_to_subdivision (get_grid_beat_divisions(), direction)); } -#endif + return ret; } @@ -4158,8 +4155,6 @@ Editor::get_grid_type_as_beats (bool& success, timepos_t const & position) { success = true; -#warning NUTEMPO FIXME needs new tempo map API -#if 0 const unsigned divisions = get_grid_beat_divisions (); if (divisions) { return Temporal::Beats::from_double (1.0 / (double) get_grid_beat_divisions ()); @@ -4167,18 +4162,18 @@ Editor::get_grid_type_as_beats (bool& success, timepos_t const & position) switch (_grid_type) { case GridTypeBeat: - return Temporal::Beats::from_double (4.0 / _session->tempo_map().meter_at_sample (position).note_divisor()); + return Temporal::Beats::from_double (4.0 / _session->tempo_map().meter_at (position).note_value()); case GridTypeBar: if (_session) { - const Meter& m = _session->tempo_map().meter_at_sample (position); - return Temporal::Beats::from_double ((4.0 * m.divisions_per_bar()) / m.note_divisor()); + const Meter& m = _session->tempo_map().meter_at (position); + return Temporal::Beats::from_double ((4.0 * m.divisions_per_bar()) / m.note_value()); } break; default: success = false; break; } -#endif + return Temporal::Beats(); } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index b4fa5fe300..56e4377ccc 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -3395,8 +3395,7 @@ MeterMarkerDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor) void MeterMarkerDrag::setup_pointer_offset () { -#warning NUTEMPO fixme needs new tempo map API to get "time()" for meter - // _pointer_offset = raw_grab_time() - _marker->meter().time(); + _pointer_offset = _marker->meter().time().distance (raw_grab_time()); } void @@ -6883,8 +6882,6 @@ NoteCreateDrag::grid_aligned_beats (timepos_t const & pos, GdkEvent const * even { Temporal::Beats beats; -#warning NUTEMPO needs new tempo map API -#if 0 TempoMap& map (_editor->session()->tempo_map()); const int32_t divisions = _editor->get_grid_music_divisions (event->button.state); @@ -6894,14 +6891,12 @@ NoteCreateDrag::grid_aligned_beats (timepos_t const & pos, GdkEvent const * even beats = pos.beats (); break; case -1: /* round to bar */ -#warning NUTEMPO need map/BBT API - //map.quarter_note_at (map.metric_at (pos).meter().round_to_bar (map.bbt_at (pos))); + beats = map.quarter_note_at (map.metric_at (pos).meter().round_to_bar (map.bbt_at (pos))); break; default: /* round to some beat subdivision */ beats = (pos).beats().round_to_subdivision (divisions, Temporal::RoundNearest); break; } -#endif return beats; } diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index c2854fb713..c18f32e12b 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -8275,8 +8275,6 @@ Editor::remove_time (timepos_t const & pos, timecnt_t const & duration, InsertTi if (tempo_too) { XMLNode& before (_session->tempo_map().get_state()); -#warning NUTEMPO need new map API -#if 0 if (_session->tempo_map().remove_time (pos, duration)) { if (!in_command) { begin_reversible_command (_("remove time")); @@ -8285,7 +8283,6 @@ Editor::remove_time (timepos_t const & pos, timecnt_t const & duration, InsertTi XMLNode& after (_session->tempo_map().get_state()); _session->add_command (new MementoCommand(_session->tempo_map(), &before, &after)); } -#endif } if (in_command) { diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc index 3439d115ed..354f6ed2fc 100644 --- a/gtk2_ardour/main_clock.cc +++ b/gtk2_ardour/main_clock.cc @@ -150,18 +150,14 @@ void MainClock::edit_current_tempo () { if (!PublicEditor::instance().session()) return; -#warning NUTEMPO needs new map API - //ARDOUR::TempoSection* ts = const_cast(&PublicEditor::instance().session()->tempo_map().tempo_section_at_sample (absolute_time())); - //PublicEditor::instance().edit_tempo_section (ts); + PublicEditor::instance().edit_tempo_section (PublicEditor::instance().session()->tempo_map().tempo_at (absolute_time())); } void MainClock::edit_current_meter () { if (!PublicEditor::instance().session()) return; -#warning NUTEMPO needs new map API - //ARDOUR::MeterSection* ms = const_cast(&PublicEditor::instance().session()->tempo_map().meter_section_at_sample (absolute_time())); - //PublicEditor::instance().edit_meter_section (ms); + PublicEditor::instance().edit_meter_section (PublicEditor::instance().session()->tempo_map().meter_at (absolute_time())); } void diff --git a/gtk2_ardour/tempo_dialog.cc b/gtk2_ardour/tempo_dialog.cc index 6a76f12f32..05a8d73804 100644 --- a/gtk2_ardour/tempo_dialog.cc +++ b/gtk2_ardour/tempo_dialog.cc @@ -44,7 +44,7 @@ using namespace ARDOUR; using namespace PBD; using namespace Temporal; -TempoDialog::TempoDialog (TempoMap& map, samplepos_t sample, const string&) +TempoDialog::TempoDialog (TempoMap& map, timepos_t const & pos, const string&) : ArdourDialog (_("New Tempo")) , _map (&map) , _section (0) @@ -58,9 +58,8 @@ TempoDialog::TempoDialog (TempoMap& map, samplepos_t sample, const string&) , pulse_selector_label (_("Pulse:"), ALIGN_LEFT, ALIGN_CENTER) , tap_tempo_button (_("Tap tempo")) { - TempoMetric metric (map.metric_at (sample)); - Temporal::BBT_Time when (metric.bbt_at (sample)); - Tempo& tempo (metric.tempo()); + Temporal::BBT_Time when (_map->bbt_at (pos)); + Tempo& tempo (_map->tempo_at (pos)); init (when, tempo.note_types_per_minute(), tempo.end_note_types_per_minute(), tempo.note_type(), Tempo::Constant, true, BeatTime); } @@ -488,17 +487,13 @@ TempoDialog::tap_tempo_focus_out (GdkEventFocus* ) return false; } -MeterDialog::MeterDialog (TempoMap& map, samplepos_t sample, const string&) +MeterDialog::MeterDialog (TempoMap& map, timepos_t const & pos, const string&) : ArdourDialog (_("New Meter")) { -#warning NUTEMPO needs new map API -#if 0 - sample = map.round_to_bar(sample, RoundNearest).sample; - Temporal::BBT_Time when (map.bbt_at_sample (sample)); - Meter meter (map.meter_at_sample (sample)); + Temporal::BBT_Time when (map.round_to_bar (map.bbt_at (pos))); + Meter& meter (map.meter_at (when)); - init (when, meter.divisions_per_bar(), meter.note_divisor(), false, MusicTime); -#endif + init (when, meter.divisions_per_bar(), meter.note_value(), false, pos.time_domain()); } MeterDialog::MeterDialog (TempoMap& map, Temporal::MeterPoint& section, const string&) diff --git a/gtk2_ardour/tempo_dialog.h b/gtk2_ardour/tempo_dialog.h index 5c39f13ddb..b357e7b720 100644 --- a/gtk2_ardour/tempo_dialog.h +++ b/gtk2_ardour/tempo_dialog.h @@ -43,7 +43,7 @@ class TempoDialog : public ArdourDialog { public: - TempoDialog (Temporal::TempoMap&, samplepos_t, const std::string & action); + TempoDialog (Temporal::TempoMap&, Temporal::timepos_t const & , const std::string & action); TempoDialog (Temporal::TempoMap&, Temporal::TempoPoint&, const std::string & action); double get_bpm (); @@ -107,7 +107,7 @@ class MeterDialog : public ArdourDialog { public: - MeterDialog (Temporal::TempoMap&, samplepos_t, const std::string & action); + MeterDialog (Temporal::TempoMap&, Temporal::timepos_t const &, const std::string & action); MeterDialog (Temporal::TempoMap&, Temporal::MeterPoint&, const std::string & action); double get_bpb ();