Difference between revisions of "audio notes"

From Noah.org
Jump to navigationJump to search
m (Created page with ' == Record audio from the microphone == <pre> arecord -vv -fdat recording.wav </pre> Using Sox (this works on OS X). This splits on silent gaps: <pre> rec -r 44100 -b 16 -s -p…')
 
Line 10: Line 10:
 
rec -r 44100 -b 16 -s -p silence 1 0.50 0.1% 1 10:00 0.1% \
 
rec -r 44100 -b 16 -s -p silence 1 0.50 0.1% 1 10:00 0.1% \
 
     | sox -p audio_recording.wav silence 1 0.50 0.1% 1 2.0 0.1% :  newfile : restart
 
     | sox -p audio_recording.wav silence 1 0.50 0.1% 1 2.0 0.1% :  newfile : restart
 +
</pre>
 +
 +
== Playback audio OX X using Sox ==
 +
 +
Note that where an output filename is require you may substitute '''-d''' or '''-t coreaudio''' (for Mac OS X). These seem to be equivalent.  The '''-d''' option seems to be the more general purpose style since it will automatically pick the correct sound output on a Mac and Linux.
 +
 +
Both examples below play audio and both will automatically detect the audio stream type. The '''play''' command is the easier to remember version. You may have special reasons for wanting to use the '''sox''' command alternative.
 +
<pre>
 +
play audio_recording.wav
 +
cat audio_recording.wav | sox - -t coreaudio
 +
</pre>
 +
 +
== Play noise ==
 +
 +
These are all equivalent.
 +
<pre>
 +
# From a file or device file.
 +
sox -t raw -r 44100 -b 16 -e unsigned-integer /dev/urandom -d
 +
sox -t raw -r 44100 -b 16 -e unsigned-integer /dev/urandom -t coreaudio
 +
# Using a pipe...
 +
cat /dev/urandom | sox -t raw -r 44100 -b 16 -e unsigned-integer - -d
 +
cat /dev/urandom | sox -t raw -r 44100 -b 16 -e unsigned-integer - -t coreaudio
 
</pre>
 
</pre>

Revision as of 04:43, 31 May 2015

Record audio from the microphone

arecord -vv -fdat recording.wav 

Using Sox (this works on OS X). This splits on silent gaps:

rec -r 44100 -b 16 -s -p silence 1 0.50 0.1% 1 10:00 0.1% \
    | sox -p audio_recording.wav silence 1 0.50 0.1% 1 2.0 0.1% :  newfile : restart

Playback audio OX X using Sox

Note that where an output filename is require you may substitute -d or -t coreaudio (for Mac OS X). These seem to be equivalent. The -d option seems to be the more general purpose style since it will automatically pick the correct sound output on a Mac and Linux.

Both examples below play audio and both will automatically detect the audio stream type. The play command is the easier to remember version. You may have special reasons for wanting to use the sox command alternative.

play audio_recording.wav
cat audio_recording.wav | sox - -t coreaudio

Play noise

These are all equivalent.

# From a file or device file.
sox -t raw -r 44100 -b 16 -e unsigned-integer /dev/urandom -d
sox -t raw -r 44100 -b 16 -e unsigned-integer /dev/urandom -t coreaudio
# Using a pipe...
cat /dev/urandom | sox -t raw -r 44100 -b 16 -e unsigned-integer - -d
cat /dev/urandom | sox -t raw -r 44100 -b 16 -e unsigned-integer - -t coreaudio