LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   tvtime and sox (automate both with one shell) (https://www.linuxquestions.org/questions/linux-software-2/tvtime-and-sox-automate-both-with-one-shell-900800/)

JDCoder 09-02-2011 09:35 PM

tvtime and sox (automate both with one shell)
 
This shell starts both tvtime and sox and closes both when tvtime is closed. It will not allow two instances to run.

Not something of great need, but for a lazy person who enjoys watching tv on his Linux laptop (just for fun), it is convenient.
I am running PCLinuxOS with a Pinnacle Systems PCTV USB2 card. Having to run sox separately became annoying,
so I wrote this small shell to run both and close both when tvtime is closed.

_____________________________________________________________________
#!/bin/sh

# Possible names for the shell: tvtime.sh or tvtime_sox.sh

# Automate tvtime and sox with this shell script
#
# opens both together and closes both together
# add to menu or create desktop launcher to run
# make shell script executable: chmod +x tvtime.sh

#Exit if already running
if [ -n $(ps -C "tvtime") ]; then
exit 0
fi

#Run sox in separate background thread/process
#parms: -q = quite: do not display under-runs
# -t = audio device type (maybe different for your install)
# hw:1,0 = hardware device number (1,0): may be different for your
# install
# -d = use default output audio (works for me)
# -G = use temp files to prevent clipping
# & = run in background: different terminal/thread
#If you have a sox command that works for you (incase this one does not)
#replace the following with your version. Remember to add the ampersand
# to the end
#$(sox -q -t alsa hw:1,0 -d -G) &
$(sox -q -t alsa hw:1,0 -d) &

# Note: I tested the above sox command on a different computer with an Aver TV Go 007 FM Plus.
# The -G option (guard against clipping) blocked the sound. I removed the -G option and there was
# sound.

#Run tvtime in this thread and wait until closed
$(tvtime)

#After tvtime is closed, get the sox PID: used to close/kill sox
#ps is used to get the sox process/proc information
#set is used to parameterize the ps results
#look for the sox pid under this shell and make it parameter $1
set $(ps -C sox --pid "$$" | grep -h sox)

#$1 now contains the process id of sox, if sox is active: $1 will not be
# null
#kill sox, if active
if [ -n $1 ]; then
kill -HUP $1
fi

exit 0
___________________________________________________________________________

lshantz 02-15-2013 05:37 PM

Bump!

Okay, here is my tail of woe, and it relates to the above. I have used Opensuse with Tvtime for 2 years. Back when I set it up initially, I had a heck of a time getting sound. Finally figured it out, made the changes and all was well. Until a week ago. My main boot disk with /, and /home went bad. The good news I was backed up. The bad news is, I was not backed up 100%. So a restore left we with a borked system. I ended up doing a fresh install, and the Tv did not work at all. I then took my old /home and restored it. Voilla! TVtime working again. After 2 days, I felt it was time to do my daily rsnapshot backups, and needed the room, so deleted my backups. BAD idea! For some unexplained reason, now all of a sudden, TvTime is back to no sound.

I'm pretty sure that to get it working, I had to do some wizardry with sox, but I forget the details. Can one of you smart guys help me to get this working again? The above does not work for me.

I have an Intel DX58SO MB. I have an older Hauppaugge Tv Tuner. BT878. I have taken the audio output on the card, and put a cable from there to my line in on the motherboard. (I'm almost positive there is a way to do it via bridging without the cable, but I don't care at this point) I have provided the info below in hopes that someone can say, hey stupid, you just do sox x blah. :)

The pulse audio controller shows the output device as "internal audio analog stereo, with the port at analog output. Input devices shows, internal audio analog stereo, with the port as analog line-in. The Bt878 capture analog stereo shows port: analog video. The configuration shows internal audio with a profile of analog stereo duplex. Bt878 audio capture profile: Analog stereo input. ??? Anybody?

arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC889 Analog [ALC889 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 2: ALC889 Analog [ALC889 Analog]
Subdevices: 2/2
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
card 1: Bt878 [Brooktree Bt878], device 0: Bt87x Digital [Bt87x Digital]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: Bt878 [Brooktree Bt878], device 1: Bt87x Analog [Bt87x Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0

lshantz 02-15-2013 05:48 PM

Well hot dang!

Funny how sometimes when you write it all down and sit back and look at things it makes some sense! I started experimenting with different combinations.

sox -S -t alsa hw:0,0 -d -G
^^ verbose

When I hit 0,0 bam!!! It is working. However, my volume control within TVtime does NOT work. It just shows zero. I could still (and hundreds of others) Could sure use some help on this too.

lshantz 02-16-2013 10:14 AM

Well, as I learn more... it seems that the sox command may not be needed for all users. At one point I found that xfce4-mixer would allow me to activate the sound via the menu. It is a very nice gui interface. Once I did that, I got an echo, and once I killed sox, it was working! Then all of a sudden xfce4-mixer disappeared. I was able to get it back via root, but now it goes away in root too. ?? Don't know why. Still no volume control via TvTime! :( I had hoped that with xfce4-mixer I would be able to tweak it and get this working too.

So if anyone can shed light on why xfce4-mixer won't load anymore that would be great. Here is the error message:

xfce4-mixer --gst-debug-level=1
xfce4-mixer: Failed to initialize xfconf: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

madhank65 02-17-2013 08:33 PM

This is sort of quote of JDCoder but thought I'd skip all that text. So, the only reason I use windows is watching (or listening) to broadcast TV while I work. Linux don't like my dongle evidently (tried lots of options, even wine); so any way going to look into Pinnacle Systems. Any one suggest a possible program that will run ASTC dongle? I'm being lazy eh? Also heard Happhauge cards will work.. I'm the only window user in the home, wife and teen girl all use SolusOS (Debian). Using ZevenOS via VB right now but rather run 1 system.

lshantz 03-21-2013 12:05 AM

Well I'm back...

Same issue... no sound with TvTime. I upgraded my Motherboard, so I am having to start over. You'd think I would have documented carefully what I did last time, but nooooo... so now I get to learn all over.

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC898 Analog [ALC898 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC898 Digital [ALC898 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0

However using the command of:
sox -S -t alsa hw:0,1 -d -G

hw:0,1: (alsa)

Encoding: Signed PCM
Channels: 2 @ 16-bit
Samplerate: 48000Hz
Replaygain: off
Duration: unknown

In:0.00% 00:00:03.50 [00:00:00.00] Out:164k [ | ] Clip:0
Aborted.
but no sound..

Tvtime -v shows in part:
mixer: Can't open device default, mixer volume and mute unavailable.

Can anyone give me an idea of where to go?


All times are GMT -5. The time now is 03:03 AM.