npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

audio-buffer-from

v1.1.1

Published

Create AudioBuffer from any source

Downloads

13,436

Readme

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 duration
var abuf6 = createBuffer({duration: 1})

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

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

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

//from node Buffer
var abuf10 = 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:

| Type | Interpretation | |---|---| | null | Blank 1-sample length buffer. | | Number | Length of resulting buffer. | | Array of Arrays | Every subarray is considered a channel data. | | AudioBuffer | Clone other AudioBuffer. | | AudioBufferList | Coalesce AudioBufferList to AudioBuffer. | | Audio | Retrieve AudioBuffer from Audio. | | Object | Create based on length/duration, channels/numberOfChannels and sampleRate properties. | | Array of Numbers | Raw data, interpreted by options.format, defaults to float64. | | Float32Array | Raw float32 data, amplitude range is -1..+1. | | Float64Array | Raw float64 data, amplitude range is -1..+1. | | Int8Array | Raw int8 data, amplitude range is -128..+127. | | Uint8Array | Raw uint8 data, amplitude range is 0..255. | | TypedArray | Any other typed array, described by options.format argument (see pcm-convert). | | ArrayBuffer | Raw data, interpreted by options.format. | | Buffer | Raw data, interpreted by options.format. | | base64 string | Base64-encoded data. | | dataURI string | DataURI string. | | ndarray | Create from ndarray instance. The shape property is considered as [length, channels]. | | ndsamples | Create from ndsamples instance, similar to ndarray. |

Options:

Property | Default | Meaning |---|---|--- length | 1 | Buffer length. If 0, buffer is unbound from context. context | audio-context | Audio context to bind. null-context creates context-free audio buffer. channels, numberOfChannels | 1 | Buffer number of channels. sampleRate, rate | 44100 | Buffer sample rate. format | null | Source pcm format string or object, see audio-format. If null, it will be detected from the source.

Related

License

© 2017 Dmitry Yv. MIT License