Generating Silence

From CodeCodex

Generating a 16-bit WAV sound file with the specified sample rate, number of channels and duration, ccontaining nothing but silence.

Bash[edit]

How to do it without writing anything resembling C code.

This version uses FFmpeg:

SampleRate=48000
NrChannels=2
Duration=1
ffmpeg -ar $SampleRate -acodec pcm_s16le -f s16le -ac $NrChannels \
    -i <(dd if=/dev/zero bs=$(($SampleRate * $NrChannels * 2)) count=$Duration) \
    out.wav

Or using SoX:

SampleRate=48000
NrChannels=2
Duration=1
sox -t .raw -r $SampleRate -c $NrChannels -s -w \
    <(dd if=/dev/zero bs=$(($SampleRate * $NrChannels * 2)) count=$Duration) \
    out.wav