Audio Liquidsoap没有明确定义标识变量

Audio Liquidsoap没有明确定义标识变量,audio,stream,audio-streaming,icecast,liquidsoap,Audio,Stream,Audio Streaming,Icecast,Liquidsoap,好吧,我已经把头发拔了好几个小时了 Liquidsoap对我不起作用,我知道这应该起作用,因为一个明显的错误 set("log.file",false) set("log.stdout",true) set("log.level",3) podcasts = playlist("/home/user/icecast/ham.txt") # This function turns a fallible # source into an infallible source # by playin

好吧,我已经把头发拔了好几个小时了

Liquidsoap对我不起作用,我知道这应该起作用,因为一个明显的错误

set("log.file",false)
set("log.stdout",true)
set("log.level",3)

podcasts = playlist("/home/user/icecast/ham.txt")

# This function turns a fallible
# source into an infallible source
# by playing a static single when
# the original song is not available
def my_safe(radio) =
  # We assume that festival is installed and
  # functional in liquidsoap
  security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!")
  # We return a fallback where the original
  # source has priority over the security
  # single. We set track_sensitive to false
  # to return immediately to the original source
  # when it becomes available again.
  fallback(track_sensitive=false,[radio, security])
end

radio= podcasts
radio= my_safe(podcasts)

# A function that contains all the output
# we want to create with the final stream
def outputs(s) =
  # First, we partially apply output.icecast
  # with common parameters. The resulting function
  # is stored in a new definition of output.icecast,
  # but this could be my_icecast or anything.
  output.icecast = output.icecast(host="localhost", password="foobar")
  # An output in mp3 to the "live" mountpoint:
  output.icecast(%mp3, mount="live",radio)
end
错误呢

At line 23, character 6: The variable radio defined here is not used anywhere
  in its scope. Use ignore(...) instead of radio = ... if you meant
  to not use it. Otherwise, this may be a typo or a sign that your script
  does not do what you intend.
如果有人能解决我的另一个问题

我想了解如何将两个源运行到两个单独的装入点

set("log.file",false)
set("log.stdout",true)
set("log.level",3)

podcasts = playlist("/home/user/icecast/ham.txt")
songlist = playlist("/home/user/icecast/otherplaylist.txt")

# This function turns a fallible
# source into an infallible source
# by playing a static single when
# the original song is not available
def my_safe(radio) =
  # We assume that festival is installed and
  # functional in liquidsoap
  security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!")
  # We return a fallback where the original
  # source has priority over the security
  # single. We set track_sensitive to false
  # to return immediately to the original source
  # when it becomes available again.
  fallback(track_sensitive=false,[radio, security])
end

radio= podcasts
radio= my_safe(podcasts)

def my_safe(songlist) =
  # We assume that festival is installed and
  # functional in liquidsoap
  security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!")
  # We return a fallback where the original
  # source has priority over the security
  # single. We set track_sensitive to false
  # to return immediately to the original source
  # when it becomes available again.
  fallback(track_sensitive=false,[songlist, security])
end

moarradio= songlist
moarradio= my_safe(songlist)

# A function that contains all the output
# we want to create with the final stream
def outputs(s) =
  # First, we partially apply output.icecast
  # with common parameters. The resulting function
  # is stored in a new definition of output.icecast,
  # but this could be my_icecast or anything.
  output.icecast = output.icecast(host="localhost", password="foobar")
  # An output in mp3 to the "live" mountpoint:
  output.icecast(%mp3, mount="live",radio)

  output.icecast(%mp3, mount="otherlive",moarmusic)
end

我得到了同样的错误,但它告诉我没有使用第二个变量(moarradio)

liquidsoap配置文件基本上是一个脚本,这意味着它将从上到下运行

读取配置文件时,它抱怨您没有使用
无线电
变量定义的第23行,原因是您使用的是定义的第24行。与许多其他语言不同,liquidsoap脚本中有

除此之外,您似乎不了解全局变量和局部变量之间的区别,以及它们各自的作用域

您正在声明一个
my_safe
函数,该函数包含一个参数。在函数的作用域内,使用其名称引用参数。然后使用全局变量作为参数调用
my_safe
函数,您所期望的将实际发生

如果不调用
outputs
函数,您的源将无法注册。只需删除函数构造

下面是我如何改写您的第二个示例:

set("log.file",false)
set("log.stdout",true)
set("log.level",3)

podcasts = playlist("/home/user/icecast/ham.txt")
songlist = playlist("/home/user/icecast/otherplaylist.txt")

# This function turns a fallible
# source into an infallible source
# by playing a static single when
# the original song is not available
def my_safe(stream) =                          # <- used a different variable name here
  # We assume that festival is installed and
  # functional in liquidsoap
  security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!")
  # We return a fallback where the original
  # source has priority over the security
  # single. We set track_sensitive to false
  # to return immediately to the original source
  # when it becomes available again.
  fallback(track_sensitive=false,[stream, security])  # <- used a different variable name here
end

radio= my_safe(podcasts) # <- fix here

# <- got rid of redeclaration of my_safe

moarradio= my_safe(songlist) # <- fix here

# <- got rid of function construct
# First, we partially apply output.icecast
# with common parameters. The resulting function
# is stored in a new definition of output.icecast,
# but this could be my_icecast or anything.
output.icecast = output.icecast(host="localhost", password="foobar")
# An output in mp3 to the "live" mountpoint:
output.icecast(%mp3, mount="live",radio)
output.icecast(%mp3, mount="otherlive",moarradio)  # <- fix here
set(“log.file”,false)
设置(“log.stdout”,true)
设置(“日志级别”,3)
播客=播放列表(“/home/user/icecast/ham.txt”)
歌曲列表=播放列表(“/home/user/icecast/otherplaylist.txt”)
#此函数可将易出错的
#将源转换为绝对正确的源
#播放静态单曲时
#原始歌曲不可用
def my_安全(流)=#