Skip to content

Commit d8a527d

Browse files
update docs
1 parent 60f4085 commit d8a527d

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

docs/frameworks/audiomanager.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ AudioManager provides:
99
- **Priority-based audio focus** - Higher priority streams interrupt lower priority ones
1010
- **Device registry** - Register I2S outputs, PWM buzzers, and microphone inputs
1111
- **Session control** - Player/Recorder sessions with start/stop/pause/resume
12-
- **WAV file support** - 8/16/24/32-bit PCM, mono/stereo, auto-upsampling
12+
- **WAV file support** - 8/16/24/32-bit PCM, IMA ADPCM (4-bit), mono/stereo, auto-upsampling
1313
- **WAV recording** - 16-bit mono PCM from I2S or ADC microphone
1414
- **RTTTL ringtone support** - Full Ring Tone Text Transfer Language parser
1515
- **Thread-safe** - Safe for concurrent access
@@ -78,9 +78,10 @@ player.start()
7878
```
7979

8080
**Supported formats:**
81-
- **Encoding**: PCM (8/16/24/32-bit)
81+
- **Encoding**: PCM (8/16/24/32-bit), IMA ADPCM (4-bit)
8282
- **Channels**: Mono or stereo
8383
- **Sample rate**: Any rate (auto-upsampled to ≥8000 Hz)
84+
- **Repeat**: Pass `repeat_count` to loop playback N times
8485

8586
### Playing RTTTL Ringtones
8687

@@ -142,6 +143,20 @@ sudo apt install ffmpeg
142143

143144
Priority and volume controls apply conceptually on desktop, although the external player handles the actual output.
144145

146+
### ADPCM WAV Encoding
147+
148+
IMA ADPCM compresses 16-bit PCM to 4 bits per sample, roughly quartering WAV file size with minimal quality loss — ideal for storage-constrained devices.
149+
150+
`ffmpeg` can encode ADPCM (`-acodec adpcm_ima_wav`) but has two drawbacks: it prepends silence that lengthens the file, and it only supports the default 4-bit depth. MicroPythonOS currently decodes 4-bit IMA ADPCM only. For better encoding results than `ffmpeg`, use [adpcm-xq](https://github.com/dbry/adpcm-xq), which avoids the silence padding and additionally supports 2 and 3-bit ADPCM (still good quality, even smaller files). If there's demand for it, 2 and 3-bit ADPCM decoding support could be added to MicroPythonOS too.
151+
152+
```bash
153+
# ffmpeg (adds silence, 4-bit only)
154+
ffmpeg -i input.wav -acodec adpcm_ima_wav output.wav
155+
156+
# adpcm-xq (clean, supports 3-bit and 4-bit)
157+
adpcm-xq -e 3 input.wav output.wav
158+
```
159+
145160
## Audio Focus Priority
146161

147162
AudioManager implements a 3-tier priority-based audio focus system inspired by Android:
@@ -279,8 +294,8 @@ Set or get the global volume (0–100).
279294
### WAV File Not Playing
280295

281296
**Requirements:**
282-
- **Encoding**: PCM only (not MP3, AAC)
283-
- **Bit depth**: 8, 16, 24, or 32-bit
297+
- **Encoding**: PCM or IMA ADPCM (not MP3, AAC)
298+
- **Bit depth**: 8, 16, 24, or 32-bit (PCM); 4-bit (ADPCM)
284299
- **Channels**: Mono or stereo
285300
- **Sample rate**: Any (auto-upsampled to ≥8000 Hz)
286301

0 commit comments

Comments
 (0)