|
1 | | ---- |
2 | | -# 🎶 Network Audio Receiver (UDP) for Raspberry Pi |
| 1 | + # 🎶 Network Audio Receiver and Sender (UDP) for Raspberry Pi |
| 2 | + |
| 3 | +A lightweight UDP stereo audio receiver together with an FFmpeg-based sender frontend for Raspberry Pi. |
3 | 4 |
|
4 | | -A lightweight **UDP stereo audio receiver** for Raspberry Pi. |
5 | | -- Lightweight UDP stereo audio receiver for Raspberry Pi with very low latency via ALSA and PipeWire. Developed in Free Pascal on Debian Bookworm and Trixie. |
6 | | -- It outputs directly to **ALSA** (also compatible with **PipeWire** via ALSA emulation). |
7 | | -- Ideal for real-time monitoring and live audio. |
| 5 | +* Ultra-low latency audio streaming over UDP |
| 6 | +* Direct ALSA output with PipeWire compatibility via ALSA emulation |
| 7 | +* Developed in Free Pascal using Codetyphon |
| 8 | +* Tested on Debian Bookworm and Debian Trixie |
| 9 | +* Ideal for real-time monitoring, live audio, and low-latency streaming setups |
8 | 10 |
|
9 | 11 | --- |
10 | 12 |
|
11 | 13 | ## ✨ Features |
12 | 14 |
|
13 | | -* Receives **stereo audio over UDP** (e.g., RTP stream) with selectable audio output: 3.5 mm jack, HDMI, USB, and more (choose one device at a time) |
14 | | -* Direct **ALSA audio output** for minimal delay |
15 | | -* Fully compatible with **PipeWire** via ALSA emulation |
16 | | -* Developed in **Free Pascal** using **Codetyphon** on **Debian Bookworm and Debian Trixie** |
17 | | -* **No codec** → uncompressed audio, maximum quality, minimal processing delay |
18 | | -* Supports multiple audio outputs: **3.5 mm jack, HDMI, USB, and more** (selectable in settings) |
19 | | -* On startup, the window is visible |
20 | | -* If the “Start Minimized” checkbox is selected, the application will start minimized |
21 | | -* **Lightweight** with minimal dependencies (ALSA or PipeWire via ALSA) |
| 15 | +* Receives stereo audio over UDP with selectable audio outputs such as 3.5 mm jack, HDMI, USB audio, and more |
| 16 | +* Supports both multicast and unicast (singlecast) |
| 17 | +* Default multicast settings work out of the box in almost any local network |
| 18 | +* FFmpeg sender frontend included |
| 19 | +* Direct ALSA audio output for minimal delay |
| 20 | +* Fully compatible with PipeWire via ALSA emulation |
| 21 | +* Uncompressed audio for maximum quality and minimal processing delay |
| 22 | +* Lightweight with minimal dependencies |
| 23 | +* Developed in Free Pascal using Codetyphon |
| 24 | +* Window is visible on startup |
| 25 | +* Optional “Start Minimized” mode |
| 26 | +* Supports multiple audio devices with individual settings |
22 | 27 |
|
23 | 28 | --- |
24 | 29 |
|
25 | | -⚡ Ultra-Low Latency Audio Streaming |
26 | | - |
27 | | -This project is optimized for extremely low end-to-end latency — achieving sub-7 ms audio transmission over network. |
| 30 | +## ⚡ Ultra-Low Latency Audio Streaming |
28 | 31 |
|
29 | | -By tuning FFmpeg RTP packet size from the default 1472 bytes down to 736 bytes, latency is significantly reduced across the entire pipeline: |
| 32 | +This project is optimized for extremely low end-to-end latency and can achieve less than 7 ms total audio delay over the network. |
30 | 33 |
|
31 | | -🚀 ~3.9 ms sender latency |
32 | | -🌐 ~0.5 ms network latency |
33 | | -🎧 ~2.5 ms receiver latency |
| 34 | +By reducing the FFmpeg RTP packet size from the default 1472 bytes to 736 bytes, latency is significantly reduced across the entire transmission path. |
34 | 35 |
|
35 | | -👉 Total latency: < 7 ms |
| 36 | +* 🚀 Sender latency: approximately 3.9 ms |
| 37 | +* 🌐 Network latency: approximately 0.5 ms |
| 38 | +* 🎧 Receiver latency: approximately 2.5 ms |
36 | 39 |
|
37 | | -🔊 Real-World Comparison |
| 40 | +👉 Total latency: less than 7 ms |
38 | 41 |
|
39 | | -That’s roughly the same delay as standing just ~2.5 meters away from a speaker — effectively real-time audio. |
| 42 | +### 🔊 Real-World Comparison |
40 | 43 |
|
41 | | -💡 Designed for Performance |
42 | | -Buffer and delay values are displayed in milliseconds (ms) for intuitive monitoring |
43 | | -Optimized for low-latency ALSA playback |
44 | | -Smaller packets = faster delivery (with minimal overhead trade-off) |
| 44 | +This is roughly the same delay as standing about 2.5 meters away from a speaker. |
45 | 45 |
|
| 46 | +### 💡 Designed for Performance |
46 | 47 |
|
| 48 | +* Buffer and delay values are displayed in milliseconds for easier monitoring |
| 49 | +* Optimized for low-latency ALSA playback |
| 50 | +* Smaller packets improve response time with only minimal protocol overhead |
47 | 51 |
|
| 52 | +--- |
48 | 53 |
|
49 | 54 | ## 💡 Example Test Setup |
50 | 55 |
|
51 | | -* **Sender**: Raspberry Pi 5 connected via Wlan streaming audio over UDP |
52 | | -* **Receiver**: Raspberry Pi 4 connected via Ethernet |
53 | | -* **Output**: 3.5 mm jack → HiFi amplifier, or HDMI/USB audio |
| 56 | +* Sender: Raspberry Pi 5 connected via Wi-Fi streaming audio over UDP |
| 57 | +* Receiver: Raspberry Pi 4 connected via Ethernet |
| 58 | +* Output: 3.5 mm jack to HiFi amplifier, HDMI audio, or USB audio |
54 | 59 |
|
55 | 60 | Result: Stable low-latency playback on a typical home network, even while streaming video. |
56 | 61 |
|
57 | 62 | --- |
58 | 63 |
|
59 | | -## ▶️ Usage |
| 64 | +## 📦 Downloads |
60 | 65 |
|
61 | | -### 📤 Sender (System Audio) |
| 66 | +Downloads are available from: |
62 | 67 |
|
63 | | -Install `ffmpeg`: |
| 68 | +* [https://sourceforge.net/projects/raspberry-udp-audio-receiver/](https://sourceforge.net/projects/raspberry-udp-audio-receiver/) |
| 69 | +* [https://github.com/RaspberryFpc/Raspberry-UDP_audio_receiver/](https://github.com/RaspberryFpc/Raspberry-UDP_audio_receiver/) |
64 | 70 |
|
65 | | -```bash |
66 | | -sudo apt install ffmpeg |
67 | | -``` |
| 71 | +--- |
| 72 | + |
| 73 | +## 📥 Installation |
68 | 74 |
|
69 | | -To transmit system audio, use the provided startup script **ffmpeg_transmitter.sh**: |
| 75 | +Use the provided `.deb` packages from the `bin` directory. |
70 | 76 |
|
71 | | -1. Edit the script and replace the IP address with the address of your receiver. |
72 | | -2. Set the port number to match the configuration on the receiver. |
73 | | -3. Make the script executable: |
| 77 | +Install the player: |
74 | 78 |
|
75 | 79 | ```bash |
76 | | -chmod +x ffmpeg_transmitter.sh |
| 80 | +sudo apt install ./udp-player.deb |
77 | 81 | ``` |
78 | 82 |
|
79 | | -4. Save the file, place it on the desktop, and start it with a double-click. |
80 | | - |
81 | | -### 📥 Receiver |
82 | | - |
83 | | -Start the player: |
| 83 | +Install the sender: |
84 | 84 |
|
85 | 85 | ```bash |
86 | | -sudo ./udp_player |
87 | | -``` |
88 | | -- If the receiver is **installed via the provided `.deb` package**, it can also be started conveniently via the system menu. |
89 | | -- In this case the player **does not require sudo**, as the necessary capabilities (`cap_net_raw,cap_sys_nice+ep`) are set during installation. |
90 | | -- On first start, it will create a **configuration file** at: |
91 | | - |
92 | | -``` |
93 | | -/var/lib/udp_player/udp_player.conf |
| 86 | +sudo apt install ./udp-sender.deb |
94 | 87 | ``` |
95 | 88 |
|
96 | | -- A window appears and starts playback automatically. |
97 | | -- Select the desired audio output in the settings window. |
98 | | -- Repeats the last valid audio block up to five times if new data is missing, preventing audible dropouts. |
99 | | - |
100 | 89 | --- |
101 | 90 |
|
102 | | -## ⚙️ Settings Description |
103 | | - |
104 | | -Control / Field | Description |
105 | | ---- | --- |
106 | | -**Audio Output Selection** | Choose the audio output device (Headphones/JACK, HDMI, USB audio, etc.). If no configuration exists for a device, a default configuration is created automatically at first start. |
107 | | -**IP** | IP address to receive audio from. Use `0.0.0.0` to listen on all network interfaces. |
108 | | -**Port** | UDP port for incoming audio. Default is `5010`. |
109 | | -**Frequency** | Audio sample rate in Hz. |
110 | | -**Latency** | Audio latency in samples. Typical values: 22000 for JACK/Headphones, 4000 for USB audio. |
111 | | -**Swap Byte Order** | Enable this if the incoming audio uses a different byte order (big/little endian). |
112 | | -**Hide Window** | If enabled, the application window remains minimized or hidden once audio starts. |
113 | | -**Test changes** | This button immediately applies the current settings without saving them. |
114 | | -**Save changes** | This button saves the current settings to the configuration file for future use. |
115 | | -**Delete Device** | This button deletes the selected device configuration. If the device exists, it will be recreated with default values at the next program start. |
| 91 | +## ▶️ Usage |
116 | 92 |
|
117 | | ---- |
| 93 | +### ▶️ Start the Player |
118 | 94 |
|
119 | | -## 🎯 Latency Optimization |
| 95 | +Start the player using the desktop menu entry created during installation. |
120 | 96 |
|
121 | | -* **Lower buffer size** → lower delay |
122 | | -* **Too low** → possible dropouts or crackling audio |
123 | | -* Best settings depend on: |
124 | | - * Network type (**LAN** allows lower latency than Wi-Fi) |
125 | | - * Raspberry Pi performance |
126 | | - * Audio hardware |
| 97 | +### 📤 Sender |
127 | 98 |
|
128 | | ---- |
| 99 | +Start the sender using the desktop menu entry. |
129 | 100 |
|
130 | | -## 🔊 Audio Volume |
| 101 | +In the sender settings, you can configure: |
131 | 102 |
|
132 | | -If sound is too quiet: |
| 103 | +* Audio source |
| 104 | +* Destination IP address |
| 105 | +* UDP port |
133 | 106 |
|
134 | | -```bash |
135 | | -alsamixer |
136 | | -``` |
| 107 | +Default multicast address: |
137 | 108 |
|
138 | | -* Press `F6` to select the right device |
139 | | -* Raise the **Master** volume |
140 | | - |
141 | | -Or via terminal: |
142 | | - |
143 | | -```bash |
144 | | -amixer set 'Master' 100% unmute |
| 109 | +```text |
| 110 | +239.255.0.1 |
145 | 111 | ``` |
146 | 112 |
|
147 | | ---- |
148 | | -# 📦 Installation / Deinstallation via dpkg |
149 | | - |
150 | | -## Installation Steps |
| 113 | +For multicast, use an address in the range: |
151 | 114 |
|
152 | | -1. Copy the `.deb` package to your Raspberry Pi. |
| 115 | +```text |
| 116 | +224.0.0.0 – 239.255.255.255 |
| 117 | +``` |
153 | 118 |
|
154 | | -2. Install the package: |
| 119 | +For unicast (singlecast), use a free IPv4 address in your local network. |
155 | 120 |
|
156 | | -```bash |
157 | | -sudo dpkg -i udp_player_x.y.z.deb |
158 | | -``` |
| 121 | +--- |
159 | 122 |
|
160 | | -This will install: |
| 123 | +## ⚙️ Player Settings Description |
| 124 | + |
| 125 | +| Control / Field | Description | |
| 126 | +| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 127 | +| Audio Output Selection | Select the audio output device such as headphones, HDMI, or USB audio. If no configuration exists, a default configuration is created automatically. | |
| 128 | +| IP | IP address to receive audio from. Use `0.0.0.0` to listen on all network interfaces. | |
| 129 | +| Port | UDP port for incoming audio. Default: `5010` | |
| 130 | +| Frequency | Audio sample rate in Hz | |
| 131 | +| Latency | Audio latency in samples. Typical values: `22000` for headphone output and `4000` for USB audio | |
| 132 | +| Swap Byte Order | Enable this if the incoming audio stream uses a different byte order | |
| 133 | +| Hide Window | If enabled, the application window is minimized or hidden after audio playback starts | |
| 134 | +| Test Changes | Applies the current settings immediately without saving | |
| 135 | +| Save Changes | Saves the current settings to the configuration file | |
| 136 | +| Delete Device | Deletes the selected device configuration. Missing configurations are recreated automatically at the next start | |
161 | 137 |
|
162 | | -``` |
163 | | -/usr/bin/udp_player # Binary |
164 | | -/usr/share/applications/... # Desktop menu entry |
165 | | -~/.udp_player/ # Config folder (empty on first start) |
166 | | -``` |
| 138 | +--- |
167 | 139 |
|
168 | | -Necessary capabilities are automatically set (`cap_net_raw,cap_sys_nice+ep`) → no sudo required for running the player. |
| 140 | +## 🎯 Latency Optimization |
169 | 141 |
|
170 | | -3. Start the player: |
| 142 | +* Lower buffer sizes reduce delay |
| 143 | +* Too low values may cause dropouts or crackling audio |
| 144 | +* Best values depend on: |
171 | 145 |
|
172 | | -```bash |
173 | | -udp_player |
174 | | -or use the menu entry created during installation. |
175 | | -``` |
| 146 | + * Network type (LAN is usually faster than Wi-Fi) |
| 147 | + * Raspberry Pi performance |
| 148 | + * Audio hardware |
176 | 149 |
|
177 | 150 | --- |
178 | 151 |
|
179 | | -## Deinstallation Steps |
180 | | - |
181 | | -To remove the player completely: |
| 152 | +## 🔊 Audio Volume |
182 | 153 |
|
183 | | -```bash |
184 | | -sudo dpkg -r udp_player |
185 | | -``` |
| 154 | +If the sound is too quiet, increase the volume in the player settings. |
186 | 155 |
|
187 | | -This removes the binary and the menu entry. |
| 156 | +--- |
188 | 157 |
|
189 | | -To also remove the config folder (if you want a clean uninstall): |
| 158 | +## 📦 Deinstallation |
190 | 159 |
|
191 | 160 | ```bash |
192 | | -rm -rf ~/.udp_player |
| 161 | +sudo apt purge udp-player |
| 162 | +sudo apt purge udp-sender |
193 | 163 | ``` |
194 | 164 |
|
| 165 | +--- |
195 | 166 |
|
196 | 167 | ## 📜 License |
197 | 168 |
|
198 | | -This project is licensed under the **MIT License**. |
| 169 | +This project is licensed under the MIT License. |
199 | 170 |
|
200 | 171 | --- |
201 | 172 |
|
202 | 173 | ## 🌐 Other Projects by the Author |
203 | 174 |
|
204 | | -* [pibackup](https://github.com/RaspberryFpc/pibackup) – Portable live backup and restore tool with GUI, Zstandard compression, auto-shrinking (resize2fs) and flexible restore options. |
205 | | -* [DS18B20-FPC-Pi-GUI](https://github.com/RaspberryFpc/DS18B20-FPC-Pi-GUI) – GUI tool to read DS18B20 temperature sensors with linearization for high accuracy. |
206 | | -* [RaspberryPi-BME280-GUI](https://github.com/RaspberryFpc/RaspberryPi-BME280-GUI) – Complete GUI application for accessing the BME280 I²C sensor using Free Pascal. |
207 | | -* [RaspberryPi-GPIOv2-FPC](https://github.com/RaspberryFpc/RaspberryPi-GPIOv2-FPC) – Simple and fast Pascal unit for controlling GPIO pins via the Linux GPIO character device interface. |
| 175 | +* [pibackup](https://github.com/RaspberryFpc/pibackup) – Portable live backup and restore tool with GUI, Zstandard compression, auto-shrinking and flexible restore options. |
| 176 | +* [DS18B20-FPC-Pi-GUI](https://github.com/RaspberryFpc/DS18B20-FPC-Pi-GUI) – GUI tool for reading DS18B20 temperature sensors with linearization for high accuracy. |
| 177 | +* [RaspberryPi-BME280-GUI](https://github.com/RaspberryFpc/RaspberryPi-BME280-GUI) – GUI application for accessing the BME280 I²C sensor using Free Pascal. |
| 178 | +* [RaspberryPi-GPIOv2-FPC](https://github.com/RaspberryFpc/RaspberryPi-GPIOv2-FPC) – Fast Pascal unit for controlling GPIO pins via the Linux GPIO character device interface. |
0 commit comments