Input Mic and Mixer using Alsa - Something that will work Using Airtime Script Modified
  • I have Just wet my appetite with python language and now ready to share with you how to deal with inputs (Mic) and output to mixer board.
    Next I will fixed myscript  based on the python that I have learnt

    This task required a number of testing as my first experience with this task result in a number of overuns on Input Alsa and underrun on Output Alsa
    The objective of this is

    Minimize the amount of coding necessary
    Use the Airtime existing scripts and include the scripts
    Have code that will not break on upgrade



    My Testing machine is a Laptop
      Release 12.04 (precise) 64-bit
      Kernel Linux 3.2.0-52-generic  
      GNOME 3.4.2

    Hardware                      Laptop          Desktop
                                                     
    Memory (GB)                   2.0              4.0
    Processor:Intel® Celeron(R)
    CPU                          900 @ 2.20GHz

    Now prepare your Alsa Card Using this tutorial http://savonet.sourceforge.net/doc-svn/faq.html or this http://sourcefabric.booktype.pro/airtime-24-for-broadcasters/preparing-the-server/


    I found the laptop not to have any trouble with Alsa Xruns while the Desktop do have Xruns.
    Xruns cause cracking,inaudible and undesirable audio called overuns and underruns

    To Over come this

    modify your ls_scipt and place this at the top
    * you only need the code in blue to placed at  the top

    #for Alsa Inputs
     set("frame.size",700)

    # for Alsa Outputs
    set("decoding.buffer_length", 20.)
    set("frame.channels", 2)
    set("frame.samplerate", 44100)


    # These are the settings for my PCI MAudio (2496)
    # You Might have to tweak this for Your card
    # Especially for Inputs -Frame size
    # Outputs like mine take (44100,48000 or 96000)  


    now put the following at the bottom of your Ls_script near the bottom and just above the "command...." instructions
    * you only need the code in green to placed at  the bottom
    #############################################################################################

    # Input from ALSA

    #This below works
    #source = input.alsa(device="pcm.liquidsoap",bufferize=false)
    #studioInput = input.alsa(device="pcm.liquidsoap",bufferize=false)
    #studioInput = input.alsa(bufferize=false)
    #studioInput = input.alsa(bufferize=false)

    studioInput = input.alsa()


    studioInput= amplify(2.0,input.alsa())

    #############################################################################################
    # do This if you want to use your playlist you created earlier
    #StreamstudioInput=mksafe(StreamstudioInput)

    #You will need a fallback
    ############
    # Do not use a fallbackskip it interferes with utils.lq
    #StreamstudioInput= fallback.skip(strip_blank(threshold=-35.,length=15.,studioInput),security)
    #############

    # like this

    #This below Works - best
    #StreamstudioInput = fallback(track_sensitive = false,[strip_blank(max_blank=13.,threshold=-35.,studioInput),security])

    #This below Works - best
    # This will also play what was loaded in the buffer for mymusicbackup above
    #StreamstudioInput = fallback(track_sensitive = false,[strip_blank(max_blank=13.,threshold=-35.,studioInput),mymusicbackup])

    #StreamstudioInput = fallback(track_sensitive = false,[strip_blank(max_blank=13.,threshold=-35.,studioInput),default])


    #This below Works
    #StreamstudioInput = fallback(track_sensitive = false,[studioInput,security])


    ##################################################################################################
    # I chose this because all my Airtime are routed through the mixer

    StreamstudioInput =fallback(
                                               track_sensitive=false,
                                               [ strip_blank(max_blank=10.,
    threshold=-23.,studioInput) , security ]
                                               )


    output.icecast( %mp3(stereo=true, bitrate=96, samplerate=44100),
                  password = "hackme", mount = "live",
                  name = "your meta-tag",
                  genre = "your genre",
                  timeout = 10.0,
                  url = "your website",
                  description = "a short description",
                  StreamstudioInput             

                   )


    ###############
    Put script above Here
    ##################
    command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --liquidsoap-started &"


    ######################################################################################################
    * you only need the code in green to placed at  the bottom

    Now When you switch on your mike or mixer you system will trigger and you have a live input streaming through your
    existing airtime

    If the mixer is silent for  10s (Max blank) and below 23db ,your security,playlist or silence(default) or schedule will play.then to your "live" mount to Icecast.

    If you use default or playlist or a schedule it will be routed through your mixer and then to your "live" mount to Icecast.
    Now You can pass your mixer out to your transmitter

    Please note

    It will best to have a fallback mount in icecast (Stream ,Live,Listen)

    You will need to put your output from in line on a mixer

    I give no guarantee it will work for you as it did for me

    I am in active development of it so make your contribution I will fix it as time goes by

    V.O.I.S.S.E.S

    Can you Hear me now

    Post edited by Voisses Tech at 2013-09-23 17:42:42
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.
  • 2 Comments sorted by
  • Vote Up0Vote Down hoerichhoerich
    Posts: 627Member, Airtime Moderator

    #for Alsa Inputs
     set("frame.size",700)

    # for Alsa Outputs
    set("decoding.buffer_length", 20.)
    set("frame.channels", 2)
    set("frame.samplerate", 44100)


    # These are the settings for my PCI MAudio (2496)
    # You Might have to tweak this for Your card
    # Especially for Inputs -Frame size
    # Outputs like mine take (44100,48000 or 96000)  


    now put the following at the bottom of your Ls_script near the bottom and just above the "command...." instructions
    * you only need the code in green to placed at  the bottom
    #############################################################################################

    # Input from ALSA

    #This below works
    #source = input.alsa(device="pcm.liquidsoap",bufferize=false)
    #studioInput = input.alsa(device="pcm.liquidsoap",bufferize=false)
    #studioInput = input.alsa(bufferize=false)
    #studioInput = input.alsa(bufferize=false)

    studioInput = input.alsa()


    studioInput= amplify(2.0,input.alsa())



    I can hear you now, voisses ;-)

    This discussion comes right in time for me, because I'm messing around with ALSA-In for a day too.
    Sadly I have not the same situation like you, but similar.
    My goal is to use the ALSA-In as fallback in ls_script.
    Practically this means, if we have a Show from Live-Studio, we just want to leave the show-slot empty.
    We cannot use it in your way, because over 100 people have access to Live-Studio and use it as Pre-Recording-Studio too.

    I think the most challenging thing is setting up correct alsa-configs.
    You have to use the right .asoundrc or asound.conf for your soundcard. In my case MAudio Delta 1010.
    Look for the right buffer-settings with trial and error, depending on soundcard and pc-performance.

    I just flew over your comment, a few questions I came across:
    Do I need both .asoundrc & asound.conf?
    If I want to use .asouncrc, should I delete systemdefault asound.conf?
    Why you set bufferize to false? I thought it depends on set.frame.size? 700 means 700milliseconds?
    And if set to false, it would not use this. Or am I wrong?

    As soon as I use more details on input.alsa(), just like input.alsa(device=dsp_chan1), Liquidsoap fails to start.
    Gotta continue end of week...
    Official Airtime Forum Manager
    --------------------------
    Most of the time an issue is located between keyboard and chair.
  • "Do I need both .asoundrc & asound.conf?"

    both does the same job

    .asoundrc  is local to the User
    asound.conf is systemwide to all user (/etc/asound.conf)

    I prefer .asoundrc  since when you upgrade it will not be affected


    /etc/asound.conf maybe deleted when you upgrade to another version

    In early days when Alsa was king of sound ,the configuration file was part of debian and its variant.

    Now with pulse its not needed  

    "Why you set bufferize to false? I thought it depends on set.frame.size? 700 means 700milliseconds?

    480-700 works with my 2496 card based on the the number of things on my machine(server).I have on it my media,my storage and MythTv (silicon homerun)

    I no longer use the output on my server so the use of 2496 for Airtime could not come more as at opportune time

    "And if set to false, it would not use this. Or am I wrong?"


    I would have use false because I would not want alsa to determine the buffer rates but for liquidsoap to determine it by setting the frame rates.

    Frames for audio is its data rates but for videos its the frames.

    I chose the unlikely option auto hence input.alsa()

    " In my case MAudio Delta 1010.look for the right buffer-settings with trial and error, depending on soundcard and pc-performance. "

    I had a delta 1010,but gave it away as I found comfort with the 2496.If someone donate one to me/otherwise.Then I can test (or perhaps a loaner).

    In a previous post you ask if one can record in say hourly?

    Yes it can through liquidsoap.but like I always said my preferred command line recorder is "Sox",it evens have a silencer and can shut off each time there is silence and you can set the lenght and threshold.

    I will post the code for liquidsoap when I find it in my notes.

    V.O.I.S.S.E.S
    Can you hear me now
    Post edited by Voisses Tech at 2013-09-24 19:42:06
    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.