Constructor
new SignalRecorder(options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Override default parameters. Properties
|
- Source:
- To Do:
-
- - add option to return only the Float32Array and not an audio buffer (node compliant) `retrieveAudioBuffer: false`
Example
import * as lfo from 'waves-lfo/client';
const audioContext = new AudioContext();
navigator.mediaDevices
.getUserMedia({ audio: true })
.then(init)
.catch((err) => console.error(err.stack));
function init(stream) {
const source = audioContext.createMediaStreamSource(stream);
const audioInNode = new lfo.source.AudioInNode({
sourceNode: source,
audioContext: audioContext,
});
const signalRecorder = new lfo.sink.SignalRecorder({
duration: 6,
retrieveAudioBuffer: true,
audioContext: audioContext,
callback: (buffer) => {
const bufferSource = audioContext.createBufferSource();
bufferSource.buffer = buffer;
bufferSource.connect(audioContext.destination);
bufferSource.start();
}
});
audioInNode.connect(signalRecorder);
audioInNode.start();
signalRecorder.start();
});
Methods
start()
Start recording.
- Source:
stop()
Stop recording and execute the callback defined in parameters.
- Source: