Open TobKra96 opened 3 years ago
I have done this whit pulseaudio server and spotifyd but you can use any audio source like vlc ... what is playing on the pi
then using the pulsemixer MLSC can be hook to source you like to get audio from
i have use the same method whit the LedFX project but and here is working
Wow, this is really cool. Thank you. I will install it on my system and write a small tutorial π
My first test failed. It seems like portaudio and pulseaudio fight against each other π. Pyaudio returned this:
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
I have already tried to uninstall Portaudio, but PyAudio stopped working after this. π Don't worry, I will go into the fight for the next round. π
Have a great day TobKra
I have problem using this on the dev2.2 branch i never manage to get it running but on the master i dont have problem
Ok, thanks for the info. I will check it :)
I was able to get a loopback method working with Librespot (dependency of rasp-tidy) back in September of last year for my longboard before I broke the damn thing haha. (Here: Longboard Lights) And just recently I attempted a different method using BlueAlsa AD2P. I know the BlueAlsa AD2P one doesn't require PulseAudio or PortAudio, the Librespot might have worked with just ALSA too. (tested with RPi 4)
Nice, I will give it a try :)
I got my setup working well and wanted to share... :D
Purpose:
Audio Input Options:
Loopback Tutorial (BlueALSA version):
sudo apt install bluealsa
sudo nano /lib/systemd/system/bluealsa.service
- Change
ExecStart=/usr/bin/bluealsa
toExecStart=/usr/bin/bluealsa -p a2dp-sink
- Save changes
sudo reboot
sudo modprobe snd-aloop
- (optional) set up a systemd service or add it in /etc/rc.local that runs this at boot
sudo nano /etc/asound.conf
- refer to attached asound.conf.txt file (it sets up a multi named both and plays to loopout for MLSC and hw:1,0, the USB soundcard)
sudo apt install expect
- run attached autobt.sh script file (don't forget file permissions)
OR
- or use
bluetoothctl
- Direct Audio Stream to "both" previously setup in asound.conf
- play audio on the device you used to connect to the RPi A2DP
bluealsa-aplay -d both 00:00:00:00:00:00
- (optional) set up a systemd service that runs this at boot
- Start MLSC If Not Running
- change audio input source to whichever corresponds to loopout (not loopin!)
- restart MLSC
DONE!
Notes: I have experienced some issues with the sample rate. Example: PyAudio says loopout's sample rate is 44,100 but MLSC's music effects do not function properly with this sample rate, instead I have found a few random ones when input do. I am using 24000.
Sources Used:
Thanks for everyone's work on this project!
If anyone needs help trying this let me know, and if I made any mistakes or something isn't working just let me know :)
I used this config from https://trac.ffmpeg.org/wiki/Capture/ALSA
Record audio from an application while also routing the audio to an output device
modprobe snd-aloop pcm_substreams=1
# /etc/asound.conf
pcm.multi {
type route;
slave.pcm {
type multi;
slaves.a.pcm "output";
slaves.b.pcm "loopin";
slaves.a.channels 2;
slaves.b.channels 2;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
bindings.3.slave b;
bindings.3.channel 1;
}
ttable.0.0 1;
ttable.1.1 1;
ttable.0.2 1;
ttable.1.3 1;
}
pcm.!default {
type plug
slave.pcm "multi"
}
pcm.output {
type hw
card 0 # Your Output Device Name
}
pcm.loopin {
type plug
slave.pcm "hw:Loopback,0,0"
}
pcm.loopout {
type plug
slave.pcm "hw:Loopback,1,0"
}
The mpg123 and shairport-sync are worked. But MLSC just not working, even it found a list of audio devices. It drives me crazy, does anyone have work way?
I used this config from https://trac.ffmpeg.org/wiki/Capture/ALSA
Record audio from an application while also routing the audio to an output device
modprobe snd-aloop pcm_substreams=1
# /etc/asound.conf pcm.multi { type route; slave.pcm { type multi; slaves.a.pcm "output"; slaves.b.pcm "loopin"; slaves.a.channels 2; slaves.b.channels 2; bindings.0.slave a; bindings.0.channel 0; bindings.1.slave a; bindings.1.channel 1; bindings.2.slave b; bindings.2.channel 0; bindings.3.slave b; bindings.3.channel 1; } ttable.0.0 1; ttable.1.1 1; ttable.0.2 1; ttable.1.3 1; } pcm.!default { type plug slave.pcm "multi" } pcm.output { type hw card 0 # Your Output Device Name } pcm.loopin { type plug slave.pcm "hw:Loopback,0,0" } pcm.loopout { type plug slave.pcm "hw:Loopback,1,0" }
The mpg123 and shairport-sync are worked. But MLSC just not working, even it found a list of audio devices. It drives me crazy, does anyone have work way?
Does it show the loopout or loopin as one of the sources and you are selecting that source for MLSC to use?
I used this config from https://trac.ffmpeg.org/wiki/Capture/ALSA Record audio from an application while also routing the audio to an output device
modprobe snd-aloop pcm_substreams=1
# /etc/asound.conf pcm.multi { type route; slave.pcm { type multi; slaves.a.pcm "output"; slaves.b.pcm "loopin"; slaves.a.channels 2; slaves.b.channels 2; bindings.0.slave a; bindings.0.channel 0; bindings.1.slave a; bindings.1.channel 1; bindings.2.slave b; bindings.2.channel 0; bindings.3.slave b; bindings.3.channel 1; } ttable.0.0 1; ttable.1.1 1; ttable.0.2 1; ttable.1.3 1; } pcm.!default { type plug slave.pcm "multi" } pcm.output { type hw card 0 # Your Output Device Name } pcm.loopin { type plug slave.pcm "hw:Loopback,0,0" } pcm.loopout { type plug slave.pcm "hw:Loopback,1,0" }
The mpg123 and shairport-sync are worked. But MLSC just not working, even it found a list of audio devices. It drives me crazy, does anyone have work way?
Does it show the loopout or loopin as one of the sources and you are selecting that source for MLSC to use?
Ummm... yes.. I tried everyone
@JohnGuan
in my asound.conf I have my loop configured a lil different, worth a try:
pcm.loopin { type plug slave.pcm "plughw:Loopback,0,0" }
pcm.loopout { type plug slave.pcm "plughw:Loopback,1,0" }
@carlyd95 Thank you for your generous answer. In fact, I tried yours. It doesn't work.π I think I may need to re-flash the system. My current system is Raspberry Pi OS Lite. I'm not quite sure if it has any effect, but the PulseAudio solution written in the previous reply seems to be more dependent on the desktop environment.
@JohnGuan weird, mine works just fine using BlueALSA as an A2DP π Iβll have to mess with shairport sometime soon.
Anyone got any ideas on how turn an MLSC pi into a DLNA speaker?
or snapcast snapclient?
or snapcast snapclient?
Snapcast worked when I tried it initially. I dont know if it has support for DLNA though.
Also bluealsa method isnβt as easy with raspberry pi now as it got removed from the official OS. I havenβt got it to work since.
@carlyd95 I've been trying to get snapcast client running but the second I install MLSC, snapcast client stops working.
β snapclient.service - Snapcast client
Loaded: loaded (/lib/systemd/system/snapclient.service; enabled; vendor pr>
Active: failed (Result: exit-code) since Thu 2022-07-07 08:12:00 BST; 3min>
Docs: man:snapclient(1)
Process: 711 ExecStart=/usr/bin/snapclient --logsink=system $SNAPCLIENT_OPT>
Main PID: 711 (code=exited, status=1/FAILURE)
CPU: 190ms
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Scheduled restart j>
Jul 07 08:12:00 raspberrypi systemd[1]: Stopped Snapcast client.
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Start request repea>
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Failed with result >
Jul 07 08:12:00 raspberrypi systemd[1]: Failed to start Snapcast client.
how did you set yours up?
what i did
sudo apt-get update
sudo apt-get upgrade
sudo reboot
I upload snapclient_0.26.0-1_armhf.deb via winscp ran the following commands
sudo apt install vim
sudo dpkg -i snapclient_0.26.0-1_armhf.deb
sudo apt-get -f install
cd /etc/default
sudo vim snapclient
inserted the IP address of the host, save and exit
sudo update-rc.d snapclient defaults
sudo service snapclient status
at this point snapcast was working
then I ran
curl -sSL https://raw.githubusercontent.com/TobKra96/music_led_strip_control/master/setup.sh | sudo bash -s -- -b master
sudo reboot
sudo apt-get -f install
then when I checked snapcast via:
sudo service snapclient status
I got:
β snapclient.service - Snapcast client
Loaded: loaded (/lib/systemd/system/snapclient.service; enabled; vendor pr>
Active: failed (Result: exit-code) since Thu 2022-07-07 08:12:00 BST; 3min>
Docs: man:snapclient(1)
Process: 711 ExecStart=/usr/bin/snapclient --logsink=system $SNAPCLIENT_OPT>
Main PID: 711 (code=exited, status=1/FAILURE)
CPU: 190ms
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Scheduled restart j>
Jul 07 08:12:00 raspberrypi systemd[1]: Stopped Snapcast client.
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Start request repea>
Jul 07 08:12:00 raspberrypi systemd[1]: snapclient.service: Failed with result >
Jul 07 08:12:00 raspberrypi systemd[1]: Failed to start Snapcast client.
Create a Tutorial for a virtual audio input device or a loopback config. Maybe we can use a Spotify connect app like https://github.com/dtcooper/raspotify