AVMIDIPlayer ignores initial track volume settings on first playback

Issue Description

When playing certain MIDI files using AVMIDIPlayer, the initial volume settings for individual tracks are being ignored during the first playback. This results in all tracks playing at the same volume level, regardless of their specified volume settings in the MIDI file.

Steps to Reproduce

  1. Load a MIDI file that contains different volume settings for multiple tracks
  2. Start playback using AVMIDIPlayer
  3. Observe that all tracks play at the same volume level, ignoring their individual volume settings

Current Behavior

  • All tracks play at the same volume level during initial playback
  • Track volume settings specified in the MIDI file are not being respected
  • This behavior consistently occurs on first playback of affected MIDI files

Expected Behavior

  • Each track should play at its specified volume level from the beginning
  • Volume settings in the MIDI file should be respected from the first playback

Workaround

I discovered that the correct volume settings can be restored by:

  1. Starting playback of the MIDI file
  2. Setting the currentPosition property to (current time - 1 second)
  3. After this operation, all tracks play at their intended volume levels

However, this is not an ideal solution as it requires manual intervention and may affect the playback experience.

Questions

  1. Is there a way to ensure the track volume settings are respected during the initial playback?
  2. Is this a known issue with AVMIDIPlayer?
  3. Are there any configuration settings or alternative approaches that could resolve this issue?

Technical Details

  • iOS Version: 18.1.1 (22B91)
  • Xcode Version: 16.1 (16B40)
AVMIDIPlayer ignores initial track volume settings on first playback
 
 
Q