Repository navigation
feat(processor): support 8 kHz to 192 kHz with a polyphase resampler - #53
Conversation
- Prepare the correction table for the internal rate at construction. - Make CorrectionTable::set_sample_rate private to scale. - Update the CorrectionConfig documentation for the initial table.
- Extend SampleRate and Tunelet to accept 8000..=192000 Hz integers. - Add a fixed-point Q14 polyphase sinc resampler with 32-bit phases. - Bypass rate conversion at 44.1 kHz and 48 kHz. - Select the 44.1 kHz core for 44.1 kHz multiples and divisors. - Map timed events to core frames and report delays in host frames. - Document the sample rate range and the host latency in the README.
- Merge the latest main branch into the feature branch. - Calculate output_gain in i64 inside Processor::next_core. - Accumulate polyphase FIR dot products in i64 for round_q14.
- Merge the latest main branch into the feature branch. - Share BlockBuffer across the three audio process methods. - Keep downmix, reset_post_resynthesis and check_block from main.
|
Review: Preferred over #73 for 8–192 kHz support (zero overhead at 44.1/48 kHz and constant CPU/memory at 192 kHz). Please address these items before merge:
|
- Merge the latest main branch into the feature branch. - Keep the scale period initialization from main. - Pass OutputLayout through the direct and resampled paths. - Update the latency documentation for the 1,593-frame dry delay.
- Write zero for formant envelope points above half of the core rate. - Document the core rate selection on SampleRate. - Document the formant envelope limit in Rust, Wasm and the README. - Align the Feedback latency field documentation with Processor.
|
Addressed all three items:
|
|
Synced with updated
|
|
Round 3 review: Approved — polyphase 8–192 kHz resampler, core-Nyquist zero-fill, and MSRV 1.88 support look solid. Please rebase onto updated main after #107 and #117 (updating process_f32/drain_f32 paths for resampled rates and adding any new rustdoc link mappings in scripts/normalize-jsdoc.mjs if needed). |
- Merge main commit 0850e25 into the resampler branch. - Route the f32 process methods through BlockBuffer and Resampler. - Add backticks to the WasmProcessor::new range docs for JSDoc. - Update README.md for 8000..=192000 Hz PCM and 32-bit float audio.
|
Merged updated
|
|
Review (local impulse verification):
|
- Merge main commit 8880205 into the resampler branch. - Scale Telemetry::period_samples to host samples. - Use set_aspiration_muted in drain_into across all sample rates. - Update README.md for active voice slices and resampler latency.
- Subtract one host frame from input_filter.half in latency_frames.
- Note InvalidConfig for prepare.max_block_frames at resampled rates.
- Check invalid sample rates in verifyRuntimeImport. - Check 8 kHz and 96 kHz audio, feedback, telemetry and drain.
|
Merged updated
|
Summary
SampleRateandWasmProcessor::new(new Tunelet()) to accept all integer sample rates in8000..=192000Hz whileSampleRate::Hz44100andSampleRate::Hz48000stay compatible.Q14polyphase sinc resampler (src/resample.rs) with coupled 32-bit phase accumulators, double-length contiguous FIR history rings, and zero floating-point core sample paths.i16and normalizedf32audio and drain paths (process,process_planar,process_mono_in_place,process_f32,process_planar_f32,process_mono_in_place_f32,drain,drain_planar,drain_mono,drain_f32,drain_planar_f32,drain_mono_f32, and WasmFloat32ArrayandTuneletAudioViewsmethods) throughprocess_intoanddrain_intowith zero heap allocations.ValidatedEventsoffsets (next_atandpeek_offset, supportingParameterControlandControlEvent::Reset), passOutputLayoutacross direct and resampled paths, and reportlatency_frames,tail_frames,processed_frames,Feedback::period_samples, andTelemetry::period_samplesin host frames.Processor::formant_envelopeandWasmProcessor::formant_envelopeagainst the host Nyquist limit and write zero for points above half of the internal core rate whenhost_rate > core_rate.Processor::newandWasmProcessor::latency_frames), normalized JSDoc / generated TypeScript declarations,scripts/verify-pack.mjsresampled-rate smoke checks, and latency and formant envelope notes inREADME.md.Verification
i16andf32output,Feedback, andTelemetryagainstmain(8880205, including feat(events)!: add scalar parameter control events #61, feat!: add pitch fields to Telemetry and trim Wasm voice slices #104, ci: deny compiler and rustdoc warnings in scripts and docs #131, and build(cargo): bump the cargo group with 2 updates #139) across stereo, planar, mono-in-place,humanize,flex_tune,ParameterControl, multi-voice choir, harmony MIDI, formant analysis/synthesis, Punch, Warm, Alien, all sixReverbModevariants,drain,drain_mono, anddrain_f32.dry_mix = 1.0) matchProcessor::latency_frames()at8000(289),16000(554),22050(820),32000(1085),44100(1593),48000(1593),88200(3233),96000(3233),176400(6467), and192000(6467) Hz.Some(69.0)across integer rates from8000to192000Hz (including44056Hz), exactf32/i16resampled parity,Telemetry::period_samples == Feedback::period_samples, zero heap allocations during audio/feedback/telemetry/control-activity/formant-envelope/drain/reset calls, and block-size invariance across block sizes1to1024.formant_envelopeandformantEnvelopeacross16000,44100,48000,48001,88200,96000,176400, and192000Hz, confirming exact LPC magnitudes up to core Nyquist and exact zero-fill above core Nyquist without aliasing.Tunelet(Int16Array,Float32Array, andTuneletAudioViews) in Node.js andscripts/verify-pack.mjsacross valid (8000..=192000Hz) and invalid (0,4000,7999,192001,384000,44100.5,NaN,Infinity) rates.cargo fmt --check,cargo clippy --locked --lib -- -D warnings,RUSTFLAGS="-D warnings" cargo build --locked --release,RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps,cargo package --locked,npm run check:wasm,npm run verify:pack,npm run verify:pack -- --ignore-scripts, and MSRV1.88native/Wasm checks with zero warnings.Automated PR initiated by user @byteland-app via Stitch Loop.