diff options
author | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2016-07-20 01:53:31 +0200 |
---|---|---|
committer | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2016-07-20 02:01:40 +0200 |
commit | f371ac1beb035716ef2e1def831a61bd4b5020c2 (patch) | |
tree | d27d8d39f34a014be79991e9f6562072e18e61fb /libs/ardour/midi_source.cc | |
parent | 728e6027d19d7c8f180187a27c8cc744917dc83f (diff) |
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().
Diffstat (limited to 'libs/ardour/midi_source.cc')
-rw-r--r-- | libs/ardour/midi_source.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 5b671b4a26..97bce4b1ab 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -385,6 +385,23 @@ MidiSource::mark_streaming_write_completed (const Lock& lock) } int +MidiSource::export_write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::Beats begin, Evoral::Beats end) +{ + Lock newsrc_lock (newsrc->mutex ()); + + if (!_model) { + error << string_compose (_("programming error: %1"), X_("no model for MidiSource during export")); + return -1; + } + + _model->write_section_to (newsrc, newsrc_lock, begin, end, true); + + newsrc->flush_midi(newsrc_lock); + + return 0; +} + +int MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Evoral::Beats begin, Evoral::Beats end) { Lock newsrc_lock (newsrc->mutex ()); |