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 - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

license

24

index.js

@@ -14,7 +14,7 @@ /**

var str2ab = require('string-to-arraybuffer')
var pick = require('pick-by-alias')
module.exports = function createBuffer (source, options) {
var length, data, channels, sampleRate, format, c, l
var length, data, channels, sampleRate, format
//src, channels

@@ -38,7 +38,13 @@ if (typeof options === 'number') {

if (options.dtype) options.format = options.dtype
options = pick(options, {
format: 'format type dtype',
channels: 'channel channels numberOfChannels channelCount',
sampleRate: 'sampleRate rate',
length: 'length size',
duration: 'duration time'
})
//detect options
channels = options.channels || options.numberOfChannels || options.channelCount
sampleRate = options.sampleRate || options.rate
channels = options.channels
sampleRate = options.sampleRate
if (options.format) format = getFormat(options.format)

@@ -73,3 +79,3 @@

for (var c = 0, l = channels; c < l; c++) {
for (c = 0, l = channels; c < l; c++) {
data[c] = source.getChannelData(c)

@@ -91,3 +97,3 @@ }

if (!channels) channels = source.length
for (var c = 0; c < channels; c++) {
for (c = 0; c < channels; c++) {
data[c] = source[c] instanceof Float32Array ? source[c] : new Float32Array(source[c])

@@ -121,3 +127,3 @@ }

data = []
for (var c = 0; c < channels; c++) {
for (c = 0; c < channels; c++) {
data[c] = source.subarray(c * length, (c + 1) * length);

@@ -136,3 +142,3 @@ }

if (data) {
for (var c = 0, l = data.length; c < l; c++) {
for (c = 0, l = data.length; c < l; c++) {
audioBuffer.getChannelData(c).set(data[c]);

@@ -139,0 +145,0 @@ }

{
"name": "audio-buffer-from",
"version": "1.0.3",
"version": "1.1.0",
"description": "Create AudioBuffer from any source",

@@ -35,2 +35,3 @@ "main": "index.js",

"pcm-convert": "^1.6.0",
"pick-by-alias": "^1.2.0",
"string-to-arraybuffer": "^1.0.0"

@@ -41,3 +42,3 @@ },

"atob-lite": "^2.0.0",
"audio-buffer-list": "^3.2.1",
"audio-buffer-list": "^4.1.0",
"create-data-uri": "^1.1.0",

@@ -44,0 +45,0 @@ "ndarray": "^1.0.18",

@@ -75,9 +75,9 @@ # 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/)

| Property | Default | Meaning |
|---|---|---|
| `length` | `1` | Buffer length. If `0`, buffer is unbound from context. |
| `context` | [`audio-context`](https://github.com/audiojs/audio-context) | Audio context to bind. `null`-context creates context-free audio buffer. |
| `channels`, `numberOfChannels` | `1` | Buffer number of channels. |
| `sampleRate` | `44100` | Buffer sample rate. |
| `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`. |
Property | Default | Meaning
|---|---|---
`length` | `1` | Buffer length. If `0`, buffer is unbound from context.
`context` | [`audio-context`](https://github.com/audiojs/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](https://github.com/audio-format). If `null`, it will be detected from the `source`.

@@ -93,2 +93,2 @@

© 2017 Dima Yv. MIT License
© 2017 Dmitry Yv. MIT License

@@ -244,2 +244,8 @@ 'use strict'

let b6 = createBuffer(null, {channels: 3, length: 5})
t.equal(b6.length, 5)
t.equal(b6.numberOfChannels, 3)
t.end()

@@ -391,3 +397,13 @@ })

let b = createBuffer({duration: 0, channels: 2})
t.equal(b.length, 0)
let c = createBuffer(null, {duration: 0, channels: 2})
t.equal(c.length, 0)
t.end()
})
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