summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-22 04:05:42 -0500
committerDavid Robillard <d@drobilla.net>2014-11-22 04:05:42 -0500
commitc1cfa12d6e5136d2e3e5501e83ff74c5009a9e60 (patch)
tree56d2811bc8b9d6f2a5accfa8e497ddd5976c7c7a /gtk2_ardour
parentcae74309a583c29dd6cc2081425c2e7b673ea13e (diff)
Wrap MusicalTime in a class.
This lets us get a more explicit handle on time conversions, and is the main step towards using actual beat:tick time and getting away from floating point precision problems.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/automation_region_view.h12
-rw-r--r--gtk2_ardour/edit_note_dialog.cc4
-rw-r--r--gtk2_ardour/editor.cc40
-rw-r--r--gtk2_ardour/editor_drag.cc6
-rw-r--r--gtk2_ardour/editor_ops.cc2
-rw-r--r--gtk2_ardour/hit.h2
-rw-r--r--gtk2_ardour/midi_region_view.cc55
-rw-r--r--gtk2_ardour/midi_region_view.h24
-rw-r--r--gtk2_ardour/patch_change_dialog.cc2
-rw-r--r--gtk2_ardour/step_editor.cc22
-rw-r--r--gtk2_ardour/step_entry.cc8
11 files changed, 93 insertions, 84 deletions
diff --git a/gtk2_ardour/automation_region_view.h b/gtk2_ardour/automation_region_view.h
index d8f0b2637f..a41c57c782 100644
--- a/gtk2_ardour/automation_region_view.h
+++ b/gtk2_ardour/automation_region_view.h
@@ -54,11 +54,11 @@ public:
float times,
boost::shared_ptr<const ARDOUR::AutomationList> slist);
- ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
+ ARDOUR::DoubleBeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter;
}
- ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const {
+ ARDOUR::DoubleBeatsFramesConverter const & source_relative_time_converter () const {
return _source_relative_time_converter;
}
@@ -83,10 +83,10 @@ protected:
void exited();
private:
- ARDOUR::BeatsFramesConverter _region_relative_time_converter;
- ARDOUR::BeatsFramesConverter _source_relative_time_converter;
- Evoral::Parameter _parameter;
- boost::shared_ptr<AutomationLine> _line;
+ ARDOUR::DoubleBeatsFramesConverter _region_relative_time_converter;
+ ARDOUR::DoubleBeatsFramesConverter _source_relative_time_converter;
+ Evoral::Parameter _parameter;
+ boost::shared_ptr<AutomationLine> _line;
};
#endif /* __gtk_ardour_automation_region_view_h__ */
diff --git a/gtk2_ardour/edit_note_dialog.cc b/gtk2_ardour/edit_note_dialog.cc
index 3d72e080ed..149b212926 100644
--- a/gtk2_ardour/edit_note_dialog.cc
+++ b/gtk2_ardour/edit_note_dialog.cc
@@ -193,7 +193,7 @@ EditNoteDialog::done (int r)
}
}
- double const t = _region_view->source_relative_time_converter().from (_time_clock.current_time ());
+ Evoral::MusicalTime const t = _region_view->source_relative_time_converter().from (_time_clock.current_time ());
if (!_time_all.get_sensitive() || _time_all.get_active ()) {
for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) {
@@ -204,7 +204,7 @@ EditNoteDialog::done (int r)
}
}
- double const d = _region_view->region_relative_time_converter().from (_length_clock.current_duration ());
+ Evoral::MusicalTime const d = _region_view->region_relative_time_converter().from (_length_clock.current_duration ());
if (!_length_all.get_sensitive() || _length_all.get_active ()) {
for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) {
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 98bf1ca35a..ce6e6b15ae 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -3901,64 +3901,64 @@ Editor::get_grid_type_as_beats (bool& success, framepos_t position)
switch (_snap_type) {
case SnapToBeat:
- return 1.0;
+ return Evoral::MusicalTime(1.0);
break;
case SnapToBeatDiv128:
- return 1.0/128.0;
+ return Evoral::MusicalTime(1.0/128.0);
break;
case SnapToBeatDiv64:
- return 1.0/64.0;
+ return Evoral::MusicalTime(1.0/64.0);
break;
case SnapToBeatDiv32:
- return 1.0/32.0;
+ return Evoral::MusicalTime(1.0/32.0);
break;
case SnapToBeatDiv28:
- return 1.0/28.0;
+ return Evoral::MusicalTime(1.0/28.0);
break;
case SnapToBeatDiv24:
- return 1.0/24.0;
+ return Evoral::MusicalTime(1.0/24.0);
break;
case SnapToBeatDiv20:
- return 1.0/20.0;
+ return Evoral::MusicalTime(1.0/20.0);
break;
case SnapToBeatDiv16:
- return 1.0/16.0;
+ return Evoral::MusicalTime(1.0/16.0);
break;
case SnapToBeatDiv14:
- return 1.0/14.0;
+ return Evoral::MusicalTime(1.0/14.0);
break;
case SnapToBeatDiv12:
- return 1.0/12.0;
+ return Evoral::MusicalTime(1.0/12.0);
break;
case SnapToBeatDiv10:
- return 1.0/10.0;
+ return Evoral::MusicalTime(1.0/10.0);
break;
case SnapToBeatDiv8:
- return 1.0/8.0;
+ return Evoral::MusicalTime(1.0/8.0);
break;
case SnapToBeatDiv7:
- return 1.0/7.0;
+ return Evoral::MusicalTime(1.0/7.0);
break;
case SnapToBeatDiv6:
- return 1.0/6.0;
+ return Evoral::MusicalTime(1.0/6.0);
break;
case SnapToBeatDiv5:
- return 1.0/5.0;
+ return Evoral::MusicalTime(1.0/5.0);
break;
case SnapToBeatDiv4:
- return 1.0/4.0;
+ return Evoral::MusicalTime(1.0/4.0);
break;
case SnapToBeatDiv3:
- return 1.0/3.0;
+ return Evoral::MusicalTime(1.0/3.0);
break;
case SnapToBeatDiv2:
- return 1.0/2.0;
+ return Evoral::MusicalTime(1.0/2.0);
break;
case SnapToBar:
if (_session) {
- return _session->tempo_map().meter_at (position).divisions_per_bar();
+ return Evoral::MusicalTime(_session->tempo_map().meter_at (position).divisions_per_bar());
}
break;
@@ -3977,7 +3977,7 @@ Editor::get_grid_type_as_beats (bool& success, framepos_t position)
break;
}
- return 0.0;
+ return Evoral::MusicalTime();
}
framecnt_t
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index ab2d2c071e..fa66c952dc 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -5220,7 +5220,7 @@ NoteCreateDrag::grid_frames (framepos_t t) const
bool success;
Evoral::MusicalTime grid_beats = _editor->get_grid_type_as_beats (success, t);
if (!success) {
- grid_beats = 1;
+ grid_beats = Evoral::MusicalTime(1);
}
return _region_view->region_beats_to_region_frames (grid_beats);
@@ -5276,13 +5276,13 @@ NoteCreateDrag::finished (GdkEvent*, bool had_movement)
framecnt_t length = (framecnt_t) fabs ((double)(_note[0] - _note[1]));
framecnt_t const g = grid_frames (start);
- double const one_tick = 1 / Timecode::BBT_Time::ticks_per_beat;
+ Evoral::MusicalTime const one_tick = Evoral::MusicalTime::ticks(1);
if (_editor->snap_mode() == SnapNormal && length < g) {
length = g - one_tick;
}
- double const length_beats = max (one_tick, _region_view->region_frames_to_region_beats (length));
+ Evoral::MusicalTime const length_beats = max (one_tick, _region_view->region_frames_to_region_beats (length));
_region_view->create_note_at (start, _drag_rect->y0(), length_beats, false);
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index a7e6d8420f..856b311ebd 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -4988,7 +4988,7 @@ Editor::insert_patch_change (bool from_context)
*/
MidiRegionView* first = dynamic_cast<MidiRegionView*> (rs.front ());
- Evoral::PatchChange<Evoral::MusicalTime> empty (0, 0, 0, 0);
+ Evoral::PatchChange<Evoral::MusicalTime> empty (Evoral::MusicalTime(), 0, 0, 0);
PatchChangeDialog d (0, _session, empty, first->instrument_info(), Gtk::Stock::ADD);
if (d.run() == RESPONSE_CANCEL) {
diff --git a/gtk2_ardour/hit.h b/gtk2_ardour/hit.h
index 5a6cef9943..f13a0ef27c 100644
--- a/gtk2_ardour/hit.h
+++ b/gtk2_ardour/hit.h
@@ -30,7 +30,7 @@ namespace ArdourCanvas {
class Hit : public NoteBase
{
public:
- typedef Evoral::Note<double> NoteType;
+ typedef Evoral::Note<Evoral::MusicalTime> NoteType;
Hit (MidiRegionView& region,
ArdourCanvas::Item* parent,
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index b9b53fbd11..b3c2cf1f84 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -550,7 +550,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
/* Shorten the length by 1 tick so that we can add a new note at the next
grid snap without it overlapping this one.
*/
- beats -= 1.0 / Timecode::BBT_Time::ticks_per_beat;
+ beats -= Evoral::MusicalTime::tick();
create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
}
@@ -564,7 +564,7 @@ MidiRegionView::button_release (GdkEventButton* ev)
/* Shorten the length by 1 tick so that we can add a new note at the next
grid snap without it overlapping this one.
*/
- beats -= 1.0 / Timecode::BBT_Time::ticks_per_beat;
+ beats -= Evoral::MusicalTime::tick();
create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true);
@@ -728,7 +728,7 @@ MidiRegionView::key_press (GdkEventKey* ev)
bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier);
bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
- change_note_lengths (fine, shorter, 0.0, start, end);
+ change_note_lengths (fine, shorter, Evoral::MusicalTime(), start, end);
return true;
@@ -909,7 +909,7 @@ MidiRegionView::show_list_editor ()
* \param snap_t true to snap t to the grid, otherwise false.
*/
void
-MidiRegionView::create_note_at (framepos_t t, double y, double length, bool snap_t)
+MidiRegionView::create_note_at (framepos_t t, double y, Evoral::MusicalTime length, bool snap_t)
{
if (length < 2 * DBL_EPSILON) {
return;
@@ -1521,7 +1521,7 @@ MidiRegionView::end_write()
/** Resolve an active MIDI note (while recording).
*/
void
-MidiRegionView::resolve_note(uint8_t note, double end_time)
+MidiRegionView::resolve_note(uint8_t note, Evoral::MusicalTime end_time)
{
if (midi_view()->note_mode() != Sustained) {
return;
@@ -1660,7 +1660,7 @@ MidiRegionView::update_note (Note* ev, bool update_ghost_regions)
ev->set_y1 (y0 + std::max(1., floor(midi_stream_view()->note_height()) - 1));
- if (note->length() == 0) {
+ if (!note->length()) {
if (_active_notes && note->note() < 128) {
// If this note is already active there's a stuck note,
// finish the old note rectangle
@@ -1862,7 +1862,7 @@ patch_applies (const ARDOUR::MidiModel::constPatchChangePtr pc, double time, uin
}
void
-MidiRegionView::get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const
+MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const
{
// The earliest event not before time
MidiModel::PatchChanges::iterator i = _model->patch_change_lower_bound (time);
@@ -2260,7 +2260,7 @@ MidiRegionView::note_selected (NoteBase* ev, bool add, bool extend)
/* find end of latest note selected, select all between that and the start of "ev" */
Evoral::MusicalTime earliest = Evoral::MaxMusicalTime;
- Evoral::MusicalTime latest = 0;
+ Evoral::MusicalTime latest = Evoral::MusicalTime();
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
if ((*i)->note()->end_time() > latest) {
@@ -2421,7 +2421,7 @@ MidiRegionView::move_selection(double dx, double dy, double cumulative_dy)
}
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
- if (Evoral::musical_time_equal ((*i)->note()->time(), earliest)) {
+ if ((*i)->note()->time() == earliest) {
to_play.push_back ((*i)->note());
}
(*i)->move_event(dx, dy);
@@ -2548,7 +2548,7 @@ MidiRegionView::get_end_position_pixels()
}
framepos_t
-MidiRegionView::source_beats_to_absolute_frames(double beats) const
+MidiRegionView::source_beats_to_absolute_frames(Evoral::MusicalTime beats) const
{
/* the time converter will return the frame corresponding to `beats'
relative to the start of the source. The start of the source
@@ -2558,7 +2558,7 @@ MidiRegionView::source_beats_to_absolute_frames(double beats) const
return source_start + _source_relative_time_converter.to (beats);
}
-double
+Evoral::MusicalTime
MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const
{
/* the `frames' argument needs to be converted into a frame count
@@ -2570,12 +2570,12 @@ MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const
}
framepos_t
-MidiRegionView::region_beats_to_region_frames(double beats) const
+MidiRegionView::region_beats_to_region_frames(Evoral::MusicalTime beats) const
{
return _region_relative_time_converter.to(beats);
}
-double
+Evoral::MusicalTime
MidiRegionView::region_frames_to_region_beats(framepos_t frames) const
{
return _region_relative_time_converter.from(frames);
@@ -2827,8 +2827,8 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo
{
bool change_start = false;
bool change_length = false;
- Evoral::MusicalTime new_start = 0;
- Evoral::MusicalTime new_length = 0;
+ Evoral::MusicalTime new_start;
+ Evoral::MusicalTime new_length;
/* NOTE: the semantics of the two delta arguments are slightly subtle:
@@ -2843,7 +2843,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo
if (front_delta < 0) {
if (event->note()->time() < -front_delta) {
- new_start = 0;
+ new_start = Evoral::MusicalTime();
} else {
new_start = event->note()->time() + front_delta; // moves earlier
}
@@ -2924,7 +2924,7 @@ MidiRegionView::change_note_time (NoteBase* event, Evoral::MusicalTime delta, bo
if (relative) {
if (delta < 0.0) {
if (event->note()->time() < -delta) {
- new_time = 0;
+ new_time = Evoral::MusicalTime();
} else {
new_time = event->note()->time() + delta;
}
@@ -3053,9 +3053,9 @@ MidiRegionView::transpose (bool up, bool fine, bool allow_smush)
void
MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTime delta, bool start, bool end)
{
- if (delta == 0.0) {
+ if (!delta) {
if (fine) {
- delta = 1.0/128.0;
+ delta = Evoral::MusicalTime(1.0/128.0);
} else {
/* grab the current grid distance */
delta = get_grid_beats(_region->position());
@@ -3074,7 +3074,9 @@ MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTim
/* note the negation of the delta for start */
- trim_note (*i, (start ? -delta : 0), (end ? delta : 0));
+ trim_note (*i,
+ (start ? -delta : Evoral::MusicalTime()),
+ (end ? delta : Evoral::MusicalTime()));
i = next;
}
@@ -3402,10 +3404,10 @@ MidiRegionView::paste_internal (framepos_t pos, unsigned paste_count, float time
const Evoral::MusicalTime first_time = (*mcb.notes().begin())->time();
const Evoral::MusicalTime last_time = (*mcb.notes().rbegin())->end_time();
const Evoral::MusicalTime duration = last_time - first_time;
- const Evoral::MusicalTime snap_duration = ceil(duration / snap_beats) * snap_beats;
- const Evoral::MusicalTime paste_offset = paste_count * snap_duration;
+ const Evoral::MusicalTime snap_duration = duration.snap_to(snap_beats);
+ const Evoral::MusicalTime paste_offset = snap_duration * paste_count;
const Evoral::MusicalTime pos_beats = absolute_frames_to_source_beats(pos) + paste_offset;
- Evoral::MusicalTime end_point = 0;
+ Evoral::MusicalTime end_point = Evoral::MusicalTime();
DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("Paste data spans from %1 to %2 (%3) ; paste pos beats = %4 (based on %5 - %6)\n",
first_time,
@@ -3585,7 +3587,8 @@ MidiRegionView::update_ghost_note (double x, double y)
the start of the source; that is how all note times are stored.
*/
_ghost_note->note()->set_time (
- std::max(0.0, absolute_frames_to_source_beats (f + _region->position ())));
+ std::max(Evoral::MusicalTime(),
+ absolute_frames_to_source_beats (f + _region->position ())));
_ghost_note->note()->set_length (length);
_ghost_note->note()->set_note (midi_stream_view()->y_to_note (y));
_ghost_note->note()->set_channel (mtv->get_channel_for_add ());
@@ -3786,7 +3789,7 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w)
if (ev.type() == MIDI_CMD_NOTE_ON) {
boost::shared_ptr<NoteType> note (
- new NoteType (ev.channel(), time_beats, 0, ev.note(), ev.velocity()));
+ new NoteType (ev.channel(), time_beats, Evoral::MusicalTime(), ev.note(), ev.velocity()));
add_note (note, true);
@@ -3969,7 +3972,7 @@ MidiRegionView::get_grid_beats(framepos_t pos) const
bool success = false;
Evoral::MusicalTime beats = editor.get_grid_type_as_beats(success, pos);
if (!success) {
- beats = 1;
+ beats = Evoral::MusicalTime(1);
}
return beats;
}
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index 098361e984..08005497df 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -110,7 +110,7 @@ public:
GhostRegion* add_ghost (TimeAxisView&);
void add_note(const boost::shared_ptr<NoteType> note, bool visible);
- void resolve_note(uint8_t note_num, double end_time);
+ void resolve_note(uint8_t note_num, Evoral::MusicalTime end_time);
void cut_copy_clear (Editing::CutCopyOp);
bool paste (framepos_t pos, unsigned paste_count, float times, const ::Selection& selection, ItemCounts& counts);
@@ -124,7 +124,7 @@ public:
* @key a reference to an instance of MIDI::Name::PatchPrimaryKey whose fields will
* will be set according to the result of the lookup
*/
- void get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const;
+ void get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const;
/** Convert a given PatchChange into a PatchPrimaryKey
*/
@@ -258,22 +258,22 @@ public:
framepos_t snap_pixel_to_sample(double x);
/** Convert a timestamp in beats into frames (both relative to region position) */
- framepos_t region_beats_to_region_frames(double beats) const;
+ framepos_t region_beats_to_region_frames(Evoral::MusicalTime beats) const;
/** Convert a timestamp in beats into absolute frames */
- framepos_t region_beats_to_absolute_frames(double beats) const {
+ framepos_t region_beats_to_absolute_frames(Evoral::MusicalTime beats) const {
return _region->position() + region_beats_to_region_frames (beats);
}
/** Convert a timestamp in frames to beats (both relative to region position) */
- double region_frames_to_region_beats(framepos_t) const;
+ Evoral::MusicalTime region_frames_to_region_beats(framepos_t) const;
/** Convert a timestamp in beats measured from source start into absolute frames */
- framepos_t source_beats_to_absolute_frames(double beats) const;
+ framepos_t source_beats_to_absolute_frames(Evoral::MusicalTime beats) const;
/** Convert a timestamp in beats measured from source start into region-relative frames */
- framepos_t source_beats_to_region_frames(double beats) const {
+ framepos_t source_beats_to_region_frames(Evoral::MusicalTime beats) const {
return source_beats_to_absolute_frames (beats) - _region->position();
}
/** Convert a timestamp in absolute frames to beats measured from source start*/
- double absolute_frames_to_source_beats(framepos_t) const;
+ Evoral::MusicalTime absolute_frames_to_source_beats(framepos_t) const;
ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
return _region_relative_time_converter;
@@ -309,7 +309,13 @@ public:
void trim_front_starting ();
void trim_front_ending ();
- void create_note_at (framepos_t, double, double, bool);
+ /** Add a note to the model, and the view, at a canvas (click) coordinate.
+ * \param t time in frames relative to the position of the region
+ * \param y vertical position in pixels
+ * \param length duration of the note in beats
+ * \param snap_t true to snap t to the grid, otherwise false.
+ */
+ void create_note_at (framepos_t t, double y, Evoral::MusicalTime length, bool snap_t);
void clear_selection (bool signal = true) { clear_selection_except (0, signal); }
diff --git a/gtk2_ardour/patch_change_dialog.cc b/gtk2_ardour/patch_change_dialog.cc
index 081604344c..3af5a4ed7f 100644
--- a/gtk2_ardour/patch_change_dialog.cc
+++ b/gtk2_ardour/patch_change_dialog.cc
@@ -143,7 +143,7 @@ PatchChangeDialog::instrument_info_changed ()
Evoral::PatchChange<Evoral::MusicalTime>
PatchChangeDialog::patch () const
{
- Evoral::MusicalTime t = 0;
+ Evoral::MusicalTime t = Evoral::MusicalTime();
if (_time_converter) {
t = _time_converter->from (_time.current_time ());
diff --git a/gtk2_ardour/step_editor.cc b/gtk2_ardour/step_editor.cc
index ef3caad5d1..ec525b84ed 100644
--- a/gtk2_ardour/step_editor.cc
+++ b/gtk2_ardour/step_editor.cc
@@ -41,7 +41,7 @@ StepEditor::StepEditor (PublicEditor& e, boost::shared_ptr<MidiTrack> t, MidiTim
step_edit_insert_position = 0;
_step_edit_triplet_countdown = 0;
_step_edit_within_chord = 0;
- _step_edit_chord_duration = 0.0;
+ _step_edit_chord_duration = Evoral::MusicalTime();
step_edit_region_view = 0;
_track->PlaylistChanged.connect (*this, invalidator (*this),
@@ -60,11 +60,11 @@ StepEditor::start_step_editing ()
{
_step_edit_triplet_countdown = 0;
_step_edit_within_chord = 0;
- _step_edit_chord_duration = 0.0;
+ _step_edit_chord_duration = Evoral::MusicalTime();
step_edit_region.reset ();
step_edit_region_view = 0;
last_added_pitch = -1;
- last_added_end = 0;
+ last_added_end = Evoral::MusicalTime();
resync_step_edit_position ();
prepare_step_edit_region ();
@@ -198,7 +198,7 @@ StepEditor::check_step_edit ()
incoming.read_contents (size, buf);
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON) {
- step_add_note (buf[0] & 0xf, buf[1], buf[2], 0.0);
+ step_add_note (buf[0] & 0xf, buf[1], buf[2], Evoral::MusicalTime());
}
}
}
@@ -233,7 +233,7 @@ StepEditor::move_step_edit_beat_pos (Evoral::MusicalTime beats)
if (-beats < step_edit_beat_pos) {
step_edit_beat_pos += beats; // its negative, remember
} else {
- step_edit_beat_pos = 0;
+ step_edit_beat_pos = Evoral::MusicalTime();
}
}
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
@@ -292,8 +292,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
up by 1 tick from where the last note ended
*/
- at += 1.0/Timecode::BBT_Time::ticks_per_beat;
- len -= 1.0/Timecode::BBT_Time::ticks_per_beat;
+ at += Evoral::MusicalTime::ticks(1);
+ len -= Evoral::MusicalTime::ticks(1);
}
step_edit_region_view->step_add_note (channel, pitch, velocity, at, len);
@@ -313,7 +313,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo
step_edit_beat_pos += beat_duration;
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
} else {
- step_edit_beat_pos += 1.0/Timecode::BBT_Time::ticks_per_beat; // tiny, but no longer overlapping
+ step_edit_beat_pos += Evoral::MusicalTime::ticks(1); // tiny, but no longer overlapping
_step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration);
}
@@ -384,7 +384,7 @@ StepEditor::step_edit_rest (Evoral::MusicalTime beats)
void
StepEditor::step_edit_beat_sync ()
{
- step_edit_beat_pos = ceil (step_edit_beat_pos);
+ step_edit_beat_pos = step_edit_beat_pos.round_up_to_beat();
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
}
@@ -399,7 +399,7 @@ StepEditor::step_edit_bar_sync ()
framepos_t fpos = step_edit_region_view->region_beats_to_absolute_frames (step_edit_beat_pos);
fpos = _session->tempo_map().round_to_bar (fpos, RoundUpAlways);
- step_edit_beat_pos = ceil (step_edit_region_view->region_frames_to_region_beats (fpos - step_edit_region->position()));
+ step_edit_beat_pos = step_edit_region_view->region_frames_to_region_beats (fpos - step_edit_region->position()).round_up_to_beat();
step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos);
}
@@ -425,7 +425,7 @@ StepEditor::region_removed (boost::weak_ptr<Region> wr)
step_edit_region.reset();
step_edit_region_view = 0;
// force a recompute of the insert position
- step_edit_beat_pos = -1.0;
+ step_edit_beat_pos = Evoral::MusicalTime(-1);
}
}
diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc
index ac13770a29..607f4abd62 100644
--- a/gtk2_ardour/step_entry.cc
+++ b/gtk2_ardour/step_entry.cc
@@ -526,13 +526,13 @@ StepEntry::on_key_release_event (GdkEventKey* ev)
void
StepEntry::rest_event_handler ()
{
- se->step_edit_rest (0.0);
+ se->step_edit_rest (Evoral::MusicalTime());
}
Evoral::MusicalTime
StepEntry::note_length ()
{
- Evoral::MusicalTime base_time = 4.0 / (Evoral::MusicalTime) length_divisor_adjustment.get_value();
+ double base_time = 4.0 / (double) length_divisor_adjustment.get_value();
RefPtr<Action> act = myactions.find_action ("StepEditing/toggle-triplet");
RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
@@ -549,7 +549,7 @@ StepEntry::note_length ()
base_time *= 1 + ((dots - 1.0)/dots);
}
- return base_time;
+ return Evoral::MusicalTime(base_time);
}
uint8_t
@@ -795,7 +795,7 @@ StepEntry::insert_rest ()
void
StepEntry::insert_grid_rest ()
{
- se->step_edit_rest (0.0);
+ se->step_edit_rest (Evoral::MusicalTime());
}
void