Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, here's what I think is happening: Core Audio is pull-based, that is, when a unit needs data, it requests it from its source. Now when I reset the time on a MusicPlayer, it's done at a certain time, say t0. Shortly after, at time t1, the AU Node fed by this MusicPlayer asks for data. The MusicPlayer takes t1 and computes where it falls in its sequence of events. Since it is invariably greater than t0, any event that starts exactly at t0 (e.g. events that starts at MIDI tick 0) are considered played and are thus not played at all. In other words, the first note(s) of the midi files is/are not played. </p> <p>Now, since my files are very short and in fact contain only a chord starting at tick 0, none of the notes are played and I get silence.</p> <p>Why this isn't happening when I load a new sequence or start a sequence when it is not already playing is not clear to me...</p> <p>Anyway, one possible fix is to: stop the player, set the sequence, set the time to 0 then delay the start of the player by e.g. 25ms. That is not ideal for responsiveness, but it works.</p> <p>A slightly more convoluted way to fix this is the following:<br> - set up a callback on render on the audio unit the music player is feeding (AudioUnitAddRenderNotify())<br> - at the time of the reset of the sequence, don't reset the time on the player but set a boolean flag<br> - in the render callback, if the flag is set, reset the time on the player and unset the flag<br> There is no delay introduced and it also works, which tends to validate my interpretation of the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload