# Reaper-Web

A low-latency, fully containerized deployment of REAPER DAW, accessible directly through a modern web browser via KasmVNC. 

This repository builds a custom Ubuntu-based image that pipes PulseAudio through a Node.js WebSocket bridge, allowing you to produce music and record microphone audio remotely without needing a local DAW installation.

## Features
- **Browser-Native Audio:** High-quality, low-latency audio playback and microphone recording streamed directly to your browser via WebSockets.
- **Auto-Initialization:** The audio pipeline initializes seamlessly on the first click inside the container.
- **Optimized Latency Stack:** Features reduced Node.js WebSocket overhead, `tsched=0` disabled in PulseAudio, and expanded JS playback buffers to prevent crackling.
- **Persistent VST/Project Storage:** Plugins (`.vst3`, `.vst`, `.lv2`) and projects are mapped to external host directories for data safety.
- **Baked-In Defaults:** Includes a pre-configured `reaper.ini` tailored for the web wrapper and Openbox settings that force REAPER into a maximized view by default.

## Architecture

* **Base Image:** `lscr.io/linuxserver/baseimage-kasmvnc:ubuntunoble`
* **Window Manager:** Openbox (configured for forced fullscreen application view).
* **Audio Backend:** PulseAudio & PipeWire
* **Streaming Protocol:** KasmVNC (WebRTC/WebSockets for video, LSIO Node.js bridge for audio).

## Prerequisites
- Docker & Docker Compose
- Ensure your Docker host has ALSA drivers loaded (`/dev/snd` must exist on the host).

## Deployment

1. **Clone the configuration:**
   Ensure this project lives in your docker-compose app path (e.g. `/srv/configs/docker_compose/reaper-web`).

2. **Configure Environment:**
   Create an `.env` file to define your paths and secure VNC password:
   ```bash
   nano .env
   ```

3. **Build and Run:**
   ```bash
   docker compose up -d --build
   ```

4. **Access the DAW:**
   Navigate to `http://<YOUR_DOCKER_HOST>:<REAPER_HTTP_PORT>` (e.g., `http://10.0.0.190:3010`).
   *Note: Microphone access requires HTTPS. If you are routing this through Nginx Proxy Manager, ensure an SSL certificate is attached and Websocket Support is enabled.*

## Data Directories
Map the following volumes in your `docker-compose.yaml` to persist your data:

- `/config` - Persistent application state and Reaper configurations. (If empty, it automatically populates from the image's optimized defaults on first boot).
- `/projects` - Your Reaper `.RPP` files and audio recordings.
- `/vst` - Legacy VST2 plugins.
- `/usr/lib/vst3` - VST3 plugins.
- `/usr/lib/lv2` - LV2 plugins.

## Troubleshooting

- **Audio is crackling:** This is usually due to network jitter or CPU overload. The internal playback buffers have been optimized to 150ms. If you are accessing this over a VPN or a high-latency WAN connection, you may need to increase the `duration > .15` threshold in `kclient.js` inside the `Dockerfile`.
- **Microphone is not working:** The browser will strictly block microphone access unless the webpage is served over **HTTPS** or accessed via `localhost`. You must use a reverse proxy to handle the SSL termination.
- **"Connection Refused" Audio Error:** If you see this in the logs, ensure the PulseAudio permissions fix (`PULSE_RUNTIME_PATH=/config/.pulse` in the `Dockerfile`) is active. This bypasses root-level Docker volume permission restrictions.
