12 ms·
How to stream audio from your phone to your laptop with PulseAudio
- ourcat 6y agoVery neat. I assume this would work work on a cheap Raspberry Pi3 or 4 too, via their Bluetooth and out via its audio jack. Now I think of it, I seem to remember seeing a project like this to make use of old wooden-box speakers (with a small amp inside too.)
- grupthink 6y agoI'd like to see someone stream my pulse to my headphones and synthesize that as music. The more amped I am, the more amped the music should be.
- WD-42 6y agoPositive reinforcement loop until your heart explodes? Be careful.
- sirius87 6y agoaww man, this is so frickin cool. i just set this up, and its amazing. i really needed this for audiobooks. thank you! <3 I use an app called "Voice" [1] on Android for audiobooks. I'm so used to it that any other app or way to consume audiobooks seems below par. [1] https://github.com/PaulWoitaschek/Voice https://github.com/PaulWoitaschek/Voice
- bostonvaulter2 6y agoThat seems interesting. Where do you get your audiobooks from?
- teruakohatu 6y agoMy library offers a audiobook service that provides DRM free MP3s.
- frosted-flakes 6y agoNot the same person, but I get my audiobooks from Amazon Audible or my local public library. In the case of Audible, the first listen usually occurs in the Audible app, but eventually I remove the DRM (converting it to mp3) and dump it in my Books folder, which automatically syncs to my phone with SyncThing. I often re-listen to audiobooks a year or two later, and subsequent listens happen in the Voice app. I like having my books stored locally so I can listen to them whenever, and it's also a safeguard if they ever disappear from Audible. When I check out audiobooks from my library, I do it through the OverDrive program on my Windows computer, which lets you download in mp3 format. It's apparently on the honour system to delete the files once you finish it (which is shocking), but I have to admit that I usually don't. If I ever do re-listen to them, I just check it out from the library again, skipping the download step because I already have the mp3s.
- libraryatnight 6y agoI hadn't considered doing this to save my audible purchases. Going to, now!
- sirius87 6y agoAudible + https://hub.docker.com/r/ryanfb/inaudible https://hub.docker.com/r/ryanfb/inaudible
- ajflores1604 6y agoCould probably roll something yourself using Spotify API. Has tempo available as a query https://developer.spotify.com/documentation/web-api/reference/tracks/get-audio-analysis/ https://developer.spotify.com/documentation/web-api/referenc...
- drewg123 6y agoThis exists. I use it daily & it is awesome. Its called spotifyd: https://github.com/Spotifyd/spotifyd https://github.com/Spotifyd/spotifyd
- mixmastamyk 6y agoI don't really understand how this fits in.
- grawprog 6y agoLinux audio can be a pain to get setup, but once you've got it setup you can do some pretty cool things. I set something up similar the other day with pulseaudio and a Bluetooth headset. I used it to route the headset channel output on mixxx to the Bluetooth headset and the master output through the speaker output. Sadly, the latency was too much to actually mix and beatmatch properly, but it was a fun exercise and just the fact I could do it was pretty cool.
- sudosysgen 6y agoI wonder if it could work with modern AptX low-latency headsets.
- rektide 6y agoPulse has latency adjustment so devices can compensate for latency. When using combine module to output to multiple devices, do drop the sync latency fr the default 10s. Especially if it's a BT device. Turned it fr a nightmarish hell of constantly drifting terrible audio to just working multiple devices output for me.
- marcan_42 6y agoLatency compensation, not magic latency elimination. The latter is not possible :-) You can get audio to line up across different outputs when it is being played from a source with a large buffering capability, which is what PulseAudio does well. But when you're trying to get real-time audio to respond to user input (e.g. games, or DJing or playing music), latency compensation just gives you the lowest common denominator, and PulseAudio isn't really any good at guaranteeing low latencies for these use cases anyway. That's why for music production on Linux, you should be using JACK (or directly using ALSA from whatever source app you have, e.g. mixxx or Ardour). In either case, the Bluetooth issue is inherent to the protocol and codec and technology stack there, and there's no way to fix it. It's really, really hard to do wireless audio with low enough latency for live music, especially on 2.4GHz where you need error correction and retransmits because the band is always so congested. I have a wireless microphone set on 2.4 using proprietary dedicated technology for this, and it still has noticeable latency (though just about usable for karaoke and such, but not ideal), because it has to introduce a fixed latency to allow for a retransmit budget in case of error.
- fignews 6y agoHave shairplay installed on my Linux desktop to accomplish something similar in the iOS playground.
- neolog 6y agoDoes anybody know, Is it possible to get high-quality two-way audio (e.g. Zoom, Skype) over Bluetooth on Linux?
- DenseComet 6y agoI believe this is an issue with the Bluetooth codecs. The higher quality codecs use bandwidth dedicated to the mic to also transmit audio signals, and cannot be used for two-way communication. If you actually look at the active codec while just listening to audio, compared to the codec used when also transmitting mic audio back, you will see that they are completely different.
- boomboomsubban 6y agoI think you just need to tell Pulse to use a different profile. https://wiki.archlinux.org/index.php/Bluetooth_headset#Switch_between_HSP/HFP_and_A2DP_setting https://wiki.archlinux.org/index.php/Bluetooth_headset#Switc...
- the_pwner224 6y agoPulse already automatically switches the profiles. The issue is that the good codecs are available in the A2DP profile which is sound output only. Pulse will automatically switch back and forth from the HSP profile when an application starts/stops using input from the headset mics, but in HFP you don't have access to the high quality codecs. Exact same thing happens on Windows and Android and on Apple devices. The only case where your linked command would be necessary is when depending on your Bluetooth devices & adapters the headset connects and then for some reason registers as HSP instead of A2DP - so you manually switch it back to A2DP to get HQ audio.
- boomboomsubban 6y agoI was confused as like you said Bluetooth voice quality is fairly universal. There is a patch to enable faststream in pulseaudio, but it sounds like very few adapters support it
- WesolyKubeczek 6y agoI’m using shairport-sync for that.
- rektide 6y agoAnother one of the Linux projects that the cranky contakerous pissy segment of the FOSS world just loves to spit on & hate, PulseAudio. The FUD keeps coming from within the FOSS world itself. But I keep seeing stuff like this, & thinking, this is such a flexible powerful tokit, pulseaudio- why are so few haters willing or capable of acknowledging that pulse does have serious upsides & vast intermixable capabilities? Maybe it's just me but I feel le Pulse Audio is another one of those epic works that is ceaselessly pointlessly shat upon while no one has anything remotely comparable. Also though still eager as heck to replace it all & this use case (a frigging awesome ubicomp style use case) with PipeWire. Zeeeerrrooop ccoopppyyyy (to the tune of leroy jenkins).
- chmln 6y agoI think it's a small but very loud minority that hates on systemd, pulseaudio, etc. Majority of users, like me, never really comment on those two because they do their job so well - they get out of my way and just work.
- the_pwner224 6y agoNot only do they work, but when you need to advanced stuff it's generally easy & works on the first try. Making loopback devices, combining audio streams and/or redirecting streams, all sorts of wacky stuff. The hardest part is finding a good guide on Google that tells you the right commands/configuration options. Same with systemd.
- mixmastamyk 6y agoPA at least was full of bugs on arrival ten+ years ago. That's what started the fight. Poor response to criticism fueled it. In short, don't replace working code with new until it is at least as good. While new stuff needs testing, folks react strongly when it lands on production systems.
- chmln 6y agoThat's definitely true as well - some responses by poettering in systemd issues in particular are unnecessarily condescending and very unprofessional. Also, while systemd and pulseaudio were heavily pushed by many distros, alsa was and still is an option and systemd alternatives exist for those who care that much.
- AdmiralAsshat 6y agoWon't the quality of the audio over Bluetooth be incredibly compressed, though?
- deathanatos 6y agoBluetooth audio generally uses one of two "profiles"; there's A2DP, and generally sounds fine. I've not noticed the compression. A2DP is one-way, audio output only. There's also HSP, which is two-way (mic+headphones, essentially), and it sounds like a potato.¹ (I have no idea why this is, either. My brother once "solved" the quality issues of HSP by getting a second headset, putting both headsets on his head, putting one in HSP and using the mic from that one, and putting the other in A2DP. It worked fine, aside from it wasn't comfortable and it looked ridiculous. He was on Windows, but I have the same issues in Linux and OS X.)
- esaym 6y agoShort answer is no. I'm not really sure why so many try to hate on bluetooth audio. But don't take my word for it, hear for yourself. You can first read up some on it[0] Then get the needed tools to encode audio into the exact same format that your headphones would see [1] Hopefully, you have an uncompressed wav file to test with. Unfortunately, the sbcenc command wants the wav in the uncommon big-endian format. Not worries, just do: "ffmpeg -i test.wav test.au" and it will convert it for you. Now feed that .au file into sbcenc: "sbcenc -B 16 -s 8 -j -b 51 test.au >test.sbc" That is the default scheme for "bluetooth high quality". Personally I have not found a difference in the sound. Of course note that the audio encoding is adaptive, so if you put on your bluetooth headphones and walk 50 ft away, yea it might sound bad... [0]: https://en.wikipedia.org/wiki/SBC_(codec) https://en.wikipedia.org/wiki/SBC_(codec) [1]: https://packages.debian.org/buster/sbc-tools https://packages.debian.org/buster/sbc-tools
- jldugger 6y agoSBC is also not the only BT codec; BT headphones often offer direct mp3 support so that there is no extra loss in quality
- brunoqc 6y agoAnyway to do it without bluetooth?
- cheeze 6y agoSure, run a 3.5mm from the phone to the mic port of any motherboard
- stallmanite 6y agoI rue the day they remove audio jacks from desktop motherboards. Presumably to improve water resistance.
- ofou 6y agoIs it possible to stream my phone mic to my laptop with Pulseaudio?
- animex 6y agoI'm confused... I have all my streaming available on my PC via web-browser. Was this created primarily for Linux users?
- diffeomorphism 6y agoThis article is not about the "streaming" you are thinking about. It is about using your PC as wireless speakers, i.e. streaming your phone audio to your PC.
- animex 6y agoBut again... why would I ever do that? I have access to all my services on my PC directly. I'm not aware of any phone-only streaming services?
- diffeomorphism 6y agoWhat does this have to do with streaming? Obvious use case would be: I am sitting on the couch and want some music played on my speakers. Option 1: Get up from the couch, go to PC, put the music on, get back to couch. Listen a bit, change my mind, get up again, change track on pc, get back to couch. Option 2: Have some kind of remote controls for the PC media player on my phone (e.g. mpd). Requires some setup and only for one specific app, but very similar. Option 3: Use phone as normal and as output select the speakers. People commonly do this with bluetooth speakers (which have their own issues) or you instead use wifi as described in the fine article. Your whole question is basically "why would anyone want wireless speakers?".
- yeswecatan 6y agoI've been playing around with mopdiy and it's excellent
- krick 6y agoI still don't really understand Linux audio layers and how all this stuff works together, how do I configure it, and so on. Is there some good manual/blogpost/etc that would explain that?
- justaj 6y agoThere's the ArchWiki, but overall the Linux audio ecosystem is severely under-documented.
- josteink 6y ago> I still don't really understand Linux audio layers and how all this stuff works together My simple understanding is that in the Linux audio stack you have the following layers: - kernel-driver for local sound devices (provides exclusive access, no mixing/multiplexing). - application-level audio-frameworks/APIs which are device-agnostic (pulse, ALSA, jack), can support, mix and multiplex multiple concurrent streams/applications. - these different application-level frameworks can have several different back ends (for real HW, BT, virtual devices, network targets, etc, other Linux application-level audio-frameworks. ) (Someone correct me if I’m wrong) Applications target a framework, but not all target the same, so the frameworks needs to be able to “plug together” so the speak. This leaves the possibility if the following scenario: App written for ALSA -> ALSA -> ALSA’s Pulseaudio backend -> PulseAudio -> Real hardware PulseAudio in particular is very featured, modular and pluggable which is why most desktops Linux distros uses this by default these days. It supports things like transparent network streaming between various kinds of targets and lets you compose “audio graphs” if need to. And that’s probably why it was chosen for the experiment in this blog post.
- marcan_42 6y agoALSA is (confusingly) two things: a userspace library and API, complete with plug-ins and configurability and even mixing, and also the kernel API that underlies it to talk to the physical hardware. So a typical chain ends up being legacy app -> ALSA -> PulseAudio -> ALSA -> kernel, because ALSA both frontends PA for legacy ALSA-only apps to use it, and also backends PA to talk to the real hardware. But ALSA isn't the only backend for PA. For example, Bluetooth audio output will go via BlueZ and into kernel socket APIs instead, since Bluetooth audio is a network protocol, not something handled in the kernel. And then there's FFADO, a userspace driver for FireWire audio devices. And you can put JACK on top of that. And then you can put PulseAudio on top of JACK. Or you can out JACK on top of PulseAudio, but that'd be silly. And PA can go over the network, both from app to a remote PA daemon, and also from PA daemon to PA daemon. And there's also netJACK if you want to put that on a network. And now PipeWire is replacing JACK and PulseAudio and impersonates their APIs and also ALSA and lets everything talk to everything else. Basically it's complicated, but also very flexible. In the end though, there is usually one "default" setup that you get if you don't do anything on a typical distro, and that's, these days, apps -> [ALSA ->] PulseAudio -> {ALSA -> kernel, BlueZ -> kernel} for most typical use cases (native PA apps and ALSA apps, local audio and bluetooth backends).
- Beldin 6y agoI've done the reverse (connecting to bluetooth speaker) out of the box on Ubuntu. So I'm surprised you'd need to install an extra PulseAudio module. Perhaps the BT module was already installed? Or do you only need the BT module to handle input, but output works via the kernel's BT stack?
- danielheath 6y agoOn my ubuntu machine the Bluetooth modules for pulse are installed by default.
- aasasd 6y agoAnything for the other way around, specifically from Mac to Android? Sort of poor man's wireless headphones.
- LeonM 6y agoInteresting. It should certainly be possible to use a little device driver for MacOS that streams all output in some IP stream format. Then use any web radio client of choice on the android device. Latency will be terrible though.
- Gys 6y agoSearch for macos loopback. It is a tool that is part of a collection of tools which might make this possible
- smegma2 6y agoYes! There are a few answers here: https://superuser.com/questions/605445/how-to-stream-my-gnu-linux-audio-output-to-android-devices-over-wi-fi https://superuser.com/questions/605445/how-to-stream-my-gnu-... I'm using the top one and it works well for me.
- zerop 6y agoA friend want to do real time speech to text of phone calls for a call center client. They want to capture the customer side of audio which is listened by customer care agent. How to build the part to extract stream of audio from this call conversation. Once extracted it would be passed to speech to text streaming API to do inference.
- dfg0987098x7 6y agoYou'd process the audio streams in the call center telephony stack (kamilio, asterisk etc)
- avodonosov 6y agoSadly, there is no good way to stream sound over wifi from my android phone to the rock64 connected to amplifier
- sirius87 6y agoYou could probably set the device as a DLNA receiver? https://www.raspberry-pi-geek.com/Archive/2014/08/Using-the-Raspberry-Pi-as-a-DLNA-receiver-for-a-stereo-system https://www.raspberry-pi-geek.com/Archive/2014/08/Using-the-... Edit: https://www.pimusicbox.com/ https://www.pimusicbox.com/
- avodonosov 6y agoI have dlna on the rock64 (volumio), the problem is on android side - there are no tools to capture the sound and stream it to dlna. Custom apps like BubbleUPnP are not satisfying, I want to stream any app sound - chrome, youtube, any
- armagon 6y agoI really wish there was a standard way of streaming audio over LANs that worked between devices (like phones, computers, and smart speakers). Bluetooth is such a pain, IMHO.
- Spivak 6y agoIf you are willing to accept something obscure PulseAudio actually has the best thing. Look into the PulseAudio native module which just let’s you put a speaker on the network as a normal boring sound output that works as if it was connected to your computer. - Install the zeroconf module on both server and clients. - Enable the native module on the server and open the port and tell PA to publish an mDNS record. - See the speaker just appear in your sound options. Play! Actual instructions if you want to set it up https://blogs.gnome.org/ignatenko/2015/07/31/how-to-set-up-network-audio-server-based-on-pulseaudio-and-auto-discovered-via-avahi/ https://blogs.gnome.org/ignatenko/2015/07/31/how-to-set-up-n...
- microcolonel 6y agoI've done this for years. It works especially well when you have more than one computer, mutually considering eachother their default output. Playing something in your tmux session on the workstation, but want to go use the laptop in the kitchen? Just move the headphones. I also use it since I brought the office workstation home, along with barrier (synergy fork), to use one set of peripherals for both of my workstations.
- armagon 6y agoThat's pretty cool! I'd actually like to stream from my Mac or a phone to an Alexa Echo Dot. Bluetooth usually works, but not always, and not needing the devices to be in close proximity would be a bonus.
- kylegordon 6y agoI tried that and whilst it works for individual outputs, having it playing synchronised with other speakers was not ideal given the timing discrepancies that appeared.
- cowmix 6y agoThis is all well and good but I still can't get mono output going out of Ubuntu 202004. The audio stack under most distros is still a weird mess.
- miki123211 6y agoThere's also Bluetooth Audio receiver, available in the Windows store for Windows 10 2004 and up, for those who lean that way.