X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsmf_source.cc;h=f48fc301f71cd7d77de994c964814a8b91e29d06;hb=e374518ca9c4643874eee3877e270eef32d95f18;hp=3e35e58fb95bb9a75f9aeb29e50d70bab9361b1a;hpb=af8c16cfe0ccfd6d4611159ba0956e98d0f08e5c;p=ardour.git diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 3e35e58fb9..f48fc301f7 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -49,22 +49,24 @@ using namespace ARDOUR; using namespace Glib; /** Constructor used for new internal-to-session files. File cannot exist. */ -SMFSource::SMFSource (Session& s, const ustring& path, bool embedded, Source::Flag flags) +SMFSource::SMFSource (Session& s, const ustring& path, Source::Flag flags) : Source(s, DataType::MIDI, path, flags) , MidiSource(s, path) - , FileSource(s, DataType::MIDI, path, embedded, flags) + , FileSource(s, DataType::MIDI, path, flags) , Evoral::SMF() , _last_ev_time_beats(0.0) , _last_ev_time_frames(0) , _smf_last_read_end (0) { - if (init(_name, false)) { + if (init(_path, false)) { throw failed_constructor (); } if (create(path)) { throw failed_constructor (); } + + load_model(true, true); // FIXME } /** Constructor used for existing internal-to-session files. */ @@ -80,13 +82,15 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist) throw failed_constructor (); } - if (init(_name, true)) { + if (init(_path, true)) { throw failed_constructor (); } if (open(_path)) { throw failed_constructor (); } + + load_model(true, true); // FIXME } SMFSource::~SMFSource () @@ -98,7 +102,7 @@ SMFSource::~SMFSource () /** All stamps in audio frames */ nframes_t -SMFSource::read_unlocked (MidiRingBuffer& destination, sframes_t source_start, +SMFSource::read_unlocked (Evoral::EventSink& destination, sframes_t source_start, sframes_t start, nframes_t duration, sframes_t stamp_offset, sframes_t negative_stamp_offset, MidiStateTracker* tracker) const @@ -116,7 +120,7 @@ SMFSource::read_unlocked (MidiRingBuffer& destination, sframes_t sour size_t scratch_size = 0; // keep track of scratch to minimize reallocs - BeatsFramesConverter converter(_session, source_start); + BeatsFramesConverter converter(_session.tempo_map(), source_start); const uint64_t start_ticks = (uint64_t)(converter.from(start) * ppqn()); @@ -179,7 +183,7 @@ SMFSource::read_unlocked (MidiRingBuffer& destination, sframes_t sour } else { break; } - + _read_data_count += ev_size; if (ev_size > scratch_size) { @@ -264,6 +268,7 @@ SMFSource::write_unlocked (MidiRingBuffer& source, sframes_t position void SMFSource::append_event_unlocked_beats (const Evoral::Event& ev) { + assert(_writing); if (ev.size() == 0) { return; } @@ -297,6 +302,7 @@ SMFSource::append_event_unlocked_beats (const Evoral::Event& ev) void SMFSource::append_event_unlocked_frames (const Evoral::Event& ev, sframes_t position) { + assert(_writing); if (ev.size() == 0) { return; } @@ -310,7 +316,7 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event& ev, sfr return; } - BeatsFramesConverter converter(_session, position); + BeatsFramesConverter converter(_session.tempo_map(), position); _length_beats = max(_length_beats, converter.from(ev.time())); @@ -358,6 +364,7 @@ SMFSource::set_state (const XMLNode& node, int version) void SMFSource::mark_streaming_midi_write_started (NoteMode mode, sframes_t start_frame) { + Glib::Mutex::Lock lm (_lock); MidiSource::mark_streaming_midi_write_started (mode, start_frame); Evoral::SMF::begin_write (); _last_ev_time_beats = 0.0; @@ -367,6 +374,7 @@ SMFSource::mark_streaming_midi_write_started (NoteMode mode, sframes_t start_fra void SMFSource::mark_streaming_write_completed () { + Glib::Mutex::Lock lm (_lock); MidiSource::mark_streaming_write_completed(); if (!writable()) { @@ -390,9 +398,9 @@ SMFSource::load_model (bool lock, bool force_reload) return; } - if (lock) { - Glib::Mutex::Lock lm (_lock); - } + boost::shared_ptr lm; + if (lock) + lm = boost::shared_ptr(new Glib::Mutex::Lock(_lock)); if (_model && !force_reload) { return; @@ -446,8 +454,6 @@ SMFSource::load_model (bool lock, bool force_reload) free(buf); } -#define LINEAR_INTERPOLATION_MODE_WORKS_PROPERLY 0 - void SMFSource::set_default_controls_interpolation () { @@ -455,12 +461,7 @@ SMFSource::set_default_controls_interpolation () Evoral::ControlSet::Controls controls = _model->controls(); for (Evoral::ControlSet::Controls::iterator c = controls.begin(); c != controls.end(); ++c) { (*c).second->list()->set_interpolation( - // to be enabled when ControlList::rt_safe_earliest_event_linear_unlocked works properly - #if LINEAR_INTERPOLATION_MODE_WORKS_PROPERLY EventTypeMap::instance().interpolation_of((*c).first)); - #else - Evoral::ControlList::Discrete); - #endif } }