× Warning! This forum is in archival status. New contributions may not work.
AutoDJ/Backup/Fallback script needs finishing touches. Help?
  • So here's what I've done with my script so far:
     
    auto_http_stream_address = "http://some.server.com/some_stream/mp3"              # Set up some strings with addresses and file paths and stuff
    custom_track_switch_meta = ref "Switching Tracks, Pleae wait." # stick some values in here to make it work
    security_single_address = "/path/to/some_single_file.mp3"

    failsafe_security = amplify(id="failsafe silence src", 0.00001, noise())                      # Set up an absolute fail-safe security in case everything goes wrong
    ref_off_air_meta = ref off_air_meta
    if !ref_off_air_meta == "" then
        ref_off_air_meta := "Airtime - offline"
    end

    failsafe_security = rewrite_metadata([("title", !ref_off_air_meta)], failsafe_security)
    ignore(output.dummy(failsafe_security, fallible=true)) 


    # Set up a silence source to clean track switching 
    track_switch_noise =  noise(id="short_noise",duration=10.0)      #generate 10 second burst of whit noise
    track_switch_silence = amplify(id="silence_src", 0.00001, track_switch_noise ) # make it really quiet
    track_switch_silence = rewrite_metadata([("title", !custom_track_switch_meta)], track_switch_silence) # rewrite meta data
    ignore(output.dummy(track_switch_silence, fallible=true))  # Keep source alive even if we don't need it right now


    security = single(id="security track",security_single_address) # Get a security MP3 file just in case the HTTP stream breaks


    automated_http_stream = input.http(id="auto http stream input", auto_http_stream_address)   # Get our HTTP stream
    ignore(output.dummy(automated_http_stream, fallible=true))        # Keep source alive  and current till we need it



    default = fallback(id="security fallback", track_sensitive=false,[security,failsafe_security]) #build our default source using fallbacks

    default = fallback(id="http stream fallback", track_sensitive=false,[automated_http_stream, default])

    default = fallback(id="track switch fallback", track_sensitive=false,[once(track_switch_silence ), default])    #play up to 10 seconds of silence before HTTP


    My first try at this didn't have any "track switch silence"  in it. The problem with this was a fraction of a second of sound from either the HTTP stream or the security MP3 would leak through between tracks from airtime itself and into the output. So I added the track switch silence to try to "Clean up" the default source. I tried to make  it 10 seconds long so that it would cover the time switching between tracks and shows and such. The idea was every track switch would have the next track ready before the 10 sec and the new track would play. Any longer then that and we probably don't have a new track to switch to because nothing is scheduled. So then we fall back to the HTTP stream.

    However, what happens in practice is all due to the "once" in there. If we don't have it, at the end of 10 sec, we start another 10 sec and so on and never actually fall back to the HTTP stream.
    e.g.
    default = fallback(id="track switch fallback", track_sensitive=false,[track_switch_silence , default])    #play up to 10 seconds of silence before HTTP

     If we do have it there it will only ever insert the silence between two tracks at the very first track switch that happens. Every time after that, we end up with the leak problem again because there is no silence to cover it. So my current problem is a damned if I do damned if I Don't situation. 

    If anyone has any thoughts on how to solve this I'd really appreciate hearing them. I'm sure there has to be a better way to go about this.
  • 4 Comments sorted by
  • I understand the problem,but I do not understand  what you want to achieve and hence there is a number of things which seems confusing.
    like the use of once for a security which is a single. you would better to implement a delay so you do not have it playing over and over,resulting in a long silence.

    My reading of this is that you have a web stream that if its drop you want it fallback to tracks and then when the feed is live again it falls back to the feed.

    If that is the case let me know,what really is your objective.

     *********************************
    * V.O.I.S.S.E.S.      *         *
    * Can You Hear Me Now *         *
    *********************************
    ♬♬♬♬♬♬♬♬♬♬♬♩♪♫♩♪♫♪♩♫♪♩ ♬♬♬♬♬♬♬♬♬♬♬
    ######################################################
    [En][24/7][712- 432- 8476]############################
    http://tunein.com/radio/BIGLINK-RADIO-s190864/
    [Korean][24/7] [712- 432- 8464]#######################
    http://tunein.com/radio/Goaheadmissionorg-s190399/
    [En][Sundays 2300-Mondays 0600 EST][712- 432- 8437]###
    http://tunein.com/radio/Caribbean-Experience-s200915/
    ######################################################
    Disclaimer:-
    "The Views express by me in no way reflect the staff,team,management of airtime,its affiliate or its
    representative.
    I am in no way a member of the staff,team,management of airtime,its affiliate or its representative,

    My views are my own opinion of which I hope will help to construed a discussion in order to solve, resolved or to make things better.

    If you follow my opinions,you do so at your own risk and I bear no responsibility for your actions or in-actions.

    My opinions is not my final thoughts but something I think as I try come to my final conclusion"
    #####################################################################
    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.
  • Yes you have that exactly right. 
    The fallback sequence should be 
    airtime scheduled content - ->10 sec silence - -> web stream - -> security track - ->  security silence

    The "once" is used on the 10 second silence to try to keep things moving down the chain and not get stuck at the 10 sec stage.
    The idea was that the "once" would be reset every time we move to the left of the fallback chain into the scheduled content, and it would then be reapplied when we start moving to the right.

    As you pointed out, using "once" is confusing, and does not work. It was the closest thing to what I wanted. A delay is exactly the function I was looking for.

    Edit -  will post full script if I can get something working
    Post edited by Phillip Mackintosh at 2013-12-02 15:42:04
  • OK here's where I got to: I added a delay on the track switch silence, but now I have a 10 second gap every time my HTTP Stream changes meta data, and I can see it switching to the silence in the log. 
    This is what the sequence is (incorrectly) doing now:

    airtime scheduled content - ->10 sec silence - -> web stream- ->10 sec silence - -> web stream - ->[Repeat previous two stages Infinitely] -->  security track - -> security silence

    Here is the section that has been changed:



    # Set up a silence source to clean track switching 
    track_switch_noise = noise(id="short_noise",duration=10.)                 # generate 10 second burst of white noise
    track_switch_silence = amplify(id="silence_src", 0.00001, track_switch_noise )     # make it really quiet
    track_switch_silence = delay(id="track switch delay", .1,track_switch_silence)      # make it unavailable after finishing so we dont get stuck here
    track_switch_silence = rewrite_metadata([("title", !custom_track_switch_meta)], track_switch_silence) # rewrite meta data



    security = single(id="security track",security_single_address)               # Get a security MP3 file just in case the HTTP stream breaks


    automated_http_stream = input.http(id="auto http stream input", auto_http_stream_address)   # Get our HTTP stream
    ignore(output.dummy(automated_http_stream, fallible=true))                           # Keep source alive  and current till we need it



    default = fallback(id="security fallback", track_sensitive=false,[security,failsafe_security]) #build our default source using fallbacks

    default = fallback(id="http stream fallback", track_sensitive=false,[automated_http_stream, default])

    default = fallback(id="track switch fallback", track_sensitive=true,[track_switch_silence, default])    #play up to 10 seconds of silence before HTTP

    Change log: -  removed once from "track switch fallback"
    -  made track sensitive true on "track switch fallback" to stop it from cutting the silence in instantly it became available again.
    - removed ignore(output.dummy(track_switch_silence)) because it was causing the 10 seconds to end to early if we cut to the silence source when it was halfway through the 10 seconds
    - Added delay to try to make source unavailable until we have played some scheduled content.

    Here is a maybe better diagram of the sequence I want showing both directions of travel:

    airtime scheduled content <- -> 10 sec silence - -> web stream <- -> security stuff here
      ↑
       ---------------------------------------------------------------------
     Note that once the sequence reaches the web stream it should not move back up the chain until we have more airtime content, but all other movement is fine. 

    The delay()  was a very good step in the right direction, But not quite enough to do what I want on its own. I experimented  with putting a once() in as well as changing track_sensitive, but I didn't end up with anything closer to a solution. Thanks again for the hint, but do you have any further thoughts?
    Post edited by Phillip Mackintosh at 2013-12-04 02:28:53
  • This  is basically how you have your current order

    security======>failsafe_security,======> auto_http_stream_address

    and your current fallback look like this

    default = fallback(track_sensitive=false,

                           [
                             security,
                             failsafe_security,
                             auto_http_stream_address
                            ]
                          )

    One Liner no tab

    default = fallback(track_sensitive=false, [ security,failsafe_security, auto_http_stream_address])

    you said you want to achieve this
                                                   
    airtime scheduled content - ->10 sec silence - -> web stream - -> security track - ->  security silence

    but for this you have to use either of 2 things

    - show/master (using some external encoder like butt or edcast etc).you can use auto on in master stream
    - or external stream (icecast /shoutcast) in the library just create a show with a [content of 10sec and webstream] and loop(link) it
    -just create a 10sec file with audacity and place it in any of the source


    If you really meant
    airtime non-scheduled content - ->10 sec silence - -> web stream - -> security track - ->  security silence
    then the fallback script would need
    so do the order like this

    default = fallback(track_sensitive=false,

                           [
                             auto_http_stream_address,
                             failsafe_security,
                             security                         
                            ]
                          )
    now the sad part of that is that you might find it stuck on playing the security or stuck in the silence

    So lets skip the silence each time and also delay a second security from playing so it check back the stream if available

    #strip security   using  strip_blank(threshold=-35.,max_blank=0.2,failsafe_security) tweak how long [0.2s] and how silent [-35db]
    # delay the security from playing back immediately using  delay(1.,security)

    so now it should look like this

    default = fallback(track_sensitive=false,

                           [
                             auto_http_stream_address,
                             strip_blank(threshold=-35.,max_blank=0.2,failsafe_security),
                              delay(1.,security)                         
                            ]
                          )


     
    or if you want to do it one liner no tab same as above

    default = fallback(track_sensitive=false,[auto_http_stream_address,strip_blank(threshold=-35.,max_blank=0.2,failsafe_security),delay(1.,security)])

      Ps.
    • you only need to do the fallback statement one time in this case,
    • careful always of using once,it is usually when you want to use a source once and not make it available again.
    • the only way to get that source available again is after LS shut down and restart

    c




    Post edited by Voisses Tech at 2013-12-05 01:59:49
    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.