haileys / bark

live sync audio streaming for local networks
GNU Affero General Public License v3.0
663 stars 11 forks source link

Integration with moOde audio player #1

Open moodeaudio opened 11 months ago

moodeaudio commented 11 months ago

Hi,

My name is Tim Curtis. I'm the maintainer for the moOde audio player project (a FOSS non-commercial project). It's an MPD based player/streamer for the Raspberry Pi family of SBC's. https://github.com/moode-player https://moodeaudio.org

One of our Forum users mentioned your nice project today https://moodeaudio.org/forum/showthread.php?tid=5734&pid=48016#pid48016 and I wanted to follow up with you to see if you might be interested in discussing integration of your software into moOde.

Currently we are using the TRX Realtime audio over IP toolset to implement our Multiroom Audio feature and it's working ok. It uses Multicast, RTP/UDP, ALSA directly, the Opus CODEC (16/48K) for the audio format and does not support clock sync but rather simply relies on low network latency. It also doesn't support playback on the sending device. The sender reads PCM from the ALSA Loopback device and the Receiver outputs to either ALSA plughw:n,m or hw:n,m device.

Clock sync would be a nice enhancement for us and since you are using raw uncompressed PCM format possibly a way to support native source rates, mostly 16/44.1K but also the usual "HiRes" rates up to 24/192K. Also support for having the sending device also be a receiver.

Regards, -Tim

Here's some additional background info on our solution.

TRX sources

https://github.com/bitkeeper/trx/releases/tag/0.6

TRX launch args

#
# Sender
#
pi@moode:~ $ trx-tx -H
trx 0.6.0
(C) Copyright 2020 Mark Hills <mark@xwax.org>
(C) Copyright 2021 Tim Curtis <tim@moodeaudio.org>

Usage: tx [<parameters>]
Real-time audio transmitter over IP

Audio device (ALSA) parameters:
  -d <dev>    Device name (default 'default')
  -m <ms>     Buffer time (default 16 milliseconds)

Network parameters:
  -h <addr>   IP address to send to (default ::)
  -p <port>   UDP port number (default 1350)

Encoding parameters:
  -r <rate>   Sample rate (default 48000 Hz, see (1) below.)
  -c <n>      Number of channels (default 2)
  -f <n>      Frame size (default 960 samples, see (2) below)
  -b <kbps>   Bitrate (approx., default 128)

Program parameters:
  -v <n>      Verbosity level (default 1)
  -D <file>   Run as a daemon, writing process ID to the given file
  -R <prio>   Realtime priority (default 45)
  -H          Print program help

(1) Sampling rate (-r) of the input signal (Hz) This must be one
of 8000, 12000, 16000, 24000, or 48000.

(2) Allowed frame sizes (-f) are defined by the Opus codec. For example,
at 48000 Hz the permitted values are 120, 240, 480, 960, 1920 or 2880 which
correspond to 2.5, 7.5, 10, 20, 40 or 60 milliseconds respectively.

### From PHP
$cmd = 'trx-tx -d trx_send -h ' . $cfgMultiroom['tx_host'] . ' -p ' . $cfgMultiroom['tx_port'] . ' -m ' . $cfgMultiroom['tx_bfr'] . ' -f ' . $cfgMultiroom['tx_frame_size'] . ' -R ' . $cfgMultiroom['tx_rtprio'] . ' -D /tmp/trx-txpid  >/dev/null';
$result = shell_exec($cmd);

#
# Receiver
#
pi@moode:~ $ trx-rx -H
trx 0.6.0
(C) Copyright 2020 Mark Hills <mark@xwax.org>
(C) Copyright 2021 Tim Curtis <tim@moodeaudio.org>

Usage: rx [<parameters>]
Real-time audio receiver over IP

Audio device (ALSA) parameters:
  -d <dev>    Device name (default 'default')
  -m <ms>     Buffer time (default 16 milliseconds)

Network parameters:
  -h <addr>   IP address to listen on (default ::)
  -p <port>   UDP port number (default 1350)
  -j <ms>     Jitter buffer (default 16 milliseconds)

Encoding parameters (must match sender):
  -r <rate>   Sample rate (default 48000 Hz)
  -c <n>      Number of channels (default 2)
  -f <n>      Frame size (default 960 samples, see (1) below)

Program parameters:
  -v <n>      Verbosity level (default 1)
  -D <file>   Run as a daemon, writing process ID to the given file
  -R <prio>   Realtime priority (default 45)
  -H          Print program help

(1) Allowed frame sizes (-f) are defined by the Opus codec. For example,
at 48000 Hz the permitted values are 120, 240, 480, 960, 1920 or 2880 which
correspond to 2.5, 7.5, 10, 20, 40 or 60 milliseconds respectively.

### From PHP
$cmd = 'trx-rx -d ' . $cfgMultiroom['rx_alsa_output_mode'] . ':' . $_SESSION['cardnum'] . ',0 -h ' . $cfgMultiroom['rx_host'] . ' -p ' . $cfgMultiroom['rx_port'] . ' -m ' . $cfgMultiroom['rx_bfr'] . ' -j ' . $cfgMultiroom['rx_jitter_bfr'] . ' -f ' . $cfgMultiroom['rx_frame_size'] . ' -R ' . $cfgMultiroom['rx_rtprio'] . ' -D /tmp/trx-rxpid  >/dev/null';
$result = shell_exec($cmd);

Multiroom Configuration screen shot

Screenshot 2023-08-21 at 10 17 56 AM

tjengbudi commented 7 months ago

@haileys any plans or future updates to support this?