GithubHelp home page GithubHelp logo

ogmkp / bark Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haileys/bark

1.0 0.0 0.0 391 KB

live sync audio streaming for local networks

License: GNU Affero General Public License v3.0

Rust 100.00%

bark's Introduction

bark!

low latency multi-receiver synchronised audio streaming for local networks.

  • Transmits uncompressed 48khz stereo audio over UDP multicast

  • Built-in time synchronisation and latency detection - no high precision NTP required!

  • Adjusts audio playback rate with the Speex resampler to stay in sync

Running the server under Pipewire or Pulse

Note: if using Pipewire, you must have pipewire-alsa installed for this to work.

  • First create a virtual node for Bark to receive audio from. You will configure applications to send audio to this node.

    $ pactl load-module module-null-sink media.class=Audio/Duplex sink_name=Bark audio.position=FL,FR
  • You can list all sources on your system with pactl:

    $ pactl list sources short
    145     Bark    PipeWire        float32le 2ch 48000Hz   SUSPENDED
    3676    alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo.monitor     PipeWire        s32le 2ch 44100Hz       IDLE
    3677    alsa_input.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo      PipeWire        s32le 2ch 44100Hz       SUSPENDED
    3678    alsa_input.usb-046d_Logitech_Webcam_C930e-02.analog-stereo     PipeWire        s16le 2ch 44100Hz       SUSPENDED
  • Run the Bark server passing the name of the sink you created with the --device option:

    $ bark stream --multicast 224.100.100.100:1530 --device Bark

Running the receiver

  • Find the sink you want the receiver to output to:

    $ pactl list sinks short
    145     Bark    PipeWire        float32le 2ch 48000Hz   SUSPENDED
    3676    alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo     PipeWire        s32le 2ch 44100Hz       RUNNING
  • Run the Bark receiver:

    $ bark receive --multicast 224.100.100.100:1530 --device alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo

Configuration

As well as on the command line, Bark's options can be set by environment variable or configuration file. Command line options and their corresponding environment variables are shown in bark --help.

Bark also searches the XDG config directories for a bark.toml configuration file, respecting any custom directories set in XDG_CONFIG_DIRS.

By default, Bark will look in $HOME/.config/bark.toml first, and then /etc/bark.toml. Options set in the configuration file take lowest precedence, are overriden by environment variables, and then finally command line options take highest precedence.

The config file supports all command line options Bark supports. Here's an example:

multicast = "224.100.100.100:1530"

[source]
device = "Bark"
delay_ms = 15

[receive]
device = "alsa_output.usb-Focusrite_Scarlett_Solo_USB-00.analog-stereo"

Monitoring the stream

Run bark stats to see a live view of the state of all Bark receivers.

Four timing fields are shown for each receiver:

  • Audio: The time offset of the audio stream, from when it should be according to the stream presentation timestamp, to when the receiver is actually playing. A positive offset means the receiver is ahead of the stream, a negative offset means the receiver is behind the stream.

  • Buffer: The length of the audio data in the receiver buffer.

  • Network: The one-way packet delay between stream source and receiver. For best sync, this should be as stable as possible.

  • Predict: The offset from the data timestamp in an audio packet (the stream source's time when the packet was sent), to what the receiver thinks the data timestamp should be according to measured clock difference and network latency.

Tuning

The stream source is responsible for setting the delay of the audio stream. The delay wants to be as low as possible without causing receivers to slew or underrun their buffers too much. Receivers will always experience some slewing to keep in sync - the network is not perfectly reliable, and clocks always run at slightly different rates - but ideally slewing should be kept to a minimum to ensure best quality. Keep an eye on bark stats while tuning this value.

The optimal delay value depends on your network, particularly with respect to packet loss and latency stability (receivers connecting wirelessly will need more delay to remain stable than those hard-wired), as well as the latency introduced by sound cards. I've observed that my desktop, which has a USB DAC, consistently tends to have less in its buffer than receivers with PCI DACs.

bark's People

Contributors

haileys avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.