Shop OBEX P1 Docs P2 Docs Learn Events
play wave file — Parallax Forums

play wave file

JTCJTC Posts: 60
edited 2010-07-01 19:33 in Propeller 1
I have a project that I need to add sound effects to. The two files are 48k bytes and the other is 68k bytes.
What would be the best way to sore and playback on demand?
Could I store them on a 24LC1025 chip and play them the play back when needed?
How would I play it back? I know there is a stereo sound chip on the prop dev board but not sure how to use it.
Thank for any help you can give.

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-07-01 14:34
    Have a look look at Rayman's WAV driver in ObEx -- it will get you started. As far as using an EEPROM, that will depend on your sample rate -- can you read samples from the EEPROM and feed them to the counters (configured as DACs) fast enough for your sample rate? Ray -- and those of us who followed his example -- tend to put our WAV files on an SD card.

    My partner, John Barrowman (also a former Parallax employee), and I developed this WAV player for entertainment- and educational-oriented businesses (museums, theme parks, Halloween displays, etc.).

    www.efx-tek.com/topics/ap-16.html

    Things we learned along the way (the hard way):

    1. Put the DAC driver into Cog 1 -- reduces noise
    2. If you're going to do serious amplification of the output use Chip's StereoDuty driver to reduce inherent system noise

    Note that as our product has to monitor physical inputs and a serial channel *while* playing a WAV file, and we're using 20W amps that will reveal any noise, we have three cogs in use while a WAV file is playing: 1) reads WAV data from SD card into buffers, 2) reads data from buffer and adjusts for channel volume, 3) StereoDuty to output the sample while reducing noise.

    I've attached a demo that uses our WAV drivers (variants of the work originally done by Rayman) and Chip's StereoDuty cog to reduce noise. Note that you won't really hear the difference playing through PC speakers connected to the Demo Board; if you use big external amps you will.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • JTCJTC Posts: 60
    edited 2010-07-01 14:47
    Thanks for the info. I thought about the SD card but this device needs to be so small to fit in space provided for it that not sure I can fit one in. Thanks for the demo I will have a look at it. smile.gifsmile.gif
  • RaymanRayman Posts: 14,889
    edited 2010-07-01 15:18
    For plain sound effects and not recorded speech or music, there are a several codes that have been posted in this forum.
    You don't need an SD card for these sound effects drivers.
    I imagine there's a lot in the hydra forum too.
    Take a look in OBEX...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
  • JTCJTC Posts: 60
    edited 2010-07-01 15:36
    Thanks Raymond. I had not though of the Hydra .
    Thanks for the links . I will check them out.
    Jim
  • RaymanRayman Posts: 14,889
    edited 2010-07-01 15:48
    Here's a recent thread that references SIDcog:

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

    I think that does sound effects...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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-01 16:05
    Hi, Jim.

    Is the microSD form factor too large for your application? (Though the spec does not require the uSD cards to support the SPI mode, all of mine work..is this a 1-off project, or do you want to sell millions of them? [noparse][[/noparse]8^)

    The HSS (Hydra Sound System www.andrewarsenault.com/hss/index.html) has a 1-bit ADPCM compressed format...it's not good enough for high quality music, but it works.

    You could pretty easily support a more standard 4-bit-per-sample ADPCM compression scheme. With 4x compression, you can just barely fit (48k + 68k) into 32k. I'm assuming you have already tried lower sample rates, and lower bits-per-sample for your 2 sound effects?

    Jonathan

    P.S. @JonnyMac: you may want to update your code to use the safe_spi driver from the latest FSRW 2.6 release..you shouldn't see any speed decrease. I'm also working on a smaller version, which is planned to save some longs, at the cost of a small speed hit. I don't have a lot of free time ATM, but let me know if you are interested, and I'll try to crank it out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
    (geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
  • JTCJTC Posts: 60
    edited 2010-07-01 16:25
    Millions.. boy I wish.
    The project would be one run of 500 units.
    What size is the Micro SD. It may work, and that would be great. I like that idea.
    There may be future projects that will require more storage.

    If I could use the 24LC1025 eeprom in place of the 24lc256 there would be enough room if it is fast enough.
    Or maybe adding SPI eprom just for the sound.
    Adding the sound effects is the last part of the project and I have no experience with it.
    I will look at the Hydra as well. I don't have but about 1" X 2.5" space so I am using the smallest surface mount parts minimumizing the circuits as much as I can. I can put the audio amp about 2 or 3 inches away in another small space. I only need mono.
    Thanks
    Jim
  • sssidneysssidney Posts: 64
    edited 2010-07-01 17:28
    JonnyMac - Does your code/driver reduce or eliminate the pop that occurs at the start of playing a wav file in the other propeller wav players?

    Post Edited (sssidney) : 7/1/2010 5:34:02 PM GMT
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-07-01 19:33
    The pop you're experience has to do with starting and stopping the driver that controls the DACs; in our product (as in the above demo), the WAV driver continues to run between files, outputting silence (0v into the amp circuitry). As with most audio products, we get a bit of a power-up pop the from amps, but none when the file is started or stops.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA

    Post Edited (JonnyMac) : 7/1/2010 7:38:55 PM GMT
Sign In or Register to comment.