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

audio-effects

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-effects - npm Package Compare versions

Comparing version 1.0.27 to 1.1.0

dist/helpers/HasAudioContext.js

173

dist/audio-nodes/effects/Delay.js

@@ -1,21 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _MultiAudioNode2 = require('../MultiAudioNode');
var _MultiAudioNode3 = _interopRequireDefault(_MultiAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var MultiAudioNode_1 = require('../MultiAudioNode');
/**

@@ -25,129 +12,97 @@ * The audio-effects delay class.

*/
var Delay = function (_MultiAudioNode) {
_inherits(Delay, _MultiAudioNode);
var Delay = (function (_super) {
__extends(Delay, _super);
function Delay(audioContext) {
_classCallCheck(this, Delay);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Delay).call(this, audioContext));
_this.nodes = {
inputGainNode: audioContext.createGain(), // Create the input and output nodes of the effect
_super.call(this, audioContext);
this.nodes = {
inputGainNode: audioContext.createGain(),
outputGainNode: audioContext.createGain(),
wetGainNode: audioContext.createGain(), // Create the gain-node we'll use to controll the wetness of the delay
durationGainNode: audioContext.createGain(), // Create the gain node we'll use to controll the duration of the delay
wetGainNode: audioContext.createGain(),
durationGainNode: audioContext.createGain(),
delayNode: audioContext.createDelay() // Create the delay node
};
// Wire it all up
_this.nodes.inputGainNode.connect(_this.nodes.wetGainNode);
_this.nodes.inputGainNode.connect(_this.nodes.delayNode);
_this.nodes.durationGainNode.connect(_this.nodes.delayNode);
_this.nodes.delayNode.connect(_this.nodes.durationGainNode);
_this.nodes.delayNode.connect(_this.nodes.outputGainNode);
_this.nodes.wetGainNode.connect(_this.nodes.outputGainNode);
this.nodes['inputGainNode'].connect(this.nodes['wetGainNode']);
this.nodes['inputGainNode'].connect(this.nodes['delayNode']);
this.nodes['durationGainNode'].connect(this.nodes['delayNode']);
this.nodes['delayNode'].connect(this.nodes['durationGainNode']);
this.nodes['delayNode'].connect(this.nodes['outputGainNode']);
this.nodes['wetGainNode'].connect(this.nodes['outputGainNode']);
// Set the input gain-node as the input-node.
_this._node = _this.nodes.inputGainNode;
this.node = this.nodes['inputGainNode'];
// Set the output gain-node as the output-node.
_this._outputNode = _this.nodes.outputGainNode;
this.output = this.nodes['outputGainNode'];
// Set the default wetness to 1
_this.wet = 1;
this.wet = 1;
// Set the default speed to 1 second
_this.speed = 1;
this.speed = 1;
// Set the default duration to 0.4
_this.duration = 0.4;
return _this;
this.duration = 0.4;
}
/**
* Getter for the effect's wetness
* @return {Float}
*/
_createClass(Delay, [{
key: 'wet',
get: function get() {
Object.defineProperty(Delay.prototype, "wet", {
/**
* Getter for the effect's wetness
* @return {number}
*/
get: function () {
return this._wet;
}
},
/**
* Setter for the effect's wetness
* @param {Float} wetness
* @return {Float}
* @param {number|string} wetness
*/
,
set: function set(wetness) {
set: function (wetness) {
// Set the internal wetness value
this._wet = parseFloat(wetness);
// Set the new value for the wetness controll gain-node
this.nodes.wetGainNode.gain.value = this._wet;
return this._wet;
}
this.nodes['wetGainNode'].gain.value = this._wet;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Delay.prototype, "speed", {
/**
* Getter for the effect's speed
* @return {Float}
* @return {number}
*/
}, {
key: 'speed',
get: function get() {
get: function () {
return this._speed;
}
},
/**
* Setter for the effect's speed
* @param {Float} speed
* @return {Float}
* @param {number|string} speed
*/
,
set: function set(speed) {
set: function (speed) {
// Set the internal speed value
this._speed = parseFloat(speed);
// Set the delayTime value of the delay-node
this.nodes.delayNode.delayTime.value = this._speed;
return this._speed;
}
this.nodes['delayNode'].delayTime.value = this._speed;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Delay.prototype, "duration", {
/**
* Getter for the effect's duration
* @return {Float}
* @return {number}
*/
}, {
key: 'duration',
get: function get() {
get: function () {
return this._duration;
}
},
/**
* Setter for the effect's duration
* @param {Float} duration
* @return {Float}
* @param {number|string} duration
*/
,
set: function set(duration) {
set: function (duration) {
// Set the internal duration value
this._duration = parseFloat(duration);
// Set the duration gain-node value
this.nodes.durationGainNode.gain.value = this._duration;
return this._duration;
}
}]);
this.nodes['durationGainNode'].gain.value = this._duration;
},
enumerable: true,
configurable: true
});
return Delay;
}(_MultiAudioNode3.default);
exports.default = Delay;
;
}(MultiAudioNode_1.MultiAudioNode));
exports.Delay = Delay;
;

@@ -1,45 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _MultiAudioNode2 = require('../MultiAudioNode');
var _MultiAudioNode3 = _interopRequireDefault(_MultiAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* Calculate a distortion curve.
*
* http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion
*
* @param {Int} intens The intensity of the curve modification.
* @return {Float32Array}
*/
var _calculateDistortionCurve = function _calculateDistortionCurve(intens) {
var intensity = parseInt(intens) || 100,
amount = 44100,
deg = Math.PI / 180,
curve = new Float32Array(amount);
var i = 0,
x = void 0;
for (; i < amount; ++i) {
x = i * 2 / amount - 1;
curve[i] = (3 + intensity) * x * 20 * deg / (Math.PI + intensity * Math.abs(x));
}
return curve;
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var MultiAudioNode_1 = require('../MultiAudioNode');
/**

@@ -49,132 +12,121 @@ * The audio-effects distortion class.

*/
var Distortion = function (_MultiAudioNode) {
_inherits(Distortion, _MultiAudioNode);
var Distortion = (function (_super) {
__extends(Distortion, _super);
function Distortion(audioContext) {
_classCallCheck(this, Distortion);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Distortion).call(this, audioContext));
_this.nodes = {
waveshaper: _this._audioContext.createWaveShaper(), // Create the waveshaper-node we'll use to create the distortion effect.
gainNode: _this._audioContext.createGain(), // Create the gain-nodes we use to increase the gain.
gainNode2: _this._audioContext.createGain(),
biquadFilterNode: _this._audioContext.createBiquadFilter() // Create the biquad-filter-node we'll use to create a lowpass filter.
_super.call(this, audioContext);
this.nodes = {
waveshaper: this.audioContext.createWaveShaper(),
gainNode: this.audioContext.createGain(),
gainNode2: this.audioContext.createGain(),
biquadFilterNode: this.audioContext.createBiquadFilter() // Create the biquad-filter-node we'll use to create a lowpass filter.
};
// Set the oversample value to 4x by default.
_this.nodes.waveshaper.oversample = '4x';
this.nodes['waveshaper'].oversample = '4x';
// Set the type of to lowpass by default.
_this.nodes.biquadFilterNode.type = 'lowpass';
this.nodes['biquadFilterNode'].type = 'lowpass';
// Set the frequency value to 2000 by default.
_this.nodes.biquadFilterNode.frequency.value = 2000;
this.nodes['biquadFilterNode'].frequency.value = 2000;
// Connect all nodes together
_this.nodes.waveshaper.connect(_this.nodes.gainNode);
_this.nodes.gainNode.connect(_this.nodes.gainNode2);
_this.nodes.gainNode2.connect(_this.nodes.biquadFilterNode);
this.nodes['waveshaper'].connect(this.nodes['gainNode']);
this.nodes['gainNode'].connect(this.nodes['gainNode2']);
this.nodes['gainNode2'].connect(this.nodes['biquadFilterNode']);
// Set the waveshaper-node as the input-node.
_this._node = _this.nodes.waveshaper;
this.node = this.nodes['waveshaper'];
// Set the biquad-filter-node as the output-node.
_this._outputNode = _this.nodes.biquadFilterNode;
this.output = this.nodes['biquadFilterNode'];
// The default intensity is 100.
_this.intensity = 100;
this.intensity = 100;
// The default gain is 1.
_this.gain = 50;
this.gain = 50;
// // The lowpass filter is turned off by default.
_this.lowPassFilter = false;
return _this;
this.lowPassFilter = false;
}
/**
* Getter for the effect's intensity.
* @return {Int}
* Calculate a distortion curve.
*
* http://stackoverflow.com/questions/22312841/waveshaper-node-in-webaudio-how-to-emulate-distortion
*
* @param {number} intens The intensity of the curve modification.
* @return {Float32Array}
*/
_createClass(Distortion, [{
key: 'intensity',
get: function get() {
return this._intensity;
Distortion.prototype.calculateDistortionCurve = function (intens) {
var intensity = parseInt(intens) || 100;
var amount = 44100;
var deg = Math.PI / 180;
var curve = new Float32Array(amount);
var i = 0;
var x;
for (; i < amount; ++i) {
x = i * 2 / amount - 1;
curve[i] = (3 + intensity) * x * 20 * deg / (Math.PI + intensity * Math.abs(x));
}
return curve;
};
;
Object.defineProperty(Distortion.prototype, "intensity", {
/**
* Getter for the effect's intensity.
* @return {number}
*/
get: function () {
return this._intensity;
},
/**
* Setter for the effect's intensity.
* @param {Int} intensity
* @return {Int}
*/
,
set: function set(intensity) {
set: function (intensity) {
// Set the internal intensity value.
this._intensity = parseInt(intensity);
// Set the new curve of the waveshaper-node
this.nodes.waveshaper.curve = _calculateDistortionCurve(this._intensity);
return this._intensity;
}
this.nodes['waveshaper'].curve = this.calculateDistortionCurve(this._intensity);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Distortion.prototype, "gain", {
/**
* Getter for the effect's gain.
* @return {Float}
* @return {number}
*/
}, {
key: 'gain',
get: function get() {
get: function () {
return this._gain;
}
},
/**
* Setter for the effect's gain.
* @param {Float} gain
* @return {Float}
* @param {number} gain
*/
,
set: function set(gain) {
set: function (gain) {
// Set the internal gain value.
this._gain = parseFloat(gain);
// Set the gain-node's gain value.
this.nodes.gainNode.gain.value = this._gain;
this.nodes.gainNode2.gain.value = 1 / this._gain;
return this._gain;
}
this.nodes['gainNode'].gain.value = this._gain;
this.nodes['gainNode2'].gain.value = 1 / this._gain;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Distortion.prototype, "lowPassFilter", {
/**
* Getter for the lowpass filter.
* @return {Boolean}
* @return {boolean}
*/
}, {
key: 'lowPassFilter',
get: function get() {
get: function () {
return this._lowPassFilter;
}
},
/**
* Setter for the lowpass filter.
* @param {Boolean} lowPassFilter
* @return {Boolean}
* @param {boolean} lowPassFilter
*/
,
set: function set(lowPassFilter) {
set: function (lowPassFilter) {
// Set the internal lowpass filter value.
this._lowPassFilter = !!lowPassFilter;
// Set the biquad-filter-node's frequency.
this.nodes.biquadFilterNode.frequency.value = this._lowPassFilter ? 2000 : 1000;
return this._lowPassFilter;
}
}]);
this.nodes['biquadFilterNode'].frequency.value = (this._lowPassFilter ? 2000 : 1000);
},
enumerable: true,
configurable: true
});
return Distortion;
}(_MultiAudioNode3.default);
exports.default = Distortion;
;
}(MultiAudioNode_1.MultiAudioNode));
exports.Distortion = Distortion;
;

@@ -1,21 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _MultiAudioNode2 = require('../MultiAudioNode');
var _MultiAudioNode3 = _interopRequireDefault(_MultiAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var MultiAudioNode_1 = require('../MultiAudioNode');
/**

@@ -25,166 +12,125 @@ * The audio-effects flanger class.

*/
var Flanger = function (_MultiAudioNode) {
_inherits(Flanger, _MultiAudioNode);
var Flanger = (function (_super) {
__extends(Flanger, _super);
function Flanger(audioContext) {
_classCallCheck(this, Flanger);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Flanger).call(this, audioContext));
_this.nodes = {
inputGainNode: audioContext.createGain(), // Create the input gain-node
wetGainNode: audioContext.createGain(), // Create the wetness controll gain-node
delayNode: audioContext.createDelay(), // Create the delay node
gainNode: audioContext.createGain(), // Create the gain controll gain-node
feedbackGainNode: audioContext.createGain(), // Create the feedback controll gain-node
_super.call(this, audioContext);
this.nodes = {
inputGainNode: audioContext.createGain(),
wetGainNode: audioContext.createGain(),
delayNode: audioContext.createDelay(),
gainNode: audioContext.createGain(),
feedbackGainNode: audioContext.createGain(),
oscillatorNode: audioContext.createOscillator() // Create the oscilator node
};
// Wire it all up
_this.nodes.oscillatorNode.connect(_this.nodes.gainNode);
_this.nodes.gainNode.connect(_this.nodes.delayNode.delayTime);
_this.nodes.inputGainNode.connect(_this.nodes.wetGainNode);
_this.nodes.inputGainNode.connect(_this.nodes.delayNode);
_this.nodes.delayNode.connect(_this.nodes.wetGainNode);
_this.nodes.delayNode.connect(_this.nodes.feedbackGainNode);
_this.nodes.feedbackGainNode.connect(_this.nodes.inputGainNode);
this.nodes['oscillatorNode'].connect(this.nodes['gainNode']);
this.nodes['gainNode'].connect(this.nodes['delayNode'].delayTime);
this.nodes['inputGainNode'].connect(this.nodes['wetGainNode']);
this.nodes['inputGainNode'].connect(this.nodes['delayNode']);
this.nodes['delayNode'].connect(this.nodes['wetGainNode']);
this.nodes['delayNode'].connect(this.nodes['feedbackGainNode']);
this.nodes['feedbackGainNode'].connect(this.nodes['inputGainNode']);
// Setup the oscillator
_this.nodes.oscillatorNode.type = 'sine';
_this.nodes.oscillatorNode.start(0);
this.nodes['oscillatorNode'].type = 'sine';
this.nodes['oscillatorNode'].start(0);
// Set the input gain-node as the input-node.
_this._node = _this.nodes.inputGainNode;
this.node = this.nodes['inputGainNode'];
// Set the output gain-node as the output-node.
_this._outputNode = _this.nodes.wetGainNode;
this.output = this.nodes['wetGainNode'];
// Set the default delay of 0.005 seconds
_this.delay = 0.005;
this.delay = 0.005;
// Set the default depth to 0.002;
_this.depth = 0.002;
this.depth = 0.002;
// Set the default feedback to 0.5
_this.feedback = 0.5;
this.feedback = 0.5;
// Set the default speed to 0.25Hz
_this.speed = 0.25;
return _this;
this.speed = 0.25;
}
/**
* Getter for the effect's delay
* @return {Float}
*/
_createClass(Flanger, [{
key: 'delay',
get: function get() {
Object.defineProperty(Flanger.prototype, "delay", {
/**
* Getter for the effect's delay
* @return {number}
*/
get: function () {
return this._delay;
}
},
/**
* Setter for the effect's delay
* @param {Float} delay
* @return {Float}
* @param {number} delay
*/
,
set: function set(delay) {
set: function (delay) {
// Set the internal delay value
this._delay = parseFloat(delay);
// Set the new value for the delay-node
this.nodes.delayNode.delayTime.value = this._delay;
return this._delay;
}
this.nodes['delayNode'].delayTime.value = this._delay;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Flanger.prototype, "depth", {
/**
* Getter for the effect's depth
* @return {Float}
* @return {number}
*/
}, {
key: 'depth',
get: function get() {
get: function () {
return this._depth;
}
},
/**
* Setter for the effect's depth
* @param {Float} depth
* @return {Float}
* @param {number} depth
*/
,
set: function set(depth) {
set: function (depth) {
// Set the internal depth value
this._depth = parseFloat(depth);
// Set the gain value of the gain-node
this.nodes.gainNode.gain.value = this._depth;
return this._depth;
}
this.nodes['gainNode'].gain.value = this._depth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Flanger.prototype, "feedback", {
/**
* Getter for the effect's feedback
* @return {Float}
* @return {number}
*/
}, {
key: 'feedback',
get: function get() {
get: function () {
return this._feedback;
}
},
/**
* Setter for the effect's feedback
* @param {Float} feedback
* @return {Float}
* @param {number} feedback
*/
,
set: function set(feedback) {
set: function (feedback) {
// Set the internal feedback value
this._feedback = parseFloat(feedback);
// Set the feedback gain-node value
this.nodes.feedbackGainNode.gain.value = this._feedback;
return this._feedback;
}
this.nodes['feedbackGainNode'].gain.value = this._feedback;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Flanger.prototype, "speed", {
/**
* Getter for the effect's speed
* @return {Float}
* @return {number}
*/
}, {
key: 'speed',
get: function get() {
get: function () {
return this._speed;
}
},
/**
* Setter for the effect's speed
* @param {Float} speed
* @return {Float}
* @param {number} speed
*/
,
set: function set(speed) {
set: function (speed) {
// Set the internal speed value
this._speed = parseFloat(speed);
// Set the speed gain-node value
this.nodes.oscillatorNode.frequency.value = this._speed;
return this._speed;
}
}]);
this.nodes['oscillatorNode'].frequency.value = this._speed;
},
enumerable: true,
configurable: true
});
return Flanger;
}(_MultiAudioNode3.default);
exports.default = Flanger;
;
}(MultiAudioNode_1.MultiAudioNode));
exports.Flanger = Flanger;
;

@@ -1,29 +0,10 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _SingleAudioNode2 = require('../SingleAudioNode');
var _SingleAudioNode3 = _interopRequireDefault(_SingleAudioNode2);
var _HasGetUserMedia = require('../../helpers/HasGetUserMedia');
var _HasGetUserMedia2 = _interopRequireDefault(_HasGetUserMedia);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var _ = require('lodash');
var SingleAudioNode_1 = require('../SingleAudioNode');
var HasGetUserMedia_1 = require('../../helpers/HasGetUserMedia');
/**

@@ -33,136 +14,106 @@ * The audio-effects input node.

*/
var Input = function (_SingleAudioNode) {
_inherits(Input, _SingleAudioNode);
var Input = (function (_super) {
__extends(Input, _super);
function Input(audioContext) {
_classCallCheck(this, Input);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Input).call(this, audioContext));
_this._deferredConnects = [];
_this._hasPermissions = false;
return _this;
_super.call(this, audioContext);
this._deferredConnects = [];
this._hasPermissions = false;
}
/**
* Getter for the effects input node.
* @return {[type]} [description]
*/
_createClass(Input, [{
key: 'getUserMedia',
Object.defineProperty(Input.prototype, "input", {
/**
* Get your microphone sound as input.
* @return {Promise} Resolves when you accept to use the microphone.
* Getter for the effects input node.
* @return {AudioNode}
*/
value: function getUserMedia() {
var _this2 = this;
return new Promise(function (resolve, reject) {
if (_HasGetUserMedia2.default) {
navigator.getUserMedia({
audio: true
}, function (stream) {
_this2.input = stream;
_this2._hasPermissions = true;
// Connect the deffered connects
_this2._deferredConnects.forEach(function (node) {
_this2.connect(node);
});
resolve(stream);
}, function (error) {
reject(error);
});
} else {
reject('Your browser does not support the use of user-media, please upgrade or use another browser!');
}
});
}
get: function () {
return this.node;
},
/**
* Connect the effect to other effects or native audio-nodes.
* @param {Native AudioNode | Audio-effects AudioNode} node
* @return {Native AudioNode | Audio-effects AudioNode}
* Setter for the effects input node.
* @param {AudioStream} stream
*/
}, {
key: 'connect',
value: function connect(node) {
// If there is no input node yet, connect when there is a node
if (typeof this._node === 'undefined') {
this._deferredConnects.push(node);
return node;
set: function (stream) {
// Create a media-stream source.
this.node = this.audioContext.createMediaStreamSource(stream);
},
enumerable: true,
configurable: true
});
/**
* Get your microphone sound as input.
* @return {Promise<AudioNode>} Resolves when you accept to use the microphone.
*/
Input.prototype.getUserMedia = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (HasGetUserMedia_1.HasGetUserMedia) {
navigator.getUserMedia({
audio: true
}, function (stream) {
_this.input = stream;
_this._hasPermissions = true;
// Connect the deffered connects
_this._deferredConnects.forEach(function (node) {
_this.connect(node);
});
resolve(stream);
}, function (error) {
reject(error);
});
}
// Check if the node is a Audio-effects AudioNode,
// otherwise assume it's a native one.
if (node.node) {
this.node.connect(node.node);
} else {
this.node.connect(node);
else {
reject('Your browser does not support the use of user-media, please upgrade or use another browser!');
}
});
};
/**
* Connect the effect to other effects or native audio-nodes.
* @param {AudioNode|SingleAudioNode|MultiAudioNode} node
* @return {AudioNode|SingleAudioNode|MultiAudioNode}
*/
Input.prototype.connect = function (node) {
// If there is no input node yet, connect when there is a node
if (typeof this.node === 'undefined') {
this._deferredConnects.push(node);
return node;
}
/**
* Get a list of audio in-and-output devices devices.
* @return {Array} A list of the available audio in-and-output devices.
*/
}, {
key: 'getAudioDevices',
value: function getAudioDevices() {
var _this3 = this;
return new Promise(function (resolve, reject) {
if (_this3._hasPermissions) {
// Check if the node is a Audio-effects AudioNode,
// otherwise assume it's a native one.
if (node.node) {
this.node.connect(node.node);
}
else {
this.node.connect(node);
}
return node;
};
/**
* Get a list of audio in-and-output devices devices.
* @return {Promise<Array<any>>} A list of the available audio in-and-output devices.
*/
Input.prototype.getAudioDevices = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this._hasPermissions) {
navigator.mediaDevices.enumerateDevices().then(function (devices) {
resolve(_.filter(devices, { kind: 'audioinput' }));
}).catch(function (error) {
reject(error);
});
}
else {
_this.getUserMedia().then(function () {
navigator.mediaDevices.enumerateDevices().then(function (devices) {
resolve(_lodash2.default.filter(devices, { kind: 'audioinput' }));
resolve(_.filter(devices, { kind: 'audioinput' }));
}).catch(function (error) {
reject(error);
});
} else {
_this3.getUserMedia().then(function () {
navigator.mediaDevices.enumerateDevices().then(function (devices) {
resolve(_lodash2.default.filter(devices, { kind: 'audioinput' }));
}).catch(function (error) {
reject(error);
});
}).catch(function (error) {
reject(error);
});
}
});
}
}, {
key: 'input',
get: function get() {
return this._node;
}
/**
* Setter for the effects input node.
* @param {AudioStrea,} stream
* @return {AudioNode}
*/
,
set: function set(stream) {
// Create a media-stream source.
this._node = this._audioContext.createMediaStreamSource(stream);
return this._node;
}
}]);
}).catch(function (error) {
reject(error);
});
}
});
};
return Input;
}(_SingleAudioNode3.default);
exports.default = Input;
;
}(SingleAudioNode_1.SingleAudioNode));
exports.Input = Input;
;

@@ -1,19 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _SingleAudioNode2 = require('../SingleAudioNode');
var _SingleAudioNode3 = _interopRequireDefault(_SingleAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SingleAudioNode_1 = require('../SingleAudioNode');
/**

@@ -23,19 +12,12 @@ * The audio-effects output class.

*/
var Output = function (_SingleAudioNode) {
_inherits(Output, _SingleAudioNode);
var Output = (function (_super) {
__extends(Output, _super);
function Output(audioContext) {
_classCallCheck(this, Output);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Output).call(this, audioContext));
if (_this._audioContext) {
_this._node = audioContext.destination;
_super.call(this, audioContext);
if (this.audioContext) {
this.node = audioContext.destination;
}
return _this;
}
return Output;
}(_SingleAudioNode3.default);
exports.default = Output;
}(SingleAudioNode_1.SingleAudioNode));
exports.Output = Output;

@@ -1,34 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _MultiAudioNode2 = require('../MultiAudioNode');
var _MultiAudioNode3 = _interopRequireDefault(_MultiAudioNode2);
var _hallReverb = require('file!../../../audio/hall-reverb.ogg');
var _hallReverb2 = _interopRequireDefault(_hallReverb);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// Load the input response file
var _getInputResponseFile = function getInputResponseFile() {
return fetch(_hallReverb2.default, {
method: 'get'
}).then(function (response) {
return response.arrayBuffer();
});
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var MultiAudioNode_1 = require('../MultiAudioNode');
/**

@@ -38,106 +12,92 @@ * The audio-effects reverb class.

*/
var Reverb = function (_MultiAudioNode) {
_inherits(Reverb, _MultiAudioNode);
var Reverb = (function (_super) {
__extends(Reverb, _super);
function Reverb(audioContext, buffer) {
_classCallCheck(this, Reverb);
// Set the audioContext
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Reverb).call(this, audioContext));
_this.audioContext = audioContext;
_this.nodes = {
inputGainNode: audioContext.createGain(), // Create the input and output gain-node
var _this = this;
_super.call(this, audioContext);
this.nodes = {
inputGainNode: audioContext.createGain(),
outputGainNode: audioContext.createGain(),
convolverNode: audioContext.createConvolver(), // Create the convolver node to create the reverb effect
wetGainNode: audioContext.createGain(), // Create the wetness controll gain-node
convolverNode: audioContext.createConvolver(),
wetGainNode: audioContext.createGain(),
levelGainNode: audioContext.createGain() // Create the level controll gain-node
};
// Wire it all up
_this.nodes.inputGainNode.connect(_this.nodes.convolverNode);
_this.nodes.inputGainNode.connect(_this.nodes.wetGainNode);
_this.nodes.convolverNode.connect(_this.nodes.levelGainNode);
_this.nodes.levelGainNode.connect(_this.nodes.outputGainNode);
_this.nodes.wetGainNode.connect(_this.nodes.outputGainNode);
this.nodes['inputGainNode'].connect(this.nodes['convolverNode']);
this.nodes['inputGainNode'].connect(this.nodes['wetGainNode']);
this.nodes['convolverNode'].connect(this.nodes['levelGainNode']);
this.nodes['levelGainNode'].connect(this.nodes['outputGainNode']);
this.nodes['wetGainNode'].connect(this.nodes['outputGainNode']);
// Set the input gain-node as the input-node.
_this._node = _this.nodes.inputGainNode;
this.node = this.nodes['inputGainNode'];
// Set the output gain-node as the output-node.
_this._outputNode = _this.nodes.outputGainNode;
this.output = this.nodes['outputGainNode'];
// Set the default wetness to 0.5
_this.wet = 0.5;
this.wet = 0.5;
// Set the default level to 1
_this.level = 1;
this.level = 1;
// Set the convolver buffer
if (buffer) {
_this.buffer = buffer;
} else {
_getInputResponseFile().then(function (buffer) {
this.buffer = buffer;
}
else {
this.getInputResponseFile().then(function (buffer) {
_this.buffer = buffer;
});
}
return _this;
}
/**
* Getter for the effect's wetness
* @return {Float}
* Get the standard input responsefile.
* @return {Promise<AudioBuffer>}
*/
_createClass(Reverb, [{
key: 'wet',
get: function get() {
Reverb.prototype.getInputResponseFile = function () {
return fetch('../../../audio/hall-reverb.ogg', {
method: 'get'
}).then(function (response) {
return response.arrayBuffer();
});
};
Object.defineProperty(Reverb.prototype, "wet", {
/**
* Getter for the effect's wetness
* @return {number}
*/
get: function () {
return this._wet;
}
},
/**
* Setter for the effect's wetness
* @param {Float} wetness
* @return {Float}
* @param {number} wetness
*/
,
set: function set(wetness) {
set: function (wetness) {
// Set the internal wetness value
this._wet = parseFloat(wetness);
// Set the new value for the wetness controll gain-node
this.nodes.wetGainNode.gain.value = this._wet;
return this._wet;
}
this.nodes['wetGainNode'].gain.value = this._wet;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Reverb.prototype, "level", {
/**
* Getter for the effect's level
* @return {Float}
* @return {number}
*/
}, {
key: 'level',
get: function get() {
get: function () {
return this._level;
}
},
/**
* Setter for the effect's level
* @param {Float} level
* @return {Float}
* @param {number} level
*/
,
set: function set(level) {
set: function (level) {
// Set the internal level value
this._level = parseFloat(level);
// Set the delayTime value of the delay-node
this.nodes.levelGainNode.gain.value = this._level;
return this._level;
}
this.nodes['levelGainNode'].gain.value = this._level;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Reverb.prototype, "buffer", {
/**

@@ -147,34 +107,24 @@ * Getter for the effect's convolver buffer

*/
}, {
key: 'buffer',
get: function get() {
get: function () {
return this._buffer;
}
},
/**
* Setter for the effect's convolver buffer
* @param {Stream} buffer
* @return {Buffer}
*/
,
set: function set(buffer) {
var _this2 = this;
return this.audioContext.decodeAudioData(buffer, function (buffer) {
set: function (buffer) {
var _this = this;
this.audioContext.decodeAudioData(buffer, function (buffer) {
// Set the internal buffer value
_this2._buffer = buffer;
_this._buffer = buffer;
// Set the buffer gain-node value
_this2.nodes.convolverNode.buffer = _this2._buffer;
return _this2._buffer;
_this.nodes['convolverNode'].buffer = _this._buffer;
});
}
}]);
},
enumerable: true,
configurable: true
});
return Reverb;
}(_MultiAudioNode3.default);
exports.default = Reverb;
;
}(MultiAudioNode_1.MultiAudioNode));
exports.Reverb = Reverb;
;

@@ -1,21 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _SingleAudioNode2 = require('../SingleAudioNode');
var _SingleAudioNode3 = _interopRequireDefault(_SingleAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SingleAudioNode_1 = require('../SingleAudioNode');
/**

@@ -25,63 +12,44 @@ * The audio-effects tremolo class.

*/
var Tremolo = function (_SingleAudioNode) {
_inherits(Tremolo, _SingleAudioNode);
var Tremolo = (function (_super) {
__extends(Tremolo, _super);
function Tremolo(audioContext) {
_classCallCheck(this, Tremolo);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Tremolo).call(this, audioContext));
_this.nodes = {
gainNode: audioContext.createGain(), // Create the gain-node
_super.call(this, audioContext);
this.nodes = {
gainNode: audioContext.createGain(),
oscillatorNode: audioContext.createOscillator() // Create the oscilator node
};
// Wire it all up
_this.nodes.oscillatorNode.connect(_this.nodes.gainNode.gain);
this.nodes['oscillatorNode'].connect(this.nodes['gainNode'].gain);
// Setup the oscillator
_this.nodes.oscillatorNode.type = 'sine';
_this.nodes.oscillatorNode.start(0);
this.nodes['oscillatorNode'].type = 'sine';
this.nodes['oscillatorNode'].start(0);
// Set the gain-node as the main node.
_this.node = _this.nodes.gainNode;
this.node = this.nodes['gainNode'];
// Set the default speed to 20Hz
_this.speed = 20;
return _this;
this.speed = 20;
}
/**
* Getter for the effect's speed
* @return {Float}
*/
_createClass(Tremolo, [{
key: 'speed',
get: function get() {
Object.defineProperty(Tremolo.prototype, "speed", {
/**
* Getter for the effect's speed
* @return {number}
*/
get: function () {
return this._speed;
}
},
/**
* Setter for the effect's speed
* @param {Float} speed
* @return {Float}
* @param {number} speed
*/
,
set: function set(speed) {
set: function (speed) {
// Set the internal speed value
this._speed = parseFloat(speed);
// Set the new value for the oscillator frequency
this.nodes.oscillatorNode.frequency.value = this._speed;
return this._speed;
}
}]);
this.nodes['oscillatorNode'].frequency.value = this._speed;
},
enumerable: true,
configurable: true
});
return Tremolo;
}(_SingleAudioNode3.default);
exports.default = Tremolo;
;
}(SingleAudioNode_1.SingleAudioNode));
exports.Tremolo = Tremolo;
;

@@ -1,21 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _SingleAudioNode2 = require('../SingleAudioNode');
var _SingleAudioNode3 = _interopRequireDefault(_SingleAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SingleAudioNode_1 = require('../SingleAudioNode');
/**

@@ -25,96 +12,71 @@ * The audio-effects volume class.

*/
var Volume = function (_SingleAudioNode) {
_inherits(Volume, _SingleAudioNode);
var Volume = (function (_super) {
__extends(Volume, _super);
function Volume(audioContext) {
_classCallCheck(this, Volume);
_super.call(this, audioContext);
// Create the gain-node which we'll use to change the volume.
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Volume).call(this, audioContext));
_this.node = _this._audioContext.createGain();
this.node = this.audioContext.createGain();
// The initial volume level is 100%.
_this.level = 1;
this.level = 1;
// The effect is not muted by default.
_this.mute = false;
return _this;
this.mute = false;
}
/**
* Setter for the effects volume.
* @param {Float} volume The volume, tipical between 0 and 1.
* @return {Float}
*/
_createClass(Volume, [{
key: 'level',
set: function set(volume) {
Object.defineProperty(Volume.prototype, "level", {
/**
* Getter for the effects volume.
* @return {Float}
*/
get: function () {
return this._level;
},
/**
* Setter for the effects volume.
* @param {Float} volume The volume, tipical between 0 and 1.
*/
set: function (volume) {
// Parse the volume, it can not be lower than 0.
var vol = parseFloat(volume);
vol = vol >= 0 ? vol : 0;
vol = (vol >= 0 ? vol : 0);
// Set the internal volume value.
this._level = vol;
// Set the gainNode's gain value.
this._node.gain.value = vol;
this.node.gain.value = vol;
// Set the internal mute value.
this._mute = vol === 0;
return this._level;
}
this._mute = (vol === 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Volume.prototype, "mute", {
/**
* Getter for the effects volume.
* @return {Float}
* Getter for the effcts mute functionality.
* @return {[type]} [description]
*/
,
get: function get() {
return this._level;
}
get: function () {
return this._mute;
},
/**
* Setter for the effects mute functionality.
* @param {Boolean} mute Whether the effect is muted.
* @return {Boolean}
*/
}, {
key: 'mute',
set: function set(mute) {
set: function (mute) {
// Set the internal mute value.
this._mute = !!mute;
if (this._mute) {
// Keep track of the volume before muting
this._levelBeforeMute = this.level;
// Set the volume to 0
this.level = 0;
} else {
}
else {
// Set the volume to the previous volume.
this.level = this._levelBeforeMute || this._level;
}
return this._mute;
}
/**
* Getter for the effcts mute functionality.
* @return {[type]} [description]
*/
,
get: function get() {
return this._mute;
}
}]);
},
enumerable: true,
configurable: true
});
return Volume;
}(_SingleAudioNode3.default);
exports.default = Volume;
;
}(SingleAudioNode_1.SingleAudioNode));
exports.Volume = Volume;
;

@@ -1,21 +0,8 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _SingleAudioNode2 = require('./SingleAudioNode');
var _SingleAudioNode3 = _interopRequireDefault(_SingleAudioNode2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SingleAudioNode_1 = require('./SingleAudioNode');
/**

@@ -28,77 +15,15 @@ * The multi-audio-node class.

*/
var MultiAudioNode = function (_SingleAudioNode) {
_inherits(MultiAudioNode, _SingleAudioNode);
var MultiAudioNode = (function (_super) {
__extends(MultiAudioNode, _super);
function MultiAudioNode(audioContext) {
_classCallCheck(this, MultiAudioNode);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(MultiAudioNode).call(this, audioContext));
_this.nodes = {};
return _this;
_super.call(this, audioContext);
}
/**
* Getter for the effects output node.
* @return {AudioNode}
*/
_createClass(MultiAudioNode, [{
key: 'connect',
Object.defineProperty(MultiAudioNode.prototype, "output", {
/**
* Connect the effect to other effects or native audio-nodes.
* @param {Native AudioNode | Audio-effects AudioNode} node
* @return {Native AudioNode | Audio-effects AudioNode}
* Getter for the effects output node.
* @return {AudioNode}
*/
value: function connect(node) {
// Check if the node is one created by audio-effects
// otherwise assume it's a native one.
if (node.node) {
this.output.connect(node.node);
} else {
this.output.connect(node);
}
return node;
}
/**
* Disconnect the effect.
* @return {Audio-effects AudioNode}
*/
}, {
key: 'disconnect',
value: function disconnect() {
this.output.disconnect();
return this.output;
}
/**
* Destroy an effect.
*/
}, {
key: 'destroy',
value: function destroy() {
var _this2 = this;
this.disconnect();
Object.keys(this.nodes).forEach(function (node) {
if (_this2.nodes[node].disconnect && typeof _this2.nodes[node].disconnect === 'function') {
_this2.nodes[node].disconnect();
}
});
}
}, {
key: 'output',
get: function get() {
get: function () {
return this._outputNode;
}
},
/**

@@ -109,12 +34,48 @@ * Setter for the effects output node.

*/
,
set: function set(output) {
return this._outputNode = output;
set: function (output) {
this._outputNode = output;
},
enumerable: true,
configurable: true
});
/**
* Connect the effect to other effects or native audio-nodes.
* @param {AudioNode|SingleAudioNode|MultiAudioNode} node
* @return {AudioNode|SingleAudioNode|MultiAudioNode}
*/
MultiAudioNode.prototype.connect = function (node) {
// Check if the node is one created by audio-effects
// otherwise assume it's a native one.
if (node.node) {
this.output.connect(node.node);
}
}]);
else {
this.output.connect(node);
}
return node;
};
/**
* Disconnect the effect.
* @return {AudioNode}
*/
MultiAudioNode.prototype.disconnect = function () {
this.output.disconnect();
return this.output;
};
/**
* Destroy an effect.
* @return {AudioNode}
*/
MultiAudioNode.prototype.destroy = function () {
var _this = this;
Object.keys(this.nodes).forEach(function (node) {
if (_this.nodes[node].disconnect && typeof _this.nodes[node].disconnect === 'function') {
_this.nodes[node].disconnect();
}
});
return this.disconnect();
};
return MultiAudioNode;
}(_SingleAudioNode3.default);
exports.default = MultiAudioNode;
;
}(SingleAudioNode_1.SingleAudioNode));
exports.MultiAudioNode = MultiAudioNode;
;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -16,66 +7,34 @@ * The basic audio node class.

*/
var AudioNode = function () {
function AudioNode(audioContext) {
_classCallCheck(this, AudioNode);
var SingleAudioNode = (function () {
function SingleAudioNode(audioContext) {
this.nodes = {};
// Set the audio-context.
this._audioContext = audioContext;
}
/**
* The effect's audio-node getter.
* @return {AudioNode} The audio-node used for the effect.
*/
_createClass(AudioNode, [{
key: "connect",
Object.defineProperty(SingleAudioNode.prototype, "audioContext", {
/**
* Connect the effect to other effects or native audio-nodes.
* @param {Native AudioNode | Audio-effects AudioNode} node
* @return {Native AudioNode | Audio-effects AudioNode}
* The effects AudioContext getter.
* @return {AudioContext} The AudioContext used by the effect.
*/
value: function connect(node) {
// Check if the node is a Audio-effects AudioNode,
// otherwise assume it's a native one.
if (node.node) {
this.node.connect(node.node);
} else {
this.node.connect(node);
}
return node;
}
get: function () {
return this._audioContext;
},
/**
* disconnect the effect.
* @return {Audio-effects AudioNode}
* The effects AudioContext setter.
* @param {AudioContext} audioContext
*/
}, {
key: "disconnect",
value: function disconnect() {
this.node.disconnect();
return this.node;
}
set: function (audioContext) {
this._audioContext = audioContext;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SingleAudioNode.prototype, "node", {
/**
* Alias for the disconnect method, to offer the same api as a MultiAudioNode.
* @return {Audio-effects AudioNode}
* The effect's audio-node getter.
* @return {AudioNode} The audio-node used for the effect.
*/
}, {
key: "destroy",
value: function destroy() {
return this.disconnect();
}
}, {
key: "node",
get: function get() {
get: function () {
return this._node;
}
},
/**

@@ -86,12 +45,42 @@ * The effect's audio-node setter.

*/
,
set: function set(node) {
return this._node = node;
set: function (node) {
this._node = node;
},
enumerable: true,
configurable: true
});
/**
* Connect the effect to other effects or native audio-nodes.
* @param {AudioNode|SingleAudioNode} node
* @return {AudioNode|SingleAudioNode}
*/
SingleAudioNode.prototype.connect = function (node) {
// Check if the node is a Audio-effects AudioNode,
// otherwise assume it's a native one.
if (node.node) {
this.node.connect(node.node);
}
}]);
return AudioNode;
}();
exports.default = AudioNode;
;
else {
this.node.connect(node);
}
return node;
};
/**
* disconnect the effect.
* @return {AudioNode}
*/
SingleAudioNode.prototype.disconnect = function () {
this.node.disconnect();
return this.node;
};
/**
* Alias for the disconnect method, to offer the same api as a MultiAudioNode.
* @return {AudioNode}
*/
SingleAudioNode.prototype.destroy = function () {
return this.disconnect();
};
return SingleAudioNode;
}());
exports.SingleAudioNode = SingleAudioNode;
;

@@ -1,41 +0,20 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _SingleAudioNode = require('./SingleAudioNode');
var _SingleAudioNode2 = _interopRequireDefault(_SingleAudioNode);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var SingleAudioNode_1 = require('./SingleAudioNode');
/**
* Wrap a native audio-node so we can chain it when connecting.
*/
var AudioNodeWrapper = function (_AudioNode) {
_inherits(AudioNodeWrapper, _AudioNode);
var AudioNodeWrapper = (function (_super) {
__extends(AudioNodeWrapper, _super);
function AudioNodeWrapper(audioContext, type) {
var _ret;
_classCallCheck(this, AudioNodeWrapper);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AudioNodeWrapper).call(this, audioContext));
_this.node = audioContext[type]();
return _ret = _this.node, _possibleConstructorReturn(_this, _ret);
_super.call(this, audioContext);
this.node = audioContext[type]();
}
return AudioNodeWrapper;
}(_SingleAudioNode2.default);
exports.default = AudioNodeWrapper;
;
}(SingleAudioNode_1.SingleAudioNode));
exports.AudioNodeWrapper = AudioNodeWrapper;
;

@@ -1,58 +0,2 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.HasGetUserMedia = exports.HasAudioContext = exports.MultiAudioNode = exports.SingleAudioNode = exports.Tremolo = exports.Reverb = exports.Flanger = exports.Delay = exports.Distortion = exports.Volume = exports.Output = exports.Input = undefined;
var _Input = require('./audio-nodes/effects/Input');
var _Input2 = _interopRequireDefault(_Input);
var _Output = require('./audio-nodes/effects/Output');
var _Output2 = _interopRequireDefault(_Output);
var _Volume = require('./audio-nodes/effects/Volume');
var _Volume2 = _interopRequireDefault(_Volume);
var _Distortion = require('./audio-nodes/effects/Distortion');
var _Distortion2 = _interopRequireDefault(_Distortion);
var _Delay = require('./audio-nodes/effects/Delay');
var _Delay2 = _interopRequireDefault(_Delay);
var _Flanger = require('./audio-nodes/effects/Flanger');
var _Flanger2 = _interopRequireDefault(_Flanger);
var _Reverb = require('./audio-nodes/effects/Reverb');
var _Reverb2 = _interopRequireDefault(_Reverb);
var _Tremolo = require('./audio-nodes/effects/Tremolo');
var _Tremolo2 = _interopRequireDefault(_Tremolo);
var _SingleAudioNode = require('./audio-nodes/SingleAudioNode');
var _SingleAudioNode2 = _interopRequireDefault(_SingleAudioNode);
var _MultiAudioNode = require('./audio-nodes/MultiAudioNode');
var _MultiAudioNode2 = _interopRequireDefault(_MultiAudioNode);
var _HasAudioContext = require('./helpers/HasAudioContext');
var _HasAudioContext2 = _interopRequireDefault(_HasAudioContext);
var _HasGetUserMedia = require('./helpers/HasGetUserMedia');
var _HasGetUserMedia2 = _interopRequireDefault(_HasGetUserMedia);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";
/**

@@ -68,13 +12,19 @@ * Export all effects:

* - Tremolo
* - Pitchshifter
*/
exports.Input = _Input2.default;
exports.Output = _Output2.default;
exports.Volume = _Volume2.default;
exports.Distortion = _Distortion2.default;
exports.Delay = _Delay2.default;
exports.Flanger = _Flanger2.default;
exports.Reverb = _Reverb2.default;
exports.Tremolo = _Tremolo2.default;
var Input_1 = require('./audio-nodes/effects/Input');
exports.Input = Input_1.Input;
var Output_1 = require('./audio-nodes/effects/Output');
exports.Output = Output_1.Output;
var Volume_1 = require('./audio-nodes/effects/Volume');
exports.Volume = Volume_1.Volume;
var Distortion_1 = require('./audio-nodes/effects/Distortion');
exports.Distortion = Distortion_1.Distortion;
var Delay_1 = require('./audio-nodes/effects/Delay');
exports.Delay = Delay_1.Delay;
var Flanger_1 = require('./audio-nodes/effects/Flanger');
exports.Flanger = Flanger_1.Flanger;
var Reverb_1 = require('./audio-nodes/effects/Reverb');
exports.Reverb = Reverb_1.Reverb;
var Tremolo_1 = require('./audio-nodes/effects/Tremolo');
exports.Tremolo = Tremolo_1.Tremolo;
/**

@@ -85,6 +35,6 @@ * Export the base audioNodes:

*/
exports.SingleAudioNode = _SingleAudioNode2.default;
exports.MultiAudioNode = _MultiAudioNode2.default;
var SingleAudioNode_1 = require('./audio-nodes/SingleAudioNode');
exports.SingleAudioNode = SingleAudioNode_1.SingleAudioNode;
var MultiAudioNode_1 = require('./audio-nodes/MultiAudioNode');
exports.MultiAudioNode = MultiAudioNode_1.MultiAudioNode;
/**

@@ -95,4 +45,5 @@ * Export helper-functions:

*/
exports.HasAudioContext = _HasAudioContext2.default;
exports.HasGetUserMedia = _HasGetUserMedia2.default;
var HasAudioContext_1 = require('./helpers/HasAudioContext');
exports.HasAudioContext = HasAudioContext_1.HasAudioContext;
var HasGetUserMedia_1 = require('./helpers/HasGetUserMedia');
exports.HasGetUserMedia = HasGetUserMedia_1.HasGetUserMedia;
{
"name": "audio-effects",
"version": "1.0.27",
"version": "1.1.0",
"description": "A javascript library to create audio effects using the web-audio-api",
"main": "dist/index.js",
"dependencies": {
"file-loader": "^0.8.5",
"@types/es6-promise": "0.0.28",
"@types/lodash": "0.0.28",
"@types/webaudioapi": "0.0.26",
"@types/webrtc": "0.0.14",
"@types/whatwg-fetch": "0.0.28",
"lodash": "^4.14.1"
},
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-preset-es2015": "^6.0.12"
"@types/es6-promise": "0.0.28",
"@types/lodash": "0.0.28",
"typescript": "^2.1.0-dev.20160802"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel src -d dist",
"build": "tsc",
"prepublish": "npm run build",

@@ -18,0 +23,0 @@ "postversion": "git push; git push --tags; npm publish"

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