I'm familiarizing myself with AKMusicTrack functions, specifically functions used to clear note data from a given sequence.
I can see that clearRange()
will clear note data between a start and end range, and clearNote()
will remove all events in the sequence of that note value.
Does anyone know of a function that will clear a single note? As in something like clearSingleNote(noteNumber MIDINoteNumber, position AKDuration, end AKDuration)
?
You can use getMIDINoteData()
to get an array of AKMIDINoteData
, filter out the notes you don't want, then overwrite the music track using replaceMIDINoteData()
with your filtered array:
// remove a C at timestamp 4.0
var trackData = myTrack.getMIDINoteData()
trackData = trackData.filter { $0.noteNumber =! 60 &&
$0.duration =! AKDuration(beats: 4.0) }
myTrack.replaceMIDINoteData(with: trackData)
There are more examples using getMIDINoteData()
in the MIDIFileEditAndSync example project.