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

audio-buffer-list

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-buffer-list - npm Package Compare versions

Comparing version 3.2.1 to 4.0.0

64

index.js

@@ -396,37 +396,2 @@ /**

AudioBufferList.prototype.map = function map (fn, from, to) {
if (from == null) from = 0
if (to == null) to = this.length
from = nidx(from, this.length)
to = nidx(to, this.length)
let fromOffset = this.offset(from)
let toOffset = this.offset(to)
let offset = from - fromOffset[1]
let before = this.buffers.slice(0, fromOffset[0])
let after = this.buffers.slice(toOffset[0] + 1)
let middle = this.buffers.slice(fromOffset[0], toOffset[0] + 1)
middle = middle.map((buf, idx) => {
let result = fn.call(this, buf, idx, offset, this.buffers, this)
if (result === undefined || result === true) result = buf
//ignore removed buffers
if (!result) {
return null;
}
//track offset
offset += result.length
return result
})
.filter((buf) => {
return buf ? !!buf.length : false
})
return new AudioBufferList(before.concat(middle).concat(after), this.numberOfChannels)
}
//apply fn to every buffer for the indicated range
AudioBufferList.prototype.each = function each (fn, from, to, reversed) {
let options = arguments[arguments.length - 1]

@@ -440,2 +405,4 @@ if (!isPlainObj(options)) options = {reversed: false}

this.split(from, to)
let fromOffset = this.offset(from)

@@ -450,2 +417,3 @@ let toOffset = this.offset(to)

if (res === false) break
if (res !== undefined) this.buffers[i] = res
offset -= buf.length

@@ -460,2 +428,5 @@ }

if (res === false) break
if (res !== undefined) {
this.buffers[i] = res
}
offset += buf.length

@@ -465,5 +436,18 @@ }

return this;
this.buffers = this.buffers.filter(buf => {
return buf ? !!buf.length : false
})
let l = 0
for (let i = 0; i < this.buffers.length; i++) {
this.numberOfChannels = Math.max(this.buffers[i].numberOfChannels, this.numberOfChannels)
l += this.buffers[i].length
}
this.length = l
this.duration = this.length / this.sampleRate
return this
}
//reverse subpart

@@ -478,5 +462,3 @@ AudioBufferList.prototype.reverse = function reverse (from, to) {

let sublist = this.slice(from, to)
.each((buf) => {
util.reverse(buf)
})
.map((buf) => util.reverse(buf))
sublist.buffers.reverse()

@@ -526,3 +508,3 @@

let fromOffset = this.offset(from)
let toOffset = this.offset(to)
let toOffset = to >= this.length - 1 ? [this.buffers.length] : this.offset(to)

@@ -534,3 +516,3 @@ let bufs = this.buffers.slice(fromOffset[0], toOffset[0])

return this
return buf
}
{
"name": "audio-buffer-list",
"version": "3.2.1",
"version": "4.0.0",
"description": "Data structure for sequence of AudioBuffers",

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

"audio-buffer": "^4.0.1",
"audio-buffer-utils": "^5.0.0",
"audio-buffer-utils": "^5.1.1",
"is-audio-buffer": "^1.0.5",

@@ -38,0 +38,0 @@ "is-plain-obj": "^1.1.0",

@@ -35,3 +35,2 @@ # audio-buffer-list [![Build Status](https://travis-ci.org/audiojs/audio-buffer-list.svg?branch=master)](https://travis-ci.org/audiojs/audio-buffer-list) [![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-list.svg)](https://greenkeeper.io/)

* [list.map(fn, from?, to?)](#listmapbuffer-index-offset--bufferbool-from0-to-0)
* [list.each(fn, from?, to?, opt?)](#listeachbuffer-index-offset---from0-to-0-reversed)
* [list.reverse(from?, to?)](#listreversestart0-end-0)

@@ -87,3 +86,3 @@ * [list.repeat(times)](#listrepeatcount)

Return sublist of the initial list. The data is not copied but returned as subarrays. `list.slice()` just creates a duplicate that way.
Return sublist of the initial list. The data is not copied but returned as subarrays.

@@ -94,6 +93,10 @@ ### `list.clone(start=0, end=-0)`

### `list.map((buffer, index, offset) => buffer|bool?, from=0, to=-0)`
### `list.map(mapper, from=0, to=-0, {reversed: false})`
Create new list by mapping every buffer. Optionally pass offsets `from` and `to` to map only buffers covering the subset, keeping the rest unchanged. If no buffer returned from the mapper function then the old buffer will be preserved. If `null` returned then the buffer will be discarded. `offset` tracks absolute `buffer` offset in new list, `index` reflects buffer count.
Map buffers of subpart of the list, defined by `from` and `to` arguments. Modifies list in-place.
Mapper function has signature `(buffer, idx, offset) => buffer`. `buffer` is an audio buffer to process, `idx` is buffer number, and `offset` is first buffer sample absolute offset. If mapper returns `undefined`, the buffer is preserved. If mapper returns `null`, the buffer is discarded. If mapper returns `false`, iterations are stopped.
Pass `{reversed: true}` option to walk in reversed order.
```js

@@ -106,3 +109,3 @@ list = list.map((buf, idx, offset) => {

//end buffer from the subset may end later than the subset
for (let i = Math.max(from - offset, 0), l = Math.min(to - offset, buf.length); i < l; i++) {
for (let i = 0, l = buf.length; i < l; i++) {
data[i] = process(data[i])

@@ -113,10 +116,5 @@ }

```
### `list.each((buffer, index, offset) => {}, from=0, to=-0, {reversed}?)`
Iterate over buffers from the indicated range. Buffers can be modified in-place during the iterating. Return `false` to break the loop. Pass `{reversed: true}` as the last argument to iterate in reverse order.
### `list.reverse(start=0, end=-0)`
Reverse indicated part of the list. Modifies list in place, returns self.
Reverse indicated part of the list. Modifies list in place.

@@ -139,3 +137,3 @@ ### `list.repeat(count)`

### `list.split(a, b, c, ...)`
### `list.split([a, b, c, ...], d, e, ...)`

@@ -146,3 +144,3 @@ Split list at the indicated indexes. That increases number of inner buffers.

Joins buffers from the indicated range.
Joins buffers from the indicated range. Returns an AudioBuffer with joined data.

@@ -149,0 +147,0 @@ ### `list.offset(idx)`

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