From f371ac1beb035716ef2e1def831a61bd4b5020c2 Mon Sep 17 00:00:00 2001 From: "Julien \"_FrnchFrgg_\" RIVAUD" Date: Wed, 20 Jul 2016 01:53:31 +0200 Subject: Add a dedicated export method to MidiRegion To export a MIDI region to a file, the code used MidiRegion::clone() since it takes care of creating a new file-backed source with the wanted contents. Nevertheless, it had several side-effects: - it created and registered a new region which is confusing to users - it only exported notes that were in the region range, but didn't remove the region start offset from MIDI events, essentially producing a spurious silence at the beginning of the exported file (this is not a problem for region cloning because the newly created region is made aware of the offset and caters for it). Add a dedicated code path for export, that uses the new offsetting capabilities of MidiModel::write_section_to(). --- libs/ardour/ardour/midi_source.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libs/ardour/ardour/midi_source.h') diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 7f2ddfbc22..c8b4263e2a 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -63,6 +63,19 @@ class LIBARDOUR_API MidiSource : virtual public Source, public boost::enable_sha Evoral::Beats begin = Evoral::MinBeats, Evoral::Beats end = Evoral::MaxBeats); + /** Export the midi data in the given time range to another MidiSource + * \param newsrc MidiSource to which data will be written. Should be a + * new, empty source. If it already has contents, the results are + * undefined. Source must be writable. + * \param begin time of earliest event that can be written. + * \param end time of latest event that can be written. + * \return zero on success, non-zero if the write failed for any reason. + */ + int export_write_to (const Lock& lock, + boost::shared_ptr newsrc, + Evoral::Beats begin, + Evoral::Beats end); + /** Read the data in a given time range from the MIDI source. * All time stamps in parameters are in audio frames (even if the source has tempo time). * \param dst Ring buffer where read events are written. -- cgit v1.2.3