Shop OBEX P1 Docs P2 Docs Learn Events
playing wav filies from a SD card, is there a delay? — Parallax Forums

playing wav filies from a SD card, is there a delay?

DgswanerDgswaner Posts: 795
edited 2008-03-04 00:34 in Propeller 1
Subject pretty much says it, doing some thinking/planning for new ad ons to my bot, it would be nice to have natural language error codes, for live debugging, or even a verbal menu. and I was just curious if someone could tell me if this is a reality or not. if it takes even a few seconds to load a wav and then play it, it won't work for debugging,

I know most of the answer is determined by file size, length etc. but If someone could tell me a delay (if any) for playing reasonably sized files on the go. from an SD card, by reasonable I'm talking 3-4 seconds or less. I know you can save wav files right to the prop and play them with no delay but I want to have several (10+/-) and know I won't have space.

if anyone has played with this before and could LEARN me I would appreciate it.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster

DGSwaner

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-03 23:12
    As you've noticed, the delay time is almost entirely determined by the size of the WAV file that you want to play. It's theoretically possible to read from the SD card while the beginning of the WAV file is playing, but that's a lot of work to get right. I think you'd do a lot better using some kind of text-based debug display. Sure speech is cool, but it's slow and not very dense ... you can't present a lot of information easily and quickly.

    I'd recommend using a small serial LCD display or, if you have enough memory, a video text display with a little TV monitor like the one Parallax sells. You can get a lot of informative information on a display like that and you can just disconnect it when you don't need it. You could even use broadcast mode for short range TV transmission.
  • ClemensClemens Posts: 236
    edited 2008-03-03 23:37
    Ray's asm wav player does audio-streaming. I tried it with a 5 minutes 40 MB file and it worked perfect.
    I can't find it on his site however, but I'm sure he'll tell us where it is as soon as he reads this thread. :-)

    Ah, here it is:

    http://forums.parallax.com/showthread.php?p=695703

    Try it, it's good.

    Post Edited (Clemens) : 3/3/2008 11:43:03 PM GMT
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2008-03-04 00:06
    Playing wav files normally involves setting up double buffers where one is feeding out the audio while the other is being read from storage. When the play buffer is exhausted it switches to the other buffer and then the exhausted play buffer is supplied with new data from storage. So you will need 2 cogs handling this as the audio cog needs to supply audio samples smoothly and without any hiccups. This way there is only the small delay of reading in the first buffer (usually a 512 byte sector). Of course the buffer has to be read in before the play buffer is exhausted but that shouldn't be a problem.

    Fill buffer A
    repeat (for n sectors)
    Play buffer A while filling buffer B
    Play buffer B while filling buffer A


    *Peter*
  • RaymanRayman Posts: 14,162
    edited 2008-03-04 00:34
    I'm using my wav player in a control system, much the way you describe.

    I don't notice any·delay.

    I have info here:

    http://www.rayslogic.com/propeller/Programming/dac/dac.htm
Sign In or Register to comment.