UNPKG

node-web-audio-api

Version:
148 lines (122 loc) 6.09 kB
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- // // // // // // // // ██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ // // ██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ // // ██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗ // // ██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║ // // ╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝ // // ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ // // // // // // - This file has been generated --------------------------- // // // // // // -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- // /* eslint-disable no-unused-vars */ const conversions = require('webidl-conversions'); const { toSanitizedSequence, } = require('./lib/cast.js'); const { isFunction, kEnumerableProperty, } = require('./lib/utils.js'); const { throwSanitizedError, } = require('./lib/errors.js'); const { kNapiObj, kAudioBuffer, } = require('./lib/symbols.js'); /* eslint-enable no-unused-vars */ const AudioNode = require('./AudioNode.js'); module.exports = (jsExport, nativeBinding) => { class DelayNode extends AudioNode { #delayTime = null; constructor(context, options) { if (arguments.length < 1) { throw new TypeError(`Failed to construct 'DelayNode': 1 argument required, but only ${arguments.length} present`); } if (!(context instanceof jsExport.BaseAudioContext)) { throw new TypeError(`Failed to construct 'DelayNode': argument 1 is not of type BaseAudioContext`); } // parsed version of the option to be passed to NAPI const parsedOptions = {}; if (options && typeof options !== 'object') { throw new TypeError('Failed to construct \'DelayNode\': argument 2 is not of type \'DelayOptions\''); } if (options && options.maxDelayTime !== undefined) { parsedOptions.maxDelayTime = conversions['double'](options.maxDelayTime, { context: `Failed to construct 'DelayNode': Failed to read the 'maxDelayTime' property from DelayOptions: The provided value (${options.maxDelayTime}})`, }); } else { parsedOptions.maxDelayTime = 1; } if (options && options.delayTime !== undefined) { parsedOptions.delayTime = conversions['double'](options.delayTime, { context: `Failed to construct 'DelayNode': Failed to read the 'delayTime' property from DelayOptions: The provided value (${options.delayTime}})`, }); } else { parsedOptions.delayTime = 0; } if (options && options.channelCount !== undefined) { parsedOptions.channelCount = conversions['unsigned long'](options.channelCount, { enforceRange: true, context: `Failed to construct 'DelayNode': Failed to read the 'channelCount' property from DelayOptions: The provided value '${options.channelCount}'`, }); } if (options && options.channelCountMode !== undefined) { parsedOptions.channelCountMode = conversions['DOMString'](options.channelCountMode, { context: `Failed to construct 'DelayNode': Failed to read the 'channelCount' property from DelayOptions: The provided value '${options.channelCountMode}'`, }); } if (options && options.channelInterpretation !== undefined) { parsedOptions.channelInterpretation = conversions['DOMString'](options.channelInterpretation, { context: `Failed to construct 'DelayNode': Failed to read the 'channelInterpretation' property from DelayOptions: The provided value '${options.channelInterpretation}'`, }); } let napiObj; try { napiObj = new nativeBinding.DelayNode(context[kNapiObj], parsedOptions); } catch (err) { throwSanitizedError(err); } super(context, { [kNapiObj]: napiObj, }); this.#delayTime = new jsExport.AudioParam({ [kNapiObj]: this[kNapiObj].delayTime, }); } get delayTime() { if (!(this instanceof DelayNode)) { throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'DelayNode\''); } return this.#delayTime; } } Object.defineProperties(DelayNode, { length: { __proto__: null, writable: false, enumerable: false, configurable: true, value: 1, }, }); Object.defineProperties(DelayNode.prototype, { [Symbol.toStringTag]: { __proto__: null, writable: false, enumerable: false, configurable: true, value: 'DelayNode', }, delayTime: kEnumerableProperty, }); return DelayNode; };