Add removeTrack and insertTrack to MidiFile class?


#1

I need to be able to remove and insert tracks to an existing MidiFile object.

I added the following to juce_MidiFile.h and it works fine as the underlying OwnedArray supports these methods. Could these methods be supported in the official version?

void removeTrack (int indexToRemove, bool deleteObject = true)
{
    tracks.remove(indexToRemove, deleteObject);
}

void insertTrack (int index, const MidiMessageSequence& trackSequence)
{
    tracks.insert(index, new MidiMessageSequence (trackSequence));
}

#2

I’m a little reluctant to just add a bunch of methods to manipulate the array… I think it probably makes more sense with this kind of class to not use it as a persistent thing that stores your state and is modified, but rather to keep your tracks in some other kind of model container, and then when it’s time to generate a midi file, you create a new temporary MidiFile object from them, use it, and discard it.