ralphy wrote: 
> I'm interested.
> 
> I couldn't use stdout from squeezelite in the python script without
> pretty much rewriting it.
> 
> I modified the pa script yesterday to use arecord from an ALSA loopback
> and with squeezelite output pointed to the same loopback device, I could
> stream the content but it rebuffered a lot.  I suspect playing around
> with the buffer sizes might fix it, but from your post in the
> squeezelite thread, sounds like your solution is much cleaner.
> 
> Thanks in advance.
And here I was assuming that your initial reply was implying (very
politely) that it was all easy and I was being slow in not understanding
how to do it!  Maybe I should have more faith in my own tinkering
abilities :)

My squeezelite script, named squeezelite-streamMarantz.sh, for my
Marantz player that will play 24/96 quality,  is:

Code:
--------------------
    
  ........./squeezelite-x86-64 -o - -a 24 -n Play-Stream-Marantz -m 
00:00:00:00:00:02 -r 96000 -p 25 -u X -s localhost:3483
  
--------------------

where ... is the path to squeezelite.  The -u X makes sure that the
output is at the specified rate, and the -m MAC is there to allow me to
run multiple players by varying the MAC.

My python script, named playstreamMarantz, for the same player, is as
below.  The input to sox must be the same as the output from
squeezelite.  The script makes the stream available on port 8083 without
further resampling.

Code:
--------------------
    #!/usr/bin/python
  
  import BaseHTTPServer
  import SocketServer
  import subprocess
  
  PORT = 8083
  
  MIMETYPE = 'audio/x-wav'
  BUFFER = 65536
  
  class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
  def do_HEAD(s):
  print s.client_address, s.path, s.command
  s.send_response(200)
  s.send_header('content-type', MIMETYPE)
  s.end_headers()
  def do_GET(s):
  s.do_HEAD()
  pa = subprocess.Popen('sox -t raw -r 96000 -b 24 -L -e signed -c 2 - -t wav - 
', shell = True, bufsize = BUFFER, stdout = subprocess.PIPE)
  while True:
  data = pa.stdout.read(1024)
  if len(data) == 0: break
  s.wfile.write(data)
  print 'stream closed'
  
  httpd = SocketServer.TCPServer(("", PORT), Handler)
  
  print "listening on port", PORT
  
  try:
  httpd.serve_forever()
  
  except KeyboardInterrupt:
  pass
  
  httpd.server_close()
  
--------------------


To run the player I run the following as the squeezelite user.  I do
this by using a user command defined in the LMS server power control
plugin, which appears in the Extras menu.  I also include it as a
command named '.autoexec' in that plugin, so it starts when LMS is
started.  It starts by killing off any squeezelite and python script
previously running.


Code:
--------------------
    
  pkill -f Play-Stream-Marantz
  pkill playstreamMarantz
  sleep 5
  ..../squeezelite-streamMarantz.sh | ..../playstreamMarantz > 
...../playstreamMarantz.out 2>&1 &
  
--------------------


All scripts must be executable by the squeezeboxserver user.

To be tidier I could parameterise the scripts so that the rate, port and
so on where specified once in the startup script.

I still can't get the squeezelite log, but I am not using any audio
device or sink, which seems to me to be a clean solution.  I've been
playing this all morning, OK so far.



LMS 7.9 on VortexBox Midi running Xubuntu 14.04, FLACs 16->24 bit,
44.1->192kbps. Wired Touch + EDO, coax to Musical Fidelity M1 CLiC.
Wireless Xubuntu 14.04 laptop controls LMS via Chromium.   Meridian
Explorer USB DAC to listen via Squeezelite on Vortexbox & other PCs as
required.  Spare Touch in loft.
------------------------------------------------------------------------
PasTim's Profile: http://forums.slimdevices.com/member.php?userid=41642
View this thread: http://forums.slimdevices.com/showthread.php?t=101622

_______________________________________________
discuss mailing list
discuss@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/discuss

Reply via email to