title: Modify Playback Tempo of an AVAudioSequencer / AVMusicTrack?
body: <p>How does one programmatically change the tempo (in BPM) of an <code>AVAudioSequencer</code> that's been loaded from an existing MIDI file (i.e. using the following)?</p>
  
  <pre><code>try sequencer.load(from: fileURL, options: AVMusicSequenceLoadOptions.smfChannelsToTracks)
  </code></pre>
  
  <p>I know that the sequencer's <code>tempoTrack</code> property returns the <code>AVMusicTrack</code> controlling the tempo, but how does one then edit it to add/change tempo events? The <a href="https://developer.apple.com/documentation/avfoundation/avaudiosequencer/1390252-tempotrack" rel="nofollow noreferrer">Apple documentation</a> simply says...</p>
  
  <blockquote>
    <p>"The tempo track can be edited and iterated upon as any other track. Non-tempo events in a tempo track are ignored."</p>
  </blockquote>
  
  <p>...but gives no further indication on how such editing would be done.</p>
  
  <p>I know there's the <code>rate</code> property, but that just revolves around a default value of 1.0, which would need some complex adjustments to allow BPM values, and I don't think would even be possible unless the file's original BPM is known at runtime.</p>
  
  <p>Alternatively, is there a way to create a new <code>AVMusicTrack</code> from scratch, with a custom tempo, and make <em>that</em> the sequencer's <code>tempoTrack</code>?</p>