Wave shields - raw format

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

Moderators: adafruit_support_bill, 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: 10546
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: 10546
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: 30
Joined: Wed Sep 16, 2009 10:31 am

Re: joy of SoX

Postby boundaryfunctions » Wed Feb 24, 2010 6:44 am

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.wordpress.com/2010/02/23/batch-converting-audio-using-sox-for-arduino-waveshield/
boundaryfunctions
 
Posts: 1
Joined: Wed Feb 24, 2010 6:38 am

Re: Wave shields - raw format

Postby skoria » Wed Mar 03, 2010 2:56 pm

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
skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 2:05 pm

Re: Wave shields - raw format

Postby adafruit » Wed Mar 03, 2010 9:39 pm

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?
User avatar
adafruit
 
Posts: 10546
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Wave shields - raw format

Postby skoria » Wed Mar 10, 2010 5:16 pm

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
skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 2:05 pm

Re: Wave shields - raw format

Postby adafruit » Wed Mar 10, 2010 7:09 pm

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!
User avatar
adafruit
 
Posts: 10546
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: Wave shields - raw format

Postby skoria » Fri Mar 12, 2010 7:42 pm

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
skoria
 
Posts: 7
Joined: Wed Mar 03, 2010 2:05 pm

Re: Wave shields - raw format

Postby adafruit » Sat Mar 13, 2010 1:28 pm

the card itself cant be a 4g card. the 2g cards work good but the 4g ones use a different addressing method :(
User avatar
adafruit
 
Posts: 10546
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc


Return to Arduino Shields from Adafruit

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!


New Products [114]

Raspberry Pi[82]
 
FLORA[24]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[12]
Arduino[60]
 
NETduino[14]
 
BeagleBone[23]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[39]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[9]


 
Breakout Boards[35]
LCDs & Displays[49]
Components & Parts[70]
Batteries & Power[54]
EL Wire/Tape/Panel[52]
LEDs[112]
 
Wireless[16]
Cables[66]
 
Lasers[6]
Sensors/Parts[147]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[41]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[25]


 
Stickers[41]
 
Skill badges[55]
 
Books[26]
 
Circuit Playground[7]
 
Gift Certificates[4]