One other confusing syntax. If you want to use the variable inside quotes,
you need to do something like
ignore(server.execute("var.set volume=#{!vol}"))
You need to enclose it in #{}
Nick
On Wed, Oct 25, 2017 at 3:17 AM, René Jaun <[email protected]> wrote:
> Hello Nick!
>
> YES! Thanks a lot! That was exactly what I was looking for.
>
>
> I'll follow up with my finished script in a few days as others mithg find
> it instructive. :)
>
>
> Just wanted to let you know things work fine now!
>
> Best regards,
>
> René
>
>
>
>
> Am 24.10.2017 um 00:10 schrieb Nicholas Vrtis:
>
> Hi Rene,
>
> I think your problem is how to reference variables defined outside a
> function OCAML handles scope.
>
> To increment a number inside a function should be done like that.
>
> timesplayed = ref 1
>
> def bumpcounter () =
> timesplayed := !timesplay + 1
> end
>
> Note the 'ref' when you define the variable in the main program
>
> Then to use that variable inside the function, you need to prefix it with !
>
> and to set it, you use := instead of just =
>
> Hope this helps.
>
> Nick
>
> On Sun, Oct 22, 2017 at 11:55 AM, René Jaun <[email protected]>
> wrote:
>
>> Hello Everyone,
>>
>> Sorry for re-bothering you with this,
>>
>> But I'm still stuck at the problem I described a few months ago.
>>
>> Back then, I've been trying to set up a "song counter"
>>
>> (which would enable me to switch the source to unavailable after having
>> played like 15 items from playlist / source).
>>
>> But whatever I tried, I could not get a simple thing like
>>
>> songsplayed = songsplayed+1
>>
>>
>> to work.
>>
>>
>> Now, I just discovered that in latest LiquidSoap, there is the "time"
>> function, which I think might do the trick just fine.
>>
>>
>> However, I don't get this one to work either.
>>
>> Could someone try helping me out once more?
>>
>>
>> What I try to do:
>>
>> As soon as my live source goes offline, music should be played for about
>> 15 minutes.
>>
>> After 15 minutes, the "music" should become unavailable and instead, a
>> single file should be played (telling the listeners that no broadcast is
>> going on).
>>
>>
>> What I get:
>>
>> Currently, the line {time - musictime < 300} results in:
>>
>> this value (referring to: musictime) has type
>> ()->float
>>
>> but it should be a subtype of
>> something that is a number type
>>
>> These are the important lines:
>>
>> #The stream should start with music
>>
>> musictime = time
>>
>>
>> #Transition to live source
>>
>> def GoLive (old, new) =
>>
>> source.skip(old)
>>
>> sequence([old,new])
>>
>> end
>>
>>
>> #Transition away from live
>>
>>
>> def ComeHome(old,new) =
>>
>> musictime = time
>>
>> sequence(old,, new)
>>
>> end
>>
>>
>> #The soures
>>
>> offairloop = mksave(playlist("/home/pi/radio/loop"))
>>
>> themusic = playlist("/mnt/storage/radio/music")
>>
>>
>> #The switch, where the magic is supposed to happen
>>
>> nonliveradio = switch (track_sensitive = true, [
>>
>> ({time - musictime < 300}, themusic),
>>
>> ({true}, offairloop)
>>
>> ])
>>
>>
>> #Later, I'll add the live source, and do a fallback: When live goes off,
>> switch to nonliveradio...
>>
>> #But that I think is not important just yet :-(
>>
>>
>> So once more, I'd appreciate any pointers.
>>
>> Thanks so much!
>> And best regards,
>> René
>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Savonet-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Savonet-users mailing
> [email protected]https://lists.sourceforge.net/lists/listinfo/savonet-users
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Savonet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users