Create new sample

Status
Not open for further replies.

cesarcofre

New member
Hi guys, I'm trying to create a new sample from a wav file, but i cant do it . Can someone help me with a step by step . Thanks!
 
The PJRC has an Audio Tutorial that cover using wave files, did you find those examples and get them to work with similar code? Please make note of what Teensy and hardware is at hand - the PJRC Audio board or other is in use.
 
Can someone help me with a step by step .

Would you need those steps for Mac, Linux or Windows?

Generic not-OS-specific version is you put all the WAV files you want into a folder together with the wav2sketch program. There's a pre-built copy for Windows. On Mac & Linux you need to compile it. See the comments at the copy of the code for a typical command line. On Mac, you'll need to install Apple's X-code command line package (free download from Apple's website).

Then just run wav2sketch from the command line. It will read all the WAV files in that folder and create the files you copy into your Arduino sketch folder. Restart Arduino, so it re-reads your program and sees the new files.

If you want smaller output, use a program like Audacity to resample the WAV files to 22.1 kHz or even 11.025 kHz. Trim any silent samples off the beginning, and if the clip is long, maybe use the fade out effect to end it sooner and trim away all the unused silence, so you get smaller files.

By default wav2sketch expects 16 bit samples and uses ulaw compression to encode them with only 8 bits. For simple sounds, ulaw's distortion isn't bad (usually much better than if you just discard the low 8 bits). For complex sounds, like music with multiple instruments, ulaw's distortion can really ruin the sound of the weaker or higher frequency parts. If you give wav2sketch an optional "-16" option on the command line, it will preserve full 16 bit quality. The output is double the size which burns Teensy's internal flash very fast, but if your sound is complex it will sound better.

For playing sample, click File > Examples > Audio > SamplePlayer. Or check out Part 2-03 of the audio library tutorial. Scroll down for the full walkthrough video, where Alysia & I demo that and every other part of the tutorial.
 
Last edited:
Status
Not open for further replies.
Back
Top