Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi everyone Im trying to follow a tutorial on generating truly random bits

How To Generate Truly Random Bits

This is the command from the tutorial but it does not work

rec -c 1 -d /dev/dsp -r 8000 -t wav -s w  - | ./noise-filter >bits

I know i can record my mic input using

rec -c 1 no.wav

this is the command i tried using

rec -c 1 -r 8000 -t wav -s noise.wav | ./noise-filter >bits

but i get

root@xxc:~/cc# rec -c 1 -r 8000 -t wav -s noise.wav  - | ./noise-filter >bits
rec WARN formats: can't set sample rate 8000; using 48000
rec FAIL sox: Input files must have the same sample-rate

I have complied noise-filter


I think the tutorial is using an older version of SOX and REC I'm using

sox: SoX v14.3.2 on Ubuntu 12.04 server

Can someone please help me ?

share|improve this question

This command line has too many outputs listed:

rec -c 1 -r 8000 -t wav -s noise.wav - | ./noise-filter >bits
                           ^file     ^standard output

For a command pipeline, the only output should be the - at the end. The rec command interprets the noise.wav parameter as an additional input, which will fail or produce bogus output. Try removing the extra filename (and other unnecessary/incompatible options):

rec -c 1 -t wav - | ./noise-filter > bits
share|improve this answer

per the tutorial you referenced (I'm following that one, too!) AND the latest-version SoX manpage (as of 9 Nov 2014), the complete, corrected command that worked for me was:

rec -c 1 -r 8000 -t raw -e signed-integer -2 - | ./noise-filter > bits

ent returned these values for a 49,152-byte file:

Entropy = 7.996356 bits per byte.

Optimum compression would reduce the size
of this 49152 byte file by 0 percent.

Chi square distribution for 49152 samples is 247.53, and randomly
would exceed this value 50.00 percent of the times.

Arithmetic mean value of data bytes is 127.5771 (127.5 = random).
Monte Carlo value for Pi is 3.147949219 (error 0.20 percent).
Serial correlation coefficient is -0.002336 (totally uncorrelated = 0.0).

This is pretty good quality random data!

share|improve this answer

Looks like your noise.wav is not at a sample rate that sox can record in, and sox requires both files to be at the same sample rate. You'll probably have to regenerate noise.wav at a higher sample rate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.