X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_tempodisplay.cc;h=7af6fef05979db04b521db1b7614e6ff5e1baaf4;hb=a5ae129a066747901ff1ed95368729b63cb6a70d;hp=adc7247e8bfb291afca44498310e2500ce8dfe35;hpb=82d876b48b9de4e178547d00e91e6aa098ae56a7;p=ardour.git diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index adc7247e8b..7af6fef059 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -103,7 +103,7 @@ Editor::draw_metric_marks (const Metrics& metrics) max_tempo = max (max_tempo, ts->beats_per_minute()); min_tempo = min (min_tempo, ts->beats_per_minute()); - tempo_curves.push_back (new TempoCurve (*this, *tempo_group, UIConfiguration::instance().color ("range drag rect"), + tempo_curves.push_back (new TempoCurve (*this, *tempo_group, UIConfiguration::instance().color ("color 62"), *(const_cast(ts)), ts->frame(), false)); metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf, *(const_cast(ts)))); @@ -112,6 +112,14 @@ Editor::draw_metric_marks (const Metrics& metrics) } + const double min_tempo_range = 5.0; + const double tempo_delta = fabs (max_tempo - min_tempo); + + if (tempo_delta < min_tempo_range) { + max_tempo += min_tempo_range - tempo_delta; + min_tempo += tempo_delta - min_tempo_range; + } + for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) { Curves::iterator tmp = x; (*x)->set_max_tempo (max_tempo); @@ -129,7 +137,7 @@ Editor::draw_metric_marks (const Metrics& metrics) TempoMarker* tempo_marker; if ((tempo_marker = dynamic_cast (*x)) != 0) { - tempo_marker->update_height_mark ((tempo_marker->tempo().beats_per_minute() - min_tempo) / (max_tempo - min_tempo)); + tempo_marker->update_height_mark ((tempo_marker->tempo().beats_per_minute() - min_tempo) / max (10.0, max_tempo - min_tempo)); } } } @@ -203,6 +211,14 @@ Editor::marker_position_changed () tempo_curves.sort (CurveComparator()); + const double min_tempo_range = 5.0; + const double tempo_delta = fabs (max_tempo - min_tempo); + + if (tempo_delta < min_tempo_range) { + max_tempo += min_tempo_range - tempo_delta; + min_tempo += tempo_delta - min_tempo_range; + } + for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) { Curves::iterator tmp = x; (*x)->set_max_tempo (max_tempo); @@ -300,7 +316,7 @@ Editor::mouse_add_new_tempo_event (framepos_t frame) if (pulse > 0.0) { XMLNode &before = map.get_state(); /* add music-locked ramped (?) tempo using the bpm/note type at frame*/ - map.add_tempo_pulse (map.tempo_at (frame), pulse, TempoSection::Ramp); + map.add_tempo (map.tempo_at_frame (frame), pulse, 0, TempoSection::Ramp, MusicTime); XMLNode &after = map.get_state(); _session->add_command(new MementoCommand(map, &before, &after)); @@ -340,9 +356,9 @@ Editor::mouse_add_new_meter_event (framepos_t frame) XMLNode &before = map.get_state(); if (meter_dialog.get_lock_style() == MusicTime) { - map.add_meter_beat (Meter (bpb, note_type), map.bbt_to_beats (requested), requested); + map.add_meter (Meter (bpb, note_type), map.beat_at_bbt (requested), requested, 0, MusicTime); } else { - map.add_meter_frame (Meter (bpb, note_type), map.frame_time (requested), map.bbt_to_beats (requested), requested); + map.add_meter (Meter (bpb, note_type), map.beat_at_bbt (requested), requested, map.frame_at_bbt (requested), AudioTime); } _session->add_command(new MementoCommand(map, &before, &map.get_state())); @@ -389,18 +405,15 @@ Editor::edit_meter_section (MeterSection* section) double const note_type = meter_dialog.get_note_type (); Timecode::BBT_Time when; - meter_dialog.get_bbt_time(when); - framepos_t const frame = _session->tempo_map().frame_at_beat (_session->tempo_map().bbt_to_beats (when)); + meter_dialog.get_bbt_time (when); + framepos_t const frame = _session->tempo_map().frame_at_bbt (when); begin_reversible_command (_("replace meter mark")); XMLNode &before = _session->tempo_map().get_state(); - section->set_position_lock_style (meter_dialog.get_lock_style()); - if (meter_dialog.get_lock_style() == MusicTime) { - _session->tempo_map().replace_meter_bbt (*section, Meter (bpb, note_type), when); - } else { - _session->tempo_map().replace_meter_frame (*section, Meter (bpb, note_type), frame); - } - XMLNode &after = _session->tempo_map().get_state(); + + _session->tempo_map().replace_meter (*section, Meter (bpb, note_type), when, frame, meter_dialog.get_lock_style()); + + XMLNode &after = _session->tempo_map().get_state(); _session->add_command(new MementoCommand(_session->tempo_map(), &before, &after)); commit_reversible_command (); } @@ -428,9 +441,13 @@ Editor::edit_tempo_section (TempoSection* section) begin_reversible_command (_("replace tempo mark")); XMLNode &before = _session->tempo_map().get_state(); - framepos_t const f = _session->tempo_map().predict_tempo_frame (section, when); - double const p = _session->tempo_map().predict_tempo_pulse (section, f); - _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, f, tempo_dialog.get_tempo_type(), tempo_dialog.get_lock_style()); + if (tempo_dialog.get_lock_style() == AudioTime) { + framepos_t const f = _session->tempo_map().predict_tempo_position (section, when).second; + _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), 0.0, f, tempo_dialog.get_tempo_type(), AudioTime); + } else { + double const p = _session->tempo_map().predict_tempo_position (section, when).first; + _session->tempo_map().replace_tempo (*section, Tempo (bpm, nt), p, 0, tempo_dialog.get_tempo_type(), MusicTime); + } XMLNode &after = _session->tempo_map().get_state(); _session->add_command (new MementoCommand(_session->tempo_map(), &before, &after));