Skip to content
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d74dee6
feat: gain impl
mdydek Nov 13, 2025
62ae75f
feat: better consistency
mdydek Nov 13, 2025
5790ce5
docs: docs proposition
mdydek Nov 14, 2025
4fd5487
feat: stereo panner options
mdydek Nov 16, 2025
5d7cc69
feat: added web
mdydek Nov 16, 2025
add1958
feat: convolver options
mdydek Nov 16, 2025
022683b
test: tests
mdydek Nov 17, 2025
0a539d1
feat: constant source options
mdydek Nov 17, 2025
a90f428
Merge branch 'main' into feat/audio-node-options-in-ctor
mdydek Nov 18, 2025
a052c45
feat: web for convolver
mdydek Nov 18, 2025
a47447b
feat: periodic wave
mdydek Nov 19, 2025
1aa6443
feat: analyser node
mdydek Nov 19, 2025
3b0b1b7
feat: biquad filter
mdydek Nov 19, 2025
1dcdaa6
feat: oscillator
mdydek Nov 20, 2025
1f62ba8
feat: mobile audio buffer sources
mdydek Nov 24, 2025
f80292a
feat: streamer node options
mdydek Nov 26, 2025
67df87d
feat: recorder adapter
mdydek Nov 26, 2025
617188a
feat: worklets
mdydek Dec 2, 2025
0a6f8d8
feat: audiobuffer
mdydek Dec 2, 2025
f074c12
feat: audiobuffer on web
mdydek Dec 2, 2025
4617720
docs: documentation for new constructors
mdydek Dec 2, 2025
002b5c3
feat: absn on web
mdydek Dec 3, 2025
25c9327
Merge branch 'main' into feat/audio-node-options-in-ctor
mdydek Dec 3, 2025
829c019
feat: delay node
mdydek Dec 3, 2025
2c6a512
feat: iirfilter
mdydek Dec 3, 2025
e487709
test: test fix
mdydek Dec 3, 2025
bf1ad3d
feat: better absn for web
mdydek Dec 3, 2025
5632d68
feat: reverted pitch correction option in factory method for absn
mdydek Dec 3, 2025
97eb239
feat: slowly removing shared ptr in options
mdydek Dec 4, 2025
7a99505
feat: removed options as shared ptr
mdydek Dec 4, 2025
b19e1fd
test: test fix
mdydek Dec 4, 2025
e12c3da
feat: changes after review
mdydek Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/common-app/src/examples/AudioFile/AudioPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class AudioPlayer {
await this.audioContext.resume();
}

this.sourceNode = this.audioContext.createBufferSource({
pitchCorrection: true,
});
this.sourceNode = this.audioContext.createBufferSource(true);
this.sourceNode.buffer = this.audioBuffer;
this.sourceNode.playbackRate.value = this.playbackRate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ const AudioVisualizer: React.FC = () => {
}

