[mythtv-users] Razzy/Tinny audio

Daryl McDonald darylangela at gmail.com
Wed May 21 23:40:27 UTC 2014


On Fri, May 9, 2014 at 12:41 PM, Daryl McDonald <darylangela at gmail.com>wrote:

> On Fri, May 9, 2014 at 11:47 AM, Stephen Worthington
> <stephen_agent at jsw.gen.nz> wrote:
> > On Fri, 9 May 2014 10:48:08 -0400, you wrote:
> >
> >>On Fri, May 9, 2014 at 3:29 AM, Stephen Worthington
> >><stephen_agent at jsw.gen.nz> wrote:
> >>> On Thu, 8 May 2014 23:59:10 -0400, you wrote:
> >>>
> >>>>On Thu, May 8, 2014 at 9:45 PM, Stephen Worthington
> >>>><stephen_agent at jsw.gen.nz> wrote:
> >>>>> On Thu, 8 May 2014 12:44:23 -0400, you wrote:
> >>>>>
> >>>>>>Greetings Mythizens, as the subject implies I'm looking into
> >>>>>>distortion from recordings on my analog card.
> >>>>>>"http://www.mythtv.org/wiki/Hauppauge_PVR-150" this wiki suggests
> >>>>>>adding a line to my change-channel.sh, like so: "sleep 5; v4l2-ctl
> >>>>>>--set-audio-input 1 -d /dev/video0 > /dev/null 2>&1" . Before
> >>>>>>implementing this solution, I'd like to confirm that since my UDEV
> >>>>>>rule names the card "/dev/videoPVR150" then the added line of script
> >>>>>>should reflect this change thusly?  "sleep 5; v4l2-ctl
> >>>>>>--set-audio-input 1 -d /dev/videoPVR150 > /dev/null 2>&1" . Should
> >>>>>>anything else be changed? The digital cards sound good and the analog
> >>>>>>card has sounded good before, which is why I'm going for this idea
> >>>>>>first.   TIA, Daryl
> >>>>>
> >>>>> This problem seems to be caused by mixing of audio from other sources
> >>>>> on the card.  I have this problem with my PVR-500 (dual PVR-150).  It
> >>>>> happens randomly at the start of using the card for a recording, and
> I
> >>>>> have never been sure what the cause was, but the drivers have never
> >>>>> been patched to fix it.  The fix you found does work, but what you
> >>>>> need to do depends on what you are using your PVR-150 for.  If you
> are
> >>>>> using it to tune to an analogue TV channel, then that fix is the
> right
> >>>>> one.  If, like me, you are using its S-Video or composite video
> inputs
> >>>>> to interface to an STB, then the fix is more complex.  In the latter
> >>>>> case, you also need a command (v4l2-ctl -f <freq>) to tune the TV
> >>>>> receiver to a frequency that is currently not in use by a signal it
> >>>>> can receive.  This is to ensure that the TV audio does not get mixed
> >>>>> into the S-Video connection's audio.
> >>>>>
> >>>>> This is what I have in my ivtv_audio_fix.sh file that I run from my
> >>>>> channel change script:
> >>>>>
> >>>>> #!/bin/sh
> >>>>>
> >>>>> # Workaround for bug which causes audio distortion on some
> recordings.
> >>>>> # From http://urlgrey.net/?p=231
> >>>>>
> >>>>> sleep 3
> >>>>>
> >>>>> if [ $# -eq 0 ]; then
> >>>>>     device=/dev/video0
> >>>>> else
> >>>>>     device=$1
> >>>>> fi
> >>>>>
> >>>>> # First, set the audio input in turn to each of the unwanted audio
> >>>>> inputs.
> >>>>> # This only became necessary as of Mythbuntu 12.04.
> >>>>> v4l2-ctl -d$device --set-audio-input=2
> >>>>> v4l2-ctl -d$device --set-audio-input=0
> >>>>>
> >>>>> # Next, also set the tuner frequency.  This also seems to be
> necessary
> >>>>> # since Mythbuntu 12.04 to suppress a slightly different audio
> >>>>> distortion.
> >>>>> # The frequency should be for an unused part of the spectrum, as the
> >>>>> unwanted
> >>>>> # audio is coming from whatever the TV tuner is tuned to.
> >>>>> v4l2-ctl -d$device -f 420
> >>>>>
> >>>>> # Reset the audio input to source 1 (the wanted input).
> >>>>> v4l2-ctl -d$device --set-audio-input=1
> >>>>>
> >>>>>
> >>>>> And this is my channel change script (change-channel-skynz.sh):
> >>>>>
> >>>>> #!/bin/sh
> >>>>>
> >>>>> REMOTE_NAME=Pace_RC-30
> >>>>> cmd="$1"
> >>>>>
> >>>>> # If things work OK with sleep 1, try this for faster channel
> changes:
> >>>>> # sleep 0.3
> >>>>> sleep_amt=1.0
> >>>>>
> >>>>> # See if this helps with missing digits at the start of a channel
> >>>>> change.
> >>>>> sleep 1.0
> >>>>>
> >>>>> #echo Change channel: $cmd >>/tmp/irsend.txt
> >>>>>
> >>>>> case $cmd in
> >>>>>     [0-9]*)
> >>>>>     # make sure we unmute by hitting vol up
> >>>>>     #/usr/bin/irsend SEND_ONCE $REMOTE_NAME Vol+
> >>>>>     #sleep $sleep_amt
> >>>>>     for digit in $(echo $1 | sed -e 's/./& /g'); do
> >>>>>             #echo irsend SEND_ONCE $REMOTE_NAME $digit
> >>>>>>>/tmp/irsend.txt
> >>>>>         /usr/bin/irsend SEND_ONCE $REMOTE_NAME $digit
> >>>>>         sleep $sleep_amt
> >>>>>     done
> >>>>>     ;;
> >>>>>
> >>>>>     *)
> >>>>>         /usr/bin/irsend SEND_ONCE $REMOTE_NAME $cmd
> >>>>>         ;;
> >>>>> esac
> >>>>>
> >>>>>
> >>>>> # Workaround for bug which causes audio distortion on some
> recordings.
> >>>>> /usr/local/bin/ivtv_audio_fix.sh &
> >>>>> _______________________________________________
> >>>>> mythtv-users mailing list
> >>>>> mythtv-users at mythtv.org
> >>>>> http://www.mythtv.org/mailman/listinfo/mythtv-users
> >>>>> http://wiki.mythtv.org/Mailing_List_etiquette
> >>>>> MythTV Forums: https://forum.mythtv.org
> >>>>
> >>>>Thanks Stephen, I use my PVR 150 to record from an analog STB
> >>>>connected via RCA jacks, this card has apparently has five possible
> >>>>input connections, one "tuner" via coax and two each of "component"
> >>>>and "S-video". To leave my system connected as is, I would need to
> >>>>create a new " ivtv_audio_fix.sh" file like yours, but change the name
> >>>>of the tuner card appropriately and modify my "change-channel.sh" as
> >>>>outlined in the original post? Or, maybe more simply, change the input
> >>>>connection to "tuner" over coax and add the one line to my
> >>>>"change-channel.sh"? with the first solution, I must need one more
> >>>>line in the "change-channel.sh" to call the new "ivtv_audio_fix.sh"
> >>>>script, right? But I'm not sure where to put it.
> >>>>Daryl
> >>>
> >>> Create the ivtv_audio_fix.sh file (I have mine in /usr/local/bin where
> >>> my change-channel-skynz.sh script is).  Then if your existing channel
> >>> change script works at all like mine, you can just add these two lines
> >>> at the end of it:
> >>>
> >>> # Workaround for bug which causes audio distortion on some recordings.
> >>> /usr/local/bin/ivtv_audio_fix.sh /dev/videoPVR150 &
> >>>
> >>> What that does is to run the ivtv_audio_fix.sh script as a separate
> >>> independent job (that is what & does).  The channel change script can
> >>> finish and that lets MythTV know that the channel change has been
> >>> done.  The ivtv_audio_fix.sh script will do its sleep while MythTV
> >>> records for the sleep time (you will hear the tinny sound for the
> >>> first few seconds of the recording, if it happened for that
> >>> recording), then the script will wake up and do its fix.  The fix has
> >>> to be done after all the recording startup work that MythTV does - if
> >>> it is done too early it does not work as the v4l commands sent by
> >>> MythTV override it.  When the ivtv_audio_fix.sh script has done its
> >>> v4l commands it will just stop without reporting back to the script
> >>> that called it (which finished several seconds before).
> >
> >>Hopefully I'm not over-reading this, what I did is create the
> >>ivtv_audio_fix.sh file in /usr/local/bin, and I changed (near the top)
> >>"device=/dev/video0" to "devive=/dev/videopvr150" and then added the
> >>two lines to the end of my "change-channel.sh" exactly as yours is
> >>(without the /dev/videoPVR150) [my uDev rule uses lower case pvr, my
> >>bad] . This preceding issue is at the heart of my original question;
> >>am I correct or wrong in assuming that the new name created by my uDev
> >>rule should be reflected in the "ivtv_audio_fix.sh" script?  Thanks
> >>again  Daryl
> >
> > If you exactly copied the two lines I posted to the bottom of your
> > change-channel.sh, then it will not work, due to the mis-spelling of
> > /dev/videopvr150 as /dev/videoPVR150 in what I wrote.  My
> > ivtv_audio_fix.sh script accepts one optional parameter on its command
> > line, the name of the device to control.  If that parameter is absent,
> > it will use the default device setting you changed at the top of
> > ivtv_audio_fix.sh.  It was not necessary to change that as the two
> > lines I posted had the device name as a parameter.  So you either need
> > to fix the spelling of /dev/videopvr150 on the call to
> > ivtv_audio_fix.sh in change-channel.sh, or remove the /dev/videoPVR150
> > from there and let ivtv_audio_fix.sh use its default device name that
> > you have already fixed.
> > _______________________________________________
> > mythtv-users mailing list
> > mythtv-users at mythtv.org
> > http://www.mythtv.org/mailman/listinfo/mythtv-users
> > http://wiki.mythtv.org/Mailing_List_etiquette
> > MythTV Forums: https://forum.mythtv.org
>
> What I exactly copied into my change-channel.sh was the last two lines
> of your change_channel_skynz.sh, so I think I'm good with the audio
> fix script edited to reflect the uDev name of my analog card and my
> channel script calling the fix script just like yours does, not the
> way you suggested had I not edited.
>
> The University of Toronto is offering free online computer science
> courses this fall, after applying myself in this direction I hope to
> get a much better practical understanding of all the things that I've
> received excellent coaching on from this list. Thanks Stephen, thanks
> list, enormous thanks Devs, I love Mythtv.   (BE & FE)   Daryl
>

 I've had almost two weeks of clear audio recordings, but a recording
yesterday has the Tin/Raz effect. Below are my "change-channel.sh" and
"ivtv_audio_fix.sh"

REMOTE_NAME=DCT700
cmd="$1"
lirc_socket="/var/run/lirc/lircdSerial"

/usr/local/bin/check_stb 1>/dev/null 2>/dev/null || :
sleep 2

case $cmd in
    [0-9]*)
    for digit in $(echo $1 | sed -e 's/./& /g'); do
        #irsend -d /dev/lircd SEND_ONCE $REMOTE_NAME $digit
        irsend -d ${lirc_socket} SEND_ONCE $REMOTE_NAME $digit
        sleep 0.2
        # If things work OK with sleep 1, try this for faster channel
changes:
        # sleep 0.3
    done
        #irsend -d /dev/lircd SEND_ONCE $REMOTE_NAME OK
        irsend -d ${lirc_socket} SEND_ONCE $REMOTE_NAME OK
sleep 1
        #irsend -d /dev/lircd SEND_ONCE $REMOTE_NAME EXIT
        irsend -d ${lirc_socket} SEND_ONCE $REMOTE_NAME EXIT
    ;;

    *)
        #irsend SEND_ONCE $REMOTE_NAME $cmd
        irsend -d ${lirc_socket} SEND_ONCE $REMOTE_NAME $cmd
        ;;
esac


# Workaround for bug which causes audio distortion on some recordings.
/usr/local/bin/ivtv_audio_fix.sh &

---------------------------------------------------------------------------------------

#!/bin/sh

# Workaround for bug which causes audio distortion on some recordings.
# From http://urlgrey.net/?p=231

sleep 3

if [ $# -eq 0 ]; then
    device=/dev/videopvr150
else
    device=$1
fi

# First, set the audio input in turn to each of the unwanted audio inputs.
# This only became necessary as of Mythbuntu 12.04.
v4l2-ctl -d$device --set-audio-input=2
v4l2-ctl -d$device --set-audio-input=0

# Next, also set the tuner frequency.  This also seems to be necessary
# since Mythbuntu 12.04 to suppress a slightly different audio distortion.
# The frequency should be for an unused part of the spectrum, as the
unwanted
# audio is coming from whatever the TV tuner is tuned to.
v4l2-ctl -d$device -f 420

# Reset the audio input to source 1 (the wanted input).
v4l2-ctl -d$device --set-audio-input=1

--------------------------------------------------------------------------------------------

I thought I'd followed Mr Worthington's advice to the letter, maybe not ,
or maybe I need to pursue a different angle. If anyone can critique this
solution, or point me in a new direction, I'd appreciate it.

TIA Daryl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20140521/871df522/attachment-0001.html>


More information about the mythtv-users mailing list