Seamless WAV restarting
WIFLI
Posts: 4
Hi all,
Long time lurker, first time poster! I'm looking to use Kye's KISS WAV Player Driver to play WAV files for an audio project, and I need to be able to seamlessly restart playback (while playing a file, having playback restart from the beginning of the file before playback has completed) fairly rapidly (ideally within 50ms or less, within 100ms at a minimum). I had thought it would be as simple as changing the sample position to its intial value so the object would refill buffers from the beginning of the file, but that doesn't seem to do the trick.
I get the feeling I'm missing something conceptual here, and so far I've gotten nowhere trying to figure out what's wrong. Any thoughts on what I'm missing? Is there a better approach to what I'm trying to accomplish? (I haven't posted code because it's long and it's a well-known object, would be happy to so so though if it makes it easier)
Long time lurker, first time poster! I'm looking to use Kye's KISS WAV Player Driver to play WAV files for an audio project, and I need to be able to seamlessly restart playback (while playing a file, having playback restart from the beginning of the file before playback has completed) fairly rapidly (ideally within 50ms or less, within 100ms at a minimum). I had thought it would be as simple as changing the sample position to its intial value so the object would refill buffers from the beginning of the file, but that doesn't seem to do the trick.
I get the feeling I'm missing something conceptual here, and so far I've gotten nowhere trying to figure out what's wrong. Any thoughts on what I'm missing? Is there a better approach to what I'm trying to accomplish? (I haven't posted code because it's long and it's a well-known object, would be happy to so so though if it makes it easier)
Comments
Measuring the time from when I first call the wavplayer to the time the file begins playing, I get about 229 ms. This is also measured on a loop which lets the file play to completion; so far I've been unable to stop the cog prior to file completion and restart it without problems.
I assume that's the way to do it; the problem is I'm not sure how to do this in ASM. Below is the code for the player:
Despite the excellent documentation, I can't seem to figure out how to make this work. Should I be looking to reset samplePositionAddress to the initial value and jump back to outerLoop? If so, how would I pass a command from my main program to the wav-playing cog to let it know to loop? (I'm thinking I'd cmp the command register to a preset literal to trigger the restart, but not sure if that's the best way).
My apologies if the above code isn't clear enough without the spin...like I said above, I think it's a conceptual problem I have with my lack of skill in ASM. If you have an object you're more familiar with and could better use as an example, I'd be happy to try to follow along...it seems I couldn't understand much less about a new object than I do about this one!
Thanks,
Wow, can't ask for more than that...will do Kye, thanks!
Sorry to reopen this topic, but I have a similar project that needs a seamless WAV player. Can someone enlighten me on how this can be done? I am currently using Kye's amazing KISS object.
Is your WAV player in the OBEX? I've tried queuing multiple sounds using the KISS driver, but there are noticeable pauses between each play.
Thanks for the help!
My object doesn't have a queing feature for multiple files -- I have never needed that, and it would be easy to code for an application that does. That said, the play() method has a counts parameter so you can play the same file any number of times. If you specify 0 as the count parameter, it gets promoted to POSX -- we figured 2.14 billion plays counts as forever. BTW, this code is the audio engine in the AP-16+ which is used in haunted houses, museums, Disneyland, and just last year Legoland selected the AP-16+ plus the HC-8+ (both from EFX-TEK) for their audio-animatronic displays across the world.
Thank you for all the help.