VectorLinux
October 30, 2014, 10:50:48 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: Linux audio capture and time shifting?  (Read 3012 times)
GrannyGeek
Packager
Vectorian
****
Posts: 2567


« on: April 27, 2008, 10:29:39 am »

I'd like to know if there is a Linux equivalent for something I do in Windows.

I have a program, Audio Cleaning Lab, that can capture anything coming from the sound card and save it to a WAV, MP3, or OGG file. Thus, it's an easy way to capture streaming audio. The program also has a time shifting feature whereby you can set it to start capturing a stream at a certain time, set how long you want the capture to go on, and then it automatically saves it to a file in the location of your choice.

I use this every week to capture a stream for the Sunday Bach program of our public radio classical station, which is on at 7 a.m., a ghastly time for a weekend program, in my opinion. I start the stream at 1 a.m. before I go to bed, have Audio Cleaning Lab set to capture and save from 7 to 8 a.m., and then I turn off the speakers and go to bed. The next day I play the captured file at a time of my choice.

Is there any Linux program that can do this, hopefully as easily as Audio Cleaning Lab does in Windows?
--GrannyGeek
Logged

Registered Linux User #397786

Happily running VL 7 Gold on  a Sempron LE-1300 desktop (2.3 GHz), 4 G RAM,  GeForce 6150 SE onboard graphics and on an HP Pavilion dv7 i7, 6 gigs, Intel 2nd Generation Integrated Graphics Controller
saulgoode
Vectorite
***
Posts: 340



« Reply #1 on: April 27, 2008, 06:19:28 pm »

I don't know about any particular program that does that (I've never looked), but the task is readily accomplished with a simple script.

Code:
#!/bin/sh
# this script sets things up to record the audio output of the soundcard
# to a file in the home directory called "Bach-date.ogg" ("date" is
# replaced by something like "2008-04-27"). Note: the recording will be
# made a 7AM on the NEXT Sunday (so this script should be run sometime
# during the week before midnight Saturday).

/usr/bin/at 7:00AM SUN <<EOF
/usr/bin/arecord -d 3600 -f cd -t raw -D copy |/usr/bin/sox -t raw -r 44100 -s -w -c 2 - /home/grannygeek/Bach-$(date +%F).ogg
EOF

The "3600" is the duration of the show (in seconds) and should be modified if the show is other than an hour long. If you wanted an uncompressed .wav file (CD quality), you can forgo SOX and just use the line:

/usr/bin/arecord -d 3600 -f cd -t wav -D copy /home/grannygeek/Bach-$(date +%F).wav

It might be necessary to add the following ALSA device description to your ~/.asoundrc

Code:
pcm.copy {
  type plug
  slave {
    pcm hw
    }
  route_policy copy
  }

EDIT: I just noticed the part about "I start the stream at 1 a.m. before I go to bed". If you don't run the script before Sunday, you should remove the "SUN" from the 'at' command in the script (this will schedule things for the next time 7:00AM occurs).
« Last Edit: April 27, 2008, 08:49:01 pm by saulgoode » Logged

A complex system that works is invariably found to have evolved from a simple system that works.
GrannyGeek
Packager
Vectorian
****
Posts: 2567


« Reply #2 on: April 29, 2008, 07:52:18 pm »

Thanks very much for the script. I'll try it out soon.
--GrannyGeek
Logged

Registered Linux User #397786

Happily running VL 7 Gold on  a Sempron LE-1300 desktop (2.3 GHz), 4 G RAM,  GeForce 6150 SE onboard graphics and on an HP Pavilion dv7 i7, 6 gigs, Intel 2nd Generation Integrated Graphics Controller
GrannyGeek
Packager
Vectorian
****
Posts: 2567


« Reply #3 on: May 10, 2008, 09:53:24 am »

I finally had an opportunity to try out the script and unfortunately ran into some problems. As of now, it didn't work for me but I think it's fixable.

First of all, I do not have a ~/.asoundrc file, so I had nothing to add the pcm.copy lines to. Would it be okay to create an asoundrc file with just those lines? Would my sound be okay with just those lines in asoundrc? My sound is working fine now and I don't want to do anything to mess it up. I'll create the file anyway to see what happens, but I'm listening to streaming audio right now and don't want to have to restart X.

The first time I tried to run the script (just to try it out, not to record Sunday Bach), I got this message:
me:$ ./record.sh                                                                       
./record.sh: line 8: 2008-5-10: command not found                                       
warning: commands will be executed using /bin/sh                                         
job 1 at Sat May 10 11:45:00 2008                                                       
Can't open /var/run/atd.pid to signal atd. No atd running?                               

Apparently, I have to start the at daemon before I can run the script. So I did an su to root and ran /usr/sbin/atd . Then as user I modified the script for further testing at 11:45 a.m. and set 12:15 p.m. as the time for the script to run. When I ran ./record.sh this time, the message said the script would run at 12:15 p.m. on Sunday (today is Saturday). I did not put SUN in the at command line in the script, so I was surprised at this result. It seems the script thinks the current time is an hour later than it actually is. If I run a date command, the time reported is the time that shows in XFce's Clock applet on the panel. So I don't know why the script thinks the time is an hour later. That's why my test script reported the script would be run on Sunday--it thought that time had already passed because it thinks my computer's time is an hour later.

I then modified the script to conform to its assumption that the time was an hour later. This time the script ran but gave me an ogg file that wouldn't play on xmms, xine, mplayer, or Amarok. From mplayer or xine (I don't remember which) I got a message about a missing demuxer. I don't know what a demuxer is or why it would be missing, since I haven't made any related changes to the defaults for all these media players.

Most of this is over my head. What can I do to fix these things?
--GrannyGeek
Logged

Registered Linux User #397786

Happily running VL 7 Gold on  a Sempron LE-1300 desktop (2.3 GHz), 4 G RAM,  GeForce 6150 SE onboard graphics and on an HP Pavilion dv7 i7, 6 gigs, Intel 2nd Generation Integrated Graphics Controller
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!