UNPKG

web-audio-api

Version:
33 lines (27 loc) 1.94 kB
var AudioNode = require('./AudioNode') , AudioParam = require('./AudioParam') , AudioBuffer = require('./AudioBuffer') , BLOCK_SIZE = require('./constants').BLOCK_SIZE , readOnlyAttr = require('./utils').readOnlyAttr var GainNode = (function(super$0){"use strict";var PRS$0 = (function(o,t){o["__proto__"]={"a":t};return o["a"]===t})({},{});var DP$0 = Object.defineProperty;var GOPD$0 = Object.getOwnPropertyDescriptor;var MIXIN$0 = function(t,s){for(var p in s){if(s.hasOwnProperty(p)){DP$0(t,p,GOPD$0(s,p));}}return t};var SP$0 = Object.setPrototypeOf||function(o,p){if(PRS$0){o["__proto__"]=p;}else {DP$0(o,"__proto__",{"value":p,"configurable":true,"enumerable":false,"writable":true});}return o};var OC$0 = Object.create;if(!PRS$0)MIXIN$0(GainNode, super$0);var proto$0={}; function GainNode(context) { super$0.call(this, context, 1, 1, undefined, 'max', 'speakers') readOnlyAttr(this, 'gain', new AudioParam(this.context, 1, 'a')) }if(super$0!==null)SP$0(GainNode,super$0);GainNode.prototype = OC$0(super$0!==null?super$0.prototype:null,{"constructor":{"value":GainNode,"configurable":true,"writable":true}});DP$0(GainNode,"prototype",{"configurable":false,"enumerable":false,"writable":false}); proto$0._tick = function() { var outBuff, inBuff, gainArray, i, ch, inChArray, outChArray super$0.prototype._tick.call(this, arguments) inBuff = this._inputs[0]._tick() gainArray = this.gain._tick().getChannelData(0) outBuff = new AudioBuffer(inBuff.numberOfChannels, BLOCK_SIZE, this.context.sampleRate) for (ch = 0; ch < inBuff.numberOfChannels; ch++) { inChArray = inBuff.getChannelData(ch) outChArray = outBuff.getChannelData(ch) for (i = 0; i < BLOCK_SIZE; i++) { outChArray[i] = inChArray[i] * gainArray[i] } } return outBuff }; MIXIN$0(GainNode.prototype,proto$0);proto$0=void 0;return GainNode;})(AudioNode); module.exports = GainNode