Advertisement
Gussak

sound/music initialization failure workaround

Dec 24th, 2012
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. echo "DETECT IF ANY SOUND IS PLAYING, configuration for Pulse Audio:"
  2. echo "- run: pavucontrol; and click at recording tab"
  3. echo "- run: arecord -f S16_LE >/dev/null"
  4. echo "- at pavucontrol, at recording, for arecord, select: Monitor of builtin audio.."
  5. echo "- stop arecord and it will keep that setup!"
  6. echo -n "press a key to continue...";read -n 1;echo
  7.  
  8. # capture thru pulse audio
  9. delay=1 #it doesnt accept less than 1s ...
  10. sedValOfMaxAmp='s".*: *""'
  11. maxAmp=`arecord -d $delay -f S16_LE \
  12.     |sox -t .wav - -n stat 2>&1 \
  13.     |grep "Maximum amplitude" \
  14.     |sed "$sedValOfMaxAmp"`
  15. echo "maxAmp=$maxAmp"
  16.  
  17. iHasSound=`echo "$maxAmp > 0.0" |bc -l`
  18. bHasSound=false;if((iHasSound==1));then bHasSound=true;fi
  19. if ! $bHasSound; then
  20.     # !!! your code to kill the application/game and restart it !!!
  21. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement