If condition in Liquidsoap.
  • Hi!

    Does someone know how to make this condition working (in Liquidsoap, i try to use it behind AirTime)

    radio = fallback([radio, security])
    che = true
    if che == true then
            radio2 = ref nrj(radio)
    else
            radio2 = ref radio
    end
    [...]
    output.shoutcast( [...], radio2 )

    It tells me:
    $ liquidsoap test.liq
    At line 54 char 8 - line 55 char 0: the variable radio2 used here
      has not been previously defined.
  • 2 Comments sorted by
    1. I will assume you have Airtime on your machine this is because versions < 1.1.1 on ubuntu and debian are not compiled with mp3 supports and so you will get a "'variable " not defined error if your output is coded with mp3.Do a command  liquidsoap --version to ensure
    2. just  a note on using "=" .  A variable with "=" of any expression is used to give the variable a brand new name its not an assigment or definition
       
       so its like myname=voisses,i can now use voisses instead of myname.
    3. nrj gives a loud and crackling sound depending on the bit rate of your track

    Therefore by saying che=true is saying che is the same name as true,more like you would want instead to assign che to be the boolean true as the default value and that would be che==true



    Post edited by Voisses Tech at 2014-03-17 23:05:48
    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.
  • Now ,the code does not make sense because you are putting a condition to do sound processing.
    to which is not clear .

    Sound processing like  nrj are used like this

    You have a source ,you take that source add something to it and then you get a  modified source.

    in basic simplicity terms that is

    source =(modified)source

    In Language terms

    (?id:string,what_want_to_do,source(audio='#a,video='#b,midi='#c))->source(audio='#a,video='#b,midi='#c)

    where what I want to do can be anything like flange,compress etc.

    You would more want to use a condition like saying

    1. If some condition exist  then do X like route the source some where else
    2. or place it in a function  and call that function at the end  like this

                def radio2()
     
                       #  make some statement about che
                                   che="blah blah blah"
         
                               #then do whatever you want
                                if che == true then
                                          radio= nrj(radio)
                                      else
                                          radio=radio
                                    end

                             end

    # then call the function

    output.shoutcast( [...], radio2 )

    Well to be honest its really not clear what you want to achieve and to be truthfull this maybe best asked in the liquidsoap mailing list

    Good luck




    Post edited by Voisses Tech at 2014-03-18 04:48:25
    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.