alter API for MIDI cloning to facilitate export
git-svn-id: svn://localhost/ardour2/branches/3.0@12401 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -62,7 +62,7 @@ class MidiRegion : public Region
|
||||
|
||||
~MidiRegion();
|
||||
|
||||
boost::shared_ptr<MidiRegion> clone () const;
|
||||
boost::shared_ptr<MidiRegion> clone (std::string path = std::string()) const;
|
||||
|
||||
boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
|
||||
MidiSource (Session& session, const XMLNode&);
|
||||
virtual ~MidiSource ();
|
||||
|
||||
boost::shared_ptr<MidiSource> clone (Evoral::MusicalTime begin = Evoral::MinMusicalTime,
|
||||
boost::shared_ptr<MidiSource> clone (const std::string& path,
|
||||
Evoral::MusicalTime begin = Evoral::MinMusicalTime,
|
||||
Evoral::MusicalTime end = Evoral::MaxMusicalTime);
|
||||
|
||||
/** Read the data in a given time range from the MIDI source.
|
||||
|
||||
@@ -128,13 +128,13 @@ MidiRegion::~MidiRegion ()
|
||||
/** Create a new MidiRegion that has its own version of some/all of the Source used by another.
|
||||
*/
|
||||
boost::shared_ptr<MidiRegion>
|
||||
MidiRegion::clone () const
|
||||
MidiRegion::clone (string path) const
|
||||
{
|
||||
BeatsFramesConverter bfc (_session.tempo_map(), _position);
|
||||
Evoral::MusicalTime const bbegin = bfc.from (_start);
|
||||
Evoral::MusicalTime const bend = bfc.from (_start + _length);
|
||||
|
||||
boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (bbegin, bend);
|
||||
boost::shared_ptr<MidiSource> ms = midi_source(0)->clone (path, bbegin, bend);
|
||||
|
||||
PropertyList plist;
|
||||
|
||||
|
||||
@@ -328,21 +328,26 @@ MidiSource::mark_streaming_write_completed ()
|
||||
}
|
||||
|
||||
boost::shared_ptr<MidiSource>
|
||||
MidiSource::clone (Evoral::MusicalTime begin, Evoral::MusicalTime end)
|
||||
MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::MusicalTime end)
|
||||
{
|
||||
string newname = PBD::basename_nosuffix(_name.val());
|
||||
string newpath;
|
||||
|
||||
/* get a new name for the MIDI file we're going to write to
|
||||
*/
|
||||
if (path.empty()) {
|
||||
|
||||
do {
|
||||
|
||||
newname = bump_name_once (newname, '-');
|
||||
/* XXX build path safely */
|
||||
newpath = _session.session_directory().midi_path().to_string() +"/"+ newname + ".mid";
|
||||
|
||||
} while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
|
||||
/* get a new name for the MIDI file we're going to write to
|
||||
*/
|
||||
|
||||
do {
|
||||
newname = bump_name_once (newname, '-');
|
||||
/* XXX build path safely */
|
||||
newpath = _session.session_directory().midi_path().to_string() +"/"+ newname + ".mid";
|
||||
|
||||
} while (Glib::file_test (newpath, Glib::FILE_TEST_EXISTS));
|
||||
} else {
|
||||
/* caller must check for pre-existing file */
|
||||
newpath = path;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MidiSource> newsrc = boost::dynamic_pointer_cast<MidiSource>(
|
||||
SourceFactory::createWritable(DataType::MIDI, _session,
|
||||
|
||||
Reference in New Issue
Block a user