This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Allow synchronized playback on multiple devices over the network

35

Votes
37
2
Tags: phonon phonon phonon
(comma "," separated)
clintonthegeek
Registered Member
Posts
49
Karma
0
The best thing about listening to music on the radio is that you can turn on multiple radios around your house, backyard, etc. and be able to hear it wherever you go.

To that end, it would be awesome to be able to stream KDE's audio to any networked device capable of receiving streaming audio (PC, laptop, PDA, iPhone, PS3, XBox etc).

AFAIK, the hardest part would be getting it synced up properly due to the gaps which would be introduced by network latency and buffering. This could be fixed by a short calibration procedure after a device connects to Phonon's network audio stream which 'listens' to the audio through your desktop microphone (or other Phonon input channel), measures the delay, and then adjusts accordingly without interrupting the stream.

Now here's the cool part: Consider the situation where the media you are listening to has more than two audio channels (i.e. 5.1 surround sound). What if your KDE desktop computer only has a **** generic one-jack stereo sound card? You have Phonon play only the front R/L channels on your desktop computer, and play only the rear channels on your networked device (which you put behind your chair/couch!). Boom -- instant wireless surround-sound speaker configuration. Never run speaker wire again! :shade:

Now with only an extra pair of computer speakers (dirt cheap used) and any wifi-enabled device with a phono-jack you can set up a surround-sound environment anywhere in your house/backyard, etc. Or even a dead-simple public announcement system for a small event. Pretty much any case where you just want to put speakers somewhere without needing a patchboard or tons of wiring to trip over (or, like me, have no speaker wire but tons of LAN cable! :D ).

And from the UI-standpoint all the users should need to do would be along the lines of
  1. Click "Add remote speakers" from the Phonon control panel (or Plasmoid or KMix or wherever)
  2. Configure the audio channels they'd like to redirect for network broadcast
  3. Connect to the stream from their device (Either directly, like say to an address like http://192.168.1.15/Phonon/Device1 or from a pre-generated playlist file copied onto the device with the stream address inside of it)
  4. Automatically (or manually, I suppose) adjust the delay so that sound output is synchronized. Maybe the desktop sends some looping calibration sound to the network device which is then picked-up by your PC microphone, or plays an animation of a movie-style clack-board or a metronome that you manually sync to coincide with accompanying sound (from the PC, since the device is just a dumb-client).

Since I'm unsure exactly how Phonon works, I'm not sure whether this would be possible on an app-by-app basis, or for the whole desktop. Presumably since networked audio devices would lag behind the server, either the server will have to transmit audio data ahead of what is currently being played locally (probably pretty hard) or delay it's local audio output to wait for the networked devices to catch up. The second option is probably easier, but would obviously lag the response time on player controls like pausing/playing, and totally mess up the sync with video playback or any other scenerio where audio should coincide with other events (like in video games).

So... Is this even feasible within the existing audio framework of Phonon/Linux/KDE?

Last edited by clintonthegeek on Sat May 02, 2009 1:33 am, edited 1 time in total.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
That is actually something to take care of "below" Phonon, i.e. in frameworks used to implement Phonon backends.

Maybe GStreamer can do that already or there are plans to add this, or somebody could be developing a Phonon backend based on NMM http://www.networkmultimedia.org/

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar
Madman
Registered Member
Posts
593
Karma
1
OS
It would be nice to have some sort of pretty UI to visualize the different outputs over the network...

If a Phonon backend were to have wireless networking support, would you see the additional speakers as devices in System Settings --> Multimedia?


Madman, proud to be a member of KDE forums since 2008-Oct.
User avatar
aapgorilla
Registered Member
Posts
247
Karma
0
OS
you can do that with pulseaudio, you can create virtual in-/output devices from any number of real devices but pulse pushes alsa drivers to the limits (or most of the time actually well beyond)...the only problem other is kmix doesnt seem to support phonon just alsa but I heard Helio from mdv is hacking away to integrate phonon or pulse into kmix

(btw I think you could do this now in gnome since 2.26)

Last edited by aapgorilla on Sat May 02, 2009 8:42 pm, edited 1 time in total.
clintonthegeek
Registered Member
Posts
49
Karma
0
aapgorilla wrote:you can do that with pulseaudio, you can create virtual in-/output devices from any number of real devices but pulse pushes alsa drivers to the limits (or most of the time actually well beyond)...the only problem other is kmix doesnt seem to support phonon just alsa but I heard Helio from mdv is hacking away to integrate phonon or pulse into kmix

(btw I think you could do this now in gnome since 2.26)

Holy ****... you're right! Googling around and reading different docs and wikis suggests that Phonon just needs to eventually make the switch to using PulseAudio as a backend directly instead of using it through Alsa like it is now... so I guess once there are KDE equivilants to the PulseAudio applications like the Device Chooser then this will become a native feature of every KDE desktop?

Image
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
clintonthegeek wrote:Googling around and reading different docs and wikis suggests that Phonon just needs to eventually make the switch to using PulseAudio as a backend directly...


That won't work since PulseAudio is not a multimedia framework, e.g. it doesn't do any media handling like decoding.

clintonthegeek wrote:...instead of using it through Alsa like it is now


Phonon doesn't do anything at this level, its backends do. If the backend, e.g. GStreamer, is configured to output to ALSA, then that this is where the audio will end up.
If it is configured to use PulseAudio, the audio will end up there.

It is always only a matter of the capabilities of the multimedia stack used to implement the Phonon backend.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
clintonthegeek
Registered Member
Posts
49
Karma
0
Thanks for the informative replies. :)

