From c1cfa12d6e5136d2e3e5501e83ff74c5009a9e60 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 22 Nov 2014 04:05:42 -0500 Subject: Wrap MusicalTime in a class. This lets us get a more explicit handle on time conversions, and is the main step towards using actual beat:tick time and getting away from floating point precision problems. --- libs/ardour/midi_model.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libs/ardour/midi_model.cc') diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 259a04bc0f..6c2132562a 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -226,13 +226,13 @@ MidiModel::NoteDiffCommand::change (const NotePtr note, Property prop, break; case StartTime: - if (Evoral::musical_time_equal (note->time(), new_time)) { + if (note->time() == new_time) { return; } change.old_time = note->time(); break; case Length: - if (Evoral::musical_time_equal (note->length(), new_time)) { + if (note->length() == new_time) { return; } change.old_time = note->length(); @@ -556,7 +556,7 @@ MidiModel::NoteDiffCommand::unmarshal_note (XMLNode *xml_note) time_str >> time; } else { warning << "note information missing time" << endmsg; - time = 0; + time = MidiModel::TimeType(); } if ((prop = xml_note->property("length")) != 0) { @@ -564,7 +564,7 @@ MidiModel::NoteDiffCommand::unmarshal_note (XMLNode *xml_note) length_str >> length; } else { warning << "note information missing length" << endmsg; - length = 1; + length = MidiModel::TimeType(1); } if ((prop = xml_note->property("velocity")) != 0) { @@ -1253,7 +1253,7 @@ MidiModel::PatchChangeDiffCommand::unmarshal_patch_change (XMLNode* n) { XMLProperty* prop; Evoral::event_id_t id = 0; - Evoral::MusicalTime time = 0; + Evoral::MusicalTime time = Evoral::MusicalTime(); int channel = 0; int program = 0; int bank = 0; @@ -1439,7 +1439,7 @@ MidiModel::write_to (boost::shared_ptr source) source->drop_model(); source->mark_streaming_midi_write_started (note_mode()); - for (Evoral::Sequence::const_iterator i = begin(0, true); i != end(); ++i) { + for (Evoral::Sequence::const_iterator i = begin(TimeType(), true); i != end(); ++i) { source->append_event_unlocked_beats(*i); } @@ -1469,7 +1469,7 @@ MidiModel::sync_to_source () ms->mark_streaming_midi_write_started (note_mode()); - for (Evoral::Sequence::const_iterator i = begin(0, true); i != end(); ++i) { + for (Evoral::Sequence::const_iterator i = begin(TimeType(), true); i != end(); ++i) { ms->append_event_unlocked_beats(*i); } @@ -1503,7 +1503,7 @@ MidiModel::write_section_to (boost::shared_ptr source, Evoral::Music source->drop_model(); source->mark_streaming_midi_write_started (note_mode()); - for (Evoral::Sequence::const_iterator i = begin(0, true); i != end(); ++i) { + for (Evoral::Sequence::const_iterator i = begin(TimeType(), true); i != end(); ++i) { const Evoral::Event& ev (*i); if (ev.time() >= begin_time && ev.time() < end_time) { @@ -1662,7 +1662,7 @@ MidiModel::resolve_overlaps_unlocked (const NotePtr note, void* arg) TimeType ea = note->end_time(); const Pitches& p (pitches (note->channel())); - NotePtr search_note(new Note(0, 0, 0, note->note())); + NotePtr search_note(new Note(0, TimeType(), TimeType(), note->note())); set to_be_deleted; bool set_note_length = false; bool set_note_time = false; @@ -1979,7 +1979,7 @@ MidiModel::insert_silence_at_start (TimeType t) for (Controls::iterator i = controls().begin(); i != controls().end(); ++i) { boost::shared_ptr ac = boost::dynamic_pointer_cast (i->second); XMLNode& before = ac->alist()->get_state (); - i->second->list()->shift (0, t); + i->second->list()->shift (0, t.to_double()); XMLNode& after = ac->alist()->get_state (); s->session().add_command (new MementoCommand (new MidiAutomationListBinder (s, i->first), &before, &after)); } -- cgit v1.2.3