Fast .wav Playback?
HMSTL
Posts: 16
Hello all,
I am completely new to Propeller and want to use it in a project where an input signal will have a .wav file stored on an SD card play as quickly as possible. I would like to use 16-bit wav files at 44.1kHz playback. The wav files only need to be about 2 seconds long, but I need a dozen or so ready to be played relatively instantly.
Is my project feasible? Would it be possible to have the SD load the files into some sort of DRAM before they are needed for faster retrieval? Obviously it's possible but 16-bit DRAM doesn't seem too common...
In case you couldn't tell, I'm really new to this stuff and have virtually no idea what I'm doing.
I am completely new to Propeller and want to use it in a project where an input signal will have a .wav file stored on an SD card play as quickly as possible. I would like to use 16-bit wav files at 44.1kHz playback. The wav files only need to be about 2 seconds long, but I need a dozen or so ready to be played relatively instantly.
Is my project feasible? Would it be possible to have the SD load the files into some sort of DRAM before they are needed for faster retrieval? Obviously it's possible but 16-bit DRAM doesn't seem too common...
In case you couldn't tell, I'm really new to this stuff and have virtually no idea what I'm doing.
Comments
Another approach is the propeller based EFX-TEK board made by John Williams (nee MacPhalen) that plays very high quality audio files as you specify with excellent sound and good amplification. This one is already made and has support for it.
Many of us have written WAV player code, so you've got lots of material to start with.
John Williams is the famous guy (Star Wars composer) which is why I am forced to use my family name, McPhalen. It's an honor, though, as my grandfather, Earnest John McPhalen, was a musician before an industrial accident cut short his career in show business.
I would also like to implement polyphony, but I know that can get tricky. I figured with 8 cogs it should be possible to do three of four of my short wavs at a time, but I don't know if it is possible with the object you have provided.
Thank you for the fast responses!
It's not. In my code you need one cog for the SD card, one to play the buffers, if noise is an issue then one for Chip's StereoDuty, and, finally, one for stuffing the buffers though this could be removed if you play a single file "inline."
Have a look at all the available code samples; you'll see there's a bit of work to play a WAV file.
There have been experiments by some to play two files at once, though I've not worked with that code.
I have done some reading on how a wav formats are stored on SD cards and how the SD card handles its data, and I think I might be able to achieve mixing by putting all my sounds in one file (the sum of the individual file sizes is well below the wav file size limit) and making a list on one of the cogs of where the different sounds start in the chunk of the file and their duration, so that I can just have the one file buffered and pull the parts I want out to play. I think that since they are in the same file that I will be able to grab samples from different places in the file and add the individual samples together before outputting them in order to combine the sounds.
I understand that each cog can output a frequency that doesn't interfere with whatever else it's doing. Can you use the samples from the file to modify the frequency of a cog's output in to have a FM output?
Sorry for all the questions and possibly ignorant-sounding conjecture, I just want to know if any of these ideas are remotely feasible.
Does this software have the anti thump setups?
(I am at work and can't download yet)
That said, I made a recent change to the AP-16+ so that it ignores metadata appended to the end of the file. I had never seen this but a customer sent me a file that did indeed have it. The WAV header gives the size of the audio chunk so I use that instead of playing through to the end of the file.
I tried a .wav player before (unsure which one) and it had these thumps and a background whine so it was unsuitable for my use. I need to have a "bell ring" for 2-3 seconds and the an automatic re-cue for the next demand.
A slower ramping up to the half way point would help.
I requested 16-bit resolution at 44.1kHz sampling playback, but after learning a little more about what exactly that means, I've realized that it would require a sampling period of 22.7 microseconds with values whose period uses 1/65536 of the sampling period. How can the output possibly have that kind of resolution within that sampling rate?
What kind of output does this produce that can deliver 16-bit resolution in 22.67 us?
These buffers are a sort of small-scale preloading, aren't they (just for sections of samples)? So that you can feed the values to the counters continuously, right?
I'm trying your *.wav player, but I can't get to have any output at all.
Is there any exact diagram of an SD-card (not microSD) connections? I may missed out something in the connection of the SD card to the Prop.
Also, what R/C values on the DAC should I use? Thanks.
page 3 on
http://www.cypress.com/?docID=9706
I hope this helps. If I understand correctly, you need the resistors and all of those connections except for the SD_CD and SD_WP.