075 Make Your Own Samples

This will step through the process of making samples that are compatible with the PickADK Sample Player program.

I'll show how I processed the cash register sample that you've been using.

I downloaded the MP3 file from here:

https://freesound.org/people/kiddpark/sounds/201159/

Once you've found an interesting file, import it into Audacity:

https://www.audacityteam.org/

I selected the area starting just before the attack, and ending, sadly, well before that wonderful ringdown.

Select by clicking on the starting point and dragging to the stopping point.

Then click the dropdown menu File → Export → Export Selected Audio

Save as a WAV file.  Set Encoding to "Signed 16-bit PCM"

If you want to downsample to 22K, then you first click on the entire sample to select it,

then click the dropdown menu Tracks → Resample.

Set the new sample rate to 22050.

Then click the "Audio Setup" button on the task bar.

Select "Audio Settings..."

Set the Project Sample Rate to 22050 and click OK

Then select the area of interest, and export, as you did before.

The files should be about half as large as the 44100 version


The next trick involves converting the wave files to .cpp files with PJRC's nifty wav2sketch utility


https://www.pjrc.com/teensy/td_libs_AudioPlayMemory.html


I can't find the most recent executable on-line, but this one has been working for me:

This is a Windows executable, so you will need a Windows machine for the finish processing.

Put wav2sketch into its own directory, along with any .wav files you wish to convert.

If you just double click on the wav2sketch icon in the directory, it will process the .wav files.

Each .wav files will get converted into a .cpp file and a .h file.

Inspect the .cpp file to make sure the format is correct.  The first sample of data should start with:

0x01 for 44 KHz u-law encoding

0x02 for 22 KHz u-law encoding

0x81 for 44 KHz 16-bit encoding

0x82 for 22 KHz u-law encoding

Here are the results:


u-law encoding compresses each 16-bit sample to an 8-bit approximation:

https://en.wikipedia.org/wiki/%CE%9C-law_algorithm

thereby reducing your storage requirements by half.

u-law coding is the standard format for wav2sketch.  If you want no encoding, you need to call wav2sketch with a command line argument:

wav2sketch -16

Here are the results:


















Copyright © 2024 The President and Fellows of Harvard College * Accessibility * Support * Request Access * Terms of Use