Shop OBEX P1 Docs P2 Docs Learn Events
Can I play two WAV files at the same time? — Parallax Forums

Can I play two WAV files at the same time?

TomlikesrocksTomlikesrocks Posts: 5
edited 2010-07-14 01:15 in Propeller 1
Hi everyone,

I've just starting working with the Propeller Chip and while i've managed to play a single WAV file fine and an MP3 file using the VS1002.
I'm wanting to know if there a way to play two .WAV files at the same time with the one SD card?

Thanks


Regards
Tom

Comments

  • RaymanRayman Posts: 14,889
    edited 2010-07-13 12:35
    I bet you can... You just have to juggle access to the SD card, but I think it can be done. I'm pretty sure the FSRW driver in OBEX can read much faster than .wav players play...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

    My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • lonesocklonesock Posts: 917
    edited 2010-07-13 14:10
    Simply declare 2 FSRW objects, only initialize one of them, then you can open a different file with each copy of the FSRW object. You should probably call both copies of the object from the same cog, though. (It might work since you are doing read only, but I wouldn't chance it.) Make sure to use the latest FSRW 2.6 from the OBEX, since some earlier versions don't support multiple copies.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
    (geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
  • sssidneysssidney Posts: 64
    edited 2010-07-13 20:24
    lonesock - could you call the read routine from different cogs if you put spin lock loops around the calls?


    
      repeat until not lockset(SemID)
      retLen := fr[noparse][[/noparse]0].pread(buf, BUF_SIZE)
      lockclr(SemID)
    
    
    
  • lonesocklonesock Posts: 917
    edited 2010-07-13 20:46
    FSRW is only the upper layer, and each instance will get it's own copy of local variables. The underlying block driver that talks with the card only runs a single copy of itself, so you should not need to use any locks. For read-only operation, I believe you can call FSRW from multiple cogs...I just have never tried it. (The mildly more difficult task is modifying FSRW to use 2 different block-layer drivers, for e.g. if you have 2 SD card slots physically hooked up to the prop.)

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
    (geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
  • sssidneysssidney Posts: 64
    edited 2010-07-13 20:55
    What happens in the block driver if it receives a new request while it is still handling the previous one?
  • lonesocklonesock Posts: 917
    edited 2010-07-13 21:05
    You know what, you're right. Looking at the code, there is a possibility that one of the FSRW objects will mistakenly think it's request has been handled, while it is really another FSRW's request that was being answered. So, yes, if calling from a different cog, we can get into trouble.

    So, either set up a handler cog to do the reading from all files as necessary, or put some form of locking around the 'readblock' calls.

    I should have some free time in about a week, if you need any support.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
    (geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
  • sssidneysssidney Posts: 64
    edited 2010-07-13 21:13
    Yeah, SPI_command variable would get out of sync. There would either have to be locking at that level or some form of queuing of requests.
  • TomlikesrocksTomlikesrocks Posts: 5
    edited 2010-07-14 01:15
    Wow, thanks guys.

    I went to bed with no replies, and wake up this morning with lots of helpful info.

    I didn't think FSRW could handle multiple files so i'll have a play and see what i can come up with.
    Looks like i have a challenge. (which is a good thing)

    Cheers [noparse]:)[/noparse]
Sign In or Register to comment.