JackTrip Documentation

repository·main·Indexed 21 days ago

https://github.com/jacktrip/jacktrip

A multi-machine audio system for high-quality, uncompressed, bidirectional audio streaming over the Internet for network music performance. Supports cross-platform environments (Linux, macOS, Windows, FreeBSD) and includes documentation for hub server containerization via Podman and Docker, AUv2/AUv3 Audio Bridge plugins for DAWs, and integrated libraries such as oscpp for OSC packet handling and Simple-FFT for Fast Fourier Transforms.

Tokens
22.5K
Snippets
62
Records
116
Agent score
67%

What's inside JackTrip

  1. Overview of JackTrip

    main
    JackTrip is a multi-machine audio system designed for network music performance over the Internet. It enables bidirectional, high-quality, uncompressed audio signal streaming for any number of channels, limited only by the computer and network capabilities. The system is cross-platform and supports heterogeneous environments, meaning machines running different operating systems (e.g., Linux, macOS, Windows, or FreeBSD) can connect to each other.
  2. What is JackTrip?

    main

    JackTrip is a multi-machine audio system designed for network music performance over the Internet. It is cross-platform, supporting Linux, macOS, and Windows.

    Key capabilities include:

    • Bidirectional, high-quality, uncompressed audio signal streaming.
    • Support for an arbitrary number of channels (limited only by hardware and network capacity).
    • Cross-platform interoperability (e.g., a Linux machine can connect to a macOS machine).
  3. What is JackTrip Virtual Studio?

    main

    JackTrip Virtual Studio is an enhanced environment for online musical collaboration. It provides:

    • Live Broadcasting Support: Integration with JackTrip Radio for sharing sessions.
    • Soundscapes DSP: Real-time digital signal processing (DSP) allowing musicians to use audio effects such as reverb, compression, and attack to enhance performances.
  4. Compare JackTrip Hub Server connection types

    main

    The JackTrip Hub Server supports three connection types, each suited for different deployment scenarios:

    1. UDP: Traditional low-latency transport. Requires open firewall ports and port forwarding for NAT traversal. Uses TCP for signaling and UDP for audio.
    2. WebRTC: Browser-compatible connection using WebRTC data channels. Provides excellent NAT traversal via ICE/STUN/TURN. Uses WebSocket over TCP for signaling.
    3. WebTransport: Modern HTTP/3 transport using QUIC. Provides built-in NAT traversal and low latency (0-RTT). Uses a single UDP port (4464) for both signaling and audio.

    All types share the same audio packet format and worker pool allocation mechanism.

    | Feature | UDP | WebRTC | WebTransport |
    |---------|-----|--------|--------------|
    | **Transport** | UDP datagrams | WebRTC data channels over UDP | QUIC datagrams over UDP |
    | **Signaling** | TCP port 4464 | WebSocket over TCP 4464 | HTTP/3 over UDP 4464 |
    | **NAT Traversal** | No | Yes (ICE/STUN/TURN) | Yes (QUIC connection migration) |
    | **Browser Support** | No | Yes (all modern browsers) | Yes (Chrome 97+, Edge 97+) |
    | **Encryption** | Optional (TLS) | Mandatory (DTLS) | Mandatory (TLS 1.3) |
    | **Setup Complexity** | Simple | Complex (ICE negotiation) | Medium (HTTP/3 CONNECT) |
    | **Connection Time** | Fastest | Medium (ICE gathering) | Fast (0-RTT after first) |
    | **Audio Transport Port** | UDP (61002 + worker_id) | ICE-negotiated UDP ports | UDP 4464 (QUIC) |
    | **Library Required** | None (Qt Network) | libdatachannel | msquic |
    | **Build Option** | Always available | `-Dlibdatachannel=enabled` | `-Dmsquic=enabled` |
  5. Implement UDP redundancy for packet loss mitigation

    main

    When redundancy is enabled with a factor $R$, each UDP datagram contains $R$ full packets concatenated. The newest packet is placed first, followed by older packets in descending order of age.

    Sender logic: Prepend the newest full packet to a buffer of previous packets each period. Receiver logic:

    1. Read the first packet's SeqNumber.
    2. If it is not the expected sequence, scan the concatenated packets for the missing one.
    3. Deliver multiple packets from the datagram in order if they are found.
  6. Protocol detection on the hub TCP port

    main

    The hub server multiplexes three connection types on a single TCP listen port by inspecting the first three bytes of each new connection.

    Initial Detection (First 3 bytes)

    First 3 bytes (hex)Interpretation
    16 03 01 through 16 03 04TLS ClientHello (browser wss://) — start TLS handshake; re-detect after decrypt
    Anything elseLegacy binary hub protocol — read 32-bit LE port number

    Post-TLS Handshake Detection (Decrypted content)

    Once the TLS handshake is complete, the server inspects the decrypted bytes:

    Decrypted contentInterpretation
    GET /ping …Health-check endpoint — responds {"status":"OK"} and closes
    GET /webrtc …HTTP WebSocket upgrade → WebRTC signaling path
    Other GET …Unsupported path — responds HTTP 404 and closes
    Other binary dataAuthenticated binary hub protocol (credentials follow)
  7. Understand WebRTC signaling flow

    main

    WebRTC signaling occurs over a WebSocket connection following these steps:

    1. TLS Handshake: Client connects via wss://. The server detects the TLS ClientHello via the 3-byte record header.
    2. WebSocket Upgrade: Client sends an HTTP GET /webrtc request with Upgrade: websocket headers.
    3. Protocol Detection: Client sends a PROTOCOL_DETECT JSON message: {"type": "protocol_detect", "protocol": 2, "clientName": "...", "version": 1}.
    4. SDP Exchange: Client sends an OFFER (SDP); Server responds with an ANSWER (SDP).
    5. ICE Gathering: Both sides exchange ICE_CANDIDATE messages.
    6. Data Channel: Once ICE + DTLS handshake completes, the data channel (labeled "audio") opens for bidirectional audio datagrams.

    Signaling Message Format: All signaling messages are JSON objects prefixed with a 4-byte big-endian length prefix over the TCP socket: [4-byte length (BE)] [JSON payload].

  8. Understand JackTrip's network transport modes

    main

    JackTrip uses different transport mechanisms depending on the deployment mode:

    • UDP (audio): The primary real-time transport. It carries PacketHeader + raw audio payload. When redundancy is enabled, multiple packets are concatenated into a single datagram for FEC.
    • UDP (control): A specific 63-byte datagram consisting entirely of 0xFF used to signal a shutdown ("Peer Stopped").
    • TCP (hub/ping-server handshake): A short-lived connection used to exchange ephemeral UDP port information. This may include TLS and credential authentication.
    • WebRTC data channel (audio): Used by the hub server's WebRTC path. It carries the same packet format (header + planar audio payload) as UDP. Signaling requires an encrypted WebSocket (wss://).
    • WebTransport / QUIC datagrams (audio): Used by the hub server's WebTransport path via HTTP/3 over QUIC (unreliable datagrams). The session is established via an HTTP/3 CONNECT request.
  9. How oscpp works: Client vs Server

    main

    The library is organized into two primary namespaces representing the two sides of OSC communication:

    • OSCPP::Client: Used for constructing and building OSC packets. It provides a fluent API to open bundles/messages and write arguments into a provided memory buffer.
    • OSCPP::Server: Used for parsing and reading OSC packets. It provides abstractions like Packet, Bundle, Message, and ArgStream to traverse the structure of received data.

    Performance Note: The library is designed for real-time sensitive contexts (like audio driver callbacks) because it avoids memory allocation (except when throwing exceptions) and system calls.

  10. How the JackTrip AUv3 architecture works

    main

    The AUv3 plugin uses a hybrid C++/Objective-C architecture to balance high-performance audio processing with macOS framework integration:

    • JackTripAU: The main AUAudioUnit subclass acting as the Objective-C wrapper for the AUv3 framework.
    • JackTripAUImpl: The C++ implementation class that contains all core audio processing logic.
    • AudioBridgeProcessor: The shared C++ audio processing engine (consistent with AUv2 and VST3 versions) that handles the actual audio exchange.
    • JackTripAUViewController: A native Cocoa-based UI controller for the plugin interface.
    • JackTripAUFactory: Handles the registration of the Audio Unit component.
  11. Format the UDP audio payload (Planar/Non-interleaved)

    main

    On the wire, the audio payload is planar (non-interleaved) by channel. This means all samples for a single channel are grouped together before moving to the next channel:

    1. First $N$ samples for channel 0
    2. Then $N$ samples for channel 1
    3. ...and so on.

    Where $N$ is the BufferSize. Note that for mono ($C=1$), the planar and interleaved layouts are identical.

  12. Use the JackTrip VST3 Audio Bridge Plugin

    main

    The JackTrip VST3 plugin acts as a bridge between your Digital Audio Workstation (DAW) and a running JackTrip instance on the same machine.

    Setup Steps

    1. Launch JackTrip: Start the JackTrip application in your desired mode on your local machine.
    2. Insert Plugin: Load the "JackTrip Audio Bridge" VST3 plugin into a track in your DAW.
    3. Connection: The plugin automatically attempts to connect to the JackTrip application via a local socket.

    Plugin Parameters

    • Send Gain: Controls the level of audio sent to remote participants (Range: -60 to +6 dB).
    • Output Mix: Blends received audio (0%) with input passthrough (100%).
    • Output Gain: Master output level (Range: -60 to +6 dB).
    • Bypass: Bypasses all audio processing.
    • Connected: A read-only indicator showing the current connection status.