Skip to content

Add DSD (Digital Speech Decoder) support with mbelib WASM#13

Draft
jLynx wants to merge 3 commits into
mainfrom
DSD
Draft

Add DSD (Digital Speech Decoder) support with mbelib WASM#13
jLynx wants to merge 3 commits into
mainfrom
DSD

Conversation

@jLynx
Copy link
Copy Markdown
Owner

@jLynx jLynx commented Apr 8, 2026

Description

This PR implements a full Digital Speech Decoder (DSD) stack to enable listening to digital voice protocols directly in the browser. It introduces a new dsd mode that supports FM-demodulated digital protocols, including DMR, P25 Phase 1, D-STAR, and NXDN.

To handle voice synthesis, the PR includes a WebAssembly (WASM) port of mbelib, allowing the decoding of AMBE and IMBE voice frames within the browser's performance constraints.

Core Changes

1. DSD DSP Pipeline

  • Frame Sync: Implemented a robust sync detection engine using collapsed polarity matching for 24-dibit (DMR/P25/D-STAR) and 18-dibit (NXDN) sync words.
  • Clock Recovery: Added a Mueller-Muller timing error detector to extract symbols from the 48 kHz IF stream.
  • Adaptive Slicing: Implemented a 4-FSK slicer with exponential moving average (EMA) tracking of signal levels to handle variable signal strengths.
  • Error Correction: Added ECC modules for Golay(24,12), Hamming(10,6,3), and Reed-Solomon GF(2^6) to improve decoding robustness.

2. mbelib WASM Integration

  • Created a C wrapper for mbelib and an Emscripten-based build script (build.sh).
  • Implemented a lazy-loading system in the Worker thread to initialize the WASM module only when needed.
  • Added persistent heap buffers for zero-allocation decoding calls between JavaScript and WASM.

3. Protocol Support

  • DMR: Support for Tier II voice superframes, including color code detection and TDMA slot-based muting.
  • P25: Parsing of Network Access Codes (NAC) and Data Unit IDs (DUID), with support for LDU1/LDU2 voice units.
  • NXDN & D-STAR: Basic voice deinterleaving and AMBE decoding.

4. UI & State Management

  • Added a new dsd mode selector to the VFO panel.
  • Implemented a real-time DSD status display (styled after SDR++ Brown) showing mode, sync status, talkgroups (TG), source IDs (SRC), and MBE error bars.

How to Build mbelib (Prerequisite)

Since the mbelib.js and .wasm files are served from public/lib/, you must compile them once if they are missing:

cd mbelib-wasm
bash build.sh

Technical Notes

  • Audio Sampling: The decoder emits 8 kHz audio frames, which are resampled to 48 kHz using a RationalResampler in the DSP worker to maintain compatibility with the existing audio pipeline.
  • Performance: The DSP chain is highly optimized; most logic operates on dibit strings or integer arrays to minimize garbage collection overhead in the worker.

jLynx added 3 commits April 8, 2026 21:49
- Introduced DSD types and constants in `src/client/worker/dsd/types.ts`.
- Implemented lazy loading for the mbelib WASM module in `src/client/worker/mbelib-init.ts`.
- Enhanced RX stream handling to include DSD status updates in `src/client/worker/rx-stream.ts`.
- Updated worker types to accommodate DSD decoder and audio resampling in `src/client/worker/types.ts`.
- Modified Vite configuration to include mbelib WASM files during the build process.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
browsdr feb08e4 Commit Preview URL

Branch Preview URL
Apr 08 2026, 10:59 PM

@jLynx jLynx changed the title Add DSD support Add DSD (Digital Speech Decoder) support with mbelib WASM Apr 8, 2026
@jLynx
Copy link
Copy Markdown
Owner Author

jLynx commented Apr 8, 2026

This is still a WIP and doesn't quite work correctly yet

@doubleailes doubleailes mentioned this pull request Apr 15, 2026
9 tasks
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.

1 participant