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

wavesurfer.js

Package Overview
Dependencies
Maintainers
1
Versions
303
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wavesurfer.js - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

.tern-port

2

bower.json
{
"name" : "wavesurfer.js",
"version" : "1.0.13",
"version" : "1.0.14",
"homepage" : "https://github.com/katspaugh/wavesurfer.js",

@@ -5,0 +5,0 @@ "main" : "build/wavesurfer.min.js",

{
"name": "wavesurfer.js",
"version": "1.0.13",
"version": "1.0.14",
"description": "Interactive navigable audio visualization using Web Audio and Canvas",

@@ -5,0 +5,0 @@ "main": "build/wavesurfer.cjs.js",

@@ -63,7 +63,2 @@ 'use strict';

this.waveCc.fillStyle = this.params.waveColor;
if (this.progressCc) {
this.progressCc.fillStyle = this.params.progressColor;
}
var halfH = this.height / 2;

@@ -74,49 +69,35 @@ var coef = halfH / max;

if (this.params.fillParent && this.width != length) {
scale = this.width / peaks.length;
scale = this.width / length;
}
this.waveCc.beginPath();
this.waveCc.moveTo($, halfH);
this.waveCc.fillStyle = this.params.waveColor;
if (this.progressCc) {
this.progressCc.beginPath();
this.progressCc.moveTo($, halfH);
this.progressCc.fillStyle = this.params.progressColor;
}
for (var i = 0; i < length; i++) {
var h = Math.round(peaks[i] * coef);
this.waveCc.lineTo(i * scale + $, halfH + h);
if (this.progressCc) {
this.progressCc.lineTo(i * scale + $, halfH + h);
[ this.waveCc, this.progressCc ].forEach(function (cc) {
if (!cc) { return; }
cc.beginPath();
cc.moveTo($, halfH);
for (var i = 0; i < length; i++) {
var h = Math.round(peaks[i] * coef);
cc.lineTo(i * scale + $, halfH + h);
}
}
this.waveCc.lineTo(this.width + $, halfH);
if (this.progressCc) {
this.progressCc.lineTo(this.width + $, halfH);
}
cc.lineTo(this.width + $, halfH);
cc.moveTo($, halfH);
this.waveCc.moveTo($, halfH);
if (this.progressCc) {
this.progressCc.moveTo($, halfH);
}
for (var i = 0; i < length; i++) {
var h = Math.round(peaks[i] * coef);
this.waveCc.lineTo(i * scale + $, halfH - h);
if (this.progressCc) {
this.progressCc.lineTo(i * scale + $, halfH - h);
for (var i = 0; i < length; i++) {
var h = Math.round(peaks[i] * coef);
cc.lineTo(i * scale + $, halfH - h);
}
}
this.waveCc.lineTo(this.width + $, halfH);
this.waveCc.fill();
cc.lineTo(this.width + $, halfH);
cc.fill();
if (this.progressCc) {
this.progressCc.lineTo(this.width + $, halfH);
this.progressCc.fill();
}
// Always draw a median line
this.waveCc.fillRect(0, halfH - $, this.width, $);
// Always draw a median line
cc.fillRect(0, halfH - $, this.width, $);
}, this);
},

@@ -123,0 +104,0 @@

@@ -115,7 +115,6 @@ 'use strict';

getPeaks: function (length) {
if (this.peaks instanceof Array) {
return this.peaks || [];
if (this.buffer) {
return WaveSurfer.WebAudio.getPeaks.call(this, length);
}
var args = Array.prototype.slice.call(arguments);
return WaveSurfer.WebAudio.getPeaks.apply(this, args);
return this.peaks || [];
},

@@ -122,0 +121,0 @@

@@ -101,3 +101,8 @@ /**

if (this.params.backend == 'WebAudio' && !WaveSurfer.WebAudio.supportsWebAudio()) {
this.params.backend = 'AudioElement';
}
this.backend = Object.create(WaveSurfer[this.params.backend]);
this.backend.init(this.params);

@@ -111,12 +116,2 @@ this.backend.on('finish', function () {

});
try {
this.backend.init(this.params);
} catch (e) {
if (e.message == "Your browser doesn't support Web Audio") {
this.params.backend = 'AudioElement';
this.backend = null;
this.createBackend();
}
}
},

@@ -337,11 +332,4 @@

this.empty();
if (peaks instanceof Array) {
this.backend.load(url, this.mediaContainer, peaks);
} else {
this.downloadArrayBuffer(url, (function(arraybuffer) {
this.backend.decodeArrayBuffer(arraybuffer, (function(buffer) {
this.backend.load(url, this.mediaContainer);
}).bind(this));
}).bind(this));
}
this.backend.load(url, this.mediaContainer, peaks);
this.backend.once('canplay', (function () {

@@ -351,5 +339,17 @@ this.drawBuffer();

}).bind(this));
this.backend.once('error', (function (err) {
this.fireEvent('error', err);
}).bind(this));
// If no pre-decoded peaks provided, attempt to download the
// audio file and decode it with Web Audio.
if (!peaks && this.backend.supportsWebAudio()) {
this.downloadArrayBuffer(url, (function (data) {
this.backend.decodeArrayBuffer(data, (function (buffer) {
this.backend.buffer = buffer;
this.drawBuffer();
}).bind(this));
}).bind(this));
}
},

@@ -356,0 +356,0 @@

@@ -10,7 +10,7 @@ 'use strict';

supportsWebAudio: function () {
return !!(window.AudioContext || window.webkitAudioContext);
},
getAudioContext: function () {
if (!(window.AudioContext || window.webkitAudioContext)) {
throw new Error("Your browser doesn't support Web Audio");
}
if (!WaveSurfer.WebAudio.audioContext) {

@@ -24,2 +24,11 @@ WaveSurfer.WebAudio.audioContext = new (

getOfflineAudioContext: function (sampleRate) {
if (!WaveSurfer.WebAudio.offlineAudioContext) {
WaveSurfer.WebAudio.offlineAudioContext = new (
window.OfflineAudioContext || window.webkitOfflineAudioContext
)(1, 2, sampleRate);
}
return WaveSurfer.WebAudio.offlineAudioContext;
},
init: function (params) {

@@ -151,7 +160,8 @@ this.params = params;

decodeArrayBuffer: function (arraybuffer, callback, errback) {
var my = this;
this.ac.decodeAudioData(arraybuffer, function (data) {
my.buffer = data;
if (!this.offlineAc) {
this.offlineAc = this.getOfflineAudioContext(this.ac ? this.ac.sampleRate : 44100);
}
this.offlineAc.decodeAudioData(arraybuffer, (function (data) {
callback(data);
}, errback);
}).bind(this), errback);
},

@@ -215,3 +225,3 @@

destroy: function () {
if (!this.isPaused()) {
if (!this.isPaused()) {
this.pause();

@@ -218,0 +228,0 @@ }

Sorry, the diff of this file is too big to display

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