Home » Questions » Computers [ Ask a new question ]

How do I computationally slice an audio file into small samples?

How do I computationally slice an audio file into small samples?

I need to cut audio files into small samples of even length. What I need is basically a batch processor for audio that does it and names the slices numerically. I'm using OSX and have found Audio Splitter. The shortest possible sample length with it is 1 second though, too long for my purpose. Anyone know an alternative?

Asked by: Guest | Views: 66
Total answers/comments: 1
Guest [Entry]

"An excellent sound converter SoX (also named 'the Swiss Army knife of audio manipulation') works on OS X, so I hope this script will help you:

#!/bin/sh

N=0
START=0
LENGTH=8000
COUNT=100
INPUT=input.mp3
OUTPUT=output-X.wav

for i in `jot ${COUNT}`; do
echo ""Trimming ${START}+${LENGTH}""
sox ${INPUT} `echo ${OUTPUT} | sed s/X/${N}/` trim ${START}s ${LENGTH}s
N=`expr ${N} + 1`
START=`expr ${START} + ${LENGTH}`
done

All lengths are in samples (you can also specify time in 'HH:MM:SS.ddd' format, check SoX manpage); it reads INPUT file and produces files named output-0.wav, output-1.wav and so on."