"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../../Class/Functional");
const AudioNode_1 = require("../../../../../../wrap/AudioNode");
const _ids_1 = require("../../../../../_ids");
class GainNode_ extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['node', 'gain'],
            o: ['node'],
        }, {
            input: {
                node: {
                    ref: true,
                },
            },
            output: {
                node: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_GAIN_NODE);
    }
    f({ node: sourceNode, gain }, done) {
        let _node;
        this._source = sourceNode;
        const context = sourceNode.getContext();
        _node = context.createGain();
        _node.gain.value = gain;
        sourceNode.connect(_node);
        const node = (0, AudioNode_1.wrapAudioNode)(_node, this.__system);
        this._node = node;
        done({
            node,
        });
    }
    d() {
        if (this._node) {
            this._source.disconnect();
            this._source = undefined;
            this._node = undefined;
        }
    }
}
exports.default = GainNode_;
//# sourceMappingURL=index.js.map