Repository navigation
feat: add f32 audio and drain methods to Processor and Tunelet - #84
Closed
google-labs-stitch[bot] wants to merge 2 commits into
Closed
google-labs-stitch[bot] wants to merge 2 commits into
google-labs-stitch[bot] wants to merge 2 commits into
Conversation
- Add f32 process and drain methods to Processor in src/processor.rs - Quantize f32 input to symmetric i16 PCM on the stack - Divide clipped i16 and downmix output by 32768.0 for f32 calls - Reserve reusable f32 buffers in WasmProcessor::new - Add processF32, processMonoF32, drainF32 and drainMonoF32 to Tunelet - Check the Float32Array methods and types in scripts/verify-pack.mjs - Document the f32 and Float32Array methods in src/lib.rs and README.md
Contributor
|
Review: Approved in principle — clean Rust/Wasm Float32 audio and drain API with symmetric f64 quantization matching the internal -32767..=32767 range. Please rebase onto updated main and adapt to two merged changes:
|
This was referenced Nov 25, 2026
- Merge main into the f32 audio branch - Pass OutputLayout::Stereo in stereo f32 calls - Pass OutputLayout::Mono in mono f32 calls - Document mono peak measurements after the downmix for f32 calls - Use decode_events and self.events in processF32 and processMonoF32 - Keep the Wasm initializer checks in scripts/verify-pack.mjs
Contributor
Author
|
Updated and synced with
|
google-labs-stitch Bot
added a commit
that referenced
this pull request
Nov 25, 2026
- Merge the #84 branch into this pull request - Share the f32 Processor methods and symmetric f64 quantization - Share input_f32, left_f32 and right_f32 across f32 Wasm calls - Share decode_events across copied and in-place f32 Wasm calls - Test and document both copied and in-place Float32 APIs
Contributor
byteland-app
deleted the
stitch/add-float32-audio-methods-jm0-c24407d7-874e-4c13-8e92-3000afe25ad9
branch
November 25, 2026 14:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
f32andFloat32Arrayaudio process and drain methods toProcessorandTunelet(WasmProcessor) so browser, Node.js and Rust hosts can passf32audio directly while keeping sample-exact fixed-point DSP output, zero post-construction Rust heap allocations and pre-mutation error atomicity.Changes
src/processor.rs:process_f32,process_planar_f32,process_mono_in_place_f32,drain_f32,drain_planar_f32anddrain_mono_f32toProcessor, passingOutputLayout::Stereofor stereo calls andOutputLayout::Monofor mono calls.f32input sample on the stack beforeProcessor::next(NaNmaps to0, finite and infinite values clamp to-1.0..=1.0, multiply inf64by32_767.0and round to-32767..=32767).i16output sample or mono downmix sample by32_768.0, and fill unused drain frames with0.0.src/wasm.rs:input_f32,left_f32andright_f32Vec<f32>buffers of lengthmax_block_framesinWasmProcessor::newwithtry_reserve_exact.processF32,processMonoF32,drainF32anddrainMonoF32onTuneletaccepting&Float32Arraybuffers, reusingdecode_events(&mut self.events, ...)for timed events and copying viacopy_toandcopy_from.Int16Arrayprocess,processMono,drainanddrainMonounchanged.scripts/verify-pack.mjs,src/lib.rs,README.md:Float32Arraymethods across bothtuneletand@bytelandtechnology/tuneletarchives inscripts/verify-pack.mjs.f32andFloat32Arrayaudio methods and conversion rules insrc/lib.rsandREADME.md.Verification
cargo fmt --checkcargo clippy --locked --lib -- -D warningscargo build --locked --releaseRUSTDOCFLAGS="-D warnings" cargo doc --locked --no-depscargo package --lockedRUSTDOCFLAGS="-D warnings" npm run check:wasmnpm run verify:packProcessor::newheap usage remains identical tomain(2,071,044bytes) and post-construction Rust audio/drain calls allocate0bytes.decode_eventsbuffer capacity without Wasm memory growth, overlapping buffer safety and pre-mutation error atomicity.Automated PR initiated by user @byteland-app via Stitch Loop.