Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • aura/engine
  • hermannschwaerzler/engine
  • sumpfralle/aura-engine
3 results
Show changes
Showing
with 263 additions and 0 deletions
This diff is collapsed.
This diff is collapsed.
__author__ = 'michel'
input_fs = single(id="fs", "/var/audio/fallback/output.flac")
input_http = input.http(id="http", "http://stream.fro.at/fro128.mp3")
linein_alsa_1 = input.alsa(id="linein", device = input_device_0, bufferize = false)
mixer = mix(id="mixer", [input_fs, input_http, linein_alsa_1])
output.alsa(id="lineout", device = output_device_0, bufferize = false, mixer)
set("log.file.path", "./<script>.log")
set("server.telnet", true)
set("server.telnet.bind_addr", "0.0.0.0")
set("server.telnet.port", 1234)
# ALSA / pulse settings
# durch ausprobieren herausgefunden für asus xonar dgx 5.1
# chip: CMI8788
# driver: snd_oxygen
set("frame.duration", 0.30)
set("alsa.alsa_buffer", 8192) # 7168) # 6144) # 8192) # 10240) #15876
set("alsa.buffer_length", 25)
set("alsa.periods", 0) # assertion error when setting periods other than 0 => alsa default
input_linein = input.alsa(id="linein", bufferize = false)
input_fs = single(id="fs", "/var/audio/fallback/output.flac")
input_http = input.http(id="http", "http://stream.fro.at/fro-128.ogg")
mixer = mix(id="mixer", [input_fs, input_http, input_linein])
output.alsa(id="lineout", bufferize = false, mixer)
%include "readini.liq"
inifile = '/etc/aura/aura.ini'
ini = read_ini(inifile)
set("log.file.path", "./<script>.log")
set("server.telnet", true)
set("server.telnet.bind_addr", "0.0.0.0")
set("server.telnet.port", 1234)
use_alsa = list.assoc("use_alsa", ini) == "y"
frame_duration = float_of_string(list.assoc("frame_duration", ini))
frame_size = int_of_string(list.assoc("frame_size", ini))
alsa_buffer = int_of_string(list.assoc("alsa_buffer", ini))
alsa_buffer_length = int_of_string(list.assoc("alsa_buffer_length", ini))
alsa_periods = int_of_string(list.assoc("alsa_periods", ini))
if use_alsa then
if frame_duration > 0.0 then
print("setting frame.duration to #{frame_duration}")
set("frame.duration", frame_duration)
end
if frame_size > 0 then
print("setting frame.size to #{frame_size}")
set("frame.size", frame_size)
end
if alsa_buffer > 0 then
print("setting alsa.buffer to #{alsa_buffer}")
set("alsa.alsa_buffer", alsa_buffer)
end
if alsa_buffer > 0 then
print("setting alsa.buffer_length to #{alsa_buffer_length}")
set("alsa.buffer_length", alsa_buffer_length)
end
if alsa_periods > 0 then
print("setting alsa.periods to #{alsa_periods}")
set("alsa.periods", alsa_periods) # assertion error when setting periods other than 0 => alsa default
end
end
# First, we create a list referencing the dynamic sources:
dyn_sources = ref []
# This is our icecast output.
# It is a partial application: the source needs to be given!
out = output.icecast(%mp3,
host="test",
password="hackme",
fallible=true)
# Now we write a function to create
# a playlist source and output it.
def create_playlist(uri) =
# The playlist source
s = playlist(uri)
# The output
output = out(s)
# We register both source and output
# in the list of sources
dyn_sources :=
list.append( [(uri,s),(uri,output)],
!dyn_sources )
"Done!"
end
# And a function to destroy a dynamic source
def destroy_playlist(uri) =
# We need to find the source in the list,
# remove it and destroy it. Currently, the language
# lacks some nice operators for that so we do it
# the functional way
# This function is executed on every item in the list
# of dynamic sources
def parse_list(ret, current_element) =
# ret is of the form: (matching_sources, remaining_sources)
# We extract those two:
matching_sources = fst(ret)
remaining_sources = snd(ret)
# current_element is of the form: ("uri", source) so
# we check the first element
current_uri = fst(current_element)
if current_uri == uri then
# In this case, we add the source to the list of
# matched sources
(list.append( [snd(current_element)],
matching_sources),
remaining_sources)
else
# In this case, we put the element in the list of remaining
# sources
(matching_sources,
list.append([current_element],
remaining_sources))
end
end
# Now we execute the function:
result = list.fold(parse_list, ([], []), !dyn_sources)
matching_sources = fst(result)
remaining_sources = snd(result)
# We store the remaining sources in dyn_sources
dyn_sources := remaining_sources
# If no source matched, we return an error
if list.length(matching_sources) == 0 then
"Error: no matching sources!"
else
# We stop all sources
list.iter(source.shutdown, matching_sources)
# And return
"Done!"
end
end
def backup_pool () =
result = get_process_lines("python ./helpers/next_song_from_pool.py")
log("next song: #{result}")
request.create(list.hd(result))
end
backup_pool = request.dynamic(backup_pool)
# Now we register the telnet commands:
server.register(namespace="dynamic_playlist",
description="Start a new dynamic playlist.",
usage="start <uri>",
"start",
create_playlist)
server.register(namespace="dynamic_playlist",
description="Stop a dynamic playlist.",
usage="stop <uri>",
"stop",
destroy_playlist)
server.register(namespace="dyn",
description="load next song from pool",
usage="next <folder>",
"next",
output.dummy(blank())
This diff is collapsed.
__author__ = 'michel'
import os
import sys
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import getopt
scriptdir = os.path.dirname(os.path.abspath(__file__))
# import our libraries
package_dir = os.path.join(scriptdir, '../../../')
path = list(sys.path)
sys.path.insert(0, package_dir)
#from libraries.reporting.messenger import AuraMessenger
from libraries.base.config import ConfigReader
from modules.communication.zmq.adapter import ClientZMQAdapter
def main(argv):
#m = AuraMessenger()
task = ''
channel = ''
name= ''
value = ''
time = ''
config = ConfigReader()
config.loadConfig()
zmqclient = ClientZMQAdapter(config.get('zmqhostip'), config.get('zmqport'))
try:
opts, args = getopt.getopt(argv,"c:t:n:v:t",["channel=","task=", "name=","value=","time="])
except getopt.GetoptError:
print('message.py -c <channel> -t <task> [-n <name> -v <value> [-t <time>]]')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('message.py -c <channel> -t <task>')
sys.exit()
elif opt in ("-c", "--channel"):
channel = arg
elif opt in ("-t", "--task"):
task = arg
elif opt in ("-n", "--name"):
name = arg
elif opt in ("-v", "--value"):
value = arg
elif opt in ("-t", "--time"):
eventtime = arg
#m.setChannel(channel)
if task == 'setEvent':
#setEvent(self, name, eventtime, value)
#opts, args = getopt.getopt(argv,"c:t:",["channel=","task="])
pass
elif task == 'setState':
if name == '':
sys.exit(2)
zmqclient.send("startup")
# m.setState(name, value)
elif task == 'liquid_startup':
zmqclient.send(task, False)
else:
print(task)
#zmqclient.send(task)
# m.sayAlive()
if __name__ == "__main__":
main(sys.argv[1:])
sys.path[:] = path
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
input_fs = single(id="fs", "/var/audio/fallback/output.flac")
input_http = input.http(id="http", "http://stream.fro.at/fro128.mp3")
linein_pulse_1 = input.pulseaudio(id="linein", device = input_device_0)
mixer = mix(id="mixer", [input_fs, input_http, linein_pulse_1])
out := output.pulseaudio(id="lineout", mixer)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.