AudioBufferBaseSourceNode
The AudioBufferBaseSourceNode interface is an AudioScheduledSourceNode which aggregates behavior of nodes that requires AudioBuffer.
Child classes:
Properties
It inherits all properties from AudioScheduledSourceNode.
| Name | Type | Description |
|---|---|---|
detune | AudioParam | k-rate AudioParam representing detuning of oscillation in cents. |
playbackRate | AudioParam | k-rate AudioParam defining speed factor at which the audio will be played. |
Methods
AudioBufferBaseSourceNode does not define any additional methods.
It inherits all methods from AudioScheduledSourceNode.
Events
onPositionChanged Mobile only
Allow to set (or remove) callback that will be fired after processing certain part of an audio.
Frequency is defined by onPositionChangedInterval. By setting this callback you can achieve pause functionality.
You can remove callback by passing null.
onPositionChangedInterval Mobile only
Allow to set frequency for onPositionChanged event. Value that can be set is around 1000/x Hz.
import { AudioContext, AudioBufferSourceNode } from 'react-native-audio-api';
function App() {
const ctx = new AudioContext();
const sourceNode = ctx.createBufferSource();
sourceNode.buffer = null; //set your buffer
let offset = 0;
sourceNode.onPositionChanged = (event) => { //setting callback
this.offset = event.value;
};
sourceNode.onPositionChangedInterval = 100; //setting frequency to ~10Hz
sourceNode.start();
}
Remarks
detune
- Default value is 0.0.
- Nominal range is -∞ to ∞.
- For example value of 100 detune the source up by one semitone, whereas -1200 down by one octave.
- When
createBufferSource(true)it is clamped to range -1200 to 1200.
playbackRate
- Default value is 1.0.
- Nominal range is -∞ to ∞.
- For example value of 1.0 plays audio at normal speed, whereas value of 2.0 plays audio twice as fast as normal speed.
- When created with
createBufferSource(true)it is clamped to range 0 to 3 and uses pitch correction algorithm.