Advertisement
metalx1000

BASH Sound recording and playback with effects

Aug 1st, 2018
1,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.72 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2018  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, or
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20. tmp="/tmp/rec.wav"
  21.  
  22. function main(){
  23.   recorder
  24.   sleep 1
  25.   while [ 1 ];do menu;done
  26. }
  27.  
  28. function clean(){
  29.   rm "$tmp"
  30.   clear
  31. }
  32.  
  33. function recorder(){
  34.   arecord -vv -fdat "$tmp" &
  35.   pid=$!
  36.   read
  37.   kill $pid
  38.   clear
  39. }
  40.  
  41. function menu(){
  42.   OPTION=$(whiptail --title "Play Back Options" --menu "Choose your option" 15 60 4 \
  43.     "1" "Play" \
  44.     "2" "Echo" \
  45.     "3" "Chorus" \
  46.     "4" "Reverse"  3>&1 1>&2 2>&3)
  47.  
  48.   exitstatus=$?
  49.   if [ $exitstatus = 0 ]; then
  50.     play_wav $OPTION
  51.   else
  52.     echo "You chose Cancel."
  53.     exit 0
  54.   fi
  55. }
  56.  
  57. function play_wav(){
  58.   if [ "$1" = "1" ]
  59.   then
  60.     play "$tmp"
  61.   elif [ "$1" = "2" ]
  62.   then
  63.     play "$tmp" echos 0.4 1 500.0 0.25 1000.0 0.3
  64.   elif [ "$1" = "3" ]
  65.   then
  66.     play "$tmp" chorus 0.6 0.9 50.0 0.4 0.25 2.0 -t 60.0 0.32 0.4 1.3 -s
  67.   elif [ "$1" = "4" ]
  68.   then
  69.     play "$tmp" reverse
  70.   fi
  71. }
  72.  
  73.  
  74. main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement