Wave shields - raw format

Ethernet, Motor, Proto, Wave, GPS etc!

Moderators: magician13134, adafruit

Wave shields - raw format

Postby zi9 » Sun Jun 08, 2008 8:55 pm

Is it possible to read RAW format files with the wave shield and the library.
How to reduce the break between a short file, if played in a loop.
How to reduce the size of the library.
thank you for aou answers
zi9
 
Posts: 1
Joined: Sat Jun 07, 2008 7:38 pm

Re: Wave shields - raw format

Postby adafruit » Mon Jun 09, 2008 10:05 am

zi9 wrote:Is it possible to read RAW format files with the wave shield and the library.


i dont know what RAW is so im going to say 'no'

How to reduce the break between a short file, if played in a loop.


that may be possible with some hacking, but it isnt documented

How to reduce the size of the library.


um, you cant
Last edited by ladyada on Mon Jun 23, 2008 10:48 pm, edited 2 times in total.
User avatar
adafruit
 
Posts: 2184
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

joy of SoX

Postby dgoodwin » Sun Jun 22, 2008 8:23 pm

Hi zi9,

I just finished trying a few different file formats. This research was by no means exhaustive, but I did hit on a satisfactory format and a method for producing these files using Sound eXchange ["SoX"]. If you don't know about SoX, help yourself to a download: http://sox.sourceforge.net/

SoX goes like this:
sox [infile options] infile [outfile options] outfile

The waveshield want 16bit mono linear pcm little endian WAV files. How do you make those? You could use Audacity or Quicktime (as covered in the manual) or run this from the command line:

Code: Select all
sox \
  --show-progress \
  INFILE.wav \
  -w \
  -t wav \
  --endian little \
  -c 1 \
  -r 22050 \
  OUTFILE.wav \
  polyphase


This is a super-handy approach for producing batches of usable files!

Note that I'm assuming that your INFILE.wav needs to be resampled to 22k; if not, just leave out the "-r 22050" and "polyphase" lines. Some explication of the args below: see the SoX docs for more information.

Have fun,
-Doug

Code: Select all
# NOTES
# first install sox. On osx with macports installed it goes like this:
# sudo port install sox +lame
#
# make sound files for the waveshield
# INPUT.WAV
# -t         (input) file type (optional if extension is definitive)
# OUTPUT.WAV
# -w         16 bit words
# --endian little   the waveshield wants little endian files
# -c 1      mono (1 channel)
# -r 22050      rate 22050 Hz.
# -t         (output) file type
# -w         16 bit words
# polyphase   best method for resampling (compare resample)
         see http://leute.server.de/wilde/resample.html
dgoodwin
 
Posts: 1
Joined: Sun Jun 22, 2008 8:00 pm
Location: Boston, MA

Postby adafruit » Mon Jun 23, 2008 10:45 pm

nice! thanks for the tutorial, ill add it to the documentation
User avatar
adafruit
 
Posts: 2184
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Wave shields - raw format

Postby dy-wen » Thu Sep 17, 2009 3:14 pm

For Debian and Ubuntu-users. Sox is available through apt-get or synaptic.
To get it running, open a terminal, move to the folder where your sounds are (cd=change directory).
Once you are there copy paste this code in your terminal:
Code: Select all
sox --show-progress INFILE.wav  -t wav --endian little -c 1 -r 22050 OUTFILE.wav



replace INFILE.wav with the name of the file you want to convert.


(in Linux, the -w and polyphase don't seem to work)
(*.wav --> all wav files in the folder you are in seems to too, but Sox does give me this message: Input files must have the same sample-rate)
dy-wen
 
Posts: 6
Joined: Wed Sep 16, 2009 10:31 am


Return to Arduino Shields

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


x