mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-03 12:19:33 +01:00
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().
This commit is contained in:
parent
728e6027d1
commit
f371ac1beb
4 changed files with 63 additions and 0 deletions
|
|
@ -384,6 +384,23 @@ MidiSource::mark_streaming_write_completed (const Lock& lock)
|
|||
mark_midi_streaming_write_completed (lock, Evoral::Sequence<Evoral::Beats>::DeleteStuckNotes);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue