UNPKG

soundfont2

Version:

A SoundFont2 parser for Node.js and web browsers

1,121 lines (890 loc) 246 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./src/chunk.ts": /*!**********************!*\ !*** ./src/chunk.ts ***! \**********************/ /*! exports provided: SF2Chunk */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF2Chunk", function() { return SF2Chunk; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ "./src/constants.ts"); /* harmony import */ var _chunks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./chunks */ "./src/chunks/index.ts"); function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var SF2Chunk = /*#__PURE__*/ function (_RIFFChunk) { _inherits(SF2Chunk, _RIFFChunk); /** * All sub-chunks of this `SF2Chunk` as `SF2Chunk`. */ function SF2Chunk(chunk) { var _this; _classCallCheck(this, SF2Chunk); _this = _possibleConstructorReturn(this, _getPrototypeOf(SF2Chunk).call(this, chunk.id, chunk.length, chunk.buffer, chunk.subChunks)); _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "subChunks", void 0); _this.subChunks = chunk.subChunks.map(function (subChunk) { return new SF2Chunk(subChunk); }); return _this; } /** * Get meta data from the chunk. This assumes the chunk is a LIST chunk, containing INFO * sub-chunks. */ _createClass(SF2Chunk, [{ key: "getMetaData", value: function getMetaData() { if (this.id !== 'LIST') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'LIST'", "'".concat(this.id, "'")); } var info = this.subChunks.reduce(function (target, chunk) { if (chunk.id === 'ifil' || chunk.id === 'iver') { // ifil and iver length must be 4 bytes if (chunk.length !== _constants__WEBPACK_IMPORTED_MODULE_1__["SF_VERSION_LENGTH"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the '".concat(chunk.id, "' sub-chunk")); } target[chunk.id] = "".concat(chunk.getInt16(), ".").concat(chunk.getInt16(2)); } else { target[chunk.id] = chunk.getString(); } return target; }, {}); if (!info.ifil) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Missing required 'ifil' sub-chunk"); } if (!info.INAM) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Missing required 'INAM' sub-chunk"); } return { version: info.ifil, soundEngine: info.isng || 'EMU8000', name: info.INAM, rom: info.irom, romVersion: info.iver, creationDate: info.ICRD, author: info.IENG, product: info.IPRD, copyright: info.ICOP, comments: info.ICMT, createdBy: info.ISFT }; } /** * Get the sample data as a unsigned 8-bit buffer from the chunk. This assumes the chunk is a * LIST chunk containing a smpl sub-chunk. */ }, { key: "getSampleData", value: function getSampleData() { if (this.id !== 'LIST') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'LIST'", "'".concat(this.id, "'")); } var sampleChunk = this.subChunks[0]; if (sampleChunk.id !== 'smpl') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Invalid chunk signature', "'smpl'", "'".concat(sampleChunk.id, "'")); } return sampleChunk.buffer; } /** * Get the preset data from the chunk. This assumes the chunk is a LIST chunk containing the * preset data sub-chunks. */ }, { key: "getPresetData", value: function getPresetData() { if (this.id !== 'LIST') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'LIST'", "'".concat(this.id, "'")); } return { presetHeaders: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getPresetHeaders"])(this.subChunks[0]), presetZones: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getZones"])(this.subChunks[1], 'pbag'), presetModulators: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getModulators"])(this.subChunks[2], 'pmod'), presetGenerators: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getGenerators"])(this.subChunks[3], 'pgen'), instrumentHeaders: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getInstrumentHeaders"])(this.subChunks[4]), instrumentZones: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getZones"])(this.subChunks[5], 'ibag'), instrumentModulators: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getModulators"])(this.subChunks[6], 'imod'), instrumentGenerators: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getGenerators"])(this.subChunks[7], 'igen'), sampleHeaders: Object(_chunks__WEBPACK_IMPORTED_MODULE_2__["getSampleHeaders"])(this.subChunks[8]) }; } }]); return SF2Chunk; }(_riff__WEBPACK_IMPORTED_MODULE_0__["RIFFChunk"]); /***/ }), /***/ "./src/chunks/generators.ts": /*!**********************************!*\ !*** ./src/chunks/generators.ts ***! \**********************************/ /*! exports provided: getGenerators */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getGenerators", function() { return getGenerators; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/types */ "./src/types/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /** * An array of GeneratorTypes that cannot be specified for presets. If one of these generator types * is found, the generator should be ignored. */ var PRESET_TYPES_BLACKLIST = [_types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].StartAddrsOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].EndAddrsOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].StartLoopAddrsOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].EndLoopAddrsOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].StartAddrsCoarseOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].EndAddrsCoarseOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].StartLoopAddrsCoarseOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].KeyNum, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Velocity, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].EndLoopAddrsCoarseOffset, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].SampleModes, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].ExclusiveClass, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].OverridingRootKey]; /** * An array of GeneratorTypes that cannot be specified for instruments. If one of these generator * types is found, the generator should be ignored. */ var INSTRUMENT_TYPES_BLACKLIST = [_types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Unused1, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Unused2, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Unused3, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Unused4, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Reserved1, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Reserved2, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].Reserved3]; /** * These GeneratorTypes specify a range of key numbers or velocity. */ var RANGE_TYPES = [_types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].KeyRange, _types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"].VelRange]; /** * Get all generators for either an preset generator chunk or a instrument generator chunk. * * TODO: Check if generator chunk is valid, by following the rules defined in the spec. See for * example: https://github.com/FluidSynth/fluidsynth/blob/v2.0.3/src/sfloader/fluid_sffile.c * * @param {SF2Chunk} chunk - The input chunk * @param {string} type - The type, can be 'pgen' or 'igen' */ var getGenerators = function getGenerators(chunk, type) { if (chunk.id !== type) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'".concat(type, "'"), "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_2__["SF_GENERATOR_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the '".concat(type, "' sub-chunk")); } return chunk.iterate(function (iterator) { var id = iterator.getInt16(); // Ignore invalid IDs if (!_types__WEBPACK_IMPORTED_MODULE_1__["GeneratorType"][id]) { return null; } if (type === 'pgen' && PRESET_TYPES_BLACKLIST.includes(id)) { return null; } if (type === 'igen' && INSTRUMENT_TYPES_BLACKLIST.includes(id)) { return null; } if (RANGE_TYPES.includes(id)) { return { id: id, range: { lo: iterator.getByte(), hi: iterator.getByte() } }; } return { id: id, value: iterator.getInt16BE() }; }); }; /***/ }), /***/ "./src/chunks/index.ts": /*!*****************************!*\ !*** ./src/chunks/index.ts ***! \*****************************/ /*! exports provided: getInstrumentHeaders, getPresetHeaders, getSampleHeaders, getGenerators, getModulators, getZones, getItemsInZone */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _instruments__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./instruments */ "./src/chunks/instruments/index.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getInstrumentHeaders", function() { return _instruments__WEBPACK_IMPORTED_MODULE_0__["getInstrumentHeaders"]; }); /* harmony import */ var _presets__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./presets */ "./src/chunks/presets/index.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getPresetHeaders", function() { return _presets__WEBPACK_IMPORTED_MODULE_1__["getPresetHeaders"]; }); /* harmony import */ var _samples__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./samples */ "./src/chunks/samples/index.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getSampleHeaders", function() { return _samples__WEBPACK_IMPORTED_MODULE_2__["getSampleHeaders"]; }); /* harmony import */ var _generators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./generators */ "./src/chunks/generators.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getGenerators", function() { return _generators__WEBPACK_IMPORTED_MODULE_3__["getGenerators"]; }); /* harmony import */ var _modulators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modulators */ "./src/chunks/modulators.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getModulators", function() { return _modulators__WEBPACK_IMPORTED_MODULE_4__["getModulators"]; }); /* harmony import */ var _zones__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./zones */ "./src/chunks/zones.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getZones", function() { return _zones__WEBPACK_IMPORTED_MODULE_5__["getZones"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getItemsInZone", function() { return _zones__WEBPACK_IMPORTED_MODULE_5__["getItemsInZone"]; }); /***/ }), /***/ "./src/chunks/instruments/headers.ts": /*!*******************************************!*\ !*** ./src/chunks/instruments/headers.ts ***! \*******************************************/ /*! exports provided: getInstrumentHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getInstrumentHeaders", function() { return getInstrumentHeaders; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /** * Get all instrument headers from a `inst` sub-chunk. * * @param {SF2Chunk} chunk - The input chunk */ var getInstrumentHeaders = function getInstrumentHeaders(chunk) { if (chunk.id !== 'inst') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'inst'", "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_1__["SF_INSTRUMENT_HEADER_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the 'inst' sub-chunk"); } return chunk.iterate(function (iterator) { return { name: iterator.getString(), bagIndex: iterator.getInt16() }; }); }; /***/ }), /***/ "./src/chunks/instruments/index.ts": /*!*****************************************!*\ !*** ./src/chunks/instruments/index.ts ***! \*****************************************/ /*! exports provided: getInstrumentHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _headers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./headers */ "./src/chunks/instruments/headers.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getInstrumentHeaders", function() { return _headers__WEBPACK_IMPORTED_MODULE_0__["getInstrumentHeaders"]; }); /***/ }), /***/ "./src/chunks/modulators.ts": /*!**********************************!*\ !*** ./src/chunks/modulators.ts ***! \**********************************/ /*! exports provided: getModulators */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getModulators", function() { return getModulators; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /** * Get the modulator enumerator value from a 16-bit integer. * * @param {number} value - The 16-bit integer */ var getModulatorValue = function getModulatorValue(value) { return { type: value >> 10 & 0x3f, polarity: value >> 9 & 1, direction: value >> 8 & 1, palette: value >> 7 & 1, index: value & 0x7f }; }; /** * Get the modulators from either a `pmod` (presets) or `imod` (instruments) chunk. * * @param {SF2Chunk} chunk - The input chunk * @param {string} type - The type of chunk, either 'pmod' or 'imod' */ var getModulators = function getModulators(chunk, type) { if (chunk.id !== type) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'".concat(type, "'"), "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_1__["SF_MODULATOR_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the '".concat(type, "' sub-chunk")); } return chunk.iterate(function (iterator) { return { source: getModulatorValue(iterator.getInt16BE()), id: iterator.getInt16BE(), value: iterator.getInt16BE(), valueSource: getModulatorValue(iterator.getInt16BE()), transform: iterator.getInt16BE() }; }); }; /***/ }), /***/ "./src/chunks/presets/headers.ts": /*!***************************************!*\ !*** ./src/chunks/presets/headers.ts ***! \***************************************/ /*! exports provided: getPresetHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPresetHeaders", function() { return getPresetHeaders; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /** * Get all preset headers from a `phdr` sub-chunk. * * @param {SF2Chunk} chunk - The input chunk */ var getPresetHeaders = function getPresetHeaders(chunk) { if (chunk.id !== 'phdr') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Invalid chunk ID', "'phdr'", "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_1__["SF_PRESET_HEADER_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the 'phdr' sub-chunk"); } return chunk.iterate(function (iterator) { return { name: iterator.getString(), preset: iterator.getInt16(), bank: iterator.getInt16(), bagIndex: iterator.getInt16(), library: iterator.getUInt32(), genre: iterator.getUInt32(), morphology: iterator.getUInt32() }; }); }; /***/ }), /***/ "./src/chunks/presets/index.ts": /*!*************************************!*\ !*** ./src/chunks/presets/index.ts ***! \*************************************/ /*! exports provided: getPresetHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _headers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./headers */ "./src/chunks/presets/headers.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getPresetHeaders", function() { return _headers__WEBPACK_IMPORTED_MODULE_0__["getPresetHeaders"]; }); /***/ }), /***/ "./src/chunks/samples/headers.ts": /*!***************************************!*\ !*** ./src/chunks/samples/headers.ts ***! \***************************************/ /*! exports provided: getSampleHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSampleHeaders", function() { return getSampleHeaders; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /** * Get all sample headers from a `shdr` sub-chunk. * * @param {SF2Chunk} chunk - The input chunk */ var getSampleHeaders = function getSampleHeaders(chunk) { if (chunk.id !== 'shdr') { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'shdr'", "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_1__["SF_SAMPLE_HEADER_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the 'shdr' sub-chunk"); } return chunk.iterate(function (iterator) { return { name: iterator.getString(), start: iterator.getUInt32(), end: iterator.getUInt32(), startLoop: iterator.getUInt32(), endLoop: iterator.getUInt32(), sampleRate: iterator.getUInt32(), originalPitch: iterator.getByte(), pitchCorrection: iterator.getChar(), link: iterator.getInt16(), type: iterator.getInt16() }; }); }; /***/ }), /***/ "./src/chunks/samples/index.ts": /*!*************************************!*\ !*** ./src/chunks/samples/index.ts ***! \*************************************/ /*! exports provided: getSampleHeaders */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _headers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./headers */ "./src/chunks/samples/headers.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getSampleHeaders", function() { return _headers__WEBPACK_IMPORTED_MODULE_0__["getSampleHeaders"]; }); /***/ }), /***/ "./src/chunks/zones.ts": /*!*****************************!*\ !*** ./src/chunks/zones.ts ***! \*****************************/ /*! exports provided: getZones, getItemsInZone */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getZones", function() { return getZones; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getItemsInZone", function() { return getItemsInZone; }); /* harmony import */ var _riff__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/riff */ "./src/riff/index.ts"); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/constants */ "./src/constants.ts"); /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ~/types */ "./src/types/index.ts"); /** * Get the preset or instrument zones from a chunk. * * @param {SF2Chunk} chunk - The input chunk * @param {string} type - The type of chunk ('pbag' or 'ibag') */ var getZones = function getZones(chunk, type) { if (chunk.id !== type) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]('Unexpected chunk ID', "'".concat(type, "'"), "'".concat(chunk.id, "'")); } if (chunk.length % _constants__WEBPACK_IMPORTED_MODULE_1__["SF_BAG_SIZE"]) { throw new _riff__WEBPACK_IMPORTED_MODULE_0__["ParseError"]("Invalid size for the '".concat(type, "' sub-chunk")); } return chunk.iterate(function (iterator) { return { generatorIndex: iterator.getInt16(), modulatorIndex: iterator.getInt16() }; }); }; /** * Get all modulators, generators and the instrument (for presets) or sample (for instruments) in a * preset or instrument. * * @template T * @template R * @param {T} headers - The preset or instrument headers * @param {Zone[]} zones - All zones for the preset or instrument * @param {Modulator[]} itemModulators - All modulators for the preset or instrument * @param {Generator[]} itemGenerators - All generators for the preset or instrument * @param {R[]} references - The instruments or samples to reference in the zone * @param {GeneratorType} referenceType - The generator type to reference it by */ var getItemsInZone = function getItemsInZone(headers, zones, itemModulators, itemGenerators, references, referenceType) { var items = []; for (var i = 0; i < headers.length; i++) { var _header = headers[i]; var next = headers[i + 1]; var start = _header.bagIndex; var end = next ? next.bagIndex : zones.length; var zoneItems = []; var _globalZone = void 0; for (var j = start; j < end; j++) { var modulators = getModulators(j, zones, itemModulators); var generators = getGenerators(j, zones, itemGenerators); var keyRange = generators[_types__WEBPACK_IMPORTED_MODULE_2__["GeneratorType"].KeyRange] && generators[_types__WEBPACK_IMPORTED_MODULE_2__["GeneratorType"].KeyRange].range; var referenceId = generators[referenceType]; if (!referenceId) { if (j - start === 0) { // first item without reference = global zone // Spec 7.3: If a preset has more than one zone, the first zone may be a global zone. // A global zone is determined by the fact that the last generator in the list is not an Instrument generator. // Spec 7.9: "Unless the zone is a global zone, the last generator in the list is a “sampleID” generator" _globalZone = { keyRange: keyRange, modulators: modulators, generators: generators }; } continue; } var reference = references[referenceId.value]; if (!reference) { continue; } zoneItems.push({ keyRange: keyRange, modulators: modulators, generators: generators, reference: reference }); } items.push({ header: _header, globalZone: _globalZone, zones: zoneItems }); } return items; }; /** * Get all modulators from a zone, based on the index. The end index is the modulator index of the * next zone, or the total zone length if the current zone is the last one. * * @param {number} index - The index * @param {Zone[]} zones - ALl zones for the preset or instrument * @param {Modulator[]} modulators - All modulators for the preset or instrument */ var getModulators = function getModulators(index, zones, modulators) { var zone = zones[index]; var next = zones[index + 1]; var start = zone.modulatorIndex; var end = next ? next.modulatorIndex : zones.length; return getZone(start, end, modulators); }; /** * Get all generators from a zone, based on the index. The end index is the generators index of the * next zone, or the total zone length if the current zone is the last one. * * @param {number} index - The index * @param {Zone[]} zones - ALl zones for the preset or instrument * @param {Generator[]} generators - All generators for the preset or instrument */ var getGenerators = function getGenerators(index, zones, generators) { var zone = zones[index]; var next = zones[index + 1]; var start = zone.generatorIndex; var end = next ? next.generatorIndex : zones.length; return getZone(start, end, generators); }; /** * Returns all modulators or generators as a key-value object, where the key is the `GeneratorType` * of the modulator or generator. * * @template T * @param {number} start - The start index * @param {number} end - The end index * @param {T[]} items - The modulators or generators */ var getZone = function getZone(start, end, items) { var itemsObject = {}; for (var i = start; i < end; i++) { var item = items[i]; if (item) { itemsObject[item.id] = item; } } return itemsObject; }; /***/ }), /***/ "./src/constants.ts": /*!**************************!*\ !*** ./src/constants.ts ***! \**************************/ /*! exports provided: SF_VERSION_LENGTH, SF_PRESET_HEADER_SIZE, SF_BAG_SIZE, SF_MODULATOR_SIZE, SF_GENERATOR_SIZE, SF_INSTRUMENT_HEADER_SIZE, SF_SAMPLE_HEADER_SIZE, DEFAULT_SAMPLE_RATE */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_VERSION_LENGTH", function() { return SF_VERSION_LENGTH; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_PRESET_HEADER_SIZE", function() { return SF_PRESET_HEADER_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_BAG_SIZE", function() { return SF_BAG_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_MODULATOR_SIZE", function() { return SF_MODULATOR_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_GENERATOR_SIZE", function() { return SF_GENERATOR_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_INSTRUMENT_HEADER_SIZE", function() { return SF_INSTRUMENT_HEADER_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SF_SAMPLE_HEADER_SIZE", function() { return SF_SAMPLE_HEADER_SIZE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_SAMPLE_RATE", function() { return DEFAULT_SAMPLE_RATE; }); var SF_VERSION_LENGTH = 4; var SF_PRESET_HEADER_SIZE = 38; var SF_BAG_SIZE = 4; var SF_MODULATOR_SIZE = 10; var SF_GENERATOR_SIZE = 4; var SF_INSTRUMENT_HEADER_SIZE = 22; var SF_SAMPLE_HEADER_SIZE = 46; var DEFAULT_SAMPLE_RATE = 22050; /***/ }), /***/ "./src/index.ts": /*!**********************!*\ !*** ./src/index.ts ***! \**********************/ /*! no static exports found */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./src/types/index.ts"); /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_0__) if(["default"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _types__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__)); /* harmony import */ var _chunk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./chunk */ "./src/chunk.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF2Chunk", function() { return _chunk__WEBPACK_IMPORTED_MODULE_1__["SF2Chunk"]; }); /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants */ "./src/constants.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_VERSION_LENGTH", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_VERSION_LENGTH"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_PRESET_HEADER_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_PRESET_HEADER_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_BAG_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_BAG_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_MODULATOR_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_MODULATOR_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_GENERATOR_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_GENERATOR_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_INSTRUMENT_HEADER_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_INSTRUMENT_HEADER_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SF_SAMPLE_HEADER_SIZE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["SF_SAMPLE_HEADER_SIZE"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_SAMPLE_RATE", function() { return _constants__WEBPACK_IMPORTED_MODULE_2__["DEFAULT_SAMPLE_RATE"]; }); /* harmony import */ var _soundFont2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./soundFont2 */ "./src/soundFont2.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundFont2", function() { return _soundFont2__WEBPACK_IMPORTED_MODULE_3__["SoundFont2"]; }); /***/ }), /***/ "./src/riff/chunkIterator.ts": /*!***********************************!*\ !*** ./src/riff/chunkIterator.ts ***! \***********************************/ /*! exports provided: ChunkIterator */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChunkIterator", function() { return ChunkIterator; }); /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/utils */ "./src/utils/index.ts"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** * A utility class to quickly iterate over a buffer. */ var ChunkIterator = /*#__PURE__*/ function () { function ChunkIterator(chunk) { var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; _classCallCheck(this, ChunkIterator); _defineProperty(this, "target", []); _defineProperty(this, "chunk", void 0); _defineProperty(this, "position", 0); this.chunk = chunk; this.position = start; } /** * Get the position from the iterator. */ _createClass(ChunkIterator, [{ key: "iterate", /** * Iterate over the chunk. * * @param {Function} callback - The callback that is called every iteration */ value: function iterate(callback) { while (this.position < this.chunk.length) { var object = callback(this); if (object) { this.target.push(object); } } } /** * Get a string from the buffer. * * @param {number} length - The length of the string. If no length is specified, a default of 20 * is assumed */ }, { key: "getString", value: function getString() { var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20; var text = Object(_utils__WEBPACK_IMPORTED_MODULE_0__["getStringFromBuffer"])(this.getBuffer(this.position, length)); this.position += length; return text; } /** * Get a signed 16-bit integer from the chunk. */ }, { key: "getInt16", value: function getInt16() { return this.chunk.buffer[this.position++] | this.chunk.buffer[this.position++] << 8; } /** * Get a signed 16-bit integer from the chunk in the big-endian format. */ }, { key: "getInt16BE", value: function getInt16BE() { return this.getInt16() << 16 >> 16; } /** * Get an unsigned 32-bit integer from the chunk. */ }, { key: "getUInt32", value: function getUInt32() { return (this.chunk.buffer[this.position++] | this.chunk.buffer[this.position++] << 8 | this.chunk.buffer[this.position++] << 16 | this.chunk.buffer[this.position++] << 24) >>> 0; } /** * Get a single byte from the chunk. */ }, { key: "getByte", value: function getByte() { return this.chunk.buffer[this.position++]; } /** * Get a signed char from the chunk. */ }, { key: "getChar", value: function getChar() { return this.chunk.buffer[this.position++] << 24 >> 24; } /** * Skip ahead in the buffer. * * @param {number} length */ }, { key: "skip", value: function skip(length) { this.position += length; } /** * Get a part of the buffer from start to start + length. * * @param {number} start * @param {number} length */ }, { key: "getBuffer", value: function getBuffer(start, length) { return this.chunk.buffer.subarray(start, start + length); } }, { key: "currentPosition", get: function get() { return this.position; } }]); return ChunkIterator; }(); /***/ }), /***/ "./src/riff/index.ts": /*!***************************!*\ !*** ./src/riff/index.ts ***! \***************************/ /*! exports provided: ChunkIterator, ParseError, parseBuffer, getChunk, getChunkLength, getSubChunks, getChunkId, RIFFChunk */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _chunkIterator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./chunkIterator */ "./src/riff/chunkIterator.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChunkIterator", function() { return _chunkIterator__WEBPACK_IMPORTED_MODULE_0__["ChunkIterator"]; }); /* harmony import */ var _parseError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./parseError */ "./src/riff/parseError.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParseError", function() { return _parseError__WEBPACK_IMPORTED_MODULE_1__["ParseError"]; }); /* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./parser */ "./src/riff/parser.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parseBuffer", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["parseBuffer"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getChunk", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["getChunk"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getChunkLength", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["getChunkLength"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getSubChunks", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["getSubChunks"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getChunkId", function() { return _parser__WEBPACK_IMPORTED_MODULE_2__["getChunkId"]; }); /* harmony import */ var _riffChunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./riffChunk */ "./src/riff/riffChunk.ts"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RIFFChunk", function() { return _riffChunk__WEBPACK_IMPORTED_MODULE_3__["RIFFChunk"]; }); /***/ }), /***/ "./src/riff/parseError.ts": /*!********************************!*\ !*** ./src/riff/parseError.ts ***! \********************************/ /*! exports provided: ParseError */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParseError", function() { return ParseError; }); function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /** * Error class used for all errors encountered during the parsing of the SoundFont 2 file. */ var ParseError = /*#__PURE__*/ function (_Error) { _inherits(ParseError, _Error); function ParseError(message, expected, received) { _classCallCheck(this, ParseError); return _possibleConstructorReturn(this, _getPrototypeOf(ParseError).call(this, "".concat(message).concat(expected && received ? ", expected ".concat(expected, ", received ").concat(received) : ""))); } return ParseError; }(_wrapNativeSuper(Error)); /***/ }), /***/ "./src/riff/parser.ts": /*!****************************!*\ !*** ./src/riff/parser.ts ***! \****************************/ /*! exports provided: parseBuffer, getChunk, getChunkLength, getSubChunks, getChunkId */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseBuffer", function() { return parseBuffer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getChunk", function() { return getChunk; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getChunkLength", function() { return getChunkLength; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSubChunks", function() { return getSubChunks; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getChunkId", function() { return getChunkId; }); /* harmony import */ var _parseError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./parseError */ "./src/riff/parseError.ts"); /* harmony import */ var _utils_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/utils/buffer */ "./src/utils/buffer.ts"); /* harmony import */ var _riffChunk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./riffChunk */ "./src/riff/riffChunk.ts"); /** * Attempts to parse a RIFF file from a raw buffer. * * @param {Uint8Array} buffer - The input buffer */ var parseBuffer = functi