Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

audio-buffer-from

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-buffer-from

Create AudioBuffer from any source

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-39.48%
Maintainers
2
Weekly downloads
 
Created
Source

audio-buffer-from Build Status unstable Greenkeeper badge

Create AudioBuffer from any source.

Usage

$ npm install audio-buffer-from

var createBuffer = require('audio-buffer-from')

//mono-buffer 1024 samples
var abuf = createBuffer(1024)

//stereo-buffer 1024 samples
var abuf2 = createBuffer(1024, 2)

//buffer from data with bound audio context
var abuf3 = createBuffer(floatArray, {context: audioContext})

//empty 1-sample mono buffer with default context
var abuf4 = createBuffer()

//0-length no-context buffer
var abuf5 = createBuffer(0)

//from pcm data
var abuf6 = createBuffer(new Uint8Array([0, 0, 255, 255]), 'interleaved 96000')

//from data-uri
var abuf7 = createBuffer('data:application/octet-stream;base64,AP8A/w==', 'uint8')

//from base64 string
var abuf7 = createBuffer('AAAAAAAAAAAAAIA/AACAPw==', 'float32 stereo planar')

//from node Buffer
var abuf8 = createBuffer(Buffer.from([0, 255, 0, 127]), 'interleaved')

API

audioBuffer = createBuffer(source|length, channels|format|options)

Create audio buffer from any source data or a number indicating length, pass options to ensure output buffer parameters. A channels number or format string can be used to shorthand options argument.

Source:
TypeInterpretation
nullBlank 1-sample length buffer.
NumberLength of resulting buffer.
Array of ArraysEvery subarray is considered a channel data.
AudioBufferClone other AudioBuffer.
ObjectCreate based on length, channels/numberOfChannels and sampleRate properties.
Array of NumbersRaw data, interpreted by options.format, defaults to float64.
Float32ArrayRaw float32 data, amplitude range is -1..+1.
Float64ArrayRaw float64 data, amplitude range is -1..+1.
Int8ArrayRaw int8 data, amplitude range is -128..+127.
Uint8ArrayRaw uint8 data, amplitude range is 0..255.
TypedArrayAny other typed array, described by options.format argument (see pcm-convert).
ArrayBufferRaw data, interpreted by options.format.
BufferRaw data, interpreted by options.format.
base64 stringBase64-encoded data.
dataURI stringDataURI string.
ndarrayCreate from ndarray instance. The shape property is considered as [length, channels].
ndsamplesCreate from ndsamples instance, similar to ndarray.
Options:
PropertyDefaultMeaning
length1Buffer length. If 0, buffer is unbound from context.
contextaudio-contextAudio context to bind. null-context creates context-free audio buffer.
channels, numberOfChannels1Buffer number of channels.
sampleRate44100Buffer sample rate.
formatnullSource pcm format string or object, see audio-format. If null, it will be detected from the source.

License

© 2017 Dima Yv. MIT License

Keywords

FAQs

Package last updated on 28 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc