Re: MusicPlayer stopping then restarting
Re: MusicPlayer stopping then restarting
- Subject: Re: MusicPlayer stopping then restarting
- From: Bill Stewart <email@hidden>
- Date: Tue, 12 Aug 2003 23:03:52 -0700
ITs the AudioUnitReset and Note Off combination that you need...
ie. when you are resetting your time, you need to turn the existing
notes off (which I think the player is doing correctly) - the biggest
problem is that if the sequence is stopped (and its underlying render
graph is stopped as well), then you need to reset the AU before you
start it up again. This should clear out all of the state the AU has
(such as tails of sounding notes)
Now that is NOT guaranteed to remove the clicks... because if you just
kill the playback engine when you stop it, you will hear clicks.
In order to really achieve this you have to do a little more work.
- Start the players graph *before* you start the player
- Start the player
- Stop the player
(that will let the graph run on (because you started it independently
of starting the player) - having sent out note offs to the synths when
you stopped the player you will hear the note slowly decay into its
note off phase (and the tail of the reverb also die down) -
- then you can stop the rendering graph (you could use a timer, and
just set it to fire say 5 to 10 seconds later...)
Now - when you restart the graph (step 1 above), in order not to hear
any of the quiet "junk" you might have left over, you should then Reset
the AU, so that it starts clean.
Now - if you are merely resetting the time to a new time, you *don't*
want to stop the rendering graph, because you want to hear the old
notes from the old time die their natural deaths as the new notes come
in. (nor in this situation do you want to reset the AU of course)
The improvements that we've made to the player for Panther will
incorporate this logic about resetting (and its also more careful about
both resetting the new time, and only turning off notes and controller
state that it established) - so all in all a better behaving monster we
hope!
Bill
On Tuesday, August 12, 2003, at 06:42 PM, Michael Norris wrote:
This topic was discussed back in January, but none of the suggested
solutions seemed to cure with the problem completely, rather they just
improved the symptoms.
I wonder if anyone has discovered the perfect solution...
THE PROBLEM:
When a MusicPlayer sequence is stopped mid-flight, the time reset to
zero then restarted, a very audible "blip" (sometimes quite loud) is
heard as the notes that were playing when MusicPlayer stopped are
flushed from the queue.
The two suggestions in previous posts were:
1) Doing an AudioUnitReset
2) Sending a MIDI notes off message just before and after restarting
Anyone like to comment on the efficacy of these or other methods?
FYI, here's a summary of the code sequence:
NewMusicPlayer(&player);
NewMusicSequence(&sequence);
MusicSequenceNewTrack(sequence,&track);
// add notes using:
MusicTrackNewMIDINoteEvent (
track, timeStamp, ¬eMessage);
MusicPlayerSetSequence (player, sequence);
MusicPlayerPreroll (player);
MusicPlayerStart (player);
// then when mid-flight
MusicPlayerStop (player);
MusicPlayerSetTime(player, 0.0);
// wait a while then:
MusicPlayerPreroll (player);
MusicPlayerStart (player);
// the "blip" is heard
-----------------------
Michael Norris
Composer/Programmer
8 Bidwill St
Mt Cook
Wellington 6002
NEW ZEALAND
-----------------------
Ph: +64 4 803 3644
Web: http://mnorris.wellington.net.nz
Stroma: http://stroma.wellington.net.nz
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.