EntityinArray
EntityinArray

Reputation: 119

Liquidsoap How to get float value from ref

I know that it's possible to get string value from ref by doing

name = ref ""
name := "Dmitriy"
print("#{name}")

But i want to get float value from ref

freq = ref 0.0

def change_pitch()
    freq := random.float(min=50.0,max=1000.0)
    1.0
end

add_timeout(fast=true,1.0,change_pitch)

output.icecast(%mp3,
    host = "coolgoga.hldns.ru", port = 8000,
    password = "xxx", mount = "entity",
    name="Entity Radio", genre="Any", description="EntityinArray's favourite 
    music",
    sine(duration=0.1,!!!TOFLOAT_SOMEHOW(freq))
)

I want to make a sine wave tone that will change its pitch every second.

Thanks for help.

Upvotes: 2

Views: 219

Answers (1)

Forged Spirit
Forged Spirit

Reputation: 11

To extract value from reference you should prefix its name with '!'

def change_pitch()
    freq := random.float(min=50.0,max=1000.0)
    !freq
end

But i am not sure you even need a reference in your script It will even work like this:

def change_pitch()
    random.float(min=50.0,max=1000.0)
end

Upvotes: 1

Related Questions