Your sound data is only a bit over 10% of the length of the demo sound in the library, so given that you said this is 20% of your original data the length of the sample shouldn’t be the issue.
Can you post the entiresound?
Can you also provide the exact type of your amp module?
I’ve also tried an 8 ohm speaker now, with the same results as before… I really don’t know why the sound isn’t playing correctly, unless it’s a compiler issue of some sort.
I’ve been compiling this using the Desktop IDE. Is there a preferred method of compiling by chance?
What sample rate was that WAV file? It’s huge (670KB)
Was it definetly mono?
That entire file seems to be sampled at 44.1kHz which is definetly overkill. You won’t get CD quality out of a Photon.
22050 Hz should be more than enough and will immediately half your data.
Next trim all the lead-in and lead-out off your sound, you don’t want to waste space for more or less silence.
If you don’t see yourself doing that you can also post the WAV file itself and I’ll try what I can do.
Oddly, when referencing this file, the compiler gives the message “Compiler timed out or encountered an error”, which I’ve been seeing a lot of while working on this. I’m not sure what else to try, besides continuing to click on “Compile and Flash” and hope for the best.
Update: I tried the Web IDE instead and this time the compiler finished and flashed the photon fine. Sadly, the audio was still the same as before. The only difference was a larger gap between the loops.
Amazing! I figured it had to be my code. Once I changed it to your code it worked perfectly as well. I had coded it per your post from April 2018, using a different initialization for the Speaker var and using the memcpy function.
Now I need to figure out how to stream the audio from the SD card to the DAC pin… That will be another rodeo.
In order to stream it from SD you’d need to get my code from above (plus some SD stuff and buffer swapping) and read the data in smaller chunks as you won’t have 100+ KB RAM to fit as many samples in.
This should take “any” 16 bit WAV file stored in the root directory of an SD card, parses the header and plays its left/mono/primary channel via the speaker library on the DAC pin.
To select a file you’d send the file name (including file extension) to the exposed Particle.function("playWav"). To see what files are stored on the SD you can send dir
Hey guys, apologies again for reviving this old thread, but it seems the app you wrote isn’t available anymore, @ScruffR. I’m making a photon based chime doorbell as well, and I want it to have multiple sounds, so the SD card app would be great to have! Could you share the code again?
Edit: the code is available on github: particle-speaker/examples/playWavFromSD at master · monkbroc/particle-speaker · GitHub