Skip to content

Conversation

@dnecra
Copy link

@dnecra dnecra commented Dec 29, 2025

Audio Stream Plugin

Description

This plugin enables streaming of raw PCM (Pulse Code Modulation) audio data from Pear Desktop over HTTP. It allows external applications, recording software, or other devices on your local network to receive real-time audio streams for processing, recording, or playback.

How It Works

The plugin consists of three main components:

  1. Renderer Process: Captures audio from the Web Audio API using a ScriptProcessorNode, converts the audio samples to PCM format (16-bit or 32-bit), and sends the data to the backend via IPC.

  2. Backend Process: Runs an HTTP server that listens for client connections. When clients connect to the /stream endpoint, the server streams PCM audio data in real-time. The server maintains a small buffer of recent audio chunks so new clients can catch up.

  3. Configuration: Users can configure the streaming port, hostname, and audio quality settings (sample rate, bit depth, channels, buffer size) through the plugin menu.

Key Features

  • Real-time PCM streaming over HTTP
  • Configurable audio quality: Sample rates (44.1kHz, 48kHz, 96kHz), bit depths (16-bit, 32-bit), mono/stereo
  • Low latency: Configurable buffer sizes (1024-8192 samples) for balancing latency vs. stability
  • Multiple client support: Multiple applications can connect simultaneously
  • Dynamic configuration: Audio settings can be changed without restarting the app
  • CORS enabled: Allows connections from web-based applications

Use Cases

  • Recording audio from Pear Desktop to external software
  • Real-time audio processing and analysis
  • Streaming to external audio devices or applications
  • Integration with home automation or audio routing systems
  • Audio visualization or analysis tools

Technical Details

  • Default port: 8765
  • Default hostname: 0.0.0.0 (listens on all interfaces)
  • Default audio settings: 48kHz, 16-bit, stereo, 2048 sample buffer
  • Protocol: HTTP streaming with binary PCM data
  • Format: Each chunk includes metadata (sample rate, bit depth, channels, timestamp) followed by raw PCM samples

Configuration

The plugin can be configured through the Pear Desktop menu:

  • Port: Set the HTTP server port (default: 8765)
  • Quality & Latency: Adjust sample rate, bit depth, channels, and buffer size

Stream URL format: http://localhost:{port}/stream

dnecra and others added 30 commits December 18, 2025 01:54
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
dnecra and others added 4 commits December 19, 2025 13:36
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Refactor audio processing to use AudioWorkletNode for improved performance and stability. Removed deprecated ScriptProcessorNode and optimized PCM data handling.
Added support for handling binary PCM data from clients.
github-actions[bot]

This comment was marked as spam.

dnecra and others added 2 commits December 29, 2025 21:25
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions[bot]

This comment was marked as spam.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions[bot]

This comment was marked as spam.

dnecra and others added 2 commits December 29, 2025 21:42
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions[bot]

This comment was marked as spam.

@ArjixWasTaken
Copy link
Member

If we are going to add audio streaming, we should do what internet radio stations do, so existing radio apps will be supported.

I see you designed your own interface for streaming data+metadata, requiring a custom client to receive the stream.
I believe we should instead follow the Icecast Protocol.

Also, using node:http is discouraged, if you look at the api-server plugin you'll see that we use a lightweight library named hono, which is really similar to express.js

Therefore I will be marking this PR as a draft, and will help make the necessary changes.

@ArjixWasTaken ArjixWasTaken marked this pull request as draft January 1, 2026 02:30
@dnecra dnecra marked this pull request as ready for review January 12, 2026 08:36
@dnecra dnecra marked this pull request as draft January 12, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants