diff options
author | David Robillard <d@drobilla.net> | 2015-01-07 00:12:07 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-01-07 00:12:07 -0500 |
commit | 2a251b457069ffb4b744fbd0dd7aca7acb31f381 (patch) | |
tree | 4311e63fe7ef1b5d7a5b841a4dd0eb7b26b324a7 | |
parent | 4d202d9157bef5b6325fe54b7874080952f86a37 (diff) |
MusicalTime => Beats.
66 files changed, 625 insertions, 584 deletions
diff --git a/gtk2_ardour/edit_note_dialog.cc b/gtk2_ardour/edit_note_dialog.cc index 5f8add9ffd..0568468d63 100644 --- a/gtk2_ardour/edit_note_dialog.cc +++ b/gtk2_ardour/edit_note_dialog.cc @@ -116,8 +116,8 @@ EditNoteDialog::EditNoteDialog (MidiRegionView* rv, set<NoteBase*> n) int test_channel = (*_events.begin())->note()->channel (); int test_pitch = (*_events.begin())->note()->note (); int test_velocity = (*_events.begin())->note()->velocity (); - Evoral::MusicalTime test_time = (*_events.begin())->note()->time (); - Evoral::MusicalTime test_length = (*_events.begin())->note()->length (); + Evoral::Beats test_time = (*_events.begin())->note()->time (); + Evoral::Beats test_length = (*_events.begin())->note()->length (); for (set<NoteBase*>::iterator i = _events.begin(); i != _events.end(); ++i) { if ((*i)->note()->channel() != test_channel) { @@ -193,7 +193,7 @@ EditNoteDialog::done (int r) } } - Evoral::MusicalTime const t = _region_view->source_relative_time_converter().from (_time_clock.current_time ()); + Evoral::Beats 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) } } - Evoral::MusicalTime const d = _region_view->region_relative_time_converter().from (_length_clock.current_duration ()); + Evoral::Beats 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 019d2f91e8..217d55bb9a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -4001,71 +4001,71 @@ Editor::get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t durat return offset; } -Evoral::MusicalTime +Evoral::Beats Editor::get_grid_type_as_beats (bool& success, framepos_t position) { success = true; switch (_snap_type) { case SnapToBeat: - return Evoral::MusicalTime(1.0); + return Evoral::Beats(1.0); break; case SnapToBeatDiv128: - return Evoral::MusicalTime(1.0/128.0); + return Evoral::Beats(1.0/128.0); break; case SnapToBeatDiv64: - return Evoral::MusicalTime(1.0/64.0); + return Evoral::Beats(1.0/64.0); break; case SnapToBeatDiv32: - return Evoral::MusicalTime(1.0/32.0); + return Evoral::Beats(1.0/32.0); break; case SnapToBeatDiv28: - return Evoral::MusicalTime(1.0/28.0); + return Evoral::Beats(1.0/28.0); break; case SnapToBeatDiv24: - return Evoral::MusicalTime(1.0/24.0); + return Evoral::Beats(1.0/24.0); break; case SnapToBeatDiv20: - return Evoral::MusicalTime(1.0/20.0); + return Evoral::Beats(1.0/20.0); break; case SnapToBeatDiv16: - return Evoral::MusicalTime(1.0/16.0); + return Evoral::Beats(1.0/16.0); break; case SnapToBeatDiv14: - return Evoral::MusicalTime(1.0/14.0); + return Evoral::Beats(1.0/14.0); break; case SnapToBeatDiv12: - return Evoral::MusicalTime(1.0/12.0); + return Evoral::Beats(1.0/12.0); break; case SnapToBeatDiv10: - return Evoral::MusicalTime(1.0/10.0); + return Evoral::Beats(1.0/10.0); break; case SnapToBeatDiv8: - return Evoral::MusicalTime(1.0/8.0); + return Evoral::Beats(1.0/8.0); break; case SnapToBeatDiv7: - return Evoral::MusicalTime(1.0/7.0); + return Evoral::Beats(1.0/7.0); break; case SnapToBeatDiv6: - return Evoral::MusicalTime(1.0/6.0); + return Evoral::Beats(1.0/6.0); break; case SnapToBeatDiv5: - return Evoral::MusicalTime(1.0/5.0); + return Evoral::Beats(1.0/5.0); break; case SnapToBeatDiv4: - return Evoral::MusicalTime(1.0/4.0); + return Evoral::Beats(1.0/4.0); break; case SnapToBeatDiv3: - return Evoral::MusicalTime(1.0/3.0); + return Evoral::Beats(1.0/3.0); break; case SnapToBeatDiv2: - return Evoral::MusicalTime(1.0/2.0); + return Evoral::Beats(1.0/2.0); break; case SnapToBar: if (_session) { - return Evoral::MusicalTime(_session->tempo_map().meter_at (position).divisions_per_bar()); + return Evoral::Beats(_session->tempo_map().meter_at (position).divisions_per_bar()); } break; @@ -4084,7 +4084,7 @@ Editor::get_grid_type_as_beats (bool& success, framepos_t position) break; } - return Evoral::MusicalTime(); + return Evoral::Beats(); } framecnt_t diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 655782e269..83b1a074e2 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -315,7 +315,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next); framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration); - Evoral::MusicalTime get_grid_type_as_beats (bool& success, framepos_t position); + Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position); void nudge_forward (bool next, bool force_playhead); void nudge_backward (bool next, bool force_playhead); @@ -1172,7 +1172,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void cut_copy (Editing::CutCopyOp); bool can_cut_copy () const; - void cut_copy_points (Editing::CutCopyOp, Evoral::MusicalTime earliest=Evoral::MusicalTime(), bool midi=false); + void cut_copy_points (Editing::CutCopyOp, Evoral::Beats earliest=Evoral::Beats(), bool midi=false); void cut_copy_regions (Editing::CutCopyOp, RegionSelection&); void cut_copy_ranges (Editing::CutCopyOp); void cut_copy_midi (Editing::CutCopyOp); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 965092e65f..9cf0f05b60 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5229,9 +5229,9 @@ framecnt_t NoteCreateDrag::grid_frames (framepos_t t) const { bool success; - Evoral::MusicalTime grid_beats = _editor->get_grid_type_as_beats (success, t); + Evoral::Beats grid_beats = _editor->get_grid_type_as_beats (success, t); if (!success) { - grid_beats = Evoral::MusicalTime(1); + grid_beats = Evoral::Beats(1); } return _region_view->region_beats_to_region_frames (grid_beats); @@ -5288,13 +5288,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); - Evoral::MusicalTime const one_tick = Evoral::MusicalTime::ticks(1); + Evoral::Beats const one_tick = Evoral::Beats::ticks(1); if (_editor->snap_mode() == SnapNormal && length < g) { length = g; } - Evoral::MusicalTime length_beats = max ( + Evoral::Beats length_beats = max ( one_tick, _region_view->region_frames_to_region_beats (length) - one_tick); _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 7c8d3efb73..529a524d8c 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -3968,7 +3968,7 @@ struct AutomationRecord { * @param op Operation (Cut, Copy or Clear) */ void -Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bool midi) +Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::Beats earliest, bool midi) { if (selection->points.empty ()) { return; @@ -4010,7 +4010,7 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo lists[al].copy->fast_simple_add ((*j)->when, (*j)->value); if (midi) { /* Update earliest MIDI start time in beats */ - earliest = std::min(earliest, Evoral::MusicalTime((*j)->when)); + earliest = std::min(earliest, Evoral::Beats((*j)->when)); } else { /* Update earliest session start time in frames */ start = std::min(start, (*i)->line().session_position(j)); @@ -4019,8 +4019,8 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo /* Snap start time backwards, so copy/paste is snap aligned. */ if (midi) { - if (earliest == Evoral::MusicalTime::max()) { - earliest = Evoral::MusicalTime(); // Weird... don't offset + if (earliest == Evoral::Beats::max()) { + earliest = Evoral::Beats(); // Weird... don't offset } earliest.round_down_to_beat(); } else { @@ -4073,7 +4073,7 @@ Editor::cut_copy_points (Editing::CutCopyOp op, Evoral::MusicalTime earliest, bo void Editor::cut_copy_midi (CutCopyOp op) { - Evoral::MusicalTime earliest = Evoral::MusicalTime::max(); + Evoral::Beats earliest = Evoral::Beats::max(); for (MidiRegionSelection::iterator i = selection->midi_regions.begin(); i != selection->midi_regions.end(); ++i) { MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i); if (mrv) { @@ -4919,14 +4919,14 @@ Editor::strip_region_silence () Command* Editor::apply_midi_note_edit_op_to_region (MidiOperator& op, MidiRegionView& mrv) { - Evoral::Sequence<Evoral::MusicalTime>::Notes selected; + Evoral::Sequence<Evoral::Beats>::Notes selected; mrv.selection_as_notelist (selected, true); - vector<Evoral::Sequence<Evoral::MusicalTime>::Notes> v; + vector<Evoral::Sequence<Evoral::Beats>::Notes> v; v.push_back (selected); - framepos_t pos_frames = mrv.midi_region()->position() - mrv.midi_region()->start(); - Evoral::MusicalTime pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames); + framepos_t pos_frames = mrv.midi_region()->position() - mrv.midi_region()->start(); + Evoral::Beats pos_beats = _session->tempo_map().framewalk_to_beats(0, pos_frames); return op (mrv.midi_region()->model(), pos_beats, v); } @@ -5093,7 +5093,7 @@ Editor::insert_patch_change (bool from_context) */ MidiRegionView* first = dynamic_cast<MidiRegionView*> (rs.front ()); - Evoral::PatchChange<Evoral::MusicalTime> empty (Evoral::MusicalTime(), 0, 0, 0); + Evoral::PatchChange<Evoral::Beats> empty (Evoral::Beats(), 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 c19bd49c37..ea3e91bf2d 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<Evoral::MusicalTime> NoteType; + typedef Evoral::Note<Evoral::Beats> NoteType; Hit (MidiRegionView& region, ArdourCanvas::Item* parent, diff --git a/gtk2_ardour/midi_cut_buffer.cc b/gtk2_ardour/midi_cut_buffer.cc index 94a21ed830..171eea823e 100644 --- a/gtk2_ardour/midi_cut_buffer.cc +++ b/gtk2_ardour/midi_cut_buffer.cc @@ -21,7 +21,7 @@ using namespace ARDOUR; MidiCutBuffer::MidiCutBuffer (Session* s) - : AutomatableSequence<Evoral::MusicalTime> (*s) + : AutomatableSequence<Evoral::Beats> (*s) , _origin (0) { diff --git a/gtk2_ardour/midi_cut_buffer.h b/gtk2_ardour/midi_cut_buffer.h index bfd31fb270..8c92b9a442 100644 --- a/gtk2_ardour/midi_cut_buffer.h +++ b/gtk2_ardour/midi_cut_buffer.h @@ -27,10 +27,10 @@ namespace ARDOUR { class Session; } -class MidiCutBuffer : public ARDOUR::AutomatableSequence<Evoral::MusicalTime> +class MidiCutBuffer : public ARDOUR::AutomatableSequence<Evoral::Beats> { public: - typedef Evoral::MusicalTime TimeType; + typedef Evoral::Beats TimeType; MidiCutBuffer (ARDOUR::Session*); ~MidiCutBuffer(); diff --git a/gtk2_ardour/midi_list_editor.cc b/gtk2_ardour/midi_list_editor.cc index ab282f2a23..4c7a30cdd9 100644 --- a/gtk2_ardour/midi_list_editor.cc +++ b/gtk2_ardour/midi_list_editor.cc @@ -292,7 +292,7 @@ MidiListEditor::scroll_event (GdkEventScroll* ev) if (note->time() + fdelta >= 0) { cmd->change (note, prop, note->time() + fdelta); } else { - cmd->change (note, prop, Evoral::MusicalTime()); + cmd->change (note, prop, Evoral::Beats()); } break; case MidiModel::NoteDiffCommand::Velocity: @@ -300,10 +300,10 @@ MidiListEditor::scroll_event (GdkEventScroll* ev) break; case MidiModel::NoteDiffCommand::Length: if (note->length().to_double() + fdelta >= - Evoral::MusicalTime::tick().to_double()) { + Evoral::Beats::tick().to_double()) { cmd->change (note, prop, note->length() + fdelta); } else { - cmd->change (note, prop, Evoral::MusicalTime::tick()); + cmd->change (note, prop, Evoral::Beats::tick()); } break; case MidiModel::NoteDiffCommand::Channel: @@ -335,7 +335,7 @@ MidiListEditor::scroll_event (GdkEventScroll* ev) if (note->time() + fdelta >= 0) { cmd->change (note, prop, note->time() + fdelta); } else { - cmd->change (note, prop, Evoral::MusicalTime()); + cmd->change (note, prop, Evoral::Beats()); } break; case MidiModel::NoteDiffCommand::Velocity: @@ -343,10 +343,10 @@ MidiListEditor::scroll_event (GdkEventScroll* ev) break; case MidiModel::NoteDiffCommand::Length: if (note->length() + fdelta >= - Evoral::MusicalTime::tick().to_double()) { + Evoral::Beats::tick().to_double()) { cmd->change (note, prop, note->length() + fdelta); } else { - cmd->change (note, prop, Evoral::MusicalTime::tick()); + cmd->change (note, prop, Evoral::Beats::tick()); } break; case MidiModel::NoteDiffCommand::Channel: @@ -773,7 +773,7 @@ MidiListEditor::redisplay_model () row[columns.start] = ss.str(); bbt.bars = 0; - const Evoral::MusicalTime dur = (*i)->end_time() - (*i)->time(); + const Evoral::Beats dur = (*i)->end_time() - (*i)->time(); bbt.beats = dur.get_beats (); bbt.ticks = dur.get_ticks (); diff --git a/gtk2_ardour/midi_list_editor.h b/gtk2_ardour/midi_list_editor.h index f8d2ce9432..9ff413946c 100644 --- a/gtk2_ardour/midi_list_editor.h +++ b/gtk2_ardour/midi_list_editor.h @@ -45,7 +45,7 @@ namespace ARDOUR { class MidiListEditor : public ArdourWindow { public: - typedef Evoral::Note<Evoral::MusicalTime> NoteType; + typedef Evoral::Note<Evoral::Beats> NoteType; MidiListEditor(ARDOUR::Session*, boost::shared_ptr<ARDOUR::MidiRegion>, boost::shared_ptr<ARDOUR::MidiTrack>); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 95f572072e..eedf67836e 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -547,12 +547,12 @@ MidiRegionView::button_release (GdkEventButton* ev) event_y = ev->y; group->canvas_to_item (event_x, event_y); - Evoral::MusicalTime beats = get_grid_beats(editor.pixel_to_sample(event_x)); + Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x)); /* 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 -= Evoral::MusicalTime::tick(); + beats -= Evoral::Beats::tick(); create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true); } @@ -561,12 +561,12 @@ MidiRegionView::button_release (GdkEventButton* ev) } case MouseDraw: { - Evoral::MusicalTime beats = get_grid_beats(editor.pixel_to_sample(event_x)); + Evoral::Beats beats = get_grid_beats(editor.pixel_to_sample(event_x)); /* 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 -= Evoral::MusicalTime::tick(); + beats -= Evoral::Beats::tick(); create_note_at (editor.pixel_to_sample (event_x), event_y, beats, true); @@ -732,7 +732,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, Evoral::MusicalTime(), start, end); + change_note_lengths (fine, shorter, Evoral::Beats(), start, end); return true; @@ -915,7 +915,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, Evoral::MusicalTime length, bool snap_t) +MidiRegionView::create_note_at (framepos_t t, double y, Evoral::Beats length, bool snap_t) { if (length < 2 * DBL_EPSILON) { return; @@ -1033,7 +1033,7 @@ MidiRegionView::note_diff_add_change (NoteBase* ev, void MidiRegionView::note_diff_add_change (NoteBase* ev, MidiModel::NoteDiffCommand::Property property, - Evoral::MusicalTime val) + Evoral::Beats val) { if (_note_diff_command) { _note_diff_command->change (ev->note(), property, val); @@ -1101,7 +1101,7 @@ MidiRegionView::find_canvas_note (boost::shared_ptr<NoteType> note) } void -MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::MusicalTime>::NoteOperator op, uint8_t val, int chan_mask) +MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask) { MidiModel::Notes notes; _model->get_notes (notes, op, val, chan_mask); @@ -1259,8 +1259,8 @@ MidiRegionView::display_sysexes() if (!ARDOUR_UI::config()->get_never_display_periodic_midi()) { for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { - const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::MusicalTime> > mev = - boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::MusicalTime> > (*i); + const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::Beats> > mev = + boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::Beats> > (*i); if (mev) { if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { @@ -1292,10 +1292,10 @@ MidiRegionView::display_sysexes() for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { - const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::MusicalTime> > mev = - boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::MusicalTime> > (*i); + const boost::shared_ptr<const Evoral::MIDIEvent<Evoral::Beats> > mev = + boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::Beats> > (*i); - Evoral::MusicalTime time = (*i)->time(); + Evoral::Beats time = (*i)->time(); if (mev) { if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { @@ -1529,7 +1529,7 @@ MidiRegionView::end_write() /** Resolve an active MIDI note (while recording). */ void -MidiRegionView::resolve_note(uint8_t note, Evoral::MusicalTime end_time) +MidiRegionView::resolve_note(uint8_t note, Evoral::Beats end_time) { if (midi_view()->note_mode() != Sustained) { return; @@ -1797,7 +1797,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) void MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, - Evoral::MusicalTime pos, Evoral::MusicalTime len) + Evoral::Beats pos, Evoral::Beats len) { boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity)); @@ -1826,7 +1826,7 @@ MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity } void -MidiRegionView::step_sustain (Evoral::MusicalTime beats) +MidiRegionView::step_sustain (Evoral::Beats beats) { change_note_lengths (false, false, beats, false, true); } @@ -1879,13 +1879,13 @@ MidiRegionView::patch_change_to_patch_key (MidiModel::PatchChangePtr p) /// Return true iff @p pc applies to the given time on the given channel. static bool -patch_applies (const ARDOUR::MidiModel::constPatchChangePtr pc, Evoral::MusicalTime time, uint8_t channel) +patch_applies (const ARDOUR::MidiModel::constPatchChangePtr pc, Evoral::Beats time, uint8_t channel) { return pc->time() <= time && pc->channel() == channel; } void -MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const +MidiRegionView::get_patch_key_at (Evoral::Beats 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); @@ -1927,7 +1927,7 @@ MidiRegionView::change_patch_change (PatchChange& pc, const MIDI::Name::PatchPri } void -MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const Evoral::PatchChange<Evoral::MusicalTime> & new_change) +MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const Evoral::PatchChange<Evoral::Beats> & new_change) { MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("alter patch change")); @@ -1959,13 +1959,13 @@ MidiRegionView::change_patch_change (MidiModel::PatchChangePtr old_change, const * MidiTimeAxisView::get_channel_for_add()) */ void -MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::MusicalTime> const & patch) +MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::Beats> const & patch) { MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview); MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("add patch change")); c->add (MidiModel::PatchChangePtr ( - new Evoral::PatchChange<Evoral::MusicalTime> ( + new Evoral::PatchChange<Evoral::Beats> ( absolute_frames_to_source_beats (_region->position() + t), mtv->get_channel_for_add(), patch.program(), patch.bank() ) @@ -1979,7 +1979,7 @@ MidiRegionView::add_patch_change (framecnt_t t, Evoral::PatchChange<Evoral::Musi } void -MidiRegionView::move_patch_change (PatchChange& pc, Evoral::MusicalTime t) +MidiRegionView::move_patch_change (PatchChange& pc, Evoral::Beats t) { MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("move patch change")); c->change_time (pc.patch (), t); @@ -2259,8 +2259,8 @@ MidiRegionView::note_selected (NoteBase* ev, bool add, bool extend) } else { /* find end of latest note selected, select all between that and the start of "ev" */ - Evoral::MusicalTime earliest = Evoral::MaxMusicalTime; - Evoral::MusicalTime latest = Evoral::MusicalTime(); + Evoral::Beats earliest = Evoral::MaxBeats; + Evoral::Beats latest = Evoral::Beats(); for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { if ((*i)->note()->end_time() > latest) { @@ -2418,7 +2418,7 @@ MidiRegionView::move_selection(double dx, double dy, double cumulative_dy) { typedef vector<boost::shared_ptr<NoteType> > PossibleChord; PossibleChord to_play; - Evoral::MusicalTime earliest = Evoral::MaxMusicalTime; + Evoral::Beats earliest = Evoral::MaxBeats; for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { if ((*i)->note()->time() < earliest) { @@ -2491,7 +2491,7 @@ MidiRegionView::note_dropped(NoteBase *, frameoffset_t dt, int8_t dnote) for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) { framepos_t new_frames = source_beats_to_absolute_frames ((*i)->note()->time()) + dt; - Evoral::MusicalTime new_time = absolute_frames_to_source_beats (new_frames); + Evoral::Beats new_time = absolute_frames_to_source_beats (new_frames); if (new_time < 0) { continue; @@ -2554,7 +2554,7 @@ MidiRegionView::get_end_position_pixels() } framepos_t -MidiRegionView::source_beats_to_absolute_frames(Evoral::MusicalTime beats) const +MidiRegionView::source_beats_to_absolute_frames(Evoral::Beats beats) const { /* the time converter will return the frame corresponding to `beats' relative to the start of the source. The start of the source @@ -2564,7 +2564,7 @@ MidiRegionView::source_beats_to_absolute_frames(Evoral::MusicalTime beats) const return source_start + _source_relative_time_converter.to (beats); } -Evoral::MusicalTime +Evoral::Beats MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const { /* the `frames' argument needs to be converted into a frame count @@ -2576,12 +2576,12 @@ MidiRegionView::absolute_frames_to_source_beats(framepos_t frames) const } framepos_t -MidiRegionView::region_beats_to_region_frames(Evoral::MusicalTime beats) const +MidiRegionView::region_beats_to_region_frames(Evoral::Beats beats) const { return _region_relative_time_converter.to(beats); } -Evoral::MusicalTime +Evoral::Beats MidiRegionView::region_frames_to_region_beats(framepos_t frames) const { return _region_relative_time_converter.from(frames); @@ -2678,9 +2678,9 @@ MidiRegionView::update_resizing (NoteBase* primary, bool at_front, double delta_ } if (!cursor_set) { - const double snapped_x = snap_pixel_to_sample (current_x); - Evoral::MusicalTime beats = region_frames_to_region_beats (snapped_x); - Evoral::MusicalTime len = Evoral::MusicalTime(); + const double snapped_x = snap_pixel_to_sample (current_x); + Evoral::Beats beats = region_frames_to_region_beats (snapped_x); + Evoral::Beats len = Evoral::Beats(); if (at_front) { if (beats < canvas_note->note()->end_time()) { @@ -2747,12 +2747,12 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ current_x = snap_pixel_to_sample (current_x) + _region->start (); /* and then to beats */ - const Evoral::MusicalTime x_beats = region_frames_to_region_beats (current_x); + const Evoral::Beats x_beats = region_frames_to_region_beats (current_x); if (at_front && x_beats < canvas_note->note()->end_time()) { note_diff_add_change (canvas_note, MidiModel::NoteDiffCommand::StartTime, x_beats); - Evoral::MusicalTime len = canvas_note->note()->time() - x_beats; + Evoral::Beats len = canvas_note->note()->time() - x_beats; len += canvas_note->note()->length(); if (!!len) { @@ -2761,7 +2761,7 @@ MidiRegionView::commit_resizing (NoteBase* primary, bool at_front, double delta_ } if (!at_front) { - const Evoral::MusicalTime len = x_beats - canvas_note->note()->time(); + const Evoral::Beats len = x_beats - canvas_note->note()->time(); if (!!len) { /* XXX convert to beats */ @@ -2821,12 +2821,12 @@ MidiRegionView::change_note_note (NoteBase* event, int8_t note, bool relative) } void -MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evoral::MusicalTime end_delta) +MidiRegionView::trim_note (NoteBase* event, Evoral::Beats front_delta, Evoral::Beats end_delta) { bool change_start = false; bool change_length = false; - Evoral::MusicalTime new_start; - Evoral::MusicalTime new_length; + Evoral::Beats new_start; + Evoral::Beats new_length; /* NOTE: the semantics of the two delta arguments are slightly subtle: @@ -2841,7 +2841,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo if (front_delta < 0) { if (event->note()->time() < -front_delta) { - new_start = Evoral::MusicalTime(); + new_start = Evoral::Beats(); } else { new_start = event->note()->time() + front_delta; // moves earlier } @@ -2856,7 +2856,7 @@ MidiRegionView::trim_note (NoteBase* event, Evoral::MusicalTime front_delta, Evo } else { - Evoral::MusicalTime new_pos = event->note()->time() + front_delta; + Evoral::Beats new_pos = event->note()->time() + front_delta; if (new_pos < event->note()->end_time()) { new_start = event->note()->time() + front_delta; @@ -2915,14 +2915,14 @@ MidiRegionView::change_note_channel (NoteBase* event, int8_t chn, bool relative) } void -MidiRegionView::change_note_time (NoteBase* event, Evoral::MusicalTime delta, bool relative) +MidiRegionView::change_note_time (NoteBase* event, Evoral::Beats delta, bool relative) { - Evoral::MusicalTime new_time; + Evoral::Beats new_time; if (relative) { if (delta < 0.0) { if (event->note()->time() < -delta) { - new_time = Evoral::MusicalTime(); + new_time = Evoral::Beats(); } else { new_time = event->note()->time() + delta; } @@ -2937,7 +2937,7 @@ MidiRegionView::change_note_time (NoteBase* event, Evoral::MusicalTime delta, bo } void -MidiRegionView::change_note_length (NoteBase* event, Evoral::MusicalTime t) +MidiRegionView::change_note_length (NoteBase* event, Evoral::Beats t) { note_diff_add_change (event, MidiModel::NoteDiffCommand::Length, t); } @@ -3049,11 +3049,11 @@ 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) +MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::Beats delta, bool start, bool end) { if (!delta) { if (fine) { - delta = Evoral::MusicalTime(1.0/128.0); + delta = Evoral::Beats(1.0/128.0); } else { /* grab the current grid distance */ delta = get_grid_beats(_region->position()); @@ -3073,8 +3073,8 @@ MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTim /* note the negation of the delta for start */ trim_note (*i, - (start ? -delta : Evoral::MusicalTime()), - (end ? delta : Evoral::MusicalTime())); + (start ? -delta : Evoral::Beats()), + (end ? delta : Evoral::Beats())); i = next; } @@ -3094,13 +3094,13 @@ MidiRegionView::nudge_notes (bool forward, bool fine) into a vector and sort before using the first one. */ - const framepos_t ref_point = source_beats_to_absolute_frames ((*(_selection.begin()))->note()->time()); - Evoral::MusicalTime delta; + const framepos_t ref_point = source_beats_to_absolute_frames ((*(_selection.begin()))->note()->time()); + Evoral::Beats delta; if (!fine) { /* non-fine, move by 1 bar regardless of snap */ - delta = Evoral::MusicalTime(trackview.session()->tempo_map().meter_at(ref_point).divisions_per_bar()); + delta = Evoral::Beats(trackview.session()->tempo_map().meter_at(ref_point).divisions_per_bar()); } else if (trackview.editor().snap_mode() == Editing::SnapOff) { @@ -3378,14 +3378,14 @@ MidiRegionView::paste_internal (framepos_t pos, unsigned paste_count, float time start_note_diff_command (_("paste")); - const Evoral::MusicalTime snap_beats = get_grid_beats(pos); - 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 = 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 = Evoral::MusicalTime(); + const Evoral::Beats snap_beats = get_grid_beats(pos); + const Evoral::Beats first_time = (*mcb.notes().begin())->time(); + const Evoral::Beats last_time = (*mcb.notes().rbegin())->end_time(); + const Evoral::Beats duration = last_time - first_time; + const Evoral::Beats snap_duration = duration.snap_to(snap_beats); + const Evoral::Beats paste_offset = snap_duration * paste_count; + const Evoral::Beats pos_beats = absolute_frames_to_source_beats(pos) + paste_offset; + Evoral::Beats end_point = Evoral::Beats(); 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, @@ -3559,9 +3559,9 @@ MidiRegionView::update_ghost_note (double x, double y) framepos_t const f = snap_frame_to_grid_underneath (unsnapped_frame, grid_frames); /* calculate time in beats relative to start of source */ - const Evoral::MusicalTime length = get_grid_beats(unsnapped_frame); - const Evoral::MusicalTime time = std::max( - Evoral::MusicalTime(), + const Evoral::Beats length = get_grid_beats(unsnapped_frame); + const Evoral::Beats time = std::max( + Evoral::Beats(), absolute_frames_to_source_beats (f + _region->position ())); _ghost_note->note()->set_time (time); @@ -3630,9 +3630,9 @@ MidiRegionView::maybe_select_by_position (GdkEventButton* ev, double /*x*/, doub uint16_t chn_mask = mtv->midi_track()->get_playback_channel_mask(); if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchGreaterThanOrEqual, (uint8_t) floor (note), chn_mask); + get_events (e, Evoral::Sequence<Evoral::Beats>::PitchGreaterThanOrEqual, (uint8_t) floor (note), chn_mask); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - get_events (e, Evoral::Sequence<Evoral::MusicalTime>::PitchLessThanOrEqual, (uint8_t) floor (note), chn_mask); + get_events (e, Evoral::Sequence<Evoral::Beats>::PitchLessThanOrEqual, (uint8_t) floor (note), chn_mask); } else { return; } @@ -3677,7 +3677,7 @@ MidiRegionView::enable_display (bool yn) } void -MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos) +MidiRegionView::show_step_edit_cursor (Evoral::Beats pos) { if (_step_edit_cursor == 0) { ArdourCanvas::Item* const group = get_canvas_group(); @@ -3694,7 +3694,7 @@ MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos) } void -MidiRegionView::move_step_edit_cursor (Evoral::MusicalTime pos) +MidiRegionView::move_step_edit_cursor (Evoral::Beats pos) { _step_edit_cursor_position = pos; @@ -3714,7 +3714,7 @@ MidiRegionView::hide_step_edit_cursor () } void -MidiRegionView::set_step_edit_cursor_width (Evoral::MusicalTime beats) +MidiRegionView::set_step_edit_cursor_width (Evoral::Beats beats) { _step_edit_cursor_width = beats; @@ -3758,12 +3758,12 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w) } /* convert from session frames to source beats */ - Evoral::MusicalTime const time_beats = _source_relative_time_converter.from( + Evoral::Beats const time_beats = _source_relative_time_converter.from( ev.time() - src->timeline_position() + _region->start()); if (ev.type() == MIDI_CMD_NOTE_ON) { boost::shared_ptr<NoteType> note ( - new NoteType (ev.channel(), time_beats, Evoral::MusicalTime(), ev.note(), ev.velocity())); + new NoteType (ev.channel(), time_beats, Evoral::Beats(), ev.note(), ev.velocity())); add_note (note, true); @@ -3916,7 +3916,7 @@ MidiRegionView::snap_frame_to_grid_underneath (framepos_t p, framecnt_t& grid_fr { PublicEditor& editor = trackview.editor (); - const Evoral::MusicalTime grid_beats = get_grid_beats(p); + const Evoral::Beats grid_beats = get_grid_beats(p); grid_frames = region_beats_to_region_frames (grid_beats); @@ -3965,14 +3965,14 @@ MidiRegionView::get_selected_channels () const } -Evoral::MusicalTime +Evoral::Beats MidiRegionView::get_grid_beats(framepos_t pos) const { - PublicEditor& editor = trackview.editor(); - bool success = false; - Evoral::MusicalTime beats = editor.get_grid_type_as_beats(success, pos); + PublicEditor& editor = trackview.editor(); + bool success = false; + Evoral::Beats beats = editor.get_grid_type_as_beats(success, pos); if (!success) { - beats = Evoral::MusicalTime(1); + beats = Evoral::Beats(1); } return beats; } diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 02d67e6d64..4f64e4410f 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -66,8 +66,8 @@ class CursorContext; class MidiRegionView : public RegionView { public: - typedef Evoral::Note<Evoral::MusicalTime> NoteType; - typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; + typedef Evoral::Note<Evoral::Beats> NoteType; + typedef Evoral::Sequence<Evoral::Beats>::Notes Notes; MidiRegionView (ArdourCanvas::Container* parent, RouteTimeAxisView& tv, @@ -100,8 +100,8 @@ public: { return midi_view()->midi_view(); } void step_add_note (uint8_t channel, uint8_t number, uint8_t velocity, - Evoral::MusicalTime pos, Evoral::MusicalTime len); - void step_sustain (Evoral::MusicalTime beats); + Evoral::Beats pos, Evoral::Beats len); + void step_sustain (Evoral::Beats beats); void set_height (double); void apply_note_range(uint8_t lowest, uint8_t highest, bool force=false); @@ -110,17 +110,17 @@ public: uint32_t get_fill_color() const; void color_handler (); - void show_step_edit_cursor (Evoral::MusicalTime pos); - void move_step_edit_cursor (Evoral::MusicalTime pos); + void show_step_edit_cursor (Evoral::Beats pos); + void move_step_edit_cursor (Evoral::Beats pos); void hide_step_edit_cursor (); - void set_step_edit_cursor_width (Evoral::MusicalTime beats); + void set_step_edit_cursor_width (Evoral::Beats beats); void redisplay_model(); GhostRegion* add_ghost (TimeAxisView&); void add_note(const boost::shared_ptr<NoteType> note, bool visible); - void resolve_note(uint8_t note_num, Evoral::MusicalTime end_time); + void resolve_note(uint8_t note_num, Evoral::Beats end_time); void cut_copy_clear (Editing::CutCopyOp); bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx); @@ -134,7 +134,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 (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const; + void get_patch_key_at (Evoral::Beats time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const; /** Convert a given PatchChange into a PatchPrimaryKey */ @@ -145,10 +145,10 @@ public: * @param new_patch new patch */ void change_patch_change (PatchChange& old_patch, const MIDI::Name::PatchPrimaryKey& new_patch); - void change_patch_change (ARDOUR::MidiModel::PatchChangePtr, Evoral::PatchChange<Evoral::MusicalTime> const &); + void change_patch_change (ARDOUR::MidiModel::PatchChangePtr, Evoral::PatchChange<Evoral::Beats> const &); - void add_patch_change (framecnt_t, Evoral::PatchChange<Evoral::MusicalTime> const &); - void move_patch_change (PatchChange &, Evoral::MusicalTime); + void add_patch_change (framecnt_t, Evoral::PatchChange<Evoral::Beats> const &); + void move_patch_change (PatchChange &, Evoral::Beats); void delete_patch_change (PatchChange *); void edit_patch_change (PatchChange *); @@ -176,7 +176,7 @@ public: void start_note_diff_command (std::string name = "midi edit"); void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, uint8_t val); - void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, Evoral::MusicalTime val); + void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, Evoral::Beats val); void note_diff_add_note (const boost::shared_ptr<NoteType> note, bool selected, bool show_velocity = false); void note_diff_remove_note (NoteBase* ev); @@ -263,22 +263,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(Evoral::MusicalTime beats) const; + framepos_t region_beats_to_region_frames(Evoral::Beats beats) const; /** Convert a timestamp in beats into absolute frames */ - framepos_t region_beats_to_absolute_frames(Evoral::MusicalTime beats) const { + framepos_t region_beats_to_absolute_frames(Evoral::Beats beats) const { return _region->position() + region_beats_to_region_frames (beats); } /** Convert a timestamp in frames to beats (both relative to region position) */ - Evoral::MusicalTime region_frames_to_region_beats(framepos_t) const; + Evoral::Beats 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(Evoral::MusicalTime beats) const; + framepos_t source_beats_to_absolute_frames(Evoral::Beats beats) const; /** Convert a timestamp in beats measured from source start into region-relative frames */ - framepos_t source_beats_to_region_frames(Evoral::MusicalTime beats) const { + framepos_t source_beats_to_region_frames(Evoral::Beats beats) const { return source_beats_to_absolute_frames (beats) - _region->position(); } /** Convert a timestamp in absolute frames to beats measured from source start*/ - Evoral::MusicalTime absolute_frames_to_source_beats(framepos_t) const; + Evoral::Beats absolute_frames_to_source_beats(framepos_t) const; ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const { return _region_relative_time_converter; @@ -290,7 +290,7 @@ public: void goto_previous_note (bool add_to_selection); void goto_next_note (bool add_to_selection); - void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end); + void change_note_lengths (bool, bool, Evoral::Beats beats, bool start, bool end); void change_velocities (bool up, bool fine, bool allow_smush, bool all_together); void transpose (bool up, bool fine, bool allow_smush); void nudge_notes (bool forward, bool fine); @@ -320,7 +320,7 @@ public: * \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 create_note_at (framepos_t t, double y, Evoral::Beats length, bool snap_t); void clear_selection (bool signal = true) { clear_selection_except (0, signal); } @@ -414,8 +414,8 @@ private: double _last_ghost_x; double _last_ghost_y; ArdourCanvas::Rectangle* _step_edit_cursor; - Evoral::MusicalTime _step_edit_cursor_width; - Evoral::MusicalTime _step_edit_cursor_position; + Evoral::Beats _step_edit_cursor_width; + Evoral::Beats _step_edit_cursor_position; NoteBase* _channel_selection_scoped_note; /** A group used to temporarily reparent _note_group to during start trims, so @@ -477,7 +477,7 @@ private: void drop_down_keys (); void maybe_select_by_position (GdkEventButton* ev, double x, double y); - void get_events (Events& e, Evoral::Sequence<Evoral::MusicalTime>::NoteOperator op, uint8_t val, int chan_mask = 0); + void get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask = 0); void display_patch_changes_on_channel (uint8_t, bool); @@ -485,7 +485,7 @@ private: void data_recorded (boost::weak_ptr<ARDOUR::MidiSource>); /** Get grid type as beats, or default to 1 if not snapped to beats. */ - Evoral::MusicalTime get_grid_beats(framepos_t pos) const; + Evoral::Beats get_grid_beats(framepos_t pos) const; void remove_ghost_note (); void mouse_mode_changed (); diff --git a/gtk2_ardour/note.h b/gtk2_ardour/note.h index 71faeb53fb..e763ea95f8 100644 --- a/gtk2_ardour/note.h +++ b/gtk2_ardour/note.h @@ -32,7 +32,7 @@ namespace ArdourCanvas { class Note : public NoteBase { public: - typedef Evoral::Note<Evoral::MusicalTime> NoteType; + typedef Evoral::Note<Evoral::Beats> NoteType; Note (MidiRegionView& region, ArdourCanvas::Item* parent, diff --git a/gtk2_ardour/note_base.h b/gtk2_ardour/note_base.h index 150837e193..9a135e4d9c 100644 --- a/gtk2_ardour/note_base.h +++ b/gtk2_ardour/note_base.h @@ -54,7 +54,7 @@ namespace ArdourCanvas { class NoteBase : public sigc::trackable { public: - typedef Evoral::Note<Evoral::MusicalTime> NoteType; + typedef Evoral::Note<Evoral::Beats> NoteType; NoteBase (MidiRegionView& region, bool, const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>()); virtual ~NoteBase (); diff --git a/gtk2_ardour/note_player.h b/gtk2_ardour/note_player.h index 4a1df8c319..9127842732 100644 --- a/gtk2_ardour/note_player.h +++ b/gtk2_ardour/note_player.h @@ -31,7 +31,7 @@ namespace ARDOUR { class NotePlayer : public sigc::trackable { public: - typedef Evoral::Note<Evoral::MusicalTime> NoteType; + typedef Evoral::Note<Evoral::Beats> NoteType; NotePlayer (boost::shared_ptr<ARDOUR::MidiTrack>); ~NotePlayer (); diff --git a/gtk2_ardour/patch_change_dialog.cc b/gtk2_ardour/patch_change_dialog.cc index 9072801c83..05cbaab459 100644 --- a/gtk2_ardour/patch_change_dialog.cc +++ b/gtk2_ardour/patch_change_dialog.cc @@ -41,12 +41,12 @@ using namespace Gtkmm2ext; /** @param tc If non-0, a time converter for this patch change. If 0, time control will be desensitized */ PatchChangeDialog::PatchChangeDialog ( - const ARDOUR::BeatsFramesConverter* tc, - ARDOUR::Session* session, - Evoral::PatchChange<Evoral::MusicalTime> const & patch, - ARDOUR::InstrumentInfo& info, - const Gtk::BuiltinStockID& ok, - bool allow_delete) + const ARDOUR::BeatsFramesConverter* tc, + ARDOUR::Session* session, + Evoral::PatchChange<Evoral::Beats> const & patch, + ARDOUR::InstrumentInfo& info, + const Gtk::BuiltinStockID& ok, + bool allow_delete) : ArdourDialog (_("Patch Change"), true) , _time_converter (tc) , _info (info) @@ -139,16 +139,16 @@ PatchChangeDialog::instrument_info_changed () fill_patch_combo (); } -Evoral::PatchChange<Evoral::MusicalTime> +Evoral::PatchChange<Evoral::Beats> PatchChangeDialog::patch () const { - Evoral::MusicalTime t = Evoral::MusicalTime(); + Evoral::Beats t = Evoral::Beats(); if (_time_converter) { t = _time_converter->from (_time.current_time ()); } - return Evoral::PatchChange<Evoral::MusicalTime> ( + return Evoral::PatchChange<Evoral::Beats> ( t, _channel.get_value_as_int() - 1, _program.get_value_as_int() - 1, diff --git a/gtk2_ardour/patch_change_dialog.h b/gtk2_ardour/patch_change_dialog.h index ed0f49df34..d19234d2c4 100644 --- a/gtk2_ardour/patch_change_dialog.h +++ b/gtk2_ardour/patch_change_dialog.h @@ -43,13 +43,13 @@ public: PatchChangeDialog ( const ARDOUR::BeatsFramesConverter *, ARDOUR::Session *, - Evoral::PatchChange<Evoral::MusicalTime> const &, + Evoral::PatchChange<Evoral::Beats> const &, ARDOUR::InstrumentInfo&, const Gtk::BuiltinStockID &, bool allow_delete = false ); - Evoral::PatchChange<Evoral::MusicalTime> patch () const; + Evoral::PatchChange<Evoral::Beats> patch () const; private: void fill_bank_combo (); diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index c126c1bab9..974799c8c0 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -289,7 +289,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0; virtual framecnt_t get_nudge_distance (framepos_t pos, framecnt_t& next) = 0; virtual framecnt_t get_paste_offset (framepos_t pos, unsigned paste_count, framecnt_t duration) = 0; - virtual Evoral::MusicalTime get_grid_type_as_beats (bool& success, framepos_t position) = 0; + virtual Evoral::Beats get_grid_type_as_beats (bool& success, framepos_t position) = 0; virtual void edit_notes (MidiRegionView*) = 0; virtual void queue_visual_videotimeline_update () = 0; diff --git a/gtk2_ardour/quantize_dialog.cc b/gtk2_ardour/quantize_dialog.cc index 45a96e1fc3..82e3a1abd5 100644 --- a/gtk2_ardour/quantize_dialog.cc +++ b/gtk2_ardour/quantize_dialog.cc @@ -131,7 +131,7 @@ QuantizeDialog::grid_size_to_musical_time (const string& txt) const if (txt == "main grid") { bool success; - Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0); + Evoral::Beats b = editor.get_grid_type_as_beats (success, 0); if (!success) { return 1.0; } diff --git a/gtk2_ardour/step_editor.cc b/gtk2_ardour/step_editor.cc index ec525b84ed..db34dcbf84 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 = Evoral::MusicalTime(); + _step_edit_chord_duration = Evoral::Beats(); 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 = Evoral::MusicalTime(); + _step_edit_chord_duration = Evoral::Beats(); step_edit_region.reset (); step_edit_region_view = 0; last_added_pitch = -1; - last_added_end = Evoral::MusicalTime(); + last_added_end = Evoral::Beats(); 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], Evoral::MusicalTime()); + step_add_note (buf[0] & 0xf, buf[1], buf[2], Evoral::Beats()); } } } @@ -216,7 +216,7 @@ StepEditor::step_add_program_change (uint8_t /*channel*/, uint8_t /*program*/) } void -StepEditor::step_edit_sustain (Evoral::MusicalTime beats) +StepEditor::step_edit_sustain (Evoral::Beats beats) { if (step_edit_region_view) { step_edit_region_view->step_sustain (beats); @@ -224,7 +224,7 @@ StepEditor::step_edit_sustain (Evoral::MusicalTime beats) } void -StepEditor::move_step_edit_beat_pos (Evoral::MusicalTime beats) +StepEditor::move_step_edit_beat_pos (Evoral::Beats beats) { if (beats > 0.0) { step_edit_beat_pos = min (step_edit_beat_pos + beats, @@ -233,14 +233,14 @@ 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 = Evoral::MusicalTime(); + step_edit_beat_pos = Evoral::Beats(); } } step_edit_region_view->move_step_edit_cursor (step_edit_beat_pos); } int -StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::MusicalTime beat_duration) +StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evoral::Beats beat_duration) { /* do these things in case undo removed the step edit region */ @@ -283,8 +283,8 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo _editor.reset_x_origin (fpos - (_editor.current_page_samples()/4)); } - Evoral::MusicalTime at = step_edit_beat_pos; - Evoral::MusicalTime len = beat_duration; + Evoral::Beats at = step_edit_beat_pos; + Evoral::Beats len = beat_duration; if ((last_added_pitch >= 0) && (pitch == last_added_pitch) && (last_added_end == 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 += Evoral::MusicalTime::ticks(1); - len -= Evoral::MusicalTime::ticks(1); + at += Evoral::Beats::ticks(1); + len -= Evoral::Beats::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 += Evoral::MusicalTime::ticks(1); // tiny, but no longer overlapping + step_edit_beat_pos += Evoral::Beats::ticks(1); // tiny, but no longer overlapping _step_edit_chord_duration = max (_step_edit_chord_duration, beat_duration); } @@ -321,7 +321,7 @@ StepEditor::step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, Evo } void -StepEditor::set_step_edit_cursor_width (Evoral::MusicalTime beats) +StepEditor::set_step_edit_cursor_width (Evoral::Beats beats) { if (step_edit_region_view) { step_edit_region_view->set_step_edit_cursor_width (beats); @@ -365,7 +365,7 @@ StepEditor::step_edit_toggle_chord () } void -StepEditor::step_edit_rest (Evoral::MusicalTime beats) +StepEditor::step_edit_rest (Evoral::Beats beats) { bool success; @@ -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 = Evoral::MusicalTime(-1); + step_edit_beat_pos = Evoral::Beats(-1); } } diff --git a/gtk2_ardour/step_editor.h b/gtk2_ardour/step_editor.h index 82df743017..299025d292 100644 --- a/gtk2_ardour/step_editor.h +++ b/gtk2_ardour/step_editor.h @@ -45,22 +45,22 @@ class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable virtual ~StepEditor (); void check_step_edit (); - void step_edit_rest (Evoral::MusicalTime beats); + void step_edit_rest (Evoral::Beats beats); void step_edit_beat_sync (); void step_edit_bar_sync (); int step_add_bank_change (uint8_t channel, uint8_t bank); int step_add_program_change (uint8_t channel, uint8_t program); int step_add_note (uint8_t channel, uint8_t pitch, uint8_t velocity, - Evoral::MusicalTime beat_duration); - void step_edit_sustain (Evoral::MusicalTime beats); + Evoral::Beats beat_duration); + void step_edit_sustain (Evoral::Beats beats); bool step_edit_within_triplet () const; void step_edit_toggle_triplet (); bool step_edit_within_chord () const; void step_edit_toggle_chord (); void reset_step_edit_beat_pos (); void resync_step_edit_to_edit_point (); - void move_step_edit_beat_pos (Evoral::MusicalTime beats); - void set_step_edit_cursor_width (Evoral::MusicalTime beats); + void move_step_edit_beat_pos (Evoral::Beats beats); + void set_step_edit_cursor_width (Evoral::Beats beats); std::string name() const; @@ -69,19 +69,19 @@ class StepEditor : public PBD::ScopedConnectionList, public sigc::trackable private: ARDOUR::framepos_t step_edit_insert_position; - Evoral::MusicalTime step_edit_beat_pos; + Evoral::Beats step_edit_beat_pos; boost::shared_ptr<ARDOUR::MidiRegion> step_edit_region; MidiRegionView* step_edit_region_view; uint8_t _step_edit_triplet_countdown; bool _step_edit_within_chord; - Evoral::MusicalTime _step_edit_chord_duration; + Evoral::Beats _step_edit_chord_duration; PBD::ScopedConnection step_edit_region_connection; PublicEditor& _editor; boost::shared_ptr<ARDOUR::MidiTrack> _track; StepEntry* step_editor; MidiTimeAxisView& _mtv; int8_t last_added_pitch; - Evoral::MusicalTime last_added_end; + Evoral::Beats last_added_end; void region_removed (boost::weak_ptr<ARDOUR::Region>); void playlist_changed (); diff --git a/gtk2_ardour/step_entry.cc b/gtk2_ardour/step_entry.cc index d7b177949f..ace02c0c68 100644 --- a/gtk2_ardour/step_entry.cc +++ b/gtk2_ardour/step_entry.cc @@ -526,10 +526,10 @@ StepEntry::on_key_release_event (GdkEventKey* ev) void StepEntry::rest_event_handler () { - se->step_edit_rest (Evoral::MusicalTime()); + se->step_edit_rest (Evoral::Beats()); } -Evoral::MusicalTime +Evoral::Beats StepEntry::note_length () { double base_time = 4.0 / (double) length_divisor_adjustment.get_value(); @@ -549,7 +549,7 @@ StepEntry::note_length () base_time *= 1 + ((dots - 1.0)/dots); } - return Evoral::MusicalTime(base_time); + return Evoral::Beats(base_time); } uint8_t @@ -795,7 +795,7 @@ StepEntry::insert_rest () void StepEntry::insert_grid_rest () { - se->step_edit_rest (Evoral::MusicalTime()); + se->step_edit_rest (Evoral::Beats()); } void diff --git a/gtk2_ardour/step_entry.h b/gtk2_ardour/step_entry.h index 364be67114..bd354f3f66 100644 --- a/gtk2_ardour/step_entry.h +++ b/gtk2_ardour/step_entry.h @@ -41,14 +41,14 @@ class StepEntry : public ArdourWindow void note_off_event_handler (int note); void rest_event_handler (); - Evoral::MusicalTime note_length(); + Evoral::Beats note_length(); uint8_t note_velocity() const; uint8_t note_channel() const; int current_octave () const { return (int) floor (octave_adjustment.get_value()); } private: - Evoral::MusicalTime _current_note_length; + Evoral::Beats _current_note_length; uint8_t _current_note_velocity; Gtk::VBox packer; diff --git a/libs/ardour/ardour/beats_frames_converter.h b/libs/ardour/ardour/beats_frames_converter.h index ada09b1179..908dd1909e 100644 --- a/libs/ardour/ardour/beats_frames_converter.h +++ b/libs/ardour/ardour/beats_frames_converter.h @@ -37,15 +37,15 @@ class TempoMap; * them to the opposite unit, taking tempo changes into account. */ class LIBARDOUR_API BeatsFramesConverter - : public Evoral::TimeConverter<Evoral::MusicalTime,framepos_t> { + : public Evoral::TimeConverter<Evoral::Beats,framepos_t> { public: BeatsFramesConverter (TempoMap& tempo_map, framepos_t origin) - : Evoral::TimeConverter<Evoral::MusicalTime, framepos_t> (origin) + : Evoral::TimeConverter<Evoral::Beats, framepos_t> (origin) , _tempo_map(tempo_map) {} - framepos_t to (Evoral::MusicalTime beats) const; - Evoral::MusicalTime from (framepos_t frames) const; + framepos_t to (Evoral::Beats beats) const; + Evoral::Beats from (framepos_t frames) const; private: TempoMap& _tempo_map; diff --git a/libs/ardour/ardour/legatize.h b/libs/ardour/ardour/legatize.h index 4a170e1a1c..78b384e1c7 100644 --- a/libs/ardour/ardour/legatize.h +++ b/libs/ardour/ardour/legatize.h @@ -39,10 +39,10 @@ public: Legatize(bool shrink_only); ~Legatize(); - typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; + typedef Evoral::Sequence<Evoral::Beats>::Notes Notes; Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model, - Evoral::MusicalTime position, + Evoral::Beats position, std::vector<Notes>& seqs); std::string name() const { return std::string ("legatize"); } diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index b86a7436bb..4214431280 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -52,9 +52,9 @@ class MidiSource; * Because of this MIDI controllers and automatable controllers/widgets/etc * are easily interchangeable. */ -class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::MusicalTime> { +class LIBARDOUR_API MidiModel : public AutomatableSequence<Evoral::Beats> { public: - typedef Evoral::MusicalTime TimeType; + typedef Evoral::Beats TimeType; MidiModel (boost::shared_ptr<MidiSource>); @@ -259,8 +259,8 @@ public: bool write_section_to(boost::shared_ptr<MidiSource> source, const Glib::Threads::Mutex::Lock& source_lock, - Evoral::MusicalTime begin = Evoral::MinMusicalTime, - Evoral::MusicalTime end = Evoral::MaxMusicalTime); + Evoral::Beats begin = Evoral::MinBeats, + Evoral::Beats end = Evoral::MaxBeats); // MidiModel doesn't use the normal AutomationList serialisation code // since controller data is stored in the .mid diff --git a/libs/ardour/ardour/midi_operator.h b/libs/ardour/ardour/midi_operator.h index 36e87b714b..b79544ed61 100644 --- a/libs/ardour/ardour/midi_operator.h +++ b/libs/ardour/ardour/midi_operator.h @@ -38,8 +38,8 @@ class LIBARDOUR_API MidiOperator { virtual ~MidiOperator() {} virtual Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, - Evoral::MusicalTime, - std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&) = 0; + Evoral::Beats, + std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&) = 0; virtual std::string name() const = 0; }; diff --git a/libs/ardour/ardour/midi_playlist_source.h b/libs/ardour/ardour/midi_playlist_source.h index f064553342..6633be3c9e 100644 --- a/libs/ardour/ardour/midi_playlist_source.h +++ b/libs/ardour/ardour/midi_playlist_source.h @@ -45,7 +45,7 @@ public: XMLNode& get_state (); int set_state (const XMLNode&, int version); - void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev); + void append_event_beats(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<Evoral::Beats>& ev); void append_event_frames(const Glib::Threads::Mutex::Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start); void load_model(const Glib::Threads::Mutex::Lock& lock, bool force_reload=false); void destroy_model(const Glib::Threads::Mutex::Lock& lock); diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 2a4e3a6190..ece23b65f0 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -37,8 +37,8 @@ namespace ARDOUR { MidiModel used by the MidiRegion */ LIBARDOUR_API extern PBD::PropertyDescriptor<void*> midi_data; - LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats; - LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats; + LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> start_beats; + LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::Beats> length_beats; } } @@ -114,8 +114,8 @@ class LIBARDOUR_API MidiRegion : public Region private: friend class RegionFactory; - PBD::Property<Evoral::MusicalTime> _start_beats; - PBD::Property<Evoral::MusicalTime> _length_beats; + PBD::Property<Evoral::Beats> _start_beats; + PBD::Property<Evoral::Beats> _length_beats; MidiRegion (const SourceList&); MidiRegion (boost::shared_ptr<const MidiRegion>); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 2b78230a00..8a0c13681d 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -43,7 +43,7 @@ template<typename T> class MidiRingBuffer; class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_shared_from_this<MidiSource> { public: - typedef Evoral::MusicalTime TimeType; + typedef Evoral::Beats TimeType; MidiSource (Session& session, std::string name, Source::Flag flags = Source::Flag(0)); MidiSource (Session& session, const XMLNode&); @@ -59,8 +59,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha */ int write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, - Evoral::MusicalTime begin = Evoral::MinMusicalTime, - Evoral::MusicalTime end = Evoral::MaxMusicalTime); + Evoral::Beats begin = Evoral::MinBeats, + Evoral::Beats end = Evoral::MaxBeats); /** Read the data in a given time range from the MIDI source. * All time stamps in parameters are in audio frames (even if the source has tempo time). @@ -93,8 +93,8 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha * * Caller must ensure that the event is later than the last written event. */ - virtual void append_event_beats(const Lock& lock, - const Evoral::Event<Evoral::MusicalTime>& ev) = 0; + virtual void append_event_beats(const Lock& lock, + const Evoral::Event<Evoral::Beats>& ev) = 0; /** Append a single event with a timestamp in frames. * @@ -132,9 +132,9 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha * etc. */ virtual void mark_midi_streaming_write_completed ( - const Lock& lock, - Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_option, - Evoral::MusicalTime when = Evoral::MusicalTime()); + const Lock& lock, + Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_option, + Evoral::Beats when = Evoral::Beats()); virtual void session_saved(); @@ -205,11 +205,11 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha boost::shared_ptr<MidiModel> _model; bool _writing; - mutable Evoral::Sequence<Evoral::MusicalTime>::const_iterator _model_iter; - mutable bool _model_iter_valid; + mutable Evoral::Sequence<Evoral::Beats>::const_iterator _model_iter; + mutable bool _model_iter_valid; - mutable Evoral::MusicalTime _length_beats; - mutable framepos_t _last_read_end; + mutable Evoral::Beats _length_beats; + mutable framepos_t _last_read_end; /** The total duration of the current capture. */ framepos_t _capture_length; diff --git a/libs/ardour/ardour/midi_state_tracker.h b/libs/ardour/ardour/midi_state_tracker.h index 98611bc722..6690931422 100644 --- a/libs/ardour/ardour/midi_state_tracker.h +++ b/libs/ardour/ardour/midi_state_tracker.h @@ -46,7 +46,7 @@ public: void remove (uint8_t note, uint8_t chn); void resolve_notes (MidiBuffer& buffer, framepos_t time); void resolve_notes (Evoral::EventSink<framepos_t>& buffer, framepos_t time); - void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::MusicalTime time); + void resolve_notes (MidiSource& src, const Glib::Threads::Mutex::Lock& lock, Evoral::Beats time); void dump (std::ostream&); void reset (); bool empty() const { return _on == 0; } diff --git a/libs/ardour/ardour/quantize.h b/libs/ardour/ardour/quantize.h index 09ba5f2aa2..639736b174 100644 --- a/libs/ardour/ardour/quantize.h +++ b/libs/ardour/ardour/quantize.h @@ -35,8 +35,8 @@ public: ~Quantize (); Command* operator() (boost::shared_ptr<ARDOUR::MidiModel>, - Evoral::MusicalTime position, - std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>&); + Evoral::Beats position, + std::vector<Evoral::Sequence<Evoral::Beats>::Notes>&); std::string name() const { return std::string ("quantize"); } private: diff --git a/libs/ardour/ardour/smf_source.h b/libs/ardour/ardour/smf_source.h index d93fdb8506..29c6403694 100644 --- a/libs/ardour/ardour/smf_source.h +++ b/libs/ardour/ardour/smf_source.h @@ -51,14 +51,14 @@ public: return safe_midi_file_extension(path); } - void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::MusicalTime>& ev); + void append_event_beats (const Lock& lock, const Evoral::Event<Evoral::Beats>& ev); void append_event_frames (const Lock& lock, const Evoral::Event<framepos_t>& ev, framepos_t source_start); void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode); void mark_streaming_write_completed (const Lock& lock); void mark_midi_streaming_write_completed (const Lock& lock, - Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption, - Evoral::MusicalTime when = Evoral::MusicalTime()); + Evoral::Sequence<Evoral::Beats>::StuckNoteOption, + Evoral::Beats when = Evoral::Beats()); XMLNode& get_state (); int set_state (const XMLNode&, int version); @@ -77,7 +77,7 @@ public: private: bool _open; - Evoral::MusicalTime _last_ev_time_beats; + Evoral::Beats _last_ev_time_beats; framepos_t _last_ev_time_frames; /** end time (start + duration) of last call to read_unlocked */ mutable framepos_t _smf_last_read_end; diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 19fe5b0b12..f2d314651d 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -276,9 +276,9 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible */ framepos_t framepos_plus_bbt (framepos_t pos, Timecode::BBT_Time b) const; - framepos_t framepos_plus_beats (framepos_t, Evoral::MusicalTime) const; - framepos_t framepos_minus_beats (framepos_t, Evoral::MusicalTime) const; - Evoral::MusicalTime framewalk_to_beats (framepos_t pos, framecnt_t distance) const; + framepos_t framepos_plus_beats (framepos_t, Evoral::Beats) const; + framepos_t framepos_minus_beats (framepos_t, Evoral::Beats) const; + Evoral::Beats framewalk_to_beats (framepos_t pos, framecnt_t distance) const; static const Tempo& default_tempo() { return _default_tempo; } static const Meter& default_meter() { return _default_meter; } diff --git a/libs/ardour/ardour/transform.h b/libs/ardour/ardour/transform.h index 08e4a43521..df77244a17 100644 --- a/libs/ardour/ardour/transform.h +++ b/libs/ardour/ardour/transform.h @@ -50,9 +50,9 @@ namespace ARDOUR { */ class LIBARDOUR_API Transform : public MidiOperator { public: - typedef Evoral::Sequence<Evoral::MusicalTime>::NotePtr NotePtr; - typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes; - typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property; + typedef Evoral::Sequence<Evoral::Beats>::NotePtr NotePtr; + typedef Evoral::Sequence<Evoral::Beats>::Notes Notes; + typedef ARDOUR::MidiModel::NoteDiffCommand::Property Property; /** Context while iterating over notes during transformation. */ struct Context { @@ -132,7 +132,7 @@ public: Transform(const Program& prog); Command* operator()(boost::shared_ptr<ARDOUR::MidiModel> model, - Evoral::MusicalTime position, + Evoral::Beats position, std::vector<Notes>& seqs); std::string name() const { return std::string ("transform"); } diff --git a/libs/ardour/ardour/variant.h b/libs/ardour/ardour/variant.h index 0402ffaa0b..9ecadbfe6a 100644 --- a/libs/ardour/ardour/variant.h +++ b/libs/ardour/ardour/variant.h @@ -57,7 +57,7 @@ public: explicit Variant(int32_t value) : _type(INT) { _int = value; } explicit Variant(int64_t value) : _type(LONG) { _long = value; } - explicit Variant(const Evoral::MusicalTime& beats) + explicit Variant(const Evoral::Beats& beats) : _type(BEATS) , _beats(beats) {} @@ -94,7 +94,7 @@ public: std::min(value, (double)INT64_MAX))); break; case BEATS: - _beats = Evoral::MusicalTime(value); + _beats = Evoral::Beats(value); break; default: _type = NOTHING; @@ -158,19 +158,19 @@ public: return false; } - bool operator==(const Evoral::MusicalTime& v) const { + bool operator==(const Evoral::Beats& v) const { return _type == BEATS && _beats == v; } bool operator!() const { return _type == NOTHING; } - Variant& operator=(Evoral::MusicalTime v) { + Variant& operator=(Evoral::Beats v) { _type = BEATS; _beats = v; return *this; } - const Evoral::MusicalTime& get_beats() const { + const Evoral::Beats& get_beats() const { ensure_type(BEATS); return _beats; } @@ -202,9 +202,9 @@ private: } } - Type _type; ///< Type tag - std::string _string; ///< PATH, STRING, URI - Evoral::MusicalTime _beats; ///< BEATS + Type _type; ///< Type tag + std::string _string; ///< PATH, STRING, URI + Evoral::Beats _beats; ///< BEATS // Union of all primitive numeric types union { diff --git a/libs/ardour/beats_frames_converter.cc b/libs/ardour/beats_frames_converter.cc index b99edbf51e..54db8008da 100644 --- a/libs/ardour/beats_frames_converter.cc +++ b/libs/ardour/beats_frames_converter.cc @@ -31,9 +31,9 @@ namespace ARDOUR { * taking tempo changes into account. */ framepos_t -BeatsFramesConverter::to (Evoral::MusicalTime beats) const +BeatsFramesConverter::to (Evoral::Beats beats) const { - if (beats < Evoral::MusicalTime()) { + if (beats < Evoral::Beats()) { std::cerr << "negative beats passed to BFC: " << beats << std::endl; PBD::stacktrace (std::cerr, 30); return 0; @@ -45,7 +45,7 @@ BeatsFramesConverter::to (Evoral::MusicalTime beats) const * supplied to the constructor. Returns the equivalent number of beats, * taking tempo changes into account. */ -Evoral::MusicalTime +Evoral::Beats BeatsFramesConverter::from (framepos_t frames) const { return _tempo_map.framewalk_to_beats (_origin_b, frames); @@ -60,7 +60,7 @@ DoubleBeatsFramesConverter::to (double beats) const PBD::stacktrace (std::cerr, 30); return 0; } - return _tempo_map.framepos_plus_beats (_origin_b, Evoral::MusicalTime(beats)) - _origin_b; + return _tempo_map.framepos_plus_beats (_origin_b, Evoral::Beats(beats)) - _origin_b; } /** As above, but with beats in double instead (for GUI). */ diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index eb2ed769d1..3ed028ef91 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -392,9 +392,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status, smfs->append_event_beats( source_lock, - Evoral::Event<Evoral::MusicalTime>( + Evoral::Event<Evoral::Beats>( 0, - Evoral::MusicalTime::ticks_at_rate(t, source->ppqn()), + Evoral::Beats::ticks_at_rate(t, source->ppqn()), size, buf)); @@ -407,9 +407,9 @@ write_midi_data_to_new_files (Evoral::SMF* source, ImportStatus& status, /* we wrote something */ - const framepos_t pos = 0; - const Evoral::MusicalTime length_beats = Evoral::MusicalTime::ticks_at_rate(t, source->ppqn()); - BeatsFramesConverter converter(smfs->session().tempo_map(), pos); + const framepos_t pos = 0; + const Evoral::Beats length_beats = Evoral::Beats::ticks_at_rate(t, source->ppqn()); + BeatsFramesConverter converter(smfs->session().tempo_map(), pos); smfs->update_length(pos + converter.to(length_beats.round_up_to_beat())); smfs->mark_streaming_write_completed (source_lock); diff --git a/libs/ardour/legatize.cc b/libs/ardour/legatize.cc index c5506fe6c0..0c118a6a48 100644 --- a/libs/ardour/legatize.cc +++ b/libs/ardour/legatize.cc @@ -31,7 +31,7 @@ Legatize::~Legatize () Command* Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model, - Evoral::MusicalTime position, + Evoral::Beats position, std::vector<Legatize::Notes>& seqs) { MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand(model, "legatize"); @@ -43,10 +43,10 @@ Legatize::operator()(boost::shared_ptr<ARDOUR::MidiModel> model, break; } - const Evoral::MusicalTime new_end = (*next)->time() - Evoral::MusicalTime::tick(); + const Evoral::Beats new_end = (*next)->time() - Evoral::Beats::tick(); if ((*i)->end_time() > new_end || (!_shrink_only && (*i)->end_time() < new_end)) { - const Evoral::MusicalTime new_length(new_end - (*i)->time()); + const Evoral::Beats new_length(new_end - (*i)->time()); cmd->change((*i), MidiModel::NoteDiffCommand::Length, new_length); } diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index e52a7c3ad7..fed0dbc0ce 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -940,14 +940,14 @@ MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen /* set length in beats to entire capture length */ BeatsFramesConverter converter (_session.tempo_map(), capture_info.front()->start); - const Evoral::MusicalTime total_capture_beats = converter.from (total_capture); + const Evoral::Beats total_capture_beats = converter.from (total_capture); _write_source->set_length_beats (total_capture_beats); /* flush to disk: this step differs from the audio path, where all the data is already on disk. */ - _write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, total_capture_beats); + _write_source->mark_midi_streaming_write_completed (source_lock, Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, total_capture_beats); /* we will want to be able to keep (over)writing the source but we don't want it to be removable. this also differs diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 18378f5386..e3226e036f 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -620,7 +620,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change) if ((prop = xml_change->property ("old")) != 0) { istringstream old_str (prop->value()); if (change.property == StartTime || change.property == Length) { - Evoral::MusicalTime old_time; + Evoral::Beats old_time; old_str >> old_time; change.old_value = old_time; } else { @@ -636,7 +636,7 @@ MidiModel::NoteDiffCommand::unmarshal_change (XMLNode *xml_change) if ((prop = xml_change->property ("new")) != 0) { istringstream new_str (prop->value()); if (change.property == StartTime || change.property == Length) { - Evoral::MusicalTime new_time; + Evoral::Beats new_time; new_str >> new_time; change.new_value = Variant(new_time); } else { @@ -1237,7 +1237,7 @@ MidiModel::PatchChangeDiffCommand::unmarshal_patch_change (XMLNode* n) { XMLProperty* prop; Evoral::event_id_t id = 0; - Evoral::MusicalTime time = Evoral::MusicalTime(); + Evoral::Beats time = Evoral::Beats(); int channel = 0; int program = 0; int bank = 0; @@ -1476,8 +1476,8 @@ MidiModel::sync_to_source (const Glib::Threads::Mutex::Lock& source_lock) bool MidiModel::write_section_to (boost::shared_ptr<MidiSource> source, const Glib::Threads::Mutex::Lock& source_lock, - Evoral::MusicalTime begin_time, - Evoral::MusicalTime end_time) + Evoral::Beats begin_time, + Evoral::Beats end_time) { ReadLock lock(read_lock()); MidiStateTracker mst; @@ -1489,12 +1489,12 @@ MidiModel::write_section_to (boost::shared_ptr<MidiSource> source, source->mark_streaming_midi_write_started (source_lock, note_mode()); for (Evoral::Sequence<TimeType>::const_iterator i = begin(TimeType(), true); i != end(); ++i) { - const Evoral::Event<Evoral::MusicalTime>& ev (*i); + const Evoral::Event<Evoral::Beats>& ev (*i); if (ev.time() >= begin_time && ev.time() < end_time) { - const Evoral::MIDIEvent<Evoral::MusicalTime>* mev = - static_cast<const Evoral::MIDIEvent<Evoral::MusicalTime>* > (&ev); + const Evoral::MIDIEvent<Evoral::Beats>* mev = + static_cast<const Evoral::MIDIEvent<Evoral::Beats>* > (&ev); if (!mev) { continue; @@ -2026,7 +2026,7 @@ MidiModel::transpose (TimeType from, TimeType to, int semitones) void MidiModel::control_list_marked_dirty () { - AutomatableSequence<Evoral::MusicalTime>::control_list_marked_dirty (); + AutomatableSequence<Evoral::Beats>::control_list_marked_dirty (); ContentsChanged (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/midi_playlist_source.cc b/libs/ardour/midi_playlist_source.cc index 587bc7b12f..4f474f7119 100644 --- a/libs/ardour/midi_playlist_source.cc +++ b/libs/ardour/midi_playlist_source.cc @@ -149,7 +149,7 @@ MidiPlaylistSource::write_unlocked (const Lock&, } void -MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::MusicalTime>& /*ev*/) +MidiPlaylistSource::append_event_beats(const Glib::Threads::Mutex::Lock& /*lock*/, const Evoral::Event<Evoral::Beats>& /*ev*/) { fatal << string_compose (_("programming error: %1"), "MidiPlaylistSource::append_event_beats() called - should be impossible") << endmsg; abort(); /*NOTREACHED*/ diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 62c642d57b..c02caff470 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -53,9 +53,9 @@ using namespace PBD; namespace ARDOUR { namespace Properties { - PBD::PropertyDescriptor<void*> midi_data; - PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats; - PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats; + PBD::PropertyDescriptor<void*> midi_data; + PBD::PropertyDescriptor<Evoral::Beats> start_beats; + PBD::PropertyDescriptor<Evoral::Beats> length_beats; } } @@ -80,7 +80,7 @@ MidiRegion::register_properties () /* Basic MidiRegion constructor (many channels) */ MidiRegion::MidiRegion (const SourceList& srcs) : Region (srcs) - , _start_beats (Properties::start_beats, Evoral::MusicalTime()) + , _start_beats (Properties::start_beats, Evoral::Beats()) , _length_beats (Properties::length_beats, midi_source(0)->length_beats()) { register_properties (); @@ -94,7 +94,7 @@ MidiRegion::MidiRegion (const SourceList& srcs) MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) : Region (other) , _start_beats (Properties::start_beats, other->_start_beats) - , _length_beats (Properties::length_beats, Evoral::MusicalTime()) + , _length_beats (Properties::length_beats, Evoral::Beats()) { update_length_beats (); register_properties (); @@ -107,11 +107,11 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other) /** Create a new MidiRegion that is part of an existing one */ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset) : Region (other, offset) - , _start_beats (Properties::start_beats, Evoral::MusicalTime()) - , _length_beats (Properties::length_beats, Evoral::MusicalTime()) + , _start_beats (Properties::start_beats, Evoral::Beats()) + , _length_beats (Properties::length_beats, Evoral::Beats()) { BeatsFramesConverter bfc (_session.tempo_map(), _position); - Evoral::MusicalTime const offset_beats = bfc.from (offset); + Evoral::Beats const offset_beats = bfc.from (offset); _start_beats = other->_start_beats.val() + offset_beats; _length_beats = other->_length_beats.val() - offset_beats; @@ -147,8 +147,8 @@ boost::shared_ptr<MidiRegion> MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const { BeatsFramesConverter bfc (_session.tempo_map(), _position); - Evoral::MusicalTime const bbegin = bfc.from (_start); - Evoral::MusicalTime const bend = bfc.from (_start + _length); + Evoral::Beats const bbegin = bfc.from (_start); + Evoral::Beats const bend = bfc.from (_start + _length); { /* Lock our source since we'll be reading from it. write_to() will @@ -223,7 +223,7 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute) /* zero length regions don't exist - so if _length_beats is zero, this object is under construction. */ - if (_length_beats.val() == Evoral::MusicalTime()) { + if (_length_beats.val() == Evoral::Beats()) { /* leave _length_beats alone, and change _length to reflect the state of things at the new position (tempo map may dictate a different number of frames */ @@ -462,7 +462,7 @@ MidiRegion::fix_negative_start () model()->insert_silence_at_start (c.from (-_start)); _start = 0; - _start_beats = Evoral::MusicalTime(); + _start_beats = Evoral::Beats(); } /** Transpose the notes in this region by a given number of semitones */ diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 0c08adf4a5..8d3b130594 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -200,7 +200,7 @@ MidiSource::midi_read (const Lock& lm, if (_model) { // Find appropriate model iterator - Evoral::Sequence<Evoral::MusicalTime>::const_iterator& i = _model_iter; + Evoral::Sequence<Evoral::Beats>::const_iterator& i = _model_iter; if (_last_read_end == 0 || start != _last_read_end || !_model_iter_valid) { // Cached iterator is invalid, search for the first event past start i = _model->begin(converter.from(start), false, filtered); @@ -297,9 +297,9 @@ MidiSource::mark_streaming_write_started (const Lock& lock) } void -MidiSource::mark_midi_streaming_write_completed (const Lock& lock, - Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption option, - Evoral::MusicalTime end) +MidiSource::mark_midi_streaming_write_completed (const Lock& lock, + Evoral::Sequence<Evoral::Beats>::StuckNoteOption option, + Evoral::Beats end) { if (_model) { _model->end_write (option, end); @@ -320,11 +320,11 @@ MidiSource::mark_midi_streaming_write_completed (const Lock& void MidiSource::mark_streaming_write_completed (const Lock& lock) { - mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); + mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes); } int -MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end) +MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::Beats begin, Evoral::Beats end) { Lock newsrc_lock (newsrc->mutex ()); @@ -333,7 +333,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev newsrc->copy_automation_state_from (this); if (_model) { - if (begin == Evoral::MinMusicalTime && end == Evoral::MaxMusicalTime) { + if (begin == Evoral::MinBeats && end == Evoral::MaxBeats) { _model->write_to (newsrc, newsrc_lock); } else { _model->write_section_to (newsrc, newsrc_lock, begin, end); @@ -347,7 +347,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Ev /* force a reload of the model if the range is partial */ - if (begin != Evoral::MinMusicalTime || end != Evoral::MaxMusicalTime) { + if (begin != Evoral::MinBeats || end != Evoral::MaxBeats) { newsrc->load_model (newsrc_lock, true); } else { newsrc->set_model (newsrc_lock, _model); diff --git a/libs/ardour/midi_state_tracker.cc b/libs/ardour/midi_state_tracker.cc index f919a02f35..9e96c4954f 100644 --- a/libs/ardour/midi_state_tracker.cc +++ b/libs/ardour/midi_state_tracker.cc @@ -168,7 +168,7 @@ MidiStateTracker::resolve_notes (Evoral::EventSink<framepos_t> &dst, framepos_t } void -MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::MusicalTime time) +MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, Evoral::Beats time) { DEBUG_TRACE (PBD::DEBUG::MidiTrackers, string_compose ("%1 MS-resolve notes @ %2 on = %3\n", this, time, _on)); @@ -181,7 +181,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, for (int channel = 0; channel < 16; ++channel) { for (int note = 0; note < 128; ++note) { while (_active_notes[note + 128 * channel]) { - Evoral::MIDIEvent<Evoral::MusicalTime> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true); + Evoral::MIDIEvent<Evoral::Beats> ev ((MIDI_CMD_NOTE_OFF|channel), time, 3, 0, true); ev.set_type (MIDI_CMD_NOTE_OFF); ev.set_channel (channel); ev.set_note (note); @@ -191,7 +191,7 @@ MidiStateTracker::resolve_notes (MidiSource& src, const MidiSource::Lock& lock, this, (int) note, (int) channel, time)); _active_notes[note + 128 * channel]--; /* don't stack events up at the same time */ - time += Evoral::MusicalTime::tick(); + time += Evoral::Beats::tick(); } } } diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index 05635600d7..71ffcc21e1 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -108,7 +108,7 @@ MidiStretch::run (boost::shared_ptr<Region> r, Progress*) new_model->append(ev, Evoral::next_event_id()); } - new_model->end_write (Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); + new_model->end_write (Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes); new_model->set_edited (true); new_src->copy_interpolation_from (src); diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index dc1976e9ff..6604469007 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -54,8 +54,8 @@ Quantize::~Quantize () Command* Quantize::operator () (boost::shared_ptr<MidiModel> model, - Evoral::MusicalTime position, - std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>& seqs) + Evoral::Beats position, + std::vector<Evoral::Sequence<Evoral::Beats>::Notes>& seqs) { /* TODO: Rewrite this to be precise with fixed point? */ @@ -69,7 +69,7 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, bool even; MidiModel::NoteDiffCommand* cmd = new MidiModel::NoteDiffCommand (model, "quantize"); - for (std::vector<Evoral::Sequence<Evoral::MusicalTime>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) { + for (std::vector<Evoral::Sequence<Evoral::Beats>::Notes>::iterator s = seqs.begin(); s != seqs.end(); ++s) { even = false; @@ -119,10 +119,10 @@ Quantize::operator () (boost::shared_ptr<MidiModel> model, delta = new_end - (*i)->end_time().to_double(); if (fabs (delta) >= _threshold) { - Evoral::MusicalTime new_dur(new_end - new_start); + Evoral::Beats new_dur(new_end - new_start); if (!new_dur) { - new_dur = Evoral::MusicalTime(_end_grid); + new_dur = Evoral::Beats(_end_grid); } cmd->change ((*i), MidiModel::NoteDiffCommand::Length, new_dur); diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index d1a82eb685..7f5e8059c9 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -278,7 +278,7 @@ SMFSource::read_unlocked (const Lock& lock, /* Note that we add on the source start time (in session frames) here so that ev_frame_time is in session frames. */ - const framepos_t ev_frame_time = converter.to(Evoral::MusicalTime::ticks_at_rate(time, ppqn())) + source_start; + const framepos_t ev_frame_time = converter.to(Evoral::Beats::ticks_at_rate(time, ppqn())) + source_start; if (ev_frame_time < start + duration) { destination.write (ev_frame_time, ev_type, ev_size, ev_buffer); @@ -380,8 +380,8 @@ SMFSource::write_unlocked (const Lock& lock, /** Append an event with a timestamp in beats */ void -SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, - const Evoral::Event<Evoral::MusicalTime>& ev) +SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, + const Evoral::Event<Evoral::Beats>& ev) { if (!_writing || ev.size() == 0) { return; @@ -391,9 +391,9 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, name().c_str(), ev.id(), ev.time(), ev.size()); for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n");*/ - Evoral::MusicalTime time = ev.time(); + Evoral::Beats time = ev.time(); if (time < _last_ev_time_beats) { - const Evoral::MusicalTime difference = _last_ev_time_beats - time; + const Evoral::Beats difference = _last_ev_time_beats - time; if (difference.to_double() / (double)ppqn() < 1.0) { /* Close enough. This problem occurs because Sequence is not actually ordered due to fuzzy time comparison. I'm pretty sure @@ -423,8 +423,8 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, _length_beats = max(_length_beats, time); - const Evoral::MusicalTime delta_time_beats = time - _last_ev_time_beats; - const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); + const Evoral::Beats delta_time_beats = time - _last_ev_time_beats; + const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id); _last_ev_time_beats = time; @@ -452,9 +452,9 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock, return; } - BeatsFramesConverter converter(_session.tempo_map(), position); - const Evoral::MusicalTime ev_time_beats = converter.from(ev.time()); - Evoral::event_id_t event_id; + BeatsFramesConverter converter(_session.tempo_map(), position); + const Evoral::Beats ev_time_beats = converter.from(ev.time()); + Evoral::event_id_t event_id; if (ev.id() < 0) { event_id = Evoral::next_event_id(); @@ -463,18 +463,18 @@ SMFSource::append_event_frames (const Glib::Threads::Mutex::Lock& lock, } if (_model) { - const Evoral::Event<Evoral::MusicalTime> beat_ev (ev.event_type(), - ev_time_beats, - ev.size(), - const_cast<uint8_t*>(ev.buffer())); + const Evoral::Event<Evoral::Beats> beat_ev (ev.event_type(), + ev_time_beats, + ev.size(), + const_cast<uint8_t*>(ev.buffer())); _model->append (beat_ev, event_id); } _length_beats = max(_length_beats, ev_time_beats); - const Evoral::MusicalTime last_time_beats = converter.from (_last_ev_time_frames); - const Evoral::MusicalTime delta_time_beats = ev_time_beats - last_time_beats; - const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); + const Evoral::Beats last_time_beats = converter.from (_last_ev_time_frames); + const Evoral::Beats delta_time_beats = ev_time_beats - last_time_beats; + const uint32_t delta_time_ticks = delta_time_beats.to_ticks(ppqn()); Evoral::SMF::append_event_delta(delta_time_ticks, ev.size(), ev.buffer(), event_id); _last_ev_time_frames = ev.time(); @@ -518,18 +518,18 @@ SMFSource::mark_streaming_midi_write_started (const Lock& lock, NoteMode mode) MidiSource::mark_streaming_midi_write_started (lock, mode); Evoral::SMF::begin_write (); - _last_ev_time_beats = Evoral::MusicalTime(); + _last_ev_time_beats = Evoral::Beats(); _last_ev_time_frames = 0; } void SMFSource::mark_streaming_write_completed (const Lock& lock) { - mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::MusicalTime>::DeleteStuckNotes); + mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes); } void -SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::MusicalTime>::StuckNoteOption stuck_notes_option, Evoral::MusicalTime when) +SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_notes_option, Evoral::Beats when) { MidiSource::mark_midi_streaming_write_completed (lm, stuck_notes_option, when); @@ -587,8 +587,8 @@ SMFSource::safe_midi_file_extension (const string& file) } static bool compare_eventlist ( - const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& a, - const std::pair< Evoral::Event<Evoral::MusicalTime>*, gint >& b) { + const std::pair< Evoral::Event<Evoral::Beats>*, gint >& a, + const std::pair< Evoral::Event<Evoral::Beats>*, gint >& b) { return ( a.first->time() < b.first->time() ); } @@ -619,7 +619,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload Evoral::SMF::seek_to_start(); uint64_t time = 0; /* in SMF ticks */ - Evoral::Event<Evoral::MusicalTime> ev; + Evoral::Event<Evoral::Beats> ev; uint32_t scratch_size = 0; // keep track of scratch and minimize reallocs @@ -631,7 +631,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload bool have_event_id; // TODO simplify event allocation - std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > > eventlist; + std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > > eventlist; for (unsigned i = 1; i <= num_tracks(); ++i) { if (seek_to_track(i)) continue; @@ -658,7 +658,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload event_id = Evoral::next_event_id(); } const uint32_t event_type = midi_parameter_type(buf[0]); - const Evoral::MusicalTime event_time = Evoral::MusicalTime::ticks_at_rate(time, ppqn()); + const Evoral::Beats event_time = Evoral::Beats::ticks_at_rate(time, ppqn()); #ifndef NDEBUG std::string ss; @@ -673,7 +673,7 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload #endif eventlist.push_back(make_pair ( - new Evoral::Event<Evoral::MusicalTime> ( + new Evoral::Event<Evoral::Beats> ( event_type, event_time, size, buf, true) , event_id)); @@ -692,13 +692,13 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload eventlist.sort(compare_eventlist); - std::list< std::pair< Evoral::Event<Evoral::MusicalTime>*, gint > >::iterator it; + std::list< std::pair< Evoral::Event<Evoral::Beats>*, gint > >::iterator it; for (it=eventlist.begin(); it!=eventlist.end(); ++it) { _model->append (*it->first, it->second); delete it->first; } - _model->end_write (Evoral::Sequence<Evoral::MusicalTime>::ResolveStuckNotes, _length_beats); + _model->end_write (Evoral::Sequence<Evoral::Beats>::ResolveStuckNotes, _length_beats); _model->set_edited (false); invalidate(lock); diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 486cbb0643..dfcc264547 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1841,7 +1841,7 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount) * pos can be -ve, if required. */ framepos_t -TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const +TempoMap::framepos_plus_beats (framepos_t pos, Evoral::Beats beats) const { Glib::Threads::RWLock::ReaderLock lm (lock); Metrics::const_iterator next_tempo; @@ -1891,11 +1891,11 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const framecnt_t distance_frames = (next_tempo == metrics.end() ? max_framepos : ((*next_tempo)->frame() - pos)); /* Distance to the end in beats */ - Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate( + Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate( distance_frames, tempo->frames_per_beat (_frame_rate)); /* Amount to subtract this time */ - Evoral::MusicalTime const delta = min (distance_beats, beats); + Evoral::Beats const delta = min (distance_beats, beats); DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n", (next_tempo == metrics.end() ? max_framepos : (*next_tempo)->frame()), @@ -1933,7 +1933,7 @@ TempoMap::framepos_plus_beats (framepos_t pos, Evoral::MusicalTime beats) const /** Subtract some (fractional) beats from a frame position, and return the result in frames */ framepos_t -TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const +TempoMap::framepos_minus_beats (framepos_t pos, Evoral::Beats beats) const { Glib::Threads::RWLock::ReaderLock lm (lock); Metrics::const_reverse_iterator prev_tempo; @@ -2000,11 +2000,11 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const framecnt_t distance_frames = (pos - tempo->frame()); /* Distance to the start in beats */ - Evoral::MusicalTime distance_beats = Evoral::MusicalTime::ticks_at_rate( + Evoral::Beats distance_beats = Evoral::Beats::ticks_at_rate( distance_frames, tempo->frames_per_beat (_frame_rate)); /* Amount to subtract this time */ - Evoral::MusicalTime const sub = min (distance_beats, beats); + Evoral::Beats const sub = min (distance_beats, beats); DEBUG_TRACE (DEBUG::TempoMath, string_compose ("\tdistance to %1 = %2 (%3 beats)\n", tempo->frame(), distance_frames, distance_beats)); @@ -2037,7 +2037,7 @@ TempoMap::framepos_minus_beats (framepos_t pos, Evoral::MusicalTime beats) const } } else { pos -= llrint (beats.to_double() * tempo->frames_per_beat (_frame_rate)); - beats = Evoral::MusicalTime(); + beats = Evoral::Beats(); } } @@ -2183,7 +2183,7 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) const /** Count the number of beats that are equivalent to distance when going forward, starting at pos. */ -Evoral::MusicalTime +Evoral::Beats TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const { Glib::Threads::RWLock::ReaderLock lm (lock); @@ -2218,7 +2218,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const string_compose ("frame %1 walk by %2 frames, start with tempo = %3 @ %4\n", pos, distance, *((const Tempo*)tempo), tempo->frame())); - Evoral::MusicalTime beats = Evoral::MusicalTime(); + Evoral::Beats beats = Evoral::Beats(); while (distance) { @@ -2246,7 +2246,7 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const pos += sub; distance -= sub; assert (tempo); - beats += Evoral::MusicalTime::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate)); + beats += Evoral::Beats::ticks_at_rate(sub, tempo->frames_per_beat (_frame_rate)); DEBUG_TRACE (DEBUG::TempoMath, string_compose ("now at %1, beats = %2 distance left %3\n", pos, beats, distance)); diff --git a/libs/ardour/test/framepos_minus_beats_test.cc b/libs/ardour/test/framepos_minus_beats_test.cc index e4c4844146..cc6341fb0b 100644 --- a/libs/ardour/test/framepos_minus_beats_test.cc +++ b/libs/ardour/test/framepos_minus_beats_test.cc @@ -26,11 +26,11 @@ FrameposMinusBeatsTest::singleTempoTest () map.add_tempo (tempo, BBT_Time (1, 1, 0)); /* Subtract 1 beat from beat 3 of the first bar */ - framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, MusicalTime(1)); + framepos_t r = map.framepos_minus_beats (frames_per_beat * 2, Beats(1)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (frames_per_beat * 1)); /* Subtract 4 beats from 3 beats in, to go beyond zero */ - r = map.framepos_minus_beats (frames_per_beat * 3, MusicalTime(4)); + r = map.framepos_minus_beats (frames_per_beat * 3, Beats(4)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (- frames_per_beat)); } @@ -70,15 +70,15 @@ FrameposMinusBeatsTest::doubleTempoTest () /* Now some tests */ /* Subtract 1 beat from 1|2 */ - framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1)); + framepos_t r = map.framepos_minus_beats (24e3, Beats(1)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (0)); /* Subtract 2 beats from 4|2 (over the tempo change) */ - r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2)); + r = map.framepos_minus_beats (288e3 + 12e3, Beats(2)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3)); /* Subtract 2.5 beats from 4|2 (over the tempo change) */ - r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5)); + r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3)); } @@ -124,15 +124,15 @@ FrameposMinusBeatsTest::doubleTempoWithMeterTest () /* Now some tests */ /* Subtract 1 beat from 1|2 */ - framepos_t r = map.framepos_minus_beats (24e3, MusicalTime(1)); + framepos_t r = map.framepos_minus_beats (24e3, Beats(1)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (0)); /* Subtract 2 beats from 4|2 (over the tempo change) */ - r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2)); + r = map.framepos_minus_beats (288e3 + 12e3, Beats(2)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3)); /* Subtract 2.5 beats from 4|2 (over the tempo change) */ - r = map.framepos_minus_beats (288e3 + 12e3, MusicalTime(2.5)); + r = map.framepos_minus_beats (288e3 + 12e3, Beats(2.5)); CPPUNIT_ASSERT_EQUAL (r, framepos_t (288e3 - 24e3 - 12e3)); } diff --git a/libs/ardour/test/framepos_plus_beats_test.cc b/libs/ardour/test/framepos_plus_beats_test.cc index abe1310f62..efc57c5872 100644 --- a/libs/ardour/test/framepos_plus_beats_test.cc +++ b/libs/ardour/test/framepos_plus_beats_test.cc @@ -25,11 +25,11 @@ FrameposPlusBeatsTest::singleTempoTest () map.add_tempo (tempo, BBT_Time (1, 1, 0)); /* Add 1 beat to beat 3 of the first bar */ - framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::MusicalTime(1)); + framepos_t r = map.framepos_plus_beats (frames_per_beat * 2, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); /* Add 4 beats to a -ve frame of 1 beat before zero */ - r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::MusicalTime(4)); + r = map.framepos_plus_beats (-frames_per_beat * 1, Evoral::Beats(4)); CPPUNIT_ASSERT_EQUAL (framepos_t (frames_per_beat * 3), r); } @@ -69,15 +69,15 @@ FrameposPlusBeatsTest::doubleTempoTest () /* Now some tests */ /* Add 1 beat to 1|2 */ - framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1)); + framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); /* Add 2 beats to 3|4 (over the tempo change) */ - r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2)); + r = map.framepos_plus_beats (264e3, Evoral::Beats(2)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); /* Add 2.5 beats to 3|3|960 (over the tempo change) */ - r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5)); + r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); } @@ -123,15 +123,15 @@ FrameposPlusBeatsTest::doubleTempoWithMeterTest () /* Now some tests */ /* Add 1 beat to 1|2 */ - framepos_t r = map.framepos_plus_beats (24e3, Evoral::MusicalTime(1)); + framepos_t r = map.framepos_plus_beats (24e3, Evoral::Beats(1)); CPPUNIT_ASSERT_EQUAL (framepos_t (48e3), r); /* Add 2 beats to 3|4 (over the tempo change) */ - r = map.framepos_plus_beats (264e3, Evoral::MusicalTime(2)); + r = map.framepos_plus_beats (264e3, Evoral::Beats(2)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); /* Add 2.5 beats to 3|3|960 (over the tempo change) */ - r = map.framepos_plus_beats (264e3 - 12e3, Evoral::MusicalTime(2.5)); + r = map.framepos_plus_beats (264e3 - 12e3, Evoral::Beats(2.5)); CPPUNIT_ASSERT_EQUAL (framepos_t (264e3 + 24e3 + 12e3), r); } diff --git a/libs/ardour/transform.cc b/libs/ardour/transform.cc index 3b4f53c860..9f029829de 100644 --- a/libs/ardour/transform.cc +++ b/libs/ardour/transform.cc @@ -121,7 +121,7 @@ Transform::Operation::eval(Context& ctx) const Command* Transform::operator()(boost::shared_ptr<MidiModel> model, - Evoral::MusicalTime position, + Evoral::Beats position, std::vector<Notes>& seqs) { typedef MidiModel::NoteDiffCommand Command; diff --git a/libs/evoral/evoral/Beats.hpp b/libs/evoral/evoral/Beats.hpp new file mode 100644 index 0000000000..e0277c4b3d --- /dev/null +++ b/libs/evoral/evoral/Beats.hpp @@ -0,0 +1,247 @@ +/* This file is part of Evoral. + * Copyright (C) 2008-2015 David Robillard <http://drobilla.net> + * Copyright (C) 2000-2008 Paul Davis + * + * Evoral is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef EVORAL_BEATS_HPP +#define EVORAL_BEATS_HPP + +#include <float.h> +#include <math.h> +#include <stdint.h> + +#include <iostream> +#include <limits> + +#include "evoral/visibility.h" + +namespace Evoral { + +/** Musical time in beats. */ +class /*LIBEVORAL_API*/ Beats { +public: + LIBEVORAL_API static const double PPQN; + + Beats() : _time(0.0) {} + + /** Create from a real number of beats. */ + explicit Beats(double time) : _time(time) {} + + /** Create from an integer number of beats. */ + static Beats beats(int32_t beats) { + return Beats((double)beats); + } + + /** Create from ticks at the standard PPQN. */ + static Beats ticks(uint32_t ticks) { + return Beats(ticks / PPQN); + } + + /** Create from ticks at a given rate. + * + * Note this can also be used to create from frames by setting ppqn to the + * number of samples per beat. + */ + static Beats ticks_at_rate(uint64_t ticks, uint32_t ppqn) { + return Beats((double)ticks / (double)ppqn); + } + + Beats& operator=(const Beats& other) { + _time = other._time; + return *this; + } + + Beats round_up_to_beat() const { + return Evoral::Beats(ceil(_time)); + } + + Beats round_down_to_beat() const { + return Evoral::Beats(floor(_time)); + } + + Beats snap_to(const Evoral::Beats& snap) const { + return Beats(ceil(_time / snap._time) * snap._time); + } + + inline bool operator==(const Beats& b) const { + /* Acceptable tolerance is 1 tick. */ + return fabs(_time - b._time) <= (1.0 / PPQN); + } + + inline bool operator==(double t) const { + /* Acceptable tolerance is 1 tick. */ + return fabs(_time - t) <= (1.0 / PPQN); + } + + inline bool operator==(int beats) const { + /* Acceptable tolerance is 1 tick. */ + return fabs(_time - beats) <= (1.0 / PPQN); + } + + inline bool operator!=(const Beats& b) const { + return !operator==(b); + } + + inline bool operator<(const Beats& b) const { + /* Acceptable tolerance is 1 tick. */ + if (fabs(_time - b._time) <= (1.0 / PPQN)) { + return false; /* Effectively identical. */ + } else { + return _time < b._time; + } + } + + inline bool operator<=(const Beats& b) const { + return operator==(b) || operator<(b); + } + + inline bool operator>(const Beats& b) const { + /* Acceptable tolerance is 1 tick. */ + if (fabs(_time - b._time) <= (1.0 / PPQN)) { + return false; /* Effectively identical. */ + } else { + return _time > b._time; + } + } + + inline bool operator>=(const Beats& b) const { + return operator==(b) || operator>(b); + } + + inline bool operator<(double b) const { + /* Acceptable tolerance is 1 tick. */ + if (fabs(_time - b) <= (1.0 / PPQN)) { + return false; /* Effectively identical. */ + } else { + return _time < b; + } + } + + inline bool operator<=(double b) const { + return operator==(b) || operator<(b); + } + + inline bool operator>(double b) const { + /* Acceptable tolerance is 1 tick. */ + if (fabs(_time - b) <= (1.0 / PPQN)) { + return false; /* Effectively identical. */ + } else { + return _time > b; + } + } + + inline bool operator>=(double b) const { + return operator==(b) || operator>(b); + } + + Beats operator+(const Beats& b) const { + return Beats(_time + b._time); + } + + Beats operator-(const Beats& b) const { + return Beats(_time - b._time); + } + + Beats operator+(double d) const { + return Beats(_time + d); + } + + Beats operator-(double d) const { + return Beats(_time - d); + } + + Beats operator-() const { + return Beats(-_time); + } + + template<typename Number> + Beats operator*(Number factor) const { + return Beats(_time * factor); + } + + Beats& operator+=(const Beats& b) { + _time += b._time; + return *this; + } + + Beats& operator-=(const Beats& b) { + _time -= b._time; + return *this; + } + + double to_double() const { return _time; } + uint64_t to_ticks() const { return lrint(_time * PPQN); } + uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); } + + uint32_t get_beats() const { return floor(_time); } + uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); } + + bool operator!() const { return _time == 0; } + + static Beats min() { return Beats(DBL_MIN); } + static Beats max() { return Beats(DBL_MAX); } + static Beats tick() { return Beats(1.0 / PPQN); } + +private: + double _time; +}; + +extern LIBEVORAL_API const Beats MaxBeats; +extern LIBEVORAL_API const Beats MinBeats; + +/* + TIL, several horrible hours later, that sometimes the compiler looks in the + namespace of a type (Evoral::Beats in this case) for an operator, and + does *NOT* look in the global namespace. + + C++ is proof that hell exists and we are living in it. In any case, move + these to the global namespace and PBD::Property's loopy + virtual-method-in-a-template will bite you. +*/ + +inline std::ostream& +operator<<(std::ostream& os, const Beats& t) +{ + os << t.to_double(); + return os; +} + +inline std::istream& +operator>>(std::istream& is, Beats& t) +{ + double beats; + is >> beats; + t = Beats(beats); + return is; +} + +} // namespace Evoral + +namespace PBD { + namespace DEBUG { + LIBEVORAL_API extern uint64_t Beats; + } +} + +namespace std { + template<> + struct numeric_limits<Evoral::Beats> { + static Evoral::Beats min() { return Evoral::Beats::min(); } + static Evoral::Beats max() { return Evoral::Beats::max(); } + }; +} + +#endif // EVORAL_BEATS_HPP diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp index 14ba36acdf..1951fb8ba6 100644 --- a/libs/evoral/evoral/types.hpp +++ b/libs/evoral/evoral/types.hpp @@ -27,6 +27,7 @@ #include <limits> #include <list> +#include "evoral/Beats.hpp" #include "evoral/visibility.h" #include "pbd/debug.h" @@ -38,207 +39,9 @@ namespace Evoral { */ typedef int32_t event_id_t; -/** Musical time: beats relative to some defined origin */ -class /*LIBEVORAL_API*/ MusicalTime { -public: - LIBEVORAL_API static const double PPQN; - - MusicalTime() : _time(0.0) {} - - /** Create from a real number of beats. */ - explicit MusicalTime(double time) : _time(time) {} - - /** Create from an integer number of beats. */ - static MusicalTime beats(int32_t beats) { - return MusicalTime((double)beats); - } - - /** Create from ticks at the standard PPQN. */ - static MusicalTime ticks(uint32_t ticks) { - return MusicalTime(ticks / PPQN); - } - - /** Create from ticks at a given rate. - * - * Note this can also be used to create from frames by setting ppqn to the - * number of samples per beat. - */ - static MusicalTime ticks_at_rate(uint64_t ticks, uint32_t ppqn) { - return MusicalTime((double)ticks / (double)ppqn); - } - - MusicalTime& operator=(const MusicalTime& other) { - _time = other._time; - return *this; - } - - MusicalTime round_up_to_beat() const { - return Evoral::MusicalTime(ceil(_time)); - } - - MusicalTime round_down_to_beat() const { - return Evoral::MusicalTime(floor(_time)); - } - - MusicalTime snap_to(const Evoral::MusicalTime& snap) const { - return MusicalTime(ceil(_time / snap._time) * snap._time); - } - - inline bool operator==(const MusicalTime& b) const { - /* Acceptable tolerance is 1 tick. */ - return fabs(_time - b._time) <= (1.0 / PPQN); - } - - inline bool operator==(double t) const { - /* Acceptable tolerance is 1 tick. */ - return fabs(_time - t) <= (1.0 / PPQN); - } - - inline bool operator==(int beats) const { - /* Acceptable tolerance is 1 tick. */ - return fabs(_time - beats) <= (1.0 / PPQN); - } - - inline bool operator!=(const MusicalTime& b) const { - return !operator==(b); - } - - inline bool operator<(const MusicalTime& b) const { - /* Acceptable tolerance is 1 tick. */ - if (fabs(_time - b._time) <= (1.0 / PPQN)) { - return false; /* Effectively identical. */ - } else { - return _time < b._time; - } - } - - inline bool operator<=(const MusicalTime& b) const { - return operator==(b) || operator<(b); - } - - inline bool operator>(const MusicalTime& b) const { - /* Acceptable tolerance is 1 tick. */ - if (fabs(_time - b._time) <= (1.0 / PPQN)) { - return false; /* Effectively identical. */ - } else { - return _time > b._time; - } - } - - inline bool operator>=(const MusicalTime& b) const { - return operator==(b) || operator>(b); - } - - inline bool operator<(double b) const { - /* Acceptable tolerance is 1 tick. */ - if (fabs(_time - b) <= (1.0 / PPQN)) { - return false; /* Effectively identical. */ - } else { - return _time < b; - } - } - - inline bool operator<=(double b) const { - return operator==(b) || operator<(b); - } - - inline bool operator>(double b) const { - /* Acceptable tolerance is 1 tick. */ - if (fabs(_time - b) <= (1.0 / PPQN)) { - return false; /* Effectively identical. */ - } else { - return _time > b; - } - } - - inline bool operator>=(double b) const { - return operator==(b) || operator>(b); - } - - MusicalTime operator+(const MusicalTime& b) const { - return MusicalTime(_time + b._time); - } - - MusicalTime operator-(const MusicalTime& b) const { - return MusicalTime(_time - b._time); - } - - MusicalTime operator+(double d) const { - return MusicalTime(_time + d); - } - - MusicalTime operator-(double d) const { - return MusicalTime(_time - d); - } - - MusicalTime operator-() const { - return MusicalTime(-_time); - } - - template<typename Number> - MusicalTime operator*(Number factor) const { - return MusicalTime(_time * factor); - } - - MusicalTime& operator+=(const MusicalTime& b) { - _time += b._time; - return *this; - } - - MusicalTime& operator-=(const MusicalTime& b) { - _time -= b._time; - return *this; - } - - double to_double() const { return _time; } - uint64_t to_ticks() const { return lrint(_time * PPQN); } - uint64_t to_ticks(uint32_t ppqn) const { return lrint(_time * ppqn); } - - uint32_t get_beats() const { return floor(_time); } - uint32_t get_ticks() const { return (uint32_t)lrint(fmod(_time, 1.0) * PPQN); } - - bool operator!() const { return _time == 0; } - - static MusicalTime min() { return MusicalTime(DBL_MIN); } - static MusicalTime max() { return MusicalTime(DBL_MAX); } - static MusicalTime tick() { return MusicalTime(1.0 / PPQN); } - -private: - double _time; -}; - -extern LIBEVORAL_API const MusicalTime MaxMusicalTime; -extern LIBEVORAL_API const MusicalTime MinMusicalTime; - /** Type of an event (opaque, mapped by application) */ typedef uint32_t EventType; -/* - TIL, several horrible hours later, that sometimes the compiler looks in the - namespace of a type (Evoral::MusicalTime in this case) for an operator, and - does *NOT* look in the global namespace. - - C++ is proof that hell exists and we are living in it. In any case, move - these to the global namespace and PBD::Property's loopy - virtual-method-in-a-template will bite you. -*/ - -inline std::ostream& -operator<<(std::ostream& os, const MusicalTime& t) -{ - os << t.to_double(); - return os; -} - -inline std::istream& -operator>>(std::istream& is, MusicalTime& t) -{ - double beats; - is >> beats; - t = MusicalTime(beats); - return is; -} - } // namespace Evoral namespace PBD { @@ -246,16 +49,7 @@ namespace PBD { LIBEVORAL_API extern uint64_t Sequence; LIBEVORAL_API extern uint64_t Note; LIBEVORAL_API extern uint64_t ControlList; - LIBEVORAL_API extern uint64_t MusicalTime; } } -namespace std { - template<> - struct numeric_limits<Evoral::MusicalTime> { - static Evoral::MusicalTime min() { return Evoral::MusicalTime::min(); } - static Evoral::MusicalTime max() { return Evoral::MusicalTime::max(); } - }; -} - #endif // EVORAL_TYPES_HPP diff --git a/libs/evoral/src/Event.cpp b/libs/evoral/src/Event.cpp index b874c37de4..66e45ab2ad 100644 --- a/libs/evoral/src/Event.cpp +++ b/libs/evoral/src/Event.cpp @@ -155,7 +155,7 @@ Event<Timestamp>::set_original_time (Timestamp t) #endif // EVORAL_EVENT_ALLOC -template class Event<Evoral::MusicalTime>; +template class Event<Evoral::Beats>; template class Event<double>; template class Event<int64_t>; diff --git a/libs/evoral/src/MIDIEvent.cpp b/libs/evoral/src/MIDIEvent.cpp index 66a97f73e4..4985f66cf4 100644 --- a/libs/evoral/src/MIDIEvent.cpp +++ b/libs/evoral/src/MIDIEvent.cpp @@ -102,7 +102,7 @@ MIDIEvent<Time>::to_xml() const #endif // EVORAL_MIDI_XML -template class MIDIEvent<Evoral::MusicalTime>; +template class MIDIEvent<Evoral::Beats>; } // namespace Evoral diff --git a/libs/evoral/src/Note.cpp b/libs/evoral/src/Note.cpp index 93c0a90478..7e4f58d73f 100644 --- a/libs/evoral/src/Note.cpp +++ b/libs/evoral/src/Note.cpp @@ -108,7 +108,7 @@ Note<Time>::operator=(const Note<Time>& other) return *this; } -template class Note<Evoral::MusicalTime>; +template class Note<Evoral::Beats>; } // namespace Evoral diff --git a/libs/evoral/src/OldSMF.cpp b/libs/evoral/src/OldSMF.cpp index 0cee749c9c..eef61e332b 100644 --- a/libs/evoral/src/OldSMF.cpp +++ b/libs/evoral/src/OldSMF.cpp @@ -364,6 +364,6 @@ SMF<Time>::write_var_len(uint32_t value) return ret; } -template class SMF<Evoral::MusicalTime>; +template class SMF<Evoral::Beats>; } // namespace Evoral diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index a77e3c94be..10b7e31b79 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -1404,6 +1404,6 @@ Sequence<Time>::dump (ostream& str) const str << "--- dump\n"; } -template class Sequence<Evoral::MusicalTime>; +template class Sequence<Evoral::Beats>; } // namespace Evoral diff --git a/libs/evoral/src/TimeConverter.cpp b/libs/evoral/src/TimeConverter.cpp index 0d39087e7c..e1e4b8231f 100644 --- a/libs/evoral/src/TimeConverter.cpp +++ b/libs/evoral/src/TimeConverter.cpp @@ -45,6 +45,6 @@ IdentityConverter<A,B>::from(B b) const template class IdentityConverter<double, framepos_t>; template class TimeConverter<double, framepos_t>; -template class TimeConverter<Evoral::MusicalTime, framepos_t>; +template class TimeConverter<Evoral::Beats, framepos_t>; } // namespace Evoral diff --git a/libs/evoral/src/types.cpp b/libs/evoral/src/types.cpp index 80801dcdea..50c2975d3d 100644 --- a/libs/evoral/src/types.cpp +++ b/libs/evoral/src/types.cpp @@ -22,8 +22,8 @@ namespace Evoral { -const double MusicalTime::PPQN = 1920.0; -const MusicalTime MaxMusicalTime = Evoral::MusicalTime(DBL_MAX); -const MusicalTime MinMusicalTime = Evoral::MusicalTime(DBL_MIN); +const double Beats::PPQN = 1920.0; +const Beats MaxBeats = Evoral::Beats(DBL_MAX); +const Beats MinBeats = Evoral::Beats(DBL_MIN); } diff --git a/libs/evoral/test/SMFTest.cpp b/libs/evoral/test/SMFTest.cpp index 9bbe021947..d42ee26dff 100644 --- a/libs/evoral/test/SMFTest.cpp +++ b/libs/evoral/test/SMFTest.cpp @@ -45,25 +45,25 @@ SMFTest::takeFiveTest () smf.seek_to_start(); uint64_t time = 0; /* in SMF ticks */ - Evoral::Event<Evoral::MusicalTime> ev; + Evoral::Event<Evoral::Beats> ev; uint32_t delta_t = 0; uint32_t size = 0; uint8_t* buf = NULL; int ret; while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) { - ev.set(buf, size, Evoral::MusicalTime()); + ev.set(buf, size, Evoral::Beats()); time += delta_t; if (ret > 0) { // didn't skip (meta) event //cerr << "read smf event type " << hex << int(buf[0]) << endl; - ev.set_time(Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn())); + ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn())); ev.set_event_type(type_map->midi_event_type(buf[0])); seq->append(ev, next_event_id ()); } } seq->end_write (Sequence<Time>::Relax, - Evoral::MusicalTime::ticks_at_rate(time, smf.ppqn())); + Evoral::Beats::ticks_at_rate(time, smf.ppqn())); CPPUNIT_ASSERT(!seq->empty()); } diff --git a/libs/evoral/test/SMFTest.hpp b/libs/evoral/test/SMFTest.hpp index 6e42b6f7b3..94172c62c8 100644 --- a/libs/evoral/test/SMFTest.hpp +++ b/libs/evoral/test/SMFTest.hpp @@ -57,7 +57,7 @@ class SMFTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END(); public: - typedef Evoral::MusicalTime Time; + typedef Evoral::Beats Time; void setUp() { type_map = new DummyTypeMap(); diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp index f6a8363f4d..39afcd3095 100644 --- a/libs/evoral/test/SequenceTest.cpp +++ b/libs/evoral/test/SequenceTest.cpp @@ -75,7 +75,7 @@ SequenceTest::iteratorSeekTest () } bool on = true; - for (Sequence<Time>::const_iterator i = seq->begin(Evoral::MusicalTime(600)); i != seq->end(); ++i) { + for (Sequence<Time>::const_iterator i = seq->begin(Evoral::Beats(600)); i != seq->end(); ++i) { if (on) { CPPUNIT_ASSERT(((const MIDIEvent<Time>&)*i).is_note_on()); CPPUNIT_ASSERT_EQUAL(i->time(), Time((num_notes + 6) * 100)); diff --git a/libs/evoral/test/SequenceTest.hpp b/libs/evoral/test/SequenceTest.hpp index d8e0406100..da1991efc8 100644 --- a/libs/evoral/test/SequenceTest.hpp +++ b/libs/evoral/test/SequenceTest.hpp @@ -113,7 +113,7 @@ class SequenceTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END (); public: - typedef MusicalTime Time; + typedef Beats Time; typedef std::vector< boost::shared_ptr< Note<Time> > > Notes; void setUp () { @@ -125,7 +125,7 @@ public: for (int i = 0; i < 12; i++) { test_notes.push_back( boost::shared_ptr<Note<Time> >( - new Note<Time>(0, MusicalTime(i * 100), MusicalTime(100), 64 + i, 64))); + new Note<Time>(0, Beats(i * 100), Beats(100), 64 + i, 64))); } } diff --git a/libs/midi++2/midnam_patch.cc b/libs/midi++2/midnam_patch.cc index 55e7ac1898..e1b3007bd3 100644 --- a/libs/midi++2/midnam_patch.cc +++ b/libs/midi++2/midnam_patch.cc @@ -97,7 +97,7 @@ Patch::get_state (void) node->add_property("Name", _name); /* - typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::MusicalTime> > > PatchMidiCommands; + typedef std::list< boost::shared_ptr< Evoral::MIDIEvent<Evoral::Beats> > > PatchMidiCommands; XMLNode* commands = node->add_child("PatchMIDICommands"); for (PatchMidiCommands::const_iterator event = _patch_midi_commands.begin(); event != _patch_midi_commands.end(); |