Note: Now that gradint supports MP3 input, you
can replace your WAVs with MP3s instead of
following the instructions here.  See samples/ReadmeMP3.txt
for notes on getting this to work.  You can
update all progress.txt's with the change like
this:

for N in $(find . -name progress.txt); do sed -e "s/\.wav/.mp3/g" < $N > n ; mv n $N; done

and do the encoding itself (in-place) with:

for N in $(find samples|grep wav$); do lame --cbr -b 48 -h -m m $N $(echo $N|sed -e s/.wav$/.mp3) && rm $N; done

---------------------

To squash down to 128kbps (16k bytes/s), be in the directory above 'samples' and do:

for Dir in $(find samples/ -type d); do mkdir -p "compressed-$Dir"; done; for F in $(find samples/ -type f|grep wav$); do if test "$F" -nt "compressed-$F"; then sox "$F" -r 16000 -c 1 -b -u test.wav; if test $(wc -c test.wav|sed -e 's/ .*//') -lt $(wc -c "$F"|sed -e 's/ .*//'); then mv test.wav "compressed-$F"; else rm test.wav; cp -p "$F" "compressed-$F"; fi; fi; done; for F in $(find samples/|grep -v wav$); do cp -up "$F" "compressed-$F" 2>/dev/null; done

The result will be in a directory called compressed-samples.  Any samples that were already smaller than the "compressed" versions, or anything that is not a .wav file, will simply be copied into compressed-samples uncompressed.  Any files already in compressed-samples will not be touched unless the "samples" equivalent is newer.  Additionally you may want to delete any samples in compressed-samples that are no longer in samples, in which case do this as well:

for F in $(find compressed-samples/ -type f); do if ! test -e $(echo "$F"|sed -e s/compressed-//); then rm "$F"; fi; done

To compress in place (erasing original files), go into samples directory and do:

for F in $(find . -type f|grep wav$); do sox "$F" -r 16000 -c 1 -b -u test.wav; if test $(wc -c test.wav|sed -e 's/ .*//') -lt $(wc -c "$F"|sed -e 's/ .*//'); then mv test.wav "$F"; else rm test.wav; fi; done

On some systems, 8-bit playback is noisy (e.g. because volume adjustments cause too many of those 8 bits to be lost); if you can't work around this then you could use 16-bit by deleting '-b -u' from the above commands, but the result will be twice as big.