title: AVMIDIPlayer init with MusicSequence
body: <p>AVMIDIPlayer has this initializer:</p>
  
  <pre><code>initWithData:soundBankURL:error:
  </code></pre>
  
  <p>This is in addition to an initializer for reading from a standard MIDI file.</p>
  
  <p>The data is NSData, which I assumed is in a standard MIDI file format. So, how to get that data? Well, the current way to create a MIDI sequence is the AudioToolbox MusicSequence. (AVAudioEngine even has a member of this type).</p>
  
  <p>MusicSequence has this converter:</p>
  
  <pre><code>MusicSequenceFileCreateData (
          MusicSequence            inSequence,
          MusicSequenceFileTypeID  inFileType,
          MusicSequenceFileFlags   inFlags,
          SInt16                   inResolution,
          CFDataRef                *outData
      );
  </code></pre>
  
  <p>So let's try that.</p>
  
  <pre><code>var status = OSStatus(noErr)
  var data:Unmanaged&lt;CFData&gt;?
  status = MusicSequenceFileCreateData (musicSequence,
          MusicSequenceFileTypeID(kMusicSequenceFile_MIDIType),
          MusicSequenceFileFlags(kMusicSequenceFileFlags_EraseFile),
          480, &amp;data)
  
  var ns:NSData = data!.takeRetainedValue()
  var error:NSError?
  self.mp = AVMIDIPlayer(data: ns, soundBankURL: soundbank, error: &amp;error)
  </code></pre>
  
  <p>(I've loaded the soundbank previously). 
  Good news: That does play the MIDI data.
  Bad news: Upon reaching the end of the sequence, it crashes.</p>
  
  <pre><code>queue = 'CallbackQueue', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  </code></pre>
  
  <p>Two guesses. There is a bug in the platform code, or (more likely) my code.</p>
  
  <p>tl;dr Am I getting the data incorrectly?</p>