if (!analyserRef.current) {
analyserRef.current = audioContextRef.current.createAnalyser();
analyserRef.current.fftSize = FFT_SIZE;
analyserRef.current.smoothingTimeConstant = 0.2;

analyserRef.current = new AnalyserNode(audioContextRef.current, { fftSize: FFT_SIZE, smoothingTimeConstant: 0.2 });
analyserRef.current.connect(audioContextRef.current.destination);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: c5c4f5280e4ae0f9f4a739c64c4260fe0b3edaf1
ReactCodegen: 096bbbb2498ca55f385e2fbd465bfa0211ee8295
ReactCommon: 25c7f94aee74ddd93a8287756a8ac0830a309544
RNAudioAPI: c763dbacdb8d89b7ce829484306df54322a7d951
RNAudioAPI: c7dc7b491a0e4b23535a55fd9b4a00d0f803f4bb
RNGestureHandler: f1dd7f92a0faa2868a919ab53bb9d66eb4ebfcf5
RNReanimated: e4993dd98196c698cbacc1441a4ac5b855ae56dc
RNScreens: d821082c6dd1cb397cc0c98b026eeafaa68be479
Expand Down
24 changes: 18 additions & 6 deletions packages/audiodocs/docs/analysis/analyser-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 1
---

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
import { ReadOnly } from '@site/src/components/Badges';
import { Optional, ReadOnly } from '@site/src/components/Badges';

# AnalyserNode

Expand All @@ -23,7 +23,23 @@ In contrast, a frequency-domain graph reveals how the signal's energy or power i

## Constructor

[`BaseAudioContext.createAnalyser()`](/docs/core/base-audio-context#createanalyser)
```tsx
constructor(context: BaseAudioContext, options?: AnalyserOptions)
```

### `AnalyserOptions`

Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions)

| Parameter | Type | Default | |
| :---: | :---: | :----: | :---- |
| `fftSize` <Optional /> | `number` | 2048 | Number representing size of fast fourier transform |
| `minDecibels` <Optional /> | `number` | -100 | Initial minimum power in dB for FFT analysis |
| `maxDecibels` <Optional /> | `number` | -30 | Initial maximum power in dB for FFT analysis |
| `smoothingTimeConstant` <Optional /> | `number` | 0.8 | Initial smoothing constant for the FFT analysis |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createAnalyser()`](/docs/core/base-audio-context#createanalyser) that creates node with default values.

## Properties

Expand Down Expand Up @@ -95,24 +111,20 @@ Each value in the array is within the range 0 to 255, where value of 127 indicat
## Remarks

#### `fftSize`
- Default value is 2048.
- Must be a power of 2 between 32 and 32768.
- Throws `IndexSizeError` if set value is not power of 2, or is outside the allowed range.

#### `minDecibels`
- Default value is -100 dB.
- 0 dB([decibel](https://en.wikipedia.org/wiki/Decibel)) is the loudest possible sound, -10 dB is a 10th of that.
- When getting data from [`getByteFrequencyData()`](/docs/analysis/analyser-node#getbytefrequencydata), any frequency with amplitude lower then `minDecibels` will be returned as 0.
- Throws `IndexSizeError` if set value is greater than or equal to `maxDecibels`.

#### `maxDecibels`
- Default value is -30 dB.
- 0 dB([decibel](https://en.wikipedia.org/wiki/Decibel)) is the loudest possible sound, -10 dB is a 10th of that.
- When getting data from [`getByteFrequencyData()`](/docs/analysis/analyser-node#getbytefrequencydata), any frequency with amplitude higher then `maxDecibels` will be returned as 255.
- Throws `IndexSizeError` if set value is less then or equal to `minDecibels`.

#### `smoothingTimeConstant`
- Default value is 0.8.
- Nominal range is 0 to 1.
- 0 means no averaging, 1 means "overlap the previous and current buffer quite a lot while computing the value".
- Throws `IndexSizeError` if set value is outside the allowed range.
Expand Down
12 changes: 12 additions & 0 deletions packages/audiodocs/docs/core/audio-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ If no arguments provided node disconnects from all outgoing connections.

#### Returns `undefined`.

### `AudioNodeOptions`

It is used to constructing majority of all `AudioNodes`.

| Parameter | Type | Default | Description |
| :---: | :---: | :----: | :---- |
| `channelCount` <Optional /> | `number` | 2 | Indicates number of channels used in mixing of node. |
| `channelCountMode` <Optional /> | [`ChannelCountMode`](/docs/types/channel-count-mode) | `max` | Determines how the number of input channels affects the number of output channels in an audio node. |
| `channelInterpretation` <Optional /> | [`ChannelInterpretation`](/docs/types/channel-interpretation) | `speakers` | Specifies how input channels are mapped out to output channels when the number of them are different. |

If any of these values are not provided, default values are used.

## Remarks

#### `numberOfInputs`
Expand Down
25 changes: 2 additions & 23 deletions packages/audiodocs/docs/core/base-audio-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Creates [`AudioBufferSourceNode`](/docs/sources/audio-buffer-source-node).

| Parameter | Type | Description |
| :---: | :---: | :---- |
| `options` <Optional /> | [`AudioBufferBaseSourceNodeOptions`](/docs/sources/audio-buffer-source-node#constructor) | Dictionary object that specifies if pitch correction has to be available. |
| `pitchCorrection` <Optional /> | `boolean` | Boolean that specifies if pitch correction has to be available. |

#### Returns `AudioBufferSourceNode`.

Expand All @@ -94,7 +94,7 @@ Creates [`AudioBufferQueueSourceNode`](/docs/sources/audio-buffer-queue-source-n

| Parameter | Type | Description |
| :---: | :---: | :---- |
| `options` <Optional /> | [`AudioBufferBaseSourceNodeOptions`](/docs/sources/audio-buffer-queue-source-node#constructor) | Dictionary object that specifies if pitch correction has to be available. |
| `pitchCorrection` <Optional /> | `boolean` | Boolean that specifies if pitch correction has to be available. |

#### Returns `AudioBufferQueueSourceNode`.

Expand All @@ -108,16 +108,6 @@ Creates [`ConstantSourceNode`](/docs/sources/constant-source-node).

Creates [`ConvolverNode`](/docs/effects/convolver-node).

| Parameter | Type | Description |
| :---: | :---: | :---- |
| `options` <Optional /> | [`ConvolverNodeOptions`](/docs/effects/convolver-node#constructor) | Dictionary object that specifies associated buffer and normalization. |

#### Errors

| Error type | Description |
| :---: | :---- |
| `NotSupportedError` | `numOfChannels` of buffer is not 1, 2 or 4. |

#### Returns `ConvolverNode`.

### `createDelay`
Expand All @@ -140,17 +130,6 @@ Creates [`GainNode`](/docs/effects/gain-node).

Creates [`IIRFilterNode`](/docs/effects/iir-filter-node).

| Parameter | Type | Description |
| :---: | :---: | :---- |
| `options` | [`IIRFilterNodeOptions`](/docs/effects/iir-filter-node#constructor) | Dictionary object that specifies the feedforward (numerator) and feedback (denominator) coefficients for the transfer function of the IIR filter. |

#### Errors

| Error type | Description |
| :---: | :---- |
| `NotSupportedError` | One or both of the input arrays exceeds 20 members. |
| `InvalidStateError` | All of the feedforward coefficients are 0, or the first feedback coefficient is 0. |

#### Returns `IIRFilterNode`.

### `createOscillator`
Expand Down
30 changes: 19 additions & 11 deletions packages/audiodocs/docs/effects/biquad-filter-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 1
---

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
import { ReadOnly } from '@site/src/components/Badges';
import { Optional, ReadOnly } from '@site/src/components/Badges';
import InteractiveExample from '@site/src/components/InteractiveExample';
import AudioApiExample from '@site/src/components/AudioApiExample'
import VinylPlayer from '@site/src/components/RecordPlayerExample/VinylAnimation';
Expand All @@ -23,7 +23,24 @@ Multiple `BiquadFilterNode` instances can be combined to create more complex fil

## Constructor

[`BaseAudioContext.createBiquadFilter()`](/docs/core/base-audio-context#createbiquadfilter)
```tsx
constructor(context: BaseAudioContext, options?: BiquadFilterOptions)
```

### `BiquadFilterOptions`

Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions)

| Parameter | Type | Default | |
| :---: | :---: | :----: | :---- |
| `Q` <Optional /> | `number` | 1 | Initial value for [`Q`](/docs/effects/biquad-filter-node#properties) |
| `detune` <Optional /> | `number` | 0 | Initial value for [`detune`](/docs/effects/biquad-filter-node#properties) |
| `frequency` <Optional /> | `number` | 350 | Initial value for [`frequency`](/docs/effects/biquad-filter-node#properties) |
| `gain` <Optional /> | `number` | 0 | Initial value for [`gain`](/docs/effects/biquad-filter-node#properties) |
| `type` <Optional /> | `BiquadFilterType` | `lowpass` | Initial value for [`type`](/docs/effects/biquad-filter-node#properties) |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createBiquadFilter()`](/docs/core/base-audio-context#createbiquadfilter) that creates node with default values.

## Properties

Expand Down Expand Up @@ -72,24 +89,15 @@ It inherits all methods from [`AudioNode`](/docs/core/audio-node#methods).
## Remarks

#### `frequency`
- Float. Default: 350.
- Range: [10, $\frac{sampleRate}{2}$].

#### `detune`
- Float. Default: 0.

#### `Q`
- Float. Default: 1.
- Range:
- For `lowpass` and `highpass` is [-Q, Q], where Q is the largest value for which $10^{Q/20}$ does not overflow the single-precision floating-point representation.
Numerically: Q ≈ 770.63678.
- For `bandpass`, `notch`, `allpass`, and `peaking`: Q is related to the filter’s bandwidth and should be positive.
- Not used for `lowshelf` and `highshelf`.

#### `gain`
- Float. Default: 0.
- Range: [-40, 40].
- Positive values correspond to amplification; negative to attenuation.

#### `type`
- [`BiquadFilterType`](#biquadfiltertype-enumeration-description). Default: `"lowpass"`.
29 changes: 21 additions & 8 deletions packages/audiodocs/docs/effects/convolver-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sidebar_position: 2
---

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
import { Optional } from '@site/src/components/Badges';

# ConvolverNode

Expand All @@ -19,18 +20,30 @@ Convolver is a node with tail-time, which means, that it continues to output non

## Constructor

[`BaseAudioContext.createConvolver(options: ConvolverNodeOptions)`](/docs/core/base-audio-context#createconvolver)

```jsx
interface ConvolverNodeOptions {
buffer?: AudioBuffer | null; // impulse response
disableNormalization?: boolean; // if normalization of output should be applied, true by default
}
```tsx
constructor(context: BaseAudioContext, options?: ConvolverOptions)
```

### `ConvolverOptions`

Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions)

| Parameter | Type | Default | |
| :---: | :---: | :----: | :---- |
| `buffer` <Optional /> | `number` | | Initial value for [`buffer`](/docs/effects/convolver-node#properties). |
| `normalize` <Optional /> | `boolean` | true | Initial value for [`normalize`](/docs/effects/convolver-node#properties). |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createConvolver()`](/docs/core/base-audio-context#createconvolver)

## Properties

It inherits all properties from [`AudioNode`](/docs/core/audio-node#properties) and has no individual ones.
It inherits all properties from [`AudioNode`](/docs/core/audio-node#properties).

| Name | Type | Description |
| :----: | :----: | :-------- |
| `buffer` | [`AudioBuffer`](/docs/sources/audio-buffer) | Associated AudioBuffer. |
| `normalize` | `boolean` | Whether the impulse response from the buffer will be scaled by an equal-power normalization when the buffer attribute is set. |

:::caution
Linear convolution is a heavy computational process, so if your audio has some weird artefacts that should not be there, try to decrease the duration of impulse response buffer.
Expand Down
18 changes: 15 additions & 3 deletions packages/audiodocs/docs/effects/gain-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 3
---

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
import { ReadOnly } from '@site/src/components/Badges';
import { Optional, ReadOnly } from '@site/src/components/Badges';
import { useGainAdsrPlayground } from '@site/src/components/InteractivePlayground/GainAdsrExample/useGainAdsrPlayground';
import InteractivePlayground from '@site/src/components/InteractivePlayground';

Expand Down Expand Up @@ -43,7 +43,20 @@ You can read more about envelopes and ADSR on [Wikipedia](<https://en.wikipedia.

## Constructor

[`BaseAudioContext.createGain()`](/docs/core/base-audio-context#creategain)
```tsx
constructor(context: BaseAudioContext, options?: GainOptions)
```

### `GainOptions`

Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions)

| Parameter | Type | Default | |
| :---: | :---: | :----: | :---- |
| `gain` <Optional /> | `number` | 1.0 | Initial value for [`gain`](/docs/effects/gain-node#properties) |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createGain()`](/docs/core/base-audio-context#creategain) that creates node with default values.

## Properties

Expand All @@ -61,5 +74,4 @@ It inherits all methods from [`AudioNode`](/docs/core/audio-node#methods).
## Remarks

#### `gain`
- Default value is 1.0.
- Nominal range is -∞ to ∞.
7 changes: 7 additions & 0 deletions packages/audiodocs/docs/effects/iir-filter-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ interface IIRFilterNodeOptions {
}
```

#### Errors

| Error type | Description |
| :---: | :---- |
| `NotSupportedError` | One or both of the input arrays exceeds 20 members. |
| `InvalidStateError` | All of the feedforward coefficients are 0, or the first feedback coefficient is 0. |

## Properties
It inherits all properties from [`AudioNode`](/docs/core/audio-node#properties).

Expand Down
29 changes: 22 additions & 7 deletions packages/audiodocs/docs/effects/periodic-wave.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@
sidebar_position: 5
---

import { Optional } from '@site/src/components/Badges';

# PeriodicWave

The `PeriodicWave` interface defines a periodic waveform that can be used to shape the output of an OscillatorNode.

## Constructor

[`BaseAudioContext.createPeriodicWave(real, imag)`](/docs/core/base-audio-context#createperiodicwave)
```tsx
constructor(context: BaseAudioContext, options: PeriodicWaveOptions)
```

[`BaseAudioContext.createPeriodicWave(real, imag, constraints: PeriodicWaveConstraints)`](/docs/core/base-audio-context#createperiodicwave)
### `PeriodicWaveOptions`

```jsx
interface PeriodicWaveConstraints {
disableNormalization: boolean; // default set to false (normalization is enabled)
}
```
| Parameter | Type | Default | Description |
| :---: | :---: | :----: | :---- |
| `real` <Optional /> | `Float32Array` | - | [Cosine terms](/docs/core/base-audio-context#createperiodicwave) |
| `imag` <Optional /> | `Float32Array` | - | [Sine terms](/docs/core/base-audio-context#createperiodicwave) |
| `disableNormalization` | `boolean` | false | Whether the periodic wave is [normalized](/docs/core/base-audio-context#createperiodicwave) or not. |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createPeriodicWave(real, imag, constraints?: PeriodicWaveConstraints)`](/docs/core/base-audio-context#createperiodicwave)

## Properties
None. `PeriodicWave` has no own or inherited properties.

## Methods
None. `PeriodicWave` has no own or inherited methods.

## Remarks

#### `real` and `imag`
- if only one is specified, the other one is treated as array of 0s of the same length
- if neither is given values are equivalent to the sine wave
- if both given, they have to have the same length
- to see how values corresponds to the output wave [see](https://webaudio.github.io/web-audio-api/#waveform-generation) for more information
15 changes: 14 additions & 1 deletion packages/audiodocs/docs/effects/stereo-panner-node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 6
---

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable"
import { ReadOnly } from '@site/src/components/Badges';
import { Optional, ReadOnly } from '@site/src/components/Badges';

# StereoPannerNode

Expand All @@ -15,6 +15,19 @@ The `StereoPannerNode` interface represents the change in ratio between two outp

## Constructor

```tsx
constructor(context: BaseAudioContext, stereoPannerOptions?: StereoPannerOptions)
```

### `StereoPannerOptions`

Inherits all properties from [`AudioNodeOptions`](/docs/core/audio-node#audionodeoptions)

| Parameter | Type | Default | Description |
| :---: | :---: | :----: | :---- |
| `pan` <Optional /> | `number` | 0.0 | Number representing pan value |

Or by using `BaseAudioContext` factory method:
[`BaseAudioContext.createStereoPanner()`](/docs/core/base-audio-context#createstereopanner)

## Properties
Expand Down
Loading