I am running a mopidy based spotify player on a raspberry pi - my goal is to utilise both the onboard analog audio as well as an external USB sound card, with a different set of speakers in different rooms plugged into each, creating a multi room system.
The key is to be able to switch / redirect audio on the fly ie without rebooting, stopping music.
This is the closest I have gotten:
sudo nano /etc/asound.conf
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
change card from 0 (onboard analog) to 1 (external usb)
then
killall -9 mopidy
/opt/startmopidy.sh
This does the job but killing mopidy stops the music (and editing asound.conf doesn't have a high WAF!) but i cant get the setting to take effect without reloading mopidy.
Someone suggested I try Pulse Audio instead of ALSA but before I do want to see if I can find a method using ALSA....suggestions??
ALSA does not allow changing the hardware device without actually opening the other device, which would require support by the application.
You need PulseAudio for that.
Related
I am having issues with Pulseeffects on Pi OS Debian Buster. I am using custom distribution called "Volumio" which is special kind of buster that focus on music and listening to music from more sources (bluetooth, airplay, network drives, local music etc.) I also have GPIO sound card connected in there "HiFiBerry DAC2 Pro"
This Volumio OS has its custom alsa configuration which looks like this:
pcm.!default {
type copy
slave.pcm "volumio"
}
pcm.volumio {
type copy
slave.pcm "volumioOutput"
}
# There is always a plug before the hardware to be safe
pcm.volumioOutput {
type plug
slave.pcm "volumioHw"
}
pcm.volumioHw {
type hw
card "sndrpihifiberry"
}
And here my issue starts. When i launch pulseeffects and i play any music from any source, equalization is not working. In pulseeffects there is something called "apps.monitor" which should monitor which apps are playing something and then automatically start sourcing music from there but it doesnt work. In pulseeffects there are also monitors of outputs like jack or HDMI but those are IDLE, not muted, they just dont "see" the music iam playing. Iam so frustrated from this its been several weeks and iam still trying to solve it or get some help but unsuccessfully.
There is one scenario in which music is being equalized and played how it should be, actually two, but its more like bypassing actual problem. In Shairport-sync (package to have airplay playback from apple devices) you can set in its config file that it should send all audio to PA backed (pulseaudio) and if i do that, then its properly sent to pulseeffects, equalized and played.
Another scenario in which iam able to equalize and play music is when i play locally saved files and i edit MPD.conf to send audio locally (127.0.0.1) over RTP stream and i enable RTP listening in pulseeffects, then it gets there, gets equalized and played.
But these two ways are not how it should work normally. It should either recognize any app (shairport, MPD or others) as an APP which plays music and then source that music from it. And if not then at least monitor of standard 3.5 mm jack should work, i could then set Volumio to play everything through 3.5 Jack, in pulseeffects set input to 3.5 Jack monitor and output to my Hifiberry and it would work but both app.monitor and 3.5 jack monitor are acting like iam not playing anything even though i am playing music.
So what am i doing wrong?
I'm working on a project where a USB audio card is unplugged and plugged arbitrarily from a computer that will be playing sounds. My software should be playing sound as soon as possible right after the card is plugged in.
In order to detect the USB being connected, I'm using libusb's LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED and LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT events, and it works flawlessly. As soon as the device is connected to the USB port, the event is triggered. Same when it's removed.
The problem I'm facing is that there's a time gap between the moment libusb detects the device, and the moment I can actually start working with the device to play sound. I'm using miniaudio to play a sinewave, but the issue is the same using Qt Multimedia, so I'm guessing it has to do with the backend (ALSA).
I've had to place an explicit wait of around 5/6 seconds after the device is detected by libusb to be able to safely open it with miniaudio, but I'd rather not have that magic number right there.
Is there any other way of knowing when the device is ready? I've tried checking udev but it gets activated at the same time as libusb.
I'm trying to connect several bluetooth devices with Raspberry PI to use them as speakers.
I'm using RetroPie as a distribution, because of the tests I've done it's the only one that matches and allows continuous synchronization with several bluetooth devices at the same time.
However, the system only detects the first device that connects as a sound card, the rest keep the bluetooth synchronization active, but it does not interpret them as audio cards even though it is indicated by blueman-manager.
Is there anything I can do to keep all devices synchronized and supported as audio cards?
Palm,
even so this a old post, it is not yet closed.
As I just got the same issue, here my answer.
What you try to do is to connect mutliple audio sreaming services (Speakers) to 1 audio bluetooth source, that is not possible like this. Therefore your PC only connects to the first box.
You could try multiple bluetooth dongles, but then you run into the timing issue with audio stream syncronization between the boxes.
The only solution is to use Bluetooth 4.1 upwards master-slave services.
Therefore the Speakers need to be connected to each other and seen as 1 device from the PC. In that mode the stream is skewed to ensure syncronous playing.
Many new Bluetooth speakers support this mode.
Hope that helped.
I have a bluetooth headset. When connecting it to Windows 10, it installs two profiles in Playback devices list:
Hands-Free. (HSP profile)
Stereo. (A2DP profile)
The Second one (Stereo) is set to be the "Default Device" and the "Default Communication Device" on the system.
When I start any program that uses the mic (recorder, chat, VoIP Calls, gaming, etc.) The sound suddenly stops working And I can only use the mic until I stop the recorder or the call.
To enable the sound again I need to make the Hands-Free (HSP) profile handle both input and output (sound and mic). Unfortunately, HSP gives really poor sound quality.
I want to know If there is a way, using code, I can change Bluetooth behavior so the two profiles work simultaneously. One handles the sound and one handles the mic so I can have high quality sound and use the mic at the same time.
You will probably never find a solution. I had the same problem (I was trying to create a walkie talkie with 2 headsets connected to the same smartphone).
On Windows (but also on Android) you can't access directly to a BT-microphone or BT-speaker because it is automatically detected as BT headset and the OS take the control of the device.
Your app can then access the OS-device and not directly the hardware device. The only OS able to do that was Symbian I think which had the most BT-protocols. On Windows you will probably never be able to do that and on Android you have to write your own A2DP-protocol if you want to access the device directly without OS interference.
So sad...
Luckily, under windows you can define different devices for communications and sound.
So, you have two choices:
Choosing Hands-free for both mic/speaker only for communication (which will switch back to A2DP after the call/teams).
Choosing another mic for communication which allow you to still use the speaker profile even in communication.
That is a bluetooth restriction : A2DP (high quality audio) cannot be use simultaneously with HFP (hands-free profile)
Is there a way to change flash players audio output device? if not, is there a swf player who has this possibility? Thanks!
I had an issue until a few minutes ago regarding this.
Two audio devices are available to my XP box: an iMic USB audio I/O device, in which I have permanently plugged my desktop speakers; and a pair of USB headphones with microphone that I plug in occasionally.
The USB headset would take precedence over the USB iMic for applications because apps appear to access the last device plugged in to a USB port. With this in mind, here was my issue:
I would be listening to some Internettings on my USB headset.
Later, I would want to use my desktop speakers for the Internettings.
This entailed unplugging my headset, shutting down Firefox and opening it up again. Because the desktop speakers are considered the most recently plugged in device, they would be default for plugins.
This is damned annoying, I said to myself, and decided a little hacker mode was in order.
Keeping Firefox open, I used Task Manager to kill the "plugin-container.exe" process. This showed a crash screen on any Flash Player applet in Firefox. Then I unplug the headset, and reload the Web page with the applet. Without restarting Firefox, Flash will then play through my desktop speakers.
If I wish to listen on the headset again, I plug the headset in, kill plugin-container.exe, and reload the page. Wham.
For as rare as I intend to switch audio devices, this will cover up part of the mess Adobe left.
I am 99% sure that setting the audio device used by the flash player is something you would need to do on an OS level. You can change the device that flash uses for microphone and video input from the player's settings, but I don't think you can change audio output.
I have found a solution, at least for the Firefox browser, to direct HTML5 audio to a specific audio device:
https://addons.mozilla.org/en-US/firefox/addon/chaudev/
Note: this is a new Firefox addon waiting to be reviewed developed by a friend of mine.
I have been waiting for this for years.
I wanted to use this when my wife is seeing YouTube on her Chrome browser and me seeing anything like Coursera online MOOC lectures (FF) on the TV which is connected to the pc. I wanted to hear my classes on the headset and my wife on the speakers for YouTube.
I have 2 mouses (one for me, wireless) and have installed a neat program called TeamPlayer which gives multiple cursors (each cursor for each mouse).
So I have now literally the capability of 2 persons working on 1 pc.
And on top of that it works seamlessly with "Enounce Myspeed" for speeding up the video lectures' playback.