Register
It is currently Fri Dec 19, 2014 11:44 am

I placed a script in the scripts folder to record music.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Wed Feb 22, 2012 3:04 pm   

Joined: Wed Feb 22, 2012 2:32 pm
Posts: 4
Ubunto 10.04 Gnome 2 nautilus.

First of all the script works fine in the terminal. The recording stops when I press CTRL-C or close the window. If I right-click in a folder and run the script, the file is created in that folder and the file size keeps increasing so I know it is recording. The problem is since there is no terminal to close and pressing Ctrl-C doesn't work I don't know how to stop the script when the music ends.

Here is the script. I need something at the end to keep Terminal open til I have recorded as much as I want. Then i can just press Ctrl-C or exit terminal to end my recording.

Code:
#!/bin/bash
# Copyright 2008-2009, Kees Cook <kees@outflux.net>
#
# Records the PulseAudio monitor channel.
# http://www.outflux.net/blog/archives/2009/04/19/recording-from-pulseaudio/
#
#This script require sox
#sudo apt-get install sox

if [ -n "$1" ]; then
    OUTFILE="$1"
else
    TIME=$(date +%d-%b-%y_%H%M-%Z)
    OUTFILE="recording_$TIME.wav"
fi

# Get sink monitor:
MONITOR=$(pactl list | grep -A2 '^Source #' | grep 'Name: .*\.monitor$' | awk '{print $NF}' | tail -n1)

# Record it raw, and convert to a wav
echo "Recording. Ctrl-C or close window to stop"
parec -d "$MONITOR" | sox -t raw -r 44100 -sLb 16 -c 2 - "$OUTFILE"

# End of soundcap.sh


Any help would certainly be appreciated!
Paul


Top
 Profile  
 PostPosted: Sat Feb 25, 2012 11:25 pm   

Joined: Wed Feb 22, 2012 2:32 pm
Posts: 4
Good grief! Does anyone read this forum?


Top
 Profile  
 PostPosted: Mon Feb 27, 2012 3:08 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 579
hi,

as the script work in a terminal, your problem is not related to bash.


Top
 Profile  
 PostPosted: Fri Mar 09, 2012 12:57 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
The simplest way may be to create another script that launches a terminal window and executes the script there.
Ex: xterm -e 'script.sh'


Top
 Profile YIM  
 PostPosted: Sat Mar 10, 2012 12:04 am   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
p3aul wrote:
Good grief! Does anyone read this forum?


Sure do, and I recognize my script.

" soundcap.sh"


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP