X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fmidi_source.cc;h=655222413aa0a5f5d836c6121c5511a99d8569c0;hb=cab09d87b8b660e6d2a6169346d30c1629d59bbb;hp=1887b74302104db67fc2018d8bc3bb43f5d5994e;hpb=f4b5f4c72ee60b6f509e307c5bfd164108d1f30b;p=ardour.git diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 1887b74302..655222413a 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -38,6 +38,7 @@ #include "ardour/midi_model.h" #include "ardour/midi_state_tracker.h" #include "ardour/midi_source.h" +#include "ardour/file_source.h" #include "ardour/session.h" #include "ardour/session_directory.h" #include "ardour/source_factory.h" @@ -331,31 +332,9 @@ MidiSource::mark_streaming_write_completed () mark_midi_streaming_write_completed (Evoral::Sequence::DeleteStuckNotes); } -boost::shared_ptr -MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::MusicalTime end) +int +MidiSource::write_to (boost::shared_ptr newsrc, Evoral::MusicalTime begin, Evoral::MusicalTime end) { - string newname = PBD::basename_nosuffix(_name.val()); - string newpath; - - if (path.empty()) { - - /* get a new name for the MIDI file we're going to write to - */ - - do { - newname = bump_name_once (newname, '-'); - newpath = Glib::build_filename (_session.session_directory().midi_path(), newname + ".mid"); - - } while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS)); - } else { - /* caller must check for pre-existing file */ - newpath = path; - } - - boost::shared_ptr newsrc = boost::dynamic_pointer_cast( - SourceFactory::createWritable(DataType::MIDI, _session, - newpath, false, _session.frame_rate())); - newsrc->set_timeline_position(_timeline_position); newsrc->copy_interpolation_from (this); newsrc->copy_automation_state_from (this); @@ -368,7 +347,7 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica } } else { error << string_compose (_("programming error: %1"), X_("no model for MidiSource during ::clone()")); - return boost::shared_ptr(); + return -1; } newsrc->flush_midi(); @@ -380,8 +359,12 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica } else { newsrc->set_model (_model); } + + /* this file is not removable (but since it is MIDI, it is mutable) */ - return newsrc; + boost::dynamic_pointer_cast (newsrc)->prevent_deletion (); + + return 0; } void