New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

audio-buffer

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-buffer - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

46

index.js

@@ -38,3 +38,3 @@ /**

//figure out options
var ctx, isWAA, floatArray
var ctx, isWAA, floatArray, isForcedType = false
if (last && typeof last != 'number') {

@@ -44,2 +44,3 @@ ctx = last.context || context

floatArray = last.floatArray || FloatArray
if (last.floatArray) isForcedType = true
}

@@ -69,3 +70,6 @@ else {

this.length = data;
this.data = new floatArray(data * this.numberOfChannels);
this.data = []
for (var c = 0; c < this.numberOfChannels; c++) {
this.data[c] = new floatArray(data)
}
}

@@ -79,7 +83,7 @@ //if other audio buffer passed - create fast clone of it

this.data = new floatArray(this.length * this.numberOfChannels);
this.data = []
//copy channel's data
for (var i = 0, l = this.numberOfChannels; i < l; i++) {
this.data.set(data.getChannelData(i), i * this.length);
for (var c = 0, l = this.numberOfChannels; c < l; c++) {
this.data[c] = data.getChannelData(c).slice()
}

@@ -99,3 +103,6 @@ }

this.length = data.length / this.numberOfChannels;
this.data = data;
this.data = []
for (var c = 0; c < this.numberOfChannels; c++) {
this.data[c] = data.subarray(c * this.length, (c + 1) * this.length);
}
}

@@ -108,5 +115,5 @@ //if array - parse channeled data

this.length = data[0].length;
this.data = new floatArray(this.length * this.numberOfChannels);
for (var i = 0; i < this.numberOfChannels; i++ ) {
this.data.set(data[i], i * this.length);
this.data = []
for (var c = 0; c < this.numberOfChannels; c++ ) {
this.data[c] = !isForcedType || (data[c] instanceof floatArray) ? data[c] : new floatArray(data[c])
}

@@ -117,5 +124,6 @@ }

this.length = Math.floor(data.length / this.numberOfChannels);
//detect zero-arrays
if (data[0] == null) data = this.length;
this.data = new floatArray(data);
this.data = []
for (var c = 0; c < this.numberOfChannels; c++) {
this.data[c] = new floatArray(data.slice(c * this.length, (c + 1) * this.length))
}
}

@@ -139,4 +147,4 @@ }

//fill channels
for (var i = 0; i < this.numberOfChannels; i++) {
audioBuffer.getChannelData(i).set(this.getChannelData(i));
for (var c = 0; c < this.numberOfChannels; c++) {
audioBuffer.getChannelData(c).set(this.getChannelData(c));
}

@@ -167,3 +175,3 @@

return this.data.subarray(channel * this.length, (channel + 1) * this.length);
return this.data[channel]
};

@@ -176,6 +184,6 @@

AudioBuffer.prototype.copyFromChannel = function (destination, channelNumber, startInChannel) {
var offset = channelNumber * this.length;
if (startInChannel == null) startInChannel = 0;
var data = this.data[channelNumber]
for (var i = startInChannel, j = 0; i < this.length && j < destination.length; i++, j++) {
destination[j] = this.data[offset + i];
destination[j] = data[i];
}

@@ -190,3 +198,3 @@ };

AudioBuffer.prototype.copyToChannel = function (source, channelNumber, startInChannel) {
var offset = channelNumber * this.length;
var data = this.data[channelNumber]

@@ -196,5 +204,5 @@ if (!startInChannel) startInChannel = 0;

for (var i = startInChannel, j = 0; i < this.length && j < source.length; i++, j++) {
this.data[offset + i] = source[j];
data[i] = source[j];
}
};
{
"name": "audio-buffer",
"version": "3.0.0",
"version": "3.1.0",
"description": "Audio data container",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,5 +45,12 @@ # audio-buffer [![Build Status](https://travis-ci.org/audiojs/audio-buffer.svg?branch=master)](https://travis-ci.org/audiojs/audio-buffer) [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

* `floatArray` — type of array for data, defaults to `Float64Array`.
* `context`: custom audio context, default context is [audio-context](https://npmjs.org/package/audio-context) module.
* `isWAA` — if WebAudioAPI _AudioBuffer_ should be created. Use `false` for emulated buffers - in nodejs that is always false. That can be handy in case if you need to create buffer from subarrays to avoid cloning the data.
* `context` — custom audio context, default context is [audio-context](https://npmjs.org/package/audio-context) module.
* `isWAA` — if WebAudioAPI _AudioBuffer_ should be created. Use `false` for emulated buffers - in nodejs that is always false. That can be handy in case if you need to create buffer from subarrays to avoid cloning the data, like so:
```js
var a = new AudioBuffer(1, [0, .1, .2, .3], {isWAA: false})
var b = new AudioBuffer(1, [a.getChannelData(0).subarray(1,2)], {isWAA: false})
b.getChannelData(0)[0] = .4
a.getChannelData(0) // [0, .4, .2, .3]
```
## See also

@@ -50,0 +57,0 @@

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