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