Skip to content

fix(audio-context): Android audio-rate biquad and listener params, real convolution, oscillator frequency automation - #287

Merged
triniwiz merged 1 commit into
masterfrom
fix/android-audio-graph-params
Nov 25, 2026
Merged

triniwiz merged 1 commit into
masterfrom
fix/android-audio-graph-params

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Fixes the Android @nativescript/audio-context gaps that the audio specs skipped. All of the fixes are in the native graph (audio_graph.cpp) and its Java glue.

ConvolverNode convolves. It used to pass its input straight through. It now does uniformly partitioned FFT convolution with one 128-frame partition per quantum, so it adds no latency (convolver.cpp).

  • The response's spectra are built on the calling thread from the buffer's native channel memory and handed to the audio thread. Nothing goes through the Java heap.
  • normalize applies the spec's equal-power scale and is read when the buffer is set, as the spec says.
  • 1-, 2- and 4-channel (true-stereo) responses use Chromium's channel mapping. The output is mono only when both the input and the response are mono.
  • With no buffer, the node outputs silence. The node keeps ringing for the response's length after its input stops.

BiquadFilterNode params take audio and automation. frequency, Q, gain and detune are now gain-style params in the engine. Before, setValueAtTime and similar calls set the value immediately, and connected audio was ignored.

  • When the params hold one value for a quantum, coefficients are computed once for that quantum. When they vary (automation or connected audio), coefficients are computed every frame, as Chromium does.
  • The coefficients use the spec formulas, including Q in dB for lowpass and highpass, detune, and the edge cases at 0 Hz and Nyquist.

AudioListener params take audio. Audio connected to a listener param is summed into it every frame, and every panner in that context reads it.

OscillatorNode.frequency automation. Oscillator and constant-source ids were never tied to their context, so their setValueAtTime and ramp events were dropped. Audio connected to frequency was summed correctly, but the automated reference never changed, so the two drifted apart. Those events are now scheduled.

Realtime contexts going silent. The cause was not the splitter disconnect. createBufferSource() without a buffer fell back to opening a Java AudioTrack for each node. Those tracks leaked until AudioFlinger ran out (no more tracks available), and later realtime contexts then failed to open a stream (AAUDIO_ERROR_INTERNAL). A source created without a buffer now just gets an id in its context's engine.

Specs: the four Android skips are removed. New specs cover:

  • the convolver: an impulse plays the response, an arbitrary input against direct convolution, normalization on and off, a stereo response with a mono input, and silence with no buffer
  • audio connected to AudioListener.positionX against automation

Pixel 9 Pro emulator, audio suite: 66/66 passing.

…al convolution, oscillator frequency automation

- ConvolverNode convolves: uniformly partitioned FFT convolution a quantum per
  partition (no latency), built off the audio thread from the buffer's native
  channels; spec normalization honouring `normalize`; 1, 2 and 4-channel
  responses; silent with no buffer.
- BiquadFilterNode frequency, Q, gain and detune are gain-style params: they
  take automation and audio, and coefficients are computed per frame when they
  vary (spec formulas, lowpass/highpass Q in dB).
- AudioListener params take audio; every panner of the context reads it.
- Oscillator and constant source automation is scheduled against its context,
  so audio connected to OscillatorNode.frequency matches the automated value.
- createBufferSource() without a buffer no longer opens a Java AudioTrack per
  node; those leaked AudioFlinger tracks until later realtime contexts could
  not open a stream.
- Specs: Android skips removed; convolver and listener specs added.
@coderabbitai

coderabbitai Bot commented Nov 25, 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: ddc8343a-4736-44e5-a0f7-10235b99e0aa

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

@github-actions

Copy link
Copy Markdown

ℹ️ Note: npm publishing is disabled for pull requests.
Publishing is performed only from tag pushes via the npm Release workflow.
If you need a test publish, merge to master — pushes publish pr-tagged prereleases.

@triniwiz
triniwiz merged commit 04eb785 into master Nov 25, 2026
36 checks passed
@triniwiz
triniwiz deleted the fix/android-audio-graph-params branch November 25, 2026 11:04
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