# create a file with 65536 bytes of zeros (i.e. 32768 short int zeros):
perl -e 'print "\0" x 65536' > zeros.raw
# create a file with 32768 short int zeros followed by 32768 short int ones:
perl -e 'print pack("s",0) x 32768; print pack("s",1) x 32768' > zeros-ones.raw
####
sox -t raw -e signed-integer -b 16 -r 8000 -c 1 zeros.raw zeros.wav
####
#!/usr/bin/perl
use strict;
use warnings;
my $infile = shift or die "Usage: $0 raw_input_file_name\n";
my $file_size = -s $infile;
open( my $fh, $infile ) or die "$infile: $!\n";
read( $fh, my $buf, $file_size );
my @ints=unpack("s*", $buf);
print scalar @ints, " short-int elements read\n";
print " ... which seems right\n" if ( @ints == $file_size/2 );
my %h;
$h{$ints[$_]}++ for (0..$#ints);
print "distinct int values found in $infile:\n";
print " $_ occurs $h{$_} times\n" for (keys %h);