A collection of audio projects for the CH32V003J4M6 RISC-V microcontroller, demonstrating various audio synthesis and playback techniques on an 8-pin, $0.10 microcontroller. From simple 1-bit music to compressed audio sample playback and speech synthesis. Click on the image to watch a video and hear the results.
This repository contains several firmware projects and development tools:
The Buzzer Studio project is available here: https://buzzer-studio.atomic14.com/
A word of warning - the Buzzer Studio codebase was creating with a lot of help from AI tools. It all runs client side, there is no backend for anyone to hack. But the code may not always be easy for a human to understand.
All firmware projects build with PlatformIO. To build locally:
Simple Sound Firmware (1-bit monophonic):
cd SimpleSoundFirmware
pio run
Polyphonic Sound Firmware (8-voice PWM):
cd PolyphonicSoundFirmware
pio run
Sample Playback (compressed audio):
cd SamplePlayback
pio run
Talkie (speech synthesis):
cd Talkie
pio run
For detailed firmware information, see each project's README: - SimpleSoundFirmware/README.md - Original single-voice 1-bit music - PolyphonicSoundFirmware/README.md - 8-voice polyphonic synthesis - SamplePlayback/README.md - Compressed audio playback with multiple codecs - Talkie/README.md - Speech synthesis implementation
Buzzer Studio (Web App):
cd buzzer-studio
npm install
npm run dev
The app allows you to: - Export tracks from MIDI files for 1-bit playback - Design sound effects with real-time preview - Export to C arrays for microcontrollers - Export to Python for MicroPython/CircuitPython - Choose from preset effects (jump, coin, laser, etc.) - Play LPC encoded audio - Encode WAV files to LPC
SimpleSoundFirmware (1-bit music): - Output: Piezo buzzer or small speaker (connected to PD6) - Input: Trigger button or signal (connected to PC1)
PolyphonicSoundFirmware (8-voice music): - Output: Piezo buzzer or small speaker (connected to PA1) - No trigger input: Plays automatically on startup
SamplePlayback (compressed audio): - Output: PWM audio output on PA1 (8-bit via PWM) - No trigger input: Plays automatically on startup
Talkie (speech synthesis): - Output: PWM audio output on PA1 (8-bit via PWM) - No trigger input: Plays speech on startup
brain-transplant/
├── SimpleSoundFirmware/ # 1-bit monophonic music playback
│ ├── src/ # Source code (main.cpp, music data)
│ ├── platformio.ini # Build configuration
│ └── README.md # Documentation
│
├── PolyphonicSoundFirmware/ # 8-voice polyphonic music
│ ├── src/ # Source code (polyphonic player)
│ ├── platformio.ini # Build configuration
│ └── README.md # Documentation
│
├── SamplePlayback/ # Compressed audio sample playback
│ ├── src/ # Source code (ADPCM decoders, PWM player)
│ │ ├── AudioStream.h # Base interface for codecs
│ │ ├── IMAAdpcmStream.* # IMA ADPCM decoder
│ │ ├── ADPCM2BitStream.* # 2-bit ADPCM decoder
│ │ ├── player.* # PWM playback engine
│ │ └── audio/ # Audio data files
│ ├── platformio.ini # Build configuration
│ └── README.md # Documentation
│
├── Talkie/ # Speech synthesis
│ ├── src/ # Source code (Talkie library port)
│ │ ├── Talkie.* # Speech synthesis engine
│ │ ├── phrases.* # Pre-defined speech phrases
│ │ └── player.* # Audio playback
│ ├── platformio.ini # Build configuration
│ └── README.md # Documentation
│
├── scripts/ # Python audio conversion tools
│ ├── wav_to_adpcm_c.py # WAV → ADPCM C array converter
│ ├── adpcm_2bit_decoder.py # 2-bit ADPCM decoder
│ ├── compare_audio.py # Audio comparison tools
│ ├── pyproject.toml # Python dependencies (uv)
│ └── README.md # Scripts documentation
│
├── buzzer-studio/ # Interactive web app
│ ├── src/ # TypeScript source code
│ ├── public/ # Static assets
│ ├── index.html # App entry point
│ ├── package.json # Dependencies and scripts
│ └── README.md # App documentation
│
└── .github/
└── workflows/
├── build-firmware.yml # Firmware CI/CD
└── buzzer-studio-ci.yml # Buzzer Studio CI/CD
For Firmware Development: - PlatformIO - Embedded build system - CH32V platform support (installed automatically by PlatformIO) - WCH-Link programmer (or compatible)
For Buzzer Studio App: - Node.js 18+ and npm - Modern web browser with Web Audio API support
For Python Scripts: - Python 3.8+ - uv package manager
SimpleSoundFirmware (1-bit music): 1. Waits for trigger signal on pin PC1 2. Toggles output pin (PD6) at specified frequencies 3. Uses microsecond-precision delays for accurate timing 4. Simple 1-bit audio (square wave)
PolyphonicSoundFirmware (8-voice music): 1. Automatically starts on power-up 2. Manages up to 8 simultaneous voices using PWM synthesis 3. Outputs mixed audio through PA1 at 8 kHz sample rate 4. Software mixing with real-time voice generation
SamplePlayback (compressed audio): 1. Decodes compressed audio using codec decoders (IMA ADPCM, 2-bit ADPCM) 2. Outputs 8-bit audio via PWM on PA1 at 8 kHz 3. Supports multiple codec formats with extensible architecture 4. Compression ratios of 2:1 and 4:1
Talkie (speech synthesis): 1. Uses Linear Predictive Coding (LPC) for speech synthesis 2. Pre-defined vocabulary of phonemes and words 3. Outputs synthesized speech via PWM on PA1 4. Real-time speech generation from phrase data
$ claude mcp add ch32v003-audio \
-- python -m otcore.mcp_server <graph>