AudioBufferBaseSourceNode
The AudioBufferBaseSourceNode
interface is an AudioScheduledSourceNode
which aggregates behavior of nodes that requires AudioBuffer
.
Child classes:
Properties
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. |
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();
}