Skip to content

Add PCM audio streaming driver - #154

Open
WojciechGw wants to merge 21 commits into
picocomputer:mainfrom
WojciechGw:driver/PCM
Open

Add PCM audio streaming driver#154
WojciechGw wants to merge 21 commits into
picocomputer:mainfrom
WojciechGw:driver/PCM

Conversation

@WojciechGw

Copy link
Copy Markdown
Contributor

Add PCM audio streaming driver

Adds raw PCM playback via a ring buffer in XRAM, activated through the existing XREG audio channel (device=0, channel=1, address=2).

XRAM layout

8-byte header at the base address followed by the ring buffer:

Offset Field Description
+0..+1 write_ptr byte index maintained by the application
+2 format bit 0=mono, bit 1=8-bit, bit 2=unsigned
+3 buf_size_log2 ring size (9–13; default 10)
+4..+5 sample_rate 8000/11025/16000/22050/32000/44100 Hz
+6..+7 read_ptr byte index written by RP2350 each IRQ
+8.. ring buffer 1 << buf_size_log2 bytes

Supported formats

All combinations of:

  • sample rate: 8000 / 11025 / 16000 / 22050 / 32000 / 44100 Hz
  • bit depth: 16-bit signed or 8-bit unsigned
  • channels: stereo or mono

The RP2350 IRQ runs at the configured sample rate and mixes BEL alert sounds on both channels, consistent with PSG and OPL behaviour. Calling any other audio XREG automatically stops PCM via aud_setup().

Activation

xreg(0, 1, 2, pcm_xram_base);  /* start */
xreg(0, 1, 2, 0xFFFF);         /* stop  */

Additional files

solution notepad
PCM.md
cc65 (c89) test player
playpcm.c
test.wav for test player
testwav.zip

@WojciechGw
WojciechGw force-pushed the driver/PCM branch 3 times, most recently from 709e454 to 293493d Compare July 5, 2026 15:26
@WojciechGw

WojciechGw commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

ROM
playpcm.zip
source
playpcm.c
Updated version.
You can now run it with:
load playpcm.rp6502 filetoplay.wav

2nd test .wav
testwav2.zip

@WojciechGw
WojciechGw force-pushed the driver/PCM branch 2 times, most recently from f1640e1 to 16b7518 Compare July 13, 2026 20:17
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