Audio Monitoring Feature
Overview
The Audio Monitoring feature allows users to listen to live audio from configured audio sources (SDR receivers, web streams, ALSA devices, etc.) directly through the web interface. This is invaluable for monitoring signal quality, debugging audio issues, and verifying that sources are receiving audio correctly.Features
Live Audio Streaming
- Real-time playback - Listen to audio sources as they capture
- WAV format streaming - Browser-compatible PCM audio
- Multiple sources - Monitor SDR, web streams, ALSA, PulseAudio, and file sources
- Auto-reconnect - Streams automatically refresh
Visual Monitoring
- Live waveform display - Real-time oscilloscope view of audio
- Audio level meters - Peak and RMS level monitoring
- Status indicators - Running, stopped, error states
- Health metrics - Sample rate, channels, buffer utilization
Source Control
- Start/Stop sources - Control audio sources from the monitoring page
- Auto-refresh - Page updates every 5 seconds
- Manual refresh - Refresh button for immediate updates
Architecture
Backend (webapp/admin/audio_ingest.py)
New Endpoint: /api/audio/stream/<source_name>
Purpose: Stream live audio in WAV formatHow it works:
- Accepts source name as URL parameter
- Validates source exists and is running
- Generates WAV header with proper format info
- Continuously pulls audio chunks from source queue
- Converts float32 audio to int16 PCM
- Yields PCM data as streaming response
- Auto-terminates after ~2 minutes to prevent resource exhaustion
- Container: WAV (RIFF)
- Codec: PCM (uncompressed)
- Bit depth: 16-bit
- Sample rate: Matches source (typically 44.1kHz)
- Channels: Matches source (typically mono)
- Duration: ~2 minutes max per stream session
WAV header structure
RIFF header (12 bytes)
- 'RIFF' magic
- File size (0xFFFFFFFF for streaming)
- 'WAVE' magic
fmt chunk (24 bytes)
- 'fmt ' magic
- Chunk size (16)
- Audio format (1 = PCM)
- Channels
- Sample rate
- Byte rate
- Block align
- Bits per sample
data chunk header (8 bytes)
- 'data' magic
- Data size (0xFFFFFFFF for streaming)
PCM audio data (continuous stream)
Frontend (templates/audio_monitoring.html)
Components
1. Source Cards- Display one card per configured audio source
- Color-coded border by status (green=running, gray=stopped, red=error)
- Shows source type, name, description
- Includes HTML5 audio player when running
- Live waveform canvas visualization
- Real-time metrics display
- Native HTML5
<audio>element - Points to
/api/audio/stream/<source_name> - Browser handles all buffering and playback
- Standard play/pause/volume controls
- Canvas-based real-time oscilloscope
- Updates every 100ms via
/api/audio/waveform/<source_name> - Displays last 2048 samples
- Green waveform on black background
- Center line for zero reference
- Grid layout with key metrics
- Peak level (dB)
- RMS level (dB)
- Sample rate (kHz)
- Channel count
- Updates every 5 seconds with source data
Usage
Accessing the Audio Monitor
- Navigate to Monitoring → Audio Monitoring in the main menu
- The page will load all configured audio sources
- Sources will be displayed as cards with their current status
Listening to a Source
If source is running:- Simply click the Play button on the HTML5 audio player
- Adjust volume as needed
- Watch the waveform for visual feedback
- Click the Start button on the source card
- Wait ~1 second for source to start
- Page will automatically refresh
- Click Play on the audio player
Stopping a Source
- Click the Stop button on the source card
- Audio playback will stop
- Waveform updates will cease
- Source status will update to "stopped"
Understanding the Display
Status Badges:- RUNNING (green) - Source is capturing audio
- STOPPED (gray) - Source is not active
- STARTING (yellow) - Source is initializing
- ERROR (red) - Source encountered an error
- DISCONNECTED (yellow) - Source lost connection
- Peak: Maximum audio level (should be below 0 dB)
- RMS: Average audio level (typical range: -40 to -10 dB)
- Sample Rate: Audio quality (44.1 kHz = CD quality)
- Channels: Mono (1) or Stereo (2)
Configuration
Audio Source Requirements
For a source to appear in the audio monitor:
- Must be configured in Audio Settings
- Must have a valid configuration
- Source adapter must be initialized
Starting Sources Automatically
To have sources auto-start on application boot:
- Go to Admin → Audio Settings
- Edit the source configuration
- Enable Auto Start option
- Save configuration
- Restart application
Technical Limitations
Stream Duration
Streams automatically terminate after ~2 minutes (6000 chunks at 20ms per chunk). This prevents:- Memory leaks from abandoned connections
- Resource exhaustion from stale streams
- Bandwidth waste from forgotten tabs
Browser Compatibility
- Chrome/Edge: Full support
- Firefox: Full support
- Safari: Full support (may have buffering quirks)
- Mobile browsers: Supported but may have autoplay restrictions
Network Requirements
- Bandwidth: ~700 Kbps per stream (44.1kHz mono 16-bit)
- Latency: ~2-5 seconds typical (buffering delay)
- Concurrent streams: No hard limit (limited by server resources)
Troubleshooting
"Source not found" Error
Cause: Source doesn't exist or hasn't been configured Solution: Go to Audio Settings and configure the source"Source not running" Error
Cause: Source is stopped or in error state Solution: Click the Start button to start the sourceNo Audio / Silence
Possible causes:- Source not receiving signal (check antenna/connection)
- Volume level too low (check browser volume and player volume)
- Source frequency/settings incorrect
- Hardware issue (SDR disconnected, etc.)
- Check waveform - if flat line, no signal
- Check metrics - if RMS < -60 dB, very weak signal
- Check System Logs for error messages
- Check Audio Health page for source status
Choppy/Stuttering Audio
Possible causes:- Network latency/bandwidth issues
- Server overload
- Too many concurrent streams
- Reduce number of active streams
- Check server CPU/memory usage
- Check network connection quality
Waveform Not Updating
Possible causes:- Source stopped
- JavaScript error
- API endpoint not responding
- Check browser console for errors
- Click Refresh button
- Restart source
API Reference
GET /api/audio/sources
Description: List all configured audio sources
Response: JSON with array of source objects
{
"sources": [
{
"id": "sdr-primary",
"name": "sdr-primary",
"type": "sdr",
"status": "running",
"enabled": true,
"metrics": {
"peakleveldb": -12.5,
"rmsleveldb": -25.3,
"sample_rate": 44100,
"channels": 1
}
}
],
"total": 1,
"active_count": 1
}
GET /api/audio/stream/<source_name>
Description: Stream live audio in WAV format
Parameters:
source_name(path) - Name of audio source
audio/wav
Headers:
Cache-Control: no-cache, no-store, must-revalidateX-Content-Type-Options: nosniff
GET /api/audio/waveform/<source_name>
Description: Get current waveform data for visualization
Parameters:
source_name(path) - Name of audio source
{
"source_name": "sdr-primary",
"waveform": [-0.01, 0.02, -0.03, ...],
"sample_count": 2048,
"timestamp": 1699384567.123,
"status": "running"
}
POST /api/audio/sources/<source_name>/start
Description: Start an audio source
Response: {"success": true}POST /api/audio/sources/<source_name>/stop
Description: Stop an audio source
Response: {"success": true}Security Considerations
Access Control
- Audio monitoring is publicly accessible (no auth required currently)
- Consider adding authentication if dealing with sensitive audio
- Stream URLs are predictable (based on source name)
Resource Protection
- Automatic stream termination after 2 minutes
- Queue size limits prevent memory exhaustion
- Rate limiting could be added for production deployments
Data Privacy
- Audio is streamed in real-time (not recorded)
- No server-side storage of audio data
- Streams are per-client (not broadcast to all)
Future Enhancements
Potential Features
- Recording capability - Save audio streams to files
- Spectral analysis - Add FFT waterfall display
- Audio alerts - Notify on signal loss/clipping
- Multi-channel support - Stereo waveform display
- Bandwidth optimization - Lower bitrate options
- Authentication - Role-based access control
- Annotations - Mark interesting audio events
- Playback history - Review past audio segments
Performance Improvements
- WebSocket streaming - Lower latency alternative to HTTP
- Opus codec - Better compression than PCM
- Adaptive bitrate - Adjust quality based on connection
- Client-side buffering - Reduce stream interruptions
Files Modified
New Files
templates/audio_monitoring.html- Frontend UIAUDIO_MONITORING.md- This documentation
Modified Files
webapp/admin/audioingest.py- Added/api/audio/stream/<sourcename>endpointwebapp/routes_public.py- Added/audio-monitorroutecomponents/navbar.html- Added "Audio Monitoring" menu item
Credits
- WAV streaming: Standard RIFF/WAV format specification
- HTML5 Audio: Native browser audio support
- Canvas waveform: Real-time 2D visualization
- Flask streaming: Flask's
streamwithcontext()generator support
Support
For issues or questions about audio monitoring:- Check this documentation
- Review System Logs for errors
- Check browser console for JavaScript errors
- Verify source configuration in Audio Settings
- Test with simple file source before SDR/stream sources
Last Updated: November 7, 2025
This document is served from docs/audio/AUDIO_MONITORING.md in the EAS Station installation.