{"_id":"audio-buffer-from","_rev":"4208875","name":"audio-buffer-from","description":"Create AudioBuffer from any source","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"time":{"modified":"2026-03-04T17:04:40.000Z","created":"2017-06-28T03:08:51.816Z","1.1.1":"2018-01-06T16:22:07.970Z","1.1.0":"2017-12-26T08:11:38.633Z","1.0.3":"2017-07-01T03:25:09.955Z","1.0.2":"2017-06-28T03:37:07.841Z","1.0.1":"2017-06-28T03:34:28.504Z","1.0.0":"2017-06-28T03:08:51.816Z"},"users":{},"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"versions":{"1.1.1":{"name":"audio-buffer-from","version":"1.1.1","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","create audio buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.4","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.6.0","pick-by-alias":"^1.2.0","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","atob-lite":"^2.0.0","audio-buffer-list":"^4.1.0","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","object-assign":"^4.1.1","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"22e6f38983aff8e78727e9aebd78bc8d69f4019a","_id":"audio-buffer-from@1.1.1","_npmVersion":"5.6.0","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"6ba1dd0d463ce19e7ba19f91f5e1f725178d38d8","size":6176,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.1.1.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.1.1.tgz_1515255727124_0.6516106994822621"},"directories":{},"publish_time":1515255727970,"_hasShrinkwrap":false,"_cnpm_publish_time":1515255727970,"_cnpmcore_publish_time":"2021-12-17T02:54:54.619Z"},"1.1.0":{"name":"audio-buffer-from","version":"1.1.0","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","create audio buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.1","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.6.0","pick-by-alias":"^1.2.0","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","atob-lite":"^2.0.0","audio-buffer-list":"^4.1.0","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","object-assign":"^4.1.1","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"6693405fa55715612c51c8584618eb153cb194fe","_id":"audio-buffer-from@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"037ec80364babceb3dc26f3b19b61018bafba179","size":6155,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.1.0.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.1.0.tgz_1514275897652_0.13098835735581815"},"directories":{},"publish_time":1514275898633,"_hasShrinkwrap":false,"_cnpm_publish_time":1514275898633,"_cnpmcore_publish_time":"2021-12-17T02:54:54.879Z"},"1.0.3":{"name":"audio-buffer-from","version":"1.0.3","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","create audio buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.1","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.6.0","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","atob-lite":"^2.0.0","audio-buffer-list":"^3.2.1","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","object-assign":"^4.1.1","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"9caa5ab79d3d8fa1ec1b8769e11a37013d152902","_id":"audio-buffer-from@1.0.3","_shasum":"b0c9ff1fd7b4a73180204a0befaf16fb7fc80561","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"b0c9ff1fd7b4a73180204a0befaf16fb7fc80561","size":5416,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.0.3.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.0.3.tgz_1498879509031_0.8583586779423058"},"directories":{},"publish_time":1498879509955,"_hasShrinkwrap":false,"_cnpm_publish_time":1498879509955,"_cnpmcore_publish_time":"2021-12-17T02:54:55.118Z"},"1.0.2":{"name":"audio-buffer-from","version":"1.0.2","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.1","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.5.1","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","object-assign":"^4.1.1","atob-lite":"^2.0.0","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"e241a8d168ca4bc88c4c5804209e0446bc7d7bd2","_id":"audio-buffer-from@1.0.2","_shasum":"931a6ac5e919b202e9f5e70c279f762df90977f8","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"931a6ac5e919b202e9f5e70c279f762df90977f8","size":5228,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.0.2.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.0.2.tgz_1498621026936_0.5869165870826691"},"directories":{},"publish_time":1498621027841,"_hasShrinkwrap":false,"_cnpm_publish_time":1498621027841,"_cnpmcore_publish_time":"2021-12-17T02:54:55.453Z"},"1.0.1":{"name":"audio-buffer-from","version":"1.0.1","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.1","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.5.1","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","object-assign":"^4.1.1","atob-lite":"^2.0.0","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"1cdfc8f91b496e89cf4623d92aff51e0cb2f03e9","_id":"audio-buffer-from@1.0.1","_shasum":"0bdb9185379d0720c720956490c34dbc16f87a19","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"0bdb9185379d0720c720956490c34dbc16f87a19","size":5148,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.0.1.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.0.1.tgz_1498620867478_0.607921072980389"},"directories":{},"publish_time":1498620868504,"_hasShrinkwrap":false,"_cnpm_publish_time":1498620868504,"_cnpmcore_publish_time":"2021-12-17T02:54:55.637Z"},"1.0.0":{"name":"audio-buffer-from","version":"1.0.0","description":"Create AudioBuffer from any source","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/audiojs/audio-buffer-from.git"},"keywords":["audio","audiojs","dsp","web-audio-api","audio-buffer","pcm"],"author":{"name":"Dima Yv","email":"df.creative@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","dependencies":{"audio-buffer":"^4.0.1","audio-context":"^1.0.1","audio-format":"^2.0.0","is-audio-buffer":"^1.0.11","is-plain-obj":"^1.1.0","pcm-convert":"^1.5.1","string-to-arraybuffer":"^1.0.0"},"devDependencies":{"arraybuffer-to-string":"^1.0.1","object-assign":"^4.1.1","atob-lite":"^2.0.0","create-data-uri":"^1.1.0","ndarray":"^1.0.18","ndsamples":"^1.0.0","tape":"^4.6.3","wav-encoder":"^1.1.0"},"gitHead":"8fdc8d2f9001289037e4912ba0b96e535e1d38e8","_id":"audio-buffer-from@1.0.0","_shasum":"8d15c10bfb285f33417639c00a42eeaefd002041","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"dfcreative","email":"df.creative@gmail.com"},"dist":{"shasum":"8d15c10bfb285f33417639c00a42eeaefd002041","size":5094,"noattachment":false,"key":"/audio-buffer-from/-/audio-buffer-from-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/audio-buffer-from/download/audio-buffer-from-1.0.0.tgz"},"maintainers":[{"name":"dfcreative","email":"df.creative@gmail.com"},{"name":"jamen","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/audio-buffer-from-1.0.0.tgz_1498619330921_0.011523490538820624"},"directories":{},"publish_time":1498619331816,"_hasShrinkwrap":false,"_cnpm_publish_time":1498619331816,"_cnpmcore_publish_time":"2021-12-17T02:54:55.835Z"}},"readme":"# audio-buffer-from [![Build Status](https://travis-ci.org/audiojs/audio-buffer-from.svg?branch=master)](https://travis-ci.org/audiojs/audio-buffer-from) [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Greenkeeper badge](https://badges.greenkeeper.io/audiojs/audio-buffer-from.svg)](https://greenkeeper.io/)\r\n\r\nCreate [AudioBuffer](https://github.com/audiojs/audio-buffer) from any source.\r\n\r\n## Usage\r\n\r\n[![$ npm install audio-buffer-from](http://nodei.co/npm/audio-buffer-from.png?mini=true)](http://npmjs.org/package/audio-buffer-from)\r\n\r\n```js\r\nvar createBuffer = require('audio-buffer-from')\r\n\r\n//mono-buffer 1024 samples\r\nvar abuf = createBuffer(1024)\r\n\r\n//stereo-buffer 1024 samples\r\nvar abuf2 = createBuffer(1024, 2)\r\n\r\n//buffer from data with bound audio context\r\nvar abuf3 = createBuffer(floatArray, {context: audioContext})\r\n\r\n//empty 1-sample mono buffer with default context\r\nvar abuf4 = createBuffer()\r\n\r\n//0-length no-context buffer\r\nvar abuf5 = createBuffer(0)\r\n\r\n//from duration\r\nvar abuf6 = createBuffer({duration: 1})\r\n\r\n//from pcm data\r\nvar abuf7 = createBuffer(new Uint8Array([0, 0, 255, 255]), 'interleaved 96000')\r\n\r\n//from data-uri\r\nvar abuf8 = createBuffer('data:application/octet-stream;base64,AP8A/w==', 'uint8')\r\n\r\n//from base64 string\r\nvar abuf9 = createBuffer('AAAAAAAAAAAAAIA/AACAPw==', 'float32 stereo planar')\r\n\r\n//from node Buffer\r\nvar abuf10 = createBuffer(Buffer.from([0, 255, 0, 127]), 'interleaved')\r\n```\r\n\r\n## API\r\n\r\n### audioBuffer = createBuffer(source|length, channels|format|options)\r\n\r\nCreate 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.\r\n\r\n#### Source:\r\n\r\n| Type | Interpretation |\r\n|---|---|\r\n| `null` | Blank 1-sample length buffer. |\r\n| `Number` | Length of resulting buffer. |\r\n| `Array` of `Arrays` | Every subarray is considered a channel data. |\r\n| `AudioBuffer` | Clone other AudioBuffer. |\r\n| `AudioBufferList` | Coalesce [AudioBufferList](https://github.com/audiojs/audio-buffer-list) to AudioBuffer. |\r\n| `Audio` | Retrieve AudioBuffer from [Audio](https://github.com/audiojs/audio). |\r\n| `Object` | Create based on `length`/`duration`, `channels`/`numberOfChannels` and `sampleRate` properties. |\r\n| `Array` of `Numbers` | Raw data, interpreted by `options.format`, defaults to `float64`. |\r\n| `Float32Array` | Raw `float32` data, amplitude range is `-1..+1`. |\r\n| `Float64Array` | Raw `float64` data, amplitude range is `-1..+1`. |\r\n| `Int8Array` | Raw `int8` data, amplitude range is `-128..+127`. |\r\n| `Uint8Array` | Raw `uint8` data, amplitude range is `0..255`. |\r\n| `TypedArray` | Any other typed array, described by `options.format` argument (see [pcm-convert](https://github.com/audiojs/pcm-convert)). |\r\n| `ArrayBuffer` | Raw data, interpreted by `options.format`. |\r\n| `Buffer` | Raw data, interpreted by `options.format`. |\r\n| `base64` string | [Base64](https://developer.mozilla.org/en/docs/Web/API/WindowBase64/Base64_encoding_and_decoding)-encoded data. |\r\n| `dataURI` string | [DataURI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) string. |\r\n| `ndarray` | Create from [ndarray](https://npmjs.org/package/ndarray) instance. The `shape` property is considered as `[length, channels]`. |\r\n| `ndsamples` | Create from [ndsamples](https://npmjs.org/package/ndsamples) instance, similar to ndarray. |\r\n\r\n#### Options:\r\n\r\nProperty | Default | Meaning\r\n|---|---|---\r\n`length` | `1` | Buffer length. If `0`, buffer is unbound from context.\r\n`context` | [`audio-context`](https://github.com/audiojs/audio-context) | Audio context to bind. `null`-context creates context-free audio buffer.\r\n`channels`, `numberOfChannels` | `1` | Buffer number of channels.\r\n`sampleRate`, `rate` | `44100` | Buffer sample rate.\r\n`format` | `null` | Source pcm format string or object, see [audio-format](https://github.com/audio-format). If `null`, it will be detected from the `source`.\r\n\r\n\r\n### Related\r\n\r\n* [audio-buffer](https://github.com/audiojs/audio-buffer)\r\n* [audio-buffer-utils](https://github.com/audiojs/audio-buffer-utils)\r\n* [pcm-convert](https://github.com/audiojs/pcm-convert)\r\n\r\n## License\r\n\r\n© 2017 Dmitry Yv. MIT License\r\n","_attachments":{},"homepage":"https://github.com/audiojs/audio-buffer-from#readme","bugs":{"url":"https://github.com/audiojs/audio-buffer-from/issues"},"license":"MIT"}