So lemme get this straight. Here's how PulseAudio fits into the multimedia stack:
Image
from http://en.wikipedia.org/wiki/File:Pulse ... iagram.svg

And here's a really helpful blog-post explaing tons of stuff about PulseAudio and ALSA and what they are (and not)
http://tiyukquellmalz.org/blogs/blog5.p ... und-stacks

This is a reply to a blog post by Aaron Seigo which has a huge flamewar comment-section which makes for some interesting reading too.

So PulseAudio is like the middle-man between the application layer (PulseAudio-enabled apps like FlashPlayer, Skype, and regular desktop apps which use libalsa), and the output devices (your soundcard, another soundcard, network stream etc.) which mainly is incharge of software mixing (making sure multiple applications can output sound at the same time) as an alternative to the current ALSA software mixer, dmix, which apparently sucks (less featurefull, doesn't work with OSS devices, etc.) or hardware mixing, which is not standardized and missing from most cheapo desktop soundcards.

So for lots of apps it goes libalsa -> PulseAudio -> real ALSA, which breaks lots of stuff because ALSA is poorly documented and PulseAudio is mainly a one-man show with limited testing capabilities. And OSS applications like VMWare out out in the cold.

So Phonon would fit into the Library layer, right? Right now the Phonon control panel shows multiple soundcard devices, and lets you route different types of applications to different devices. I'm still a little unclear on how that is different (not redundant) to what PulseAudio wants to do. I don't have PulseAudio installed right now, so I can't quite see how they play together. But based on your last post, it would go KDE App -> Phonon -> GStreamer (or XINE or whatever) (decoded from MP3 or ogg or whatever to raw DATA) -> PulseAudio -> Soundcard (through ALSA drivers again?) or network or whatever. Is that right?

So the configuration of all the different wonderful PulseAudio outputs (sinks?) to the soundcard/USB headset/network stack would be configured independantly of Phonon, right? In a few years, assuming PulseAudio becomes the defacto-standard for audio mixing, wouldn't that make the different devices in Phonon's configuration panel redundant?

I know it's a lot of questions, it just seems that there is a whole-lot of misunderstanding and missplaced ill-will toward every part of the audio-stack based on all of the opinions I'm reading, so I guess at this point I'm just trying to figure how everything fits together. :D

But whether through Phonon or PulseAudio or whatever, the bottom line is EVENTUALLY something like the idea in my OP will be feasible in the near (distant) future, right?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Phonon simply enables applications to communicate in a abstract manner with any multimedia framework ( read Library Layer ) that a backend has been written for. It can instruct the framework through the backend which audio devices it wishes to use. It is part of the "Application Layer".

Therefore it is actually like follows: Phonon Enabled Application > Phonon Backend ( Xine / GStreamer ) > Pulseaudio > ALSA Sink.

Last edited by bcooksley on Mon May 04, 2009 5:28 am, edited 1 time in total.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
aapgorilla
Registered Member
Posts
247
Karma
0
OS
then we need a pulse enabled mixer/tray applet and we're in business...

clintonthegeek wrote:But whether through Phonon or PulseAudio or whatever, the bottom line is EVENTUALLY something like the idea in my OP will be feasible in the near (distant) future, right?


you could do it today in gnome.... :(

Last edited by aapgorilla on Wed May 06, 2009 9:38 pm, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
By Pulse enabled Mixer / Tray applet you mean a Pulseaudio backend to KMix I hope?

You can do it today in GNOME is because I believe Pulseaudio was started to help fix the "esound" daemon problem GNOME has. GNOME also started NetworkManager, hence why the GNOME applet always has the latest and greatest.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
aapgorilla
Registered Member
Posts
247
Karma
0
OS
bcooksley wrote:By Pulse enabled Mixer / Tray applet you mean a Pulseaudio backend to KMix I hope?


Yeah but GNOME had to rewrite theirs, so I don't know how easy it is to do it with the existing kmix
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS
The problem is that there is no way to configure the backend through phonon.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965
User avatar
aapgorilla
Registered Member
Posts
247
Karma
0
OS
I don't have my other (usb)soundcard here but see the problem, I have selected pulse audio as my output device which is great but kmix only controls my (****) intel hda internal soundcard, so it seems kmix does not use phonon

Image

Last edited by aapgorilla on Thu May 07, 2009 4:53 pm, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
This is because Phonon was not designed for Audio Mixing applications such as KMix, since KMix interfaces with a level lower than Phonon does ( the underlying audio driver framework, ALSA/OSS )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
waldelf
Registered Member
Posts
333
Karma
0
OS
so... thats a lot of information... thx btw. but.. what would be the best solution to this problem? do we have to use phonon for this ...if phonon does not provide an api for this .. can phonon be extended ?


Kubuntu 12.04 x64 | KDE SC 4.8
Nvidia 8800 GTS | Core2Duo E6600 | 4 GB RAM


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]