├── .babelrc ├── .gitignore ├── README.md ├── build ├── bundle.js └── index.html ├── js └── index.js ├── package.json └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015" 4 | ], 5 | "plugins": [ 6 | "transform-decorators-legacy", 7 | "transform-class-properties", 8 | "transform-object-rest-spread", 9 | "transform-async-to-generator", 10 | "transform-async-to-module-method", 11 | ["transform-runtime", { 12 | "polyfill": false, 13 | "regenerator": true 14 | }] 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | <<<<<<< 6f87c16601e1b81e9c889801c5598faf1495fe8e 18 | # nyc test coverage 19 | .nyc_output 20 | 21 | ======= 22 | >>>>>>> First commit - Adding the whole project 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # node-waf configuration 27 | .lock-wscript 28 | 29 | # Compiled binary addons (http://nodejs.org/api/addons.html) 30 | build/Release 31 | 32 | # Dependency directories 33 | node_modules 34 | jspm_packages 35 | 36 | # Optional npm cache directory 37 | .npm 38 | 39 | # Optional REPL history 40 | .node_repl_history 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ATTENTION! 2 | # This package is now maintained as a part of the [sountility collection](https://github.com/scriptify/sountility). This repository won't be used anymore for this package, but it will still be maintained. 3 | 4 | # Chnl - one channel, all effects. 5 | 6 | ## Why would I ever want a _Chnl_? 7 | 8 | I needed something with a LOT of audio effects integrated which can be manipulated in many different aspects. And I needed to use this in many different ways: Every native AudioNode should be able to connect to it as it would be a normal AudioNode, but also other Chnls should be able to connect to another Chnl. 9 | So I could simply and intuitively create audio graphs with a set of effects. 10 | No matter if I connect a song, mic input or even a synthesizer. 11 | 12 | __Therefore I created _Chnl_.__ 13 | 14 | __Attention__: Since the [webaudio-effect-unit](https://github.com/scriptify/webaudio-effect-unit) has reached v.1.1.0, the way how the effects work has changed. Have a look at it's repository for more details. Make sure to do this __BEFORE__ you update. If you have difficulties or question, just open an issue! I am always glad if I can help. :smile: 15 | ## Installation 16 | Via npm 17 | ``` 18 | npm i webaudio-chnl -S 19 | ``` 20 | 21 | 22 | ## Usage 23 | It's really simple. And intuitive. 24 | ### Creating a __Chnl__ 25 | You can create a new _Chnl_ instance by constructing the _Chnl_-class with your _AudioContext object_ as the 1° parameter. 26 | ```javascript 27 | new Channel(audioCtx) 28 | ``` 29 | 30 | ### Effects 31 | You have access to __a lot of effects__. 32 | Under the hood, _Chnl_ uses the [webaudio-effect-units-collection](https://github.com/scriptify/webaudio-effect-units-collection) module. So you have access to a lot of effects which can be enabled and disabled. 33 | 34 | You can access the effects with the _effects_ property of your _Chnl_ instance. 35 | 36 | 37 | _Example_ 38 | ```javascript 39 | const channel = new Chnl(audioCtx); 40 | const { 41 | gain, 42 | chorus, 43 | delay, 44 | phaser, 45 | overdrive, 46 | compressor, 47 | lowpass, 48 | highpass, 49 | tremolo, 50 | wahwah, 51 | bitcrusher, 52 | moog, 53 | pingPongDelay 54 | } = channel.effects; 55 | 56 | gain.setValue('gain', 0.55); 57 | 58 | delay.addEffect('delay'); 59 | delay.setValue('feedback', 0.2); 60 | ``` 61 | 62 | ### Connecting 63 | #### Connect to a Chnl 64 | You can connect any _normal AudioNode_ to a _Chnl_: 65 | ```javascript 66 | const channel = new Chnl(audioCtx); 67 | const gain = audioCtx.createGain(); 68 | gain.connect(channel); 69 | ``` 70 | But you can also connect a _Chnl_ to a _normal AudioNode_: 71 | ```javascript 72 | const channel = new Chnl(audioCtx); 73 | const gain = audioCtx.createGain(); 74 | channel.connect(gain); 75 | ``` 76 | You can even connect one _Chnl_ to another one: 77 | ```javascript 78 | const channel1 = new Chnl(audioCtx); 79 | const channel2 = new Chnl(audioCtx); 80 | channel1.connect(channel2); 81 | ``` 82 | Have fun connecting! 83 | 84 | ### Activating an effect (since v0.0.6) 85 | Per default, no effect is connected in the interior audio graph. In previous versions, this was the case. I decided to revise the way how effects are used. Because if all effects are initially actively connected, there's way more needless audio processing (also if the effects are initially turned off). Therefore I decided to connect the effects only if they are explicitly needed. 86 | 87 | __TLDR:__ Before using an effect, you need to activate it. When activating an effect, the whole audiograph will be rebuilt. 88 | 89 | __Note:__ The 'gain'-effect is already activated by default. 90 | 91 | _Example_: 92 | ```javascript 93 | const chnl = new Chnl(audioCtx); 94 | chnl.addEffect('delay'); 95 | chnl.addEffect('chorus'); 96 | chnl.effects.delay.setValue('delayTime', 500); 97 | ``` 98 | 99 | ### Disabling an effect (since v0.0.6) 100 | Since you can activate an effect, it's no surprise that you can also disable the same effect. When you disable an effect, it will be removed from the audiograph to prevent needless processing. 101 | _Example_: 102 | ```javascript 103 | const chnl = new Chnl(audioCtx); 104 | chnl.addEffect('delay'); 105 | chnl.effects.delay.setValue('delayTime', 500); 106 | chnl.removeEffect('chorus'); 107 | ``` 108 | 109 | ### Final example 110 | This a bit more advanced example, which connects an oscillator to a Chnl and applies some effects. 111 | ```javascript 112 | const audioCtx = new AudioContext(); 113 | const chnl = new Chnl(audioCtx); 114 | 115 | const osci = audioCtx.createOscillator(); 116 | osci.frequency.value = 300; 117 | 118 | osci.connect(chnl); 119 | chnl.connect(audioCtx.destination); 120 | 121 | // Activate effects 122 | chnl.addEffect('highpass'); 123 | chnl.addEffect('bitcrusher'); 124 | 125 | chnl.effects.gain.setValue('gain', 0.2); 126 | chnl.effects.highpass.setValue('frequency', 500); 127 | chnl.effects.bitcrusher.setValue('bits', 4); 128 | 129 | osci.start(); 130 | ``` 131 | -------------------------------------------------------------------------------- /build/bundle.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EffectUnit=t():e.EffectUnit=t()}(this,function(){return function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return e[a].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=n(1),r=a(i),o=n(55),u=a(o),s=n(56),c=a(s),l=n(60),f=a(l),h=function(){function e(t){(0,u.default)(this,e),this.currentGraph=[],this.context=t,this.input=t.createGain(),this.output=t.createGain(),this.effects=(0,f.default)(t),this.setupGraph([this.input,this.effects.gain,this.output])}return(0,c.default)(e,[{key:"setupGraph",value:function(e){for(var t=0;t=t.length?{value:void 0,done:!0}:(e=a(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){var a=n(6),i=n(7);e.exports=function(e){return function(t,n){var r,o,u=String(i(t)),s=a(n),c=u.length;return s<0||s>=c?e?"":void 0:(r=u.charCodeAt(s),r<55296||r>56319||s+1===c||(o=u.charCodeAt(s+1))<56320||o>57343?e?u.charAt(s):r:e?u.slice(s,s+2):(r-55296<<10)+(o-56320)+65536)}}},function(e,t){var n=Math.ceil,a=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?a:n)(e)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){"use strict";var a=n(9),i=n(10),r=n(25),o=n(15),u=n(26),s=n(27),c=n(28),l=n(44),f=n(46),h=n(45)("iterator"),p=!([].keys&&"next"in[].keys()),d="@@iterator",v="keys",m="values",y=function(){return this};e.exports=function(e,t,n,b,g,_,x){c(n,t,b);var w,k,M,O=function(e){if(!p&&e in T)return T[e];switch(e){case v:return function(){return new n(this,e)};case m:return function(){return new n(this,e)}}return function(){return new n(this,e)}},G=t+" Iterator",P=g==m,L=!1,T=e.prototype,j=T[h]||T[d]||g&&T[g],F=j||O(g),C=g?P?O("entries"):F:void 0,q="Array"==t?T.entries||j:j;if(q&&(M=f(q.call(new e)),M!==Object.prototype&&(l(M,G,!0),a||u(M,h)||o(M,h,y))),P&&j&&j.name!==m&&(L=!0,F=function(){return j.call(this)}),a&&!x||!p&&!L&&T[h]||o(T,h,F),s[t]=F,s[G]=y,g)if(w={values:P?F:O(m),keys:_?F:O(v),entries:C},x)for(k in w)k in T||r(T,k,w[k]);else i(i.P+i.F*(p||L),t,w);return w}},function(e,t){e.exports=!0},function(e,t,n){var a=n(11),i=n(12),r=n(13),o=n(15),u="prototype",s=function(e,t,n){var c,l,f,h=e&s.F,p=e&s.G,d=e&s.S,v=e&s.P,m=e&s.B,y=e&s.W,b=p?i:i[t]||(i[t]={}),g=b[u],_=p?a:d?a[t]:(a[t]||{})[u];p&&(n=t);for(c in n)l=!h&&_&&void 0!==_[c],l&&c in b||(f=l?_[c]:n[c],b[c]=p&&"function"!=typeof _[c]?n[c]:m&&l?r(f,a):y&&_[c]==f?function(e){var t=function(t,n,a){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,a)}return e.apply(this,arguments)};return t[u]=e[u],t}(f):v&&"function"==typeof f?r(Function.call,f):f,v&&((b.virtual||(b.virtual={}))[c]=f,e&s.R&&g&&!g[c]&&o(g,c,f)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(e,t){var n=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=n)},function(e,t,n){var a=n(14);e.exports=function(e,t,n){if(a(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,a){return e.call(t,n,a)};case 3:return function(n,a,i){return e.call(t,n,a,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){var a=n(16),i=n(24);e.exports=n(20)?function(e,t,n){return a.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){var a=n(17),i=n(19),r=n(23),o=Object.defineProperty;t.f=n(20)?Object.defineProperty:function(e,t,n){if(a(e),t=r(t,!0),a(n),i)try{return o(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var a=n(18);e.exports=function(e){if(!a(e))throw TypeError(e+" is not an object!");return e}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){e.exports=!n(20)&&!n(21)(function(){return 7!=Object.defineProperty(n(22)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){e.exports=!n(21)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){var a=n(18),i=n(11).document,r=a(i)&&a(i.createElement);e.exports=function(e){return r?i.createElement(e):{}}},function(e,t,n){var a=n(18);e.exports=function(e,t){if(!a(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!a(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!a(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!a(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){e.exports=n(15)},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports={}},function(e,t,n){"use strict";var a=n(29),i=n(24),r=n(44),o={};n(15)(o,n(45)("iterator"),function(){return this}),e.exports=function(e,t,n){e.prototype=a(o,{next:i(1,n)}),r(e,t+" Iterator")}},function(e,t,n){var a=n(17),i=n(30),r=n(42),o=n(39)("IE_PROTO"),u=function(){},s="prototype",c=function(){var e,t=n(22)("iframe"),a=r.length,i="<",o=">";for(t.style.display="none",n(43).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write(i+"script"+o+"document.F=Object"+i+"/script"+o),e.close(),c=e.F;a--;)delete c[s][r[a]];return c()};e.exports=Object.create||function(e,t){var n;return null!==e?(u[s]=a(e),n=new u,u[s]=null,n[o]=e):n=c(),void 0===t?n:i(n,t)}},function(e,t,n){var a=n(16),i=n(17),r=n(31);e.exports=n(20)?Object.defineProperties:function(e,t){i(e);for(var n,o=r(t),u=o.length,s=0;u>s;)a.f(e,n=o[s++],t[n]);return e}},function(e,t,n){var a=n(32),i=n(42);e.exports=Object.keys||function(e){return a(e,i)}},function(e,t,n){var a=n(26),i=n(33),r=n(36)(!1),o=n(39)("IE_PROTO");e.exports=function(e,t){var n,u=i(e),s=0,c=[];for(n in u)n!=o&&a(u,n)&&c.push(n);for(;t.length>s;)a(u,n=t[s++])&&(~r(c,n)||c.push(n));return c}},function(e,t,n){var a=n(34),i=n(7);e.exports=function(e){return a(i(e))}},function(e,t,n){var a=n(35);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==a(e)?e.split(""):Object(e)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var a=n(33),i=n(37),r=n(38);e.exports=function(e){return function(t,n,o){var u,s=a(t),c=i(s.length),l=r(o,c);if(e&&n!=n){for(;c>l;)if(u=s[l++],u!=u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===n)return e||l||0;return!e&&-1}}},function(e,t,n){var a=n(6),i=Math.min;e.exports=function(e){return e>0?i(a(e),9007199254740991):0}},function(e,t,n){var a=n(6),i=Math.max,r=Math.min;e.exports=function(e,t){return e=a(e),e<0?i(e+t,0):r(e,t)}},function(e,t,n){var a=n(40)("keys"),i=n(41);e.exports=function(e){return a[e]||(a[e]=i(e))}},function(e,t,n){var a=n(11),i="__core-js_shared__",r=a[i]||(a[i]={});e.exports=function(e){return r[e]||(r[e]={})}},function(e,t){var n=0,a=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+a).toString(36))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t,n){e.exports=n(11).document&&document.documentElement},function(e,t,n){var a=n(16).f,i=n(26),r=n(45)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,r)&&a(e,r,{configurable:!0,value:t})}},function(e,t,n){var a=n(40)("wks"),i=n(41),r=n(11).Symbol,o="function"==typeof r,u=e.exports=function(e){return a[e]||(a[e]=o&&r[e]||(o?r:i)("Symbol."+e))};u.store=a},function(e,t,n){var a=n(26),i=n(47),r=n(39)("IE_PROTO"),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),a(e,r)?e[r]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var a=n(7);e.exports=function(e){return Object(a(e))}},function(e,t,n){"use strict";var a=n(13),i=n(10),r=n(47),o=n(49),u=n(50),s=n(37),c=n(51),l=n(52);i(i.S+i.F*!n(54)(function(e){Array.from(e)}),"Array",{from:function(e){var t,n,i,f,h=r(e),p="function"==typeof this?this:Array,d=arguments.length,v=d>1?arguments[1]:void 0,m=void 0!==v,y=0,b=l(h);if(m&&(v=a(v,d>2?arguments[2]:void 0,2)),void 0==b||p==Array&&u(b))for(t=s(h.length),n=new p(t);t>y;y++)c(n,y,m?v(h[y],y):h[y]);else for(f=b.call(h),n=new p;!(i=f.next()).done;y++)c(n,y,m?o(f,v,[i.value,y],!0):i.value);return n.length=y,n}})},function(e,t,n){var a=n(17);e.exports=function(e,t,n,i){try{return i?t(a(n)[0],n[1]):t(n)}catch(t){var r=e.return;throw void 0!==r&&a(r.call(e)),t}}},function(e,t,n){var a=n(27),i=n(45)("iterator"),r=Array.prototype;e.exports=function(e){return void 0!==e&&(a.Array===e||r[i]===e)}},function(e,t,n){"use strict";var a=n(16),i=n(24);e.exports=function(e,t,n){t in e?a.f(e,t,i(0,n)):e[t]=n}},function(e,t,n){var a=n(53),i=n(45)("iterator"),r=n(27);e.exports=n(12).getIteratorMethod=function(e){if(void 0!=e)return e[i]||e["@@iterator"]||r[a(e)]}},function(e,t,n){var a=n(35),i=n(45)("toStringTag"),r="Arguments"==a(function(){return arguments}()),o=function(e,t){try{return e[t]}catch(e){}};e.exports=function(e){var t,n,u;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=o(t=Object(e),i))?n:r?a(t):"Object"==(u=a(t))&&"function"==typeof t.callee?"Arguments":u}},function(e,t,n){var a=n(45)("iterator"),i=!1;try{var r=[7][a]();r.return=function(){i=!0},Array.from(r,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var r=[7],o=r[a]();o.next=function(){return{done:n=!0}},r[a]=function(){return o},e(r)}catch(e){}return n}},function(e,t){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=n(57),r=a(i);t.default=function(){function e(e,t){for(var n=0;ni&&(i=r),a=e%t,i<-100||i>20?(o=Math.round(Math.log(a)/Math.log(10)),u=Math.pow(10,o),(a/u).toFixed(o-i)*u):parseFloat(a.toFixed(-i))}function o(e){return 0===e?1:Math.abs(e)/e}function u(e){return(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))}function s(e,t){return void 0===e?t:e}var c,l,f=function(e,t){e.value=t},h=Object.create(null,{activate:{writable:!0,value:function(e){e?(this.input.disconnect(),this.input.connect(this.activateNode),this.activateCallback&&this.activateCallback(e)):(this.input.disconnect(),this.input.connect(this.output))}},bypass:{get:function(){return this._bypass},set:function(e){this._lastBypassValue!==e&&(this._bypass=e,this.activate(!e),this._lastBypassValue=e)}},connect:{value:function(e){this.output.connect(e)}},disconnect:{value:function(e){this.output.disconnect(e)}},connectInOrder:{value:function(e){for(var t=e.length-1;t--;){if(!e[t].connect)return console.error("AudioNode.connectInOrder: TypeError: Not an AudioNode.",e[t]);e[t+1].input?e[t].connect(e[t+1].input):e[t].connect(e[t+1])}}},getDefaults:{value:function(){var e={};for(var t in this.defaults)e[t]=this.defaults[t].value;return e}},automate:{value:function(e,t,n,a){var i,r=a?~~(a/1e3):c.currentTime,o=n?~~(n/1e3):0,u=this.defaults[e],s=this[e];s?u.automatable?(n?(i="linearRampToValueAtTime",s.cancelScheduledValues(r),s.setValueAtTime(s.value,r)):i="setValueAtTime",s[i](t,o+r)):s=t:console.error("Invalid Property for "+this.name)}}}),p="float",d="boolean",v="string",m="int";"undefined"!=typeof e&&e.exports?e.exports=n:window.define("Tuna",t),n.prototype.Bitcrusher=function(e){e||(e=this.getDefaults()),this.bufferSize=e.bufferSize||this.defaults.bufferSize.value,this.input=c.createGain(),this.activateNode=c.createGain(),this.processor=c.createScriptProcessor(this.bufferSize,1,1),this.output=c.createGain(),this.activateNode.connect(this.processor),this.processor.connect(this.output);var t,n,a,i,r,o=0,u=0;this.processor.onaudioprocess=function(e){for(t=e.inputBuffer.getChannelData(0),n=e.outputBuffer.getChannelData(0),a=Math.pow(.5,this.bits),r=t.length,i=0;i=1&&(o-=1,u=a*Math.floor(t[i]/a+.5)),n[i]=u},this.bits=e.bits||this.defaults.bits.value,this.normfreq=s(e.normfreq,this.defaults.normfreq.value),this.bypass=e.bypass||!1},n.prototype.Bitcrusher.prototype=Object.create(h,{name:{value:"Bitcrusher"},defaults:{writable:!0,value:{bits:{value:4,min:1,max:16,automatable:!1,type:m},bufferSize:{value:4096,min:256,max:16384,automatable:!1,type:m},bypass:{value:!1,automatable:!1,type:d},normfreq:{value:.1,min:1e-4,max:1,automatable:!1,type:p}}},bits:{enumerable:!0,get:function(){return this.processor.bits},set:function(e){this.processor.bits=e}},normfreq:{enumerable:!0,get:function(){return this.processor.normfreq},set:function(e){this.processor.normfreq=e}}}),n.prototype.Cabinet=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.activateNode=c.createGain(),this.convolver=this.newConvolver(e.impulsePath||"../impulses/impulse_guitar.wav"),this.makeupNode=c.createGain(),this.output=c.createGain(),this.activateNode.connect(this.convolver.input),this.convolver.output.connect(this.makeupNode),this.makeupNode.connect(this.output),this.makeupGain=s(e.makeupGain,this.defaults.makeupGain),this.bypass=e.bypass||!1},n.prototype.Cabinet.prototype=Object.create(h,{name:{value:"Cabinet"},defaults:{writable:!0,value:{makeupGain:{value:1,min:0,max:20,automatable:!0,type:p},bypass:{value:!1,automatable:!1,type:d}}},makeupGain:{enumerable:!0,get:function(){return this.makeupNode.gain},set:function(e){this.makeupNode.gain.value=e}},newConvolver:{value:function(e){return new l.Convolver({impulse:e,dryLevel:0,wetLevel:1})}}}),n.prototype.Chorus=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.attenuator=this.activateNode=c.createGain(),this.splitter=c.createChannelSplitter(2),this.delayL=c.createDelay(),this.delayR=c.createDelay(),this.feedbackGainNodeLR=c.createGain(),this.feedbackGainNodeRL=c.createGain(),this.merger=c.createChannelMerger(2),this.output=c.createGain(),this.lfoL=new l.LFO({target:this.delayL.delayTime,callback:f}),this.lfoR=new l.LFO({target:this.delayR.delayTime,callback:f}),this.input.connect(this.attenuator),this.attenuator.connect(this.output),this.attenuator.connect(this.splitter),this.splitter.connect(this.delayL,0),this.splitter.connect(this.delayR,1),this.delayL.connect(this.feedbackGainNodeLR),this.delayR.connect(this.feedbackGainNodeRL),this.feedbackGainNodeLR.connect(this.delayR),this.feedbackGainNodeRL.connect(this.delayL),this.delayL.connect(this.merger,0,0),this.delayR.connect(this.merger,0,1),this.merger.connect(this.output),this.feedback=s(e.feedback,this.defaults.feedback.value),this.rate=s(e.rate,this.defaults.rate.value),this.delay=s(e.delay,this.defaults.delay.value),this.depth=s(e.depth,this.defaults.depth.value),this.lfoR.phase=Math.PI/2,this.attenuator.gain.value=.6934,this.lfoL.activate(!0),this.lfoR.activate(!0),this.bypass=e.bypass||!1},n.prototype.Chorus.prototype=Object.create(h,{name:{value:"Chorus"},defaults:{writable:!0,value:{feedback:{value:.4,min:0,max:.95,automatable:!1,type:p},delay:{value:.0045,min:0,max:1,automatable:!1,type:p},depth:{value:.7,min:0,max:1,automatable:!1,type:p},rate:{value:1.5,min:0,max:8,automatable:!1,type:p},bypass:{value:!1,automatable:!1,type:d}}},delay:{enumerable:!0,get:function(){return this._delay},set:function(e){this._delay=2e-4*(2*Math.pow(10,e)),this.lfoL.offset=this._delay,this.lfoR.offset=this._delay,this._depth=this._depth}},depth:{enumerable:!0,get:function(){return this._depth},set:function(e){this._depth=e,this.lfoL.oscillation=this._depth*this._delay,this.lfoR.oscillation=this._depth*this._delay}},feedback:{enumerable:!0,get:function(){return this._feedback},set:function(e){this._feedback=e,this.feedbackGainNodeLR.gain.value=this._feedback,this.feedbackGainNodeRL.gain.value=this._feedback}},rate:{enumerable:!0,get:function(){return this._rate},set:function(e){this._rate=e,this.lfoL.frequency=this._rate,this.lfoR.frequency=this._rate}}}),n.prototype.Compressor=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.compNode=this.activateNode=c.createDynamicsCompressor(),this.makeupNode=c.createGain(),this.output=c.createGain(),this.compNode.connect(this.makeupNode),this.makeupNode.connect(this.output),this.automakeup=s(e.automakeup,this.defaults.automakeup.value),this.makeupGain=s(e.makeupGain,this.defaults.makeupGain.value),this.threshold=s(e.threshold,this.defaults.threshold.value),this.release=s(e.release,this.defaults.release.value),this.attack=s(e.attack,this.defaults.attack.value),this.ratio=e.ratio||this.defaults.ratio.value,this.knee=s(e.knee,this.defaults.knee.value),this.bypass=e.bypass||!1},n.prototype.Compressor.prototype=Object.create(h,{name:{value:"Compressor"},defaults:{writable:!0,value:{threshold:{value:-20,min:-60,max:0,automatable:!0,type:p},release:{value:250,min:10,max:2e3,automatable:!0,type:p},makeupGain:{value:1,min:1,max:100,automatable:!0,type:p},attack:{value:1,min:0,max:1e3,automatable:!0,type:p},ratio:{value:4,min:1,max:50,automatable:!0,type:p},knee:{value:5,min:0,max:40,automatable:!0,type:p},automakeup:{value:!1,automatable:!1,type:d},bypass:{value:!1,automatable:!1,type:d}}},computeMakeup:{value:function(){var e=4,t=this.compNode;return-(t.threshold.value-t.threshold.value/t.ratio.value)/e}},automakeup:{enumerable:!0,get:function(){return this._automakeup},set:function(e){this._automakeup=e,this._automakeup&&(this.makeupGain=this.computeMakeup())}},threshold:{enumerable:!0,get:function(){return this.compNode.threshold},set:function(e){this.compNode.threshold.value=e,this._automakeup&&(this.makeupGain=this.computeMakeup())}},ratio:{enumerable:!0,get:function(){return this.compNode.ratio},set:function(e){this.compNode.ratio.value=e,this._automakeup&&(this.makeupGain=this.computeMakeup())}},knee:{enumerable:!0,get:function(){return this.compNode.knee},set:function(e){this.compNode.knee.value=e,this._automakeup&&(this.makeupGain=this.computeMakeup())}},attack:{enumerable:!0,get:function(){return this.compNode.attack},set:function(e){this.compNode.attack.value=e/1e3}},release:{enumerable:!0,get:function(){return this.compNode.release},set:function(e){this.compNode.release.value=e/1e3}},makeupGain:{enumerable:!0,get:function(){return this.makeupNode.gain},set:function(e){this.makeupNode.gain.value=i(e)}}}),n.prototype.Convolver=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.activateNode=c.createGain(),this.convolver=c.createConvolver(),this.dry=c.createGain(),this.filterLow=c.createBiquadFilter(),this.filterHigh=c.createBiquadFilter(),this.wet=c.createGain(),this.output=c.createGain(),this.activateNode.connect(this.filterLow),this.activateNode.connect(this.dry),this.filterLow.connect(this.filterHigh),this.filterHigh.connect(this.convolver),this.convolver.connect(this.wet),this.wet.connect(this.output),this.dry.connect(this.output),this.dryLevel=s(e.dryLevel,this.defaults.dryLevel.value),this.wetLevel=s(e.wetLevel,this.defaults.wetLevel.value),this.highCut=e.highCut||this.defaults.highCut.value,this.buffer=e.impulse||"../impulses/ir_rev_short.wav",this.lowCut=e.lowCut||this.defaults.lowCut.value,this.level=s(e.level,this.defaults.level.value),this.filterHigh.type="lowpass",this.filterLow.type="highpass",this.bypass=e.bypass||!1},n.prototype.Convolver.prototype=Object.create(h,{name:{value:"Convolver"},defaults:{writable:!0,value:{highCut:{value:22050,min:20,max:22050,automatable:!0,type:p},lowCut:{value:20,min:20,max:22050,automatable:!0,type:p},dryLevel:{value:1,min:0,max:1,automatable:!0,type:p},wetLevel:{value:1,min:0,max:1,automatable:!0,type:p},level:{value:1,min:0,max:1,automatable:!0,type:p}}},lowCut:{get:function(){return this.filterLow.frequency},set:function(e){this.filterLow.frequency.value=e}},highCut:{get:function(){return this.filterHigh.frequency},set:function(e){this.filterHigh.frequency.value=e}},level:{get:function(){return this.output.gain},set:function(e){this.output.gain.value=e}},dryLevel:{get:function(){return this.dry.gain},set:function(e){this.dry.gain.value=e}},wetLevel:{get:function(){return this.wet.gain},set:function(e){this.wet.gain.value=e}},buffer:{enumerable:!1,get:function(){return this.convolver.buffer},set:function(e){var t=this.convolver,n=new XMLHttpRequest;return e?(n.open("GET",e,!0),n.responseType="arraybuffer",n.onreadystatechange=function(){4===n.readyState&&(n.status<300&&n.status>199||302===n.status)&&c.decodeAudioData(n.response,function(e){t.buffer=e},function(e){e&&console.log("Tuna.Convolver.setBuffer: Error decoding data"+e)})},void n.send(null)):void console.log("Tuna.Convolver.setBuffer: Missing impulse path!")}}}),n.prototype.Delay=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.activateNode=c.createGain(),this.dry=c.createGain(),this.wet=c.createGain(),this.filter=c.createBiquadFilter(),this.delay=c.createDelay(10),this.feedbackNode=c.createGain(),this.output=c.createGain(),this.activateNode.connect(this.delay),this.activateNode.connect(this.dry),this.delay.connect(this.filter),this.filter.connect(this.feedbackNode),this.feedbackNode.connect(this.delay),this.feedbackNode.connect(this.wet),this.wet.connect(this.output),this.dry.connect(this.output),this.delayTime=e.delayTime||this.defaults.delayTime.value,this.feedback=s(e.feedback,this.defaults.feedback.value),this.wetLevel=s(e.wetLevel,this.defaults.wetLevel.value),this.dryLevel=s(e.dryLevel,this.defaults.dryLevel.value),this.cutoff=e.cutoff||this.defaults.cutoff.value,this.filter.type="lowpass",this.bypass=e.bypass||!1},n.prototype.Delay.prototype=Object.create(h,{name:{value:"Delay"},defaults:{writable:!0,value:{delayTime:{value:100,min:20,max:1e3,automatable:!1,type:p},feedback:{value:.45,min:0,max:.9,automatable:!0,type:p},cutoff:{value:2e4,min:20,max:2e4,automatable:!0,type:p},wetLevel:{value:.5,min:0,max:1,automatable:!0,type:p},dryLevel:{value:1,min:0,max:1,automatable:!0,type:p}}},delayTime:{enumerable:!0,get:function(){return this.delay.delayTime},set:function(e){this.delay.delayTime.value=e/1e3}},wetLevel:{enumerable:!0,get:function(){return this.wet.gain},set:function(e){this.wet.gain.value=e}},dryLevel:{enumerable:!0,get:function(){return this.dry.gain},set:function(e){this.dry.gain.value=e}},feedback:{enumerable:!0,get:function(){return this.feedbackNode.gain},set:function(e){this.feedbackNode.gain.value=e}},cutoff:{enumerable:!0,get:function(){return this.filter.frequency},set:function(e){this.filter.frequency.value=e}}}),n.prototype.Filter=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.activateNode=c.createGain(),this.filter=c.createBiquadFilter(),this.output=c.createGain(),this.activateNode.connect(this.filter),this.filter.connect(this.output),this.frequency=e.frequency||this.defaults.frequency.value,this.Q=e.resonance||this.defaults.Q.value,this.filterType=s(e.filterType,this.defaults.filterType.value),this.gain=s(e.gain,this.defaults.gain.value),this.bypass=e.bypass||!1},n.prototype.Filter.prototype=Object.create(h,{name:{value:"Filter"},defaults:{writable:!0,value:{frequency:{value:800,min:20,max:22050,automatable:!0,type:p},Q:{value:1,min:.001,max:100,automatable:!0,type:p},gain:{value:0,min:-40,max:40,automatable:!0,type:p},bypass:{value:!1,automatable:!1,type:d},filterType:{value:"lowpass",automatable:!1,type:v}}},filterType:{enumerable:!0,get:function(){return this.filter.type},set:function(e){this.filter.type=e}},Q:{enumerable:!0,get:function(){return this.filter.Q},set:function(e){this.filter.Q.value=e}},gain:{enumerable:!0,get:function(){return this.filter.gain},set:function(e){this.filter.gain.value=e}},frequency:{enumerable:!0,get:function(){return this.filter.frequency},set:function(e){this.filter.frequency.value=e}}}),n.prototype.Gain=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.activateNode=c.createGain(),this.gainNode=c.createGain(),this.output=c.createGain(),this.activateNode.connect(this.gainNode),this.gainNode.connect(this.output),this.gain=s(e.gain,this.defaults.gain.value),this.bypass=e.bypass||!1},n.prototype.Gain.prototype=Object.create(h,{name:{value:"Gain"},defaults:{writable:!0,value:{bypass:{value:!1,automatable:!1,type:d},gain:{value:1,automatable:!0,type:p}}},gain:{enumerable:!0,get:function(){return this.gainNode.gain},set:function(e){this.gainNode.gain.value=e}}}),n.prototype.MoogFilter=function(e){e||(e=this.getDefaults()),this.bufferSize=e.bufferSize||this.defaults.bufferSize.value,this.input=c.createGain(),this.activateNode=c.createGain(),this.processor=c.createScriptProcessor(this.bufferSize,1,1),this.output=c.createGain(),this.activateNode.connect(this.processor),this.processor.connect(this.output);var t,n,a,i,r,o,u,l;t=n=a=i=r=o=u=l=0;var f,h,p,d,v,m,y;this.processor.onaudioprocess=function(e){for(f=e.inputBuffer.getChannelData(0),h=e.outputBuffer.getChannelData(0),p=1.16*this.cutoff,y=.35013*(p*p)*(p*p),d=this.resonance*(1-.15*p*p),m=f.length,v=0;v=0?5.8:1.2,n[a]=u(r)},function(e,t,n){var a,i,r,o=1-e;for(a=0;a.99?.99:1-e;for(a=0;as?r=s+(u-s)/(1+Math.pow((u-s)/(1-s),2)):u>1&&(r=u),n[a]=o(i)*r*(1/((s+1)/2))},function(e,t,n){var a,i;for(a=0;a=-.08905&&i<.320018?n[a]=-6.153*(i*i)+3.9375*i:n[a]=.630035},function(e,t,n){var a,i,r=2+Math.round(14*e),o=Math.round(Math.pow(2,r-1));for(a=0;a1?1:e<0?0:e,this._sensitivity),this.setFilterFreq()}},baseFrequency:{enumerable:!0,get:function(){return this._baseFrequency},set:function(e){this._baseFrequency=50*Math.pow(10,2*e),this._excursionFrequency=Math.min(c.sampleRate/2,this.baseFrequency*Math.pow(2,this._excursionOctaves)),this.setFilterFreq()}},excursionOctaves:{enumerable:!0,get:function(){return this._excursionOctaves},set:function(e){this._excursionOctaves=e,this._excursionFrequency=Math.min(c.sampleRate/2,this.baseFrequency*Math.pow(2,this._excursionOctaves)),this.setFilterFreq()}},sensitivity:{enumerable:!0,get:function(){return this._sensitivity},set:function(e){this._sensitivity=Math.pow(10,e)}},resonance:{enumerable:!0,get:function(){return this._resonance},set:function(e){this._resonance=e,this.filterPeaking.Q=this._resonance}},init:{value:function(){this.output.gain.value=1,this.filterPeaking.type="peaking",this.filterBp.type="bandpass",this.filterPeaking.frequency.value=100,this.filterPeaking.gain.value=20,this.filterPeaking.Q.value=5,this.filterBp.frequency.value=100,this.filterBp.Q.value=1}}}),n.prototype.EnvelopeFollower=function(e){e||(e=this.getDefaults()),this.input=c.createGain(),this.jsNode=this.output=c.createScriptProcessor(this.buffersize,1,1),this.input.connect(this.output),this.attackTime=s(e.attackTime,this.defaults.attackTime.value),this.releaseTime=s(e.releaseTime,this.defaults.releaseTime.value),this._envelope=0,this.target=e.target||{},this.callback=e.callback||function(){},this.bypass=e.bypass||!1},n.prototype.EnvelopeFollower.prototype=Object.create(h,{name:{value:"EnvelopeFollower"},defaults:{value:{attackTime:{value:.003,min:0,max:.5,automatable:!1,type:p},releaseTime:{value:.5,min:0,max:.5,automatable:!1,type:p}}},buffersize:{value:256},envelope:{value:0},sampleRate:{value:44100},attackTime:{enumerable:!0,get:function(){return this._attackTime},set:function(e){this._attackTime=e,this._attackC=Math.exp(-1/this._attackTime*this.sampleRate/this.buffersize)}},releaseTime:{enumerable:!0,get:function(){return this._releaseTime},set:function(e){this._releaseTime=e,this._releaseC=Math.exp(-1/this._releaseTime*this.sampleRate/this.buffersize)}},callback:{get:function(){return this._callback},set:function(e){"function"==typeof e?this._callback=e:console.error("tuna.js: "+this.name+": Callback must be a function!")}},target:{get:function(){return this._target},set:function(e){this._target=e}},activate:{value:function(e){this.activated=e,e?(this.jsNode.connect(c.destination),this.jsNode.onaudioprocess=this.returnCompute(this)):(this.jsNode.disconnect(),this.jsNode.onaudioprocess=null),this.activateCallback&&this.activateCallback(e)}},returnCompute:{value:function(e){return function(t){e.compute(t)}}},compute:{value:function(e){var t,n,a,i,r=e.inputBuffer.getChannelData(0).length,o=e.inputBuffer.numberOfChannels;if(n=a=i=0,o>1)for(i=0;i2*Math.PI&&(t._phase=0),e(t._target,t._offset+t._oscillation*Math.sin(t._phase))}}}}),n.toString=n.prototype.toString=function(){return"Please visit https://github.com/Theodeus/tuna/wiki for instructions on how to use Tuna.js"}}()},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return new s.default((0,o.default)({},c,{effectChain:{gain:e.createGain()}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.gainData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=t.gainData={name:"gain",values:[{name:"gain",options:{type:"range",defaultValue:1,min:0,max:1,step:.01},set:function(e,t){e.gain.gain.value=t}},{name:"muted",options:{type:"single",defaultValue:!1},set:function(e,t){e.gain.gain.value=t?0:1}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=n(4),r=a(i);t.default=r.default||function(e){for(var t=1;tc;)for(var h,p=u(arguments[c++]),d=l?a(p).concat(l(p)):a(p),v=d.length,m=0;v>m;)f.call(p,h=d[m++])&&(n[h]=p[h]);return n}:s},function(e,t,n){var a=n(24),i=n(37);e.exports=Object.keys||function(e){return a(e,i)}},function(e,t,n){var a=n(25),i=n(26),r=n(30)(!1),o=n(34)("IE_PROTO");e.exports=function(e,t){var n,u=i(e),s=0,c=[];for(n in u)n!=o&&a(u,n)&&c.push(n);for(;t.length>s;)a(u,n=t[s++])&&(~r(c,n)||c.push(n));return c}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var a=n(27),i=n(29);e.exports=function(e){return a(i(e))}},function(e,t,n){var a=n(28);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==a(e)?e.split(""):Object(e)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var a=n(26),i=n(31),r=n(33);e.exports=function(e){return function(t,n,o){var u,s=a(t),c=i(s.length),l=r(o,c);if(e&&n!=n){for(;c>l;)if(u=s[l++],u!=u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===n)return e||l||0;return!e&&-1}}},function(e,t,n){var a=n(32),i=Math.min;e.exports=function(e){return e>0?i(a(e),9007199254740991):0}},function(e,t){var n=Math.ceil,a=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?a:n)(e)}},function(e,t,n){var a=n(32),i=Math.max,r=Math.min;e.exports=function(e,t){return e=a(e),e<0?i(e+t,0):r(e,t)}},function(e,t,n){var a=n(35)("keys"),i=n(36);e.exports=function(e){return a[e]||(a[e]=i(e))}},function(e,t,n){var a=n(8),i="__core-js_shared__",r=a[i]||(a[i]={});e.exports=function(e){return r[e]||(r[e]={})}},function(e,t){var n=0,a=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+a).toString(36))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var a=n(29);e.exports=function(e){return Object(a(e))}},function(e,t,n){!function(t,n){e.exports=n()}(this,function(){return function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={exports:{},id:a,loaded:!1};return e[a].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),r=a(i);t.default=r.default},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),r=a(i),o=n(3),u=a(o),s=n(22),c=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{name:"",effectChain:{},values:[]},n=arguments[1];if((0,r.default)(this,e),this.isEffectUnit=!0,!n)throw new Error("The AudioContext specified (3° parameter) is not defined!");this.name=name,this.audioCtx=n,this.effectChain=(0,s.functionsToValues)(t.effectChain),this.values=(0,s.bindMethodsToValues)(t.values,this.effectChain),this.values.forEach(function(e){e.options.defaultValue&&e.set(e.options.defaultValue)}),this.setupEffectChain()}return(0,u.default)(e,[{key:"enable",value:function(){this.effectGain.gain.value=1,this.directGain.gain.value=0}},{key:"disable",value:function(){this.effectGain.gain.value=0,this.directGain.gain.value=1}},{key:"connect",value:function(e){e.isEffectUnit?this.output.connect(e.input):this.output.connect(e)}},{key:"setValue",value:function(e,t){(0,s.filterValue)(this.values,e).set(t)}},{key:"getValueOptions",value:function(e){return(0,s.filterValue)(this.values,e).options}},{key:"setupEffectChain",value:function(){this.effectGain=this.audioCtx.createGain(),this.directGain=this.audioCtx.createGain(),this.output=this.audioCtx.createGain(),this.input=this.audioCtx.createGain(),this.input.connect(this.effectGain),this.input.connect(this.directGain),this.directGain.connect(this.output);var e=(0,s.objToArray)(this.effectChain);if(e.length>=1){this.effectGain.connect(e[0]);for(var t=0;tc;)for(var h,p=u(arguments[c++]),d=l?a(p).concat(l(p)):a(p),v=d.length,m=0;v>m;)f.call(p,h=d[m++])&&(n[h]=p[h]);return n}:s},function(e,t,n){var a=n(29),i=n(42);e.exports=Object.keys||function(e){return a(e,i)}},function(e,t,n){var a=n(30),i=n(31),r=n(35)(!1),o=n(39)("IE_PROTO");e.exports=function(e,t){var n,u=i(e),s=0,c=[];for(n in u)n!=o&&a(u,n)&&c.push(n);for(;t.length>s;)a(u,n=t[s++])&&(~r(c,n)||c.push(n));return c}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var a=n(32),i=n(34);e.exports=function(e){return a(i(e))}},function(e,t,n){var a=n(33);e.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==a(e)?e.split(""):Object(e)}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var a=n(31),i=n(36),r=n(38);e.exports=function(e){return function(t,n,o){var u,s=a(t),c=i(s.length),l=r(o,c);if(e&&n!=n){for(;c>l;)if(u=s[l++],u!=u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===n)return e||l||0;return!e&&-1}}},function(e,t,n){var a=n(37),i=Math.min;e.exports=function(e){return e>0?i(a(e),9007199254740991):0}},function(e,t){var n=Math.ceil,a=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?a:n)(e)}},function(e,t,n){var a=n(37),i=Math.max,r=Math.min;e.exports=function(e,t){return e=a(e),e<0?i(e+t,0):r(e,t)}},function(e,t,n){var a=n(40)("keys"),i=n(41);e.exports=function(e){return a[e]||(a[e]=i(e))}},function(e,t,n){var a=n(8),i="__core-js_shared__",r=a[i]||(a[i]={});e.exports=function(e){return r[e]||(r[e]={})}},function(e,t){var n=0,a=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+a).toString(36))}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var a=n(34);e.exports=function(e){return Object(a(e))}}])})},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},d,{effectChain:{chorus:new t.Chorus({rate:f,feedback:h,delay:p})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.chorusData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=1.5,h=.2,p=.0045,d=t.chorusData={name:"chorus",values:[{name:"rate",options:{type:"range",defaultValue:f,min:.01,max:8,step:.01},set:function(e,t){e.chorus.rate=t}},{name:"feedback",options:{type:"range", 3 | defaultValue:h,min:0,max:1,step:.01},set:function(e,t){e.chorus.feedback=t}},{name:"delay",options:{type:"range",defaultValue:p,min:0,max:1,step:.01},set:function(e,t){e.chorus.delay=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},m,{effectChain:{delay:new t.Delay({feedback:f,delayTime:h,wetLevel:p,dryLevel:d,cutoff:v})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.delayData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=.45,h=150,p=.25,d=1,v=2e3,m=t.delayData={name:"delay",values:[{name:"feedback",options:{type:"range",defaultValue:f,min:0,max:1,step:.01},set:function(e,t){e.delay.feedback=t}},{name:"delayTime",options:{type:"range",defaultValue:h,min:1,max:1e4,step:1},set:function(e,t){e.delay.delayTime=t}},{name:"wetLevel",options:{type:"range",defaultValue:p,min:0,max:1,step:.01},set:function(e,t){e.delay.wetLevel=t}},{name:"dryLevel",options:{type:"range",defaultValue:d,min:0,max:1,step:.01},set:function(e,t){e.delay.dryLevel=t}},{name:"cutoff",options:{type:"range",defaultValue:v,min:20,max:22050,step:1},set:function(e,t){e.delay.cutoff=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},m,{effectChain:{phaser:new t.Phaser({rate:1.2,depth:.3,feedback:.2,stereoPhase:30,baseModulationFrequency:700})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.phaserData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=1.2,h=.3,p=.2,d=30,v=700,m=t.phaserData={name:"phaser",values:[{name:"rate",options:{type:"range",defaultValue:f,min:.01,max:8,step:.01},set:function(e,t){e.phaser.rate=t}},{name:"depth",options:{type:"range",defaultValue:h,min:0,max:1,step:.01},set:function(e,t){e.phaser.depth=t}},{name:"feedback",options:{type:"range",defaultValue:p,min:0,max:1,step:.01},set:function(e,t){e.phaser.feedback=t}},{name:"stereoPhase",options:{type:"range",defaultValue:d,min:0,max:180,step:.1},set:function(e,t){e.phaser.stereoPhase=t}},{name:"baseModulationFrequency",options:{type:"range",defaultValue:v,min:500,max:1500,step:1},set:function(e,t){e.phaser.baseModulationFrequency=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},d,{effectChain:{overdrive:new t.Overdrive({outputGain:f,drive:h,curveAmount:p,algorithmIndex:0})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.overdriveData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=.5,h=.7,p=1,d=t.overdriveData={name:"overdrive",values:[{name:"outputGain",options:{type:"range",defaultValue:f,min:0,max:1,step:.01},set:function(e,t){e.overdrive.outputGain=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},b,{effectChain:{compressor:new t.Compressor({threshold:f,makeupGain:h,attack:p,release:d,ratio:v,knee:m,automakeup:y})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.compressorData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=-1,h=1,p=1,d=0,v=4,m=5,y=!0,b=t.compressorData={name:"compressor",values:[{name:"threshold",options:{type:"range",defaultValue:f,min:-100,max:0,step:.1},set:function(e,t){e.compressor.threshold=t}},{name:"makeupGain",options:{type:"range",defaultValue:h,min:0,max:1,step:.01},set:function(e,t){e.compressor.makeupGain=t}},{name:"attack",options:{type:"range",defaultValue:p,min:0,max:1e3,step:1},set:function(e,t){e.compressor.attack=t}},{name:"release",options:{type:"range",defaultValue:d,min:0,max:3e3,step:1},set:function(e,t){e.compressor.release=t}},{name:"ratio",options:{type:"range",defaultValue:v,min:1,max:20,step:1},set:function(e,t){e.compressor.ratio=t}},{name:"knee",options:{type:"range",defaultValue:m,min:0,max:40,step:1},set:function(e,t){e.compressor.knee=t}},{name:"automakeup",options:{type:"single",defaultValue:y},set:function(e,t){e.compressor.automakeup=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return new s.default((0,o.default)({},l,{effectChain:{lowpass:function(){var t=e.createBiquadFilter();return t.type="lowpass",t.frequency.value=800,t}}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.lowpassData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=800,l=t.lowpassData={name:"lowpass",values:[{name:"frequency",options:{type:"range",defaultValue:c,min:0,max:2e4,step:1},set:function(e,t){e.lowpass.frequency.value=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){return new s.default((0,o.default)({},l,{effectChain:{highpass:function(){var t=e.createBiquadFilter();return t.type="highpass",t.frequency.value=c,t}}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.highpassData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=200,l=t.highpassData={name:"highpass",values:[{name:"frequency",options:{type:"range",defaultValue:c,min:0,max:2e4,step:1},set:function(e,t){e.highpass.frequency.value=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},d,{effectChain:{tremolo:new t.Tremolo({intensity:f,rate:h,stereoPhase:p})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.tremoloData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=.3,h=4,p=0,d=t.tremoloData={name:"tremolo",values:[{name:"intensity",options:{type:"range",defaultValue:f,min:0,max:1,step:.01},set:function(e,t){e.tremolo.intensity=t}},{name:"rate",options:{type:"range",defaultValue:h,min:.001,max:8,step:.01},set:function(e,t){e.tremolo.rate=t}},{name:"stereoPhase",options:{type:"range",defaultValue:p,min:0,max:180,step:1},set:function(e,t){e.tremolo.stereoPhase=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},y,{effectChain:{wahwah:new t.WahWah({automode:f,baseFrequency:h,excursionOctaves:p,sweep:d,resonance:v,sensitivity:m})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.wahWahData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=!0,h=.5,p=2,d=.2,v=10,m=.5,y=t.wahWahData={name:"wahwah",values:[{name:"automode",options:{type:"single",defaultValue:f},set:function(e,t){e.wahwah.automode=t}},{name:"baseFrequency",options:{type:"range",defaultValue:h,min:0,max:1,step:.01},set:function(e,t){e.wahwah.baseFrequency=t}},{name:"excursionOctaves",options:{type:"range",defaultValue:p,min:0,max:6,step:1},set:function(e,t){e.wahwah.excursionOctaves=t}},{name:"sweep",options:{type:"range",defaultValue:d,min:0,max:1,step:.01},set:function(e,t){e.wahwah.sweep=t}},{name:"resonance",options:{type:"range",defaultValue:v,min:0,max:100,step:1},set:function(e,t){e.wahwah.resonance=t}},{name:"sensitivity",options:{type:"range",defaultValue:m,min:0,max:1,step:.01},set:function(e,t){e.wahwah.sensitivity=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},p,{effectChain:{bitcrusher:new t.Bitcrusher({bits:4,normfreq:.1,bufferSize:4096})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.bitcrusherData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=4,h=.1,p=t.bitcrusherData={name:"bitcrusher",values:[{name:"bits",options:{type:"range",defaultValue:f,min:1,max:16,step:1},set:function(e,t){e.bitcrusher.bits=t}},{name:"normfreq",options:{type:"range",defaultValue:h,min:.1,max:1,step:.01},set:function(e,t){e.bitcrusher.normfreq=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},p,{effectChain:{moog:new t.MoogFilter({cutoff:.065,resonance:3.5,bufferSize:4096})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.moogData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=.065,h=3.5,p=t.moogData={name:"moog",values:[{name:"cutoff",options:{type:"range",defaultValue:f,min:0,max:1,step:.01},set:function(e,t){e.moog.cutoff=t}},{name:"resonance",options:{type:"range",defaultValue:h,min:0,max:4,step:.01},set:function(e,t){e.moog.resonance=t}}]}},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.default(e);return new s.default((0,o.default)({},v,{effectChain:{pingpong:new t.PingPongDelay({wetLevel:.5,feedback:.3,delayTimeLeft:150,delayTimeRight:200})}}),e)}Object.defineProperty(t,"__esModule",{value:!0}),t.pingPongDelayData=void 0;var r=n(3),o=a(r);t.default=i;var u=n(41),s=a(u),c=n(1),l=a(c),f=.5,h=.3,p=150,d=150,v=t.pingPongDelayData={name:"pingPongDelay",values:[{name:"wetLevel",options:{type:"range",defaultValue:f,min:0,max:1,step:.01},set:function(e,t){e.pingpong.wetLevel=t}},{name:"feedback",options:{type:"range",defaultValue:h,min:0,max:1,step:.01},set:function(e,t){e.pingpong.feedback=t}},{name:"delayTimeLeft",options:{type:"range",defaultValue:p,min:1,max:1e4,step:1},set:function(e,t){e.pingpong.delayTimeLeft=t}},{name:"delayTimeRight",options:{type:"range",defaultValue:d,min:1,max:1e4,step:1},set:function(e,t){e.pingpong.DEFAULT_DELAYTIMERIGHT=t}}]}}])})}])}); -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Testing Chnl 5 | 6 | 7 |
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /js/index.js: -------------------------------------------------------------------------------- 1 | import createEffects from 'webaudio-effect-units-collection'; 2 | 3 | export default class Chnl { 4 | input; 5 | output; 6 | effects; 7 | 8 | currentGraph = []; 9 | 10 | constructor(audioCtx) { 11 | this.context = audioCtx; 12 | this.input = audioCtx.createGain(); 13 | this.output = audioCtx.createGain(); 14 | this.effects = createEffects(audioCtx); 15 | // Setup initial graph 16 | this.setupGraph([this.input, this.effects.gain, this.output]); 17 | } 18 | 19 | setupGraph(graph) { 20 | // first of all, clear all connections (all nodes but the output) 21 | for(let i = 0; i < (this.currentGraph.length - 1); i++) { 22 | const currNode = this.currentGraph[i]; 23 | // Disconnect all outgoing connections 24 | currNode.disconnect(); 25 | } 26 | 27 | for(let i = 0; i < (graph.length - 1); i++) { 28 | const currNode = graph[i]; 29 | const nextNode = graph[i + 1]; 30 | currNode.connect(nextNode); 31 | } 32 | 33 | this.currentGraph = graph; 34 | 35 | } 36 | 37 | addEffect(name) { 38 | const effect = this.effects[name]; 39 | 40 | if(!effect) 41 | throw new Error(`You tried to add an inexistent effect.`) 42 | 43 | 44 | if(!effect.name) 45 | this.effects[name].name = name; 46 | 47 | // Create new graph: input -> (all effects which are already present in the graph) -> effectToAdd -> output 48 | const newGraph = [ 49 | this.input, 50 | ...this.currentGraph.filter(node => ( node !== this.input && node !== this.output )), 51 | effect, 52 | this.output 53 | ]; 54 | 55 | this.setupGraph(newGraph); 56 | } 57 | 58 | removeEffect(name) { 59 | 60 | this.setupGraph( this.currentGraph.filter( node => node.name !== name ) ); 61 | 62 | } 63 | 64 | connect(node) { 65 | this.output.connect(node); 66 | } 67 | 68 | } 69 | 70 | /*const audioCtx = new AudioContext(); 71 | const audioElem = new Audio(song); 72 | const audioElem2 = new Audio(song); 73 | const audio = audioCtx.createMediaElementSource(audioElem); 74 | const audio2 = audioCtx.createMediaElementSource(audioElem2); 75 | const chnl = new Chnl(audioCtx); 76 | const chnl2 = new Chnl(audioCtx); 77 | 78 | audio.connect(chnl); 79 | chnl.connect(audioCtx.destination); 80 | chnl.addEffect('delay'); 81 | 82 | audio2.connect(chnl2); 83 | chnl2.connect(audioCtx.destination); 84 | 85 | window.setTimeout(() => { 86 | //audioElem2.play(); 87 | }, 500) 88 | 89 | audioElem.play();*/ 90 | 91 | /* 92 | const audioCtx = new AudioContext(); 93 | const chnl = new Chnl(audioCtx); 94 | 95 | const osci = audioCtx.createOscillator(); 96 | osci.frequency.value = 300; 97 | 98 | osci.connect(chnl); 99 | chnl.connect(audioCtx.destination); 100 | 101 | // Activate effects 102 | chnl.addEffect('highpass'); 103 | chnl.addEffect('bitcrusher'); 104 | 105 | chnl.effects.gain.setValue('gain', 0.2); 106 | chnl.effects.highpass.setValue('frequency', 500); 107 | chnl.effects.bitcrusher.setValue('bits', 4); 108 | 109 | osci.start(); 110 | */ 111 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webaudio-chnl", 3 | "version": "0.0.6", 4 | "description": "Chnl - one channel, all effects.", 5 | "main": "build/bundle.js", 6 | "scripts": { 7 | "start:dev": "webpack-dev-server", 8 | "start:prod": "webpack" 9 | }, 10 | "keywords": [], 11 | "author": "Maximilian Torggler", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "babel-core": "*", 15 | "babel-loader": "*", 16 | "babel-plugin-transform-async-to-generator": "*", 17 | "babel-plugin-transform-async-to-module-method": "*", 18 | "babel-plugin-transform-class-properties": "*", 19 | "babel-plugin-transform-decorators-legacy": "*", 20 | "babel-plugin-transform-object-rest-spread": "*", 21 | "babel-plugin-transform-runtime": "*", 22 | "babel-polyfill": "*", 23 | "babel-preset-es2015": "*", 24 | "npm-install-webpack-plugin": "*", 25 | "webpack": "*", 26 | "webpack-dev-server": "*", 27 | "webpack-merge": "*", 28 | "worker-loader": "*", 29 | "file-loader": "*" 30 | }, 31 | "repository": { 32 | "type": "git", 33 | "url": "https://github.com/scriptify/Chnl.git" 34 | }, 35 | "dependencies": { 36 | "webaudio-effect-units-collection": "^1.0.3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'), 2 | webpack = require('webpack'), // Da bundling modules! 3 | NpmInstallPlugin = require('npm-install-webpack-plugin'), // Install client dependencies automatically! 4 | merge = require('webpack-merge'); // Merge together configurations! 5 | 6 | const PATHS = { 7 | js: path.join(__dirname, './js/'), 8 | build: path.join(__dirname, './build') 9 | }; 10 | 11 | const TARGET = process.env.npm_lifecycle_event; 12 | 13 | const COMMON_CONFIGURATION = { 14 | entry: { 15 | app: PATHS.js 16 | }, 17 | resolve: { 18 | extensions: ['', '.js'], // Resolve these extensions 19 | }, 20 | output: { 21 | path: PATHS.build, 22 | filename: 'bundle.js', 23 | libraryTarget: 'umd', 24 | library: 'EffectUnit' 25 | }, 26 | module: { 27 | loaders: [ 28 | { 29 | test: /\.js$/, 30 | loaders: ['babel?cacheDirectory'], 31 | include: PATHS.js 32 | }, 33 | { 34 | test: /\.wav$/, 35 | loaders: ['file'], 36 | include: PATHS.js 37 | } 38 | ] 39 | } 40 | }; 41 | 42 | switch(TARGET) { 43 | // Which procedure was started? 44 | default: 45 | case 'start:dev': { 46 | module.exports = merge(COMMON_CONFIGURATION, { 47 | devServer: { 48 | contentBase: PATHS.build, 49 | historyApiFallback: true, 50 | hot: true, 51 | inline: true, 52 | progress: true, 53 | stats: 'errors-only' 54 | }, 55 | plugins: [ 56 | new webpack.HotModuleReplacementPlugin(), 57 | new NpmInstallPlugin({ 58 | save: true 59 | }) 60 | ], 61 | devtool: 'eval-source-map' 62 | }); 63 | } 64 | break; 65 | case 'start:prod': { 66 | module.exports = merge(COMMON_CONFIGURATION, { 67 | plugins: [ 68 | new webpack.DefinePlugin({ 69 | 'process.env': { 70 | 'NODE_ENV': JSON.stringify('production') 71 | } 72 | }), 73 | new webpack.optimize.UglifyJsPlugin({ 74 | compress: { warnings: false } 75 | }), 76 | new webpack.optimize.DedupePlugin() 77 | ] 78 | }); 79 | } 80 | } 81 | --------------------------------------------------------------------------------