UNPKG

qambi

Version:

MIDI sequencer, loads MIDI files, can record and playback MIDI, uses WebMIDI and WebAudio

64 lines (50 loc) 2.24 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChannelEffect = undefined; 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 _init_audio = require('./init_audio'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ChannelEffect = exports.ChannelEffect = function () { function ChannelEffect() { _classCallCheck(this, ChannelEffect); this.input = _init_audio.context.createGain(); this.output = _init_audio.context.createGain(); this._dry = _init_audio.context.createGain(); this._wet = _init_audio.context.createGain(); this._dry.gain.value = 1; this._wet.gain.value = 0; this.amount = 0; } _createClass(ChannelEffect, [{ key: 'init', value: function init() { this.input.connect(this._dry); this._dry.connect(this.output); this.input.connect(this._nodeFX); this._nodeFX.connect(this._wet); this._wet.connect(this.output); } }, { key: 'setAmount', value: function setAmount(value) { /* this.amount = value < 0 ? 0 : value > 1 ? 1 : value; var gain1 = Math.cos(this.amount * 0.5 * Math.PI), gain2 = Math.cos((1.0 - this.amount) * 0.5 * Math.PI); this.gainNode.gain.value = gain2 * this.ratio; */ if (value < 0) { value = 0; } else if (value > 1) { value = 1; } this.amount = value; this._wet.gain.value = this.amount; this._dry.gain.value = 1 - this.amount; //console.log('wet',this.wetGain.gain.value,'dry',this.dryGain.gain.value); } }]); return ChannelEffect; }();