Skip to content

fix(audio-context): iOS realtime quanta, channel mixing, real DSP nodes and HRTF; Android per-context clocks and AudioParam.value - #290

Open
triniwiz wants to merge 10 commits into
masterfrom
feat/ios-audio-spec
Open

triniwiz wants to merge 10 commits into
masterfrom
feat/ios-audio-spec

Conversation

@triniwiz

@triniwiz triniwiz commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Fixes #64

Completes the Web Audio spec suite on iOS and closes the remaining gaps between iOS and Android in @nativescript/audio-context.

iOS

  • Spec coverage across the API, scheduling, offline rendering, DSP and worklet suites.
  • DynamicsCompressorNode now runs Chromium's DynamicsCompressorKernel in place of Apple's dynamics processor. It is the same algorithm as on Android: 6 ms look-ahead, knee curve and makeup gain, with reduction metered from the render.
  • AudioWorkletNode inputs now report computedNumberOfChannels on every quantum, following channelCount/channelCountMode/channelInterpretation. The constructor's channel options now reach the native node.

Android

  • Each context has its own clock and its own suspend. suspend() resolves only once the render thread has stopped that context's clock.
  • AudioParam.value is read from the render, and scheduling is measured against the next quantum.
  • MediaStream factories throw NotSupportedError.
  • Worklet inputs follow computedNumberOfChannels, and default to 'max' as the spec says.
  • The AAR is rebuilt for all ABIs.

Shared

  • createChannelMerger(n) and createChannelSplitter(n) accept a channel count, as the spec says; a bare number used to be read as an options object, giving the default 6 channels.
  • There is now one MIT KEMAR HRTF header, src-native/common/hrtf_kemar.h, with its licence note. The Android CMake build and the iOS plugin both compile it (iOS through build.xcconfig and a small .mm shim), and it is published with the package.
  • Specs: the compressor look-ahead spec runs on both platforms, and the androidTest helper is renamed nativeTest. New worklet channel-count cases, plus a per-context suspend spec: two realtime contexts are suspended and resumed independently, then all together.

Results: audio suite, iOS simulator 151/151, Android Pixel 9 Pro emulator 151/151.

…l DSP nodes and HRTF

- A realtime AudioContext renders its engine manually in 128-frame quanta, pulled by a separate
  output engine: it runs from construction at the requested sampleRate, currentTime counts its
  own frames from 0 (stop(currentTime + 0.02) now plays 20 ms), and a DelayNode in a cycle delays
  by one quantum, not one device buffer.
- Every node mixes its inputs per channelCount/channelCountMode/channelInterpretation with the
  spec's per-node limits, each output carries its real channel count, and the destination mixes
  with Web Audio's rules.
- Real ConvolverNode (partitioned FFT, ConvolverOptions.buffer/disableNormalization), IIRFilterNode,
  WaveShaperNode (curve, oversampling), StereoPannerNode, render-thread AnalyserNode, HRTF panning
  from the MIT KEMAR set, band-limited and custom oscillator waves, loopStart/loopEnd.
- AudioParam: exponential ramps, setTargetAtTime, value curves and cancelAndHold natively; value
  reads the automated value; argument checks. A split DelayNode heals when its cycle is broken.
- Spec validation across nodes and contexts, getOutputTimestamp, MediaStream stubs, typings.
…l DSP nodes and HRTF

- A realtime AudioContext renders its engine manually in 128-frame quanta, pulled by a separate
  output engine: it runs from construction at the requested sampleRate, currentTime counts its
  own frames from 0 (stop(currentTime + 0.02) now plays 20 ms), and a DelayNode in a cycle delays
  by one quantum, not one device buffer.
- Every node mixes its inputs per channelCount/channelCountMode/channelInterpretation with the
  spec's per-node limits, each output carries its real channel count, and the destination mixes
  with Web Audio's rules.
- Real ConvolverNode (partitioned FFT, ConvolverOptions.buffer/disableNormalization), IIRFilterNode,
  WaveShaperNode (curve, oversampling), StereoPannerNode, render-thread AnalyserNode, HRTF panning
  from the MIT KEMAR set, band-limited and custom oscillator waves, loopStart/loopEnd.
- AudioParam: exponential ramps, setTargetAtTime, value curves and cancelAndHold natively; value
  reads the automated value; argument checks. A split DelayNode heals when its cycle is broken.
- Spec validation across nodes and contexts, getOutputTimestamp, MediaStream stubs, typings.
…dioContext complete, enable shared specs on iOS
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1883bd0-2c8a-4f54-919d-ba391f6ee666

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…rror

index.d.ts declares createMediaStreamSource/TrackSource/Destination; Android lacked them, so the shared spec got a TypeError.
…m.value from the render, scheduling against the next quantum

- currentTime now reports the next quantum to render (published per quantum) instead of the
  start of the last callback, so start()/stop(currentTime + x) no longer land in audio that was
  already rendered; short stops after an immediate start play their full length.
- Each realtime context has its own clock (render clock less time spent suspended). It starts
  at 0 on the first quantum rendered after construction; suspend()/resume() stop and restart
  only that context's nodes and clock, and the stream stops once every context is suspended.
  A closed context's clock stops.
- AudioParam.value returns the value the last rendered quantum gave (automation plus connected
  audio), or a value set since, via the nativeComputedValue hook.
@triniwiz triniwiz changed the title fix(audio-context): iOS realtime quanta, per-node channel mixing, real DSP nodes and HRTF fix(audio-context): iOS realtime quanta, channel mixing, real DSP nodes and HRTF; Android per-context clocks and AudioParam.value Nov 26, 2026
…Channels, shared KEMAR set, per-context suspend spec

- iOS DynamicsCompressorNode renders Chromium's DynamicsCompressorKernel (as on
  Android) in the param effect unit: 6 ms look-ahead, knee curve, makeup gain,
  reduction metered from the render. Replaces Apple's dynamics processor.
- AudioWorkletNode inputs carry computedNumberOfChannels per quantum from
  channelCount/channelCountMode on iOS and Android; constructor channel options
  now reach the native node.
- One MIT KEMAR header in src-native/common, compiled by the Android CMake build
  and the iOS plugin (via build.xcconfig); the iOS copy is gone.
- Specs: compressor look-ahead on both platforms, androidTest renamed nativeTest,
  worklet channel-count cases, two realtime contexts suspended/resumed apart.
…stops the clock; worklet inputs default to 'max'
…channel count, as the spec says

A number was read as an options object, so createChannelMerger(2) built the
default 6-input merger. Both forms are accepted now.

This branch has not been deployed

No deployments
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