BEETLE

BEETLE V1.4.9 — Original BD4S Streaming / Prefetch Lab

Development stage, 21 October 2026. NOT an FM1 firmware update.

What actually changed

The project now contains independently written C code to stream the original BD4S sample format through two small decoded PCM windows per voice. The new module is firmware/fm1-native/beetle_bd4_prefetch.[ch]. It has a bounded background worker, a RAM-only audio renderer, six independently addressable voices, and thirteen assignable sample-source IDs (U01–U13). It does not call or embed another firmware’s sample engine.

The original project includes upstream Felucca/ETCH lineage and therefore retains GPL-3.0-only and relevant upstream credits. No licence notices or existing BEETLE functions have been removed.

Architecture

Stage Function Allowed to read external storage?
BD4S source (13 slots) Verified, versioned compressed mono blobs Storage provider owns this
Main-loop prefetch Read 16-byte header / 6-byte block index, load up to 134 compressed bytes, decode <=64 frames per operation YES, outside audio IRQ
Six-voice ring window Two 64-frame PCM windows per voice; bounded preallocated memory NO
Render Output 44,100 Hz mono with simple 2:1 linear interpolation from 22,050 Hz PCM NO

Tested

Run from the top-level repository:

python tests/dpcm4/run_prefetch.py
python tests/dpcm4/test_codec.py
python tests/dpcm4/test_storage_integration.py

The first test generates thirteen original BD4S sources, validates C rendering against the Python-decoded reference at every output frame, runs six simultaneous voices without underruns when prefetch is serviced, exercises 1-, 2-, 63-, 64-, 65- and 257-frame edge cases, and plays a 20-second individual file from start to finish. It also injects missing reads, verifies underrun reporting and recovery, and tests invalid source headers. UndefinedBehaviorSanitizer is included in its host compiler command.

The existing stage-3 offline flash simulation separately fits 20.06 seconds in total across 13 slots, with a MOUNTAINKING-sized project and eleven NUGGIE-sized projects. It does not demonstrate that every possible combination of 12 full projects and 20 seconds will fit.

Still required before a physical FM1 .fwsc

  1. Establish real target RAM/linker ownership and verify the additional 2.8 KiB does not clash with audio scratch, display/USB buffers, or legacy 6 KiB project-owned one-shot RAM.
  2. Prove which physical flash regions can be used by transactional Storage V2, with independent OTA and factory-recovery verification. The offline model must not be wired to 0x97000..0xDEFFF in an already provisioned device without safe migration and a complete external backup.
  3. Implement and verify the single-producer/single-consumer synchronization between real FM1 audio ISR and main loop. Current lab APIs are used with serialized access and are not a concurrency proof.
  4. Implement sequencer lookahead, retriggers, sample-accurate note placement, coexistence with the existing six drumvoices and eight synthvoices, mixer gain/panning, project links and legacy V22/V23 migration.
  5. Add a USB protocol with capability negotiation, CRC-checked chunk upload, nonblocking final commit, readback, and an explicit STORAGE FULL refusal.
  6. Measure worst-case DMA deadlines with 6 drumvoices, 8 synthvoices, USB multitrack, full-screen LCD activity and simultaneous user samples. Test MOUNTAINKING transitions, long playback and unplug/replug/power failure.
  7. Only then compile, package and independently hardware-validate a new firmware image. Product identity must stay FM-1_2123 (V1.3.8).

Release provenance