Spacesound: Difference between revisions

From NURDspace
(Created page with "=== Info === Audio VM running Snapcast. All audio related stuff for the space happens here, such as MPD, the soundboard etc. However, due to the nature of Snapcast there is a...")
 
No edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=== Info ===


Audio VM running Snapcast. All audio related stuff for the space happens here, such as MPD, the soundboard etc. However, due to the nature of Snapcast there is a artifical delay introduced to keep all the clients in-sync. As such, audio visualisation such as LedFX would still be running on Slabpi to provide a low-latency audio RGB-barfing experience in zaal 1.
{{Inventory
|Name=Spacesound
|Owner=Space
|Status=Infra
|Hostname=spacesound.vm.nurd.space
|Location=rack
|Picture=spacesound.jpg
|Tool=No
}}


Under the hood, Snapcast provides a FIFO under <code>/tmp/snapfifo</code> where you can dump audio. Pulseaudio for example is configured to send audio to this fifo. We are still running Pulseaudio under the hood, to provide an interface for multiple audio programs to run at once.
=== Info ===
 
=== Notes ===
 
* Disabled protected fifos <code>sudo sysctl fs.protected_fifos=0</code> (Set in <code>sysctl.conf</code>)
* Added user nurds to the group pulse
* Added user pulse to the group snapserver <code>usermod -aG snapserver pulse</code>
 
==== Config changes ====
 
===== system.pa =====
 
Both <code>native-protocol-tcp</code> and <code>module-native-protocol-unix</code> have been enabled to allow programs to access pulseaudio. Without the latter line for example, everything trying to play audio through pulse gets a access denied. For <code>native-protocol-unix</code> to work, remove the other entries.
 
<pre>load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;10.0.0.0/24 
load-module module-native-protocol-unix auth-anonymous=1</pre>
To make Pulseaudio send audio to snapcast
 
<pre>load-module module-pipe-sink file=/tmp/snapfifo sink_name=Snapcast format=s16le rate=48000
update-sink-proplist Snapcast device.description=Snapcast</pre>
===== client.conf =====


Needed to make clients know where to connect to, because we are running system wide.
Spacesound is a software/hardware infrastructure used to manage and play audio content in the space. It can be used to stream music, provide sound effects, or facilitate other audio-related tasks. Spacesound runs on an Intel NUC and is designed to be customizable, allowing for the integration of different audio sources and configurations to meet specific needs.  


<pre>default-server = 127.0.0.1</pre>
The NUC is responsible for running Snapcast, which manages all audio-related tasks for the space, including MPD, soundboard, and more. However, because Snapcast synchronizes all clients, there is an artificial delay, making it unsuitable for audio visualization such as LedFX. Consequently, Soundfx is utilized for these purposes.
=== Running services ===


* Icecast + Darkice
Spacesound uses Pipewire as its underlying audio infrastructure, providing a First-In-First-Out (FIFO) output for Snapcast. Spacesound is configured to send all it's audio to this FIFO. Additionally, pipewire is used as the mixing interface for multiple audio programs to run simultaneously. This configuration allows Spacesound to provide a seamless and efficient audio management experience for the space. Spacesound is designed to run most of its audio software as a user, rather than as a global service (root). To make this process easier, an X11 session combined with X11vnc has been put in place, allowing for a more streamlined experience in automatically starting the various audio services. This configuration also enables the use of qpwgraph, which simplifies the process of configuring audio routing. Additionally, if necessary, plugins such as compressors or limiters can be added within the audio chain. Overall, this approach provides more flexibility and control over the audio management process.
* themesongs.service (/home/nurds/scripts)
* espeak-server (/home/nurds/scripts)
* icecast-title (/home/nurds/scripts)


=== Configs ===
Spacesound provides a variety of notable services that make it a powerful and versatile audio management system. These services include:


===== /etc/default/snapserver =====
* Snapcast: a multiroom client-server audio player, where all clients are time synchronized with the server to play perfectly synced audio. It's not a standalone player, but an extension that turns your existing audio player into a Sonos-like multiroom solution.
* MPD (Music Player Daemon): a flexible and customizable music player that supports a wide range of audio formats and can be controlled via various interfaces, including web and mobile.
* Spotify Connect (librespot): an integration with the popular music streaming service that enables users to control their Spotify playback through Spacesound.
* [[Soundboard]]: a feature that allows users to play various pre-recorded sounds, jingles, or effects through Spacesound, providing an interactive and immersive audio experience.
* Icecast Radio Broadcast: a service that enables users to stream audio content over the internet, allowing for the creation and distribution of live or pre-recorded audio broadcasts.


===== snapserver.conf =====
=== Technical information ===
== Specs ==
* NUC6I5SYH
*  Intel Core i5-6260U CPU @ 1.80GHz (Skylake)
* 8GB DDR4
* 128GB SSD


<pre>source = pipe:///tmp/snapfifo?name=default&amp;mode=create 
=== Services ===
As most services run under the user nurds, to edit/start/stop/restart these services you need to use systemctl as <code>systemctl --user</code>


buffer = 100
The following services are suppose to be running:
sampleformat = 48000:16:2
* mpdtube.service (See: [[mpdtube]])
codec = pcm</pre>
* mpd_plugin.service (MPD ghbot plugin)
===== /usr/share/dbus-1/system.d/pulseaudio.conf =====
* testhappy-alsa.service (Some flok thing?)
<pre>
* mpd_icecast_update.service (Allows tthe title to be updated for the radio)
<source lang="xml"><?xml version="1.0"?> <!--*-nxml-*--> 
* spotify.service (Librespotify, for Spotify connect)
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" 
* soundboard.service (See [[soundboard]]
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> 
<busconfig> 
<policy group="pulse"> 
<allow own="org.pulseaudio.Server"/> 
</policy> 
 
<policy context="default"> 
<allow send_destination="org.pulseaudio.Server"/> 
<allow receive_sender="org.pulseaudio.Server"/> 
</policy> 
</busconfig></pre>


===== /etc/systemd/system/pulseaudio.service =====
=== Stutters? ===
<pre>
Spacesound is a complicated system, and there are various services at play that might need to be tweaked to allow for a stutter-free experience. It can also depend on the snapcast client, the network or other issues.  
</source>
== Snapcast ==
[Unit]<br />
For snapcast, one can try to tweak some latency settings in the config located at <code>/etc/snapserver.conf</code>
Description=PulseAudio Daemon
To provide a low latency experience but a stutter-free experience both chunk_ms and buffer can be tweaked.


[Install]<br />
== Pipewire ==
WantedBy=multi-user.target
For pipewire, one can try to tweak settings in <code>/etc/wireplumber/wireplumber.conf</code> the settings that can be adjusted are the settings for <code>libpipewire-module-rt</code>  see https://docs.pipewire.org/page_module_rt.html


[Service]<br />
== Radio Stream ==
Type=simple<br />
Due to issues with introduced when using pulseaudio together with snapcast and darkice, darkice has been switched to running in a docker container on docker.vm.nurd.space. It's a container that runs darkice + snapcast and pulseaudio. Two instances are running, one for 320Kbps mp3 and one for the lower quality stream.
ExecStart=/usr/bin/pulseaudio –system –realtime –disallow-exit –no-cpu-limit


<pre>
=== Legacy ===
Spacesound was previously running on a Raspberry Pi 4, but due to unforeseen member issues, the Pi4 was moved to the ledticker. We attempted to run Spacesound on a Raspberry Pi 3B, but it lacked the necessary performance, resulting in terrible stutters. Consequently, we chose to use a NUC to run the Spacesound infrastructure. The hostname for Spacesound is spacesound.vm.nurd.space as initially Spacesound started as a VM/LXC running on [[Coherence]], but as stutters persisted, it was moved to hardware.  See also [[SlabPi]]


- OS: Ubuntu 20.01 LTS
=== Future===
</pre>
== Video streaming ==
With the increased processing power of Spacesound, the team is exploring the possibility of adding video streaming capabilities to the infrastructure. The plan is to use OBS (Open Broadcaster Software) in combination with NDIS to enable the streaming of videos. This setup would allow audio to be handled by Spacesound and pushed through Snapcast while the video is streamed to monitors throughout the space


==== Installed ====
== Bluetooth streaming ==
<pre>
== Line input ==
apt-get install alsa-utils alsa-tools mpc mpd ncmpcpp pamix nfs-common mplayer pulseaudio espeak </pre>
== Studio to Spacesound==

Latest revision as of 16:41, 26 February 2023


Spacesound
Spacesound.jpg
Owner Space
Status Infra
Hostname spacesound.vm.nurd.space
Location rack
Tool No
Tool category

Spacesound

spacesound.jpg {{{InventoryOwner}}}Property "Tool Owner" (as page type) with input value "{{{InventoryOwner}}}" contains invalid characters or is incomplete and therefore can cause unexpected results during a query or annotation process. rack

Info

Spacesound is a software/hardware infrastructure used to manage and play audio content in the space. It can be used to stream music, provide sound effects, or facilitate other audio-related tasks. Spacesound runs on an Intel NUC and is designed to be customizable, allowing for the integration of different audio sources and configurations to meet specific needs.

The NUC is responsible for running Snapcast, which manages all audio-related tasks for the space, including MPD, soundboard, and more. However, because Snapcast synchronizes all clients, there is an artificial delay, making it unsuitable for audio visualization such as LedFX. Consequently, Soundfx is utilized for these purposes.

Spacesound uses Pipewire as its underlying audio infrastructure, providing a First-In-First-Out (FIFO) output for Snapcast. Spacesound is configured to send all it's audio to this FIFO. Additionally, pipewire is used as the mixing interface for multiple audio programs to run simultaneously. This configuration allows Spacesound to provide a seamless and efficient audio management experience for the space. Spacesound is designed to run most of its audio software as a user, rather than as a global service (root). To make this process easier, an X11 session combined with X11vnc has been put in place, allowing for a more streamlined experience in automatically starting the various audio services. This configuration also enables the use of qpwgraph, which simplifies the process of configuring audio routing. Additionally, if necessary, plugins such as compressors or limiters can be added within the audio chain. Overall, this approach provides more flexibility and control over the audio management process.

Spacesound provides a variety of notable services that make it a powerful and versatile audio management system. These services include:

  • Snapcast: a multiroom client-server audio player, where all clients are time synchronized with the server to play perfectly synced audio. It's not a standalone player, but an extension that turns your existing audio player into a Sonos-like multiroom solution.
  • MPD (Music Player Daemon): a flexible and customizable music player that supports a wide range of audio formats and can be controlled via various interfaces, including web and mobile.
  • Spotify Connect (librespot): an integration with the popular music streaming service that enables users to control their Spotify playback through Spacesound.
  • Soundboard: a feature that allows users to play various pre-recorded sounds, jingles, or effects through Spacesound, providing an interactive and immersive audio experience.
  • Icecast Radio Broadcast: a service that enables users to stream audio content over the internet, allowing for the creation and distribution of live or pre-recorded audio broadcasts.

Technical information

Specs

  • NUC6I5SYH
  • Intel Core i5-6260U CPU @ 1.80GHz (Skylake)
  • 8GB DDR4
  • 128GB SSD

Services

As most services run under the user nurds, to edit/start/stop/restart these services you need to use systemctl as systemctl --user

The following services are suppose to be running:

  • mpdtube.service (See: mpdtube)
  • mpd_plugin.service (MPD ghbot plugin)
  • testhappy-alsa.service (Some flok thing?)
  • mpd_icecast_update.service (Allows tthe title to be updated for the radio)
  • spotify.service (Librespotify, for Spotify connect)
  • soundboard.service (See soundboard

Stutters?

Spacesound is a complicated system, and there are various services at play that might need to be tweaked to allow for a stutter-free experience. It can also depend on the snapcast client, the network or other issues.

Snapcast

For snapcast, one can try to tweak some latency settings in the config located at /etc/snapserver.conf To provide a low latency experience but a stutter-free experience both chunk_ms and buffer can be tweaked.

Pipewire

For pipewire, one can try to tweak settings in /etc/wireplumber/wireplumber.conf the settings that can be adjusted are the settings for libpipewire-module-rt see https://docs.pipewire.org/page_module_rt.html

Radio Stream

Due to issues with introduced when using pulseaudio together with snapcast and darkice, darkice has been switched to running in a docker container on docker.vm.nurd.space. It's a container that runs darkice + snapcast and pulseaudio. Two instances are running, one for 320Kbps mp3 and one for the lower quality stream.

Legacy

Spacesound was previously running on a Raspberry Pi 4, but due to unforeseen member issues, the Pi4 was moved to the ledticker. We attempted to run Spacesound on a Raspberry Pi 3B, but it lacked the necessary performance, resulting in terrible stutters. Consequently, we chose to use a NUC to run the Spacesound infrastructure. The hostname for Spacesound is spacesound.vm.nurd.space as initially Spacesound started as a VM/LXC running on Coherence, but as stutters persisted, it was moved to hardware. See also SlabPi

Future

Video streaming

With the increased processing power of Spacesound, the team is exploring the possibility of adding video streaming capabilities to the infrastructure. The plan is to use OBS (Open Broadcaster Software) in combination with NDIS to enable the streaming of videos. This setup would allow audio to be handled by Spacesound and pushed through Snapcast while the video is streamed to monitors throughout the space

Bluetooth streaming

Line input

Studio to Spacesound