Class: MediaElementAudioStream

MediaElementAudioStream

new MediaElementAudioStream(element, optionsopt)

Extracts audio from an <audio> or <video> element and provides it as a Node.js Readable stream

Parameters:
Name Type Attributes Description
element HTMLMediaElement | string

<audio> or <video> element or CSS selector

options Object <optional>

options

Properties
Name Type Attributes Default Description
bufferSize Number | null <optional>
null

buffer size - Mozilla docs recommend leaving this unset for optimal performance

muteSource Boolean <optional>
false

If true, the audio will not be sent back to the source

objectMode Boolean <optional>
true

emit AudioBuffers w/ the audio + a bit of metadata instead of Node.js Buffers with audio only

Source:
See:

Methods

(static) toRaw(chunk) → {Float32Array}

Converts a Buffer back into the raw Float32Array format that browsers use. Note: this is just a new DataView for the same underlying buffer - the actual audio data is not copied or changed here.

Parameters:
Name Type Description
chunk Buffer

node-style buffer of audio data from a 'data' event or read() call

Source:
Returns:

raw 32-bit float data view of audio data

Type
Float32Array

(inner) connect()

Setup script processor to extract audio and also re-connect it via a no-op gain node if desired

Delayed to avoid processing the stream of silence received before the file begins playing

Source:

(inner) processAudio(e)

Convert and emit the raw audio data

Parameters:
Name Type Description
e AudioProcessingEvent

https://developer.mozilla.org/en-US/docs/Web/API/AudioProcessingEvent

Source:
See: