Testing Sound Cards
- https://www.instructables.com/Test-Sound-Card-and-Speakers-in-Raspberry-Pi/
- https://linuxconfig.org/how-to-test-microphone-with-audio-linux-sound-architecture-alsa
- https://sysplay.in/blog/linux/2019/06/playing-with-alsa-loopback-devices/ Setup Guides
- https://gist.github.com/bmweiner/f80e7aaeca5bcee1db46e56914b415fa Official Docs
- Icecast: https://icecast.org/docs/icecast-2.4.1/basic-setup.html
- Darkice: http://www.darkice.org/
man darkice.cfg
- shairport-sync: https://github.com/mikebrady/shairport-sync/blob/master/INSTALL.md
Create the loopback device:
sudo modprobe snd-aloop
sudo echo "snd-aloop" >> /etc/modules
View sound stuff:
cat /proc/asound/modules
cat /proc/asound/cards
(show sound cards; first number is device id, followed by [DEVICE_NAME ])cat /proc/asound/card1/pcm0p/info
(show info for card 1, device 0, playback)cat /proc/asound/card1/pcm0c/info
(show info for card 1, device 0, capture)aplay -l
show all playback devicesarecord -l
show all capture (recording) devices
Test sound stuff:
speaker-test
sends test noises to playback devices. We can test our loopback
by setting up speaker-test
to play on the loopback's playback device, and
setting arecord
to record from the loopback capture device simultaneously.
First set up arecord to listen to the capture devce for a signed, 16-bit,
little-endian stream at 48000 Hz (speaker test's default) (your device may be
different; use the above notes to determine it):
arecord -f S16_LE -d 10 -r 48000 --device="hw:Loopback,1,0" test-lo.wav
Then start playing a test tone on one channel of the playback device:
speaker-test -Dhw:Loopback,0,0 -c1 -twav
Finally play your recording with aplay
:
aplay test-lo.wav
Later once you've got darkice and icecast2 set up you can use the speaker
test to test those two pieces without shairport by running the test on two
channels at 44100 Hz (use -tsine
because the wav test isn't 44100 Hz):
speaker-test -Dhw:Loopback,0,0 -c2 -tsine -r44100
Installation:
sudo apt install shairport-sync darkice icecast2
Configuration:
- shairport-sync
- Mostly the default config is sufficient?
- For some reason it doesn't start whenever I try to change the
name
in the config'sgeneral
stanza. - set
interpolation
tobasic
insted ofsoxr
if CPU usage is too high. - In the
alsa
config stanza setoutput_device = "hw:Loopback,0,0"
(or whatever you got working withspeaker-test
earlier)
- icecast
- you should probably change the passwords during the installation config.
- "source" is things sending audio to icecast; you'll use this password in the darkice config.
- set up the actual stream in the
<listen-socket>
section- Uncommenting the
<bind-port>
breaks it. I don't know why. - I think you need to uncomment the
<shoutcast-mount>
bit and give it a name. This name is what you put in the darkice config.
- Uncommenting the
- darkice
- Server, port, password, mountPoint, and name under the
[icecast2-0]
stanza have to match the icecast config (what ismountPoint
vsname
?) /etc/darkice.cfg
:
[general] duration = 0 bufferSecs = 1 reconnect = yes realtime = yes rtprio = 3 [input] device = hw:Loopback,1,0 sampleRate = 44100 bitsPerSample = 16 channel = 2 [icecast2-0] bitrateMode = vbr format = mp3 quality = 0.8 server = localhost port = 8000 password = <pwd> mountPoint = sonos name = sonos
/etc/systemd/system/darkice.service
:
[Unit] Description=DarkIce Live audio streamer After=icecast2.service [Service] ExecStart=/usr/bin/darkice [Install] WantedBy=multi-user.target
- Server, port, password, mountPoint, and name under the
Launch, and Start on Reboot:
sudo systemctl daemon-reload # so that it picks up the darkice service we wrote
sudo systemctl start shairport-sync.service
sudo systemctl start icecast2 # this has to start before darkice
sudo systemctl start darkice.service
sudo systemctl enable shairport-sync.service
sudo systemctl enable icecast2
sudo systemctl enable darkice.service
Add the icecast url to sonos: Manage -> Add Radio Station
...use the pi's
IP address (probably should make it static in the router!) and the
port and shoutcast-mount name from the icecast2 config (ex):
http://192.168.1.65/sonos
Instead of (in addition to?) shairport-sync
, do we have somethign that'll do
this via chromcast?