The reason why the audio appears to "drop out" is that the loop always runs to the *end of the track*, so if loop length < track length, the loop start will be offset from the beginning of the track. If you add a new event in past the current track end, that is now the new track end, and the loop end *is pushed out* to that time. If there is a lot of silence between the previous track (and loop) end and the new one, then loop_length's worth of that silence now becomes part of the loop.
Draw that out on "paper" and you will see:
Initial Case with events throughout track (***)
Track Start Track End <------------------- Loop Length----------------------> **********************MIDI Events********************** |------------------- WHAT YOU HEAR -------------------|
New Event (%) Added Out Past End
Track Start Track End <------------------- Loop Length----------------------> ******************MIDI Events******************* % |------------------- WHAT YOU HEAR -------------------|
So note (no pun intended) that what you will now hear is the second half of the old events, then silence, then your new event followed immediately by the second half of the old events again, etc.
When you hear the gap depends on where the new event was entered, and where the playback point was at the time.
This also explains what you mention in your final comment: the loop *always* goes to the EOT, regardless of where you add events prior to that. Setting track length shorter and shorter would have the effect of moving the start of the loop closer and closer to the end of the track.
-DS
Adding notes on the fly to a looping MusicTrack appears to not work as expected. I will have to add say 5 or six (a seemingly random number of) notes before MusicPlayer acknowledges it.
My RSI is killing me today, so rather than type my explanation out , I will just copy and paste someone else's similar issue...
it is 7 years later and i m having the same problem as xmidi:
"(1) I enter some MIDI Events into a MusicTrack via MusicTrackNewMIDINoteEvent() - I generate new MIDI events when one clicks within a specified area. (2) Set the track to loop every four beats. (3) Start the sequence - the sequence successfully sends out the notes and loops properly (4) Now when one clicks around some more (and thus creates new Events), the new events *ARE* successfully entered into the MusicTrack but every 10th new Event or so causes the MusicPlayer to *temporarily* pause until another Event is entered.
To note: none of the new Events are ever 'lost' or mis-entered, just seems to block the MusicPlayer."
but it happens only, if the loop property is used. i m writing only MIDIRawData to my Sequence and i m also unable to set kSequenceTrackProperty_TrackLength. it works until i add an event behind _TrackLength, from now on always the last event in the track is the _TrackLength, even if set _TrackLength again before those events..
|