audio-node-suite
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -30,2 +30,3 @@ /* | ||
grunt.loadNpmTasks("grunt-eslint") | ||
grunt.loadNpmTasks("grunt-tslint") | ||
grunt.initConfig({ | ||
@@ -38,2 +39,10 @@ eslint: { | ||
}, | ||
tslint: { | ||
"audio-node-suite": { | ||
options: { | ||
configuration: "tslint.json" | ||
}, | ||
src: "./src/*.ts" | ||
} | ||
}, | ||
browserify: { | ||
@@ -99,4 +108,4 @@ "audio-node-suite-browser": { | ||
}) | ||
grunt.registerTask("default", [ "eslint", "browserify" ]) | ||
grunt.registerTask("default", [ "eslint", "tslint", "browserify" ]) | ||
} | ||
@@ -30,5 +30,5 @@ /* | ||
},{}],3:[function(_dereq_,module,exports){ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeLimiter=exports.AudioNodeCompressor=exports.AudioNodeGain=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js");function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}var AudioNodeGain=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{db:0},o);var r=a.createGain();return r.gain.setValueAtTime((0,_audioNodeSuite1Util.dBFSToGain)(o.db),a.currentTime),r};exports.AudioNodeGain=AudioNodeGain;var AudioNodeCompressor=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{threshold:-16,attack:.003,release:.4,knee:3,ratio:2},o);var r=a.createDynamicsCompressor();return r.threshold.value=o.threshold,r.knee.value=o.knee,r.ratio.value=o.ratio,r.attack.value=o.attack,r.release.value=o.release,r};exports.AudioNodeCompressor=AudioNodeCompressor;var AudioNodeLimiter=function e(a){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];_classCallCheck(this,e),o=Object.assign({},{threshold:-3,attack:.003,release:.05,knee:0,ratio:20});var r=a.createDynamicsCompressor();return r.threshold.value=o.threshold,r.knee.value=o.knee,r.ratio.value=o.ratio,r.attack.value=o.attack,r.release.value=o.release,r};exports.AudioNodeLimiter=AudioNodeLimiter; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeLimiter=exports.AudioNodeCompressor=exports.AudioNodeGain=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js");function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}var AudioNodeGain=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{gain:0},o);var r=a.createGain();return r.gain.setValueAtTime((0,_audioNodeSuite1Util.dBFSToGain)(o.gain),a.currentTime),r};exports.AudioNodeGain=AudioNodeGain;var AudioNodeCompressor=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{threshold:-16,attack:.003,release:.4,knee:3,ratio:2},o);var r=a.createDynamicsCompressor();return r.threshold.value=o.threshold,r.knee.value=o.knee,r.ratio.value=o.ratio,r.attack.value=o.attack,r.release.value=o.release,r};exports.AudioNodeCompressor=AudioNodeCompressor;var AudioNodeLimiter=function e(a){var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];_classCallCheck(this,e),o=Object.assign({},{threshold:-3,attack:.003,release:.05,knee:0,ratio:20});var r=a.createDynamicsCompressor();return r.threshold.value=o.threshold,r.knee.value=o.knee,r.ratio.value=o.ratio,r.attack.value=o.attack,r.release.value=o.release,r};exports.AudioNodeLimiter=AudioNodeLimiter; | ||
},{"./audio-node-suite-1-util.js":1}],4:[function(_dereq_,module,exports){ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeEqualizer=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js");function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}var AudioNodeEqualizer=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e);var i=[];if((o=Object.assign({},{bands:[{type:"peaking",freq:64,q:1,gain:1}]},o)).bands.length<1)throw new Error("at least one band has to be specified");for(var t=0;t<o.bands.length;t++){var n=Object.assign({},{type:"peaking",freq:64*Math.pow(2,t),q:1,gain:1},o.bands[t]),r=a.createBiquadFilter();r.type=n.type,r.frequency.value=n.freq,r.Q.value=n.q,r.gain.value=n.gain,i.push(r),t>0&&i[t-1].connect(i[t])}return 1===o.bands.length?i[0]:new _audioNodeSuite2Composite.AudioNodeComposite(i[0],i[i.length-1])};exports.AudioNodeEqualizer=AudioNodeEqualizer; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeEqualizer=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js");function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}var AudioNodeEqualizer=function e(a){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e);var i=[];if((o=Object.assign({},{bands:[]},o)).bands.length<1)throw new Error("at least one band has to be specified");for(var t=0;t<o.bands.length;t++){var n=Object.assign({},{type:"peaking",freq:64*Math.pow(2,t),q:1,gain:1},o.bands[t]),r=a.createBiquadFilter();r.type=n.type,r.frequency.value=n.freq,r.Q.value=n.q,r.gain.value=n.gain,i.push(r),t>0&&i[t-1].connect(i[t])}return 1===o.bands.length?i[0]:new _audioNodeSuite2Composite.AudioNodeComposite(i[0],i[i.length-1])};exports.AudioNodeEqualizer=AudioNodeEqualizer; | ||
},{"./audio-node-suite-2-composite.js":2}],5:[function(_dereq_,module,exports){ | ||
@@ -41,3 +41,3 @@ "use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeMeter=void 0;var AudioNodeMeter=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),n=Object.assign({},{fftSize:2048,minDecibels:-100,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:1e3/120,intervalLength:100},n);var a=t.createAnalyser();a.fftSize=n.fftSize,a.minDecibels=n.minDecibels,a.maxDecibels=n.maxDecibels,a.smoothingTimeConstant=n.smoothingTimeConstant;var i=new Float32Array(a.frequencyBinCount),r=new Float32Array(a.frequencyBinCount),l=[],o=-1,s=[],v=-1,c=function(e,t,n){for(var a=e.length<n?e.length:n,i=0,r=0,l=0;l<=t;l++){var o=l+(a-t);i+=o*e[l],r+=o}for(var s=t+1;s<a;s++){var v=s-(t+1);i+=v*e[s],r+=v}return i/=r,i},h=function(){a.getFloatFrequencyData(i);for(var e={},t=0,h=0;h<i.length;h++)i[h]<a.minDecibels?i[h]=a.minDecibels:i[h]>a.maxDecibels&&(i[h]=a.maxDecibels),t+=i[h]*i[h],r[h]=i[h];e.avg=Math.sqrt(t/i.length),r.sort(),e.min=r[0];var m=Math.floor(r.length/8);e.q1=r[1*m],e.q2=r[2*m],e.q3=r[3*m],e.med=r[4*m],e.q4=r[5*m],e.q5=r[6*m],e.q6=r[7*m],e.max=r[r.length-1],o=(o+1)%n.intervalLength,l[o]=e.max,e.lvlAvg=c(l,o,n.intervalLength),e.lvlDev=Math.abs(e.max-e.lvlAvg),v=(v+1)%n.intervalLength,s[v]=e.lvlDev,e.devAvg=c(s,v,n.intervalLength),e.devDev=Math.abs(e.lvlDev-e.devAvg),a._stat=e};return setInterval(h,n.intervalTime),h(),a.data=function(){return i},a.stat=function(){return a._stat},a};exports.AudioNodeMeter=AudioNodeMeter; | ||
},{"./audio-node-suite-5-meter.js":5}],8:[function(_dereq_,module,exports){ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeVoiceFilter=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js");function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var AudioNodeVoiceFilter=function e(o){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),i=Object.assign({},{},i);var d=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"highpass",freq:80,q:1},{type:"notch",freq:50,q:20},{type:"notch",freq:960,q:1.5},{type:"lowpass",freq:20480,q:.5}]}),t=new _audioNodeSuite6Gate.AudioNodeGate(o,{threshold:-50,hysteresis:-6,reduction:-50,interval:2,attack:4,hold:40,release:20}),a=new _audioNodeSuite3Standard.AudioNodeCompressor(o,{threshold:-16,attack:.003,release:.4,knee:3,ratio:2}),u=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"peaking",freq:240,q:.75,gain:3},{type:"highshelf",freq:3840,q:.75,gain:6}]}),r=new _audioNodeSuite3Standard.AudioNodeGain(o,{db:-6}),n=new _audioNodeSuite3Standard.AudioNodeLimiter(o,{threshold:-3});return d.connect(t),t.connect(a),a.connect(u),u.connect(r),r.connect(n),new _audioNodeSuite2Composite.AudioNodeComposite(d,n)};exports.AudioNodeVoiceFilter=AudioNodeVoiceFilter; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeVoiceFilter=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js");function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var AudioNodeVoiceFilter=function e(o){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),i=Object.assign({},{gain:0},i);var t=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"highpass",freq:80,q:1},{type:"notch",freq:50,q:20},{type:"notch",freq:960,q:1.5},{type:"lowpass",freq:20480,q:.5}]}),d=new _audioNodeSuite6Gate.AudioNodeGate(o,{threshold:-50,hysteresis:-6,reduction:-50,interval:2,attack:4,hold:40,release:20}),a=new _audioNodeSuite3Standard.AudioNodeCompressor(o,{threshold:-16,attack:.003,release:.4,knee:3,ratio:2}),u=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"peaking",freq:240,q:.75,gain:3},{type:"highshelf",freq:3840,q:.75,gain:6}]}),r=new _audioNodeSuite3Standard.AudioNodeGain(o,{gain:-6+i.gain}),n=new _audioNodeSuite3Standard.AudioNodeLimiter(o,{threshold:-3});return t.connect(d),d.connect(a),a.connect(u),u.connect(r),r.connect(n),new _audioNodeSuite2Composite.AudioNodeComposite(t,n)};exports.AudioNodeVoiceFilter=AudioNodeVoiceFilter; | ||
},{"./audio-node-suite-2-composite.js":2,"./audio-node-suite-3-standard.js":3,"./audio-node-suite-4-equalizer.js":4,"./audio-node-suite-6-gate.js":6}],9:[function(_dereq_,module,exports){ | ||
@@ -44,0 +44,0 @@ "use strict";var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js"),_audioNodeSuite7Spectrum=_dereq_("./audio-node-suite-7-spectrum.js"),_audioNodeSuite8Voice=_dereq_("./audio-node-suite-8-voice.js");module.exports={AudioNodeComposite:_audioNodeSuite2Composite.AudioNodeComposite,AudioNodeGain:_audioNodeSuite3Standard.AudioNodeGain,AudioNodeCompressor:_audioNodeSuite3Standard.AudioNodeCompressor,AudioNodeLimiter:_audioNodeSuite3Standard.AudioNodeLimiter,AudioNodeEqualizer:_audioNodeSuite4Equalizer.AudioNodeEqualizer,AudioNodeMeter:_audioNodeSuite5Meter.AudioNodeMeter,AudioNodeGate:_audioNodeSuite6Gate.AudioNodeGate,AudioNodeSpectrum:_audioNodeSuite7Spectrum.AudioNodeSpectrum,AudioNodeVoice:_audioNodeSuite8Voice.AudioNodeVoice}; |
@@ -278,3 +278,3 @@ /* | ||
params = Object.assign({}, { | ||
db: 0 | ||
gain: 0 | ||
}, params); | ||
@@ -284,3 +284,3 @@ /* create and configure underlying Gain node */ | ||
const gain = context.createGain(); | ||
gain.gain.setValueAtTime((0, _audioNodeSuite1Util.dBFSToGain)(params.db), context.currentTime); | ||
gain.gain.setValueAtTime((0, _audioNodeSuite1Util.dBFSToGain)(params.gain), context.currentTime); | ||
return gain; | ||
@@ -388,8 +388,3 @@ } | ||
params = Object.assign({}, { | ||
bands: [{ | ||
type: "peaking", | ||
freq: 64, | ||
q: 1, | ||
gain: 1.0 | ||
}] | ||
bands: [] | ||
}, params); | ||
@@ -406,3 +401,3 @@ /* interate over all bands */ | ||
freq: 64 * Math.pow(2, i), | ||
q: 1, | ||
q: 1.0, | ||
gain: 1.0 | ||
@@ -978,3 +973,3 @@ }, params.bands[i]); | ||
params = Object.assign({}, { | ||
/* NONE */ | ||
gain: 0.0 | ||
}, params); | ||
@@ -1040,3 +1035,3 @@ /* 1. create: cutting equalizer */ | ||
const gain = new _audioNodeSuite3Standard.AudioNodeGain(context, { | ||
db: -6.0 | ||
gain: -6.0 + params.gain | ||
}); | ||
@@ -1043,0 +1038,0 @@ /* 6. create: limiter */ |
{ | ||
"name": "audio-node-suite", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Audio-Node-Suite -- Web Audio API AudioNode Suite", | ||
@@ -27,2 +27,5 @@ "keywords": [ "web", "audio", "api", "audionode", "suite" ], | ||
"grunt-browserify": "5.3.0", | ||
"grunt-tslint": "5.0.2", | ||
"tslint": "6.1.3", | ||
"typescript": "4.0.3", | ||
"grunt-eslint": "23.0.0", | ||
@@ -29,0 +32,0 @@ "babel-eslint": "10.1.0", |
@@ -60,2 +60,8 @@ | ||
Usage | ||
----- | ||
See the [TypeScript definition file](src/audio-node-suite.d.ts) | ||
for details on the exposed Application Programming Interface (API). | ||
Implementation Notice | ||
@@ -62,0 +68,0 @@ --------------------- |
@@ -33,3 +33,3 @@ /* | ||
params = Object.assign({}, { | ||
db: 0 | ||
gain: 0 | ||
}, params) | ||
@@ -39,3 +39,3 @@ | ||
const gain = context.createGain() | ||
gain.gain.setValueAtTime(dBFSToGain(params.db), context.currentTime) | ||
gain.gain.setValueAtTime(dBFSToGain(params.gain), context.currentTime) | ||
return gain | ||
@@ -42,0 +42,0 @@ } |
@@ -33,3 +33,3 @@ /* | ||
params = Object.assign({}, { | ||
bands: [ { type: "peaking", freq: 64, q: 1, gain: 1.0 } ] | ||
bands: [] | ||
}, params) | ||
@@ -46,3 +46,3 @@ | ||
freq: 64 * Math.pow(2, i), | ||
q: 1, | ||
q: 1.0, | ||
gain: 1.0 | ||
@@ -49,0 +49,0 @@ }, params.bands[i]) |
@@ -46,3 +46,3 @@ /* | ||
params = Object.assign({}, { | ||
/* NONE */ | ||
gain: 0.0 | ||
}, params) | ||
@@ -90,3 +90,3 @@ | ||
const gain = new AudioNodeGain(context, { | ||
db: -6.0 | ||
gain: -6.0 + params.gain | ||
}) | ||
@@ -93,0 +93,0 @@ |
118867
18
2129
101
21