X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsmf_source.cc;h=9d332b5453d72534d1e2a9cf1cd0b4cf6dd1bc12;hb=6739b6a1e31f943f039b3c1678190af4fe0f8d16;hp=d5c89b5ee97bd0bbfe9fb3535ad389530e755699;hpb=c9023ae73d6d70fead3e827811b384e2b171e4d6;p=ardour.git diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index d5c89b5ee9..9d332b5453 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -30,7 +30,7 @@ #include "pbd/stl_delete.h" #include "pbd/strsplit.h" -#include +#include "pbd/gstdio_compat.h" #include #include @@ -71,7 +71,7 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags) if (init (_path, false)) { throw failed_constructor (); } - + assert (!Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); existence_check (); @@ -107,7 +107,7 @@ SMFSource::SMFSource (Session& s, const string& path) if (init (_path, true)) { throw failed_constructor (); } - + assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); existence_check (); @@ -202,6 +202,12 @@ SMFSource::open_for_write () return 0; } +void +SMFSource::close () +{ + /* nothing to do: file descriptor is never kept open */ +} + /** All stamps in audio frames */ framecnt_t SMFSource::read_unlocked (const Lock& lock, @@ -364,7 +370,7 @@ SMFSource::write_unlocked (const Lock& lock, break; } time -= position; - + ev.set(buf, size, time); ev.set_event_type(midi_parameter_type(ev.buffer()[0])); ev.set_id(Evoral::next_event_id()); @@ -391,9 +397,11 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock, return; } - /*printf("SMFSource: %s - append_event_beats ID = %d time = %lf, size = %u, data = ", +#if 0 + printf("SMFSource: %s - append_event_beats ID = %d time = %lf, size = %u, data = ", 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");*/ + for (size_t i = 0; i < ev.size(); ++i) printf("%X ", ev.buffer()[i]); printf("\n"); +#endif Evoral::Beats time = ev.time(); if (time < _last_ev_time_beats) { @@ -546,7 +554,7 @@ SMFSource::mark_midi_streaming_write_completed (const Lock& lm, Evoral::Sequence _model->set_edited(false); } - Evoral::SMF::end_write (); + Evoral::SMF::end_write (_path); /* data in the file now, not removable */ @@ -569,7 +577,7 @@ SMFSource::safe_midi_file_extension (const string& file) static bool compile = true; const int nmatches = 2; regmatch_t matches[nmatches]; - + if (Glib::file_test (file, Glib::FILE_TEST_EXISTS)) { if (!Glib::file_test (file, Glib::FILE_TEST_IS_REGULAR)) { /* exists but is not a regular file */ @@ -582,7 +590,7 @@ SMFSource::safe_midi_file_extension (const string& file) } else { compile = false; } - + if (regexec (&compiled_pattern, file.c_str(), nmatches, matches, 0)) { return false; } @@ -672,8 +680,8 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload ss += b; } - DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %6 load model delta %1, time %2, size %3 buf %4, type %5\n", - delta_t, time, size, ss , event_type, name())); + DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("SMF %7 load model delta %1, time %2, size %3 buf %4, type %5 id %6\n", + delta_t, time, size, ss , event_type, event_id, name())); #endif eventlist.push_back(make_pair ( @@ -702,6 +710,10 @@ SMFSource::load_model (const Glib::Threads::Mutex::Lock& lock, bool force_reload delete it->first; } + // cerr << "----SMF-SRC-----\n"; + // _playback_buf->dump (cerr); + // cerr << "----------------\n"; + _model->end_write (Evoral::Sequence::ResolveStuckNotes, _length_beats); _model->set_edited (false); invalidate(lock); @@ -726,7 +738,7 @@ SMFSource::flush_midi (const Lock& lock) ensure_disk_file (lock); - Evoral::SMF::end_write (); + Evoral::SMF::end_write (_path); /* data in the file means its no longer removable */ mark_nonremovable (); @@ -737,7 +749,6 @@ void SMFSource::set_path (const string& p) { FileSource::set_path (p); - SMF::set_path (_path); } /** Ensure that this source has some file on disk, even if it's just a SMF header */ @@ -773,8 +784,8 @@ SMFSource::prevent_deletion () /* Unlike the audio case, the MIDI file remains mutable (because we can edit MIDI data) */ - + _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy)); } - - + +