Copy/paste notes from different clips

Hi!

I am looking into the proper way to handle clipboard operations on notes selected from different MidiClip’s in a CollectionClip (on a FolderTrack).

Notes can be pasted on the same subtracks or different subtracks, so some of them might be empty (no MidiClip’s).

I’m using the SelectedMidiEvents class to hold MIDI notes from different MidiClip’s.

I’ve look into :

  • Clipboard / Clipboard::Clips. New clips are will be created. I could merge them after the paste operation. Not sure if it can handle pasting the content on different subtracks ? (Maybe that’s what trackOffset is used for).
  • Clipboard / Clipboard::MidiEvents, creating or fetching the MidiClip’s manually, calling Clipboard::pasteIntoClip(...) for each “source” MidiClip.

Or… write my own copy/paste code, taking care of the automations, etc., which would be quite complex.

Happy to hear your thoughts about this.

Thanks in advance!

E.

Update.

I tried using the Clipboard with Clipboard::Clips, and this seems to works nicely (when copying on the same tracks, for now).

After the paste operation, I call FolderTrack::generateCollectionClips(). As the old CollectionClip doesn’t reflect the new changes. I then iterate all CollectionClips to find the one that contains all the MidiClip’s associated to each selected notes.

I then proceed to merge the pasted clips, to keep things tidy.

This works nicely so far. I think I could use the same logic and Clip::moveToTrack() if the users wants to paste the same clips on different tracks.

BTW does the CollectionClip index is retained after a call to FolderTrack::generateCollectionClips() ? I could simply use the same index rather than manually searching the folder track CollectionClips.

E.