Wave shields - raw format

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
zi9
 
Posts: 1
Joined: Sat Jun 07, 2008 8:38 pm

Wave shields - raw format

Post by zi9 »

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

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave shields - raw format

Post by adafruit »

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 adafruit2 on Mon Jun 23, 2008 11:48 pm, edited 2 times in total.

User avatar
dgoodwin
 
Posts: 1
Joined: Sun Jun 22, 2008 9:00 pm

joy of SoX

Post by dgoodwin »

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

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

nice! thanks for the tutorial, ill add it to the documentation

User avatar
dy-wen
 
Posts: 30
Joined: Wed Sep 16, 2009 11:31 am

Re: Wave shields - raw format

Post by dy-wen »

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)

boundaryfunctions
 
Posts: 1
Joined: Wed Feb 24, 2010 7:38 am

Re: joy of SoX

Post by boundaryfunctions »

thanks for pointing me to soX, it's a real charm for doing almost everything in audio-processing! :D

i wrote a little bash-skript for batch-converting lot's of wavefiles to the waveshield-compatible format (mono, 22kHz, 16bit). if you want to use it, just copy it from here: http://boundaryfunctions.BANNED.com/ ... aveshield/

skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 3:05 pm

Re: Wave shields - raw format

Post by skoria »

Hi,

I've also written a sox "a2wav" processing bash script. The one posted above is much more complete though, but this one might show how easy the command in question is to adapt to all kinds of input files to SOX. It can take quite a few. You may need to run "sudo apt-get install libsox-fmt-all" before you run it, or whatever your equivalent is, to get sox to support all these file types.

By the way, speaking of converted files, I'm just about to convert 200 music files in the hopes of finding at least 50 that work on the wave shield!My first conversion of about 30 files gave me only about 10 that played... Does anyone else get that? Also sometimes the card just doesn't get read...

Ale

Code: Select all

#!/bin/bash
Z=1
# a static var, always zero

PRE="tzi"
# Prefix. Files will be named prefix+number.wav

Y=1
# the counter

for x in *
do
        echo "Converting $PRE$Y.WAV"
        #This next line does all the stuff so comment it out first
        #   and make sure the filenames look the way you want them...
        #   ..and then change it to be your own output directory, not my one!
        #       Ok here it comes:
        sox --show-progress "$x" -t wav --endian little -c 1 -r 22050 done/$PRE$Y.WAV
        Y=$(($Y + $Z))
done

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave shields - raw format

Post by adafruit »

all mono <=22khz, <=16bit wav's should be played. check to see if they have compression turned on or something. what happens if you try to play them?

skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 3:05 pm

Re: Wave shields - raw format

Post by skoria »

adafruit wrote:all mono <=22khz, <=16bit wav's should be played. check to see if they have compression turned on or something. what happens if you try to play them?
I get "Couldn't open file" which corresponds to a bit of code saying

f = card.open_file(name);
if (!f) {
putstring_nl(" Couldn't open file"); return;
}

Is there a way to debug that further?

On the other hand I'm thinking it might be the SD card. When copying files to it, I got a few I/O errors too...

Ale

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave shields - raw format

Post by adafruit »

On the other hand I'm thinking it might be the SD card. When copying files to it, I got a few I/O errors too...
yes you need to fix that first. if the sd card isnt working, its a bit much to expect the arduino to be able to read from it!

skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 3:05 pm

Re: Wave shields - raw format

Post by skoria »

Hi,

Well, now I'm thinking the reason it kept failing was the CRC error correction thing, which I spotted on another thread, but yes I did buy another one meanwhile and now it works fine. It is a 2gb card though, and I notice in the documentation you mention it should take up to 1gb, but mine has been working fine so far with less than 1gb of stuff on it. I wonder if more files will make it ill or slightly light headed though...

Am now at the maker faire uk - and looking forward to using the mintyboost and wave shield in my project!

Ale

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Wave shields - raw format

Post by adafruit »

the card itself cant be a 4g card. the 2g cards work good but the 4g ones use a different addressing method :(

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”