-Class(UnlimitedPizza, "Pepperoni").inherits(Widget)({
- INNER_HTML : ' \
-<a class="record-button">Record.</a> \
-<div class="record-info"> \
- <div class="record-progress"> \
- <div class="record-progress-bar-container"> \
- <div class="record-progress-bar"></div> \
- </div> \
- <a class="record-clear">Clear recording.</a> \
- </div> \
- <audio class="record-preview" controls></audio> \
- <div class="filter-switches"> \
- <input class="filter-switch" name="bandpass-filter" type="checkbox" /> <label for="bandpass-filter">Band Pass</label> \
- <input class="filter-switch" name="hipass-filter" type="checkbox" /> <label for="hipass-filter">Hi Pass</label> \
- <input class="filter-switch" name="lopass-filter" type="checkbox" /> <label for="lopass-filter">Lo Pass</label> \
- <input class="filter-switch" name="reverb-filter" type="checkbox" /> <label for="reverb-filter">Reverb</label> \
- <input class="filter-switch" name="distort-filter" type="checkbox" /> <label for="distort-filter">Distort</label> \
- </div> \
-</div> \
- ',
- PAUSE : 'Pause.',
- RECORD : 'Record.',
- prototype : {
- maxSize : 1048576,
- recording : false,
- source : null,
- recorder : null,
- context : null,
- _delayNode : null,
- _bandPassFilterNode : null,
- _hiPassFilterNode : null,
- _loPassFilterNode : null,
- _convolverNode : null,
- _distortionNode : null,
- _activatedNodes : null,
- workerPath : '/js/vendor/recorderjs/recorderWorker.js',
- init : function init(config) {
- var channels, frameCount, reverbBuffer, request, requestHandler;
-
- Widget.prototype.init.call(this, config);
-
- if (!this.context) {
- this.context = new (window.AudioContext || window.webkitAudioContext)();
- }
-
- this._delayNode = this.context.createDelay(1.0);
- this._bandPassFilterNode = this.context.createBiquadFilter();
- this._hiPassFilterNode = this.context.createBiquadFilter();
- this._loPassFilterNode = this.context.createBiquadFilter();
- this._convolverNode = this.context.createConvolver();
- this._distortionNode = this.context.createWaveShaper();
-
- this._distortionNode.curve = this._generateDistortion(400);
- this._distortionNode.oversample = '4x';
-
- this._activatedNodes = [];
-
- // config lo pass
- this._loPassFilterNode.type = "lowpass";
- this._loPassFilterNode.frequency.value = 1000;
- this._loPassFilterNode.gain.value = 25;
-
- // config hi pass
- this._hiPassFilterNode.type = "highpass";
- this._hiPassFilterNode.frequency.value = 3000;
- this._hiPassFilterNode.gain.value = 25;
-
- // config band pass
- this._bandPassFilterNode.type = "bandpass";
- this._bandPassFilterNode.frequency.value = 2000;
- this._bandPassFilterNode.gain.value = 25;
-
- requestHandler = function bufferFile(ev) {
- var request = ev.target;
- console.log("Reverb loading");
- this.context.decodeAudioData(request.response, function(buffer){
- console.log("Reverb loaded");
- this._convolverNode.buffer = buffer;
- }.bind(this));
- }.bind(this);
-
- request = new XMLHttpRequest();
- request.open('GET', '/reverb.ogg', true);
- request.responseType = 'arraybuffer';
- request.addEventListener('load', requestHandler, false);
- request.send();
-
- if (!this.source) {
- this._getUserMedia({
- audio : true
- }, this._onUserMedia.bind(this), this._onUserMediaError.bind(this))
- }
-
- this.element.html(this.constructor.INNER_HTML);