Add a dedicated export method to MidiRegion
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Tue, 19 Jul 2016 23:53:31 +0000 (01:53 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Wed, 20 Jul 2016 00:01:40 +0000 (02:01 +0200)
commitf371ac1beb035716ef2e1def831a61bd4b5020c2
treed27d8d39f34a014be79991e9f6562072e18e61fb
parent728e6027d19d7c8f180187a27c8cc744917dc83f
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_region.h
libs/ardour/ardour/midi_source.h
libs/ardour/midi_region.cc
libs/ardour/midi_source.cc