UNPKG

@trackr/effects-gain

Version:

A subpackage of trackr that contains gain effects.

24 lines (23 loc) 709 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.randomGain = exports.gain = void 0; exports.gain = (options) => { return (audioContext, eo) => { const o = _gain(audioContext, options ? options.value : 0.5); eo.latestSource.connect(o); return o; }; }; exports.randomGain = () => { return (audioContext, eo) => { const value = Math.random(); const o = _gain(audioContext, value); eo.latestSource.connect(o); return o; }; }; function _gain(audioContext, value) { const o = audioContext.createGain(); o.gain.setValueAtTime(value, audioContext.currentTime); return o; }