Skip to content

audiojs/audio-buffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 19, 2025
841a73a · Jan 19, 2025
Jan 28, 2023
Apr 12, 2017
Dec 18, 2015
Aug 28, 2016
Nov 7, 2016
Jan 26, 2018
May 22, 2017
Jan 28, 2023
Jan 28, 2023
Jan 28, 2023
Jan 29, 2023
Jan 19, 2025
Jan 28, 2023

Repository files navigation

audio-buffer test stable

AudioBuffer - basic audio data container class with planar float32 data layout.

Useful instead of Buffer in audio streams, audio components, workers, nodejs, environments without web-audio-api. Enables various audio-buffer utils outside of audio contexts or browsers.

Implementation is compatible with Web Audio API AudioBuffer, can be used as ponyfill.

Usage

npm install audio-buffer

new AudioBuffer(options)

Create audio buffer from options.

  • options.length — number of samples, minimum is 1.
  • options.sampleRate — sample rate from 3000..768000 range.
  • options.numberOfChannels (optional) — default number of channels is 1.

buffer.duration

Duration of the underlying audio data, in seconds.

buffer.length

Number of samples per channel.

buffer.sampleRate

Default sample rate is 44100.

buffer.numberOfChannels

Default number of channels is 1.

buffer.getChannelData(channel)

Get array containing the data for the channel (not copied).

buffer.copyFromChannel(destination, channelNumber, startInChannel=0)

Place data from channel to destination Float32Array.

buffer.copyToChannel(source, channelNumber, startInChannel=0)

Place data from source Float32Array to the channel.

Similar

  • ndsamples — audio-wrapper for ndarrays. A somewhat alternative approach to wrap audio data, based on ndarrays, used by some modules in livejs.
  • 1, 2, 3, 4 — other AudioBuffer implementations.
  • audiodata alternative data holder from @mohayonao.

🕉