emkay443

PulseAudio Recording Script

Aug 30th, 2013
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.43 KB | None | 0 0
  1. #!/bin/bash
  2. # PulseAudio Recording Script
  3. #
  4. # Record sound output from PulseAudio
  5. # and convert it to something useful using sox
  6. #
  7. # Dependencies: pulseaudio, pacat (parec), sox
  8. #
  9. # Author: Michael Koch (Emkay443) (m<DOT>koch<AT>emkay443<DOT>de)
  10. # Version: 2013-08-31
  11. # License: GNU General Public License v3 (http://www.gnu.de/documents/gpl-3.0.en.html)
  12.  
  13. ###################
  14. ## CONFIGURATION ##
  15. ###################
  16.  
  17. # Sample rate in Hz
  18. sample_rate=44000
  19.  
  20. # Number of bits (8/16/24)
  21. bits=16
  22.  
  23. # Number of channels
  24. channels=2
  25.  
  26. # Pulseaudio monitor device
  27. # Use "pacmd list | grep .monitor" and change the following value
  28. # according to the output of the above command (it has too look like in this example!)
  29. pulse_monitor_device="alsa_output.pci-0000_00_1b.0.analog-stereo.monitor"
  30.  
  31.  
  32. #########################################################################################
  33. # WARNING: You should be careful when changing any code below. Modify at your own risk! #
  34. #########################################################################################
  35.  
  36. ##################
  37. ## MAIN PROGRAM ##
  38. ##################
  39. if [ ! -z $1 ]; then
  40.     echo "Recording Sound to $1"
  41.     echo "Stop sound recording with CTRL-C"
  42.     parec -d $pulse_monitor_device | sox -t raw -r $sample_rate -e signed-integer -L -b $bits -c $channels - $1
  43. else
  44.     echo "This program requires one parameter - the file path of the converted file"
  45.     exit 1
  46. fi
  47.  
  48. exit 0
Advertisement
Add Comment
Please, Sign In to add comment