Skip to content

Gain Node Gain Modulation #364

@bertrandmc

Description

@bertrandmc

Feature Request

I would like to request the ability to modulate the gain parameter of the GainNode within the react-native-audio-api, specifically by connecting an OscillatorNode directly to the gain parameter.

In the Web Audio API, it's possible to connect an OscillatorNode directly to an AudioParam, such as the gain parameter of a GainNode. This allows for powerful and efficient modulation of audio parameters, creating effects like tremolo, vibrato, and complex envelope followers.

const context = new AudioContext();

const gainNode = context.createGain();
gainNode.connect(context.destination);

const oscillator = context.createOscillator();
oscillator.type = "square";
oscillator.frequency.setValueAtTime(440, context.currentTime);
oscillator.connect(gainNode);
oscillator.start();

const lfo = context.createOscillator();
lfo.frequency.setValueAtTime(1, context.currentTime);
lfo.connect(gainNode.gain);
lfo.start(0);

Currently, when I try to connect the lfo to the gainNode's gain parameter, react-native-audio-api throws an error because connect method does not expect an AudioParam.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions