PDA

View Full Version : LMS and Sonos - trying



philippe_44
2014-09-21, 22:35
I'me creating that new thread to try to reach a decent solution on that. I'd copy first a few existing messages from other threads that I've exchanged

------------ my working solution today -----------------

Sonos cannot point to LMS, they ignore each other. What Sonos does well is distributing analog source connected to the line-in of any capable device (a play:5 or a connect) to any other device in the Sonos system and keeping them fully in sync. So it is as simple as connecting the line-out of a SB3 or a Touch or a Receiver to any Sonos device with Line-In. Then _that_ Squeezebox device becomes your bridge. In other words, you have to always play on that SB device to be able to listen to your music on the Sonos system. The Sonos is, to some extend, just used as wireless speakers with enhanced synchronization capabilities. What is amazing is that when I tried that, I was expecting the Sonos system to delay the analog input to a few 100ms and have to delay all my Squeezebox devices to take that into account, I was expecting awfull jitter at all - well, not at all (and I've been using that for almost 2 years). There is no audible delay between an analog input of a Sonos system and that same music forwarded to any other sonos devices - this is just instant "forward"

So, what is played on my Sonos "extensions" is fully controlled by my Squeezebox system (I use iPeng a lot, it is really a great piece of software). The only time when I use the Sonos controller is to mute / unmute / group Sonos speakers as, again, all the Sonos speakers appears as "one single entity" to the SB system. But that's all. Of course, at any time, you can ask the Sonos system to play something else than the line-in of (eg) a Play:5. The Sonos system is pointing to the same folder containing my music, so everything is as well available "natively"

Say you have

Kitchen : Boombox
Dinner room : SB3 on amplifier speakers
Bedroom : Radio

you add Sonos devices
Dinner room : Play:5
Bedroom : 2xSonos:1

Connect line-out of SB3 to the Play:5 line-in using a Y connector

To play on the Sonos(Dinner) or Sonos(Bedroom), the caveat is that you have to play on SB(Kitchen). On Sonos, configure it to re-play Sonos(Dinner:LineIn) to Sonos(Bedroom) and/or Sonos(Dinner). Using your prefered SB controller, then do what you used to do, and all speakers in Bedroom will play in perfect sync, although they are a combo of Sonos and Squeezebox. If you want to switch off Sonos(Dinner) or Sonos(Bedroom), use the Sonos application on your preferred smartphone. You can also dedicated an "old" Squeezebox receiver to be the bridge between the system, not connected to any speaker - in that case, no annoyance of having mandatory sound to be heard in one room to bridge to Sonos. I feel it is a very smooth transition or a very good combo

philippe_44
2014-09-21, 22:36
In fact, I was thinking that is I can get a multiple instance of SqueezeLite, all feeding different streams connected to Sonos controller, it might be an interesting solution. In other words

SqueezeLite:1 ==> Stream:1 ==> Sonos device:1
SqueezeLite:2 ==> Stream:2 ==> Sonos device:2
. . . . .
SqueezeLite:N ==> Stream:N ==> Sonos device:N

So, from LMS, each Sonos device would be a separated SqueezeLite entity, so it would be independently controllable as far as volume and what is played on to it. From Sonos controller, what is needed is to play a different stream on each device. Synchronization is not likely to work, but it can be achieved by connecting multiple Sonos devices to a single stream

It might be a resource hog, I don't know but I'll try with one first to see if it is possible to easily procude a stream (like a radio stream) that Sonos would recognize and if it works, then I'll see how to hack Squeezelite and a simple streamer. I realize it might not work at all, but can be a fun result :-)

Thoughts ?

philippe_44
2014-09-21, 22:38
-------one answer -----------
Probably no need to hack squeezelite as it already does output to stdout and has been used in other threads to pipe audio into other applications. In this case possibly VLC but it does not support http streaming Flac only streaming MP3 and possibly other lossy audio.

------ my cont'd ------------
That's what I'm doing now for test. I started with FFmpeg to directly do RTP but unfortunately Sonos does not support RTP. So I will either use FFServer or VLC. But, for going beyond just the test that would proove feasibility, I was more concerned about the CPU required by multiple transcoding, i.e Squeezelite decoding then VLC re-coding, that x times number of streams ... pretty inefficient, no ?

philippe_44
2014-09-21, 22:39
---------- another proposal -----------

If mp3 is acceptable, the simplest way would be to point the sonos devices to http://lmsserver:9000/stream.mp3 (see here for details)

philippe_44
2014-09-21, 22:39
Back home for some tests - this is unfortuately unusable. Sonos streams properly from http://<my LMS>/stream.mp3 but the delay for start or stop is like 30 seconds. Propably just the fact that this is heavily buffered and the Sonos client just get the stream from LMS "as it is", LMS is just a http audio server. Well I guess I will have at least to get back to squeezelite and translate a few commands to Sonos as an uPnP client. This will obviously be a long journey :-). I'v seen other threads where people manage to have something similar, but not exactly that, especially no sycn and lot of transcoding that I'd like to avoid. If I cannot make it work with at minimum a sync between LMS and Sonos, then I'd better stick to my current HW solution which provides perfect audio synchro, just with that limitation that the whole Sonos system is seens a single player by LMS

What gives me some hope is that when I use a generic app on my iPhone like PPlayer and I choose one of my uPnP servers as a server (not a Sonos device) and one of the Sonos devices as a client, it works fine, this external app is capable of streaming between both and there is almost no delay between play requests and actual play (same for stop /pause/restart). So, there might be a solution.

But if you don't care about sync and delay, using http://<my LMS>/stream.mp3 as a radio station of Sonos works

philippe_44
2014-09-24, 21:49
was able to get and compile libupnp & pthread32 for Windows - sample upnp application works and is able to communicate with other apps. Will see next step if I can control a Sonos device

philippe_44
2014-09-28, 18:07
Just want to report some update. Thanks to libupnp, I now have a small application that discovers automatically all uPNP media renderer on my networks. It is a general uPNP control point, but focusing on Sonos, I'm able to play, pause, stop Sonos devices.

1) I can send an URI that comes from LMS directly. In that case, LMS is acting as a uPNP media server and my app does nothing else that being a control point
2) More interesting, my app can also receive all HTTP-GET from Sonos devices, after it has sent "play" command to it so that, I can play anything coming from the inside of the app

I'm hopeful that I can now automatically create some "fake" SB Squeezelite devices that will simply expose Sonos to LMS - one "fake Squeezelite" for every Sonos.

With 1) it could be a software gateway between the 2, now that play, pause, stop works, the song would be direclty piped from Sonos to LMS, but my app would provide the control. There would be no synchro possible in that case, Squeezelite would not play any role in the audio data stream in fact.

With 2) the audio data stream would transit through my app and, maybe, I could get synchro by carefully feeding them to Sonos devices (although it requires messing with partial GET and things like that which might not work nicely ...)

kefkekeyser
2015-06-26, 04:37
But if you don't care about sync and delay, using stream.mp3 as a radio station of Sonos works

Does this mean that if I have a Play 5, I can just add the LMS stream as a radio station and play that on the Play 5?
Will smart volume (replaygain) and smart crossfade work in this case?
If I now also buy another SONOS player, let's say a Play 3, and I also point this to the same LMS radio station, will it be in sync with the Play 5 (SONOS syncs both players)?

I have LMS running on my Synology DS214play and really like the smartmix plugin. SONOS doesn't have this (and also does not support ReplayGain for mp3's), but they have a lot of other streaming services that squeezebox lacks (22tracks, ...). Playing LMS as a radio station in SONOS might then give me the best of both worlds.

PaulinPosset
2015-06-26, 06:50
Does this mean that if I have a Play 5, I can just add the LMS stream as a radio station and play that on the Play 5?
Will smart volume (replaygain) and smart crossfade work in this case?
If I now also buy another SONOS player, let's say a Play 3, and I also point this to the same LMS radio station, will it be in sync with the Play 5 (SONOS syncs both players)?

I have LMS running on my Synology DS214play and really like the smartmix plugin. SONOS doesn't have this (and also does not support ReplayGain for mp3's), but they have a lot of other streaming services that squeezebox lacks (22tracks, ...). Playing LMS as a radio station in SONOS might then give me the best of both worlds.

Things have moved on a bit since Phillipe last posted in this thread back in September so you might be interested in these threads ;):


http://forums.slimdevices.com/showthread.php?102496-announce-squeeze2upnp-a-bridge-between-LMS-and-uPNP-devices

http://forums.slimdevices.com/showthread.php?103728-Announce-UPnPBridge-integrate-UPnP-DLNA-players-with-LMS-(squeeze2upnp)

kefkekeyser
2015-06-26, 07:30
Things have moved on a bit since Phillipe last posted in this thread back in September so you might be interested in these threads ;)

Jikes, that are two really big threads. The squeeze2upnp seems like something to try, but I read on the first page that it doesn't support replaygain or smart transitions :(

PaulinPosset
2015-06-28, 01:57
Jikes, that are two really big threads. The squeeze2upnp seems like something to try, but I read on the first page that it doesn't support replaygain or smart transitions :(

I don't use either of those functions so am not best qualified to answer but if you post your question on the new thread Philippe will no doubt answer.

http://forums.slimdevices.com/showthread.php?103728-Announce-UPnPBridge-integrate-UPnP-DLNA-players-with-LMS-(squeeze2upnp)

philippe_44
2015-07-05, 13:36
Jikes, that are two really big threads. The squeeze2upnp seems like something to try, but I read on the first page that it doesn't support replaygain or smart transitions :(

The difficulty of replaygain and smart transition is that this is (at best) a player-dependent feature. The nature of sq2u is to be a bridge between LMS and UPnP players, so the audio tracks are not decoded, but they are forwarded (with a lot of tweaking) to the player. Decoding all tracks would potentially require a lot more CPU. I could potentially apply replaygain when receiving raw audio (pcm, wav, aiff), but flac and mp3 and all other coded format would be excluded. Smart transitions are on the same line, but even more complicated.

I thought at the beginning to have a few other modes, including one where all tracks would be decoded and that would have had allowed such features, but between the CPU load and lots of other extra complications in handling UPnP players, I concentrated on the "bridge" mode. The architecture of the system still allows it, but I don't have a plan to develop it currently. I'm concentrating on bug correction, compatibility with the infinite variation of UPnP implementations and finding a solution for synchronisation for a few subset of players.

Mnyb
2015-07-06, 01:21
FYI on a squeezebox the replaygain adjustments and xfade is done in the player itself . Is any upnp player supporting this ?

Suppose the combo of xfade and gapless and sync is near impossible to accomplish with a combination of squeezeboxes and upnp players , best case scenario can it be done with two identical upnp players ? But no one has that :) ( usually a set of mixed players ) but this looks like an endless support case ......

philippe_44
2015-07-06, 19:02
FYI on a squeezebox the replaygain adjustments and xfade is done in the player itself . Is any upnp player supporting this ?

Suppose the combo of xfade and gapless and sync is near impossible to accomplish with a combination of squeezeboxes and upnp players , best case scenario can it be done with two identical upnp players ? But no one has that :) ( usually a set of mixed players ) but this looks like an endless support case ......

Unfortunately not, having only upnp players or combo does not change the issue. To my knowledge, it is not part of upnp standard to have replay gain or xfade. To get some of these, squeeze2upnp would need to

- decode the incoming audio stream
- apply the replay gain
- optionally re-encode it in flac, mp3
- send it to the upnp player

... lots of CPU !

for xfade without gap, this is even worse as I would need to, on top of the above, aggregate all I'm receiving from LMS into a single long track and apply the xfade transform on the fly and sen that stream to the upnp player. But then it would prevent me from knowing which track is played on the player (remember that upnp players buffer a lot of the sent data, so the only way to know and report the time position to LMS is to request this position from the player itself). So to 'guess' where I am in a track and in a playlist, I would have to substract the sum of already played track(s) duration from the reported time position (which would always increase). This is doable, but this is a convoluted thing to do, on top of many other side effects related to pause, repositioning and various details.

So I'm sorry for the ones that really want replay gain and xfade, but at this point of squeeze2upnp development, this is too much of a stretch.

LMSSonos
2016-07-10, 05:20
I have a collection with more than 50k tracks and recently added some Sonos devices to my existing Squeezeboxes. I wanted to be able to access all music there as well, so I build a basic bridge for Sonos to talk with LMS server. I had it in mind to run on my synology nas so it's written in nodeJS, code can be downloaded on github, can't post a link right now - first post - just search for lmssonos on github ;-)

philippe_44
2016-07-10, 07:07
I have a collection with more than 50k tracks and recently added some Sonos devices to my existing Squeezeboxes. I wanted to be able to access all music there as well, so I build a basic bridge for Sonos to talk with LMS server. I had it in mind to run on my synology nas so it's written in nodeJS, code can be downloaded on github, can't post a link right now - first post - just search for lmssonos on github ;-)

Hi - The UPnP bridge I finally built works also very well with Sonos, but it means that LMS is the music source, it does not let you listen to Sonos collection in LMS