Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing track names from midi file instead of overwriting them with "InitializedTrack" #2903

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

techfreak01
Copy link
Contributor

Hi Aure

I tried to use AppleSequencer to read a midi file, find a specific track by name, make some changes on that track and then write the result back to the file with sequencer.genData()!.write(to: fileUrl!).

While doing that, I run into two issues of AppleSequencer midi file handling:

  • When reading a file with named tracks (containing TrackName meta events), these names are ignored and all tracks in AudioKit have the same name "InitializedTrack"
  • When writing the sequence back into the midi file, additional meta events with track name "InitializedTrack" were added to the midi file.

This pull request fixes these two issues as following:

  • function init(musicTrack: MusicTrack, name: String = "Unnamed") in MusicTrackManager now reads the track name from existing meta event, if the name parameter is an empty string. If no track name meta event is found, no name is set by intention (to not change midi file when writing back).
  • function init(musicTrack: MusicTrack, name: String = "Unnamed") in MusicTrackManager first removes existing track name meta event before adding a new one.
  • function initTracks() in AppleSequencer initializes MusicTrackManager with empty name to request track names from midi file
  • Added a new public function addMetaEvent() that is also internally used to write the track name meta event
  • Added a new public function clearMetaEvent(_ metaEventType: MIDIByte) that is also internally used to delete existing track name meta event.

Regards, Matthias

Matthias Bauer added 4 commits March 1, 2024 11:15
…Track"

- Do not set a track name for tracks not named in midi file
…a event.

Only use existing track name from meta event, if the name parameter is an empty string
@aure aure merged commit df84034 into AudioKit:main Apr 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants