audio recording - how to record mic input and pipe the output to another program

06
2014-04
  • acrs

    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

    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 ?

  • Answers
  • Bradd Szonye

    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
    
  • Alex Hofsteede

    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.


  • Related Question

    Is there an open source program for recording all sound input and output on Windows?
  • GJ.

    I'm looking for an open source utility that can record all input and output audio simultaneously on Windows. Preferably each direction should be in its own channel, but a mono/joined stereo would also be fine.

    Anyone knows of such a beast?


  • Related Answers
  • harrymc

    You can use Audacity, which is a free, open source software for recording and editing sounds.

    Audacity has a large wiki and tutorials.