1import { 2 require_react 3} from "/assets/chunk-RFGJYZHZ.js"; 4import { 5 __commonJS, 6 __toESM 7} from "/assets/chunk-LALCD62Z.js"; 8
vendor: 441 bytes, lines 9-18
9// node_modules/automation-events/node_modules/@babel/runtime/helpers/arrayWithHoles.js 10var require_arrayWithHoles = __commonJS({ 11 "node_modules/automation-events/node_modules/@babel/runtime/helpers/arrayWithHoles.js"(exports, module) { 12 function _arrayWithHoles(r) { 13 if (Array.isArray(r)) return r; 14 } 15 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports; 16 } 17}); 18
vendor: 1,123 bytes, lines 19-46
19// node_modules/automation-events/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js 20var require_iterableToArrayLimit = __commonJS({ 21 "node_modules/automation-events/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"(exports, module) { 22 function _iterableToArrayLimit(r, l) { 23 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; 24 if (null != t) { 25 var e, n, i, u, a = [], f = true, o = false; 26 try { 27 if (i = (t = t.call(r)).next, 0 === l) { 28 if (Object(t) !== t) return; 29 f = false; 30 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; 31 } catch (r2) { 32 o = true, n = r2; 33 } finally { 34 try { 35 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; 36 } finally { 37 if (o) throw n; 38 } 39 } 40 return a; 41 } 42 } 43 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports; 44 } 45}); 46
vendor: 546 bytes, lines 47-58
47// node_modules/automation-events/node_modules/@babel/runtime/helpers/arrayLikeToArray.js 48var require_arrayLikeToArray = __commonJS({ 49 "node_modules/automation-events/node_modules/@babel/runtime/helpers/arrayLikeToArray.js"(exports, module) { 50 function _arrayLikeToArray(r, a) { 51 (null == a || a > r.length) && (a = r.length); 52 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; 53 return n; 54 } 55 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; 56 } 57}); 58
vendor: 887 bytes, lines 59-73
59// node_modules/automation-events/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js 60var require_unsupportedIterableToArray = __commonJS({ 61 "node_modules/automation-events/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"(exports, module) { 62 var arrayLikeToArray = require_arrayLikeToArray(); 63 function _unsupportedIterableToArray(r, a) { 64 if (r) { 65 if ("string" == typeof r) return arrayLikeToArray(r, a); 66 var t = {}.toString.call(r).slice(8, -1); 67 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0; 68 } 69 } 70 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; 71 } 72}); 73
vendor: 575 bytes, lines 74-83
74// node_modules/automation-events/node_modules/@babel/runtime/helpers/nonIterableRest.js 75var require_nonIterableRest = __commonJS({ 76 "node_modules/automation-events/node_modules/@babel/runtime/helpers/nonIterableRest.js"(exports, module) { 77 function _nonIterableRest() { 78 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 79 } 80 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports; 81 } 82}); 83
vendor: 762 bytes, lines 84-97
84// node_modules/automation-events/node_modules/@babel/runtime/helpers/slicedToArray.js 85var require_slicedToArray = __commonJS({ 86 "node_modules/automation-events/node_modules/@babel/runtime/helpers/slicedToArray.js"(exports, module) { 87 var arrayWithHoles = require_arrayWithHoles(); 88 var iterableToArrayLimit = require_iterableToArrayLimit(); 89 var unsupportedIterableToArray = require_unsupportedIterableToArray(); 90 var nonIterableRest = require_nonIterableRest(); 91 function _slicedToArray(r, e) { 92 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest(); 93 } 94 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; 95 } 96}); 97
vendor: 493 bytes, lines 98-107
98// node_modules/automation-events/node_modules/@babel/runtime/helpers/classCallCheck.js 99var require_classCallCheck = __commonJS({ 100 "node_modules/automation-events/node_modules/@babel/runtime/helpers/classCallCheck.js"(exports, module) { 101 function _classCallCheck(a, n) { 102 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); 103 } 104 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports; 105 } 106}); 107
vendor: 798 bytes, lines 108-122
108// node_modules/automation-events/node_modules/@babel/runtime/helpers/typeof.js 109var require_typeof = __commonJS({ 110 "node_modules/automation-events/node_modules/@babel/runtime/helpers/typeof.js"(exports, module) { 111 function _typeof(o) { 112 "@babel/helpers - typeof"; 113 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { 114 return typeof o2; 115 } : function(o2) { 116 return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; 117 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o); 118 } 119 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; 120 } 121}); 122
vendor: 775 bytes, lines 123-140
123// node_modules/automation-events/node_modules/@babel/runtime/helpers/toPrimitive.js 124var require_toPrimitive = __commonJS({ 125 "node_modules/automation-events/node_modules/@babel/runtime/helpers/toPrimitive.js"(exports, module) { 126 var _typeof = require_typeof()["default"]; 127 function toPrimitive(t, r) { 128 if ("object" != _typeof(t) || !t) return t; 129 var e = t[Symbol.toPrimitive]; 130 if (void 0 !== e) { 131 var i = e.call(t, r || "default"); 132 if ("object" != _typeof(i)) return i; 133 throw new TypeError("@@toPrimitive must return a primitive value."); 134 } 135 return ("string" === r ? String : Number)(t); 136 } 137 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; 138 } 139}); 140
vendor: 578 bytes, lines 141-153
141// node_modules/automation-events/node_modules/@babel/runtime/helpers/toPropertyKey.js 142var require_toPropertyKey = __commonJS({ 143 "node_modules/automation-events/node_modules/@babel/runtime/helpers/toPropertyKey.js"(exports, module) { 144 var _typeof = require_typeof()["default"]; 145 var toPrimitive = require_toPrimitive(); 146 function toPropertyKey(t) { 147 var i = toPrimitive(t, "string"); 148 return "symbol" == _typeof(i) ? i : i + ""; 149 } 150 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; 151 } 152}); 153
vendor: 878 bytes, lines 154-172
154// node_modules/automation-events/node_modules/@babel/runtime/helpers/createClass.js 155var require_createClass = __commonJS({ 156 "node_modules/automation-events/node_modules/@babel/runtime/helpers/createClass.js"(exports, module) { 157 var toPropertyKey = require_toPropertyKey(); 158 function _defineProperties(e, r) { 159 for (var t = 0; t < r.length; t++) { 160 var o = r[t]; 161 o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, toPropertyKey(o.key), o); 162 } 163 } 164 function _createClass(e, r, t) { 165 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { 166 writable: false 167 }), e; 168 } 169 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports; 170 } 171}); 172
vendor: 19,244 bytes, lines 173-458
173// node_modules/automation-events/build/es5/bundle.js 174var require_bundle = __commonJS({ 175 "node_modules/automation-events/build/es5/bundle.js"(exports, module) { 176 (function(global, factory) { 177 typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_slicedToArray(), require_classCallCheck(), require_createClass()) : typeof define === "function" && define.amd ? define(["exports", "@babel/runtime/helpers/slicedToArray", "@babel/runtime/helpers/classCallCheck", "@babel/runtime/helpers/createClass"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.automationEvents = {}, global._slicedToArray, global._classCallCheck, global._createClass)); 178 })(exports, function(exports2, _slicedToArray, _classCallCheck, _createClass) { 179 "use strict"; 180 var createExtendedExponentialRampToValueAutomationEvent = function createExtendedExponentialRampToValueAutomationEvent2(value, endTime, insertTime) { 181 return { 182 endTime, 183 insertTime, 184 type: "exponentialRampToValue", 185 value 186 }; 187 }; 188 var createExtendedLinearRampToValueAutomationEvent = function createExtendedLinearRampToValueAutomationEvent2(value, endTime, insertTime) { 189 return { 190 endTime, 191 insertTime, 192 type: "linearRampToValue", 193 value 194 }; 195 }; 196 var createSetValueAutomationEvent2 = function createSetValueAutomationEvent3(value, startTime) { 197 return { 198 startTime, 199 type: "setValue", 200 value 201 }; 202 }; 203 var createSetValueCurveAutomationEvent2 = function createSetValueCurveAutomationEvent3(values, startTime, duration) { 204 return { 205 duration, 206 startTime, 207 type: "setValueCurve", 208 values 209 }; 210 }; 211 var getTargetValueAtTime = function getTargetValueAtTime2(time, valueAtStartTime, _ref) { 212 var startTime = _ref.startTime, target = _ref.target, timeConstant = _ref.timeConstant; 213 return target + (valueAtStartTime - target) * Math.exp((startTime - time) / timeConstant); 214 }; 215 var isExponentialRampToValueAutomationEvent = function isExponentialRampToValueAutomationEvent2(automationEvent) { 216 return automationEvent.type === "exponentialRampToValue"; 217 }; 218 var isLinearRampToValueAutomationEvent = function isLinearRampToValueAutomationEvent2(automationEvent) { 219 return automationEvent.type === "linearRampToValue"; 220 }; 221 var isAnyRampToValueAutomationEvent = function isAnyRampToValueAutomationEvent2(automationEvent) { 222 return isExponentialRampToValueAutomationEvent(automationEvent) || isLinearRampToValueAutomationEvent(automationEvent); 223 }; 224 var isSetValueAutomationEvent = function isSetValueAutomationEvent2(automationEvent) { 225 return automationEvent.type === "setValue"; 226 }; 227 var isSetValueCurveAutomationEvent = function isSetValueCurveAutomationEvent2(automationEvent) { 228 return automationEvent.type === "setValueCurve"; 229 }; 230 var _getValueOfAutomationEventAtIndexAtTime = function getValueOfAutomationEventAtIndexAtTime(automationEvents, index, time, defaultValue) { 231 var automationEvent = automationEvents[index]; 232 return automationEvent === void 0 ? defaultValue : isAnyRampToValueAutomationEvent(automationEvent) || isSetValueAutomationEvent(automationEvent) ? automationEvent.value : isSetValueCurveAutomationEvent(automationEvent) ? automationEvent.values[automationEvent.values.length - 1] : getTargetValueAtTime(time, _getValueOfAutomationEventAtIndexAtTime(automationEvents, index - 1, automationEvent.startTime, defaultValue), automationEvent); 233 }; 234 var getEndTimeAndValueOfPreviousAutomationEvent = function getEndTimeAndValueOfPreviousAutomationEvent2(automationEvents, index, currentAutomationEvent, nextAutomationEvent, defaultValue) { 235 return currentAutomationEvent === void 0 ? [nextAutomationEvent.insertTime, defaultValue] : isAnyRampToValueAutomationEvent(currentAutomationEvent) ? [currentAutomationEvent.endTime, currentAutomationEvent.value] : isSetValueAutomationEvent(currentAutomationEvent) ? [currentAutomationEvent.startTime, currentAutomationEvent.value] : isSetValueCurveAutomationEvent(currentAutomationEvent) ? [currentAutomationEvent.startTime + currentAutomationEvent.duration, currentAutomationEvent.values[currentAutomationEvent.values.length - 1]] : [currentAutomationEvent.startTime, _getValueOfAutomationEventAtIndexAtTime(automationEvents, index - 1, currentAutomationEvent.startTime, defaultValue)]; 236 }; 237 var isCancelAndHoldAutomationEvent = function isCancelAndHoldAutomationEvent2(automationEvent) { 238 return automationEvent.type === "cancelAndHold"; 239 }; 240 var isCancelScheduledValuesAutomationEvent = function isCancelScheduledValuesAutomationEvent2(automationEvent) { 241 return automationEvent.type === "cancelScheduledValues"; 242 }; 243 var getEventTime = function getEventTime2(automationEvent) { 244 if (isCancelAndHoldAutomationEvent(automationEvent) || isCancelScheduledValuesAutomationEvent(automationEvent)) { 245 return automationEvent.cancelTime; 246 } 247 if (isExponentialRampToValueAutomationEvent(automationEvent) || isLinearRampToValueAutomationEvent(automationEvent)) { 248 return automationEvent.endTime; 249 } 250 return automationEvent.startTime; 251 }; 252 var getExponentialRampValueAtTime = function getExponentialRampValueAtTime2(time, startTime, valueAtStartTime, _ref) { 253 var endTime = _ref.endTime, value = _ref.value; 254 if (valueAtStartTime === value) { 255 return value; 256 } 257 if (0 < valueAtStartTime && 0 < value || valueAtStartTime < 0 && value < 0) { 258 return valueAtStartTime * Math.pow(value / valueAtStartTime, (time - startTime) / (endTime - startTime)); 259 } 260 return 0; 261 }; 262 var getLinearRampValueAtTime = function getLinearRampValueAtTime2(time, startTime, valueAtStartTime, _ref) { 263 var endTime = _ref.endTime, value = _ref.value; 264 return valueAtStartTime + (time - startTime) / (endTime - startTime) * (value - valueAtStartTime); 265 }; 266 var interpolateValue = function interpolateValue2(values, theoreticIndex) { 267 var lowerIndex = Math.floor(theoreticIndex); 268 var upperIndex = Math.ceil(theoreticIndex); 269 if (lowerIndex === upperIndex) { 270 return values[lowerIndex]; 271 } 272 return (1 - (theoreticIndex - lowerIndex)) * values[lowerIndex] + (1 - (upperIndex - theoreticIndex)) * values[upperIndex]; 273 }; 274 var getValueCurveValueAtTime = function getValueCurveValueAtTime2(time, _ref) { 275 var duration = _ref.duration, startTime = _ref.startTime, values = _ref.values; 276 var theoreticIndex = (time - startTime) / duration * (values.length - 1); 277 return interpolateValue(values, theoreticIndex); 278 }; 279 var isSetTargetAutomationEvent = function isSetTargetAutomationEvent2(automationEvent) { 280 return automationEvent.type === "setTarget"; 281 }; 282 var AutomationEventList2 = /* @__PURE__ */ function() { 283 function AutomationEventList3(defaultValue) { 284 _classCallCheck(this, AutomationEventList3); 285 this._automationEvents = []; 286 this._currenTime = 0; 287 this._defaultValue = defaultValue; 288 } 289 return _createClass(AutomationEventList3, [{ 290 key: Symbol.iterator, 291 value: function value() { 292 return this._automationEvents[Symbol.iterator](); 293 } 294 }, { 295 key: "add", 296 value: function add(automationEvent) { 297 var eventTime = getEventTime(automationEvent); 298 if (isCancelAndHoldAutomationEvent(automationEvent) || isCancelScheduledValuesAutomationEvent(automationEvent)) { 299 var index = this._automationEvents.findIndex(function(currentAutomationEvent) { 300 if (isCancelScheduledValuesAutomationEvent(automationEvent) && isSetValueCurveAutomationEvent(currentAutomationEvent)) { 301 return currentAutomationEvent.startTime + currentAutomationEvent.duration >= eventTime; 302 } 303 return getEventTime(currentAutomationEvent) >= eventTime; 304 }); 305 var removedAutomationEvent = this._automationEvents[index]; 306 if (index !== -1) { 307 this._automationEvents = this._automationEvents.slice(0, index); 308 } 309 if (isCancelAndHoldAutomationEvent(automationEvent)) { 310 var lastAutomationEvent = this._automationEvents[this._automationEvents.length - 1]; 311 if (removedAutomationEvent !== void 0 && isAnyRampToValueAutomationEvent(removedAutomationEvent)) { 312 if (lastAutomationEvent !== void 0 && isSetTargetAutomationEvent(lastAutomationEvent)) { 313 throw new Error("The internal list is malformed."); 314 } 315 var startTime = lastAutomationEvent === void 0 ? removedAutomationEvent.insertTime : isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.startTime + lastAutomationEvent.duration : getEventTime(lastAutomationEvent); 316 var startValue = lastAutomationEvent === void 0 ? this._defaultValue : isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] : lastAutomationEvent.value; 317 var value = isExponentialRampToValueAutomationEvent(removedAutomationEvent) ? getExponentialRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent) : getLinearRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent); 318 var truncatedAutomationEvent = isExponentialRampToValueAutomationEvent(removedAutomationEvent) ? createExtendedExponentialRampToValueAutomationEvent(value, eventTime, this._currenTime) : createExtendedLinearRampToValueAutomationEvent(value, eventTime, this._currenTime); 319 this._automationEvents.push(truncatedAutomationEvent); 320 } 321 if (lastAutomationEvent !== void 0 && isSetTargetAutomationEvent(lastAutomationEvent)) { 322 this._automationEvents.push(createSetValueAutomationEvent2(this.getValue(eventTime), eventTime)); 323 } 324 if (lastAutomationEvent !== void 0 && isSetValueCurveAutomationEvent(lastAutomationEvent) && lastAutomationEvent.startTime + lastAutomationEvent.duration > eventTime) { 325 var duration = eventTime - lastAutomationEvent.startTime; 326 var ratio = (lastAutomationEvent.values.length - 1) / lastAutomationEvent.duration; 327 var length = Math.max(2, 1 + Math.ceil(duration * ratio)); 328 var fraction = duration / (length - 1) * ratio; 329 var values = lastAutomationEvent.values.slice(0, length); 330 if (fraction < 1) { 331 for (var i = 1; i < length; i += 1) { 332 var factor = fraction * i % 1; 333 values[i] = lastAutomationEvent.values[i - 1] * (1 - factor) + lastAutomationEvent.values[i] * factor; 334 } 335 } 336 this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent2(values, lastAutomationEvent.startTime, duration); 337 } 338 } 339 } else { 340 var _index = this._automationEvents.findIndex(function(currentAutomationEvent) { 341 return getEventTime(currentAutomationEvent) > eventTime; 342 }); 343 var previousAutomationEvent = _index === -1 ? this._automationEvents[this._automationEvents.length - 1] : this._automationEvents[_index - 1]; 344 if (previousAutomationEvent !== void 0 && isSetValueCurveAutomationEvent(previousAutomationEvent) && getEventTime(previousAutomationEvent) + previousAutomationEvent.duration > eventTime) { 345 return false; 346 } 347 var persistentAutomationEvent = isExponentialRampToValueAutomationEvent(automationEvent) ? createExtendedExponentialRampToValueAutomationEvent(automationEvent.value, automationEvent.endTime, this._currenTime) : isLinearRampToValueAutomationEvent(automationEvent) ? createExtendedLinearRampToValueAutomationEvent(automationEvent.value, eventTime, this._currenTime) : automationEvent; 348 if (_index === -1) { 349 this._automationEvents.push(persistentAutomationEvent); 350 } else { 351 if (isSetValueCurveAutomationEvent(automationEvent) && eventTime + automationEvent.duration > getEventTime(this._automationEvents[_index])) { 352 return false; 353 } 354 this._automationEvents.splice(_index, 0, persistentAutomationEvent); 355 } 356 } 357 return true; 358 } 359 }, { 360 key: "flush", 361 value: function flush(time) { 362 var index = this._automationEvents.findIndex(function(currentAutomationEvent) { 363 return getEventTime(currentAutomationEvent) > time; 364 }); 365 if (index > 1) { 366 var remainingAutomationEvents = this._automationEvents.slice(index - 1); 367 var firstRemainingAutomationEvent = remainingAutomationEvents[0]; 368 if (isSetTargetAutomationEvent(firstRemainingAutomationEvent)) { 369 remainingAutomationEvents.unshift(createSetValueAutomationEvent2(_getValueOfAutomationEventAtIndexAtTime(this._automationEvents, index - 2, firstRemainingAutomationEvent.startTime, this._defaultValue), firstRemainingAutomationEvent.startTime)); 370 } 371 this._automationEvents = remainingAutomationEvents; 372 } 373 } 374 }, { 375 key: "getValue", 376 value: function getValue(time) { 377 if (this._automationEvents.length === 0) { 378 return this._defaultValue; 379 } 380 var indexOfNextEvent = this._automationEvents.findIndex(function(automationEvent) { 381 return getEventTime(automationEvent) > time; 382 }); 383 var nextAutomationEvent = this._automationEvents[indexOfNextEvent]; 384 var indexOfCurrentEvent = (indexOfNextEvent === -1 ? this._automationEvents.length : indexOfNextEvent) - 1; 385 var currentAutomationEvent = this._automationEvents[indexOfCurrentEvent]; 386 if (currentAutomationEvent !== void 0 && isSetTargetAutomationEvent(currentAutomationEvent) && (nextAutomationEvent === void 0 || !isAnyRampToValueAutomationEvent(nextAutomationEvent) || nextAutomationEvent.insertTime > time)) { 387 return getTargetValueAtTime(time, _getValueOfAutomationEventAtIndexAtTime(this._automationEvents, indexOfCurrentEvent - 1, currentAutomationEvent.startTime, this._defaultValue), currentAutomationEvent); 388 } 389 if (currentAutomationEvent !== void 0 && isSetValueAutomationEvent(currentAutomationEvent) && (nextAutomationEvent === void 0 || !isAnyRampToValueAutomationEvent(nextAutomationEvent))) { 390 return currentAutomationEvent.value; 391 } 392 if (currentAutomationEvent !== void 0 && isSetValueCurveAutomationEvent(currentAutomationEvent) && (nextAutomationEvent === void 0 || !isAnyRampToValueAutomationEvent(nextAutomationEvent) || currentAutomationEvent.startTime + currentAutomationEvent.duration > time)) { 393 if (time < currentAutomationEvent.startTime + currentAutomationEvent.duration) { 394 return getValueCurveValueAtTime(time, currentAutomationEvent); 395 } 396 return currentAutomationEvent.values[currentAutomationEvent.values.length - 1]; 397 } 398 if (currentAutomationEvent !== void 0 && isAnyRampToValueAutomationEvent(currentAutomationEvent) && (nextAutomationEvent === void 0 || !isAnyRampToValueAutomationEvent(nextAutomationEvent))) { 399 return currentAutomationEvent.value; 400 } 401 if (nextAutomationEvent !== void 0 && isExponentialRampToValueAutomationEvent(nextAutomationEvent)) { 402 var _getEndTimeAndValueOf = getEndTimeAndValueOfPreviousAutomationEvent(this._automationEvents, indexOfCurrentEvent, currentAutomationEvent, nextAutomationEvent, this._defaultValue), _getEndTimeAndValueOf2 = _slicedToArray(_getEndTimeAndValueOf, 2), startTime = _getEndTimeAndValueOf2[0], value = _getEndTimeAndValueOf2[1]; 403 return getExponentialRampValueAtTime(time, startTime, value, nextAutomationEvent); 404 } 405 if (nextAutomationEvent !== void 0 && isLinearRampToValueAutomationEvent(nextAutomationEvent)) { 406 var _getEndTimeAndValueOf3 = getEndTimeAndValueOfPreviousAutomationEvent(this._automationEvents, indexOfCurrentEvent, currentAutomationEvent, nextAutomationEvent, this._defaultValue), _getEndTimeAndValueOf4 = _slicedToArray(_getEndTimeAndValueOf3, 2), _startTime = _getEndTimeAndValueOf4[0], _value = _getEndTimeAndValueOf4[1]; 407 return getLinearRampValueAtTime(time, _startTime, _value, nextAutomationEvent); 408 } 409 return this._defaultValue; 410 } 411 }]); 412 }(); 413 var createCancelAndHoldAutomationEvent2 = function createCancelAndHoldAutomationEvent3(cancelTime) { 414 return { 415 cancelTime, 416 type: "cancelAndHold" 417 }; 418 }; 419 var createCancelScheduledValuesAutomationEvent2 = function createCancelScheduledValuesAutomationEvent3(cancelTime) { 420 return { 421 cancelTime, 422 type: "cancelScheduledValues" 423 }; 424 }; 425 var createExponentialRampToValueAutomationEvent2 = function createExponentialRampToValueAutomationEvent3(value, endTime) { 426 return { 427 endTime, 428 type: "exponentialRampToValue", 429 value 430 }; 431 }; 432 var createLinearRampToValueAutomationEvent2 = function createLinearRampToValueAutomationEvent3(value, endTime) { 433 return { 434 endTime, 435 type: "linearRampToValue", 436 value 437 }; 438 }; 439 var createSetTargetAutomationEvent2 = function createSetTargetAutomationEvent3(target, startTime, timeConstant) { 440 return { 441 startTime, 442 target, 443 timeConstant, 444 type: "setTarget" 445 }; 446 }; 447 exports2.AutomationEventList = AutomationEventList2; 448 exports2.createCancelAndHoldAutomationEvent = createCancelAndHoldAutomationEvent2; 449 exports2.createCancelScheduledValuesAutomationEvent = createCancelScheduledValuesAutomationEvent2; 450 exports2.createExponentialRampToValueAutomationEvent = createExponentialRampToValueAutomationEvent2; 451 exports2.createLinearRampToValueAutomationEvent = createLinearRampToValueAutomationEvent2; 452 exports2.createSetTargetAutomationEvent = createSetTargetAutomationEvent2; 453 exports2.createSetValueAutomationEvent = createSetValueAutomationEvent2; 454 exports2.createSetValueCurveAutomationEvent = createSetValueCurveAutomationEvent2; 455 }); 456 } 457}); 458
vendor: 12,714 bytes, lines 459-834
459// node_modules/fft.js/lib/fft.js 460var require_fft = __commonJS({ 461 "node_modules/fft.js/lib/fft.js"(exports, module) { 462 "use strict"; 463 function FFT3(size) { 464 this.size = size | 0; 465 if (this.size <= 1 || (this.size & this.size - 1) !== 0) 466 throw new Error("FFT size must be a power of two and bigger than 1"); 467 this._csize = size << 1; 468 var table = new Array(this.size * 2); 469 for (var i = 0; i < table.length; i += 2) { 470 const angle = Math.PI * i / this.size; 471 table[i] = Math.cos(angle); 472 table[i + 1] = -Math.sin(angle); 473 } 474 this.table = table; 475 var power = 0; 476 for (var t = 1; this.size > t; t <<= 1) 477 power++; 478 this._width = power % 2 === 0 ? power - 1 : power; 479 this._bitrev = new Array(1 << this._width); 480 for (var j = 0; j < this._bitrev.length; j++) { 481 this._bitrev[j] = 0; 482 for (var shift = 0; shift < this._width; shift += 2) { 483 var revShift = this._width - shift - 2; 484 this._bitrev[j] |= (j >>> shift & 3) << revShift; 485 } 486 } 487 this._out = null; 488 this._data = null; 489 this._inv = 0; 490 } 491 module.exports = FFT3; 492 FFT3.prototype.fromComplexArray = function fromComplexArray(complex, storage) { 493 var res = storage || new Array(complex.length >>> 1); 494 for (var i = 0; i < complex.length; i += 2) 495 res[i >>> 1] = complex[i]; 496 return res; 497 }; 498 FFT3.prototype.createComplexArray = function createComplexArray() { 499 const res = new Array(this._csize); 500 for (var i = 0; i < res.length; i++) 501 res[i] = 0; 502 return res; 503 }; 504 FFT3.prototype.toComplexArray = function toComplexArray(input, storage) { 505 var res = storage || this.createComplexArray(); 506 for (var i = 0; i < res.length; i += 2) { 507 res[i] = input[i >>> 1]; 508 res[i + 1] = 0; 509 } 510 return res; 511 }; 512 FFT3.prototype.completeSpectrum = function completeSpectrum(spectrum) { 513 var size = this._csize; 514 var half = size >>> 1; 515 for (var i = 2; i < half; i += 2) { 516 spectrum[size - i] = spectrum[i]; 517 spectrum[size - i + 1] = -spectrum[i + 1]; 518 } 519 }; 520 FFT3.prototype.transform = function transform(out, data) { 521 if (out === data) 522 throw new Error("Input and output buffers must be different"); 523 this._out = out; 524 this._data = data; 525 this._inv = 0; 526 this._transform4(); 527 this._out = null; 528 this._data = null; 529 }; 530 FFT3.prototype.realTransform = function realTransform(out, data) { 531 if (out === data) 532 throw new Error("Input and output buffers must be different"); 533 this._out = out; 534 this._data = data; 535 this._inv = 0; 536 this._realTransform4(); 537 this._out = null; 538 this._data = null; 539 }; 540 FFT3.prototype.inverseTransform = function inverseTransform(out, data) { 541 if (out === data) 542 throw new Error("Input and output buffers must be different"); 543 this._out = out; 544 this._data = data; 545 this._inv = 1; 546 this._transform4(); 547 for (var i = 0; i < out.length; i++) 548 out[i] /= this.size; 549 this._out = null; 550 this._data = null; 551 }; 552 FFT3.prototype._transform4 = function _transform4() { 553 var out = this._out; 554 var size = this._csize; 555 var width = this._width; 556 var step = 1 << width; 557 var len = size / step << 1; 558 var outOff; 559 var t; 560 var bitrev = this._bitrev; 561 if (len === 4) { 562 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { 563 const off = bitrev[t]; 564 this._singleTransform2(outOff, off, step); 565 } 566 } else { 567 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { 568 const off = bitrev[t]; 569 this._singleTransform4(outOff, off, step); 570 } 571 } 572 var inv = this._inv ? -1 : 1; 573 var table = this.table; 574 for (step >>= 2; step >= 2; step >>= 2) { 575 len = size / step << 1; 576 var quarterLen = len >>> 2; 577 for (outOff = 0; outOff < size; outOff += len) { 578 var limit = outOff + quarterLen; 579 for (var i = outOff, k = 0; i < limit; i += 2, k += step) { 580 const A = i; 581 const B = A + quarterLen; 582 const C = B + quarterLen; 583 const D = C + quarterLen; 584 const Ar = out[A]; 585 const Ai = out[A + 1]; 586 const Br = out[B]; 587 const Bi = out[B + 1]; 588 const Cr = out[C]; 589 const Ci = out[C + 1]; 590 const Dr = out[D]; 591 const Di = out[D + 1]; 592 const MAr = Ar; 593 const MAi = Ai; 594 const tableBr = table[k]; 595 const tableBi = inv * table[k + 1]; 596 const MBr = Br * tableBr - Bi * tableBi; 597 const MBi = Br * tableBi + Bi * tableBr; 598 const tableCr = table[2 * k]; 599 const tableCi = inv * table[2 * k + 1]; 600 const MCr = Cr * tableCr - Ci * tableCi; 601 const MCi = Cr * tableCi + Ci * tableCr; 602 const tableDr = table[3 * k]; 603 const tableDi = inv * table[3 * k + 1]; 604 const MDr = Dr * tableDr - Di * tableDi; 605 const MDi = Dr * tableDi + Di * tableDr; 606 const T0r = MAr + MCr; 607 const T0i = MAi + MCi; 608 const T1r = MAr - MCr; 609 const T1i = MAi - MCi; 610 const T2r = MBr + MDr; 611 const T2i = MBi + MDi; 612 const T3r = inv * (MBr - MDr); 613 const T3i = inv * (MBi - MDi); 614 const FAr = T0r + T2r; 615 const FAi = T0i + T2i; 616 const FCr = T0r - T2r; 617 const FCi = T0i - T2i; 618 const FBr = T1r + T3i; 619 const FBi = T1i - T3r; 620 const FDr = T1r - T3i; 621 const FDi = T1i + T3r; 622 out[A] = FAr; 623 out[A + 1] = FAi; 624 out[B] = FBr; 625 out[B + 1] = FBi; 626 out[C] = FCr; 627 out[C + 1] = FCi; 628 out[D] = FDr; 629 out[D + 1] = FDi; 630 } 631 } 632 } 633 }; 634 FFT3.prototype._singleTransform2 = function _singleTransform2(outOff, off, step) { 635 const out = this._out; 636 const data = this._data; 637 const evenR = data[off]; 638 const evenI = data[off + 1]; 639 const oddR = data[off + step]; 640 const oddI = data[off + step + 1]; 641 const leftR = evenR + oddR; 642 const leftI = evenI + oddI; 643 const rightR = evenR - oddR; 644 const rightI = evenI - oddI; 645 out[outOff] = leftR; 646 out[outOff + 1] = leftI; 647 out[outOff + 2] = rightR; 648 out[outOff + 3] = rightI; 649 }; 650 FFT3.prototype._singleTransform4 = function _singleTransform4(outOff, off, step) { 651 const out = this._out; 652 const data = this._data; 653 const inv = this._inv ? -1 : 1; 654 const step2 = step * 2; 655 const step3 = step * 3; 656 const Ar = data[off]; 657 const Ai = data[off + 1]; 658 const Br = data[off + step]; 659 const Bi = data[off + step + 1]; 660 const Cr = data[off + step2]; 661 const Ci = data[off + step2 + 1]; 662 const Dr = data[off + step3]; 663 const Di = data[off + step3 + 1]; 664 const T0r = Ar + Cr; 665 const T0i = Ai + Ci; 666 const T1r = Ar - Cr; 667 const T1i = Ai - Ci; 668 const T2r = Br + Dr; 669 const T2i = Bi + Di; 670 const T3r = inv * (Br - Dr); 671 const T3i = inv * (Bi - Di); 672 const FAr = T0r + T2r; 673 const FAi = T0i + T2i; 674 const FBr = T1r + T3i; 675 const FBi = T1i - T3r; 676 const FCr = T0r - T2r; 677 const FCi = T0i - T2i; 678 const FDr = T1r - T3i; 679 const FDi = T1i + T3r; 680 out[outOff] = FAr; 681 out[outOff + 1] = FAi; 682 out[outOff + 2] = FBr; 683 out[outOff + 3] = FBi; 684 out[outOff + 4] = FCr; 685 out[outOff + 5] = FCi; 686 out[outOff + 6] = FDr; 687 out[outOff + 7] = FDi; 688 }; 689 FFT3.prototype._realTransform4 = function _realTransform4() { 690 var out = this._out; 691 var size = this._csize; 692 var width = this._width; 693 var step = 1 << width; 694 var len = size / step << 1; 695 var outOff; 696 var t; 697 var bitrev = this._bitrev; 698 if (len === 4) { 699 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { 700 const off = bitrev[t]; 701 this._singleRealTransform2(outOff, off >>> 1, step >>> 1); 702 } 703 } else { 704 for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { 705 const off = bitrev[t]; 706 this._singleRealTransform4(outOff, off >>> 1, step >>> 1); 707 } 708 } 709 var inv = this._inv ? -1 : 1; 710 var table = this.table; 711 for (step >>= 2; step >= 2; step >>= 2) { 712 len = size / step << 1; 713 var halfLen = len >>> 1; 714 var quarterLen = halfLen >>> 1; 715 var hquarterLen = quarterLen >>> 1; 716 for (outOff = 0; outOff < size; outOff += len) { 717 for (var i = 0, k = 0; i <= hquarterLen; i += 2, k += step) { 718 var A = outOff + i; 719 var B = A + quarterLen; 720 var C = B + quarterLen; 721 var D = C + quarterLen; 722 var Ar = out[A]; 723 var Ai = out[A + 1]; 724 var Br = out[B]; 725 var Bi = out[B + 1]; 726 var Cr = out[C]; 727 var Ci = out[C + 1]; 728 var Dr = out[D]; 729 var Di = out[D + 1]; 730 var MAr = Ar; 731 var MAi = Ai; 732 var tableBr = table[k]; 733 var tableBi = inv * table[k + 1]; 734 var MBr = Br * tableBr - Bi * tableBi; 735 var MBi = Br * tableBi + Bi * tableBr; 736 var tableCr = table[2 * k]; 737 var tableCi = inv * table[2 * k + 1]; 738 var MCr = Cr * tableCr - Ci * tableCi; 739 var MCi = Cr * tableCi + Ci * tableCr; 740 var tableDr = table[3 * k]; 741 var tableDi = inv * table[3 * k + 1]; 742 var MDr = Dr * tableDr - Di * tableDi; 743 var MDi = Dr * tableDi + Di * tableDr; 744 var T0r = MAr + MCr; 745 var T0i = MAi + MCi; 746 var T1r = MAr - MCr; 747 var T1i = MAi - MCi; 748 var T2r = MBr + MDr; 749 var T2i = MBi + MDi; 750 var T3r = inv * (MBr - MDr); 751 var T3i = inv * (MBi - MDi); 752 var FAr = T0r + T2r; 753 var FAi = T0i + T2i; 754 var FBr = T1r + T3i; 755 var FBi = T1i - T3r; 756 out[A] = FAr; 757 out[A + 1] = FAi; 758 out[B] = FBr; 759 out[B + 1] = FBi; 760 if (i === 0) { 761 var FCr = T0r - T2r; 762 var FCi = T0i - T2i; 763 out[C] = FCr; 764 out[C + 1] = FCi; 765 continue; 766 } 767 if (i === hquarterLen) 768 continue; 769 var ST0r = T1r; 770 var ST0i = -T1i; 771 var ST1r = T0r; 772 var ST1i = -T0i; 773 var ST2r = -inv * T3i; 774 var ST2i = -inv * T3r; 775 var ST3r = -inv * T2i; 776 var ST3i = -inv * T2r; 777 var SFAr = ST0r + ST2r; 778 var SFAi = ST0i + ST2i; 779 var SFBr = ST1r + ST3i; 780 var SFBi = ST1i - ST3r; 781 var SA = outOff + quarterLen - i; 782 var SB = outOff + halfLen - i; 783 out[SA] = SFAr; 784 out[SA + 1] = SFAi; 785 out[SB] = SFBr; 786 out[SB + 1] = SFBi; 787 } 788 } 789 } 790 }; 791 FFT3.prototype._singleRealTransform2 = function _singleRealTransform2(outOff, off, step) { 792 const out = this._out; 793 const data = this._data; 794 const evenR = data[off]; 795 const oddR = data[off + step]; 796 const leftR = evenR + oddR; 797 const rightR = evenR - oddR; 798 out[outOff] = leftR; 799 out[outOff + 1] = 0; 800 out[outOff + 2] = rightR; 801 out[outOff + 3] = 0; 802 }; 803 FFT3.prototype._singleRealTransform4 = function _singleRealTransform4(outOff, off, step) { 804 const out = this._out; 805 const data = this._data; 806 const inv = this._inv ? -1 : 1; 807 const step2 = step * 2; 808 const step3 = step * 3; 809 const Ar = data[off]; 810 const Br = data[off + step]; 811 const Cr = data[off + step2]; 812 const Dr = data[off + step3]; 813 const T0r = Ar + Cr; 814 const T1r = Ar - Cr; 815 const T2r = Br + Dr; 816 const T3r = inv * (Br - Dr); 817 const FAr = T0r + T2r; 818 const FBr = T1r; 819 const FBi = -T3r; 820 const FCr = T0r - T2r; 821 const FDr = T1r; 822 const FDi = T3r; 823 out[outOff] = FAr; 824 out[outOff + 1] = 0; 825 out[outOff + 2] = FBr; 826 out[outOff + 3] = FBi; 827 out[outOff + 4] = FCr; 828 out[outOff + 5] = 0; 829 out[outOff + 6] = FDr; 830 out[outOff + 7] = FDi; 831 }; 832 } 833}); 834
835// app/javascript/components/daw/DAW.jsx 836var import_react17 = __toESM(require_react()); 837
838// app/javascript/components/daw/context/DAWContext.jsx 839var import_react = __toESM(require_react()); 840
841// app/javascript/components/daw/context/DAWReducer.js 842var ActionTypes = { 843 SET_PLAYING: "SET_PLAYING", 844 SET_BPM: "SET_BPM", 845 SET_CURRENT_STEP: "SET_CURRENT_STEP", 846 SET_LOOP: "SET_LOOP", 847 SET_LOOP_POINTS: "SET_LOOP_POINTS", 848 ADD_TRACK: "ADD_TRACK", 849 REMOVE_TRACK: "REMOVE_TRACK", 850 UPDATE_TRACK: "UPDATE_TRACK", 851 UPDATE_TRACK_EFFECTS: "UPDATE_TRACK_EFFECTS", 852 SELECT_TRACK: "SELECT_TRACK", 853 ADD_NOTE: "ADD_NOTE", 854 REMOVE_NOTE: "REMOVE_NOTE", 855 UPDATE_NOTE: "UPDATE_NOTE", 856 CLEAR_PATTERN: "CLEAR_PATTERN", 857 FILL_PATTERN: "FILL_PATTERN", 858 DUPLICATE_PATTERN: "DUPLICATE_PATTERN", 859 SET_MASTER_VOLUME: "SET_MASTER_VOLUME", 860 LOAD_PROJECT: "LOAD_PROJECT", 861 NEW_PROJECT: "NEW_PROJECT", 862 SET_AUDIO_INITIALIZED: "SET_AUDIO_INITIALIZED", 863 SET_STEPS_PER_MEASURE: "SET_STEPS_PER_MEASURE", 864 SET_TOTAL_STEPS: "SET_TOTAL_STEPS", 865 SET_PROJECT_NAME: "SET_PROJECT_NAME", 866 SET_SELECTED_PITCH: "SET_SELECTED_PITCH", 867 PREPARE_PATTERN_LOAD: "PREPARE_PATTERN_LOAD", 868 LOAD_PATTERN: "LOAD_PATTERN", 869 SET_CURRENT_PATTERN_ID: "SET_CURRENT_PATTERN_ID" 870}; 871var DEFAULT_TRACK_EFFECTS = { 872 eq3: { 873 enabled: false, 874 low: 0, 875 // dB (-12 to 12) 876 mid: 0, 877 // dB (-12 to 12) 878 high: 0, 879 // dB (-12 to 12) 880 lowFrequency: 400, 881 // Hz 882 highFrequency: 2500 883 // Hz 884 }, 885 compressor: { 886 enabled: false, 887 threshold: -24, 888 // dB 889 ratio: 4, 890 // ratio 891 attack: 3e-3, 892 // seconds 893 release: 0.25 894 // seconds 895 }, 896 distortion: { 897 enabled: false, 898 amount: 0.4, 899 type: "softclip" 900 }, 901 phaser: { 902 enabled: false, 903 frequency: 0.5, 904 // Hz (LFO rate) 905 octaves: 3, 906 // range of modulation 907 baseFrequency: 1e3, 908 // Hz 909 wet: 0.5 910 }, 911 tremolo: { 912 enabled: false, 913 frequency: 4, 914 // Hz (LFO rate) 915 depth: 0.5, 916 // 0-1 917 wet: 1 918 }, 919 chorus: { 920 enabled: false, 921 frequency: 1.5, 922 depth: 0.7, 923 wet: 0.3 924 }, 925 delay: { 926 enabled: false, 927 time: "8n", 928 feedback: 0.3, 929 wet: 0.3 930 }, 931 reverb: { 932 enabled: false, 933 roomSize: 0.5, 934 wet: 0.3 935 } 936}; 937var noteIdCounter = 0; 938var generateNoteId = () => `note-${Date.now()}-${++noteIdCounter}`; 939var trackIdCounter = 0; 940var generateTrackId = () => `track-${Date.now()}-${++trackIdCounter}`; 941var synthCounter = 1; 942var drumCounter = 1; 943var pluckCounter = 1; 944var fmCounter = 1; 945var amCounter = 1; 946var initialState = { 947 isPlaying: false, 948 audioInitialized: false, 949 currentStep: 0, 950 bpm: 120, 951 isLooping: true, 952 loopStart: 0, 953 loopEnd: 16, 954 stepsPerMeasure: 16, 955 totalSteps: 16, 956 masterVolume: 0.8, 957 projectName: "", 958 selectedPitch: null, 959 // For pattern fill - which row is selected 960 currentPatternId: null, 961 // For tracking loaded pattern from library 962 tracks: [ 963 { 964 id: "track-1", 965 name: "Synth 1", 966 type: "synth", 967 instrument: { 968 oscillator: "sawtooth", 969 attack: 0.01, 970 decay: 0.1, 971 sustain: 0.5, 972 release: 0.3, 973 filterFreq: 2e3, 974 filterRes: 1, 975 lfo: { 976 enabled: false, 977 rate: "8n", 978 // Tempo-synced rate (1m, 2n, 4n, 8n, 16n, 32n, triplets) 979 waveform: "sine", 980 // sine, square, sawtooth, triangle 981 depth: 0.5 982 // 0-1 (how much the filter moves) 983 } 984 }, 985 effects: { ...DEFAULT_TRACK_EFFECTS }, 986 muted: false, 987 solo: false, 988 volume: 0.8, 989 pan: 0, 990 notes: [] 991 } 992 ], 993 selectedTrackId: "track-1" 994}; 995function createDefaultSynthTrack() { 996 const id = generateTrackId(); 997 return { 998 id, 999 name: `Synth ${synthCounter++}`, 1000 type: "synth", 1001 instrument: { 1002 oscillator: "sawtooth", 1003 attack: 0.01, 1004 decay: 0.1, 1005 sustain: 0.5, 1006 release: 0.3, 1007 filterFreq: 2e3, 1008 filterRes: 1, 1009 lfo: { 1010 enabled: false, 1011 rate: "8n", 1012 // Tempo-synced rate (1m, 2n, 4n, 8n, 16n, 32n, triplets) 1013 waveform: "sine", 1014 // sine, square, sawtooth, triangle 1015 depth: 0.5 1016 // 0-1 (how much the filter moves) 1017 } 1018 }, 1019 effects: { ...DEFAULT_TRACK_EFFECTS }, 1020 muted: false, 1021 solo: false, 1022 volume: 0.8, 1023 pan: 0, 1024 notes: [] 1025 }; 1026} 1027function createDefaultDrumTrack() { 1028 const id = generateTrackId(); 1029 return { 1030 id, 1031 name: `Drums ${drumCounter++}`, 1032 type: "drums", 1033 instrument: { 1034 kit: "default" 1035 }, 1036 effects: { ...DEFAULT_TRACK_EFFECTS }, 1037 muted: false, 1038 solo: false, 1039 volume: 0.8, 1040 pan: 0, 1041 notes: [] 1042 }; 1043} 1044function createAudioTrack(name, audioData) { 1045 const id = generateTrackId(); 1046 return { 1047 id, 1048 name: name || `Audio ${id.split("-").pop()}`, 1049 type: "audio", 1050 audioData, 1051 // { url, buffer, duration } 1052 effects: { ...DEFAULT_TRACK_EFFECTS }, 1053 muted: false, 1054 solo: false, 1055 volume: 0.8, 1056 pan: 0, 1057 notes: [] 1058 // Not used for audio tracks 1059 }; 1060} 1061function createPluckTrack() { 1062 const id = generateTrackId(); 1063 return { 1064 id, 1065 name: `Pluck ${pluckCounter++}`, 1066 type: "pluck", 1067 instrument: { 1068 attackNoise: 1, 1069 // 0-10 (string attack noise) 1070 dampening: 4e3, 1071 // Hz (string dampening frequency) 1072 resonance: 0.7, 1073 // 0-1 (string resonance) 1074 release: 1 1075 // seconds (release time) 1076 }, 1077 effects: { ...DEFAULT_TRACK_EFFECTS }, 1078 muted: false, 1079 solo: false, 1080 volume: 0.8, 1081 pan: 0, 1082 notes: [] 1083 }; 1084} 1085function createFMTrack() { 1086 const id = generateTrackId(); 1087 return { 1088 id, 1089 name: `FM ${fmCounter++}`, 1090 type: "fm", 1091 instrument: { 1092 harmonicity: 3, 1093 // ratio between carrier and modulator 1094 modulationIndex: 10, 1095 // modulation depth 1096 attack: 0.01, 1097 decay: 0.1, 1098 sustain: 0.5, 1099 release: 0.5, 1100 modulationAttack: 0.5, 1101 modulationDecay: 0, 1102 modulationSustain: 1, 1103 modulationRelease: 0.5 1104 }, 1105 effects: { ...DEFAULT_TRACK_EFFECTS }, 1106 muted: false, 1107 solo: false, 1108 volume: 0.8, 1109 pan: 0, 1110 notes: [] 1111 }; 1112} 1113function createAMTrack() { 1114 const id = generateTrackId(); 1115 return { 1116 id, 1117 name: `AM ${amCounter++}`, 1118 type: "am", 1119 instrument: { 1120 harmonicity: 3, 1121 // ratio between carrier and modulator 1122 attack: 0.01, 1123 decay: 0.1, 1124 sustain: 0.5, 1125 release: 0.5, 1126 modulationAttack: 0.5, 1127 modulationDecay: 0, 1128 modulationSustain: 1, 1129 modulationRelease: 0.5 1130 }, 1131 effects: { ...DEFAULT_TRACK_EFFECTS }, 1132 muted: false, 1133 solo: false, 1134 volume: 0.8, 1135 pan: 0, 1136 notes: [] 1137 }; 1138} 1139function generateFillNotes(fillType, pitch, totalSteps) { 1140 const notes = []; 1141 let stepInterval; 1142 switch (fillType) { 1143 case "every": 1144 stepInterval = 1; 1145 break; 1146 case "every2": 1147 stepInterval = 2; 1148 break; 1149 case "every4": 1150 stepInterval = 4;
1151 break; 1152 case "everyHalf": 1153 stepInterval = 0.5; 1154 break; 1155 default: 1156 return notes; 1157 } 1158 for (let step = 0; step < totalSteps; step += stepInterval) { 1159 notes.push({ 1160 id: generateNoteId(), 1161 pitch, 1162 step: Math.floor(step), 1163 duration: Math.min(stepInterval, 1), 1164 velocity: 100 1165 }); 1166 } 1167 return notes; 1168} 1169function dawReducer(state, action) { 1170 switch (action.type) { 1171 case ActionTypes.SET_PLAYING: 1172 return { ...state, isPlaying: action.payload }; 1173 case ActionTypes.SET_AUDIO_INITIALIZED: 1174 return { ...state, audioInitialized: action.payload }; 1175 case ActionTypes.SET_BPM: 1176 return { ...state, bpm: Math.max(40, Math.min(240, action.payload)) }; 1177 case ActionTypes.SET_CURRENT_STEP: 1178 return { ...state, currentStep: action.payload }; 1179 case ActionTypes.SET_LOOP: 1180 return { ...state, isLooping: action.payload }; 1181 case ActionTypes.SET_LOOP_POINTS: 1182 return { 1183 ...state, 1184 loopStart: action.payload.start ?? state.loopStart, 1185 loopEnd: action.payload.end ?? state.loopEnd 1186 }; 1187 case ActionTypes.SET_STEPS_PER_MEASURE: 1188 return { ...state, stepsPerMeasure: action.payload }; 1189 case ActionTypes.SET_TOTAL_STEPS: 1190 return { 1191 ...state, 1192 totalSteps: action.payload, 1193 loopEnd: Math.min(state.loopEnd, action.payload) 1194 }; 1195 case ActionTypes.SET_MASTER_VOLUME: 1196 return { ...state, masterVolume: Math.max(0, Math.min(1, action.payload)) }; 1197 case ActionTypes.ADD_TRACK: 1198 return { 1199 ...state, 1200 tracks: [...state.tracks, action.payload], 1201 selectedTrackId: action.payload.id 1202 }; 1203 case ActionTypes.REMOVE_TRACK: 1204 if (state.tracks.length <= 1) return state; 1205 const newTracks = state.tracks.filter((t) => t.id !== action.payload); 1206 return { 1207 ...state, 1208 tracks: newTracks, 1209 selectedTrackId: state.selectedTrackId === action.payload ? newTracks[0]?.id : state.selectedTrackId 1210 }; 1211 case ActionTypes.UPDATE_TRACK: 1212 return { 1213 ...state, 1214 tracks: state.tracks.map( 1215 (t) => t.id === action.payload.id ? { ...t, ...action.payload.updates } : t 1216 ) 1217 }; 1218 case ActionTypes.UPDATE_TRACK_EFFECTS: { 1219 const { trackId, effectType, settings } = action.payload; 1220 return { 1221 ...state, 1222 tracks: state.tracks.map((t) => { 1223 if (t.id !== trackId) return t; 1224 return { 1225 ...t, 1226 effects: { 1227 ...t.effects, 1228 [effectType]: { 1229 ...t.effects[effectType], 1230 ...settings 1231 } 1232 } 1233 }; 1234 }) 1235 }; 1236 } 1237 case ActionTypes.SELECT_TRACK: 1238 return { ...state, selectedTrackId: action.payload }; 1239 case ActionTypes.ADD_NOTE: { 1240 const { trackId, note } = action.payload; 1241 return { 1242 ...state, 1243 tracks: state.tracks.map( 1244 (t) => t.id === trackId ? { ...t, notes: [...t.notes, { ...note, id: note.id || generateNoteId() }] } : t 1245 ) 1246 }; 1247 } 1248 case ActionTypes.REMOVE_NOTE: { 1249 const { trackId, noteId } = action.payload; 1250 return { 1251 ...state, 1252 tracks: state.tracks.map( 1253 (t) => t.id === trackId ? { ...t, notes: t.notes.filter((n) => n.id !== noteId) } : t 1254 ) 1255 }; 1256 } 1257 case ActionTypes.UPDATE_NOTE: { 1258 const { trackId, noteId, updates } = action.payload; 1259 return { 1260 ...state, 1261 tracks: state.tracks.map( 1262 (t) => t.id === trackId ? { 1263 ...t, 1264 notes: t.notes.map((n) => n.id === noteId ? { ...n, ...updates } : n) 1265 } : t 1266 ) 1267 }; 1268 } 1269 case ActionTypes.CLEAR_PATTERN: { 1270 const { trackId } = action.payload; 1271 return { 1272 ...state, 1273 tracks: state.tracks.map( 1274 (t) => t.id === trackId ? { ...t, notes: [] } : t 1275 ) 1276 }; 1277 } 1278 case ActionTypes.FILL_PATTERN: { 1279 const { trackId, fillType, pitch } = action.payload; 1280 const newNotes = generateFillNotes(fillType, pitch, state.totalSteps); 1281 return { 1282 ...state, 1283 tracks: state.tracks.map((t) => { 1284 if (t.id !== trackId) return t; 1285 const existingNotes = t.notes.filter((n) => n.pitch !== pitch); 1286 return { ...t, notes: [...existingNotes, ...newNotes] }; 1287 }) 1288 }; 1289 } 1290 case ActionTypes.DUPLICATE_PATTERN: { 1291 const { trackId } = action.payload; 1292 return { 1293 ...state, 1294 tracks: state.tracks.map((t) => { 1295 if (t.id !== trackId) return t; 1296 const offset = state.totalSteps; 1297 const duplicatedNotes = t.notes.map((note) => ({ 1298 ...note, 1299 id: generateNoteId(), 1300 step: note.step + offset 1301 })); 1302 return { 1303 ...t, 1304 notes: [...t.notes, ...duplicatedNotes] 1305 }; 1306 }), 1307 totalSteps: state.totalSteps * 2, 1308 loopEnd: state.loopEnd * 2 1309 }; 1310 } 1311 case ActionTypes.LOAD_PROJECT: 1312 return { ...action.payload, audioInitialized: state.audioInitialized }; 1313 case ActionTypes.NEW_PROJECT: 1314 return { ...initialState, audioInitialized: state.audioInitialized }; 1315 case ActionTypes.SET_PROJECT_NAME: 1316 return { ...state, projectName: action.payload }; 1317 case ActionTypes.SET_SELECTED_PITCH: 1318 return { ...state, selectedPitch: action.payload }; 1319 case ActionTypes.PREPARE_PATTERN_LOAD: 1320 return { ...state, isPlaying: false, currentStep: 0 }; 1321 case ActionTypes.LOAD_PATTERN: { 1322 const { pattern, mode = "replace" } = action.payload; 1323 const processedTracks = (pattern.data?.tracks || []).map((track) => { 1324 const newTrackId = generateTrackId(); 1325 const mergedEffects = { ...DEFAULT_TRACK_EFFECTS }; 1326 if (track.effects) {
1327 Object.keys(track.effects).forEach((effectType) => { 1328 if (mergedEffects[effectType]) { 1329 mergedEffects[effectType] = { 1330 ...mergedEffects[effectType], 1331 ...track.effects[effectType] 1332 }; 1333 } 1334 }); 1335 } 1336 return { 1337 ...track, 1338 id: newTrackId, 1339 effects: mergedEffects, 1340 notes: (track.notes || []).map((note) => ({ 1341 ...note, 1342 id: generateNoteId() 1343 })) 1344 }; 1345 }); 1346 if (mode === "merge") { 1347 return { 1348 ...state, 1349 tracks: [...state.tracks, ...processedTracks], 1350 currentPatternId: pattern.id 1351 }; 1352 } 1353 return { 1354 ...state, 1355 bpm: pattern.bpm || state.bpm, 1356 totalSteps: pattern.total_steps || pattern.totalSteps || state.totalSteps, 1357 stepsPerMeasure: pattern.steps_per_measure || pattern.stepsPerMeasure || state.stepsPerMeasure, 1358 loopEnd: pattern.total_steps || pattern.totalSteps || state.loopEnd, 1359 tracks: processedTracks.length > 0 ? processedTracks : state.tracks, 1360 selectedTrackId: processedTracks[0]?.id || state.selectedTrackId, 1361 currentPatternId: pattern.id || null, 1362 projectName: pattern.name || state.projectName 1363 }; 1364 } 1365 case ActionTypes.SET_CURRENT_PATTERN_ID: 1366 return { ...state, currentPatternId: action.payload }; 1367 default: 1368 return state; 1369 } 1370} 1371
1372// app/javascript/components/daw/context/DAWContext.jsx 1373var DAWContext = (0, import_react.createContext)(null); 1374function DAWProvider({ children }) { 1375 const [state, dispatch] = (0, import_react.useReducer)(dawReducer, initialState); 1376 const actions = { 1377 setPlaying: (0, import_react.useCallback)((isPlaying) => { 1378 dispatch({ type: ActionTypes.SET_PLAYING, payload: isPlaying }); 1379 }, []), 1380 setAudioInitialized: (0, import_react.useCallback)((initialized) => { 1381 dispatch({ type: ActionTypes.SET_AUDIO_INITIALIZED, payload: initialized }); 1382 }, []), 1383 setBPM: (0, import_react.useCallback)((bpm) => { 1384 dispatch({ type: ActionTypes.SET_BPM, payload: bpm }); 1385 }, []), 1386 setCurrentStep: (0, import_react.useCallback)((step) => { 1387 dispatch({ type: ActionTypes.SET_CURRENT_STEP, payload: step }); 1388 }, []), 1389 setLoop: (0, import_react.useCallback)((enabled) => { 1390 dispatch({ type: ActionTypes.SET_LOOP, payload: enabled }); 1391 }, []), 1392 setLoopPoints: (0, import_react.useCallback)((start2, end) => { 1393 dispatch({ type: ActionTypes.SET_LOOP_POINTS, payload: { start: start2, end } }); 1394 }, []), 1395 setTotalSteps: (0, import_react.useCallback)((steps) => { 1396 dispatch({ type: ActionTypes.SET_TOTAL_STEPS, payload: steps }); 1397 }, []), 1398 setMasterVolume: (0, import_react.useCallback)((volume) => { 1399 dispatch({ type: ActionTypes.SET_MASTER_VOLUME, payload: volume }); 1400 }, []), 1401 addTrack: (0, import_react.useCallback)((type = "synth") => { 1402 let track; 1403 switch (type) { 1404 case "drums": 1405 track = createDefaultDrumTrack(); 1406 break; 1407 case "pluck": 1408 track = createPluckTrack(); 1409 break; 1410 case "fm": 1411 track = createFMTrack(); 1412 break; 1413 case "am": 1414 track = createAMTrack(); 1415 break; 1416 default: 1417 track = createDefaultSynthTrack(); 1418 } 1419 dispatch({ type: ActionTypes.ADD_TRACK, payload: track }); 1420 return track.id; 1421 }, []), 1422 addAudioTrack: (0, import_react.useCallback)((name, audioData) => { 1423 const track = createAudioTrack(name, audioData); 1424 dispatch({ type: ActionTypes.ADD_TRACK, payload: track }); 1425 return track.id; 1426 }, []), 1427 removeTrack: (0, import_react.useCallback)((trackId) => { 1428 dispatch({ type: ActionTypes.REMOVE_TRACK, payload: trackId }); 1429 }, []), 1430 updateTrack: (0, import_react.useCallback)((trackId, updates) => { 1431 dispatch({ type: ActionTypes.UPDATE_TRACK, payload: { id: trackId, updates } }); 1432 }, []), 1433 updateTrackEffects: (0, import_react.useCallback)((trackId, effectType, settings) => { 1434 dispatch({ type: ActionTypes.UPDATE_TRACK_EFFECTS, payload: { trackId, effectType, settings } }); 1435 }, []), 1436 selectTrack: (0, import_react.useCallback)((trackId) => { 1437 dispatch({ type: ActionTypes.SELECT_TRACK, payload: trackId }); 1438 }, []), 1439 addNote: (0, import_react.useCallback)((trackId, note) => { 1440 dispatch({ type: ActionTypes.ADD_NOTE, payload: { trackId, note: { ...note, id: generateNoteId() } } }); 1441 }, []), 1442 removeNote: (0, import_react.useCallback)((trackId, noteId) => { 1443 dispatch({ type: ActionTypes.REMOVE_NOTE, payload: { trackId, noteId } }); 1444 }, []), 1445 updateNote: (0, import_react.useCallback)((trackId, noteId, updates) => { 1446 dispatch({ type: ActionTypes.UPDATE_NOTE, payload: { trackId, noteId, updates } }); 1447 }, []), 1448 clearPattern: (0, import_react.useCallback)((trackId) => { 1449 dispatch({ type: ActionTypes.CLEAR_PATTERN, payload: { trackId } }); 1450 }, []), 1451 fillPattern: (0, import_react.useCallback)((trackId, fillType, pitch = 60) => { 1452 dispatch({ type: ActionTypes.FILL_PATTERN, payload: { trackId, fillType, pitch } }); 1453 }, []), 1454 duplicatePattern: (0, import_react.useCallback)((trackId) => { 1455 dispatch({ type: ActionTypes.DUPLICATE_PATTERN, payload: { trackId } }); 1456 }, []), 1457 loadProject: (0, import_react.useCallback)((projectState) => { 1458 dispatch({ type: ActionTypes.LOAD_PROJECT, payload: projectState }); 1459 }, []), 1460 newProject: (0, import_react.useCallback)(() => { 1461 dispatch({ type: ActionTypes.NEW_PROJECT }); 1462 }, []), 1463 setProjectName: (0, import_react.useCallback)((name) => { 1464 dispatch({ type: ActionTypes.SET_PROJECT_NAME, payload: name }); 1465 }, []), 1466 setSelectedPitch: (0, import_react.useCallback)((pitch) => { 1467 dispatch({ type: ActionTypes.SET_SELECTED_PITCH, payload: pitch }); 1468 }, []), 1469 preparePatternLoad: (0, import_react.useCallback)(() => { 1470 dispatch({ type: ActionTypes.PREPARE_PATTERN_LOAD }); 1471 }, []), 1472 loadPattern: (0, import_react.useCallback)((pattern, mode = "replace") => { 1473 dispatch({ type: ActionTypes.LOAD_PATTERN, payload: { pattern, mode } }); 1474 }, []), 1475 setCurrentPatternId: (0, import_react.useCallback)((patternId) => { 1476 dispatch({ type: ActionTypes.SET_CURRENT_PATTERN_ID, payload: patternId }); 1477 }, []) 1478 }; 1479 const getSelectedTrack = (0, import_react.useCallback)(() => { 1480 return state.tracks.find((t) => t.id === state.selectedTrackId) || state.tracks[0]; 1481 }, [state.tracks, state.selectedTrackId]); 1482 return /* @__PURE__ */ import_react.default.createElement(DAWContext.Provider, { value: { state, actions, getSelectedTrack } }, children); 1483} 1484function useDAW() { 1485 const context2 = (0, import_react.useContext)(DAWContext); 1486 if (!context2) { 1487 throw new Error("useDAW must be used within a DAWProvider"); 1488 } 1489 return context2; 1490} 1491
vendor: 68 bytes, lines 1492-1494
1492// node_modules/tone/build/esm/version.js 1493var version = "15.1.22"; 1494
vendor: 126 bytes, lines 1495-1497
1495// node_modules/standardized-audio-context/build/es2019/module.js 1496var import_automation_events2 = __toESM(require_bundle()); 1497
vendor: 147 bytes, lines 1498-1500
1498// node_modules/standardized-audio-context/build/es2019/factories/abort-error.js 1499var createAbortError = () => new DOMException("", "AbortError"); 1500
vendor: 482 bytes, lines 1501-1507
1501// node_modules/standardized-audio-context/build/es2019/factories/add-active-input-connection-to-audio-node.js 1502var createAddActiveInputConnectionToAudioNode = (insertElementInSet2) => { 1503 return (activeInputs, source, [output, input, eventListener], ignoreDuplicates) => { 1504 insertElementInSet2(activeInputs[input], [source, output, eventListener], (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output, ignoreDuplicates); 1505 }; 1506}; 1507
vendor: 592 bytes, lines 1508-1523
1508// node_modules/standardized-audio-context/build/es2019/factories/add-audio-node-connections.js 1509var createAddAudioNodeConnections = (audioNodeConnectionsStore) => { 1510 return (audioNode, audioNodeRenderer, nativeAudioNode) => { 1511 const activeInputs = []; 1512 for (let i = 0; i < nativeAudioNode.numberOfInputs; i += 1) { 1513 activeInputs.push(/* @__PURE__ */ new Set()); 1514 } 1515 audioNodeConnectionsStore.set(audioNode, { 1516 activeInputs, 1517 outputs: /* @__PURE__ */ new Set(), 1518 passiveInputs: /* @__PURE__ */ new WeakMap(), 1519 renderer: audioNodeRenderer 1520 }); 1521 }; 1522}; 1523
vendor: 393 bytes, lines 1524-1530
1524// node_modules/standardized-audio-context/build/es2019/factories/add-audio-param-connections.js 1525var createAddAudioParamConnections = (audioParamConnectionsStore) => { 1526 return (audioParam, audioParamRenderer) => { 1527 audioParamConnectionsStore.set(audioParam, { activeInputs: /* @__PURE__ */ new Set(), passiveInputs: /* @__PURE__ */ new WeakMap(), renderer: audioParamRenderer }); 1528 }; 1529}; 1530
vendor: 664 bytes, lines 1531-1542
1531// node_modules/standardized-audio-context/build/es2019/globals.js 1532var ACTIVE_AUDIO_NODE_STORE = /* @__PURE__ */ new WeakSet(); 1533var AUDIO_NODE_CONNECTIONS_STORE = /* @__PURE__ */ new WeakMap(); 1534var AUDIO_NODE_STORE = /* @__PURE__ */ new WeakMap(); 1535var AUDIO_PARAM_CONNECTIONS_STORE = /* @__PURE__ */ new WeakMap(); 1536var AUDIO_PARAM_STORE = /* @__PURE__ */ new WeakMap(); 1537var CONTEXT_STORE = /* @__PURE__ */ new WeakMap(); 1538var EVENT_LISTENERS = /* @__PURE__ */ new WeakMap(); 1539var CYCLE_COUNTERS = /* @__PURE__ */ new WeakMap(); 1540var NODE_NAME_TO_PROCESSOR_CONSTRUCTOR_MAPS = /* @__PURE__ */ new WeakMap(); 1541var NODE_TO_PROCESSOR_MAPS = /* @__PURE__ */ new WeakMap(); 1542
vendor: 317 bytes, lines 1543-1558
1543// node_modules/standardized-audio-context/build/es2019/helpers/is-constructible.js 1544var handler = { 1545 construct() { 1546 return handler; 1547 } 1548}; 1549var isConstructible = (constructible) => { 1550 try { 1551 const proxy = new Proxy(constructible, handler); 1552 new proxy(); 1553 } catch { 1554 return false; 1555 } 1556 return true; 1557}; 1558
vendor: 1,136 bytes, lines 1559-1574
1559// node_modules/standardized-audio-context/build/es2019/helpers/split-import-statements.js 1560var IMPORT_STATEMENT_REGEX = /^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/; 1561var splitImportStatements = (source, url) => { 1562 const importStatements = []; 1563 let sourceWithoutImportStatements = source.replace(/^[\s]+/, ""); 1564 let result = sourceWithoutImportStatements.match(IMPORT_STATEMENT_REGEX); 1565 while (result !== null) { 1566 const unresolvedUrl = result[1].slice(1, -1); 1567 const importStatementWithResolvedUrl = result[0].replace(/([\s]+)?;?$/, "").replace(unresolvedUrl, new URL(unresolvedUrl, url).toString()); 1568 importStatements.push(importStatementWithResolvedUrl); 1569 sourceWithoutImportStatements = sourceWithoutImportStatements.slice(result[0].length).replace(/^[\s]+/, ""); 1570 result = sourceWithoutImportStatements.match(IMPORT_STATEMENT_REGEX); 1571 } 1572 return [importStatements.join(";"), sourceWithoutImportStatements]; 1573}; 1574
vendor: 6,595 bytes, lines 1575-1685
1575// node_modules/standardized-audio-context/build/es2019/factories/add-audio-worklet-module.js 1576var verifyParameterDescriptors = (parameterDescriptors) => { 1577 if (parameterDescriptors !== void 0 && !Array.isArray(parameterDescriptors)) { 1578 throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array."); 1579 } 1580}; 1581var verifyProcessorCtor = (processorCtor) => { 1582 if (!isConstructible(processorCtor)) { 1583 throw new TypeError("The given value for processorCtor should be a constructor."); 1584 } 1585 if (processorCtor.prototype === null || typeof processorCtor.prototype !== "object") { 1586 throw new TypeError("The given value for processorCtor should have a prototype."); 1587 } 1588}; 1589var createAddAudioWorkletModule = (cacheTestResult2, createNotSupportedError2, evaluateSource, exposeCurrentFrameAndCurrentTime2, fetchSource, getNativeContext2, getOrCreateBackupOfflineAudioContext2, isNativeOfflineAudioContext2, nativeAudioWorkletNodeConstructor2, ongoingRequests, resolvedRequests, testAudioWorkletProcessorPostMessageSupport, window3) => { 1590 let index = 0; 1591 return (context2, moduleURL, options = { credentials: "omit" }) => { 1592 const resolvedRequestsOfContext = resolvedRequests.get(context2); 1593 if (resolvedRequestsOfContext !== void 0 && resolvedRequestsOfContext.has(moduleURL)) { 1594 return Promise.resolve(); 1595 } 1596 const ongoingRequestsOfContext = ongoingRequests.get(context2); 1597 if (ongoingRequestsOfContext !== void 0) { 1598 const promiseOfOngoingRequest = ongoingRequestsOfContext.get(moduleURL); 1599 if (promiseOfOngoingRequest !== void 0) { 1600 return promiseOfOngoingRequest; 1601 } 1602 } 1603 const nativeContext = getNativeContext2(context2); 1604 const promise = nativeContext.audioWorklet === void 0 ? fetchSource(moduleURL).then(([source, absoluteUrl]) => { 1605 const [importStatements, sourceWithoutImportStatements] = splitImportStatements(source, absoluteUrl); 1606 const wrappedSource = `${importStatements};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${sourceWithoutImportStatements} 1607})})(window,'_AWGS')`; 1608 return evaluateSource(wrappedSource); 1609 }).then(() => { 1610 const evaluateAudioWorkletGlobalScope = window3._AWGS.pop(); 1611 if (evaluateAudioWorkletGlobalScope === void 0) { 1612 throw new SyntaxError(); 1613 } 1614 exposeCurrentFrameAndCurrentTime2(nativeContext.currentTime, nativeContext.sampleRate, () => evaluateAudioWorkletGlobalScope(class AudioWorkletProcessor { 1615 }, void 0, (name, processorCtor) => { 1616 if (name.trim() === "") { 1617 throw createNotSupportedError2(); 1618 } 1619 const nodeNameToProcessorConstructorMap = NODE_NAME_TO_PROCESSOR_CONSTRUCTOR_MAPS.get(nativeContext); 1620 if (nodeNameToProcessorConstructorMap !== void 0) { 1621 if (nodeNameToProcessorConstructorMap.has(name)) { 1622 throw createNotSupportedError2(); 1623 } 1624 verifyProcessorCtor(processorCtor); 1625 verifyParameterDescriptors(processorCtor.parameterDescriptors); 1626 nodeNameToProcessorConstructorMap.set(name, processorCtor); 1627 } else { 1628 verifyProcessorCtor(processorCtor); 1629 verifyParameterDescriptors(processorCtor.parameterDescriptors); 1630 NODE_NAME_TO_PROCESSOR_CONSTRUCTOR_MAPS.set(nativeContext, /* @__PURE__ */ new Map([[name, processorCtor]])); 1631 } 1632 }, nativeContext.sampleRate, void 0, void 0)); 1633 }) : Promise.all([ 1634 fetchSource(moduleURL), 1635 Promise.resolve(cacheTestResult2(testAudioWorkletProcessorPostMessageSupport, testAudioWorkletProcessorPostMessageSupport)) 1636 ]).then(([[source, absoluteUrl], isSupportingPostMessage]) => { 1637 const currentIndex = index + 1; 1638 index = currentIndex; 1639 const [importStatements, sourceWithoutImportStatements] = splitImportStatements(source, absoluteUrl); 1640 const patchedAudioWorkletProcessor = isSupportingPostMessage ? "AudioWorkletProcessor" : "class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"; 1641 const memberDefinition = isSupportingPostMessage ? "" : "__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"; 1642 const bufferRegistration = isSupportingPostMessage ? "" : "i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"; 1643 const wrappedSource = `${importStatements};((AudioWorkletProcessor,registerProcessor)=>{${sourceWithoutImportStatements} 1644})(${patchedAudioWorkletProcessor},(n,p)=>registerProcessor(n,class extends p{${memberDefinition}process(i,o,p){${bufferRegistration}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${currentIndex}',class extends AudioWorkletProcessor{process(){return !1}})`; 1645 const blob = new Blob([wrappedSource], { type: "application/javascript; charset=utf-8" }); 1646 const url = URL.createObjectURL(blob); 1647 return nativeContext.audioWorklet.addModule(url, options).then(() => { 1648 if (isNativeOfflineAudioContext2(nativeContext)) { 1649 return nativeContext; 1650 } 1651 const backupOfflineAudioContext = getOrCreateBackupOfflineAudioContext2(nativeContext); 1652 return backupOfflineAudioContext.audioWorklet.addModule(url, options).then(() => backupOfflineAudioContext); 1653 }).then((nativeContextOrBackupOfflineAudioContext) => { 1654 if (nativeAudioWorkletNodeConstructor2 === null) { 1655 throw new SyntaxError(); 1656 } 1657 try { 1658 new nativeAudioWorkletNodeConstructor2(nativeContextOrBackupOfflineAudioContext, `__sac${currentIndex}`); 1659 } catch { 1660 throw new SyntaxError(); 1661 } 1662 }).finally(() => URL.revokeObjectURL(url)); 1663 }); 1664 if (ongoingRequestsOfContext === void 0) { 1665 ongoingRequests.set(context2, /* @__PURE__ */ new Map([[moduleURL, promise]])); 1666 } else { 1667 ongoingRequestsOfContext.set(moduleURL, promise); 1668 } 1669 promise.then(() => { 1670 const updatedResolvedRequestsOfContext = resolvedRequests.get(context2); 1671 if (updatedResolvedRequestsOfContext === void 0) { 1672 resolvedRequests.set(context2, /* @__PURE__ */ new Set([moduleURL])); 1673 } else { 1674 updatedResolvedRequestsOfContext.add(moduleURL); 1675 } 1676 }).finally(() => { 1677 const updatedOngoingRequestsOfContext = ongoingRequests.get(context2); 1678 if (updatedOngoingRequestsOfContext !== void 0) { 1679 updatedOngoingRequestsOfContext.delete(moduleURL); 1680 } 1681 }); 1682 return promise; 1683 }; 1684}; 1685
vendor: 273 bytes, lines 1686-1694
1686// node_modules/standardized-audio-context/build/es2019/helpers/get-value-for-key.js 1687var getValueForKey = (map, key) => { 1688 const value = map.get(key); 1689 if (value === void 0) { 1690 throw new Error("A value with the given key could not be found."); 1691 } 1692 return value; 1693}; 1694
vendor: 484 bytes, lines 1695-1708
1695// node_modules/standardized-audio-context/build/es2019/helpers/pick-element-from-set.js 1696var pickElementFromSet = (set, predicate) => { 1697 const matchingElements = Array.from(set).filter(predicate); 1698 if (matchingElements.length > 1) { 1699 throw Error("More than one element was found."); 1700 } 1701 if (matchingElements.length === 0) { 1702 throw Error("No element was found."); 1703 } 1704 const [matchingElement] = matchingElements; 1705 set.delete(matchingElement); 1706 return matchingElement; 1707}; 1708
vendor: 570 bytes, lines 1709-1718
1709// node_modules/standardized-audio-context/build/es2019/helpers/delete-passive-input-connection-to-audio-node.js 1710var deletePassiveInputConnectionToAudioNode = (passiveInputs, source, output, input) => { 1711 const passiveInputConnections = getValueForKey(passiveInputs, source); 1712 const matchingConnection = pickElementFromSet(passiveInputConnections, (passiveInputConnection) => passiveInputConnection[0] === output && passiveInputConnection[1] === input); 1713 if (passiveInputConnections.size === 0) { 1714 passiveInputs.delete(source); 1715 } 1716 return matchingConnection; 1717}; 1718
vendor: 210 bytes, lines 1719-1723
1719// node_modules/standardized-audio-context/build/es2019/helpers/get-event-listeners-of-audio-node.js 1720var getEventListenersOfAudioNode = (audioNode) => { 1721 return getValueForKey(EVENT_LISTENERS, audioNode); 1722}; 1723
vendor: 390 bytes, lines 1724-1732
1724// node_modules/standardized-audio-context/build/es2019/helpers/set-internal-state-to-active.js 1725var setInternalStateToActive = (audioNode) => { 1726 if (ACTIVE_AUDIO_NODE_STORE.has(audioNode)) { 1727 throw new Error("The AudioNode is already stored."); 1728 } 1729 ACTIVE_AUDIO_NODE_STORE.add(audioNode); 1730 getEventListenersOfAudioNode(audioNode).forEach((eventListener) => eventListener(true)); 1731}; 1732
vendor: 161 bytes, lines 1733-1737
1733// node_modules/standardized-audio-context/build/es2019/guards/audio-worklet-node.js 1734var isAudioWorkletNode = (audioNode) => { 1735 return "port" in audioNode; 1736}; 1737
vendor: 393 bytes, lines 1738-1746
1738// node_modules/standardized-audio-context/build/es2019/helpers/set-internal-state-to-passive.js 1739var setInternalStateToPassive = (audioNode) => { 1740 if (!ACTIVE_AUDIO_NODE_STORE.has(audioNode)) { 1741 throw new Error("The AudioNode is not stored."); 1742 } 1743 ACTIVE_AUDIO_NODE_STORE.delete(audioNode); 1744 getEventListenersOfAudioNode(audioNode).forEach((eventListener) => eventListener(false)); 1745}; 1746
vendor: 341 bytes, lines 1747-1753
1747// node_modules/standardized-audio-context/build/es2019/helpers/set-internal-state-to-passive-when-necessary.js 1748var setInternalStateToPassiveWhenNecessary = (audioNode, activeInputs) => { 1749 if (!isAudioWorkletNode(audioNode) && activeInputs.every((connections) => connections.size === 0)) { 1750 setInternalStateToPassive(audioNode); 1751 } 1752}; 1753
vendor: 3,229 bytes, lines 1754-1809
1754// node_modules/standardized-audio-context/build/es2019/factories/add-connection-to-audio-node.js 1755var createAddConnectionToAudioNode = (addActiveInputConnectionToAudioNode2, addPassiveInputConnectionToAudioNode2, connectNativeAudioNodeToNativeAudioNode2, deleteActiveInputConnectionToAudioNode2, disconnectNativeAudioNodeFromNativeAudioNode2, getAudioNodeConnections2, getAudioNodeTailTime2, getEventListenersOfAudioNode2, getNativeAudioNode2, insertElementInSet2, isActiveAudioNode2, isPartOfACycle2, isPassiveAudioNode2) => { 1756 const tailTimeTimeoutIds = /* @__PURE__ */ new WeakMap(); 1757 return (source, destination, output, input, isOffline) => { 1758 const { activeInputs, passiveInputs } = getAudioNodeConnections2(destination); 1759 const { outputs } = getAudioNodeConnections2(source); 1760 const eventListeners = getEventListenersOfAudioNode2(source); 1761 const eventListener = (isActive) => { 1762 const nativeDestinationAudioNode = getNativeAudioNode2(destination); 1763 const nativeSourceAudioNode = getNativeAudioNode2(source); 1764 if (isActive) { 1765 const partialConnection = deletePassiveInputConnectionToAudioNode(passiveInputs, source, output, input); 1766 addActiveInputConnectionToAudioNode2(activeInputs, source, partialConnection, false); 1767 if (!isOffline && !isPartOfACycle2(source)) { 1768 connectNativeAudioNodeToNativeAudioNode2(nativeSourceAudioNode, nativeDestinationAudioNode, output, input); 1769 } 1770 if (isPassiveAudioNode2(destination)) { 1771 setInternalStateToActive(destination); 1772 } 1773 } else { 1774 const partialConnection = deleteActiveInputConnectionToAudioNode2(activeInputs, source, output, input); 1775 addPassiveInputConnectionToAudioNode2(passiveInputs, input, partialConnection, false); 1776 if (!isOffline && !isPartOfACycle2(source)) { 1777 disconnectNativeAudioNodeFromNativeAudioNode2(nativeSourceAudioNode, nativeDestinationAudioNode, output, input); 1778 } 1779 const tailTime = getAudioNodeTailTime2(destination); 1780 if (tailTime === 0) { 1781 if (isActiveAudioNode2(destination)) { 1782 setInternalStateToPassiveWhenNecessary(destination, activeInputs); 1783 } 1784 } else { 1785 const tailTimeTimeoutId = tailTimeTimeoutIds.get(destination); 1786 if (tailTimeTimeoutId !== void 0) { 1787 clearTimeout(tailTimeTimeoutId); 1788 } 1789 tailTimeTimeoutIds.set(destination, setTimeout(() => { 1790 if (isActiveAudioNode2(destination)) { 1791 setInternalStateToPassiveWhenNecessary(destination, activeInputs); 1792 } 1793 }, tailTime * 1e3)); 1794 } 1795 } 1796 }; 1797 if (insertElementInSet2(outputs, [destination, output, input], (outputConnection) => outputConnection[0] === destination && outputConnection[1] === output && outputConnection[2] === input, true)) { 1798 eventListeners.add(eventListener); 1799 if (isActiveAudioNode2(source)) { 1800 addActiveInputConnectionToAudioNode2(activeInputs, source, [output, input, eventListener], true); 1801 } else { 1802 addPassiveInputConnectionToAudioNode2(passiveInputs, input, [source, output, eventListener], true); 1803 } 1804 return true; 1805 } 1806 return false; 1807 }; 1808}; 1809
vendor: 712 bytes, lines 1810-1821
1810// node_modules/standardized-audio-context/build/es2019/factories/add-passive-input-connection-to-audio-node.js 1811var createAddPassiveInputConnectionToAudioNode = (insertElementInSet2) => { 1812 return (passiveInputs, input, [source, output, eventListener], ignoreDuplicates) => { 1813 const passiveInputConnections = passiveInputs.get(source); 1814 if (passiveInputConnections === void 0) { 1815 passiveInputs.set(source, /* @__PURE__ */ new Set([[output, input, eventListener]])); 1816 } else { 1817 insertElementInSet2(passiveInputConnections, [output, input, eventListener], (passiveInputConnection) => passiveInputConnection[0] === output && passiveInputConnection[1] === input, ignoreDuplicates); 1818 } 1819 }; 1820}; 1821
vendor: 800 bytes, lines 1822-1840
1822// node_modules/standardized-audio-context/build/es2019/factories/add-silent-connection.js 1823var createAddSilentConnection = (createNativeGainNode2) => { 1824 return (nativeContext, nativeAudioScheduledSourceNode) => { 1825 const nativeGainNode = createNativeGainNode2(nativeContext, { 1826 channelCount: 1, 1827 channelCountMode: "explicit", 1828 channelInterpretation: "discrete", 1829 gain: 0 1830 }); 1831 nativeAudioScheduledSourceNode.connect(nativeGainNode).connect(nativeContext.destination); 1832 const disconnect2 = () => { 1833 nativeAudioScheduledSourceNode.removeEventListener("ended", disconnect2); 1834 nativeAudioScheduledSourceNode.disconnect(nativeGainNode); 1835 nativeGainNode.disconnect(); 1836 }; 1837 nativeAudioScheduledSourceNode.addEventListener("ended", disconnect2); 1838 }; 1839}; 1840
vendor: 315 bytes, lines 1841-1847
1841// node_modules/standardized-audio-context/build/es2019/factories/add-unrendered-audio-worklet-node.js 1842var createAddUnrenderedAudioWorkletNode = (getUnrenderedAudioWorkletNodes2) => { 1843 return (nativeContext, audioWorkletNode) => { 1844 getUnrenderedAudioWorkletNodes2(nativeContext).add(audioWorkletNode); 1845 }; 1846}; 1847
vendor: 2,713 bytes, lines 1848-1919
1848// node_modules/standardized-audio-context/build/es2019/factories/analyser-node-constructor.js 1849var DEFAULT_OPTIONS = { 1850 channelCount: 2, 1851 channelCountMode: "max", 1852 channelInterpretation: "speakers", 1853 fftSize: 2048, 1854 maxDecibels: -30, 1855 minDecibels: -100, 1856 smoothingTimeConstant: 0.8 1857}; 1858var createAnalyserNodeConstructor = (audionNodeConstructor, createAnalyserNodeRenderer2, createIndexSizeError2, createNativeAnalyserNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 1859 return class AnalyserNode extends audionNodeConstructor { 1860 constructor(context2, options) { 1861 const nativeContext = getNativeContext2(context2); 1862 const mergedOptions = { ...DEFAULT_OPTIONS, ...options }; 1863 const nativeAnalyserNode = createNativeAnalyserNode2(nativeContext, mergedOptions); 1864 const analyserNodeRenderer = isNativeOfflineAudioContext2(nativeContext) ? createAnalyserNodeRenderer2() : null; 1865 super(context2, false, nativeAnalyserNode, analyserNodeRenderer); 1866 this._nativeAnalyserNode = nativeAnalyserNode; 1867 } 1868 get fftSize() { 1869 return this._nativeAnalyserNode.fftSize; 1870 } 1871 set fftSize(value) { 1872 this._nativeAnalyserNode.fftSize = value; 1873 } 1874 get frequencyBinCount() { 1875 return this._nativeAnalyserNode.frequencyBinCount; 1876 } 1877 get maxDecibels() { 1878 return this._nativeAnalyserNode.maxDecibels; 1879 } 1880 set maxDecibels(value) { 1881 const maxDecibels = this._nativeAnalyserNode.maxDecibels; 1882 this._nativeAnalyserNode.maxDecibels = value; 1883 if (!(value > this._nativeAnalyserNode.minDecibels)) { 1884 this._nativeAnalyserNode.maxDecibels = maxDecibels; 1885 throw createIndexSizeError2(); 1886 } 1887 } 1888 get minDecibels() { 1889 return this._nativeAnalyserNode.minDecibels; 1890 } 1891 set minDecibels(value) { 1892 const minDecibels = this._nativeAnalyserNode.minDecibels; 1893 this._nativeAnalyserNode.minDecibels = value; 1894 if (!(this._nativeAnalyserNode.maxDecibels > value)) { 1895 this._nativeAnalyserNode.minDecibels = minDecibels; 1896 throw createIndexSizeError2(); 1897 } 1898 } 1899 get smoothingTimeConstant() { 1900 return this._nativeAnalyserNode.smoothingTimeConstant; 1901 } 1902 set smoothingTimeConstant(value) { 1903 this._nativeAnalyserNode.smoothingTimeConstant = value; 1904 } 1905 getByteFrequencyData(array) { 1906 this._nativeAnalyserNode.getByteFrequencyData(array); 1907 } 1908 getByteTimeDomainData(array) { 1909 this._nativeAnalyserNode.getByteTimeDomainData(array); 1910 } 1911 getFloatFrequencyData(array) { 1912 this._nativeAnalyserNode.getFloatFrequencyData(array); 1913 } 1914 getFloatTimeDomainData(array) { 1915 this._nativeAnalyserNode.getFloatTimeDomainData(array); 1916 } 1917 }; 1918}; 1919
vendor: 204 bytes, lines 1920-1924
1920// node_modules/standardized-audio-context/build/es2019/helpers/is-owned-by-context.js 1921var isOwnedByContext = (nativeAudioNode, nativeContext) => { 1922 return nativeAudioNode.context === nativeContext; 1923}; 1924
vendor: 1,773 bytes, lines 1925-1959
1925// node_modules/standardized-audio-context/build/es2019/factories/analyser-node-renderer-factory.js 1926var createAnalyserNodeRendererFactory = (createNativeAnalyserNode2, getNativeAudioNode2, renderInputsOfAudioNode2) => { 1927 return () => { 1928 const renderedNativeAnalyserNodes = /* @__PURE__ */ new WeakMap(); 1929 const createAnalyserNode = async (proxy, nativeOfflineAudioContext) => { 1930 let nativeAnalyserNode = getNativeAudioNode2(proxy); 1931 const nativeAnalyserNodeIsOwnedByContext = isOwnedByContext(nativeAnalyserNode, nativeOfflineAudioContext); 1932 if (!nativeAnalyserNodeIsOwnedByContext) { 1933 const options = { 1934 channelCount: nativeAnalyserNode.channelCount, 1935 channelCountMode: nativeAnalyserNode.channelCountMode, 1936 channelInterpretation: nativeAnalyserNode.channelInterpretation, 1937 fftSize: nativeAnalyserNode.fftSize, 1938 maxDecibels: nativeAnalyserNode.maxDecibels, 1939 minDecibels: nativeAnalyserNode.minDecibels, 1940 smoothingTimeConstant: nativeAnalyserNode.smoothingTimeConstant 1941 }; 1942 nativeAnalyserNode = createNativeAnalyserNode2(nativeOfflineAudioContext, options); 1943 } 1944 renderedNativeAnalyserNodes.set(nativeOfflineAudioContext, nativeAnalyserNode); 1945 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAnalyserNode); 1946 return nativeAnalyserNode; 1947 }; 1948 return { 1949 render(proxy, nativeOfflineAudioContext) { 1950 const renderedNativeAnalyserNode = renderedNativeAnalyserNodes.get(nativeOfflineAudioContext); 1951 if (renderedNativeAnalyserNode !== void 0) { 1952 return Promise.resolve(renderedNativeAnalyserNode); 1953 } 1954 return createAnalyserNode(proxy, nativeOfflineAudioContext); 1955 } 1956 }; 1957 }; 1958}; 1959
vendor: 337 bytes, lines 1960-1969
1960// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-buffer-copy-channel-methods-out-of-bounds-support.js 1961var testAudioBufferCopyChannelMethodsOutOfBoundsSupport = (nativeAudioBuffer) => { 1962 try { 1963 nativeAudioBuffer.copyToChannel(new Float32Array(1), 0, -1); 1964 } catch { 1965 return false; 1966 } 1967 return true; 1968}; 1969
vendor: 160 bytes, lines 1970-1972
1970// node_modules/standardized-audio-context/build/es2019/factories/index-size-error.js 1971var createIndexSizeError = () => new DOMException("", "IndexSizeError"); 1972
vendor: 511 bytes, lines 1973-1988
1973// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-buffer-get-channel-data-method.js 1974var wrapAudioBufferGetChannelDataMethod = (audioBuffer) => { 1975 audioBuffer.getChannelData = /* @__PURE__ */ ((getChannelData) => { 1976 return (channel) => { 1977 try { 1978 return getChannelData.call(audioBuffer, channel); 1979 } catch (err) { 1980 if (err.code === 12) { 1981 throw createIndexSizeError(); 1982 } 1983 throw err; 1984 } 1985 }; 1986 })(audioBuffer.getChannelData); 1987}; 1988
vendor: 2,059 bytes, lines 1989-2022
1989// node_modules/standardized-audio-context/build/es2019/factories/audio-buffer-constructor.js 1990var DEFAULT_OPTIONS2 = { 1991 numberOfChannels: 1 1992}; 1993var createAudioBufferConstructor = (audioBufferStore2, cacheTestResult2, createNotSupportedError2, nativeAudioBufferConstructor2, nativeOfflineAudioContextConstructor2, testNativeAudioBufferConstructorSupport, wrapAudioBufferCopyChannelMethods2, wrapAudioBufferCopyChannelMethodsOutOfBounds2) => { 1994 let nativeOfflineAudioContext = null; 1995 return class AudioBuffer { 1996 constructor(options) { 1997 if (nativeOfflineAudioContextConstructor2 === null) { 1998 throw new Error("Missing the native OfflineAudioContext constructor."); 1999 } 2000 const { length, numberOfChannels, sampleRate } = { ...DEFAULT_OPTIONS2, ...options }; 2001 if (nativeOfflineAudioContext === null) { 2002 nativeOfflineAudioContext = new nativeOfflineAudioContextConstructor2(1, 1, 44100); 2003 } 2004 const audioBuffer = nativeAudioBufferConstructor2 !== null && cacheTestResult2(testNativeAudioBufferConstructorSupport, testNativeAudioBufferConstructorSupport) ? new nativeAudioBufferConstructor2({ length, numberOfChannels, sampleRate }) : nativeOfflineAudioContext.createBuffer(numberOfChannels, length, sampleRate); 2005 if (audioBuffer.numberOfChannels === 0) { 2006 throw createNotSupportedError2(); 2007 } 2008 if (typeof audioBuffer.copyFromChannel !== "function") { 2009 wrapAudioBufferCopyChannelMethods2(audioBuffer); 2010 wrapAudioBufferGetChannelDataMethod(audioBuffer); 2011 } else if (!cacheTestResult2(testAudioBufferCopyChannelMethodsOutOfBoundsSupport, () => testAudioBufferCopyChannelMethodsOutOfBoundsSupport(audioBuffer))) { 2012 wrapAudioBufferCopyChannelMethodsOutOfBounds2(audioBuffer); 2013 } 2014 audioBufferStore2.add(audioBuffer); 2015 return audioBuffer; 2016 } 2017 static [Symbol.hasInstance](instance) { 2018 return instance !== null && typeof instance === "object" && Object.getPrototypeOf(instance) === AudioBuffer.prototype || audioBufferStore2.has(instance); 2019 } 2020 }; 2021}; 2022
vendor: 188 bytes, lines 2023-2026
2023// node_modules/standardized-audio-context/build/es2019/constants.js 2024var MOST_NEGATIVE_SINGLE_FLOAT = -34028234663852886e22; 2025var MOST_POSITIVE_SINGLE_FLOAT = -MOST_NEGATIVE_SINGLE_FLOAT; 2026
vendor: 168 bytes, lines 2027-2029
2027// node_modules/standardized-audio-context/build/es2019/helpers/is-active-audio-node.js 2028var isActiveAudioNode = (audioNode) => ACTIVE_AUDIO_NODE_STORE.has(audioNode); 2029
vendor: 4,018 bytes, lines 2030-2127
2030// node_modules/standardized-audio-context/build/es2019/factories/audio-buffer-source-node-constructor.js 2031var DEFAULT_OPTIONS3 = { 2032 buffer: null, 2033 channelCount: 2, 2034 channelCountMode: "max", 2035 channelInterpretation: "speakers", 2036 // Bug #149: Safari does not yet support the detune AudioParam. 2037 loop: false, 2038 loopEnd: 0, 2039 loopStart: 0, 2040 playbackRate: 1 2041}; 2042var createAudioBufferSourceNodeConstructor = (audioNodeConstructor2, createAudioBufferSourceNodeRenderer2, createAudioParam2, createInvalidStateError2, createNativeAudioBufferSourceNode2, getNativeContext2, isNativeOfflineAudioContext2, wrapEventListener2) => { 2043 return class AudioBufferSourceNode extends audioNodeConstructor2 { 2044 constructor(context2, options) { 2045 const nativeContext = getNativeContext2(context2); 2046 const mergedOptions = { ...DEFAULT_OPTIONS3, ...options }; 2047 const nativeAudioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeContext, mergedOptions); 2048 const isOffline = isNativeOfflineAudioContext2(nativeContext); 2049 const audioBufferSourceNodeRenderer = isOffline ? createAudioBufferSourceNodeRenderer2() : null; 2050 super(context2, false, nativeAudioBufferSourceNode, audioBufferSourceNodeRenderer); 2051 this._audioBufferSourceNodeRenderer = audioBufferSourceNodeRenderer; 2052 this._isBufferNullified = false; 2053 this._isBufferSet = mergedOptions.buffer !== null; 2054 this._nativeAudioBufferSourceNode = nativeAudioBufferSourceNode; 2055 this._onended = null; 2056 this._playbackRate = createAudioParam2(this, isOffline, nativeAudioBufferSourceNode.playbackRate, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 2057 } 2058 get buffer() { 2059 if (this._isBufferNullified) { 2060 return null; 2061 } 2062 return this._nativeAudioBufferSourceNode.buffer; 2063 } 2064 set buffer(value) { 2065 this._nativeAudioBufferSourceNode.buffer = value; 2066 if (value !== null) { 2067 if (this._isBufferSet) { 2068 throw createInvalidStateError2(); 2069 } 2070 this._isBufferSet = true; 2071 } 2072 } 2073 get loop() { 2074 return this._nativeAudioBufferSourceNode.loop; 2075 } 2076 set loop(value) { 2077 this._nativeAudioBufferSourceNode.loop = value; 2078 } 2079 get loopEnd() { 2080 return this._nativeAudioBufferSourceNode.loopEnd; 2081 } 2082 set loopEnd(value) { 2083 this._nativeAudioBufferSourceNode.loopEnd = value; 2084 } 2085 get loopStart() { 2086 return this._nativeAudioBufferSourceNode.loopStart; 2087 } 2088 set loopStart(value) { 2089 this._nativeAudioBufferSourceNode.loopStart = value; 2090 } 2091 get onended() { 2092 return this._onended; 2093 } 2094 set onended(value) { 2095 const wrappedListener = typeof value === "function" ? wrapEventListener2(this, value) : null; 2096 this._nativeAudioBufferSourceNode.onended = wrappedListener; 2097 const nativeOnEnded = this._nativeAudioBufferSourceNode.onended; 2098 this._onended = nativeOnEnded !== null && nativeOnEnded === wrappedListener ? value : nativeOnEnded; 2099 } 2100 get playbackRate() { 2101 return this._playbackRate; 2102 } 2103 start(when = 0, offset = 0, duration) { 2104 this._nativeAudioBufferSourceNode.start(when, offset, duration); 2105 if (this._audioBufferSourceNodeRenderer !== null) { 2106 this._audioBufferSourceNodeRenderer.start = duration === void 0 ? [when, offset] : [when, offset, duration]; 2107 } 2108 if (this.context.state !== "closed") { 2109 setInternalStateToActive(this); 2110 const resetInternalStateToPassive = () => { 2111 this._nativeAudioBufferSourceNode.removeEventListener("ended", resetInternalStateToPassive); 2112 if (isActiveAudioNode(this)) { 2113 setInternalStateToPassive(this); 2114 } 2115 }; 2116 this._nativeAudioBufferSourceNode.addEventListener("ended", resetInternalStateToPassive); 2117 } 2118 } 2119 stop(when = 0) { 2120 this._nativeAudioBufferSourceNode.stop(when); 2121 if (this._audioBufferSourceNodeRenderer !== null) { 2122 this._audioBufferSourceNodeRenderer.stop = when; 2123 } 2124 } 2125 }; 2126}; 2127
vendor: 2,824 bytes, lines 2128-2183
2128// node_modules/standardized-audio-context/build/es2019/factories/audio-buffer-source-node-renderer-factory.js 2129var createAudioBufferSourceNodeRendererFactory = (connectAudioParam2, createNativeAudioBufferSourceNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 2130 return () => { 2131 const renderedNativeAudioBufferSourceNodes = /* @__PURE__ */ new WeakMap(); 2132 let start2 = null; 2133 let stop = null; 2134 const createAudioBufferSourceNode = async (proxy, nativeOfflineAudioContext) => { 2135 let nativeAudioBufferSourceNode = getNativeAudioNode2(proxy); 2136 const nativeAudioBufferSourceNodeIsOwnedByContext = isOwnedByContext(nativeAudioBufferSourceNode, nativeOfflineAudioContext); 2137 if (!nativeAudioBufferSourceNodeIsOwnedByContext) { 2138 const options = { 2139 buffer: nativeAudioBufferSourceNode.buffer, 2140 channelCount: nativeAudioBufferSourceNode.channelCount, 2141 channelCountMode: nativeAudioBufferSourceNode.channelCountMode, 2142 channelInterpretation: nativeAudioBufferSourceNode.channelInterpretation, 2143 // Bug #149: Safari does not yet support the detune AudioParam. 2144 loop: nativeAudioBufferSourceNode.loop, 2145 loopEnd: nativeAudioBufferSourceNode.loopEnd, 2146 loopStart: nativeAudioBufferSourceNode.loopStart, 2147 playbackRate: nativeAudioBufferSourceNode.playbackRate.value 2148 }; 2149 nativeAudioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeOfflineAudioContext, options); 2150 if (start2 !== null) { 2151 nativeAudioBufferSourceNode.start(...start2); 2152 } 2153 if (stop !== null) { 2154 nativeAudioBufferSourceNode.stop(stop); 2155 } 2156 } 2157 renderedNativeAudioBufferSourceNodes.set(nativeOfflineAudioContext, nativeAudioBufferSourceNode); 2158 if (!nativeAudioBufferSourceNodeIsOwnedByContext) { 2159 await renderAutomation2(nativeOfflineAudioContext, proxy.playbackRate, nativeAudioBufferSourceNode.playbackRate); 2160 } else { 2161 await connectAudioParam2(nativeOfflineAudioContext, proxy.playbackRate, nativeAudioBufferSourceNode.playbackRate); 2162 } 2163 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAudioBufferSourceNode); 2164 return nativeAudioBufferSourceNode; 2165 }; 2166 return { 2167 set start(value) { 2168 start2 = value; 2169 }, 2170 set stop(value) { 2171 stop = value; 2172 }, 2173 render(proxy, nativeOfflineAudioContext) { 2174 const renderedNativeAudioBufferSourceNode = renderedNativeAudioBufferSourceNodes.get(nativeOfflineAudioContext); 2175 if (renderedNativeAudioBufferSourceNode !== void 0) { 2176 return Promise.resolve(renderedNativeAudioBufferSourceNode); 2177 } 2178 return createAudioBufferSourceNode(proxy, nativeOfflineAudioContext); 2179 } 2180 }; 2181 }; 2182}; 2183
vendor: 180 bytes, lines 2184-2188
2184// node_modules/standardized-audio-context/build/es2019/guards/audio-buffer-source-node.js 2185var isAudioBufferSourceNode = (audioNode) => { 2186 return "playbackRate" in audioNode; 2187}; 2188
vendor: 189 bytes, lines 2189-2193
2189// node_modules/standardized-audio-context/build/es2019/guards/biquad-filter-node.js 2190var isBiquadFilterNode = (audioNode) => { 2191 return "frequency" in audioNode && "gain" in audioNode; 2192}; 2193
vendor: 167 bytes, lines 2194-2198
2194// node_modules/standardized-audio-context/build/es2019/guards/constant-source-node.js 2195var isConstantSourceNode = (audioNode) => { 2196 return "offset" in audioNode; 2197}; 2198
vendor: 175 bytes, lines 2199-2203
2199// node_modules/standardized-audio-context/build/es2019/guards/gain-node.js 2200var isGainNode = (audioNode) => { 2201 return !("frequency" in audioNode) && "gain" in audioNode; 2202}; 2203
vendor: 212 bytes, lines 2204-2208
2204// node_modules/standardized-audio-context/build/es2019/guards/oscillator-node.js 2205var isOscillatorNode = (audioNode) => { 2206 return "detune" in audioNode && "frequency" in audioNode && !("gain" in audioNode); 2207}; 2208
vendor: 160 bytes, lines 2209-2213
2209// node_modules/standardized-audio-context/build/es2019/guards/stereo-panner-node.js 2210var isStereoPannerNode = (audioNode) => { 2211 return "pan" in audioNode; 2212}; 2213
vendor: 211 bytes, lines 2214-2218
2214// node_modules/standardized-audio-context/build/es2019/helpers/get-audio-node-connections.js 2215var getAudioNodeConnections = (audioNode) => { 2216 return getValueForKey(AUDIO_NODE_CONNECTIONS_STORE, audioNode); 2217}; 2218
vendor: 216 bytes, lines 2219-2223
2219// node_modules/standardized-audio-context/build/es2019/helpers/get-audio-param-connections.js 2220var getAudioParamConnections = (audioParam) => { 2221 return getValueForKey(AUDIO_PARAM_CONNECTIONS_STORE, audioParam); 2222}; 2223
vendor: 1,399 bytes, lines 2224-2246
2224// node_modules/standardized-audio-context/build/es2019/helpers/deactivate-active-audio-node-input-connections.js 2225var deactivateActiveAudioNodeInputConnections = (audioNode, trace) => { 2226 const { activeInputs } = getAudioNodeConnections(audioNode); 2227 activeInputs.forEach((connections) => connections.forEach(([source]) => { 2228 if (!trace.includes(audioNode)) { 2229 deactivateActiveAudioNodeInputConnections(source, [...trace, audioNode]); 2230 } 2231 })); 2232 const audioParams = isAudioBufferSourceNode(audioNode) ? [ 2233 // Bug #149: Safari does not yet support the detune AudioParam. 2234 audioNode.playbackRate 2235 ] : isAudioWorkletNode(audioNode) ? Array.from(audioNode.parameters.values()) : isBiquadFilterNode(audioNode) ? [audioNode.Q, audioNode.detune, audioNode.frequency, audioNode.gain] : isConstantSourceNode(audioNode) ? [audioNode.offset] : isGainNode(audioNode) ? [audioNode.gain] : isOscillatorNode(audioNode) ? [audioNode.detune, audioNode.frequency] : isStereoPannerNode(audioNode) ? [audioNode.pan] : []; 2236 for (const audioParam of audioParams) { 2237 const audioParamConnections = getAudioParamConnections(audioParam); 2238 if (audioParamConnections !== void 0) { 2239 audioParamConnections.activeInputs.forEach(([source]) => deactivateActiveAudioNodeInputConnections(source, trace)); 2240 } 2241 } 2242 if (isActiveAudioNode(audioNode)) { 2243 setInternalStateToPassive(audioNode); 2244 } 2245}; 2246
vendor: 208 bytes, lines 2247-2251
2247// node_modules/standardized-audio-context/build/es2019/helpers/deactivate-audio-graph.js 2248var deactivateAudioGraph = (context2) => { 2249 deactivateActiveAudioNodeInputConnections(context2.destination, []); 2250}; 2251
vendor: 335 bytes, lines 2252-2256
2252// node_modules/standardized-audio-context/build/es2019/helpers/is-valid-latency-hint.js 2253var isValidLatencyHint = (latencyHint) => { 2254 return latencyHint === void 0 || typeof latencyHint === "number" || typeof latencyHint === "string" && (latencyHint === "balanced" || latencyHint === "interactive" || latencyHint === "playback"); 2255}; 2256
vendor: 5,299 bytes, lines 2257-2382
2257// node_modules/standardized-audio-context/build/es2019/factories/audio-context-constructor.js 2258var createAudioContextConstructor = (baseAudioContextConstructor2, createInvalidStateError2, createNotSupportedError2, createUnknownError2, mediaElementAudioSourceNodeConstructor2, mediaStreamAudioDestinationNodeConstructor2, mediaStreamAudioSourceNodeConstructor2, mediaStreamTrackAudioSourceNodeConstructor2, nativeAudioContextConstructor2) => { 2259 return class AudioContext extends baseAudioContextConstructor2 { 2260 constructor(options = {}) { 2261 if (nativeAudioContextConstructor2 === null) { 2262 throw new Error("Missing the native AudioContext constructor."); 2263 } 2264 let nativeAudioContext; 2265 try { 2266 nativeAudioContext = new nativeAudioContextConstructor2(options); 2267 } catch (err) { 2268 if (err.code === 12 && err.message === "sampleRate is not in range") { 2269 throw createNotSupportedError2(); 2270 } 2271 throw err; 2272 } 2273 if (nativeAudioContext === null) { 2274 throw createUnknownError2(); 2275 } 2276 if (!isValidLatencyHint(options.latencyHint)) { 2277 throw new TypeError(`The provided value '${options.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`); 2278 } 2279 if (options.sampleRate !== void 0 && nativeAudioContext.sampleRate !== options.sampleRate) { 2280 throw createNotSupportedError2(); 2281 } 2282 super(nativeAudioContext, 2); 2283 const { latencyHint } = options; 2284 const { sampleRate } = nativeAudioContext; 2285 this._baseLatency = typeof nativeAudioContext.baseLatency === "number" ? nativeAudioContext.baseLatency : latencyHint === "balanced" ? 512 / sampleRate : latencyHint === "interactive" || latencyHint === void 0 ? 256 / sampleRate : latencyHint === "playback" ? 1024 / sampleRate : ( 2286 /* 2287 * @todo The min (256) and max (16384) values are taken from the allowed bufferSize values of a 2288 * ScriptProcessorNode. 2289 */ 2290 Math.max(2, Math.min(128, Math.round(latencyHint * sampleRate / 128))) * 128 / sampleRate 2291 ); 2292 this._nativeAudioContext = nativeAudioContext; 2293 if (nativeAudioContextConstructor2.name === "webkitAudioContext") { 2294 this._nativeGainNode = nativeAudioContext.createGain(); 2295 this._nativeOscillatorNode = nativeAudioContext.createOscillator(); 2296 this._nativeGainNode.gain.value = 1e-37; 2297 this._nativeOscillatorNode.connect(this._nativeGainNode).connect(nativeAudioContext.destination); 2298 this._nativeOscillatorNode.start(); 2299 } else { 2300 this._nativeGainNode = null; 2301 this._nativeOscillatorNode = null; 2302 } 2303 this._state = null; 2304 if (nativeAudioContext.state === "running") { 2305 this._state = "suspended"; 2306 const revokeState = () => { 2307 if (this._state === "suspended") { 2308 this._state = null; 2309 } 2310 nativeAudioContext.removeEventListener("statechange", revokeState); 2311 }; 2312 nativeAudioContext.addEventListener("statechange", revokeState); 2313 } 2314 } 2315 get baseLatency() { 2316 return this._baseLatency; 2317 } 2318 get state() { 2319 return this._state !== null ? this._state : this._nativeAudioContext.state; 2320 } 2321 close() { 2322 if (this.state === "closed") { 2323 return this._nativeAudioContext.close().then(() => { 2324 throw createInvalidStateError2(); 2325 }); 2326 } 2327 if (this._state === "suspended") { 2328 this._state = null; 2329 } 2330 return this._nativeAudioContext.close().then(() => { 2331 if (this._nativeGainNode !== null && this._nativeOscillatorNode !== null) { 2332 this._nativeOscillatorNode.stop(); 2333 this._nativeGainNode.disconnect(); 2334 this._nativeOscillatorNode.disconnect(); 2335 } 2336 deactivateAudioGraph(this); 2337 }); 2338 } 2339 createMediaElementSource(mediaElement) { 2340 return new mediaElementAudioSourceNodeConstructor2(this, { mediaElement }); 2341 } 2342 createMediaStreamDestination() { 2343 return new mediaStreamAudioDestinationNodeConstructor2(this); 2344 } 2345 createMediaStreamSource(mediaStream) { 2346 return new mediaStreamAudioSourceNodeConstructor2(this, { mediaStream }); 2347 } 2348 createMediaStreamTrackSource(mediaStreamTrack) { 2349 return new mediaStreamTrackAudioSourceNodeConstructor2(this, { mediaStreamTrack }); 2350 } 2351 resume() { 2352 if (this._state === "suspended") { 2353 return new Promise((resolve, reject) => { 2354 const resolvePromise = () => { 2355 this._nativeAudioContext.removeEventListener("statechange", resolvePromise); 2356 if (this._nativeAudioContext.state === "running") { 2357 resolve(); 2358 } else { 2359 this.resume().then(resolve, reject); 2360 } 2361 }; 2362 this._nativeAudioContext.addEventListener("statechange", resolvePromise); 2363 }); 2364 } 2365 return this._nativeAudioContext.resume().catch((err) => { 2366 if (err === void 0 || err.code === 15) { 2367 throw createInvalidStateError2(); 2368 } 2369 throw err; 2370 }); 2371 } 2372 suspend() { 2373 return this._nativeAudioContext.suspend().catch((err) => { 2374 if (err === void 0) { 2375 throw createInvalidStateError2(); 2376 } 2377 throw err; 2378 }); 2379 } 2380 }; 2381}; 2382
vendor: 1,891 bytes, lines 2383-2421
2383// node_modules/standardized-audio-context/build/es2019/factories/audio-destination-node-constructor.js 2384var createAudioDestinationNodeConstructor = (audioNodeConstructor2, createAudioDestinationNodeRenderer2, createIndexSizeError2, createInvalidStateError2, createNativeAudioDestinationNode, getNativeContext2, isNativeOfflineAudioContext2, renderInputsOfAudioNode2) => { 2385 return class AudioDestinationNode extends audioNodeConstructor2 { 2386 constructor(context2, channelCount) { 2387 const nativeContext = getNativeContext2(context2); 2388 const isOffline = isNativeOfflineAudioContext2(nativeContext); 2389 const nativeAudioDestinationNode = createNativeAudioDestinationNode(nativeContext, channelCount, isOffline); 2390 const audioDestinationNodeRenderer = isOffline ? createAudioDestinationNodeRenderer2(renderInputsOfAudioNode2) : null; 2391 super(context2, false, nativeAudioDestinationNode, audioDestinationNodeRenderer); 2392 this._isNodeOfNativeOfflineAudioContext = isOffline; 2393 this._nativeAudioDestinationNode = nativeAudioDestinationNode; 2394 } 2395 get channelCount() { 2396 return this._nativeAudioDestinationNode.channelCount; 2397 } 2398 set channelCount(value) { 2399 if (this._isNodeOfNativeOfflineAudioContext) { 2400 throw createInvalidStateError2(); 2401 } 2402 if (value > this._nativeAudioDestinationNode.maxChannelCount) { 2403 throw createIndexSizeError2(); 2404 } 2405 this._nativeAudioDestinationNode.channelCount = value; 2406 } 2407 get channelCountMode() { 2408 return this._nativeAudioDestinationNode.channelCountMode; 2409 } 2410 set channelCountMode(value) { 2411 if (this._isNodeOfNativeOfflineAudioContext) { 2412 throw createInvalidStateError2(); 2413 } 2414 this._nativeAudioDestinationNode.channelCountMode = value; 2415 } 2416 get maxChannelCount() { 2417 return this._nativeAudioDestinationNode.maxChannelCount; 2418 } 2419 }; 2420}; 2421
vendor: 1,062 bytes, lines 2422-2441
2422// node_modules/standardized-audio-context/build/es2019/factories/audio-destination-node-renderer-factory.js 2423var createAudioDestinationNodeRenderer = (renderInputsOfAudioNode2) => { 2424 const renderedNativeAudioDestinationNodes = /* @__PURE__ */ new WeakMap(); 2425 const createAudioDestinationNode = async (proxy, nativeOfflineAudioContext) => { 2426 const nativeAudioDestinationNode = nativeOfflineAudioContext.destination; 2427 renderedNativeAudioDestinationNodes.set(nativeOfflineAudioContext, nativeAudioDestinationNode); 2428 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAudioDestinationNode); 2429 return nativeAudioDestinationNode; 2430 }; 2431 return { 2432 render(proxy, nativeOfflineAudioContext) { 2433 const renderedNativeAudioDestinationNode = renderedNativeAudioDestinationNodes.get(nativeOfflineAudioContext); 2434 if (renderedNativeAudioDestinationNode !== void 0) { 2435 return Promise.resolve(renderedNativeAudioDestinationNode); 2436 } 2437 return createAudioDestinationNode(proxy, nativeOfflineAudioContext); 2438 } 2439 }; 2440}; 2441
vendor: 8,223 bytes, lines 2442-2659
2442// node_modules/standardized-audio-context/build/es2019/factories/audio-listener-factory.js 2443var createAudioListenerFactory = (createAudioParam2, createNativeChannelMergerNode2, createNativeConstantSourceNode2, createNativeScriptProcessorNode2, createNotSupportedError2, getFirstSample2, isNativeOfflineAudioContext2, overwriteAccessors2) => { 2444 return (context2, nativeContext) => { 2445 const nativeListener = nativeContext.listener; 2446 const createFakeAudioParams = () => { 2447 const buffer = new Float32Array(1); 2448 const channelMergerNode = createNativeChannelMergerNode2(nativeContext, { 2449 channelCount: 1, 2450 channelCountMode: "explicit", 2451 channelInterpretation: "speakers", 2452 numberOfInputs: 9 2453 }); 2454 const isOffline = isNativeOfflineAudioContext2(nativeContext); 2455 let isScriptProcessorNodeCreated = false; 2456 let lastOrientation = [0, 0, -1, 0, 1, 0]; 2457 let lastPosition = [0, 0, 0]; 2458 const createScriptProcessorNode = () => { 2459 if (isScriptProcessorNodeCreated) { 2460 return; 2461 } 2462 isScriptProcessorNodeCreated = true; 2463 const scriptProcessorNode = createNativeScriptProcessorNode2(nativeContext, 256, 9, 0); 2464 scriptProcessorNode.onaudioprocess = ({ inputBuffer }) => { 2465 const orientation = [ 2466 getFirstSample2(inputBuffer, buffer, 0), 2467 getFirstSample2(inputBuffer, buffer, 1), 2468 getFirstSample2(inputBuffer, buffer, 2), 2469 getFirstSample2(inputBuffer, buffer, 3), 2470 getFirstSample2(inputBuffer, buffer, 4), 2471 getFirstSample2(inputBuffer, buffer, 5) 2472 ]; 2473 if (orientation.some((value, index) => value !== lastOrientation[index])) { 2474 nativeListener.setOrientation(...orientation); 2475 lastOrientation = orientation; 2476 } 2477 const positon = [ 2478 getFirstSample2(inputBuffer, buffer, 6), 2479 getFirstSample2(inputBuffer, buffer, 7), 2480 getFirstSample2(inputBuffer, buffer, 8) 2481 ]; 2482 if (positon.some((value, index) => value !== lastPosition[index])) { 2483 nativeListener.setPosition(...positon); 2484 lastPosition = positon; 2485 } 2486 }; 2487 channelMergerNode.connect(scriptProcessorNode); 2488 }; 2489 const createSetOrientation = (index) => (value) => { 2490 if (value !== lastOrientation[index]) { 2491 lastOrientation[index] = value; 2492 nativeListener.setOrientation(...lastOrientation); 2493 } 2494 }; 2495 const createSetPosition = (index) => (value) => { 2496 if (value !== lastPosition[index]) { 2497 lastPosition[index] = value; 2498 nativeListener.setPosition(...lastPosition); 2499 } 2500 }; 2501 const createFakeAudioParam = (input, initialValue, setValue) => { 2502 const constantSourceNode = createNativeConstantSourceNode2(nativeContext, { 2503 channelCount: 1, 2504 channelCountMode: "explicit", 2505 channelInterpretation: "discrete", 2506 offset: initialValue 2507 }); 2508 constantSourceNode.connect(channelMergerNode, 0, input); 2509 constantSourceNode.start(); 2510 Object.defineProperty(constantSourceNode.offset, "defaultValue", { 2511 get() { 2512 return initialValue; 2513 } 2514 }); 2515 const audioParam = createAudioParam2({ context: context2 }, isOffline, constantSourceNode.offset, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 2516 overwriteAccessors2(audioParam, "value", (get) => () => get.call(audioParam), (set) => (value) => { 2517 try { 2518 set.call(audioParam, value); 2519 } catch (err) { 2520 if (err.code !== 9) { 2521 throw err; 2522 } 2523 } 2524 createScriptProcessorNode(); 2525 if (isOffline) { 2526 setValue(value); 2527 } 2528 }); 2529 audioParam.cancelAndHoldAtTime = ((cancelAndHoldAtTime) => { 2530 if (isOffline) { 2531 return () => { 2532 throw createNotSupportedError2(); 2533 }; 2534 } 2535 return (...args) => { 2536 const value = cancelAndHoldAtTime.apply(audioParam, args); 2537 createScriptProcessorNode(); 2538 return value; 2539 }; 2540 })(audioParam.cancelAndHoldAtTime); 2541 audioParam.cancelScheduledValues = ((cancelScheduledValues) => { 2542 if (isOffline) { 2543 return () => { 2544 throw createNotSupportedError2(); 2545 }; 2546 } 2547 return (...args) => { 2548 const value = cancelScheduledValues.apply(audioParam, args); 2549 createScriptProcessorNode(); 2550 return value; 2551 }; 2552 })(audioParam.cancelScheduledValues); 2553 audioParam.exponentialRampToValueAtTime = ((exponentialRampToValueAtTime) => { 2554 if (isOffline) { 2555 return () => { 2556 throw createNotSupportedError2(); 2557 }; 2558 } 2559 return (...args) => { 2560 const value = exponentialRampToValueAtTime.apply(audioParam, args); 2561 createScriptProcessorNode(); 2562 return value; 2563 }; 2564 })(audioParam.exponentialRampToValueAtTime); 2565 audioParam.linearRampToValueAtTime = ((linearRampToValueAtTime) => { 2566 if (isOffline) { 2567 return () => { 2568 throw createNotSupportedError2(); 2569 }; 2570 } 2571 return (...args) => { 2572 const value = linearRampToValueAtTime.apply(audioParam, args); 2573 createScriptProcessorNode(); 2574 return value; 2575 }; 2576 })(audioParam.linearRampToValueAtTime); 2577 audioParam.setTargetAtTime = ((setTargetAtTime) => { 2578 if (isOffline) { 2579 return () => { 2580 throw createNotSupportedError2(); 2581 }; 2582 } 2583 return (...args) => { 2584 const value = setTargetAtTime.apply(audioParam, args); 2585 createScriptProcessorNode(); 2586 return value; 2587 }; 2588 })(audioParam.setTargetAtTime); 2589 audioParam.setValueAtTime = ((setValueAtTime) => { 2590 if (isOffline) { 2591 return () => { 2592 throw createNotSupportedError2(); 2593 }; 2594 } 2595 return (...args) => { 2596 const value = setValueAtTime.apply(audioParam, args); 2597 createScriptProcessorNode(); 2598 return value; 2599 }; 2600 })(audioParam.setValueAtTime); 2601 audioParam.setValueCurveAtTime = ((setValueCurveAtTime) => { 2602 if (isOffline) { 2603 return () => { 2604 throw createNotSupportedError2(); 2605 }; 2606 } 2607 return (...args) => { 2608 const value = setValueCurveAtTime.apply(audioParam, args); 2609 createScriptProcessorNode(); 2610 return value; 2611 }; 2612 })(audioParam.setValueCurveAtTime); 2613 return audioParam; 2614 }; 2615 return { 2616 forwardX: createFakeAudioParam(0, 0, createSetOrientation(0)), 2617 forwardY: createFakeAudioParam(1, 0, createSetOrientation(1)), 2618 forwardZ: createFakeAudioParam(2, -1, createSetOrientation(2)), 2619 positionX: createFakeAudioParam(6, 0, createSetPosition(0)), 2620 positionY: createFakeAudioParam(7, 0, createSetPosition(1)), 2621 positionZ: createFakeAudioParam(8, 0, createSetPosition(2)), 2622 upX: createFakeAudioParam(3, 0, createSetOrientation(3)), 2623 upY: createFakeAudioParam(4, 1, createSetOrientation(4)), 2624 upZ: createFakeAudioParam(5, 0, createSetOrientation(5)) 2625 }; 2626 }; 2627 const { forwardX, forwardY, forwardZ, positionX, positionY, positionZ, upX, upY, upZ } = nativeListener.forwardX === void 0 ? createFakeAudioParams() : nativeListener; 2628 return { 2629 get forwardX() { 2630 return forwardX; 2631 }, 2632 get forwardY() { 2633 return forwardY; 2634 }, 2635 get forwardZ() { 2636 return forwardZ; 2637 }, 2638 get positionX() { 2639 return positionX; 2640 }, 2641 get positionY() { 2642 return positionY; 2643 }, 2644 get positionZ() { 2645 return positionZ; 2646 }, 2647 get upX() { 2648 return upX; 2649 }, 2650 get upY() { 2651 return upY; 2652 }, 2653 get upZ() { 2654 return upZ; 2655 } 2656 }; 2657 }; 2658}; 2659
vendor: 173 bytes, lines 2660-2664
2660// node_modules/standardized-audio-context/build/es2019/guards/audio-node.js 2661var isAudioNode = (audioNodeOrAudioParam) => { 2662 return "context" in audioNodeOrAudioParam; 2663}; 2664
vendor: 200 bytes, lines 2665-2669
2665// node_modules/standardized-audio-context/build/es2019/guards/audio-node-output-connection.js 2666var isAudioNodeOutputConnection = (outputConnection) => { 2667 return isAudioNode(outputConnection[0]); 2668}; 2669
vendor: 396 bytes, lines 2670-2683
2670// node_modules/standardized-audio-context/build/es2019/helpers/insert-element-in-set.js 2671var insertElementInSet = (set, element, predicate, ignoreDuplicates) => { 2672 for (const lmnt of set) { 2673 if (predicate(lmnt)) { 2674 if (ignoreDuplicates) { 2675 return false; 2676 } 2677 throw Error("The set contains at least one similar element."); 2678 } 2679 } 2680 set.add(element); 2681 return true; 2682}; 2683
vendor: 418 bytes, lines 2684-2688
2684// node_modules/standardized-audio-context/build/es2019/helpers/add-active-input-connection-to-audio-param.js 2685var addActiveInputConnectionToAudioParam = (activeInputs, source, [output, eventListener], ignoreDuplicates) => { 2686 insertElementInSet(activeInputs, [source, output, eventListener], (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output, ignoreDuplicates); 2687}; 2688
vendor: 592 bytes, lines 2689-2698
2689// node_modules/standardized-audio-context/build/es2019/helpers/add-passive-input-connection-to-audio-param.js 2690var addPassiveInputConnectionToAudioParam = (passiveInputs, [source, output, eventListener], ignoreDuplicates) => { 2691 const passiveInputConnections = passiveInputs.get(source); 2692 if (passiveInputConnections === void 0) { 2693 passiveInputs.set(source, /* @__PURE__ */ new Set([[output, eventListener]])); 2694 } else { 2695 insertElementInSet(passiveInputConnections, [output, eventListener], (passiveInputConnection) => passiveInputConnection[0] === output, ignoreDuplicates); 2696 } 2697}; 2698
vendor: 228 bytes, lines 2699-2703
2699// node_modules/standardized-audio-context/build/es2019/guards/native-audio-node-faker.js 2700var isNativeAudioNodeFaker = (nativeAudioNodeOrNativeAudioNodeFaker) => { 2701 return "inputs" in nativeAudioNodeOrNativeAudioNodeFaker; 2702}; 2703
vendor: 649 bytes, lines 2704-2714
2704// node_modules/standardized-audio-context/build/es2019/helpers/connect-native-audio-node-to-native-audio-node.js 2705var connectNativeAudioNodeToNativeAudioNode = (nativeSourceAudioNode, nativeDestinationAudioNode, output, input) => { 2706 if (isNativeAudioNodeFaker(nativeDestinationAudioNode)) { 2707 const fakeNativeDestinationAudioNode = nativeDestinationAudioNode.inputs[input]; 2708 nativeSourceAudioNode.connect(fakeNativeDestinationAudioNode, output, 0); 2709 return [fakeNativeDestinationAudioNode, output, 0]; 2710 } 2711 nativeSourceAudioNode.connect(nativeDestinationAudioNode, output, input); 2712 return [nativeDestinationAudioNode, output, input]; 2713}; 2714
vendor: 453 bytes, lines 2715-2725
2715// node_modules/standardized-audio-context/build/es2019/helpers/delete-active-input-connection.js 2716var deleteActiveInputConnection = (activeInputConnections, source, output) => { 2717 for (const activeInputConnection of activeInputConnections) { 2718 if (activeInputConnection[0] === source && activeInputConnection[1] === output) { 2719 activeInputConnections.delete(activeInputConnection); 2720 return activeInputConnection; 2721 } 2722 } 2723 return null; 2724}; 2725
vendor: 345 bytes, lines 2726-2730
2726// node_modules/standardized-audio-context/build/es2019/helpers/delete-active-input-connection-to-audio-param.js 2727var deleteActiveInputConnectionToAudioParam = (activeInputs, source, output) => { 2728 return pickElementFromSet(activeInputs, (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output); 2729}; 2730
vendor: 355 bytes, lines 2731-2738
2731// node_modules/standardized-audio-context/build/es2019/helpers/delete-event-listeners-of-audio-node.js 2732var deleteEventListenerOfAudioNode = (audioNode, eventListener) => { 2733 const eventListeners = getEventListenersOfAudioNode(audioNode); 2734 if (!eventListeners.delete(eventListener)) { 2735 throw new Error("Missing the expected event listener."); 2736 } 2737}; 2738
vendor: 526 bytes, lines 2739-2748
2739// node_modules/standardized-audio-context/build/es2019/helpers/delete-passive-input-connection-to-audio-param.js 2740var deletePassiveInputConnectionToAudioParam = (passiveInputs, source, output) => { 2741 const passiveInputConnections = getValueForKey(passiveInputs, source); 2742 const matchingConnection = pickElementFromSet(passiveInputConnections, (passiveInputConnection) => passiveInputConnection[0] === output); 2743 if (passiveInputConnections.size === 0) { 2744 passiveInputs.delete(source); 2745 } 2746 return matchingConnection; 2747}; 2748
vendor: 493 bytes, lines 2749-2757
2749// node_modules/standardized-audio-context/build/es2019/helpers/disconnect-native-audio-node-from-native-audio-node.js 2750var disconnectNativeAudioNodeFromNativeAudioNode = (nativeSourceAudioNode, nativeDestinationAudioNode, output, input) => { 2751 if (isNativeAudioNodeFaker(nativeDestinationAudioNode)) { 2752 nativeSourceAudioNode.disconnect(nativeDestinationAudioNode.inputs[input], output, 0); 2753 } else { 2754 nativeSourceAudioNode.disconnect(nativeDestinationAudioNode, output, input); 2755 } 2756}; 2757
vendor: 189 bytes, lines 2758-2762
2758// node_modules/standardized-audio-context/build/es2019/helpers/get-native-audio-node.js 2759var getNativeAudioNode = (audioNode) => { 2760 return getValueForKey(AUDIO_NODE_STORE, audioNode); 2761}; 2762
vendor: 194 bytes, lines 2763-2767
2763// node_modules/standardized-audio-context/build/es2019/helpers/get-native-audio-param.js 2764var getNativeAudioParam = (audioParam) => { 2765 return getValueForKey(AUDIO_PARAM_STORE, audioParam); 2766}; 2767
vendor: 168 bytes, lines 2768-2772
2768// node_modules/standardized-audio-context/build/es2019/helpers/is-part-of-a-cycle.js 2769var isPartOfACycle = (audioNode) => { 2770 return CYCLE_COUNTERS.has(audioNode); 2771}; 2772
vendor: 185 bytes, lines 2773-2777
2773// node_modules/standardized-audio-context/build/es2019/helpers/is-passive-audio-node.js 2774var isPassiveAudioNode = (audioNode) => { 2775 return !ACTIVE_AUDIO_NODE_STORE.has(audioNode); 2776}; 2777
vendor: 1,352 bytes, lines 2778-2812
2778// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-node-disconnect-method-support.js 2779var testAudioNodeDisconnectMethodSupport = (nativeAudioContext, nativeAudioWorkletNodeConstructor2) => { 2780 return new Promise((resolve) => { 2781 if (nativeAudioWorkletNodeConstructor2 !== null) { 2782 resolve(true); 2783 } else { 2784 const analyzer = nativeAudioContext.createScriptProcessor(256, 1, 1); 2785 const dummy = nativeAudioContext.createGain(); 2786 const ones = nativeAudioContext.createBuffer(1, 2, 44100); 2787 const channelData = ones.getChannelData(0); 2788 channelData[0] = 1; 2789 channelData[1] = 1; 2790 const source = nativeAudioContext.createBufferSource(); 2791 source.buffer = ones; 2792 source.loop = true; 2793 source.connect(analyzer).connect(nativeAudioContext.destination); 2794 source.connect(dummy); 2795 source.disconnect(dummy); 2796 analyzer.onaudioprocess = (event) => { 2797 const chnnlDt = event.inputBuffer.getChannelData(0); 2798 if (Array.prototype.some.call(chnnlDt, (sample) => sample === 1)) { 2799 resolve(true); 2800 } else { 2801 resolve(false); 2802 } 2803 source.stop(); 2804 analyzer.onaudioprocess = null; 2805 source.disconnect(analyzer); 2806 analyzer.disconnect(nativeAudioContext.destination); 2807 }; 2808 source.start(); 2809 } 2810 }); 2811}; 2812
vendor: 446 bytes, lines 2813-2824
2813// node_modules/standardized-audio-context/build/es2019/helpers/visit-each-audio-node-once.js 2814var visitEachAudioNodeOnce = (cycles, visitor) => { 2815 const counts = /* @__PURE__ */ new Map(); 2816 for (const cycle of cycles) { 2817 for (const audioNode of cycle) { 2818 const count = counts.get(audioNode); 2819 counts.set(audioNode, count === void 0 ? 1 : count + 1); 2820 } 2821 } 2822 counts.forEach((count, audioNode) => visitor(audioNode, count)); 2823}; 2824
vendor: 198 bytes, lines 2825-2829
2825// node_modules/standardized-audio-context/build/es2019/guards/native-audio-node.js 2826var isNativeAudioNode = (nativeAudioNodeOrAudioParam) => { 2827 return "context" in nativeAudioNodeOrAudioParam; 2828}; 2829
vendor: 2,773 bytes, lines 2830-2888
2830// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-node-disconnect-method.js 2831var wrapAudioNodeDisconnectMethod = (nativeAudioNode) => { 2832 const connections = /* @__PURE__ */ new Map(); 2833 nativeAudioNode.connect = /* @__PURE__ */ ((connect2) => { 2834 return (destination, output = 0, input = 0) => { 2835 const returnValue = isNativeAudioNode(destination) ? connect2(destination, output, input) : connect2(destination, output); 2836 const connectionsToDestination = connections.get(destination); 2837 if (connectionsToDestination === void 0) { 2838 connections.set(destination, [{ input, output }]); 2839 } else { 2840 if (connectionsToDestination.every((connection) => connection.input !== input || connection.output !== output)) { 2841 connectionsToDestination.push({ input, output }); 2842 } 2843 } 2844 return returnValue; 2845 }; 2846 })(nativeAudioNode.connect.bind(nativeAudioNode)); 2847 nativeAudioNode.disconnect = /* @__PURE__ */ ((disconnect2) => { 2848 return (destinationOrOutput, output, input) => { 2849 disconnect2.apply(nativeAudioNode); 2850 if (destinationOrOutput === void 0) { 2851 connections.clear(); 2852 } else if (typeof destinationOrOutput === "number") { 2853 for (const [destination, connectionsToDestination] of connections) { 2854 const filteredConnections = connectionsToDestination.filter((connection) => connection.output !== destinationOrOutput); 2855 if (filteredConnections.length === 0) { 2856 connections.delete(destination); 2857 } else { 2858 connections.set(destination, filteredConnections); 2859 } 2860 } 2861 } else if (connections.has(destinationOrOutput)) { 2862 if (output === void 0) { 2863 connections.delete(destinationOrOutput); 2864 } else { 2865 const connectionsToDestination = connections.get(destinationOrOutput); 2866 if (connectionsToDestination !== void 0) { 2867 const filteredConnections = connectionsToDestination.filter((connection) => connection.output !== output && (connection.input !== input || input === void 0)); 2868 if (filteredConnections.length === 0) { 2869 connections.delete(destinationOrOutput); 2870 } else { 2871 connections.set(destinationOrOutput, filteredConnections); 2872 } 2873 } 2874 } 2875 } 2876 for (const [destination, connectionsToDestination] of connections) { 2877 connectionsToDestination.forEach((connection) => { 2878 if (isNativeAudioNode(destination)) { 2879 nativeAudioNode.connect(destination, connection.output, connection.input); 2880 } else { 2881 nativeAudioNode.connect(destination, connection.output); 2882 } 2883 }); 2884 } 2885 }; 2886 })(nativeAudioNode.disconnect); 2887}; 2888
vendor: 11,589 bytes, lines 2889-3135
2889// node_modules/standardized-audio-context/build/es2019/factories/audio-node-constructor.js 2890var addConnectionToAudioParamOfAudioContext = (source, destination, output, isOffline) => { 2891 const { activeInputs, passiveInputs } = getAudioParamConnections(destination); 2892 const { outputs } = getAudioNodeConnections(source); 2893 const eventListeners = getEventListenersOfAudioNode(source); 2894 const eventListener = (isActive) => { 2895 const nativeAudioNode = getNativeAudioNode(source); 2896 const nativeAudioParam = getNativeAudioParam(destination); 2897 if (isActive) { 2898 const partialConnection = deletePassiveInputConnectionToAudioParam(passiveInputs, source, output); 2899 addActiveInputConnectionToAudioParam(activeInputs, source, partialConnection, false); 2900 if (!isOffline && !isPartOfACycle(source)) { 2901 nativeAudioNode.connect(nativeAudioParam, output); 2902 } 2903 } else { 2904 const partialConnection = deleteActiveInputConnectionToAudioParam(activeInputs, source, output); 2905 addPassiveInputConnectionToAudioParam(passiveInputs, partialConnection, false); 2906 if (!isOffline && !isPartOfACycle(source)) { 2907 nativeAudioNode.disconnect(nativeAudioParam, output); 2908 } 2909 } 2910 }; 2911 if (insertElementInSet(outputs, [destination, output], (outputConnection) => outputConnection[0] === destination && outputConnection[1] === output, true)) { 2912 eventListeners.add(eventListener); 2913 if (isActiveAudioNode(source)) { 2914 addActiveInputConnectionToAudioParam(activeInputs, source, [output, eventListener], true); 2915 } else { 2916 addPassiveInputConnectionToAudioParam(passiveInputs, [source, output, eventListener], true); 2917 } 2918 return true; 2919 } 2920 return false; 2921}; 2922var deleteInputConnectionOfAudioNode = (source, destination, output, input) => { 2923 const { activeInputs, passiveInputs } = getAudioNodeConnections(destination); 2924 const activeInputConnection = deleteActiveInputConnection(activeInputs[input], source, output); 2925 if (activeInputConnection === null) { 2926 const passiveInputConnection = deletePassiveInputConnectionToAudioNode(passiveInputs, source, output, input); 2927 return [passiveInputConnection[2], false]; 2928 } 2929 return [activeInputConnection[2], true]; 2930}; 2931var deleteInputConnectionOfAudioParam = (source, destination, output) => { 2932 const { activeInputs, passiveInputs } = getAudioParamConnections(destination); 2933 const activeInputConnection = deleteActiveInputConnection(activeInputs, source, output); 2934 if (activeInputConnection === null) { 2935 const passiveInputConnection = deletePassiveInputConnectionToAudioParam(passiveInputs, source, output); 2936 return [passiveInputConnection[1], false]; 2937 } 2938 return [activeInputConnection[2], true]; 2939}; 2940var deleteInputsOfAudioNode = (source, isOffline, destination, output, input) => { 2941 const [listener, isActive] = deleteInputConnectionOfAudioNode(source, destination, output, input); 2942 if (listener !== null) { 2943 deleteEventListenerOfAudioNode(source, listener); 2944 if (isActive && !isOffline && !isPartOfACycle(source)) { 2945 disconnectNativeAudioNodeFromNativeAudioNode(getNativeAudioNode(source), getNativeAudioNode(destination), output, input); 2946 } 2947 } 2948 if (isActiveAudioNode(destination)) { 2949 const { activeInputs } = getAudioNodeConnections(destination); 2950 setInternalStateToPassiveWhenNecessary(destination, activeInputs); 2951 } 2952}; 2953var deleteInputsOfAudioParam = (source, isOffline, destination, output) => { 2954 const [listener, isActive] = deleteInputConnectionOfAudioParam(source, destination, output); 2955 if (listener !== null) { 2956 deleteEventListenerOfAudioNode(source, listener); 2957 if (isActive && !isOffline && !isPartOfACycle(source)) { 2958 getNativeAudioNode(source).disconnect(getNativeAudioParam(destination), output); 2959 } 2960 } 2961}; 2962var deleteAnyConnection = (source, isOffline) => { 2963 const audioNodeConnectionsOfSource = getAudioNodeConnections(source); 2964 const destinations = []; 2965 for (const outputConnection of audioNodeConnectionsOfSource.outputs) { 2966 if (isAudioNodeOutputConnection(outputConnection)) { 2967 deleteInputsOfAudioNode(source, isOffline, ...outputConnection); 2968 } else { 2969 deleteInputsOfAudioParam(source, isOffline, ...outputConnection); 2970 } 2971 destinations.push(outputConnection[0]); 2972 } 2973 audioNodeConnectionsOfSource.outputs.clear(); 2974 return destinations; 2975}; 2976var deleteConnectionAtOutput = (source, isOffline, output) => { 2977 const audioNodeConnectionsOfSource = getAudioNodeConnections(source); 2978 const destinations = []; 2979 for (const outputConnection of audioNodeConnectionsOfSource.outputs) { 2980 if (outputConnection[1] === output) { 2981 if (isAudioNodeOutputConnection(outputConnection)) { 2982 deleteInputsOfAudioNode(source, isOffline, ...outputConnection); 2983 } else { 2984 deleteInputsOfAudioParam(source, isOffline, ...outputConnection); 2985 } 2986 destinations.push(outputConnection[0]); 2987 audioNodeConnectionsOfSource.outputs.delete(outputConnection); 2988 } 2989 } 2990 return destinations; 2991}; 2992var deleteConnectionToDestination = (source, isOffline, destination, output, input) => { 2993 const audioNodeConnectionsOfSource = getAudioNodeConnections(source); 2994 return Array.from(audioNodeConnectionsOfSource.outputs).filter((outputConnection) => outputConnection[0] === destination && (output === void 0 || outputConnection[1] === output) && (input === void 0 || outputConnection[2] === input)).map((outputConnection) => { 2995 if (isAudioNodeOutputConnection(outputConnection)) { 2996 deleteInputsOfAudioNode(source, isOffline, ...outputConnection); 2997 } else { 2998 deleteInputsOfAudioParam(source, isOffline, ...outputConnection); 2999 } 3000 audioNodeConnectionsOfSource.outputs.delete(outputConnection); 3001 return outputConnection[0]; 3002 }); 3003}; 3004var createAudioNodeConstructor = (addAudioNodeConnections, addConnectionToAudioNode, cacheTestResult2, createIncrementCycleCounter, createIndexSizeError2, createInvalidAccessError2, createNotSupportedError2, decrementCycleCounter, detectCycles, eventTargetConstructor2, getNativeContext2, isNativeAudioContext2, isNativeAudioNode3, isNativeAudioParam2, isNativeOfflineAudioContext2, nativeAudioWorkletNodeConstructor2) => { 3005 return class AudioNode extends eventTargetConstructor2 { 3006 constructor(context2, isActive, nativeAudioNode, audioNodeRenderer) { 3007 super(nativeAudioNode); 3008 this._context = context2; 3009 this._nativeAudioNode = nativeAudioNode; 3010 const nativeContext = getNativeContext2(context2); 3011 if (isNativeAudioContext2(nativeContext) && true !== cacheTestResult2(testAudioNodeDisconnectMethodSupport, () => { 3012 return testAudioNodeDisconnectMethodSupport(nativeContext, nativeAudioWorkletNodeConstructor2); 3013 })) { 3014 wrapAudioNodeDisconnectMethod(nativeAudioNode); 3015 } 3016 AUDIO_NODE_STORE.set(this, nativeAudioNode); 3017 EVENT_LISTENERS.set(this, /* @__PURE__ */ new Set()); 3018 if (context2.state !== "closed" && isActive) { 3019 setInternalStateToActive(this); 3020 } 3021 addAudioNodeConnections(this, audioNodeRenderer, nativeAudioNode); 3022 } 3023 get channelCount() { 3024 return this._nativeAudioNode.channelCount; 3025 } 3026 set channelCount(value) { 3027 this._nativeAudioNode.channelCount = value; 3028 } 3029 get channelCountMode() { 3030 return this._nativeAudioNode.channelCountMode; 3031 } 3032 set channelCountMode(value) { 3033 this._nativeAudioNode.channelCountMode = value; 3034 } 3035 get channelInterpretation() { 3036 return this._nativeAudioNode.channelInterpretation; 3037 } 3038 set channelInterpretation(value) { 3039 this._nativeAudioNode.channelInterpretation = value; 3040 } 3041 get context() { 3042 return this._context; 3043 } 3044 get numberOfInputs() { 3045 return this._nativeAudioNode.numberOfInputs; 3046 } 3047 get numberOfOutputs() { 3048 return this._nativeAudioNode.numberOfOutputs; 3049 } 3050 // tslint:disable-next-line:invalid-void 3051 connect(destination, output = 0, input = 0) { 3052 if (output < 0 || output >= this._nativeAudioNode.numberOfOutputs) { 3053 throw createIndexSizeError2(); 3054 } 3055 const nativeContext = getNativeContext2(this._context); 3056 const isOffline = isNativeOfflineAudioContext2(nativeContext); 3057 if (isNativeAudioNode3(destination) || isNativeAudioParam2(destination)) { 3058 throw createInvalidAccessError2(); 3059 } 3060 if (isAudioNode(destination)) { 3061 const nativeDestinationAudioNode = getNativeAudioNode(destination); 3062 try { 3063 const connection = connectNativeAudioNodeToNativeAudioNode(this._nativeAudioNode, nativeDestinationAudioNode, output, input); 3064 const isPassive = isPassiveAudioNode(this); 3065 if (isOffline || isPassive) { 3066 this._nativeAudioNode.disconnect(...connection); 3067 } 3068 if (this.context.state !== "closed" && !isPassive && isPassiveAudioNode(destination)) { 3069 setInternalStateToActive(destination); 3070 } 3071 } catch (err) { 3072 if (err.code === 12) { 3073 throw createInvalidAccessError2(); 3074 } 3075 throw err; 3076 } 3077 const isNewConnectionToAudioNode = addConnectionToAudioNode(this, destination, output, input, isOffline); 3078 if (isNewConnectionToAudioNode) { 3079 const cycles = detectCycles([this], destination); 3080 visitEachAudioNodeOnce(cycles, createIncrementCycleCounter(isOffline)); 3081 } 3082 return destination; 3083 } 3084 const nativeAudioParam = getNativeAudioParam(destination); 3085 if (nativeAudioParam.name === "playbackRate" && nativeAudioParam.maxValue === 1024) { 3086 throw createNotSupportedError2(); 3087 } 3088 try { 3089 this._nativeAudioNode.connect(nativeAudioParam, output); 3090 if (isOffline || isPassiveAudioNode(this)) { 3091 this._nativeAudioNode.disconnect(nativeAudioParam, output); 3092 } 3093 } catch (err) { 3094 if (err.code === 12) { 3095 throw createInvalidAccessError2(); 3096 } 3097 throw err; 3098 } 3099 const isNewConnectionToAudioParam = addConnectionToAudioParamOfAudioContext(this, destination, output, isOffline); 3100 if (isNewConnectionToAudioParam) { 3101 const cycles = detectCycles([this], destination); 3102 visitEachAudioNodeOnce(cycles, createIncrementCycleCounter(isOffline)); 3103 } 3104 } 3105 disconnect(destinationOrOutput, output, input) { 3106 let destinations; 3107 const nativeContext = getNativeContext2(this._context); 3108 const isOffline = isNativeOfflineAudioContext2(nativeContext); 3109 if (destinationOrOutput === void 0) { 3110 destinations = deleteAnyConnection(this, isOffline); 3111 } else if (typeof destinationOrOutput === "number") { 3112 if (destinationOrOutput < 0 || destinationOrOutput >= this.numberOfOutputs) { 3113 throw createIndexSizeError2(); 3114 } 3115 destinations = deleteConnectionAtOutput(this, isOffline, destinationOrOutput); 3116 } else { 3117 if (output !== void 0 && (output < 0 || output >= this.numberOfOutputs)) { 3118 throw createIndexSizeError2(); 3119 } 3120 if (isAudioNode(destinationOrOutput) && input !== void 0 && (input < 0 || input >= destinationOrOutput.numberOfInputs)) { 3121 throw createIndexSizeError2(); 3122 } 3123 destinations = deleteConnectionToDestination(this, isOffline, destinationOrOutput, output, input); 3124 if (destinations.length === 0) { 3125 throw createInvalidAccessError2(); 3126 } 3127 } 3128 for (const destination of destinations) { 3129 const cycles = detectCycles([this], destination); 3130 visitEachAudioNodeOnce(cycles, decrementCycleCounter); 3131 } 3132 } 3133 }; 3134}; 3135
vendor: 8,234 bytes, lines 3136-3286
3136// node_modules/standardized-audio-context/build/es2019/factories/audio-param-factory.js 3137var import_automation_events = __toESM(require_bundle()); 3138var createAudioParamFactory = (addAudioParamConnections, audioParamAudioNodeStore2, audioParamStore, createAudioParamRenderer2, createCancelAndHoldAutomationEvent2, createCancelScheduledValuesAutomationEvent2, createExponentialRampToValueAutomationEvent2, createLinearRampToValueAutomationEvent2, createSetTargetAutomationEvent2, createSetValueAutomationEvent2, createSetValueCurveAutomationEvent2, nativeAudioContextConstructor2, setValueAtTimeUntilPossible2) => { 3139 return (audioNode, isAudioParamOfOfflineAudioContext, nativeAudioParam, maxValue = null, minValue = null) => { 3140 const defaultValue = nativeAudioParam.value; 3141 const automationEventList = new import_automation_events.AutomationEventList(defaultValue); 3142 const audioParamRenderer = isAudioParamOfOfflineAudioContext ? createAudioParamRenderer2(automationEventList) : null; 3143 const audioParam = { 3144 get defaultValue() { 3145 return defaultValue; 3146 }, 3147 get maxValue() { 3148 return maxValue === null ? nativeAudioParam.maxValue : maxValue; 3149 }, 3150 get minValue() { 3151 return minValue === null ? nativeAudioParam.minValue : minValue; 3152 }, 3153 get value() { 3154 return nativeAudioParam.value; 3155 }, 3156 set value(value) { 3157 nativeAudioParam.value = value; 3158 audioParam.setValueAtTime(value, audioNode.context.currentTime); 3159 }, 3160 cancelAndHoldAtTime(cancelTime) { 3161 if (typeof nativeAudioParam.cancelAndHoldAtTime === "function") { 3162 if (audioParamRenderer === null) { 3163 automationEventList.flush(audioNode.context.currentTime); 3164 } 3165 automationEventList.add(createCancelAndHoldAutomationEvent2(cancelTime)); 3166 nativeAudioParam.cancelAndHoldAtTime(cancelTime); 3167 } else { 3168 const previousLastEvent = Array.from(automationEventList).pop(); 3169 if (audioParamRenderer === null) { 3170 automationEventList.flush(audioNode.context.currentTime); 3171 } 3172 automationEventList.add(createCancelAndHoldAutomationEvent2(cancelTime)); 3173 const currentLastEvent = Array.from(automationEventList).pop(); 3174 nativeAudioParam.cancelScheduledValues(cancelTime); 3175 if (previousLastEvent !== currentLastEvent && currentLastEvent !== void 0) { 3176 if (currentLastEvent.type === "exponentialRampToValue") { 3177 nativeAudioParam.exponentialRampToValueAtTime(currentLastEvent.value, currentLastEvent.endTime); 3178 } else if (currentLastEvent.type === "linearRampToValue") { 3179 nativeAudioParam.linearRampToValueAtTime(currentLastEvent.value, currentLastEvent.endTime); 3180 } else if (currentLastEvent.type === "setValue") { 3181 nativeAudioParam.setValueAtTime(currentLastEvent.value, currentLastEvent.startTime); 3182 } else if (currentLastEvent.type === "setValueCurve") { 3183 nativeAudioParam.setValueCurveAtTime(currentLastEvent.values, currentLastEvent.startTime, currentLastEvent.duration); 3184 } 3185 } 3186 } 3187 return audioParam; 3188 }, 3189 cancelScheduledValues(cancelTime) { 3190 if (audioParamRenderer === null) { 3191 automationEventList.flush(audioNode.context.currentTime); 3192 } 3193 automationEventList.add(createCancelScheduledValuesAutomationEvent2(cancelTime)); 3194 nativeAudioParam.cancelScheduledValues(cancelTime); 3195 return audioParam; 3196 }, 3197 exponentialRampToValueAtTime(value, endTime) { 3198 if (value === 0) { 3199 throw new RangeError(); 3200 } 3201 if (!Number.isFinite(endTime) || endTime < 0) { 3202 throw new RangeError(); 3203 } 3204 const currentTime = audioNode.context.currentTime; 3205 if (audioParamRenderer === null) { 3206 automationEventList.flush(currentTime); 3207 } 3208 if (Array.from(automationEventList).length === 0) { 3209 automationEventList.add(createSetValueAutomationEvent2(defaultValue, currentTime)); 3210 nativeAudioParam.setValueAtTime(defaultValue, currentTime); 3211 } 3212 automationEventList.add(createExponentialRampToValueAutomationEvent2(value, endTime)); 3213 nativeAudioParam.exponentialRampToValueAtTime(value, endTime); 3214 return audioParam; 3215 }, 3216 linearRampToValueAtTime(value, endTime) { 3217 const currentTime = audioNode.context.currentTime; 3218 if (audioParamRenderer === null) { 3219 automationEventList.flush(currentTime); 3220 } 3221 if (Array.from(automationEventList).length === 0) { 3222 automationEventList.add(createSetValueAutomationEvent2(defaultValue, currentTime)); 3223 nativeAudioParam.setValueAtTime(defaultValue, currentTime); 3224 } 3225 automationEventList.add(createLinearRampToValueAutomationEvent2(value, endTime)); 3226 nativeAudioParam.linearRampToValueAtTime(value, endTime); 3227 return audioParam; 3228 }, 3229 setTargetAtTime(target, startTime, timeConstant) { 3230 if (audioParamRenderer === null) { 3231 automationEventList.flush(audioNode.context.currentTime); 3232 } 3233 automationEventList.add(createSetTargetAutomationEvent2(target, startTime, timeConstant)); 3234 nativeAudioParam.setTargetAtTime(target, startTime, timeConstant); 3235 return audioParam; 3236 }, 3237 setValueAtTime(value, startTime) { 3238 if (audioParamRenderer === null) { 3239 automationEventList.flush(audioNode.context.currentTime); 3240 } 3241 automationEventList.add(createSetValueAutomationEvent2(value, startTime)); 3242 nativeAudioParam.setValueAtTime(value, startTime); 3243 return audioParam; 3244 }, 3245 setValueCurveAtTime(values, startTime, duration) { 3246 const convertedValues = values instanceof Float32Array ? values : new Float32Array(values); 3247 if (nativeAudioContextConstructor2 !== null && nativeAudioContextConstructor2.name === "webkitAudioContext") { 3248 const endTime = startTime + duration; 3249 const sampleRate = audioNode.context.sampleRate; 3250 const firstSample = Math.ceil(startTime * sampleRate); 3251 const lastSample = Math.floor(endTime * sampleRate); 3252 const numberOfInterpolatedValues = lastSample - firstSample; 3253 const interpolatedValues = new Float32Array(numberOfInterpolatedValues); 3254 for (let i = 0; i < numberOfInterpolatedValues; i += 1) { 3255 const theoreticIndex = (convertedValues.length - 1) / duration * ((firstSample + i) / sampleRate - startTime); 3256 const lowerIndex = Math.floor(theoreticIndex); 3257 const upperIndex = Math.ceil(theoreticIndex); 3258 interpolatedValues[i] = lowerIndex === upperIndex ? convertedValues[lowerIndex] : (1 - (theoreticIndex - lowerIndex)) * convertedValues[lowerIndex] + (1 - (upperIndex - theoreticIndex)) * convertedValues[upperIndex]; 3259 } 3260 if (audioParamRenderer === null) { 3261 automationEventList.flush(audioNode.context.currentTime); 3262 } 3263 automationEventList.add(createSetValueCurveAutomationEvent2(interpolatedValues, startTime, duration)); 3264 nativeAudioParam.setValueCurveAtTime(interpolatedValues, startTime, duration); 3265 const timeOfLastSample = lastSample / sampleRate; 3266 if (timeOfLastSample < endTime) { 3267 setValueAtTimeUntilPossible2(audioParam, interpolatedValues[interpolatedValues.length - 1], timeOfLastSample); 3268 } 3269 setValueAtTimeUntilPossible2(audioParam, convertedValues[convertedValues.length - 1], endTime); 3270 } else { 3271 if (audioParamRenderer === null) { 3272 automationEventList.flush(audioNode.context.currentTime); 3273 } 3274 automationEventList.add(createSetValueCurveAutomationEvent2(convertedValues, startTime, duration)); 3275 nativeAudioParam.setValueCurveAtTime(convertedValues, startTime, duration); 3276 } 3277 return audioParam; 3278 } 3279 }; 3280 audioParamStore.set(audioParam, nativeAudioParam); 3281 audioParamAudioNodeStore2.set(audioParam, audioNode); 3282 addAudioParamConnections(audioParam, audioParamRenderer); 3283 return audioParam; 3284 }; 3285}; 3286
vendor: 1,298 bytes, lines 3287-3314
3287// node_modules/standardized-audio-context/build/es2019/factories/audio-param-renderer.js 3288var createAudioParamRenderer = (automationEventList) => { 3289 return { 3290 replay(audioParam) { 3291 for (const automationEvent of automationEventList) { 3292 if (automationEvent.type === "exponentialRampToValue") { 3293 const { endTime, value } = automationEvent; 3294 audioParam.exponentialRampToValueAtTime(value, endTime); 3295 } else if (automationEvent.type === "linearRampToValue") { 3296 const { endTime, value } = automationEvent; 3297 audioParam.linearRampToValueAtTime(value, endTime); 3298 } else if (automationEvent.type === "setTarget") { 3299 const { startTime, target, timeConstant } = automationEvent; 3300 audioParam.setTargetAtTime(target, startTime, timeConstant); 3301 } else if (automationEvent.type === "setValue") { 3302 const { startTime, value } = automationEvent; 3303 audioParam.setValueAtTime(value, startTime); 3304 } else if (automationEvent.type === "setValueCurve") { 3305 const { duration, startTime, values } = automationEvent; 3306 audioParam.setValueCurveAtTime(values, startTime, duration); 3307 } else { 3308 throw new Error("Can't apply an unknown automation."); 3309 } 3310 } 3311 } 3312 }; 3313}; 3314
vendor: 590 bytes, lines 3315-3342
3315// node_modules/standardized-audio-context/build/es2019/read-only-map.js 3316var ReadOnlyMap = class { 3317 constructor(parameters) { 3318 this._map = new Map(parameters); 3319 } 3320 get size() { 3321 return this._map.size; 3322 } 3323 entries() { 3324 return this._map.entries(); 3325 } 3326 forEach(callback, thisArg = null) { 3327 return this._map.forEach((value, key) => callback.call(thisArg, value, key, this)); 3328 } 3329 get(name) { 3330 return this._map.get(name); 3331 } 3332 has(name) { 3333 return this._map.has(name); 3334 } 3335 keys() { 3336 return this._map.keys(); 3337 } 3338 values() { 3339 return this._map.values(); 3340 } 3341}; 3342
vendor: 3,631 bytes, lines 3343-3402
3343// node_modules/standardized-audio-context/build/es2019/factories/audio-worklet-node-constructor.js 3344var DEFAULT_OPTIONS4 = { 3345 channelCount: 2, 3346 // Bug #61: The channelCountMode should be 'max' according to the spec but is set to 'explicit' to achieve consistent behavior. 3347 channelCountMode: "explicit", 3348 channelInterpretation: "speakers", 3349 numberOfInputs: 1, 3350 numberOfOutputs: 1, 3351 parameterData: {}, 3352 processorOptions: {} 3353}; 3354var createAudioWorkletNodeConstructor = (addUnrenderedAudioWorkletNode2, audioNodeConstructor2, createAudioParam2, createAudioWorkletNodeRenderer2, createNativeAudioWorkletNode2, getAudioNodeConnections2, getBackupOfflineAudioContext2, getNativeContext2, isNativeOfflineAudioContext2, nativeAudioWorkletNodeConstructor2, sanitizeAudioWorkletNodeOptions2, setActiveAudioWorkletNodeInputs2, testAudioWorkletNodeOptionsClonability2, wrapEventListener2) => { 3355 return class AudioWorkletNode extends audioNodeConstructor2 { 3356 constructor(context2, name, options) { 3357 var _a; 3358 const nativeContext = getNativeContext2(context2); 3359 const isOffline = isNativeOfflineAudioContext2(nativeContext); 3360 const mergedOptions = sanitizeAudioWorkletNodeOptions2({ ...DEFAULT_OPTIONS4, ...options }); 3361 testAudioWorkletNodeOptionsClonability2(mergedOptions); 3362 const nodeNameToProcessorConstructorMap = NODE_NAME_TO_PROCESSOR_CONSTRUCTOR_MAPS.get(nativeContext); 3363 const processorConstructor = nodeNameToProcessorConstructorMap === null || nodeNameToProcessorConstructorMap === void 0 ? void 0 : nodeNameToProcessorConstructorMap.get(name); 3364 const nativeContextOrBackupOfflineAudioContext = isOffline || nativeContext.state !== "closed" ? nativeContext : (_a = getBackupOfflineAudioContext2(nativeContext)) !== null && _a !== void 0 ? _a : nativeContext; 3365 const nativeAudioWorkletNode = createNativeAudioWorkletNode2(nativeContextOrBackupOfflineAudioContext, isOffline ? null : context2.baseLatency, nativeAudioWorkletNodeConstructor2, name, processorConstructor, mergedOptions); 3366 const audioWorkletNodeRenderer = isOffline ? createAudioWorkletNodeRenderer2(name, mergedOptions, processorConstructor) : null; 3367 super(context2, true, nativeAudioWorkletNode, audioWorkletNodeRenderer); 3368 const parameters = []; 3369 nativeAudioWorkletNode.parameters.forEach((nativeAudioParam, nm) => { 3370 const audioParam = createAudioParam2(this, isOffline, nativeAudioParam); 3371 parameters.push([nm, audioParam]); 3372 }); 3373 this._nativeAudioWorkletNode = nativeAudioWorkletNode; 3374 this._onprocessorerror = null; 3375 this._parameters = new ReadOnlyMap(parameters); 3376 if (isOffline) { 3377 addUnrenderedAudioWorkletNode2(nativeContext, this); 3378 } 3379 const { activeInputs } = getAudioNodeConnections2(this); 3380 setActiveAudioWorkletNodeInputs2(nativeAudioWorkletNode, activeInputs); 3381 } 3382 get onprocessorerror() { 3383 return this._onprocessorerror; 3384 } 3385 set onprocessorerror(value) { 3386 const wrappedListener = typeof value === "function" ? wrapEventListener2(this, value) : null; 3387 this._nativeAudioWorkletNode.onprocessorerror = wrappedListener; 3388 const nativeOnProcessorError = this._nativeAudioWorkletNode.onprocessorerror; 3389 this._onprocessorerror = nativeOnProcessorError !== null && nativeOnProcessorError === wrappedListener ? value : nativeOnProcessorError; 3390 } 3391 get parameters() { 3392 if (this._parameters === null) { 3393 return this._nativeAudioWorkletNode.parameters; 3394 } 3395 return this._parameters; 3396 } 3397 get port() { 3398 return this._nativeAudioWorkletNode.port; 3399 } 3400 }; 3401}; 3402
vendor: 759 bytes, lines 3403-3420
3403// node_modules/standardized-audio-context/build/es2019/helpers/copy-from-channel.js 3404function copyFromChannel(audioBuffer, parent, key, channelNumber, bufferOffset) { 3405 if (typeof audioBuffer.copyFromChannel === "function") { 3406 if (parent[key].byteLength === 0) { 3407 parent[key] = new Float32Array(128); 3408 } 3409 audioBuffer.copyFromChannel(parent[key], channelNumber, bufferOffset); 3410 } else { 3411 const channelData = audioBuffer.getChannelData(channelNumber); 3412 if (parent[key].byteLength === 0) { 3413 parent[key] = channelData.slice(bufferOffset, bufferOffset + 128); 3414 } else { 3415 const slicedInput = new Float32Array(channelData.buffer, bufferOffset * Float32Array.BYTES_PER_ELEMENT, 128); 3416 parent[key].set(slicedInput); 3417 } 3418 } 3419} 3420
vendor: 487 bytes, lines 3421-3433
3421// node_modules/standardized-audio-context/build/es2019/helpers/copy-to-channel.js 3422var copyToChannel = (audioBuffer, parent, key, channelNumber, bufferOffset) => { 3423 if (typeof audioBuffer.copyToChannel === "function") { 3424 if (parent[key].byteLength !== 0) { 3425 audioBuffer.copyToChannel(parent[key], channelNumber, bufferOffset); 3426 } 3427 } else { 3428 if (parent[key].byteLength !== 0) { 3429 audioBuffer.getChannelData(channelNumber).set(parent[key], bufferOffset); 3430 } 3431 } 3432}; 3433
vendor: 394 bytes, lines 3434-3447
3434// node_modules/standardized-audio-context/build/es2019/helpers/create-nested-arrays.js 3435var createNestedArrays = (x, y) => { 3436 const arrays = []; 3437 for (let i = 0; i < x; i += 1) { 3438 const array = []; 3439 const length = typeof y === "number" ? y : y[i]; 3440 for (let j = 0; j < length; j += 1) { 3441 array.push(new Float32Array(128)); 3442 } 3443 arrays.push(array); 3444 } 3445 return arrays; 3446}; 3447
vendor: 395 bytes, lines 3448-3454
3448// node_modules/standardized-audio-context/build/es2019/helpers/get-audio-worklet-processor.js 3449var getAudioWorkletProcessor = (nativeOfflineAudioContext, proxy) => { 3450 const nodeToProcessorMap = getValueForKey(NODE_TO_PROCESSOR_MAPS, nativeOfflineAudioContext); 3451 const nativeAudioWorkletNode = getNativeAudioNode(proxy); 3452 return getValueForKey(nodeToProcessorMap, nativeAudioWorkletNode); 3453}; 3454
vendor: 12,716 bytes, lines 3455-3686
3455// node_modules/standardized-audio-context/build/es2019/factories/audio-worklet-node-renderer-factory.js 3456var processBuffer = async (proxy, renderedBuffer, nativeOfflineAudioContext, options, outputChannelCount, processorConstructor, exposeCurrentFrameAndCurrentTime2) => { 3457 const length = renderedBuffer === null ? Math.ceil(proxy.context.length / 128) * 128 : renderedBuffer.length; 3458 const numberOfInputChannels = options.channelCount * options.numberOfInputs; 3459 const numberOfOutputChannels = outputChannelCount.reduce((sum, value) => sum + value, 0); 3460 const processedBuffer = numberOfOutputChannels === 0 ? null : nativeOfflineAudioContext.createBuffer(numberOfOutputChannels, length, nativeOfflineAudioContext.sampleRate); 3461 if (processorConstructor === void 0) { 3462 throw new Error("Missing the processor constructor."); 3463 } 3464 const audioNodeConnections = getAudioNodeConnections(proxy); 3465 const audioWorkletProcessor = await getAudioWorkletProcessor(nativeOfflineAudioContext, proxy); 3466 const inputs = createNestedArrays(options.numberOfInputs, options.channelCount); 3467 const outputs = createNestedArrays(options.numberOfOutputs, outputChannelCount); 3468 const parameters = Array.from(proxy.parameters.keys()).reduce((prmtrs, name) => ({ ...prmtrs, [name]: new Float32Array(128) }), {}); 3469 for (let i = 0; i < length; i += 128) { 3470 if (options.numberOfInputs > 0 && renderedBuffer !== null) { 3471 for (let j = 0; j < options.numberOfInputs; j += 1) { 3472 for (let k = 0; k < options.channelCount; k += 1) { 3473 copyFromChannel(renderedBuffer, inputs[j], k, k, i); 3474 } 3475 } 3476 } 3477 if (processorConstructor.parameterDescriptors !== void 0 && renderedBuffer !== null) { 3478 processorConstructor.parameterDescriptors.forEach(({ name }, index) => { 3479 copyFromChannel(renderedBuffer, parameters, name, numberOfInputChannels + index, i); 3480 }); 3481 } 3482 for (let j = 0; j < options.numberOfInputs; j += 1) { 3483 for (let k = 0; k < outputChannelCount[j]; k += 1) { 3484 if (outputs[j][k].byteLength === 0) { 3485 outputs[j][k] = new Float32Array(128); 3486 } 3487 } 3488 } 3489 try { 3490 const potentiallyEmptyInputs = inputs.map((input, index) => { 3491 if (audioNodeConnections.activeInputs[index].size === 0) { 3492 return []; 3493 } 3494 return input; 3495 }); 3496 const activeSourceFlag = exposeCurrentFrameAndCurrentTime2(i / nativeOfflineAudioContext.sampleRate, nativeOfflineAudioContext.sampleRate, () => audioWorkletProcessor.process(potentiallyEmptyInputs, outputs, parameters)); 3497 if (processedBuffer !== null) { 3498 for (let j = 0, outputChannelSplitterNodeOutput = 0; j < options.numberOfOutputs; j += 1) { 3499 for (let k = 0; k < outputChannelCount[j]; k += 1) { 3500 copyToChannel(processedBuffer, outputs[j], k, outputChannelSplitterNodeOutput + k, i); 3501 } 3502 outputChannelSplitterNodeOutput += outputChannelCount[j]; 3503 } 3504 } 3505 if (!activeSourceFlag) { 3506 break; 3507 } 3508 } catch (error) { 3509 proxy.dispatchEvent(new ErrorEvent("processorerror", { 3510 colno: error.colno, 3511 filename: error.filename, 3512 lineno: error.lineno, 3513 message: error.message 3514 })); 3515 break; 3516 } 3517 } 3518 return processedBuffer; 3519}; 3520var createAudioWorkletNodeRendererFactory = (connectAudioParam2, connectMultipleOutputs2, createNativeAudioBufferSourceNode2, createNativeChannelMergerNode2, createNativeChannelSplitterNode2, createNativeConstantSourceNode2, createNativeGainNode2, deleteUnrenderedAudioWorkletNode2, disconnectMultipleOutputs2, exposeCurrentFrameAndCurrentTime2, getNativeAudioNode2, nativeAudioWorkletNodeConstructor2, nativeOfflineAudioContextConstructor2, renderAutomation2, renderInputsOfAudioNode2, renderNativeOfflineAudioContext2) => { 3521 return (name, options, processorConstructor) => { 3522 const renderedNativeAudioNodes = /* @__PURE__ */ new WeakMap(); 3523 let processedBufferPromise = null; 3524 const createAudioNode = async (proxy, nativeOfflineAudioContext) => { 3525 let nativeAudioWorkletNode = getNativeAudioNode2(proxy); 3526 let nativeOutputNodes = null; 3527 const nativeAudioWorkletNodeIsOwnedByContext = isOwnedByContext(nativeAudioWorkletNode, nativeOfflineAudioContext); 3528 const outputChannelCount = Array.isArray(options.outputChannelCount) ? options.outputChannelCount : Array.from(options.outputChannelCount); 3529 if (nativeAudioWorkletNodeConstructor2 === null) { 3530 const numberOfOutputChannels = outputChannelCount.reduce((sum, value) => sum + value, 0); 3531 const outputChannelSplitterNode = createNativeChannelSplitterNode2(nativeOfflineAudioContext, { 3532 channelCount: Math.max(1, numberOfOutputChannels), 3533 channelCountMode: "explicit", 3534 channelInterpretation: "discrete", 3535 numberOfOutputs: Math.max(1, numberOfOutputChannels) 3536 }); 3537 const outputChannelMergerNodes = []; 3538 for (let i = 0; i < proxy.numberOfOutputs; i += 1) { 3539 outputChannelMergerNodes.push(createNativeChannelMergerNode2(nativeOfflineAudioContext, { 3540 channelCount: 1, 3541 channelCountMode: "explicit", 3542 channelInterpretation: "speakers", 3543 numberOfInputs: outputChannelCount[i] 3544 })); 3545 } 3546 const outputGainNode = createNativeGainNode2(nativeOfflineAudioContext, { 3547 channelCount: options.channelCount, 3548 channelCountMode: options.channelCountMode, 3549 channelInterpretation: options.channelInterpretation, 3550 gain: 1 3551 }); 3552 outputGainNode.connect = connectMultipleOutputs2.bind(null, outputChannelMergerNodes); 3553 outputGainNode.disconnect = disconnectMultipleOutputs2.bind(null, outputChannelMergerNodes); 3554 nativeOutputNodes = [outputChannelSplitterNode, outputChannelMergerNodes, outputGainNode]; 3555 } else if (!nativeAudioWorkletNodeIsOwnedByContext) { 3556 nativeAudioWorkletNode = new nativeAudioWorkletNodeConstructor2(nativeOfflineAudioContext, name); 3557 } 3558 renderedNativeAudioNodes.set(nativeOfflineAudioContext, nativeOutputNodes === null ? nativeAudioWorkletNode : nativeOutputNodes[2]); 3559 if (nativeOutputNodes !== null) { 3560 if (processedBufferPromise === null) { 3561 if (processorConstructor === void 0) { 3562 throw new Error("Missing the processor constructor."); 3563 } 3564 if (nativeOfflineAudioContextConstructor2 === null) { 3565 throw new Error("Missing the native OfflineAudioContext constructor."); 3566 } 3567 const numberOfInputChannels = proxy.channelCount * proxy.numberOfInputs; 3568 const numberOfParameters = processorConstructor.parameterDescriptors === void 0 ? 0 : processorConstructor.parameterDescriptors.length; 3569 const numberOfChannels = numberOfInputChannels + numberOfParameters; 3570 const renderBuffer = async () => { 3571 const partialOfflineAudioContext = new nativeOfflineAudioContextConstructor2( 3572 numberOfChannels, 3573 // Ceil the length to the next full render quantum. 3574 // Bug #17: Safari does not yet expose the length. 3575 Math.ceil(proxy.context.length / 128) * 128, 3576 nativeOfflineAudioContext.sampleRate 3577 ); 3578 const gainNodes = []; 3579 const inputChannelSplitterNodes = []; 3580 for (let i = 0; i < options.numberOfInputs; i += 1) { 3581 gainNodes.push(createNativeGainNode2(partialOfflineAudioContext, { 3582 channelCount: options.channelCount, 3583 channelCountMode: options.channelCountMode, 3584 channelInterpretation: options.channelInterpretation, 3585 gain: 1 3586 })); 3587 inputChannelSplitterNodes.push(createNativeChannelSplitterNode2(partialOfflineAudioContext, { 3588 channelCount: options.channelCount, 3589 channelCountMode: "explicit", 3590 channelInterpretation: "discrete", 3591 numberOfOutputs: options.channelCount 3592 })); 3593 } 3594 const constantSourceNodes = await Promise.all(Array.from(proxy.parameters.values()).map(async (audioParam) => { 3595 const constantSourceNode = createNativeConstantSourceNode2(partialOfflineAudioContext, { 3596 channelCount: 1, 3597 channelCountMode: "explicit", 3598 channelInterpretation: "discrete", 3599 offset: audioParam.value 3600 }); 3601 await renderAutomation2(partialOfflineAudioContext, audioParam, constantSourceNode.offset); 3602 return constantSourceNode; 3603 })); 3604 const inputChannelMergerNode = createNativeChannelMergerNode2(partialOfflineAudioContext, { 3605 channelCount: 1, 3606 channelCountMode: "explicit", 3607 channelInterpretation: "speakers", 3608 numberOfInputs: Math.max(1, numberOfInputChannels + numberOfParameters) 3609 }); 3610 for (let i = 0; i < options.numberOfInputs; i += 1) { 3611 gainNodes[i].connect(inputChannelSplitterNodes[i]); 3612 for (let j = 0; j < options.channelCount; j += 1) { 3613 inputChannelSplitterNodes[i].connect(inputChannelMergerNode, j, i * options.channelCount + j); 3614 } 3615 } 3616 for (const [index, constantSourceNode] of constantSourceNodes.entries()) { 3617 constantSourceNode.connect(inputChannelMergerNode, 0, numberOfInputChannels + index); 3618 constantSourceNode.start(0); 3619 } 3620 inputChannelMergerNode.connect(partialOfflineAudioContext.destination); 3621 await Promise.all(gainNodes.map((gainNode) => renderInputsOfAudioNode2(proxy, partialOfflineAudioContext, gainNode))); 3622 return renderNativeOfflineAudioContext2(partialOfflineAudioContext); 3623 }; 3624 processedBufferPromise = processBuffer(proxy, numberOfChannels === 0 ? null : await renderBuffer(), nativeOfflineAudioContext, options, outputChannelCount, processorConstructor, exposeCurrentFrameAndCurrentTime2); 3625 } 3626 const processedBuffer = await processedBufferPromise; 3627 const audioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeOfflineAudioContext, { 3628 buffer: null, 3629 channelCount: 2, 3630 channelCountMode: "max", 3631 channelInterpretation: "speakers", 3632 loop: false, 3633 loopEnd: 0, 3634 loopStart: 0, 3635 playbackRate: 1 3636 }); 3637 const [outputChannelSplitterNode, outputChannelMergerNodes, outputGainNode] = nativeOutputNodes; 3638 if (processedBuffer !== null) { 3639 audioBufferSourceNode.buffer = processedBuffer; 3640 audioBufferSourceNode.start(0); 3641 } 3642 audioBufferSourceNode.connect(outputChannelSplitterNode); 3643 for (let i = 0, outputChannelSplitterNodeOutput = 0; i < proxy.numberOfOutputs; i += 1) { 3644 const outputChannelMergerNode = outputChannelMergerNodes[i]; 3645 for (let j = 0; j < outputChannelCount[i]; j += 1) { 3646 outputChannelSplitterNode.connect(outputChannelMergerNode, outputChannelSplitterNodeOutput + j, j); 3647 } 3648 outputChannelSplitterNodeOutput += outputChannelCount[i]; 3649 } 3650 return outputGainNode; 3651 } 3652 if (!nativeAudioWorkletNodeIsOwnedByContext) { 3653 for (const [nm, audioParam] of proxy.parameters.entries()) { 3654 await renderAutomation2( 3655 nativeOfflineAudioContext, 3656 audioParam, 3657 // @todo The definition that TypeScript uses of the AudioParamMap is lacking many methods. 3658 nativeAudioWorkletNode.parameters.get(nm) 3659 ); 3660 } 3661 } else { 3662 for (const [nm, audioParam] of proxy.parameters.entries()) { 3663 await connectAudioParam2( 3664 nativeOfflineAudioContext, 3665 audioParam, 3666 // @todo The definition that TypeScript uses of the AudioParamMap is lacking many methods. 3667 nativeAudioWorkletNode.parameters.get(nm) 3668 ); 3669 } 3670 } 3671 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAudioWorkletNode); 3672 return nativeAudioWorkletNode; 3673 }; 3674 return { 3675 render(proxy, nativeOfflineAudioContext) { 3676 deleteUnrenderedAudioWorkletNode2(nativeOfflineAudioContext, proxy); 3677 const renderedNativeAudioWorkletNodeOrGainNode = renderedNativeAudioNodes.get(nativeOfflineAudioContext); 3678 if (renderedNativeAudioWorkletNodeOrGainNode !== void 0) { 3679 return Promise.resolve(renderedNativeAudioWorkletNodeOrGainNode); 3680 } 3681 return createAudioNode(proxy, nativeOfflineAudioContext); 3682 } 3683 }; 3684 }; 3685}; 3686
vendor: 3,368 bytes, lines 3687-3768
3687// node_modules/standardized-audio-context/build/es2019/factories/base-audio-context-constructor.js 3688var createBaseAudioContextConstructor = (addAudioWorkletModule2, analyserNodeConstructor2, audioBufferConstructor2, audioBufferSourceNodeConstructor2, biquadFilterNodeConstructor2, channelMergerNodeConstructor2, channelSplitterNodeConstructor2, constantSourceNodeConstructor2, convolverNodeConstructor2, decodeAudioData2, delayNodeConstructor2, dynamicsCompressorNodeConstructor2, gainNodeConstructor2, iIRFilterNodeConstructor2, minimalBaseAudioContextConstructor2, oscillatorNodeConstructor2, pannerNodeConstructor2, periodicWaveConstructor2, stereoPannerNodeConstructor2, waveShaperNodeConstructor2) => { 3689 return class BaseAudioContext extends minimalBaseAudioContextConstructor2 { 3690 constructor(_nativeContext, numberOfChannels) { 3691 super(_nativeContext, numberOfChannels); 3692 this._nativeContext = _nativeContext; 3693 this._audioWorklet = addAudioWorkletModule2 === void 0 ? void 0 : { 3694 addModule: (moduleURL, options) => { 3695 return addAudioWorkletModule2(this, moduleURL, options); 3696 } 3697 }; 3698 } 3699 get audioWorklet() { 3700 return this._audioWorklet; 3701 } 3702 createAnalyser() { 3703 return new analyserNodeConstructor2(this); 3704 } 3705 createBiquadFilter() { 3706 return new biquadFilterNodeConstructor2(this); 3707 } 3708 createBuffer(numberOfChannels, length, sampleRate) { 3709 return new audioBufferConstructor2({ length, numberOfChannels, sampleRate }); 3710 } 3711 createBufferSource() { 3712 return new audioBufferSourceNodeConstructor2(this); 3713 } 3714 createChannelMerger(numberOfInputs = 6) { 3715 return new channelMergerNodeConstructor2(this, { numberOfInputs }); 3716 } 3717 createChannelSplitter(numberOfOutputs = 6) { 3718 return new channelSplitterNodeConstructor2(this, { numberOfOutputs }); 3719 } 3720 createConstantSource() { 3721 return new constantSourceNodeConstructor2(this); 3722 } 3723 createConvolver() { 3724 return new convolverNodeConstructor2(this); 3725 } 3726 createDelay(maxDelayTime = 1) { 3727 return new delayNodeConstructor2(this, { maxDelayTime }); 3728 } 3729 createDynamicsCompressor() { 3730 return new dynamicsCompressorNodeConstructor2(this); 3731 } 3732 createGain() { 3733 return new gainNodeConstructor2(this); 3734 } 3735 createIIRFilter(feedforward, feedback) { 3736 return new iIRFilterNodeConstructor2(this, { feedback, feedforward }); 3737 } 3738 createOscillator() { 3739 return new oscillatorNodeConstructor2(this); 3740 } 3741 createPanner() { 3742 return new pannerNodeConstructor2(this); 3743 } 3744 createPeriodicWave(real, imag, constraints = { disableNormalization: false }) { 3745 return new periodicWaveConstructor2(this, { ...constraints, imag, real }); 3746 } 3747 createStereoPanner() { 3748 return new stereoPannerNodeConstructor2(this); 3749 } 3750 createWaveShaper() { 3751 return new waveShaperNodeConstructor2(this); 3752 } 3753 decodeAudioData(audioData, successCallback, errorCallback) { 3754 return decodeAudioData2(this._nativeContext, audioData).then((audioBuffer) => { 3755 if (typeof successCallback === "function") { 3756 successCallback(audioBuffer); 3757 } 3758 return audioBuffer; 3759 }, (err) => { 3760 if (typeof errorCallback === "function") { 3761 errorCallback(err); 3762 } 3763 throw err; 3764 }); 3765 } 3766 }; 3767}; 3768
vendor: 2,623 bytes, lines 3769-3829
3769// node_modules/standardized-audio-context/build/es2019/factories/biquad-filter-node-constructor.js 3770var DEFAULT_OPTIONS5 = { 3771 Q: 1, 3772 channelCount: 2, 3773 channelCountMode: "max", 3774 channelInterpretation: "speakers", 3775 detune: 0, 3776 frequency: 350, 3777 gain: 0, 3778 type: "lowpass" 3779}; 3780var createBiquadFilterNodeConstructor = (audioNodeConstructor2, createAudioParam2, createBiquadFilterNodeRenderer2, createInvalidAccessError2, createNativeBiquadFilterNode2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 3781 return class BiquadFilterNode extends audioNodeConstructor2 { 3782 constructor(context2, options) { 3783 const nativeContext = getNativeContext2(context2); 3784 const mergedOptions = { ...DEFAULT_OPTIONS5, ...options }; 3785 const nativeBiquadFilterNode = createNativeBiquadFilterNode2(nativeContext, mergedOptions); 3786 const isOffline = isNativeOfflineAudioContext2(nativeContext); 3787 const biquadFilterNodeRenderer = isOffline ? createBiquadFilterNodeRenderer2() : null; 3788 super(context2, false, nativeBiquadFilterNode, biquadFilterNodeRenderer); 3789 this._Q = createAudioParam2(this, isOffline, nativeBiquadFilterNode.Q, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 3790 this._detune = createAudioParam2(this, isOffline, nativeBiquadFilterNode.detune, 1200 * Math.log2(MOST_POSITIVE_SINGLE_FLOAT), -1200 * Math.log2(MOST_POSITIVE_SINGLE_FLOAT)); 3791 this._frequency = createAudioParam2(this, isOffline, nativeBiquadFilterNode.frequency, context2.sampleRate / 2, 0); 3792 this._gain = createAudioParam2(this, isOffline, nativeBiquadFilterNode.gain, 40 * Math.log10(MOST_POSITIVE_SINGLE_FLOAT), MOST_NEGATIVE_SINGLE_FLOAT); 3793 this._nativeBiquadFilterNode = nativeBiquadFilterNode; 3794 setAudioNodeTailTime2(this, 1); 3795 } 3796 get detune() { 3797 return this._detune; 3798 } 3799 get frequency() { 3800 return this._frequency; 3801 } 3802 get gain() { 3803 return this._gain; 3804 } 3805 get Q() { 3806 return this._Q; 3807 } 3808 get type() { 3809 return this._nativeBiquadFilterNode.type; 3810 } 3811 set type(value) { 3812 this._nativeBiquadFilterNode.type = value; 3813 } 3814 getFrequencyResponse(frequencyHz, magResponse, phaseResponse) { 3815 try { 3816 this._nativeBiquadFilterNode.getFrequencyResponse(frequencyHz, magResponse, phaseResponse); 3817 } catch (err) { 3818 if (err.code === 11) { 3819 throw createInvalidAccessError2(); 3820 } 3821 throw err; 3822 } 3823 if (frequencyHz.length !== magResponse.length || magResponse.length !== phaseResponse.length) { 3824 throw createInvalidAccessError2(); 3825 } 3826 } 3827 }; 3828}; 3829
vendor: 2,834 bytes, lines 3830-3876
3830// node_modules/standardized-audio-context/build/es2019/factories/biquad-filter-node-renderer-factory.js 3831var createBiquadFilterNodeRendererFactory = (connectAudioParam2, createNativeBiquadFilterNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 3832 return () => { 3833 const renderedNativeBiquadFilterNodes = /* @__PURE__ */ new WeakMap(); 3834 const createBiquadFilterNode = async (proxy, nativeOfflineAudioContext) => { 3835 let nativeBiquadFilterNode = getNativeAudioNode2(proxy); 3836 const nativeBiquadFilterNodeIsOwnedByContext = isOwnedByContext(nativeBiquadFilterNode, nativeOfflineAudioContext); 3837 if (!nativeBiquadFilterNodeIsOwnedByContext) { 3838 const options = { 3839 Q: nativeBiquadFilterNode.Q.value, 3840 channelCount: nativeBiquadFilterNode.channelCount, 3841 channelCountMode: nativeBiquadFilterNode.channelCountMode, 3842 channelInterpretation: nativeBiquadFilterNode.channelInterpretation, 3843 detune: nativeBiquadFilterNode.detune.value, 3844 frequency: nativeBiquadFilterNode.frequency.value, 3845 gain: nativeBiquadFilterNode.gain.value, 3846 type: nativeBiquadFilterNode.type 3847 }; 3848 nativeBiquadFilterNode = createNativeBiquadFilterNode2(nativeOfflineAudioContext, options); 3849 } 3850 renderedNativeBiquadFilterNodes.set(nativeOfflineAudioContext, nativeBiquadFilterNode); 3851 if (!nativeBiquadFilterNodeIsOwnedByContext) { 3852 await renderAutomation2(nativeOfflineAudioContext, proxy.Q, nativeBiquadFilterNode.Q); 3853 await renderAutomation2(nativeOfflineAudioContext, proxy.detune, nativeBiquadFilterNode.detune); 3854 await renderAutomation2(nativeOfflineAudioContext, proxy.frequency, nativeBiquadFilterNode.frequency); 3855 await renderAutomation2(nativeOfflineAudioContext, proxy.gain, nativeBiquadFilterNode.gain); 3856 } else { 3857 await connectAudioParam2(nativeOfflineAudioContext, proxy.Q, nativeBiquadFilterNode.Q); 3858 await connectAudioParam2(nativeOfflineAudioContext, proxy.detune, nativeBiquadFilterNode.detune); 3859 await connectAudioParam2(nativeOfflineAudioContext, proxy.frequency, nativeBiquadFilterNode.frequency); 3860 await connectAudioParam2(nativeOfflineAudioContext, proxy.gain, nativeBiquadFilterNode.gain); 3861 } 3862 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeBiquadFilterNode); 3863 return nativeBiquadFilterNode; 3864 }; 3865 return { 3866 render(proxy, nativeOfflineAudioContext) { 3867 const renderedNativeBiquadFilterNode = renderedNativeBiquadFilterNodes.get(nativeOfflineAudioContext); 3868 if (renderedNativeBiquadFilterNode !== void 0) { 3869 return Promise.resolve(renderedNativeBiquadFilterNode); 3870 } 3871 return createBiquadFilterNode(proxy, nativeOfflineAudioContext); 3872 } 3873 }; 3874 }; 3875}; 3876
vendor: 994 bytes, lines 3877-3906
3877// node_modules/standardized-audio-context/build/es2019/factories/cache-test-result.js 3878var createCacheTestResult = (ongoingTests, testResults) => { 3879 return (tester, test) => { 3880 const cachedTestResult = testResults.get(tester); 3881 if (cachedTestResult !== void 0) { 3882 return cachedTestResult; 3883 } 3884 const ongoingTest = ongoingTests.get(tester); 3885 if (ongoingTest !== void 0) { 3886 return ongoingTest; 3887 } 3888 try { 3889 const synchronousTestResult = test(); 3890 if (synchronousTestResult instanceof Promise) { 3891 ongoingTests.set(tester, synchronousTestResult); 3892 return synchronousTestResult.catch(() => false).then((finalTestResult) => { 3893 ongoingTests.delete(tester); 3894 testResults.set(tester, finalTestResult); 3895 return finalTestResult; 3896 }); 3897 } 3898 testResults.set(tester, synchronousTestResult); 3899 return synchronousTestResult; 3900 } catch { 3901 testResults.set(tester, false); 3902 return false; 3903 } 3904 }; 3905}; 3906
vendor: 972 bytes, lines 3907-3925
3907// node_modules/standardized-audio-context/build/es2019/factories/channel-merger-node-constructor.js 3908var DEFAULT_OPTIONS6 = { 3909 channelCount: 1, 3910 channelCountMode: "explicit", 3911 channelInterpretation: "speakers", 3912 numberOfInputs: 6 3913}; 3914var createChannelMergerNodeConstructor = (audioNodeConstructor2, createChannelMergerNodeRenderer2, createNativeChannelMergerNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 3915 return class ChannelMergerNode extends audioNodeConstructor2 { 3916 constructor(context2, options) { 3917 const nativeContext = getNativeContext2(context2); 3918 const mergedOptions = { ...DEFAULT_OPTIONS6, ...options }; 3919 const nativeChannelMergerNode = createNativeChannelMergerNode2(nativeContext, mergedOptions); 3920 const channelMergerNodeRenderer = isNativeOfflineAudioContext2(nativeContext) ? createChannelMergerNodeRenderer2() : null; 3921 super(context2, false, nativeChannelMergerNode, channelMergerNodeRenderer); 3922 } 3923 }; 3924}; 3925
vendor: 1,563 bytes, lines 3926-3957
3926// node_modules/standardized-audio-context/build/es2019/factories/channel-merger-node-renderer-factory.js 3927var createChannelMergerNodeRendererFactory = (createNativeChannelMergerNode2, getNativeAudioNode2, renderInputsOfAudioNode2) => { 3928 return () => { 3929 const renderedNativeAudioNodes = /* @__PURE__ */ new WeakMap(); 3930 const createAudioNode = async (proxy, nativeOfflineAudioContext) => { 3931 let nativeAudioNode = getNativeAudioNode2(proxy); 3932 const nativeAudioNodeIsOwnedByContext = isOwnedByContext(nativeAudioNode, nativeOfflineAudioContext); 3933 if (!nativeAudioNodeIsOwnedByContext) { 3934 const options = { 3935 channelCount: nativeAudioNode.channelCount, 3936 channelCountMode: nativeAudioNode.channelCountMode, 3937 channelInterpretation: nativeAudioNode.channelInterpretation, 3938 numberOfInputs: nativeAudioNode.numberOfInputs 3939 }; 3940 nativeAudioNode = createNativeChannelMergerNode2(nativeOfflineAudioContext, options); 3941 } 3942 renderedNativeAudioNodes.set(nativeOfflineAudioContext, nativeAudioNode); 3943 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAudioNode); 3944 return nativeAudioNode; 3945 }; 3946 return { 3947 render(proxy, nativeOfflineAudioContext) { 3948 const renderedNativeAudioNode = renderedNativeAudioNodes.get(nativeOfflineAudioContext); 3949 if (renderedNativeAudioNode !== void 0) { 3950 return Promise.resolve(renderedNativeAudioNode); 3951 } 3952 return createAudioNode(proxy, nativeOfflineAudioContext); 3953 } 3954 }; 3955 }; 3956}; 3957
vendor: 1,061 bytes, lines 3958-3976
3958// node_modules/standardized-audio-context/build/es2019/factories/channel-splitter-node-constructor.js 3959var DEFAULT_OPTIONS7 = { 3960 channelCount: 6, 3961 channelCountMode: "explicit", 3962 channelInterpretation: "discrete", 3963 numberOfOutputs: 6 3964}; 3965var createChannelSplitterNodeConstructor = (audioNodeConstructor2, createChannelSplitterNodeRenderer2, createNativeChannelSplitterNode2, getNativeContext2, isNativeOfflineAudioContext2, sanitizeChannelSplitterOptions2) => { 3966 return class ChannelSplitterNode extends audioNodeConstructor2 { 3967 constructor(context2, options) { 3968 const nativeContext = getNativeContext2(context2); 3969 const mergedOptions = sanitizeChannelSplitterOptions2({ ...DEFAULT_OPTIONS7, ...options }); 3970 const nativeChannelSplitterNode = createNativeChannelSplitterNode2(nativeContext, mergedOptions); 3971 const channelSplitterNodeRenderer = isNativeOfflineAudioContext2(nativeContext) ? createChannelSplitterNodeRenderer2() : null; 3972 super(context2, false, nativeChannelSplitterNode, channelSplitterNodeRenderer); 3973 } 3974 }; 3975}; 3976
vendor: 1,573 bytes, lines 3977-4008
3977// node_modules/standardized-audio-context/build/es2019/factories/channel-splitter-node-renderer-factory.js 3978var createChannelSplitterNodeRendererFactory = (createNativeChannelSplitterNode2, getNativeAudioNode2, renderInputsOfAudioNode2) => { 3979 return () => { 3980 const renderedNativeAudioNodes = /* @__PURE__ */ new WeakMap(); 3981 const createAudioNode = async (proxy, nativeOfflineAudioContext) => { 3982 let nativeAudioNode = getNativeAudioNode2(proxy); 3983 const nativeAudioNodeIsOwnedByContext = isOwnedByContext(nativeAudioNode, nativeOfflineAudioContext); 3984 if (!nativeAudioNodeIsOwnedByContext) { 3985 const options = { 3986 channelCount: nativeAudioNode.channelCount, 3987 channelCountMode: nativeAudioNode.channelCountMode, 3988 channelInterpretation: nativeAudioNode.channelInterpretation, 3989 numberOfOutputs: nativeAudioNode.numberOfOutputs 3990 }; 3991 nativeAudioNode = createNativeChannelSplitterNode2(nativeOfflineAudioContext, options); 3992 } 3993 renderedNativeAudioNodes.set(nativeOfflineAudioContext, nativeAudioNode); 3994 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeAudioNode); 3995 return nativeAudioNode; 3996 }; 3997 return { 3998 render(proxy, nativeOfflineAudioContext) { 3999 const renderedNativeAudioNode = renderedNativeAudioNodes.get(nativeOfflineAudioContext); 4000 if (renderedNativeAudioNode !== void 0) { 4001 return Promise.resolve(renderedNativeAudioNode); 4002 } 4003 return createAudioNode(proxy, nativeOfflineAudioContext); 4004 } 4005 }; 4006 }; 4007}; 4008
vendor: 328 bytes, lines 4009-4015
4009// node_modules/standardized-audio-context/build/es2019/factories/connect-audio-param.js 4010var createConnectAudioParam = (renderInputsOfAudioParam2) => { 4011 return (nativeOfflineAudioContext, audioParam, nativeAudioParam) => { 4012 return renderInputsOfAudioParam2(audioParam, nativeOfflineAudioContext, nativeAudioParam); 4013 }; 4014}; 4015
vendor: 532 bytes, lines 4016-4029
4016// node_modules/standardized-audio-context/build/es2019/factories/connect-multiple-outputs.js 4017var createConnectMultipleOutputs = (createIndexSizeError2) => { 4018 return (outputAudioNodes, destination, output = 0, input = 0) => { 4019 const outputAudioNode = outputAudioNodes[output]; 4020 if (outputAudioNode === void 0) { 4021 throw createIndexSizeError2(); 4022 } 4023 if (isNativeAudioNode(destination)) { 4024 return outputAudioNode.connect(destination, 0, input); 4025 } 4026 return outputAudioNode.connect(destination, 0); 4027 }; 4028}; 4029
vendor: 973 bytes, lines 4030-4054
4030// node_modules/standardized-audio-context/build/es2019/factories/connected-native-audio-buffer-source-node-factory.js 4031var createConnectedNativeAudioBufferSourceNodeFactory = (createNativeAudioBufferSourceNode2) => { 4032 return (nativeContext, nativeAudioNode) => { 4033 const nativeAudioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeContext, { 4034 buffer: null, 4035 channelCount: 2, 4036 channelCountMode: "max", 4037 channelInterpretation: "speakers", 4038 loop: false, 4039 loopEnd: 0, 4040 loopStart: 0, 4041 playbackRate: 1 4042 }); 4043 const nativeAudioBuffer = nativeContext.createBuffer(1, 2, 44100); 4044 nativeAudioBufferSourceNode.buffer = nativeAudioBuffer; 4045 nativeAudioBufferSourceNode.loop = true; 4046 nativeAudioBufferSourceNode.connect(nativeAudioNode); 4047 nativeAudioBufferSourceNode.start(); 4048 return () => { 4049 nativeAudioBufferSourceNode.stop(); 4050 nativeAudioBufferSourceNode.disconnect(nativeAudioNode); 4051 }; 4052 }; 4053}; 4054
vendor: 2,680 bytes, lines 4055-4112
4055// node_modules/standardized-audio-context/build/es2019/factories/constant-source-node-constructor.js 4056var DEFAULT_OPTIONS8 = { 4057 channelCount: 2, 4058 channelCountMode: "max", 4059 channelInterpretation: "speakers", 4060 offset: 1 4061}; 4062var createConstantSourceNodeConstructor = (audioNodeConstructor2, createAudioParam2, createConstantSourceNodeRendererFactory2, createNativeConstantSourceNode2, getNativeContext2, isNativeOfflineAudioContext2, wrapEventListener2) => { 4063 return class ConstantSourceNode extends audioNodeConstructor2 { 4064 constructor(context2, options) { 4065 const nativeContext = getNativeContext2(context2); 4066 const mergedOptions = { ...DEFAULT_OPTIONS8, ...options }; 4067 const nativeConstantSourceNode = createNativeConstantSourceNode2(nativeContext, mergedOptions); 4068 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4069 const constantSourceNodeRenderer = isOffline ? createConstantSourceNodeRendererFactory2() : null; 4070 super(context2, false, nativeConstantSourceNode, constantSourceNodeRenderer); 4071 this._constantSourceNodeRenderer = constantSourceNodeRenderer; 4072 this._nativeConstantSourceNode = nativeConstantSourceNode; 4073 this._offset = createAudioParam2(this, isOffline, nativeConstantSourceNode.offset, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 4074 this._onended = null; 4075 } 4076 get offset() { 4077 return this._offset; 4078 } 4079 get onended() { 4080 return this._onended; 4081 } 4082 set onended(value) { 4083 const wrappedListener = typeof value === "function" ? wrapEventListener2(this, value) : null; 4084 this._nativeConstantSourceNode.onended = wrappedListener; 4085 const nativeOnEnded = this._nativeConstantSourceNode.onended; 4086 this._onended = nativeOnEnded !== null && nativeOnEnded === wrappedListener ? value : nativeOnEnded; 4087 } 4088 start(when = 0) { 4089 this._nativeConstantSourceNode.start(when); 4090 if (this._constantSourceNodeRenderer !== null) { 4091 this._constantSourceNodeRenderer.start = when; 4092 } 4093 if (this.context.state !== "closed") { 4094 setInternalStateToActive(this); 4095 const resetInternalStateToPassive = () => { 4096 this._nativeConstantSourceNode.removeEventListener("ended", resetInternalStateToPassive); 4097 if (isActiveAudioNode(this)) { 4098 setInternalStateToPassive(this); 4099 } 4100 }; 4101 this._nativeConstantSourceNode.addEventListener("ended", resetInternalStateToPassive); 4102 } 4103 } 4104 stop(when = 0) { 4105 this._nativeConstantSourceNode.stop(when); 4106 if (this._constantSourceNodeRenderer !== null) { 4107 this._constantSourceNodeRenderer.stop = when; 4108 } 4109 } 4110 }; 4111}; 4112
vendor: 2,403 bytes, lines 4113-4163
4113// node_modules/standardized-audio-context/build/es2019/factories/constant-source-node-renderer-factory.js 4114var createConstantSourceNodeRendererFactory = (connectAudioParam2, createNativeConstantSourceNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 4115 return () => { 4116 const renderedNativeConstantSourceNodes = /* @__PURE__ */ new WeakMap(); 4117 let start2 = null; 4118 let stop = null; 4119 const createConstantSourceNode = async (proxy, nativeOfflineAudioContext) => { 4120 let nativeConstantSourceNode = getNativeAudioNode2(proxy); 4121 const nativeConstantSourceNodeIsOwnedByContext = isOwnedByContext(nativeConstantSourceNode, nativeOfflineAudioContext); 4122 if (!nativeConstantSourceNodeIsOwnedByContext) { 4123 const options = { 4124 channelCount: nativeConstantSourceNode.channelCount, 4125 channelCountMode: nativeConstantSourceNode.channelCountMode, 4126 channelInterpretation: nativeConstantSourceNode.channelInterpretation, 4127 offset: nativeConstantSourceNode.offset.value 4128 }; 4129 nativeConstantSourceNode = createNativeConstantSourceNode2(nativeOfflineAudioContext, options); 4130 if (start2 !== null) { 4131 nativeConstantSourceNode.start(start2); 4132 } 4133 if (stop !== null) { 4134 nativeConstantSourceNode.stop(stop); 4135 } 4136 } 4137 renderedNativeConstantSourceNodes.set(nativeOfflineAudioContext, nativeConstantSourceNode); 4138 if (!nativeConstantSourceNodeIsOwnedByContext) { 4139 await renderAutomation2(nativeOfflineAudioContext, proxy.offset, nativeConstantSourceNode.offset); 4140 } else { 4141 await connectAudioParam2(nativeOfflineAudioContext, proxy.offset, nativeConstantSourceNode.offset); 4142 } 4143 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeConstantSourceNode); 4144 return nativeConstantSourceNode; 4145 }; 4146 return { 4147 set start(value) { 4148 start2 = value; 4149 }, 4150 set stop(value) { 4151 stop = value; 4152 }, 4153 render(proxy, nativeOfflineAudioContext) { 4154 const renderedNativeConstantSourceNode = renderedNativeConstantSourceNodes.get(nativeOfflineAudioContext); 4155 if (renderedNativeConstantSourceNode !== void 0) { 4156 return Promise.resolve(renderedNativeConstantSourceNode); 4157 } 4158 return createConstantSourceNode(proxy, nativeOfflineAudioContext); 4159 } 4160 }; 4161 }; 4162}; 4163
vendor: 246 bytes, lines 4164-4171
4164// node_modules/standardized-audio-context/build/es2019/factories/convert-number-to-unsigned-long.js 4165var createConvertNumberToUnsignedLong = (unit32Array) => { 4166 return (value) => { 4167 unit32Array[0] = value; 4168 return unit32Array[0]; 4169 }; 4170}; 4171
vendor: 2,118 bytes, lines 4172-4221
4172// node_modules/standardized-audio-context/build/es2019/factories/convolver-node-constructor.js 4173var DEFAULT_OPTIONS9 = { 4174 buffer: null, 4175 channelCount: 2, 4176 channelCountMode: "clamped-max", 4177 channelInterpretation: "speakers", 4178 disableNormalization: false 4179}; 4180var createConvolverNodeConstructor = (audioNodeConstructor2, createConvolverNodeRenderer2, createNativeConvolverNode2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 4181 return class ConvolverNode extends audioNodeConstructor2 { 4182 constructor(context2, options) { 4183 const nativeContext = getNativeContext2(context2); 4184 const mergedOptions = { ...DEFAULT_OPTIONS9, ...options }; 4185 const nativeConvolverNode = createNativeConvolverNode2(nativeContext, mergedOptions); 4186 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4187 const convolverNodeRenderer = isOffline ? createConvolverNodeRenderer2() : null; 4188 super(context2, false, nativeConvolverNode, convolverNodeRenderer); 4189 this._isBufferNullified = false; 4190 this._nativeConvolverNode = nativeConvolverNode; 4191 if (mergedOptions.buffer !== null) { 4192 setAudioNodeTailTime2(this, mergedOptions.buffer.duration); 4193 } 4194 } 4195 get buffer() { 4196 if (this._isBufferNullified) { 4197 return null; 4198 } 4199 return this._nativeConvolverNode.buffer; 4200 } 4201 set buffer(value) { 4202 this._nativeConvolverNode.buffer = value; 4203 if (value === null && this._nativeConvolverNode.buffer !== null) { 4204 const nativeContext = this._nativeConvolverNode.context; 4205 this._nativeConvolverNode.buffer = nativeContext.createBuffer(1, 1, nativeContext.sampleRate); 4206 this._isBufferNullified = true; 4207 setAudioNodeTailTime2(this, 0); 4208 } else { 4209 this._isBufferNullified = false; 4210 setAudioNodeTailTime2(this, this._nativeConvolverNode.buffer === null ? 0 : this._nativeConvolverNode.buffer.duration); 4211 } 4212 } 4213 get normalize() { 4214 return this._nativeConvolverNode.normalize; 4215 } 4216 set normalize(value) { 4217 this._nativeConvolverNode.normalize = value; 4218 } 4219 }; 4220}; 4221
vendor: 1,861 bytes, lines 4222-4258
4222// node_modules/standardized-audio-context/build/es2019/factories/convolver-node-renderer-factory.js 4223var createConvolverNodeRendererFactory = (createNativeConvolverNode2, getNativeAudioNode2, renderInputsOfAudioNode2) => { 4224 return () => { 4225 const renderedNativeConvolverNodes = /* @__PURE__ */ new WeakMap(); 4226 const createConvolverNode = async (proxy, nativeOfflineAudioContext) => { 4227 let nativeConvolverNode = getNativeAudioNode2(proxy); 4228 const nativeConvolverNodeIsOwnedByContext = isOwnedByContext(nativeConvolverNode, nativeOfflineAudioContext); 4229 if (!nativeConvolverNodeIsOwnedByContext) { 4230 const options = { 4231 buffer: nativeConvolverNode.buffer, 4232 channelCount: nativeConvolverNode.channelCount, 4233 channelCountMode: nativeConvolverNode.channelCountMode, 4234 channelInterpretation: nativeConvolverNode.channelInterpretation, 4235 disableNormalization: !nativeConvolverNode.normalize 4236 }; 4237 nativeConvolverNode = createNativeConvolverNode2(nativeOfflineAudioContext, options); 4238 } 4239 renderedNativeConvolverNodes.set(nativeOfflineAudioContext, nativeConvolverNode); 4240 if (isNativeAudioNodeFaker(nativeConvolverNode)) { 4241 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeConvolverNode.inputs[0]); 4242 } else { 4243 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeConvolverNode); 4244 } 4245 return nativeConvolverNode; 4246 }; 4247 return { 4248 render(proxy, nativeOfflineAudioContext) { 4249 const renderedNativeConvolverNode = renderedNativeConvolverNodes.get(nativeOfflineAudioContext); 4250 if (renderedNativeConvolverNode !== void 0) { 4251 return Promise.resolve(renderedNativeConvolverNode); 4252 } 4253 return createConvolverNode(proxy, nativeOfflineAudioContext); 4254 } 4255 }; 4256 }; 4257}; 4258
vendor: 661 bytes, lines 4259-4275
4259// node_modules/standardized-audio-context/build/es2019/factories/create-native-offline-audio-context.js 4260var createCreateNativeOfflineAudioContext = (createNotSupportedError2, nativeOfflineAudioContextConstructor2) => { 4261 return (numberOfChannels, length, sampleRate) => { 4262 if (nativeOfflineAudioContextConstructor2 === null) { 4263 throw new Error("Missing the native OfflineAudioContext constructor."); 4264 } 4265 try { 4266 return new nativeOfflineAudioContextConstructor2(numberOfChannels, length, sampleRate); 4267 } catch (err) { 4268 if (err.name === "SyntaxError") { 4269 throw createNotSupportedError2(); 4270 } 4271 throw err; 4272 } 4273 }; 4274}; 4275
vendor: 160 bytes, lines 4276-4278
4276// node_modules/standardized-audio-context/build/es2019/factories/data-clone-error.js 4277var createDataCloneError = () => new DOMException("", "DataCloneError"); 4278
vendor: 528 bytes, lines 4279-4298
4279// node_modules/standardized-audio-context/build/es2019/helpers/detach-array-buffer.js 4280var detachArrayBuffer = (arrayBuffer) => { 4281 const { port1, port2 } = new MessageChannel(); 4282 return new Promise((resolve) => { 4283 const closeAndResolve = () => { 4284 port2.onmessage = null; 4285 port1.close(); 4286 port2.close(); 4287 resolve(); 4288 }; 4289 port2.onmessage = () => closeAndResolve(); 4290 try { 4291 port1.postMessage(arrayBuffer, [arrayBuffer]); 4292 } catch { 4293 } finally { 4294 closeAndResolve(); 4295 } 4296 }); 4297}; 4298
vendor: 2,191 bytes, lines 4299-4354
4299// node_modules/standardized-audio-context/build/es2019/factories/decode-audio-data.js 4300var createDecodeAudioData = (audioBufferStore2, cacheTestResult2, createDataCloneError2, createEncodingError2, detachedArrayBuffers, getNativeContext2, isNativeContext2, testAudioBufferCopyChannelMethodsOutOfBoundsSupport2, testPromiseSupport2, wrapAudioBufferCopyChannelMethods2, wrapAudioBufferCopyChannelMethodsOutOfBounds2) => { 4301 return (anyContext, audioData) => { 4302 const nativeContext = isNativeContext2(anyContext) ? anyContext : getNativeContext2(anyContext); 4303 if (detachedArrayBuffers.has(audioData)) { 4304 const err = createDataCloneError2(); 4305 return Promise.reject(err); 4306 } 4307 try { 4308 detachedArrayBuffers.add(audioData); 4309 } catch { 4310 } 4311 if (cacheTestResult2(testPromiseSupport2, () => testPromiseSupport2(nativeContext))) { 4312 return nativeContext.decodeAudioData(audioData).then((audioBuffer) => { 4313 detachArrayBuffer(audioData).catch(() => { 4314 }); 4315 if (!cacheTestResult2(testAudioBufferCopyChannelMethodsOutOfBoundsSupport2, () => testAudioBufferCopyChannelMethodsOutOfBoundsSupport2(audioBuffer))) { 4316 wrapAudioBufferCopyChannelMethodsOutOfBounds2(audioBuffer); 4317 } 4318 audioBufferStore2.add(audioBuffer); 4319 return audioBuffer; 4320 }); 4321 } 4322 return new Promise((resolve, reject) => { 4323 const complete = async () => { 4324 try { 4325 await detachArrayBuffer(audioData); 4326 } catch { 4327 } 4328 }; 4329 const fail = (err) => { 4330 reject(err); 4331 complete(); 4332 }; 4333 try { 4334 nativeContext.decodeAudioData(audioData, (audioBuffer) => { 4335 if (typeof audioBuffer.copyFromChannel !== "function") { 4336 wrapAudioBufferCopyChannelMethods2(audioBuffer); 4337 wrapAudioBufferGetChannelDataMethod(audioBuffer); 4338 } 4339 audioBufferStore2.add(audioBuffer); 4340 complete().then(() => resolve(audioBuffer)); 4341 }, (err) => { 4342 if (err === null) { 4343 fail(createEncodingError2()); 4344 } else { 4345 fail(err); 4346 } 4347 }); 4348 } catch (err) { 4349 fail(err); 4350 } 4351 }); 4352 }; 4353}; 4354
vendor: 1,511 bytes, lines 4355-4384
4355// node_modules/standardized-audio-context/build/es2019/factories/decrement-cycle-counter.js 4356var createDecrementCycleCounter = (connectNativeAudioNodeToNativeAudioNode2, cycleCounters, getAudioNodeConnections2, getNativeAudioNode2, getNativeAudioParam2, getNativeContext2, isActiveAudioNode2, isNativeOfflineAudioContext2) => { 4357 return (audioNode, count) => { 4358 const cycleCounter = cycleCounters.get(audioNode); 4359 if (cycleCounter === void 0) { 4360 throw new Error("Missing the expected cycle count."); 4361 } 4362 const nativeContext = getNativeContext2(audioNode.context); 4363 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4364 if (cycleCounter === count) { 4365 cycleCounters.delete(audioNode); 4366 if (!isOffline && isActiveAudioNode2(audioNode)) { 4367 const nativeSourceAudioNode = getNativeAudioNode2(audioNode); 4368 const { outputs } = getAudioNodeConnections2(audioNode); 4369 for (const output of outputs) { 4370 if (isAudioNodeOutputConnection(output)) { 4371 const nativeDestinationAudioNode = getNativeAudioNode2(output[0]); 4372 connectNativeAudioNodeToNativeAudioNode2(nativeSourceAudioNode, nativeDestinationAudioNode, output[1], output[2]); 4373 } else { 4374 const nativeDestinationAudioParam = getNativeAudioParam2(output[0]); 4375 nativeSourceAudioNode.connect(nativeDestinationAudioParam, output[1]); 4376 } 4377 } 4378 } 4379 } else { 4380 cycleCounters.set(audioNode, cycleCounter - count); 4381 } 4382 }; 4383}; 4384
vendor: 1,205 bytes, lines 4385-4410
4385// node_modules/standardized-audio-context/build/es2019/factories/delay-node-constructor.js 4386var DEFAULT_OPTIONS10 = { 4387 channelCount: 2, 4388 channelCountMode: "max", 4389 channelInterpretation: "speakers", 4390 delayTime: 0, 4391 maxDelayTime: 1 4392}; 4393var createDelayNodeConstructor = (audioNodeConstructor2, createAudioParam2, createDelayNodeRenderer2, createNativeDelayNode2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 4394 return class DelayNode extends audioNodeConstructor2 { 4395 constructor(context2, options) { 4396 const nativeContext = getNativeContext2(context2); 4397 const mergedOptions = { ...DEFAULT_OPTIONS10, ...options }; 4398 const nativeDelayNode = createNativeDelayNode2(nativeContext, mergedOptions); 4399 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4400 const delayNodeRenderer = isOffline ? createDelayNodeRenderer2(mergedOptions.maxDelayTime) : null; 4401 super(context2, false, nativeDelayNode, delayNodeRenderer); 4402 this._delayTime = createAudioParam2(this, isOffline, nativeDelayNode.delayTime); 4403 setAudioNodeTailTime2(this, mergedOptions.maxDelayTime); 4404 } 4405 get delayTime() { 4406 return this._delayTime; 4407 } 4408 }; 4409}; 4410
vendor: 1,879 bytes, lines 4411-4448
4411// node_modules/standardized-audio-context/build/es2019/factories/delay-node-renderer-factory.js 4412var createDelayNodeRendererFactory = (connectAudioParam2, createNativeDelayNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 4413 return (maxDelayTime) => { 4414 const renderedNativeDelayNodes = /* @__PURE__ */ new WeakMap(); 4415 const createDelayNode = async (proxy, nativeOfflineAudioContext) => { 4416 let nativeDelayNode = getNativeAudioNode2(proxy); 4417 const nativeDelayNodeIsOwnedByContext = isOwnedByContext(nativeDelayNode, nativeOfflineAudioContext); 4418 if (!nativeDelayNodeIsOwnedByContext) { 4419 const options = { 4420 channelCount: nativeDelayNode.channelCount, 4421 channelCountMode: nativeDelayNode.channelCountMode, 4422 channelInterpretation: nativeDelayNode.channelInterpretation, 4423 delayTime: nativeDelayNode.delayTime.value, 4424 maxDelayTime 4425 }; 4426 nativeDelayNode = createNativeDelayNode2(nativeOfflineAudioContext, options); 4427 } 4428 renderedNativeDelayNodes.set(nativeOfflineAudioContext, nativeDelayNode); 4429 if (!nativeDelayNodeIsOwnedByContext) { 4430 await renderAutomation2(nativeOfflineAudioContext, proxy.delayTime, nativeDelayNode.delayTime); 4431 } else { 4432 await connectAudioParam2(nativeOfflineAudioContext, proxy.delayTime, nativeDelayNode.delayTime); 4433 } 4434 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeDelayNode); 4435 return nativeDelayNode; 4436 }; 4437 return { 4438 render(proxy, nativeOfflineAudioContext) { 4439 const renderedNativeDelayNode = renderedNativeDelayNodes.get(nativeOfflineAudioContext); 4440 if (renderedNativeDelayNode !== void 0) { 4441 return Promise.resolve(renderedNativeDelayNode); 4442 } 4443 return createDelayNode(proxy, nativeOfflineAudioContext); 4444 } 4445 }; 4446 }; 4447}; 4448
vendor: 409 bytes, lines 4449-4455
4449// node_modules/standardized-audio-context/build/es2019/factories/delete-active-input-connection-to-audio-node.js 4450var createDeleteActiveInputConnectionToAudioNode = (pickElementFromSet2) => { 4451 return (activeInputs, source, output, input) => { 4452 return pickElementFromSet2(activeInputs[input], (activeInputConnection) => activeInputConnection[0] === source && activeInputConnection[1] === output); 4453 }; 4454}; 4455
vendor: 324 bytes, lines 4456-4462
4456// node_modules/standardized-audio-context/build/es2019/factories/delete-unrendered-audio-worklet-node.js 4457var createDeleteUnrenderedAudioWorkletNode = (getUnrenderedAudioWorkletNodes2) => { 4458 return (nativeContext, audioWorkletNode) => { 4459 getUnrenderedAudioWorkletNodes2(nativeContext).delete(audioWorkletNode); 4460 }; 4461}; 4462
vendor: 151 bytes, lines 4463-4467
4463// node_modules/standardized-audio-context/build/es2019/guards/delay-node.js 4464var isDelayNode = (audioNode) => { 4465 return "delayTime" in audioNode; 4466}; 4467
vendor: 788 bytes, lines 4468-4485
4468// node_modules/standardized-audio-context/build/es2019/factories/detect-cycles.js 4469var createDetectCycles = (audioParamAudioNodeStore2, getAudioNodeConnections2, getValueForKey2) => { 4470 return function detectCycles(chain, nextLink) { 4471 const audioNode = isAudioNode(nextLink) ? nextLink : getValueForKey2(audioParamAudioNodeStore2, nextLink); 4472 if (isDelayNode(audioNode)) { 4473 return []; 4474 } 4475 if (chain[0] === audioNode) { 4476 return [chain]; 4477 } 4478 if (chain.includes(audioNode)) { 4479 return []; 4480 } 4481 const { outputs } = getAudioNodeConnections2(audioNode); 4482 return Array.from(outputs).map((outputConnection) => detectCycles([...chain, audioNode], outputConnection[0])).reduce((mergedCycles, nestedCycles) => mergedCycles.concat(nestedCycles), []); 4483 }; 4484}; 4485
vendor: 1,584 bytes, lines 4486-4517
4486// node_modules/standardized-audio-context/build/es2019/factories/disconnect-multiple-outputs.js 4487var getOutputAudioNodeAtIndex = (createIndexSizeError2, outputAudioNodes, output) => { 4488 const outputAudioNode = outputAudioNodes[output]; 4489 if (outputAudioNode === void 0) { 4490 throw createIndexSizeError2(); 4491 } 4492 return outputAudioNode; 4493}; 4494var createDisconnectMultipleOutputs = (createIndexSizeError2) => { 4495 return (outputAudioNodes, destinationOrOutput = void 0, output = void 0, input = 0) => { 4496 if (destinationOrOutput === void 0) { 4497 return outputAudioNodes.forEach((outputAudioNode) => outputAudioNode.disconnect()); 4498 } 4499 if (typeof destinationOrOutput === "number") { 4500 return getOutputAudioNodeAtIndex(createIndexSizeError2, outputAudioNodes, destinationOrOutput).disconnect(); 4501 } 4502 if (isNativeAudioNode(destinationOrOutput)) { 4503 if (output === void 0) { 4504 return outputAudioNodes.forEach((outputAudioNode) => outputAudioNode.disconnect(destinationOrOutput)); 4505 } 4506 if (input === void 0) { 4507 return getOutputAudioNodeAtIndex(createIndexSizeError2, outputAudioNodes, output).disconnect(destinationOrOutput, 0); 4508 } 4509 return getOutputAudioNodeAtIndex(createIndexSizeError2, outputAudioNodes, output).disconnect(destinationOrOutput, 0, input); 4510 } 4511 if (output === void 0) { 4512 return outputAudioNodes.forEach((outputAudioNode) => outputAudioNode.disconnect(destinationOrOutput)); 4513 } 4514 return getOutputAudioNodeAtIndex(createIndexSizeError2, outputAudioNodes, output).disconnect(destinationOrOutput, 0); 4515 }; 4516}; 4517
vendor: 3,471 bytes, lines 4518-4596
4518// node_modules/standardized-audio-context/build/es2019/factories/dynamics-compressor-node-constructor.js 4519var DEFAULT_OPTIONS11 = { 4520 attack: 3e-3, 4521 channelCount: 2, 4522 channelCountMode: "clamped-max", 4523 channelInterpretation: "speakers", 4524 knee: 30, 4525 ratio: 12, 4526 release: 0.25, 4527 threshold: -24 4528}; 4529var createDynamicsCompressorNodeConstructor = (audioNodeConstructor2, createAudioParam2, createDynamicsCompressorNodeRenderer2, createNativeDynamicsCompressorNode2, createNotSupportedError2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 4530 return class DynamicsCompressorNode extends audioNodeConstructor2 { 4531 constructor(context2, options) { 4532 const nativeContext = getNativeContext2(context2); 4533 const mergedOptions = { ...DEFAULT_OPTIONS11, ...options }; 4534 const nativeDynamicsCompressorNode = createNativeDynamicsCompressorNode2(nativeContext, mergedOptions); 4535 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4536 const dynamicsCompressorNodeRenderer = isOffline ? createDynamicsCompressorNodeRenderer2() : null; 4537 super(context2, false, nativeDynamicsCompressorNode, dynamicsCompressorNodeRenderer); 4538 this._attack = createAudioParam2(this, isOffline, nativeDynamicsCompressorNode.attack); 4539 this._knee = createAudioParam2(this, isOffline, nativeDynamicsCompressorNode.knee); 4540 this._nativeDynamicsCompressorNode = nativeDynamicsCompressorNode; 4541 this._ratio = createAudioParam2(this, isOffline, nativeDynamicsCompressorNode.ratio); 4542 this._release = createAudioParam2(this, isOffline, nativeDynamicsCompressorNode.release); 4543 this._threshold = createAudioParam2(this, isOffline, nativeDynamicsCompressorNode.threshold); 4544 setAudioNodeTailTime2(this, 6e-3); 4545 } 4546 get attack() { 4547 return this._attack; 4548 } 4549 // Bug #108: Safari allows a channelCount of three and above which is why the getter and setter needs to be overwritten here. 4550 get channelCount() { 4551 return this._nativeDynamicsCompressorNode.channelCount; 4552 } 4553 set channelCount(value) { 4554 const previousChannelCount = this._nativeDynamicsCompressorNode.channelCount; 4555 this._nativeDynamicsCompressorNode.channelCount = value; 4556 if (value > 2) { 4557 this._nativeDynamicsCompressorNode.channelCount = previousChannelCount; 4558 throw createNotSupportedError2(); 4559 } 4560 } 4561 /* 4562 * Bug #109: Only Chrome and Firefox disallow a channelCountMode of 'max' yet which is why the getter and setter needs to be 4563 * overwritten here. 4564 */ 4565 get channelCountMode() { 4566 return this._nativeDynamicsCompressorNode.channelCountMode; 4567 } 4568 set channelCountMode(value) { 4569 const previousChannelCount = this._nativeDynamicsCompressorNode.channelCountMode; 4570 this._nativeDynamicsCompressorNode.channelCountMode = value; 4571 if (value === "max") { 4572 this._nativeDynamicsCompressorNode.channelCountMode = previousChannelCount; 4573 throw createNotSupportedError2(); 4574 } 4575 } 4576 get knee() { 4577 return this._knee; 4578 } 4579 get ratio() { 4580 return this._ratio; 4581 } 4582 get reduction() { 4583 if (typeof this._nativeDynamicsCompressorNode.reduction.value === "number") { 4584 return this._nativeDynamicsCompressorNode.reduction.value; 4585 } 4586 return this._nativeDynamicsCompressorNode.reduction; 4587 } 4588 get release() { 4589 return this._release; 4590 } 4591 get threshold() { 4592 return this._threshold; 4593 } 4594 }; 4595}; 4596
vendor: 3,319 bytes, lines 4597-4645
4597// node_modules/standardized-audio-context/build/es2019/factories/dynamics-compressor-node-renderer-factory.js 4598var createDynamicsCompressorNodeRendererFactory = (connectAudioParam2, createNativeDynamicsCompressorNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 4599 return () => { 4600 const renderedNativeDynamicsCompressorNodes = /* @__PURE__ */ new WeakMap(); 4601 const createDynamicsCompressorNode = async (proxy, nativeOfflineAudioContext) => { 4602 let nativeDynamicsCompressorNode = getNativeAudioNode2(proxy); 4603 const nativeDynamicsCompressorNodeIsOwnedByContext = isOwnedByContext(nativeDynamicsCompressorNode, nativeOfflineAudioContext); 4604 if (!nativeDynamicsCompressorNodeIsOwnedByContext) { 4605 const options = { 4606 attack: nativeDynamicsCompressorNode.attack.value, 4607 channelCount: nativeDynamicsCompressorNode.channelCount, 4608 channelCountMode: nativeDynamicsCompressorNode.channelCountMode, 4609 channelInterpretation: nativeDynamicsCompressorNode.channelInterpretation, 4610 knee: nativeDynamicsCompressorNode.knee.value, 4611 ratio: nativeDynamicsCompressorNode.ratio.value, 4612 release: nativeDynamicsCompressorNode.release.value, 4613 threshold: nativeDynamicsCompressorNode.threshold.value 4614 }; 4615 nativeDynamicsCompressorNode = createNativeDynamicsCompressorNode2(nativeOfflineAudioContext, options); 4616 } 4617 renderedNativeDynamicsCompressorNodes.set(nativeOfflineAudioContext, nativeDynamicsCompressorNode); 4618 if (!nativeDynamicsCompressorNodeIsOwnedByContext) { 4619 await renderAutomation2(nativeOfflineAudioContext, proxy.attack, nativeDynamicsCompressorNode.attack); 4620 await renderAutomation2(nativeOfflineAudioContext, proxy.knee, nativeDynamicsCompressorNode.knee); 4621 await renderAutomation2(nativeOfflineAudioContext, proxy.ratio, nativeDynamicsCompressorNode.ratio); 4622 await renderAutomation2(nativeOfflineAudioContext, proxy.release, nativeDynamicsCompressorNode.release); 4623 await renderAutomation2(nativeOfflineAudioContext, proxy.threshold, nativeDynamicsCompressorNode.threshold); 4624 } else { 4625 await connectAudioParam2(nativeOfflineAudioContext, proxy.attack, nativeDynamicsCompressorNode.attack); 4626 await connectAudioParam2(nativeOfflineAudioContext, proxy.knee, nativeDynamicsCompressorNode.knee); 4627 await connectAudioParam2(nativeOfflineAudioContext, proxy.ratio, nativeDynamicsCompressorNode.ratio); 4628 await connectAudioParam2(nativeOfflineAudioContext, proxy.release, nativeDynamicsCompressorNode.release); 4629 await connectAudioParam2(nativeOfflineAudioContext, proxy.threshold, nativeDynamicsCompressorNode.threshold); 4630 } 4631 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeDynamicsCompressorNode); 4632 return nativeDynamicsCompressorNode; 4633 }; 4634 return { 4635 render(proxy, nativeOfflineAudioContext) { 4636 const renderedNativeDynamicsCompressorNode = renderedNativeDynamicsCompressorNodes.get(nativeOfflineAudioContext); 4637 if (renderedNativeDynamicsCompressorNode !== void 0) { 4638 return Promise.resolve(renderedNativeDynamicsCompressorNode); 4639 } 4640 return createDynamicsCompressorNode(proxy, nativeOfflineAudioContext); 4641 } 4642 }; 4643 }; 4644}; 4645
vendor: 156 bytes, lines 4646-4648
4646// node_modules/standardized-audio-context/build/es2019/factories/encoding-error.js 4647var createEncodingError = () => new DOMException("", "EncodingError"); 4648
vendor: 1,504 bytes, lines 4649-4692
4649// node_modules/standardized-audio-context/build/es2019/factories/evaluate-source.js 4650var createEvaluateSource = (window3) => { 4651 return (source) => new Promise((resolve, reject) => { 4652 if (window3 === null) { 4653 reject(new SyntaxError()); 4654 return; 4655 } 4656 const head = window3.document.head; 4657 if (head === null) { 4658 reject(new SyntaxError()); 4659 } else { 4660 const script = window3.document.createElement("script"); 4661 const blob = new Blob([source], { type: "application/javascript" }); 4662 const url = URL.createObjectURL(blob); 4663 const originalOnErrorHandler = window3.onerror; 4664 const removeErrorEventListenerAndRevokeUrl = () => { 4665 window3.onerror = originalOnErrorHandler; 4666 URL.revokeObjectURL(url); 4667 }; 4668 window3.onerror = (message, src, lineno, colno, error) => { 4669 if (src === url || src === window3.location.href && lineno === 1 && colno === 1) { 4670 removeErrorEventListenerAndRevokeUrl(); 4671 reject(error); 4672 return false; 4673 } 4674 if (originalOnErrorHandler !== null) { 4675 return originalOnErrorHandler(message, src, lineno, colno, error); 4676 } 4677 }; 4678 script.onerror = () => { 4679 removeErrorEventListenerAndRevokeUrl(); 4680 reject(new SyntaxError()); 4681 }; 4682 script.onload = () => { 4683 removeErrorEventListenerAndRevokeUrl(); 4684 resolve(); 4685 }; 4686 script.src = url; 4687 script.type = "module"; 4688 head.appendChild(script); 4689 } 4690 }); 4691}; 4692
vendor: 1,214 bytes, lines 4693-4721
4693// node_modules/standardized-audio-context/build/es2019/factories/event-target-constructor.js 4694var createEventTargetConstructor = (wrapEventListener2) => { 4695 return class EventTarget { 4696 constructor(_nativeEventTarget) { 4697 this._nativeEventTarget = _nativeEventTarget; 4698 this._listeners = /* @__PURE__ */ new WeakMap(); 4699 } 4700 addEventListener(type, listener, options) { 4701 if (listener !== null) { 4702 let wrappedEventListener = this._listeners.get(listener); 4703 if (wrappedEventListener === void 0) { 4704 wrappedEventListener = wrapEventListener2(this, listener); 4705 if (typeof listener === "function") { 4706 this._listeners.set(listener, wrappedEventListener); 4707 } 4708 } 4709 this._nativeEventTarget.addEventListener(type, wrappedEventListener, options); 4710 } 4711 } 4712 dispatchEvent(event) { 4713 return this._nativeEventTarget.dispatchEvent(event); 4714 } 4715 removeEventListener(type, listener, options) { 4716 const wrappedEventListener = listener === null ? void 0 : this._listeners.get(listener); 4717 this._nativeEventTarget.removeEventListener(type, wrappedEventListener === void 0 ? null : wrappedEventListener, options); 4718 } 4719 }; 4720}; 4721
vendor: 682 bytes, lines 4722-4749
4722// node_modules/standardized-audio-context/build/es2019/factories/expose-current-frame-and-current-time.js 4723var createExposeCurrentFrameAndCurrentTime = (window3) => { 4724 return (currentTime, sampleRate, fn) => { 4725 Object.defineProperties(window3, { 4726 currentFrame: { 4727 configurable: true, 4728 get() { 4729 return Math.round(currentTime * sampleRate); 4730 } 4731 }, 4732 currentTime: { 4733 configurable: true, 4734 get() { 4735 return currentTime; 4736 } 4737 } 4738 }); 4739 try { 4740 return fn(); 4741 } finally { 4742 if (window3 !== null) { 4743 delete window3.currentFrame; 4744 delete window3.currentTime; 4745 } 4746 } 4747 }; 4748}; 4749
vendor: 355 bytes, lines 4750-4763
4750// node_modules/standardized-audio-context/build/es2019/factories/fetch-source.js 4751var createFetchSource = (createAbortError2) => { 4752 return async (url) => { 4753 try { 4754 const response = await fetch(url); 4755 if (response.ok) { 4756 return [await response.text(), response.url]; 4757 } 4758 } catch { 4759 } 4760 throw createAbortError2(); 4761 }; 4762}; 4763
vendor: 1,093 bytes, lines 4764-4787
4764// node_modules/standardized-audio-context/build/es2019/factories/gain-node-constructor.js 4765var DEFAULT_OPTIONS12 = { 4766 channelCount: 2, 4767 channelCountMode: "max", 4768 channelInterpretation: "speakers", 4769 gain: 1 4770}; 4771var createGainNodeConstructor = (audioNodeConstructor2, createAudioParam2, createGainNodeRenderer2, createNativeGainNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 4772 return class GainNode extends audioNodeConstructor2 { 4773 constructor(context2, options) { 4774 const nativeContext = getNativeContext2(context2); 4775 const mergedOptions = { ...DEFAULT_OPTIONS12, ...options }; 4776 const nativeGainNode = createNativeGainNode2(nativeContext, mergedOptions); 4777 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4778 const gainNodeRenderer = isOffline ? createGainNodeRenderer2() : null; 4779 super(context2, false, nativeGainNode, gainNodeRenderer); 4780 this._gain = createAudioParam2(this, isOffline, nativeGainNode.gain, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 4781 } 4782 get gain() { 4783 return this._gain; 4784 } 4785 }; 4786}; 4787
vendor: 1,786 bytes, lines 4788-4824
4788// node_modules/standardized-audio-context/build/es2019/factories/gain-node-renderer-factory.js 4789var createGainNodeRendererFactory = (connectAudioParam2, createNativeGainNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 4790 return () => { 4791 const renderedNativeGainNodes = /* @__PURE__ */ new WeakMap(); 4792 const createGainNode = async (proxy, nativeOfflineAudioContext) => { 4793 let nativeGainNode = getNativeAudioNode2(proxy); 4794 const nativeGainNodeIsOwnedByContext = isOwnedByContext(nativeGainNode, nativeOfflineAudioContext); 4795 if (!nativeGainNodeIsOwnedByContext) { 4796 const options = { 4797 channelCount: nativeGainNode.channelCount, 4798 channelCountMode: nativeGainNode.channelCountMode, 4799 channelInterpretation: nativeGainNode.channelInterpretation, 4800 gain: nativeGainNode.gain.value 4801 }; 4802 nativeGainNode = createNativeGainNode2(nativeOfflineAudioContext, options); 4803 } 4804 renderedNativeGainNodes.set(nativeOfflineAudioContext, nativeGainNode); 4805 if (!nativeGainNodeIsOwnedByContext) { 4806 await renderAutomation2(nativeOfflineAudioContext, proxy.gain, nativeGainNode.gain); 4807 } else { 4808 await connectAudioParam2(nativeOfflineAudioContext, proxy.gain, nativeGainNode.gain); 4809 } 4810 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeGainNode); 4811 return nativeGainNode; 4812 }; 4813 return { 4814 render(proxy, nativeOfflineAudioContext) { 4815 const renderedNativeGainNode = renderedNativeGainNodes.get(nativeOfflineAudioContext); 4816 if (renderedNativeGainNode !== void 0) { 4817 return Promise.resolve(renderedNativeGainNode); 4818 } 4819 return createGainNode(proxy, nativeOfflineAudioContext); 4820 } 4821 }; 4822 }; 4823}; 4824
vendor: 327 bytes, lines 4825-4829
4825// node_modules/standardized-audio-context/build/es2019/factories/get-active-audio-worklet-node-inputs.js 4826var createGetActiveAudioWorkletNodeInputs = (activeAudioWorkletNodeInputsStore2, getValueForKey2) => { 4827 return (nativeAudioWorkletNode) => getValueForKey2(activeAudioWorkletNodeInputsStore2, nativeAudioWorkletNode); 4828}; 4829
vendor: 451 bytes, lines 4830-4840
4830// node_modules/standardized-audio-context/build/es2019/factories/get-audio-node-renderer.js 4831var createGetAudioNodeRenderer = (getAudioNodeConnections2) => { 4832 return (audioNode) => { 4833 const audioNodeConnections = getAudioNodeConnections2(audioNode); 4834 if (audioNodeConnections.renderer === null) { 4835 throw new Error("Missing the renderer of the given AudioNode in the audio graph."); 4836 } 4837 return audioNodeConnections.renderer; 4838 }; 4839}; 4840
vendor: 298 bytes, lines 4841-4848
4841// node_modules/standardized-audio-context/build/es2019/factories/get-audio-node-tail-time.js 4842var createGetAudioNodeTailTime = (audioNodeTailTimeStore2) => { 4843 return (audioNode) => { 4844 var _a; 4845 return (_a = audioNodeTailTimeStore2.get(audioNode)) !== null && _a !== void 0 ? _a : 0; 4846 }; 4847}; 4848
vendor: 461 bytes, lines 4849-4859
4849// node_modules/standardized-audio-context/build/es2019/factories/get-audio-param-renderer.js 4850var createGetAudioParamRenderer = (getAudioParamConnections2) => { 4851 return (audioParam) => { 4852 const audioParamConnections = getAudioParamConnections2(audioParam); 4853 if (audioParamConnections.renderer === null) { 4854 throw new Error("Missing the renderer of the given AudioParam in the audio graph."); 4855 } 4856 return audioParamConnections.renderer; 4857 }; 4858}; 4859
vendor: 284 bytes, lines 4860-4866
4860// node_modules/standardized-audio-context/build/es2019/factories/get-backup-offline-audio-context.js 4861var createGetBackupOfflineAudioContext = (backupOfflineAudioContextStore2) => { 4862 return (nativeContext) => { 4863 return backupOfflineAudioContextStore2.get(nativeContext); 4864 }; 4865}; 4866
vendor: 169 bytes, lines 4867-4869
4867// node_modules/standardized-audio-context/build/es2019/factories/invalid-state-error.js 4868var createInvalidStateError = () => new DOMException("", "InvalidStateError"); 4869
vendor: 332 bytes, lines 4870-4880
4870// node_modules/standardized-audio-context/build/es2019/factories/get-native-context.js 4871var createGetNativeContext = (contextStore) => { 4872 return (context2) => { 4873 const nativeContext = contextStore.get(context2); 4874 if (nativeContext === void 0) { 4875 throw createInvalidStateError(); 4876 } 4877 return nativeContext; 4878 }; 4879}; 4880
vendor: 811 bytes, lines 4881-4896
4881// node_modules/standardized-audio-context/build/es2019/factories/get-or-create-backup-offline-audio-context.js 4882var createGetOrCreateBackupOfflineAudioContext = (backupOfflineAudioContextStore2, nativeOfflineAudioContextConstructor2) => { 4883 return (nativeContext) => { 4884 let backupOfflineAudioContext = backupOfflineAudioContextStore2.get(nativeContext); 4885 if (backupOfflineAudioContext !== void 0) { 4886 return backupOfflineAudioContext; 4887 } 4888 if (nativeOfflineAudioContextConstructor2 === null) { 4889 throw new Error("Missing the native OfflineAudioContext constructor."); 4890 } 4891 backupOfflineAudioContext = new nativeOfflineAudioContextConstructor2(1, 1, 44100); 4892 backupOfflineAudioContextStore2.set(nativeContext, backupOfflineAudioContext); 4893 return backupOfflineAudioContext; 4894 }; 4895}; 4896
vendor: 486 bytes, lines 4897-4907
4897// node_modules/standardized-audio-context/build/es2019/factories/get-unrendered-audio-worklet-nodes.js 4898var createGetUnrenderedAudioWorkletNodes = (unrenderedAudioWorkletNodeStore2) => { 4899 return (nativeContext) => { 4900 const unrenderedAudioWorkletNodes = unrenderedAudioWorkletNodeStore2.get(nativeContext); 4901 if (unrenderedAudioWorkletNodes === void 0) { 4902 throw new Error("The context has no set of AudioWorkletNodes."); 4903 } 4904 return unrenderedAudioWorkletNodes; 4905 }; 4906}; 4907
vendor: 172 bytes, lines 4908-4910
4908// node_modules/standardized-audio-context/build/es2019/factories/invalid-access-error.js 4909var createInvalidAccessError = () => new DOMException("", "InvalidAccessError"); 4910
vendor: 656 bytes, lines 4911-4922
4911// node_modules/standardized-audio-context/build/es2019/helpers/wrap-iir-filter-node-get-frequency-response-method.js 4912var wrapIIRFilterNodeGetFrequencyResponseMethod = (nativeIIRFilterNode) => { 4913 nativeIIRFilterNode.getFrequencyResponse = /* @__PURE__ */ ((getFrequencyResponse) => { 4914 return (frequencyHz, magResponse, phaseResponse) => { 4915 if (frequencyHz.length !== magResponse.length || magResponse.length !== phaseResponse.length) { 4916 throw createInvalidAccessError(); 4917 } 4918 return getFrequencyResponse.call(nativeIIRFilterNode, frequencyHz, magResponse, phaseResponse); 4919 }; 4920 })(nativeIIRFilterNode.getFrequencyResponse); 4921}; 4922
vendor: 1,393 bytes, lines 4923-4947
4923// node_modules/standardized-audio-context/build/es2019/factories/iir-filter-node-constructor.js 4924var DEFAULT_OPTIONS13 = { 4925 channelCount: 2, 4926 channelCountMode: "max", 4927 channelInterpretation: "speakers" 4928}; 4929var createIIRFilterNodeConstructor = (audioNodeConstructor2, createNativeIIRFilterNode2, createIIRFilterNodeRenderer2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 4930 return class IIRFilterNode extends audioNodeConstructor2 { 4931 constructor(context2, options) { 4932 const nativeContext = getNativeContext2(context2); 4933 const isOffline = isNativeOfflineAudioContext2(nativeContext); 4934 const mergedOptions = { ...DEFAULT_OPTIONS13, ...options }; 4935 const nativeIIRFilterNode = createNativeIIRFilterNode2(nativeContext, isOffline ? null : context2.baseLatency, mergedOptions); 4936 const iirFilterNodeRenderer = isOffline ? createIIRFilterNodeRenderer2(mergedOptions.feedback, mergedOptions.feedforward) : null; 4937 super(context2, false, nativeIIRFilterNode, iirFilterNodeRenderer); 4938 wrapIIRFilterNodeGetFrequencyResponseMethod(nativeIIRFilterNode); 4939 this._nativeIIRFilterNode = nativeIIRFilterNode; 4940 setAudioNodeTailTime2(this, 1); 4941 } 4942 getFrequencyResponse(frequencyHz, magResponse, phaseResponse) { 4943 return this._nativeIIRFilterNode.getFrequencyResponse(frequencyHz, magResponse, phaseResponse); 4944 } 4945 }; 4946}; 4947
vendor: 922 bytes, lines 4948-4972
4948// node_modules/standardized-audio-context/build/es2019/helpers/filter-buffer.js 4949var filterBuffer = (feedback, feedbackLength, feedforward, feedforwardLength, minLength, xBuffer, yBuffer, bufferIndex, bufferLength, input, output) => { 4950 const inputLength = input.length; 4951 let i = bufferIndex; 4952 for (let j = 0; j < inputLength; j += 1) { 4953 let y = feedforward[0] * input[j]; 4954 for (let k = 1; k < minLength; k += 1) { 4955 const x = i - k & bufferLength - 1; 4956 y += feedforward[k] * xBuffer[x]; 4957 y -= feedback[k] * yBuffer[x]; 4958 } 4959 for (let k = minLength; k < feedforwardLength; k += 1) { 4960 y += feedforward[k] * xBuffer[i - k & bufferLength - 1]; 4961 } 4962 for (let k = minLength; k < feedbackLength; k += 1) { 4963 y -= feedback[k] * yBuffer[i - k & bufferLength - 1]; 4964 } 4965 xBuffer[i] = input[j]; 4966 yBuffer[i] = y; 4967 i = i + 1 & bufferLength - 1; 4968 output[j] = y; 4969 } 4970 return i; 4971}; 4972
vendor: 4,697 bytes, lines 4973-5062
4973// node_modules/standardized-audio-context/build/es2019/factories/iir-filter-node-renderer-factory.js 4974var filterFullBuffer = (renderedBuffer, nativeOfflineAudioContext, feedback, feedforward) => { 4975 const convertedFeedback = feedback instanceof Float64Array ? feedback : new Float64Array(feedback); 4976 const convertedFeedforward = feedforward instanceof Float64Array ? feedforward : new Float64Array(feedforward); 4977 const feedbackLength = convertedFeedback.length; 4978 const feedforwardLength = convertedFeedforward.length; 4979 const minLength = Math.min(feedbackLength, feedforwardLength); 4980 if (convertedFeedback[0] !== 1) { 4981 for (let i = 0; i < feedbackLength; i += 1) { 4982 convertedFeedforward[i] /= convertedFeedback[0]; 4983 } 4984 for (let i = 1; i < feedforwardLength; i += 1) { 4985 convertedFeedback[i] /= convertedFeedback[0]; 4986 } 4987 } 4988 const bufferLength = 32; 4989 const xBuffer = new Float32Array(bufferLength); 4990 const yBuffer = new Float32Array(bufferLength); 4991 const filteredBuffer = nativeOfflineAudioContext.createBuffer(renderedBuffer.numberOfChannels, renderedBuffer.length, renderedBuffer.sampleRate); 4992 const numberOfChannels = renderedBuffer.numberOfChannels; 4993 for (let i = 0; i < numberOfChannels; i += 1) { 4994 const input = renderedBuffer.getChannelData(i); 4995 const output = filteredBuffer.getChannelData(i); 4996 xBuffer.fill(0); 4997 yBuffer.fill(0); 4998 filterBuffer(convertedFeedback, feedbackLength, convertedFeedforward, feedforwardLength, minLength, xBuffer, yBuffer, 0, bufferLength, input, output); 4999 } 5000 return filteredBuffer; 5001}; 5002var createIIRFilterNodeRendererFactory = (createNativeAudioBufferSourceNode2, getNativeAudioNode2, nativeOfflineAudioContextConstructor2, renderInputsOfAudioNode2, renderNativeOfflineAudioContext2) => { 5003 return (feedback, feedforward) => { 5004 const renderedNativeAudioNodes = /* @__PURE__ */ new WeakMap(); 5005 let filteredBufferPromise = null; 5006 const createAudioNode = async (proxy, nativeOfflineAudioContext) => { 5007 let nativeAudioBufferSourceNode = null; 5008 let nativeIIRFilterNode = getNativeAudioNode2(proxy); 5009 const nativeIIRFilterNodeIsOwnedByContext = isOwnedByContext(nativeIIRFilterNode, nativeOfflineAudioContext); 5010 if (nativeOfflineAudioContext.createIIRFilter === void 0) { 5011 nativeAudioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeOfflineAudioContext, { 5012 buffer: null, 5013 channelCount: 2, 5014 channelCountMode: "max", 5015 channelInterpretation: "speakers", 5016 loop: false, 5017 loopEnd: 0, 5018 loopStart: 0, 5019 playbackRate: 1 5020 }); 5021 } else if (!nativeIIRFilterNodeIsOwnedByContext) { 5022 nativeIIRFilterNode = nativeOfflineAudioContext.createIIRFilter(feedforward, feedback); 5023 } 5024 renderedNativeAudioNodes.set(nativeOfflineAudioContext, nativeAudioBufferSourceNode === null ? nativeIIRFilterNode : nativeAudioBufferSourceNode); 5025 if (nativeAudioBufferSourceNode !== null) { 5026 if (filteredBufferPromise === null) { 5027 if (nativeOfflineAudioContextConstructor2 === null) { 5028 throw new Error("Missing the native OfflineAudioContext constructor."); 5029 } 5030 const partialOfflineAudioContext = new nativeOfflineAudioContextConstructor2( 5031 // Bug #47: The AudioDestinationNode in Safari gets not initialized correctly. 5032 proxy.context.destination.channelCount, 5033 // Bug #17: Safari does not yet expose the length. 5034 proxy.context.length, 5035 nativeOfflineAudioContext.sampleRate 5036 ); 5037 filteredBufferPromise = (async () => { 5038 await renderInputsOfAudioNode2(proxy, partialOfflineAudioContext, partialOfflineAudioContext.destination); 5039 const renderedBuffer = await renderNativeOfflineAudioContext2(partialOfflineAudioContext); 5040 return filterFullBuffer(renderedBuffer, nativeOfflineAudioContext, feedback, feedforward); 5041 })(); 5042 } 5043 const filteredBuffer = await filteredBufferPromise; 5044 nativeAudioBufferSourceNode.buffer = filteredBuffer; 5045 nativeAudioBufferSourceNode.start(0); 5046 return nativeAudioBufferSourceNode; 5047 } 5048 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeIIRFilterNode); 5049 return nativeIIRFilterNode; 5050 }; 5051 return { 5052 render(proxy, nativeOfflineAudioContext) { 5053 const renderedNativeAudioNode = renderedNativeAudioNodes.get(nativeOfflineAudioContext); 5054 if (renderedNativeAudioNode !== void 0) { 5055 return Promise.resolve(renderedNativeAudioNode); 5056 } 5057 return createAudioNode(proxy, nativeOfflineAudioContext); 5058 } 5059 }; 5060 }; 5061}; 5062
vendor: 1,336 bytes, lines 5063-5089
5063// node_modules/standardized-audio-context/build/es2019/factories/increment-cycle-counter-factory.js 5064var createIncrementCycleCounterFactory = (cycleCounters, disconnectNativeAudioNodeFromNativeAudioNode2, getAudioNodeConnections2, getNativeAudioNode2, getNativeAudioParam2, isActiveAudioNode2) => { 5065 return (isOffline) => { 5066 return (audioNode, count) => { 5067 const cycleCounter = cycleCounters.get(audioNode); 5068 if (cycleCounter === void 0) { 5069 if (!isOffline && isActiveAudioNode2(audioNode)) { 5070 const nativeSourceAudioNode = getNativeAudioNode2(audioNode); 5071 const { outputs } = getAudioNodeConnections2(audioNode); 5072 for (const output of outputs) { 5073 if (isAudioNodeOutputConnection(output)) { 5074 const nativeDestinationAudioNode = getNativeAudioNode2(output[0]); 5075 disconnectNativeAudioNodeFromNativeAudioNode2(nativeSourceAudioNode, nativeDestinationAudioNode, output[1], output[2]); 5076 } else { 5077 const nativeDestinationAudioParam = getNativeAudioParam2(output[0]); 5078 nativeSourceAudioNode.disconnect(nativeDestinationAudioParam, output[1]); 5079 } 5080 } 5081 } 5082 cycleCounters.set(audioNode, count); 5083 } else { 5084 cycleCounters.set(audioNode, cycleCounter + count); 5085 } 5086 }; 5087 }; 5088}; 5089
vendor: 335 bytes, lines 5090-5097
5090// node_modules/standardized-audio-context/build/es2019/factories/is-any-audio-context.js 5091var createIsAnyAudioContext = (contextStore, isNativeAudioContext2) => { 5092 return (anything) => { 5093 const nativeContext = contextStore.get(anything); 5094 return isNativeAudioContext2(nativeContext) || isNativeAudioContext2(anything); 5095 }; 5096}; 5097
vendor: 245 bytes, lines 5098-5102
5098// node_modules/standardized-audio-context/build/es2019/factories/is-any-audio-node.js 5099var createIsAnyAudioNode = (audioNodeStore, isNativeAudioNode3) => { 5100 return (anything) => audioNodeStore.has(anything) || isNativeAudioNode3(anything); 5101}; 5102
vendor: 251 bytes, lines 5103-5107
5103// node_modules/standardized-audio-context/build/es2019/factories/is-any-audio-param.js 5104var createIsAnyAudioParam = (audioParamStore, isNativeAudioParam2) => { 5105 return (anything) => audioParamStore.has(anything) || isNativeAudioParam2(anything); 5106}; 5107
vendor: 371 bytes, lines 5108-5115
5108// node_modules/standardized-audio-context/build/es2019/factories/is-any-offline-audio-context.js 5109var createIsAnyOfflineAudioContext = (contextStore, isNativeOfflineAudioContext2) => { 5110 return (anything) => { 5111 const nativeContext = contextStore.get(anything); 5112 return isNativeOfflineAudioContext2(nativeContext) || isNativeOfflineAudioContext2(anything); 5113 }; 5114}; 5115
vendor: 304 bytes, lines 5116-5122
5116// node_modules/standardized-audio-context/build/es2019/factories/is-native-audio-context.js 5117var createIsNativeAudioContext = (nativeAudioContextConstructor2) => { 5118 return (anything) => { 5119 return nativeAudioContextConstructor2 !== null && anything instanceof nativeAudioContextConstructor2; 5120 }; 5121}; 5122
vendor: 282 bytes, lines 5123-5129
5123// node_modules/standardized-audio-context/build/es2019/factories/is-native-audio-node.js 5124var createIsNativeAudioNode = (window3) => { 5125 return (anything) => { 5126 return window3 !== null && typeof window3.AudioNode === "function" && anything instanceof window3.AudioNode; 5127 }; 5128}; 5129
vendor: 286 bytes, lines 5130-5136
5130// node_modules/standardized-audio-context/build/es2019/factories/is-native-audio-param.js 5131var createIsNativeAudioParam = (window3) => { 5132 return (anything) => { 5133 return window3 !== null && typeof window3.AudioParam === "function" && anything instanceof window3.AudioParam; 5134 }; 5135}; 5136
vendor: 294 bytes, lines 5137-5143
5137// node_modules/standardized-audio-context/build/es2019/factories/is-native-context.js 5138var createIsNativeContext = (isNativeAudioContext2, isNativeOfflineAudioContext2) => { 5139 return (anything) => { 5140 return isNativeAudioContext2(anything) || isNativeOfflineAudioContext2(anything); 5141 }; 5142}; 5143
vendor: 340 bytes, lines 5144-5150
5144// node_modules/standardized-audio-context/build/es2019/factories/is-native-offline-audio-context.js 5145var createIsNativeOfflineAudioContext = (nativeOfflineAudioContextConstructor2) => { 5146 return (anything) => { 5147 return nativeOfflineAudioContextConstructor2 !== null && anything instanceof nativeOfflineAudioContextConstructor2; 5148 }; 5149}; 5150
vendor: 174 bytes, lines 5151-5153
5151// node_modules/standardized-audio-context/build/es2019/factories/is-secure-context.js 5152var createIsSecureContext = (window3) => window3 !== null && window3.isSecureContext; 5153
vendor: 925 bytes, lines 5154-5171
5154// node_modules/standardized-audio-context/build/es2019/factories/media-element-audio-source-node-constructor.js 5155var createMediaElementAudioSourceNodeConstructor = (audioNodeConstructor2, createNativeMediaElementAudioSourceNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 5156 return class MediaElementAudioSourceNode extends audioNodeConstructor2 { 5157 constructor(context2, options) { 5158 const nativeContext = getNativeContext2(context2); 5159 const nativeMediaElementAudioSourceNode = createNativeMediaElementAudioSourceNode2(nativeContext, options); 5160 if (isNativeOfflineAudioContext2(nativeContext)) { 5161 throw TypeError(); 5162 } 5163 super(context2, true, nativeMediaElementAudioSourceNode, null); 5164 this._nativeMediaElementAudioSourceNode = nativeMediaElementAudioSourceNode; 5165 } 5166 get mediaElement() { 5167 return this._nativeMediaElementAudioSourceNode.mediaElement; 5168 } 5169 }; 5170}; 5171
vendor: 1,146 bytes, lines 5172-5195
5172// node_modules/standardized-audio-context/build/es2019/factories/media-stream-audio-destination-node-constructor.js 5173var DEFAULT_OPTIONS14 = { 5174 channelCount: 2, 5175 channelCountMode: "explicit", 5176 channelInterpretation: "speakers" 5177}; 5178var createMediaStreamAudioDestinationNodeConstructor = (audioNodeConstructor2, createNativeMediaStreamAudioDestinationNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 5179 return class MediaStreamAudioDestinationNode extends audioNodeConstructor2 { 5180 constructor(context2, options) { 5181 const nativeContext = getNativeContext2(context2); 5182 if (isNativeOfflineAudioContext2(nativeContext)) { 5183 throw new TypeError(); 5184 } 5185 const mergedOptions = { ...DEFAULT_OPTIONS14, ...options }; 5186 const nativeMediaStreamAudioDestinationNode = createNativeMediaStreamAudioDestinationNode2(nativeContext, mergedOptions); 5187 super(context2, false, nativeMediaStreamAudioDestinationNode, null); 5188 this._nativeMediaStreamAudioDestinationNode = nativeMediaStreamAudioDestinationNode; 5189 } 5190 get stream() { 5191 return this._nativeMediaStreamAudioDestinationNode.stream; 5192 } 5193 }; 5194}; 5195
vendor: 917 bytes, lines 5196-5213
5196// node_modules/standardized-audio-context/build/es2019/factories/media-stream-audio-source-node-constructor.js 5197var createMediaStreamAudioSourceNodeConstructor = (audioNodeConstructor2, createNativeMediaStreamAudioSourceNode2, getNativeContext2, isNativeOfflineAudioContext2) => { 5198 return class MediaStreamAudioSourceNode extends audioNodeConstructor2 { 5199 constructor(context2, options) { 5200 const nativeContext = getNativeContext2(context2); 5201 const nativeMediaStreamAudioSourceNode = createNativeMediaStreamAudioSourceNode2(nativeContext, options); 5202 if (isNativeOfflineAudioContext2(nativeContext)) { 5203 throw new TypeError(); 5204 } 5205 super(context2, true, nativeMediaStreamAudioSourceNode, null); 5206 this._nativeMediaStreamAudioSourceNode = nativeMediaStreamAudioSourceNode; 5207 } 5208 get mediaStream() { 5209 return this._nativeMediaStreamAudioSourceNode.mediaStream; 5210 } 5211 }; 5212}; 5213
vendor: 651 bytes, lines 5214-5224
5214// node_modules/standardized-audio-context/build/es2019/factories/media-stream-track-audio-source-node-constructor.js 5215var createMediaStreamTrackAudioSourceNodeConstructor = (audioNodeConstructor2, createNativeMediaStreamTrackAudioSourceNode2, getNativeContext2) => { 5216 return class MediaStreamTrackAudioSourceNode extends audioNodeConstructor2 { 5217 constructor(context2, options) { 5218 const nativeContext = getNativeContext2(context2); 5219 const nativeMediaStreamTrackAudioSourceNode = createNativeMediaStreamTrackAudioSourceNode2(nativeContext, options); 5220 super(context2, true, nativeMediaStreamTrackAudioSourceNode, null); 5221 } 5222 }; 5223}; 5224
vendor: 4,642 bytes, lines 5225-5338
5225// node_modules/standardized-audio-context/build/es2019/factories/minimal-audio-context-constructor.js 5226var createMinimalAudioContextConstructor = (createInvalidStateError2, createNotSupportedError2, createUnknownError2, minimalBaseAudioContextConstructor2, nativeAudioContextConstructor2) => { 5227 return class MinimalAudioContext extends minimalBaseAudioContextConstructor2 { 5228 constructor(options = {}) { 5229 if (nativeAudioContextConstructor2 === null) { 5230 throw new Error("Missing the native AudioContext constructor."); 5231 } 5232 let nativeAudioContext; 5233 try { 5234 nativeAudioContext = new nativeAudioContextConstructor2(options); 5235 } catch (err) { 5236 if (err.code === 12 && err.message === "sampleRate is not in range") { 5237 throw createNotSupportedError2(); 5238 } 5239 throw err; 5240 } 5241 if (nativeAudioContext === null) { 5242 throw createUnknownError2(); 5243 } 5244 if (!isValidLatencyHint(options.latencyHint)) { 5245 throw new TypeError(`The provided value '${options.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`); 5246 } 5247 if (options.sampleRate !== void 0 && nativeAudioContext.sampleRate !== options.sampleRate) { 5248 throw createNotSupportedError2(); 5249 } 5250 super(nativeAudioContext, 2); 5251 const { latencyHint } = options; 5252 const { sampleRate } = nativeAudioContext; 5253 this._baseLatency = typeof nativeAudioContext.baseLatency === "number" ? nativeAudioContext.baseLatency : latencyHint === "balanced" ? 512 / sampleRate : latencyHint === "interactive" || latencyHint === void 0 ? 256 / sampleRate : latencyHint === "playback" ? 1024 / sampleRate : ( 5254 /* 5255 * @todo The min (256) and max (16384) values are taken from the allowed bufferSize values of a 5256 * ScriptProcessorNode. 5257 */ 5258 Math.max(2, Math.min(128, Math.round(latencyHint * sampleRate / 128))) * 128 / sampleRate 5259 ); 5260 this._nativeAudioContext = nativeAudioContext; 5261 if (nativeAudioContextConstructor2.name === "webkitAudioContext") { 5262 this._nativeGainNode = nativeAudioContext.createGain(); 5263 this._nativeOscillatorNode = nativeAudioContext.createOscillator(); 5264 this._nativeGainNode.gain.value = 1e-37; 5265 this._nativeOscillatorNode.connect(this._nativeGainNode).connect(nativeAudioContext.destination); 5266 this._nativeOscillatorNode.start(); 5267 } else { 5268 this._nativeGainNode = null; 5269 this._nativeOscillatorNode = null; 5270 } 5271 this._state = null; 5272 if (nativeAudioContext.state === "running") { 5273 this._state = "suspended"; 5274 const revokeState = () => { 5275 if (this._state === "suspended") { 5276 this._state = null; 5277 } 5278 nativeAudioContext.removeEventListener("statechange", revokeState); 5279 }; 5280 nativeAudioContext.addEventListener("statechange", revokeState); 5281 } 5282 } 5283 get baseLatency() { 5284 return this._baseLatency; 5285 } 5286 get state() { 5287 return this._state !== null ? this._state : this._nativeAudioContext.state; 5288 } 5289 close() { 5290 if (this.state === "closed") { 5291 return this._nativeAudioContext.close().then(() => { 5292 throw createInvalidStateError2(); 5293 }); 5294 } 5295 if (this._state === "suspended") { 5296 this._state = null; 5297 } 5298 return this._nativeAudioContext.close().then(() => { 5299 if (this._nativeGainNode !== null && this._nativeOscillatorNode !== null) { 5300 this._nativeOscillatorNode.stop(); 5301 this._nativeGainNode.disconnect(); 5302 this._nativeOscillatorNode.disconnect(); 5303 } 5304 deactivateAudioGraph(this); 5305 }); 5306 } 5307 resume() { 5308 if (this._state === "suspended") { 5309 return new Promise((resolve, reject) => { 5310 const resolvePromise = () => { 5311 this._nativeAudioContext.removeEventListener("statechange", resolvePromise); 5312 if (this._nativeAudioContext.state === "running") { 5313 resolve(); 5314 } else { 5315 this.resume().then(resolve, reject); 5316 } 5317 }; 5318 this._nativeAudioContext.addEventListener("statechange", resolvePromise); 5319 }); 5320 } 5321 return this._nativeAudioContext.resume().catch((err) => { 5322 if (err === void 0 || err.code === 15) { 5323 throw createInvalidStateError2(); 5324 } 5325 throw err; 5326 }); 5327 } 5328 suspend() { 5329 return this._nativeAudioContext.suspend().catch((err) => { 5330 if (err === void 0) { 5331 throw createInvalidStateError2(); 5332 } 5333 throw err; 5334 }); 5335 } 5336 }; 5337}; 5338
vendor: 1,724 bytes, lines 5339-5379
5339// node_modules/standardized-audio-context/build/es2019/factories/minimal-base-audio-context-constructor.js 5340var createMinimalBaseAudioContextConstructor = (audioDestinationNodeConstructor2, createAudioListener2, eventTargetConstructor2, isNativeOfflineAudioContext2, unrenderedAudioWorkletNodeStore2, wrapEventListener2) => { 5341 return class MinimalBaseAudioContext extends eventTargetConstructor2 { 5342 constructor(_nativeContext, numberOfChannels) { 5343 super(_nativeContext); 5344 this._nativeContext = _nativeContext; 5345 CONTEXT_STORE.set(this, _nativeContext); 5346 if (isNativeOfflineAudioContext2(_nativeContext)) { 5347 unrenderedAudioWorkletNodeStore2.set(_nativeContext, /* @__PURE__ */ new Set()); 5348 } 5349 this._destination = new audioDestinationNodeConstructor2(this, numberOfChannels); 5350 this._listener = createAudioListener2(this, _nativeContext); 5351 this._onstatechange = null; 5352 } 5353 get currentTime() { 5354 return this._nativeContext.currentTime; 5355 } 5356 get destination() { 5357 return this._destination; 5358 } 5359 get listener() { 5360 return this._listener; 5361 } 5362 get onstatechange() { 5363 return this._onstatechange; 5364 } 5365 set onstatechange(value) { 5366 const wrappedListener = typeof value === "function" ? wrapEventListener2(this, value) : null; 5367 this._nativeContext.onstatechange = wrappedListener; 5368 const nativeOnStateChange = this._nativeContext.onstatechange; 5369 this._onstatechange = nativeOnStateChange !== null && nativeOnStateChange === wrappedListener ? value : nativeOnStateChange; 5370 } 5371 get sampleRate() { 5372 return this._nativeContext.sampleRate; 5373 } 5374 get state() { 5375 return this._nativeContext.state; 5376 } 5377 }; 5378}; 5379
vendor: 505 bytes, lines 5380-5396
5380// node_modules/standardized-audio-context/build/es2019/helpers/test-promise-support.js 5381var testPromiseSupport = (nativeContext) => { 5382 const uint32Array = new Uint32Array([1179011410, 40, 1163280727, 544501094, 16, 131073, 44100, 176400, 1048580, 1635017060, 4, 0]); 5383 try { 5384 const promise = nativeContext.decodeAudioData(uint32Array.buffer, () => { 5385 }); 5386 if (promise === void 0) { 5387 return false; 5388 } 5389 promise.catch(() => { 5390 }); 5391 return true; 5392 } catch { 5393 } 5394 return false; 5395}; 5396
vendor: 2,424 bytes, lines 5397-5456
5397// node_modules/standardized-audio-context/build/es2019/factories/minimal-offline-audio-context-constructor.js 5398var DEFAULT_OPTIONS15 = { 5399 numberOfChannels: 1 5400}; 5401var createMinimalOfflineAudioContextConstructor = (cacheTestResult2, createInvalidStateError2, createNativeOfflineAudioContext2, minimalBaseAudioContextConstructor2, startRendering2) => { 5402 return class MinimalOfflineAudioContext extends minimalBaseAudioContextConstructor2 { 5403 constructor(options) { 5404 const { length, numberOfChannels, sampleRate } = { ...DEFAULT_OPTIONS15, ...options }; 5405 const nativeOfflineAudioContext = createNativeOfflineAudioContext2(numberOfChannels, length, sampleRate); 5406 if (!cacheTestResult2(testPromiseSupport, () => testPromiseSupport(nativeOfflineAudioContext))) { 5407 nativeOfflineAudioContext.addEventListener("statechange", /* @__PURE__ */ (() => { 5408 let i = 0; 5409 const delayStateChangeEvent = (event) => { 5410 if (this._state === "running") { 5411 if (i > 0) { 5412 nativeOfflineAudioContext.removeEventListener("statechange", delayStateChangeEvent); 5413 event.stopImmediatePropagation(); 5414 this._waitForThePromiseToSettle(event); 5415 } else { 5416 i += 1; 5417 } 5418 } 5419 }; 5420 return delayStateChangeEvent; 5421 })()); 5422 } 5423 super(nativeOfflineAudioContext, numberOfChannels); 5424 this._length = length; 5425 this._nativeOfflineAudioContext = nativeOfflineAudioContext; 5426 this._state = null; 5427 } 5428 get length() { 5429 if (this._nativeOfflineAudioContext.length === void 0) { 5430 return this._length; 5431 } 5432 return this._nativeOfflineAudioContext.length; 5433 } 5434 get state() { 5435 return this._state === null ? this._nativeOfflineAudioContext.state : this._state; 5436 } 5437 startRendering() { 5438 if (this._state === "running") { 5439 return Promise.reject(createInvalidStateError2()); 5440 } 5441 this._state = "running"; 5442 return startRendering2(this.destination, this._nativeOfflineAudioContext).finally(() => { 5443 this._state = null; 5444 deactivateAudioGraph(this); 5445 }); 5446 } 5447 _waitForThePromiseToSettle(event) { 5448 if (this._state === null) { 5449 this._nativeOfflineAudioContext.dispatchEvent(event); 5450 } else { 5451 setTimeout(() => this._waitForThePromiseToSettle(event)); 5452 } 5453 } 5454 }; 5455}; 5456
vendor: 2,584 bytes, lines 5457-5514
5457// node_modules/standardized-audio-context/build/es2019/factories/monitor-connections.js 5458var createMonitorConnections = (insertElementInSet2, isNativeAudioNode3) => { 5459 return (nativeAudioNode, whenConnected, whenDisconnected) => { 5460 const connections = /* @__PURE__ */ new Set(); 5461 nativeAudioNode.connect = /* @__PURE__ */ ((connect2) => { 5462 return (destination, output = 0, input = 0) => { 5463 const wasDisconnected = connections.size === 0; 5464 if (isNativeAudioNode3(destination)) { 5465 connect2.call(nativeAudioNode, destination, output, input); 5466 insertElementInSet2(connections, [destination, output, input], (connection) => connection[0] === destination && connection[1] === output && connection[2] === input, true); 5467 if (wasDisconnected) { 5468 whenConnected(); 5469 } 5470 return destination; 5471 } 5472 connect2.call(nativeAudioNode, destination, output); 5473 insertElementInSet2(connections, [destination, output], (connection) => connection[0] === destination && connection[1] === output, true); 5474 if (wasDisconnected) { 5475 whenConnected(); 5476 } 5477 return; 5478 }; 5479 })(nativeAudioNode.connect); 5480 nativeAudioNode.disconnect = /* @__PURE__ */ ((disconnect2) => { 5481 return (destinationOrOutput, output, input) => { 5482 const wasConnected = connections.size > 0; 5483 if (destinationOrOutput === void 0) { 5484 disconnect2.apply(nativeAudioNode); 5485 connections.clear(); 5486 } else if (typeof destinationOrOutput === "number") { 5487 disconnect2.call(nativeAudioNode, destinationOrOutput); 5488 for (const connection of connections) { 5489 if (connection[1] === destinationOrOutput) { 5490 connections.delete(connection); 5491 } 5492 } 5493 } else { 5494 if (isNativeAudioNode3(destinationOrOutput)) { 5495 disconnect2.call(nativeAudioNode, destinationOrOutput, output, input); 5496 } else { 5497 disconnect2.call(nativeAudioNode, destinationOrOutput, output); 5498 } 5499 for (const connection of connections) { 5500 if (connection[0] === destinationOrOutput && (output === void 0 || connection[1] === output) && (input === void 0 || connection[2] === input)) { 5501 connections.delete(connection); 5502 } 5503 } 5504 } 5505 const isDisconnected = connections.size === 0; 5506 if (wasConnected && isDisconnected) { 5507 whenDisconnected(); 5508 } 5509 }; 5510 })(nativeAudioNode.disconnect); 5511 return nativeAudioNode; 5512 }; 5513}; 5514
vendor: 314 bytes, lines 5515-5522
5515// node_modules/standardized-audio-context/build/es2019/helpers/assign-native-audio-node-option.js 5516var assignNativeAudioNodeOption = (nativeAudioNode, options, option) => { 5517 const value = options[option]; 5518 if (value !== void 0 && value !== nativeAudioNode[option]) { 5519 nativeAudioNode[option] = value; 5520 } 5521}; 5522
vendor: 403 bytes, lines 5523-5529
5523// node_modules/standardized-audio-context/build/es2019/helpers/assign-native-audio-node-options.js 5524var assignNativeAudioNodeOptions = (nativeAudioNode, options) => { 5525 assignNativeAudioNodeOption(nativeAudioNode, options, "channelCount"); 5526 assignNativeAudioNodeOption(nativeAudioNode, options, "channelCountMode"); 5527 assignNativeAudioNodeOption(nativeAudioNode, options, "channelInterpretation"); 5528}; 5529
vendor: 290 bytes, lines 5530-5534
5530// node_modules/standardized-audio-context/build/es2019/helpers/test-analyser-node-get-float-time-domain-data-method-support.js 5531var testAnalyserNodeGetFloatTimeDomainDataMethodSupport = (nativeAnalyserNode) => { 5532 return typeof nativeAnalyserNode.getFloatTimeDomainData === "function"; 5533}; 5534
vendor: 601 bytes, lines 5535-5547
5535// node_modules/standardized-audio-context/build/es2019/helpers/wrap-analyser-node-get-float-time-domain-data-method.js 5536var wrapAnalyserNodeGetFloatTimeDomainDataMethod = (nativeAnalyserNode) => { 5537 nativeAnalyserNode.getFloatTimeDomainData = (array) => { 5538 const byteTimeDomainData = new Uint8Array(array.length); 5539 nativeAnalyserNode.getByteTimeDomainData(byteTimeDomainData); 5540 const length = Math.max(byteTimeDomainData.length, nativeAnalyserNode.fftSize); 5541 for (let i = 0; i < length; i += 1) { 5542 array[i] = (byteTimeDomainData[i] - 128) * 78125e-7; 5543 } 5544 return array; 5545 }; 5546}; 5547
vendor: 1,040 bytes, lines 5548-5566
5548// node_modules/standardized-audio-context/build/es2019/factories/native-analyser-node-factory.js 5549var createNativeAnalyserNodeFactory = (cacheTestResult2, createIndexSizeError2) => { 5550 return (nativeContext, options) => { 5551 const nativeAnalyserNode = nativeContext.createAnalyser(); 5552 assignNativeAudioNodeOptions(nativeAnalyserNode, options); 5553 if (!(options.maxDecibels > options.minDecibels)) { 5554 throw createIndexSizeError2(); 5555 } 5556 assignNativeAudioNodeOption(nativeAnalyserNode, options, "fftSize"); 5557 assignNativeAudioNodeOption(nativeAnalyserNode, options, "maxDecibels"); 5558 assignNativeAudioNodeOption(nativeAnalyserNode, options, "minDecibels"); 5559 assignNativeAudioNodeOption(nativeAnalyserNode, options, "smoothingTimeConstant"); 5560 if (!cacheTestResult2(testAnalyserNodeGetFloatTimeDomainDataMethodSupport, () => testAnalyserNodeGetFloatTimeDomainDataMethodSupport(nativeAnalyserNode))) { 5561 wrapAnalyserNodeGetFloatTimeDomainDataMethod(nativeAnalyserNode); 5562 } 5563 return nativeAnalyserNode; 5564 }; 5565}; 5566
vendor: 306 bytes, lines 5567-5577
5567// node_modules/standardized-audio-context/build/es2019/factories/native-audio-buffer-constructor.js 5568var createNativeAudioBufferConstructor = (window3) => { 5569 if (window3 === null) { 5570 return null; 5571 } 5572 if (window3.hasOwnProperty("AudioBuffer")) { 5573 return window3.AudioBuffer; 5574 } 5575 return null; 5576}; 5577
vendor: 362 bytes, lines 5578-5585
5578// node_modules/standardized-audio-context/build/es2019/helpers/assign-native-audio-node-audio-param-value.js 5579var assignNativeAudioNodeAudioParamValue = (nativeAudioNode, options, audioParam) => { 5580 const value = options[audioParam]; 5581 if (value !== void 0 && value !== nativeAudioNode[audioParam].value) { 5582 nativeAudioNode[audioParam].value = value; 5583 } 5584}; 5585
vendor: 593 bytes, lines 5586-5599
5586// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-buffer-source-node-start-method-consecutive-calls.js 5587var wrapAudioBufferSourceNodeStartMethodConsecutiveCalls = (nativeAudioBufferSourceNode) => { 5588 nativeAudioBufferSourceNode.start = /* @__PURE__ */ ((start2) => { 5589 let isScheduled = false; 5590 return (when = 0, offset = 0, duration) => { 5591 if (isScheduled) { 5592 throw createInvalidStateError(); 5593 } 5594 start2.call(nativeAudioBufferSourceNode, when, offset, duration); 5595 isScheduled = true; 5596 }; 5597 })(nativeAudioBufferSourceNode.start); 5598}; 5599
vendor: 645 bytes, lines 5600-5611
5600// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-scheduled-source-node-start-method-negative-parameters.js 5601var wrapAudioScheduledSourceNodeStartMethodNegativeParameters = (nativeAudioScheduledSourceNode) => { 5602 nativeAudioScheduledSourceNode.start = /* @__PURE__ */ ((start2) => { 5603 return (when = 0, offset = 0, duration) => { 5604 if (typeof duration === "number" && duration < 0 || offset < 0 || when < 0) { 5605 throw new RangeError("The parameters can't be negative."); 5606 } 5607 start2.call(nativeAudioScheduledSourceNode, when, offset, duration); 5608 }; 5609 })(nativeAudioScheduledSourceNode.start); 5610}; 5611
vendor: 534 bytes, lines 5612-5623
5612// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-scheduled-source-node-stop-method-negative-parameters.js 5613var wrapAudioScheduledSourceNodeStopMethodNegativeParameters = (nativeAudioScheduledSourceNode) => { 5614 nativeAudioScheduledSourceNode.stop = /* @__PURE__ */ ((stop) => { 5615 return (when = 0) => { 5616 if (when < 0) { 5617 throw new RangeError("The parameter can't be negative."); 5618 } 5619 stop.call(nativeAudioScheduledSourceNode, when); 5620 }; 5621 })(nativeAudioScheduledSourceNode.stop); 5622}; 5623
vendor: 3,138 bytes, lines 5624-5656
5624// node_modules/standardized-audio-context/build/es2019/factories/native-audio-buffer-source-node-factory.js 5625var createNativeAudioBufferSourceNodeFactory = (addSilentConnection2, cacheTestResult2, testAudioBufferSourceNodeStartMethodConsecutiveCallsSupport2, testAudioBufferSourceNodeStartMethodOffsetClampingSupport2, testAudioBufferSourceNodeStopMethodNullifiedBufferSupport2, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2, wrapAudioBufferSourceNodeStartMethodOffsetClampling, wrapAudioBufferSourceNodeStopMethodNullifiedBuffer, wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls2) => { 5626 return (nativeContext, options) => { 5627 const nativeAudioBufferSourceNode = nativeContext.createBufferSource(); 5628 assignNativeAudioNodeOptions(nativeAudioBufferSourceNode, options); 5629 assignNativeAudioNodeAudioParamValue(nativeAudioBufferSourceNode, options, "playbackRate"); 5630 assignNativeAudioNodeOption(nativeAudioBufferSourceNode, options, "buffer"); 5631 assignNativeAudioNodeOption(nativeAudioBufferSourceNode, options, "loop"); 5632 assignNativeAudioNodeOption(nativeAudioBufferSourceNode, options, "loopEnd"); 5633 assignNativeAudioNodeOption(nativeAudioBufferSourceNode, options, "loopStart"); 5634 if (!cacheTestResult2(testAudioBufferSourceNodeStartMethodConsecutiveCallsSupport2, () => testAudioBufferSourceNodeStartMethodConsecutiveCallsSupport2(nativeContext))) { 5635 wrapAudioBufferSourceNodeStartMethodConsecutiveCalls(nativeAudioBufferSourceNode); 5636 } 5637 if (!cacheTestResult2(testAudioBufferSourceNodeStartMethodOffsetClampingSupport2, () => testAudioBufferSourceNodeStartMethodOffsetClampingSupport2(nativeContext))) { 5638 wrapAudioBufferSourceNodeStartMethodOffsetClampling(nativeAudioBufferSourceNode); 5639 } 5640 if (!cacheTestResult2(testAudioBufferSourceNodeStopMethodNullifiedBufferSupport2, () => testAudioBufferSourceNodeStopMethodNullifiedBufferSupport2(nativeContext))) { 5641 wrapAudioBufferSourceNodeStopMethodNullifiedBuffer(nativeAudioBufferSourceNode, nativeContext); 5642 } 5643 if (!cacheTestResult2(testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2(nativeContext))) { 5644 wrapAudioScheduledSourceNodeStartMethodNegativeParameters(nativeAudioBufferSourceNode); 5645 } 5646 if (!cacheTestResult2(testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2, () => testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2(nativeContext))) { 5647 wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls2(nativeAudioBufferSourceNode, nativeContext); 5648 } 5649 if (!cacheTestResult2(testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2(nativeContext))) { 5650 wrapAudioScheduledSourceNodeStopMethodNegativeParameters(nativeAudioBufferSourceNode); 5651 } 5652 addSilentConnection2(nativeContext, nativeAudioBufferSourceNode); 5653 return nativeAudioBufferSourceNode; 5654 }; 5655}; 5656
vendor: 386 bytes, lines 5657-5667
5657// node_modules/standardized-audio-context/build/es2019/factories/native-audio-context-constructor.js 5658var createNativeAudioContextConstructor = (window3) => { 5659 if (window3 === null) { 5660 return null; 5661 } 5662 if (window3.hasOwnProperty("AudioContext")) { 5663 return window3.AudioContext; 5664 } 5665 return window3.hasOwnProperty("webkitAudioContext") ? window3.webkitAudioContext : null; 5666}; 5667
vendor: 2,103 bytes, lines 5668-5717
5668// node_modules/standardized-audio-context/build/es2019/factories/native-audio-destination-node.js 5669var createNativeAudioDestinationNodeFactory = (createNativeGainNode2, overwriteAccessors2) => { 5670 return (nativeContext, channelCount, isNodeOfNativeOfflineAudioContext) => { 5671 const nativeAudioDestinationNode = nativeContext.destination; 5672 if (nativeAudioDestinationNode.channelCount !== channelCount) { 5673 try { 5674 nativeAudioDestinationNode.channelCount = channelCount; 5675 } catch { 5676 } 5677 } 5678 if (isNodeOfNativeOfflineAudioContext && nativeAudioDestinationNode.channelCountMode !== "explicit") { 5679 nativeAudioDestinationNode.channelCountMode = "explicit"; 5680 } 5681 if (nativeAudioDestinationNode.maxChannelCount === 0) { 5682 Object.defineProperty(nativeAudioDestinationNode, "maxChannelCount", { 5683 value: channelCount 5684 }); 5685 } 5686 const gainNode = createNativeGainNode2(nativeContext, { 5687 channelCount, 5688 channelCountMode: nativeAudioDestinationNode.channelCountMode, 5689 channelInterpretation: nativeAudioDestinationNode.channelInterpretation, 5690 gain: 1 5691 }); 5692 overwriteAccessors2(gainNode, "channelCount", (get) => () => get.call(gainNode), (set) => (value) => { 5693 set.call(gainNode, value); 5694 try { 5695 nativeAudioDestinationNode.channelCount = value; 5696 } catch (err) { 5697 if (value > nativeAudioDestinationNode.maxChannelCount) { 5698 throw err; 5699 } 5700 } 5701 }); 5702 overwriteAccessors2(gainNode, "channelCountMode", (get) => () => get.call(gainNode), (set) => (value) => { 5703 set.call(gainNode, value); 5704 nativeAudioDestinationNode.channelCountMode = value; 5705 }); 5706 overwriteAccessors2(gainNode, "channelInterpretation", (get) => () => get.call(gainNode), (set) => (value) => { 5707 set.call(gainNode, value); 5708 nativeAudioDestinationNode.channelInterpretation = value; 5709 }); 5710 Object.defineProperty(gainNode, "maxChannelCount", { 5711 get: () => nativeAudioDestinationNode.maxChannelCount 5712 }); 5713 gainNode.connect(nativeAudioDestinationNode); 5714 return gainNode; 5715 }; 5716}; 5717
vendor: 306 bytes, lines 5718-5725
5718// node_modules/standardized-audio-context/build/es2019/factories/native-audio-worklet-node-constructor.js 5719var createNativeAudioWorkletNodeConstructor = (window3) => { 5720 if (window3 === null) { 5721 return null; 5722 } 5723 return window3.hasOwnProperty("AudioWorkletNode") ? window3.AudioWorkletNode : null; 5724}; 5725
vendor: 331 bytes, lines 5726-5735
5726// node_modules/standardized-audio-context/build/es2019/helpers/test-clonability-of-audio-worklet-node-options.js 5727var testClonabilityOfAudioWorkletNodeOptions = (audioWorkletNodeOptions) => { 5728 const { port1 } = new MessageChannel(); 5729 try { 5730 port1.postMessage(audioWorkletNodeOptions); 5731 } finally { 5732 port1.close(); 5733 } 5734}; 5735
vendor: 5,133 bytes, lines 5736-5842
5736// node_modules/standardized-audio-context/build/es2019/factories/native-audio-worklet-node-factory.js 5737var createNativeAudioWorkletNodeFactory = (createInvalidStateError2, createNativeAudioWorkletNodeFaker2, createNativeGainNode2, createNotSupportedError2, monitorConnections2) => { 5738 return (nativeContext, baseLatency, nativeAudioWorkletNodeConstructor2, name, processorConstructor, options) => { 5739 if (nativeAudioWorkletNodeConstructor2 !== null) { 5740 try { 5741 const nativeAudioWorkletNode = new nativeAudioWorkletNodeConstructor2(nativeContext, name, options); 5742 const patchedEventListeners = /* @__PURE__ */ new Map(); 5743 let onprocessorerror = null; 5744 Object.defineProperties(nativeAudioWorkletNode, { 5745 /* 5746 * Bug #61: Overwriting the property accessors for channelCount and channelCountMode is necessary as long as some 5747 * browsers have no native implementation to achieve a consistent behavior. 5748 */ 5749 channelCount: { 5750 get: () => options.channelCount, 5751 set: () => { 5752 throw createInvalidStateError2(); 5753 } 5754 }, 5755 channelCountMode: { 5756 get: () => "explicit", 5757 set: () => { 5758 throw createInvalidStateError2(); 5759 } 5760 }, 5761 // Bug #156: Chrome and Edge do not yet fire an ErrorEvent. 5762 onprocessorerror: { 5763 get: () => onprocessorerror, 5764 set: (value) => { 5765 if (typeof onprocessorerror === "function") { 5766 nativeAudioWorkletNode.removeEventListener("processorerror", onprocessorerror); 5767 } 5768 onprocessorerror = typeof value === "function" ? value : null; 5769 if (typeof onprocessorerror === "function") { 5770 nativeAudioWorkletNode.addEventListener("processorerror", onprocessorerror); 5771 } 5772 } 5773 } 5774 }); 5775 nativeAudioWorkletNode.addEventListener = /* @__PURE__ */ ((addEventListener) => { 5776 return (...args) => { 5777 if (args[0] === "processorerror") { 5778 const unpatchedEventListener = typeof args[1] === "function" ? args[1] : typeof args[1] === "object" && args[1] !== null && typeof args[1].handleEvent === "function" ? args[1].handleEvent : null; 5779 if (unpatchedEventListener !== null) { 5780 const patchedEventListener = patchedEventListeners.get(args[1]); 5781 if (patchedEventListener !== void 0) { 5782 args[1] = patchedEventListener; 5783 } else { 5784 args[1] = (event) => { 5785 if (event.type === "error") { 5786 Object.defineProperties(event, { 5787 type: { value: "processorerror" } 5788 }); 5789 unpatchedEventListener(event); 5790 } else { 5791 unpatchedEventListener(new ErrorEvent(args[0], { ...event })); 5792 } 5793 }; 5794 patchedEventListeners.set(unpatchedEventListener, args[1]); 5795 } 5796 } 5797 } 5798 addEventListener.call(nativeAudioWorkletNode, "error", args[1], args[2]); 5799 return addEventListener.call(nativeAudioWorkletNode, ...args); 5800 }; 5801 })(nativeAudioWorkletNode.addEventListener); 5802 nativeAudioWorkletNode.removeEventListener = /* @__PURE__ */ ((removeEventListener) => { 5803 return (...args) => { 5804 if (args[0] === "processorerror") { 5805 const patchedEventListener = patchedEventListeners.get(args[1]); 5806 if (patchedEventListener !== void 0) { 5807 patchedEventListeners.delete(args[1]); 5808 args[1] = patchedEventListener; 5809 } 5810 } 5811 removeEventListener.call(nativeAudioWorkletNode, "error", args[1], args[2]); 5812 return removeEventListener.call(nativeAudioWorkletNode, args[0], args[1], args[2]); 5813 }; 5814 })(nativeAudioWorkletNode.removeEventListener); 5815 if (options.numberOfOutputs !== 0) { 5816 const nativeGainNode = createNativeGainNode2(nativeContext, { 5817 channelCount: 1, 5818 channelCountMode: "explicit", 5819 channelInterpretation: "discrete", 5820 gain: 0 5821 }); 5822 nativeAudioWorkletNode.connect(nativeGainNode).connect(nativeContext.destination); 5823 const whenConnected = () => nativeGainNode.disconnect(); 5824 const whenDisconnected = () => nativeGainNode.connect(nativeContext.destination); 5825 return monitorConnections2(nativeAudioWorkletNode, whenConnected, whenDisconnected); 5826 } 5827 return nativeAudioWorkletNode; 5828 } catch (err) { 5829 if (err.code === 11) { 5830 throw createNotSupportedError2(); 5831 } 5832 throw err; 5833 } 5834 } 5835 if (processorConstructor === void 0) { 5836 throw createNotSupportedError2(); 5837 } 5838 testClonabilityOfAudioWorkletNodeOptions(options); 5839 return createNativeAudioWorkletNodeFaker2(nativeContext, baseLatency, processorConstructor, options); 5840 }; 5841}; 5842
vendor: 299 bytes, lines 5843-5850
5843// node_modules/standardized-audio-context/build/es2019/helpers/compute-buffer-size.js 5844var computeBufferSize = (baseLatency, sampleRate) => { 5845 if (baseLatency === null) { 5846 return 512; 5847 } 5848 return Math.max(512, Math.min(16384, Math.pow(2, Math.round(Math.log2(baseLatency * sampleRate))))); 5849}; 5850
vendor: 539 bytes, lines 5851-5868
5851// node_modules/standardized-audio-context/build/es2019/helpers/clone-audio-worklet-node-options.js 5852var cloneAudioWorkletNodeOptions = (audioWorkletNodeOptions) => { 5853 return new Promise((resolve, reject) => { 5854 const { port1, port2 } = new MessageChannel(); 5855 port1.onmessage = ({ data }) => { 5856 port1.close(); 5857 port2.close(); 5858 resolve(data); 5859 }; 5860 port1.onmessageerror = ({ data }) => { 5861 port1.close(); 5862 port2.close(); 5863 reject(data); 5864 }; 5865 port2.postMessage(audioWorkletNodeOptions); 5866 }); 5867}; 5868
vendor: 377 bytes, lines 5869-5874
5869// node_modules/standardized-audio-context/build/es2019/helpers/create-audio-worklet-processor-promise.js 5870var createAudioWorkletProcessorPromise = async (processorConstructor, audioWorkletNodeOptions) => { 5871 const clonedAudioWorkletNodeOptions = await cloneAudioWorkletNodeOptions(audioWorkletNodeOptions); 5872 return new processorConstructor(clonedAudioWorkletNodeOptions); 5873}; 5874
vendor: 705 bytes, lines 5875-5886
5875// node_modules/standardized-audio-context/build/es2019/helpers/create-audio-worklet-processor.js 5876var createAudioWorkletProcessor = (nativeContext, nativeAudioWorkletNode, processorConstructor, audioWorkletNodeOptions) => { 5877 let nodeToProcessorMap = NODE_TO_PROCESSOR_MAPS.get(nativeContext); 5878 if (nodeToProcessorMap === void 0) { 5879 nodeToProcessorMap = /* @__PURE__ */ new WeakMap(); 5880 NODE_TO_PROCESSOR_MAPS.set(nativeContext, nodeToProcessorMap); 5881 } 5882 const audioWorkletProcessorPromise = createAudioWorkletProcessorPromise(processorConstructor, audioWorkletNodeOptions); 5883 nodeToProcessorMap.set(nativeAudioWorkletNode, audioWorkletProcessorPromise); 5884 return audioWorkletProcessorPromise; 5885}; 5886
vendor: 16,693 bytes, lines 5887-6252
5887// node_modules/standardized-audio-context/build/es2019/factories/native-audio-worklet-node-faker-factory.js 5888var createNativeAudioWorkletNodeFakerFactory = (connectMultipleOutputs2, createIndexSizeError2, createInvalidStateError2, createNativeChannelMergerNode2, createNativeChannelSplitterNode2, createNativeConstantSourceNode2, createNativeGainNode2, createNativeScriptProcessorNode2, createNotSupportedError2, disconnectMultipleOutputs2, exposeCurrentFrameAndCurrentTime2, getActiveAudioWorkletNodeInputs2, monitorConnections2) => { 5889 return (nativeContext, baseLatency, processorConstructor, options) => { 5890 if (options.numberOfInputs === 0 && options.numberOfOutputs === 0) { 5891 throw createNotSupportedError2(); 5892 } 5893 const outputChannelCount = Array.isArray(options.outputChannelCount) ? options.outputChannelCount : Array.from(options.outputChannelCount); 5894 if (outputChannelCount.some((channelCount) => channelCount < 1)) { 5895 throw createNotSupportedError2(); 5896 } 5897 if (outputChannelCount.length !== options.numberOfOutputs) { 5898 throw createIndexSizeError2(); 5899 } 5900 if (options.channelCountMode !== "explicit") { 5901 throw createNotSupportedError2(); 5902 } 5903 const numberOfInputChannels = options.channelCount * options.numberOfInputs; 5904 const numberOfOutputChannels = outputChannelCount.reduce((sum, value) => sum + value, 0); 5905 const numberOfParameters = processorConstructor.parameterDescriptors === void 0 ? 0 : processorConstructor.parameterDescriptors.length; 5906 if (numberOfInputChannels + numberOfParameters > 6 || numberOfOutputChannels > 6) { 5907 throw createNotSupportedError2(); 5908 } 5909 const messageChannel = new MessageChannel(); 5910 const gainNodes = []; 5911 const inputChannelSplitterNodes = []; 5912 for (let i = 0; i < options.numberOfInputs; i += 1) { 5913 gainNodes.push(createNativeGainNode2(nativeContext, { 5914 channelCount: options.channelCount, 5915 channelCountMode: options.channelCountMode, 5916 channelInterpretation: options.channelInterpretation, 5917 gain: 1 5918 })); 5919 inputChannelSplitterNodes.push(createNativeChannelSplitterNode2(nativeContext, { 5920 channelCount: options.channelCount, 5921 channelCountMode: "explicit", 5922 channelInterpretation: "discrete", 5923 numberOfOutputs: options.channelCount 5924 })); 5925 } 5926 const constantSourceNodes = []; 5927 if (processorConstructor.parameterDescriptors !== void 0) { 5928 for (const { defaultValue, maxValue, minValue, name } of processorConstructor.parameterDescriptors) { 5929 const constantSourceNode = createNativeConstantSourceNode2(nativeContext, { 5930 channelCount: 1, 5931 channelCountMode: "explicit", 5932 channelInterpretation: "discrete", 5933 offset: options.parameterData[name] !== void 0 ? options.parameterData[name] : defaultValue === void 0 ? 0 : defaultValue 5934 }); 5935 Object.defineProperties(constantSourceNode.offset, { 5936 defaultValue: { 5937 get: () => defaultValue === void 0 ? 0 : defaultValue 5938 }, 5939 maxValue: { 5940 get: () => maxValue === void 0 ? MOST_POSITIVE_SINGLE_FLOAT : maxValue 5941 }, 5942 minValue: { 5943 get: () => minValue === void 0 ? MOST_NEGATIVE_SINGLE_FLOAT : minValue 5944 } 5945 }); 5946 constantSourceNodes.push(constantSourceNode); 5947 } 5948 } 5949 const inputChannelMergerNode = createNativeChannelMergerNode2(nativeContext, { 5950 channelCount: 1, 5951 channelCountMode: "explicit", 5952 channelInterpretation: "speakers", 5953 numberOfInputs: Math.max(1, numberOfInputChannels + numberOfParameters) 5954 }); 5955 const bufferSize = computeBufferSize(baseLatency, nativeContext.sampleRate); 5956 const scriptProcessorNode = createNativeScriptProcessorNode2( 5957 nativeContext, 5958 bufferSize, 5959 numberOfInputChannels + numberOfParameters, 5960 // Bug #87: Only Firefox will fire an AudioProcessingEvent if there is no connected output. 5961 Math.max(1, numberOfOutputChannels) 5962 ); 5963 const outputChannelSplitterNode = createNativeChannelSplitterNode2(nativeContext, { 5964 channelCount: Math.max(1, numberOfOutputChannels), 5965 channelCountMode: "explicit", 5966 channelInterpretation: "discrete", 5967 numberOfOutputs: Math.max(1, numberOfOutputChannels) 5968 }); 5969 const outputChannelMergerNodes = []; 5970 for (let i = 0; i < options.numberOfOutputs; i += 1) { 5971 outputChannelMergerNodes.push(createNativeChannelMergerNode2(nativeContext, { 5972 channelCount: 1, 5973 channelCountMode: "explicit", 5974 channelInterpretation: "speakers", 5975 numberOfInputs: outputChannelCount[i] 5976 })); 5977 } 5978 for (let i = 0; i < options.numberOfInputs; i += 1) { 5979 gainNodes[i].connect(inputChannelSplitterNodes[i]); 5980 for (let j = 0; j < options.channelCount; j += 1) { 5981 inputChannelSplitterNodes[i].connect(inputChannelMergerNode, j, i * options.channelCount + j); 5982 } 5983 } 5984 const parameterMap = new ReadOnlyMap(processorConstructor.parameterDescriptors === void 0 ? [] : processorConstructor.parameterDescriptors.map(({ name }, index) => { 5985 const constantSourceNode = constantSourceNodes[index]; 5986 constantSourceNode.connect(inputChannelMergerNode, 0, numberOfInputChannels + index); 5987 constantSourceNode.start(0); 5988 return [name, constantSourceNode.offset]; 5989 })); 5990 inputChannelMergerNode.connect(scriptProcessorNode); 5991 let channelInterpretation = options.channelInterpretation; 5992 let onprocessorerror = null; 5993 const outputAudioNodes = options.numberOfOutputs === 0 ? [scriptProcessorNode] : outputChannelMergerNodes; 5994 const nativeAudioWorkletNodeFaker = { 5995 get bufferSize() { 5996 return bufferSize; 5997 }, 5998 get channelCount() { 5999 return options.channelCount; 6000 }, 6001 set channelCount(_) { 6002 throw createInvalidStateError2(); 6003 }, 6004 get channelCountMode() { 6005 return options.channelCountMode; 6006 }, 6007 set channelCountMode(_) { 6008 throw createInvalidStateError2(); 6009 }, 6010 get channelInterpretation() { 6011 return channelInterpretation; 6012 }, 6013 set channelInterpretation(value) { 6014 for (const gainNode of gainNodes) { 6015 gainNode.channelInterpretation = value; 6016 } 6017 channelInterpretation = value; 6018 }, 6019 get context() { 6020 return scriptProcessorNode.context; 6021 }, 6022 get inputs() { 6023 return gainNodes; 6024 }, 6025 get numberOfInputs() { 6026 return options.numberOfInputs; 6027 }, 6028 get numberOfOutputs() { 6029 return options.numberOfOutputs; 6030 }, 6031 get onprocessorerror() { 6032 return onprocessorerror; 6033 }, 6034 set onprocessorerror(value) { 6035 if (typeof onprocessorerror === "function") { 6036 nativeAudioWorkletNodeFaker.removeEventListener("processorerror", onprocessorerror); 6037 } 6038 onprocessorerror = typeof value === "function" ? value : null; 6039 if (typeof onprocessorerror === "function") { 6040 nativeAudioWorkletNodeFaker.addEventListener("processorerror", onprocessorerror); 6041 } 6042 }, 6043 get parameters() { 6044 return parameterMap; 6045 }, 6046 get port() { 6047 return messageChannel.port2; 6048 }, 6049 addEventListener(...args) { 6050 return scriptProcessorNode.addEventListener(args[0], args[1], args[2]); 6051 }, 6052 connect: connectMultipleOutputs2.bind(null, outputAudioNodes), 6053 disconnect: disconnectMultipleOutputs2.bind(null, outputAudioNodes), 6054 dispatchEvent(...args) { 6055 return scriptProcessorNode.dispatchEvent(args[0]); 6056 }, 6057 removeEventListener(...args) { 6058 return scriptProcessorNode.removeEventListener(args[0], args[1], args[2]); 6059 } 6060 }; 6061 const patchedEventListeners = /* @__PURE__ */ new Map(); 6062 messageChannel.port1.addEventListener = /* @__PURE__ */ ((addEventListener) => { 6063 return (...args) => { 6064 if (args[0] === "message") { 6065 const unpatchedEventListener = typeof args[1] === "function" ? args[1] : typeof args[1] === "object" && args[1] !== null && typeof args[1].handleEvent === "function" ? args[1].handleEvent : null; 6066 if (unpatchedEventListener !== null) { 6067 const patchedEventListener = patchedEventListeners.get(args[1]); 6068 if (patchedEventListener !== void 0) { 6069 args[1] = patchedEventListener; 6070 } else { 6071 args[1] = (event) => { 6072 exposeCurrentFrameAndCurrentTime2(nativeContext.currentTime, nativeContext.sampleRate, () => unpatchedEventListener(event)); 6073 }; 6074 patchedEventListeners.set(unpatchedEventListener, args[1]); 6075 } 6076 } 6077 } 6078 return addEventListener.call(messageChannel.port1, args[0], args[1], args[2]); 6079 }; 6080 })(messageChannel.port1.addEventListener); 6081 messageChannel.port1.removeEventListener = /* @__PURE__ */ ((removeEventListener) => { 6082 return (...args) => { 6083 if (args[0] === "message") { 6084 const patchedEventListener = patchedEventListeners.get(args[1]); 6085 if (patchedEventListener !== void 0) { 6086 patchedEventListeners.delete(args[1]); 6087 args[1] = patchedEventListener; 6088 } 6089 } 6090 return removeEventListener.call(messageChannel.port1, args[0], args[1], args[2]); 6091 }; 6092 })(messageChannel.port1.removeEventListener); 6093 let onmessage = null; 6094 Object.defineProperty(messageChannel.port1, "onmessage", { 6095 get: () => onmessage, 6096 set: (value) => { 6097 if (typeof onmessage === "function") { 6098 messageChannel.port1.removeEventListener("message", onmessage); 6099 } 6100 onmessage = typeof value === "function" ? value : null; 6101 if (typeof onmessage === "function") { 6102 messageChannel.port1.addEventListener("message", onmessage); 6103 messageChannel.port1.start(); 6104 } 6105 } 6106 }); 6107 processorConstructor.prototype.port = messageChannel.port1; 6108 let audioWorkletProcessor = null; 6109 const audioWorkletProcessorPromise = createAudioWorkletProcessor(nativeContext, nativeAudioWorkletNodeFaker, processorConstructor, options); 6110 audioWorkletProcessorPromise.then((dWrkltPrcssr) => audioWorkletProcessor = dWrkltPrcssr); 6111 const inputs = createNestedArrays(options.numberOfInputs, options.channelCount); 6112 const outputs = createNestedArrays(options.numberOfOutputs, outputChannelCount); 6113 const parameters = processorConstructor.parameterDescriptors === void 0 ? [] : processorConstructor.parameterDescriptors.reduce((prmtrs, { name }) => ({ ...prmtrs, [name]: new Float32Array(128) }), {}); 6114 let isActive = true; 6115 const disconnectOutputsGraph = () => { 6116 if (options.numberOfOutputs > 0) { 6117 scriptProcessorNode.disconnect(outputChannelSplitterNode); 6118 } 6119 for (let i = 0, outputChannelSplitterNodeOutput = 0; i < options.numberOfOutputs; i += 1) { 6120 const outputChannelMergerNode = outputChannelMergerNodes[i]; 6121 for (let j = 0; j < outputChannelCount[i]; j += 1) { 6122 outputChannelSplitterNode.disconnect(outputChannelMergerNode, outputChannelSplitterNodeOutput + j, j); 6123 } 6124 outputChannelSplitterNodeOutput += outputChannelCount[i]; 6125 } 6126 }; 6127 const activeInputIndexes = /* @__PURE__ */ new Map(); 6128 scriptProcessorNode.onaudioprocess = ({ inputBuffer, outputBuffer }) => { 6129 if (audioWorkletProcessor !== null) { 6130 const activeInputs = getActiveAudioWorkletNodeInputs2(nativeAudioWorkletNodeFaker); 6131 for (let i = 0; i < bufferSize; i += 128) { 6132 for (let j = 0; j < options.numberOfInputs; j += 1) { 6133 for (let k = 0; k < options.channelCount; k += 1) { 6134 copyFromChannel(inputBuffer, inputs[j], k, k, i); 6135 } 6136 } 6137 if (processorConstructor.parameterDescriptors !== void 0) { 6138 processorConstructor.parameterDescriptors.forEach(({ name }, index) => { 6139 copyFromChannel(inputBuffer, parameters, name, numberOfInputChannels + index, i); 6140 }); 6141 } 6142 for (let j = 0; j < options.numberOfInputs; j += 1) { 6143 for (let k = 0; k < outputChannelCount[j]; k += 1) { 6144 if (outputs[j][k].byteLength === 0) { 6145 outputs[j][k] = new Float32Array(128); 6146 } 6147 } 6148 } 6149 try { 6150 const potentiallyEmptyInputs = inputs.map((input, index) => { 6151 const activeInput = activeInputs[index]; 6152 if (activeInput.size > 0) { 6153 activeInputIndexes.set(index, bufferSize / 128); 6154 return input; 6155 } 6156 const count = activeInputIndexes.get(index); 6157 if (count === void 0) { 6158 return []; 6159 } 6160 if (input.every((channelData) => channelData.every((sample) => sample === 0))) { 6161 if (count === 1) { 6162 activeInputIndexes.delete(index); 6163 } else { 6164 activeInputIndexes.set(index, count - 1); 6165 } 6166 } 6167 return input; 6168 }); 6169 const activeSourceFlag = exposeCurrentFrameAndCurrentTime2(nativeContext.currentTime + i / nativeContext.sampleRate, nativeContext.sampleRate, () => audioWorkletProcessor.process(potentiallyEmptyInputs, outputs, parameters)); 6170 isActive = activeSourceFlag; 6171 for (let j = 0, outputChannelSplitterNodeOutput = 0; j < options.numberOfOutputs; j += 1) { 6172 for (let k = 0; k < outputChannelCount[j]; k += 1) { 6173 copyToChannel(outputBuffer, outputs[j], k, outputChannelSplitterNodeOutput + k, i); 6174 } 6175 outputChannelSplitterNodeOutput += outputChannelCount[j]; 6176 } 6177 } catch (error) { 6178 isActive = false; 6179 nativeAudioWorkletNodeFaker.dispatchEvent(new ErrorEvent("processorerror", { 6180 colno: error.colno, 6181 filename: error.filename, 6182 lineno: error.lineno, 6183 message: error.message 6184 })); 6185 } 6186 if (!isActive) { 6187 for (let j = 0; j < options.numberOfInputs; j += 1) { 6188 gainNodes[j].disconnect(inputChannelSplitterNodes[j]); 6189 for (let k = 0; k < options.channelCount; k += 1) { 6190 inputChannelSplitterNodes[i].disconnect(inputChannelMergerNode, k, j * options.channelCount + k); 6191 } 6192 } 6193 if (processorConstructor.parameterDescriptors !== void 0) { 6194 const length = processorConstructor.parameterDescriptors.length; 6195 for (let j = 0; j < length; j += 1) { 6196 const constantSourceNode = constantSourceNodes[j]; 6197 constantSourceNode.disconnect(inputChannelMergerNode, 0, numberOfInputChannels + j); 6198 constantSourceNode.stop(); 6199 } 6200 } 6201 inputChannelMergerNode.disconnect(scriptProcessorNode); 6202 scriptProcessorNode.onaudioprocess = null; 6203 if (isConnected) { 6204 disconnectOutputsGraph(); 6205 } else { 6206 disconnectFakeGraph(); 6207 } 6208 break; 6209 } 6210 } 6211 } 6212 }; 6213 let isConnected = false; 6214 const nativeGainNode = createNativeGainNode2(nativeContext, { 6215 channelCount: 1, 6216 channelCountMode: "explicit", 6217 channelInterpretation: "discrete", 6218 gain: 0 6219 }); 6220 const connectFakeGraph = () => scriptProcessorNode.connect(nativeGainNode).connect(nativeContext.destination); 6221 const disconnectFakeGraph = () => { 6222 scriptProcessorNode.disconnect(nativeGainNode); 6223 nativeGainNode.disconnect(); 6224 }; 6225 const whenConnected = () => { 6226 if (isActive) { 6227 disconnectFakeGraph(); 6228 if (options.numberOfOutputs > 0) { 6229 scriptProcessorNode.connect(outputChannelSplitterNode); 6230 } 6231 for (let i = 0, outputChannelSplitterNodeOutput = 0; i < options.numberOfOutputs; i += 1) { 6232 const outputChannelMergerNode = outputChannelMergerNodes[i]; 6233 for (let j = 0; j < outputChannelCount[i]; j += 1) { 6234 outputChannelSplitterNode.connect(outputChannelMergerNode, outputChannelSplitterNodeOutput + j, j); 6235 } 6236 outputChannelSplitterNodeOutput += outputChannelCount[i]; 6237 } 6238 } 6239 isConnected = true; 6240 }; 6241 const whenDisconnected = () => { 6242 if (isActive) { 6243 connectFakeGraph(); 6244 disconnectOutputsGraph(); 6245 } 6246 isConnected = false; 6247 }; 6248 connectFakeGraph(); 6249 return monitorConnections2(nativeAudioWorkletNodeFaker, whenConnected, whenDisconnected); 6250 }; 6251}; 6252
vendor: 731 bytes, lines 6253-6264
6253// node_modules/standardized-audio-context/build/es2019/factories/native-biquad-filter-node.js 6254var createNativeBiquadFilterNode = (nativeContext, options) => { 6255 const nativeBiquadFilterNode = nativeContext.createBiquadFilter(); 6256 assignNativeAudioNodeOptions(nativeBiquadFilterNode, options); 6257 assignNativeAudioNodeAudioParamValue(nativeBiquadFilterNode, options, "Q"); 6258 assignNativeAudioNodeAudioParamValue(nativeBiquadFilterNode, options, "detune"); 6259 assignNativeAudioNodeAudioParamValue(nativeBiquadFilterNode, options, "frequency"); 6260 assignNativeAudioNodeAudioParamValue(nativeBiquadFilterNode, options, "gain"); 6261 assignNativeAudioNodeOption(nativeBiquadFilterNode, options, "type"); 6262 return nativeBiquadFilterNode; 6263}; 6264
vendor: 647 bytes, lines 6265-6276
6265// node_modules/standardized-audio-context/build/es2019/factories/native-channel-merger-node-factory.js 6266var createNativeChannelMergerNodeFactory = (nativeAudioContextConstructor2, wrapChannelMergerNode2) => { 6267 return (nativeContext, options) => { 6268 const nativeChannelMergerNode = nativeContext.createChannelMerger(options.numberOfInputs); 6269 if (nativeAudioContextConstructor2 !== null && nativeAudioContextConstructor2.name === "webkitAudioContext") { 6270 wrapChannelMergerNode2(nativeContext, nativeChannelMergerNode); 6271 } 6272 assignNativeAudioNodeOptions(nativeChannelMergerNode, options); 6273 return nativeChannelMergerNode; 6274 }; 6275}; 6276
vendor: 853 bytes, lines 6277-6305
6277// node_modules/standardized-audio-context/build/es2019/helpers/wrap-channel-splitter-node.js 6278var wrapChannelSplitterNode = (channelSplitterNode) => { 6279 const channelCount = channelSplitterNode.numberOfOutputs; 6280 Object.defineProperty(channelSplitterNode, "channelCount", { 6281 get: () => channelCount, 6282 set: (value) => { 6283 if (value !== channelCount) { 6284 throw createInvalidStateError(); 6285 } 6286 } 6287 }); 6288 Object.defineProperty(channelSplitterNode, "channelCountMode", { 6289 get: () => "explicit", 6290 set: (value) => { 6291 if (value !== "explicit") { 6292 throw createInvalidStateError(); 6293 } 6294 } 6295 }); 6296 Object.defineProperty(channelSplitterNode, "channelInterpretation", { 6297 get: () => "discrete", 6298 set: (value) => { 6299 if (value !== "discrete") { 6300 throw createInvalidStateError(); 6301 } 6302 } 6303 }); 6304}; 6305
vendor: 426 bytes, lines 6306-6313
6306// node_modules/standardized-audio-context/build/es2019/factories/native-channel-splitter-node.js 6307var createNativeChannelSplitterNode = (nativeContext, options) => { 6308 const nativeChannelSplitterNode = nativeContext.createChannelSplitter(options.numberOfOutputs); 6309 assignNativeAudioNodeOptions(nativeChannelSplitterNode, options); 6310 wrapChannelSplitterNode(nativeChannelSplitterNode); 6311 return nativeChannelSplitterNode; 6312}; 6313
vendor: 1,446 bytes, lines 6314-6333
6314// node_modules/standardized-audio-context/build/es2019/factories/native-constant-source-node-factory.js 6315var createNativeConstantSourceNodeFactory = (addSilentConnection2, cacheTestResult2, createNativeConstantSourceNodeFaker2, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2) => { 6316 return (nativeContext, options) => { 6317 if (nativeContext.createConstantSource === void 0) { 6318 return createNativeConstantSourceNodeFaker2(nativeContext, options); 6319 } 6320 const nativeConstantSourceNode = nativeContext.createConstantSource(); 6321 assignNativeAudioNodeOptions(nativeConstantSourceNode, options); 6322 assignNativeAudioNodeAudioParamValue(nativeConstantSourceNode, options, "offset"); 6323 if (!cacheTestResult2(testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2(nativeContext))) { 6324 wrapAudioScheduledSourceNodeStartMethodNegativeParameters(nativeConstantSourceNode); 6325 } 6326 if (!cacheTestResult2(testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2(nativeContext))) { 6327 wrapAudioScheduledSourceNodeStopMethodNegativeParameters(nativeConstantSourceNode); 6328 } 6329 addSilentConnection2(nativeContext, nativeConstantSourceNode); 6330 return nativeConstantSourceNode; 6331 }; 6332}; 6333
vendor: 294 bytes, lines 6334-6340
6334// node_modules/standardized-audio-context/build/es2019/helpers/intercept-connections.js 6335var interceptConnections = (original, interceptor) => { 6336 original.connect = interceptor.connect.bind(interceptor); 6337 original.disconnect = interceptor.disconnect.bind(interceptor); 6338 return original; 6339}; 6340
vendor: 3,013 bytes, lines 6341-6426
6341// node_modules/standardized-audio-context/build/es2019/factories/native-constant-source-node-faker-factory.js 6342var createNativeConstantSourceNodeFakerFactory = (addSilentConnection2, createNativeAudioBufferSourceNode2, createNativeGainNode2, monitorConnections2) => { 6343 return (nativeContext, { offset, ...audioNodeOptions }) => { 6344 const audioBuffer = nativeContext.createBuffer(1, 2, 44100); 6345 const audioBufferSourceNode = createNativeAudioBufferSourceNode2(nativeContext, { 6346 buffer: null, 6347 channelCount: 2, 6348 channelCountMode: "max", 6349 channelInterpretation: "speakers", 6350 loop: false, 6351 loopEnd: 0, 6352 loopStart: 0, 6353 playbackRate: 1 6354 }); 6355 const gainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: offset }); 6356 const channelData = audioBuffer.getChannelData(0); 6357 channelData[0] = 1; 6358 channelData[1] = 1; 6359 audioBufferSourceNode.buffer = audioBuffer; 6360 audioBufferSourceNode.loop = true; 6361 const nativeConstantSourceNodeFaker = { 6362 get bufferSize() { 6363 return void 0; 6364 }, 6365 get channelCount() { 6366 return gainNode.channelCount; 6367 }, 6368 set channelCount(value) { 6369 gainNode.channelCount = value; 6370 }, 6371 get channelCountMode() { 6372 return gainNode.channelCountMode; 6373 }, 6374 set channelCountMode(value) { 6375 gainNode.channelCountMode = value; 6376 }, 6377 get channelInterpretation() { 6378 return gainNode.channelInterpretation; 6379 }, 6380 set channelInterpretation(value) { 6381 gainNode.channelInterpretation = value; 6382 }, 6383 get context() { 6384 return gainNode.context; 6385 }, 6386 get inputs() { 6387 return []; 6388 }, 6389 get numberOfInputs() { 6390 return audioBufferSourceNode.numberOfInputs; 6391 }, 6392 get numberOfOutputs() { 6393 return gainNode.numberOfOutputs; 6394 }, 6395 get offset() { 6396 return gainNode.gain; 6397 }, 6398 get onended() { 6399 return audioBufferSourceNode.onended; 6400 }, 6401 set onended(value) { 6402 audioBufferSourceNode.onended = value; 6403 }, 6404 addEventListener(...args) { 6405 return audioBufferSourceNode.addEventListener(args[0], args[1], args[2]); 6406 }, 6407 dispatchEvent(...args) { 6408 return audioBufferSourceNode.dispatchEvent(args[0]); 6409 }, 6410 removeEventListener(...args) { 6411 return audioBufferSourceNode.removeEventListener(args[0], args[1], args[2]); 6412 }, 6413 start(when = 0) { 6414 audioBufferSourceNode.start.call(audioBufferSourceNode, when); 6415 }, 6416 stop(when = 0) { 6417 audioBufferSourceNode.stop.call(audioBufferSourceNode, when); 6418 } 6419 }; 6420 const whenConnected = () => audioBufferSourceNode.connect(gainNode); 6421 const whenDisconnected = () => audioBufferSourceNode.disconnect(gainNode); 6422 addSilentConnection2(nativeContext, audioBufferSourceNode); 6423 return monitorConnections2(interceptConnections(nativeConstantSourceNodeFaker, gainNode), whenConnected, whenDisconnected); 6424 }; 6425}; 6426
vendor: 1,328 bytes, lines 6427-6457
6427// node_modules/standardized-audio-context/build/es2019/factories/native-convolver-node-factory.js 6428var createNativeConvolverNodeFactory = (createNotSupportedError2, overwriteAccessors2) => { 6429 return (nativeContext, options) => { 6430 const nativeConvolverNode = nativeContext.createConvolver(); 6431 assignNativeAudioNodeOptions(nativeConvolverNode, options); 6432 if (options.disableNormalization === nativeConvolverNode.normalize) { 6433 nativeConvolverNode.normalize = !options.disableNormalization; 6434 } 6435 assignNativeAudioNodeOption(nativeConvolverNode, options, "buffer"); 6436 if (options.channelCount > 2) { 6437 throw createNotSupportedError2(); 6438 } 6439 overwriteAccessors2(nativeConvolverNode, "channelCount", (get) => () => get.call(nativeConvolverNode), (set) => (value) => { 6440 if (value > 2) { 6441 throw createNotSupportedError2(); 6442 } 6443 return set.call(nativeConvolverNode, value); 6444 }); 6445 if (options.channelCountMode === "max") { 6446 throw createNotSupportedError2(); 6447 } 6448 overwriteAccessors2(nativeConvolverNode, "channelCountMode", (get) => () => get.call(nativeConvolverNode), (set) => (value) => { 6449 if (value === "max") { 6450 throw createNotSupportedError2(); 6451 } 6452 return set.call(nativeConvolverNode, value); 6453 }); 6454 return nativeConvolverNode; 6455 }; 6456}; 6457
vendor: 387 bytes, lines 6458-6465
6458// node_modules/standardized-audio-context/build/es2019/factories/native-delay-node.js 6459var createNativeDelayNode = (nativeContext, options) => { 6460 const nativeDelayNode = nativeContext.createDelay(options.maxDelayTime); 6461 assignNativeAudioNodeOptions(nativeDelayNode, options); 6462 assignNativeAudioNodeAudioParamValue(nativeDelayNode, options, "delayTime"); 6463 return nativeDelayNode; 6464}; 6465
vendor: 1,064 bytes, lines 6466-6485
6466// node_modules/standardized-audio-context/build/es2019/factories/native-dynamics-compressor-node-factory.js 6467var createNativeDynamicsCompressorNodeFactory = (createNotSupportedError2) => { 6468 return (nativeContext, options) => { 6469 const nativeDynamicsCompressorNode = nativeContext.createDynamicsCompressor(); 6470 assignNativeAudioNodeOptions(nativeDynamicsCompressorNode, options); 6471 if (options.channelCount > 2) { 6472 throw createNotSupportedError2(); 6473 } 6474 if (options.channelCountMode === "max") { 6475 throw createNotSupportedError2(); 6476 } 6477 assignNativeAudioNodeAudioParamValue(nativeDynamicsCompressorNode, options, "attack"); 6478 assignNativeAudioNodeAudioParamValue(nativeDynamicsCompressorNode, options, "knee"); 6479 assignNativeAudioNodeAudioParamValue(nativeDynamicsCompressorNode, options, "ratio"); 6480 assignNativeAudioNodeAudioParamValue(nativeDynamicsCompressorNode, options, "release"); 6481 assignNativeAudioNodeAudioParamValue(nativeDynamicsCompressorNode, options, "threshold"); 6482 return nativeDynamicsCompressorNode; 6483 }; 6484}; 6485
vendor: 355 bytes, lines 6486-6493
6486// node_modules/standardized-audio-context/build/es2019/factories/native-gain-node.js 6487var createNativeGainNode = (nativeContext, options) => { 6488 const nativeGainNode = nativeContext.createGain(); 6489 assignNativeAudioNodeOptions(nativeGainNode, options); 6490 assignNativeAudioNodeAudioParamValue(nativeGainNode, options, "gain"); 6491 return nativeGainNode; 6492}; 6493
vendor: 578 bytes, lines 6494-6505
6494// node_modules/standardized-audio-context/build/es2019/factories/native-iir-filter-node-factory.js 6495var createNativeIIRFilterNodeFactory = (createNativeIIRFilterNodeFaker2) => { 6496 return (nativeContext, baseLatency, options) => { 6497 if (nativeContext.createIIRFilter === void 0) { 6498 return createNativeIIRFilterNodeFaker2(nativeContext, baseLatency, options); 6499 } 6500 const nativeIIRFilterNode = nativeContext.createIIRFilter(options.feedforward, options.feedback); 6501 assignNativeAudioNodeOptions(nativeIIRFilterNode, options); 6502 return nativeIIRFilterNode; 6503 }; 6504}; 6505
vendor: 5,628 bytes, lines 6506-6640
6506// node_modules/standardized-audio-context/build/es2019/factories/native-iir-filter-node-faker-factory.js 6507function divide(a, b) { 6508 const denominator = b[0] * b[0] + b[1] * b[1]; 6509 return [(a[0] * b[0] + a[1] * b[1]) / denominator, (a[1] * b[0] - a[0] * b[1]) / denominator]; 6510} 6511function multiply(a, b) { 6512 return [a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]]; 6513} 6514function evaluatePolynomial(coefficient, z) { 6515 let result = [0, 0]; 6516 for (let i = coefficient.length - 1; i >= 0; i -= 1) { 6517 result = multiply(result, z); 6518 result[0] += coefficient[i]; 6519 } 6520 return result; 6521} 6522var createNativeIIRFilterNodeFakerFactory = (createInvalidAccessError2, createInvalidStateError2, createNativeScriptProcessorNode2, createNotSupportedError2) => { 6523 return (nativeContext, baseLatency, { channelCount, channelCountMode, channelInterpretation, feedback, feedforward }) => { 6524 const bufferSize = computeBufferSize(baseLatency, nativeContext.sampleRate); 6525 const convertedFeedback = feedback instanceof Float64Array ? feedback : new Float64Array(feedback); 6526 const convertedFeedforward = feedforward instanceof Float64Array ? feedforward : new Float64Array(feedforward); 6527 const feedbackLength = convertedFeedback.length; 6528 const feedforwardLength = convertedFeedforward.length; 6529 const minLength = Math.min(feedbackLength, feedforwardLength); 6530 if (feedbackLength === 0 || feedbackLength > 20) { 6531 throw createNotSupportedError2(); 6532 } 6533 if (convertedFeedback[0] === 0) { 6534 throw createInvalidStateError2(); 6535 } 6536 if (feedforwardLength === 0 || feedforwardLength > 20) { 6537 throw createNotSupportedError2(); 6538 } 6539 if (convertedFeedforward[0] === 0) { 6540 throw createInvalidStateError2(); 6541 } 6542 if (convertedFeedback[0] !== 1) { 6543 for (let i = 0; i < feedforwardLength; i += 1) { 6544 convertedFeedforward[i] /= convertedFeedback[0]; 6545 } 6546 for (let i = 1; i < feedbackLength; i += 1) { 6547 convertedFeedback[i] /= convertedFeedback[0]; 6548 } 6549 } 6550 const scriptProcessorNode = createNativeScriptProcessorNode2(nativeContext, bufferSize, channelCount, channelCount); 6551 scriptProcessorNode.channelCount = channelCount; 6552 scriptProcessorNode.channelCountMode = channelCountMode; 6553 scriptProcessorNode.channelInterpretation = channelInterpretation; 6554 const bufferLength = 32; 6555 const bufferIndexes = []; 6556 const xBuffers = []; 6557 const yBuffers = []; 6558 for (let i = 0; i < channelCount; i += 1) { 6559 bufferIndexes.push(0); 6560 const xBuffer = new Float32Array(bufferLength); 6561 const yBuffer = new Float32Array(bufferLength); 6562 xBuffer.fill(0); 6563 yBuffer.fill(0); 6564 xBuffers.push(xBuffer); 6565 yBuffers.push(yBuffer); 6566 } 6567 scriptProcessorNode.onaudioprocess = (event) => { 6568 const inputBuffer = event.inputBuffer; 6569 const outputBuffer = event.outputBuffer; 6570 const numberOfChannels = inputBuffer.numberOfChannels; 6571 for (let i = 0; i < numberOfChannels; i += 1) { 6572 const input = inputBuffer.getChannelData(i); 6573 const output = outputBuffer.getChannelData(i); 6574 bufferIndexes[i] = filterBuffer(convertedFeedback, feedbackLength, convertedFeedforward, feedforwardLength, minLength, xBuffers[i], yBuffers[i], bufferIndexes[i], bufferLength, input, output); 6575 } 6576 }; 6577 const nyquist = nativeContext.sampleRate / 2; 6578 const nativeIIRFilterNodeFaker = { 6579 get bufferSize() { 6580 return bufferSize; 6581 }, 6582 get channelCount() { 6583 return scriptProcessorNode.channelCount; 6584 }, 6585 set channelCount(value) { 6586 scriptProcessorNode.channelCount = value; 6587 }, 6588 get channelCountMode() { 6589 return scriptProcessorNode.channelCountMode; 6590 }, 6591 set channelCountMode(value) { 6592 scriptProcessorNode.channelCountMode = value; 6593 }, 6594 get channelInterpretation() { 6595 return scriptProcessorNode.channelInterpretation; 6596 }, 6597 set channelInterpretation(value) { 6598 scriptProcessorNode.channelInterpretation = value; 6599 }, 6600 get context() { 6601 return scriptProcessorNode.context; 6602 }, 6603 get inputs() { 6604 return [scriptProcessorNode]; 6605 }, 6606 get numberOfInputs() { 6607 return scriptProcessorNode.numberOfInputs; 6608 }, 6609 get numberOfOutputs() { 6610 return scriptProcessorNode.numberOfOutputs; 6611 }, 6612 addEventListener(...args) { 6613 return scriptProcessorNode.addEventListener(args[0], args[1], args[2]); 6614 }, 6615 dispatchEvent(...args) { 6616 return scriptProcessorNode.dispatchEvent(args[0]); 6617 }, 6618 getFrequencyResponse(frequencyHz, magResponse, phaseResponse) { 6619 if (frequencyHz.length !== magResponse.length || magResponse.length !== phaseResponse.length) { 6620 throw createInvalidAccessError2(); 6621 } 6622 const length = frequencyHz.length; 6623 for (let i = 0; i < length; i += 1) { 6624 const omega = -Math.PI * (frequencyHz[i] / nyquist); 6625 const z = [Math.cos(omega), Math.sin(omega)]; 6626 const numerator = evaluatePolynomial(convertedFeedforward, z); 6627 const denominator = evaluatePolynomial(convertedFeedback, z); 6628 const response = divide(numerator, denominator); 6629 magResponse[i] = Math.sqrt(response[0] * response[0] + response[1] * response[1]); 6630 phaseResponse[i] = Math.atan2(response[1], response[0]); 6631 } 6632 }, 6633 removeEventListener(...args) { 6634 return scriptProcessorNode.removeEventListener(args[0], args[1], args[2]); 6635 } 6636 }; 6637 return interceptConnections(nativeIIRFilterNodeFaker, scriptProcessorNode); 6638 }; 6639}; 6640
vendor: 269 bytes, lines 6641-6645
6641// node_modules/standardized-audio-context/build/es2019/factories/native-media-element-audio-source-node.js 6642var createNativeMediaElementAudioSourceNode = (nativeAudioContext, options) => { 6643 return nativeAudioContext.createMediaElementSource(options.mediaElement); 6644}; 6645
vendor: 604 bytes, lines 6646-6655
6646// node_modules/standardized-audio-context/build/es2019/factories/native-media-stream-audio-destination-node.js 6647var createNativeMediaStreamAudioDestinationNode = (nativeAudioContext, options) => { 6648 const nativeMediaStreamAudioDestinationNode = nativeAudioContext.createMediaStreamDestination(); 6649 assignNativeAudioNodeOptions(nativeMediaStreamAudioDestinationNode, options); 6650 if (nativeMediaStreamAudioDestinationNode.numberOfOutputs === 1) { 6651 Object.defineProperty(nativeMediaStreamAudioDestinationNode, "numberOfOutputs", { get: () => 0 }); 6652 } 6653 return nativeMediaStreamAudioDestinationNode; 6654}; 6655
vendor: 672 bytes, lines 6656-6665
6656// node_modules/standardized-audio-context/build/es2019/factories/native-media-stream-audio-source-node.js 6657var createNativeMediaStreamAudioSourceNode = (nativeAudioContext, { mediaStream }) => { 6658 const audioStreamTracks = mediaStream.getAudioTracks(); 6659 audioStreamTracks.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0); 6660 const filteredAudioStreamTracks = audioStreamTracks.slice(0, 1); 6661 const nativeMediaStreamAudioSourceNode = nativeAudioContext.createMediaStreamSource(new MediaStream(filteredAudioStreamTracks)); 6662 Object.defineProperty(nativeMediaStreamAudioSourceNode, "mediaStream", { value: mediaStream }); 6663 return nativeMediaStreamAudioSourceNode; 6664}; 6665
vendor: 867 bytes, lines 6666-6683
6666// node_modules/standardized-audio-context/build/es2019/factories/native-media-stream-track-audio-source-node-factory.js 6667var createNativeMediaStreamTrackAudioSourceNodeFactory = (createInvalidStateError2, isNativeOfflineAudioContext2) => { 6668 return (nativeAudioContext, { mediaStreamTrack }) => { 6669 if (typeof nativeAudioContext.createMediaStreamTrackSource === "function") { 6670 return nativeAudioContext.createMediaStreamTrackSource(mediaStreamTrack); 6671 } 6672 const mediaStream = new MediaStream([mediaStreamTrack]); 6673 const nativeMediaStreamAudioSourceNode = nativeAudioContext.createMediaStreamSource(mediaStream); 6674 if (mediaStreamTrack.kind !== "audio") { 6675 throw createInvalidStateError2(); 6676 } 6677 if (isNativeOfflineAudioContext2(nativeAudioContext)) { 6678 throw new TypeError(); 6679 } 6680 return nativeMediaStreamAudioSourceNode; 6681 }; 6682}; 6683
vendor: 429 bytes, lines 6684-6694
6684// node_modules/standardized-audio-context/build/es2019/factories/native-offline-audio-context-constructor.js 6685var createNativeOfflineAudioContextConstructor = (window3) => { 6686 if (window3 === null) { 6687 return null; 6688 } 6689 if (window3.hasOwnProperty("OfflineAudioContext")) { 6690 return window3.OfflineAudioContext; 6691 } 6692 return window3.hasOwnProperty("webkitOfflineAudioContext") ? window3.webkitOfflineAudioContext : null; 6693}; 6694
vendor: 1,922 bytes, lines 6695-6720
6695// node_modules/standardized-audio-context/build/es2019/factories/native-oscillator-node-factory.js 6696var createNativeOscillatorNodeFactory = (addSilentConnection2, cacheTestResult2, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2, wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls2) => { 6697 return (nativeContext, options) => { 6698 const nativeOscillatorNode = nativeContext.createOscillator(); 6699 assignNativeAudioNodeOptions(nativeOscillatorNode, options); 6700 assignNativeAudioNodeAudioParamValue(nativeOscillatorNode, options, "detune"); 6701 assignNativeAudioNodeAudioParamValue(nativeOscillatorNode, options, "frequency"); 6702 if (options.periodicWave !== void 0) { 6703 nativeOscillatorNode.setPeriodicWave(options.periodicWave); 6704 } else { 6705 assignNativeAudioNodeOption(nativeOscillatorNode, options, "type"); 6706 } 6707 if (!cacheTestResult2(testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStartMethodNegativeParametersSupport2(nativeContext))) { 6708 wrapAudioScheduledSourceNodeStartMethodNegativeParameters(nativeOscillatorNode); 6709 } 6710 if (!cacheTestResult2(testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2, () => testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport2(nativeContext))) { 6711 wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls2(nativeOscillatorNode, nativeContext); 6712 } 6713 if (!cacheTestResult2(testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2, () => testAudioScheduledSourceNodeStopMethodNegativeParametersSupport2(nativeContext))) { 6714 wrapAudioScheduledSourceNodeStopMethodNegativeParameters(nativeOscillatorNode); 6715 } 6716 addSilentConnection2(nativeContext, nativeOscillatorNode); 6717 return nativeOscillatorNode; 6718 }; 6719}; 6720
vendor: 1,604 bytes, lines 6721-6746
6721// node_modules/standardized-audio-context/build/es2019/factories/native-panner-node-factory.js 6722var createNativePannerNodeFactory = (createNativePannerNodeFaker2) => { 6723 return (nativeContext, options) => { 6724 const nativePannerNode = nativeContext.createPanner(); 6725 if (nativePannerNode.orientationX === void 0) { 6726 return createNativePannerNodeFaker2(nativeContext, options); 6727 } 6728 assignNativeAudioNodeOptions(nativePannerNode, options); 6729 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "orientationX"); 6730 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "orientationY"); 6731 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "orientationZ"); 6732 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "positionX"); 6733 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "positionY"); 6734 assignNativeAudioNodeAudioParamValue(nativePannerNode, options, "positionZ"); 6735 assignNativeAudioNodeOption(nativePannerNode, options, "coneInnerAngle"); 6736 assignNativeAudioNodeOption(nativePannerNode, options, "coneOuterAngle"); 6737 assignNativeAudioNodeOption(nativePannerNode, options, "coneOuterGain"); 6738 assignNativeAudioNodeOption(nativePannerNode, options, "distanceModel"); 6739 assignNativeAudioNodeOption(nativePannerNode, options, "maxDistance"); 6740 assignNativeAudioNodeOption(nativePannerNode, options, "panningModel"); 6741 assignNativeAudioNodeOption(nativePannerNode, options, "refDistance"); 6742 assignNativeAudioNodeOption(nativePannerNode, options, "rolloffFactor"); 6743 return nativePannerNode; 6744 }; 6745}; 6746
vendor: 11,269 bytes, lines 6747-7020
6747// node_modules/standardized-audio-context/build/es2019/factories/native-panner-node-faker-factory.js 6748var createNativePannerNodeFakerFactory = (connectNativeAudioNodeToNativeAudioNode2, createInvalidStateError2, createNativeChannelMergerNode2, createNativeGainNode2, createNativeScriptProcessorNode2, createNativeWaveShaperNode2, createNotSupportedError2, disconnectNativeAudioNodeFromNativeAudioNode2, getFirstSample2, monitorConnections2) => { 6749 return (nativeContext, { coneInnerAngle, coneOuterAngle, coneOuterGain, distanceModel, maxDistance, orientationX, orientationY, orientationZ, panningModel, positionX, positionY, positionZ, refDistance, rolloffFactor, ...audioNodeOptions }) => { 6750 const pannerNode = nativeContext.createPanner(); 6751 if (audioNodeOptions.channelCount > 2) { 6752 throw createNotSupportedError2(); 6753 } 6754 if (audioNodeOptions.channelCountMode === "max") { 6755 throw createNotSupportedError2(); 6756 } 6757 assignNativeAudioNodeOptions(pannerNode, audioNodeOptions); 6758 const SINGLE_CHANNEL_OPTIONS = { 6759 channelCount: 1, 6760 channelCountMode: "explicit", 6761 channelInterpretation: "discrete" 6762 }; 6763 const channelMergerNode = createNativeChannelMergerNode2(nativeContext, { 6764 ...SINGLE_CHANNEL_OPTIONS, 6765 channelInterpretation: "speakers", 6766 numberOfInputs: 6 6767 }); 6768 const inputGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: 1 }); 6769 const orientationXGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 1 }); 6770 const orientationYGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 6771 const orientationZGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 6772 const positionXGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 6773 const positionYGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 6774 const positionZGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 6775 const scriptProcessorNode = createNativeScriptProcessorNode2(nativeContext, 256, 6, 1); 6776 const waveShaperNode = createNativeWaveShaperNode2(nativeContext, { 6777 ...SINGLE_CHANNEL_OPTIONS, 6778 curve: new Float32Array([1, 1]), 6779 oversample: "none" 6780 }); 6781 let lastOrientation = [orientationX, orientationY, orientationZ]; 6782 let lastPosition = [positionX, positionY, positionZ]; 6783 const buffer = new Float32Array(1); 6784 scriptProcessorNode.onaudioprocess = ({ inputBuffer }) => { 6785 const orientation = [ 6786 getFirstSample2(inputBuffer, buffer, 0), 6787 getFirstSample2(inputBuffer, buffer, 1), 6788 getFirstSample2(inputBuffer, buffer, 2) 6789 ]; 6790 if (orientation.some((value, index) => value !== lastOrientation[index])) { 6791 pannerNode.setOrientation(...orientation); 6792 lastOrientation = orientation; 6793 } 6794 const positon = [ 6795 getFirstSample2(inputBuffer, buffer, 3), 6796 getFirstSample2(inputBuffer, buffer, 4), 6797 getFirstSample2(inputBuffer, buffer, 5) 6798 ]; 6799 if (positon.some((value, index) => value !== lastPosition[index])) { 6800 pannerNode.setPosition(...positon); 6801 lastPosition = positon; 6802 } 6803 }; 6804 Object.defineProperty(orientationYGainNode.gain, "defaultValue", { get: () => 0 }); 6805 Object.defineProperty(orientationZGainNode.gain, "defaultValue", { get: () => 0 }); 6806 Object.defineProperty(positionXGainNode.gain, "defaultValue", { get: () => 0 }); 6807 Object.defineProperty(positionYGainNode.gain, "defaultValue", { get: () => 0 }); 6808 Object.defineProperty(positionZGainNode.gain, "defaultValue", { get: () => 0 }); 6809 const nativePannerNodeFaker = { 6810 get bufferSize() { 6811 return void 0; 6812 }, 6813 get channelCount() { 6814 return pannerNode.channelCount; 6815 }, 6816 set channelCount(value) { 6817 if (value > 2) { 6818 throw createNotSupportedError2(); 6819 } 6820 inputGainNode.channelCount = value; 6821 pannerNode.channelCount = value; 6822 }, 6823 get channelCountMode() { 6824 return pannerNode.channelCountMode; 6825 }, 6826 set channelCountMode(value) { 6827 if (value === "max") { 6828 throw createNotSupportedError2(); 6829 } 6830 inputGainNode.channelCountMode = value; 6831 pannerNode.channelCountMode = value; 6832 }, 6833 get channelInterpretation() { 6834 return pannerNode.channelInterpretation; 6835 }, 6836 set channelInterpretation(value) { 6837 inputGainNode.channelInterpretation = value; 6838 pannerNode.channelInterpretation = value; 6839 }, 6840 get coneInnerAngle() { 6841 return pannerNode.coneInnerAngle; 6842 }, 6843 set coneInnerAngle(value) { 6844 pannerNode.coneInnerAngle = value; 6845 }, 6846 get coneOuterAngle() { 6847 return pannerNode.coneOuterAngle; 6848 }, 6849 set coneOuterAngle(value) { 6850 pannerNode.coneOuterAngle = value; 6851 }, 6852 get coneOuterGain() { 6853 return pannerNode.coneOuterGain; 6854 }, 6855 set coneOuterGain(value) { 6856 if (value < 0 || value > 1) { 6857 throw createInvalidStateError2(); 6858 } 6859 pannerNode.coneOuterGain = value; 6860 }, 6861 get context() { 6862 return pannerNode.context; 6863 }, 6864 get distanceModel() { 6865 return pannerNode.distanceModel; 6866 }, 6867 set distanceModel(value) { 6868 pannerNode.distanceModel = value; 6869 }, 6870 get inputs() { 6871 return [inputGainNode]; 6872 }, 6873 get maxDistance() { 6874 return pannerNode.maxDistance; 6875 }, 6876 set maxDistance(value) { 6877 if (value < 0) { 6878 throw new RangeError(); 6879 } 6880 pannerNode.maxDistance = value; 6881 }, 6882 get numberOfInputs() { 6883 return pannerNode.numberOfInputs; 6884 }, 6885 get numberOfOutputs() { 6886 return pannerNode.numberOfOutputs; 6887 }, 6888 get orientationX() { 6889 return orientationXGainNode.gain; 6890 }, 6891 get orientationY() { 6892 return orientationYGainNode.gain; 6893 }, 6894 get orientationZ() { 6895 return orientationZGainNode.gain; 6896 }, 6897 get panningModel() { 6898 return pannerNode.panningModel; 6899 }, 6900 set panningModel(value) { 6901 pannerNode.panningModel = value; 6902 }, 6903 get positionX() { 6904 return positionXGainNode.gain; 6905 }, 6906 get positionY() { 6907 return positionYGainNode.gain; 6908 }, 6909 get positionZ() { 6910 return positionZGainNode.gain; 6911 }, 6912 get refDistance() { 6913 return pannerNode.refDistance; 6914 }, 6915 set refDistance(value) { 6916 if (value < 0) { 6917 throw new RangeError(); 6918 } 6919 pannerNode.refDistance = value; 6920 }, 6921 get rolloffFactor() { 6922 return pannerNode.rolloffFactor; 6923 }, 6924 set rolloffFactor(value) { 6925 if (value < 0) { 6926 throw new RangeError(); 6927 } 6928 pannerNode.rolloffFactor = value; 6929 }, 6930 addEventListener(...args) { 6931 return inputGainNode.addEventListener(args[0], args[1], args[2]); 6932 }, 6933 dispatchEvent(...args) { 6934 return inputGainNode.dispatchEvent(args[0]); 6935 }, 6936 removeEventListener(...args) { 6937 return inputGainNode.removeEventListener(args[0], args[1], args[2]); 6938 } 6939 }; 6940 if (coneInnerAngle !== nativePannerNodeFaker.coneInnerAngle) { 6941 nativePannerNodeFaker.coneInnerAngle = coneInnerAngle; 6942 } 6943 if (coneOuterAngle !== nativePannerNodeFaker.coneOuterAngle) { 6944 nativePannerNodeFaker.coneOuterAngle = coneOuterAngle; 6945 } 6946 if (coneOuterGain !== nativePannerNodeFaker.coneOuterGain) { 6947 nativePannerNodeFaker.coneOuterGain = coneOuterGain; 6948 } 6949 if (distanceModel !== nativePannerNodeFaker.distanceModel) { 6950 nativePannerNodeFaker.distanceModel = distanceModel; 6951 } 6952 if (maxDistance !== nativePannerNodeFaker.maxDistance) { 6953 nativePannerNodeFaker.maxDistance = maxDistance; 6954 } 6955 if (orientationX !== nativePannerNodeFaker.orientationX.value) { 6956 nativePannerNodeFaker.orientationX.value = orientationX; 6957 } 6958 if (orientationY !== nativePannerNodeFaker.orientationY.value) { 6959 nativePannerNodeFaker.orientationY.value = orientationY; 6960 } 6961 if (orientationZ !== nativePannerNodeFaker.orientationZ.value) { 6962 nativePannerNodeFaker.orientationZ.value = orientationZ; 6963 } 6964 if (panningModel !== nativePannerNodeFaker.panningModel) { 6965 nativePannerNodeFaker.panningModel = panningModel; 6966 } 6967 if (positionX !== nativePannerNodeFaker.positionX.value) { 6968 nativePannerNodeFaker.positionX.value = positionX; 6969 } 6970 if (positionY !== nativePannerNodeFaker.positionY.value) { 6971 nativePannerNodeFaker.positionY.value = positionY; 6972 } 6973 if (positionZ !== nativePannerNodeFaker.positionZ.value) { 6974 nativePannerNodeFaker.positionZ.value = positionZ; 6975 } 6976 if (refDistance !== nativePannerNodeFaker.refDistance) { 6977 nativePannerNodeFaker.refDistance = refDistance; 6978 } 6979 if (rolloffFactor !== nativePannerNodeFaker.rolloffFactor) { 6980 nativePannerNodeFaker.rolloffFactor = rolloffFactor; 6981 } 6982 if (lastOrientation[0] !== 1 || lastOrientation[1] !== 0 || lastOrientation[2] !== 0) { 6983 pannerNode.setOrientation(...lastOrientation); 6984 } 6985 if (lastPosition[0] !== 0 || lastPosition[1] !== 0 || lastPosition[2] !== 0) { 6986 pannerNode.setPosition(...lastPosition); 6987 } 6988 const whenConnected = () => { 6989 inputGainNode.connect(pannerNode); 6990 connectNativeAudioNodeToNativeAudioNode2(inputGainNode, waveShaperNode, 0, 0); 6991 waveShaperNode.connect(orientationXGainNode).connect(channelMergerNode, 0, 0); 6992 waveShaperNode.connect(orientationYGainNode).connect(channelMergerNode, 0, 1); 6993 waveShaperNode.connect(orientationZGainNode).connect(channelMergerNode, 0, 2); 6994 waveShaperNode.connect(positionXGainNode).connect(channelMergerNode, 0, 3); 6995 waveShaperNode.connect(positionYGainNode).connect(channelMergerNode, 0, 4); 6996 waveShaperNode.connect(positionZGainNode).connect(channelMergerNode, 0, 5); 6997 channelMergerNode.connect(scriptProcessorNode).connect(nativeContext.destination); 6998 }; 6999 const whenDisconnected = () => { 7000 inputGainNode.disconnect(pannerNode); 7001 disconnectNativeAudioNodeFromNativeAudioNode2(inputGainNode, waveShaperNode, 0, 0); 7002 waveShaperNode.disconnect(orientationXGainNode); 7003 orientationXGainNode.disconnect(channelMergerNode); 7004 waveShaperNode.disconnect(orientationYGainNode); 7005 orientationYGainNode.disconnect(channelMergerNode); 7006 waveShaperNode.disconnect(orientationZGainNode); 7007 orientationZGainNode.disconnect(channelMergerNode); 7008 waveShaperNode.disconnect(positionXGainNode); 7009 positionXGainNode.disconnect(channelMergerNode); 7010 waveShaperNode.disconnect(positionYGainNode); 7011 positionYGainNode.disconnect(channelMergerNode); 7012 waveShaperNode.disconnect(positionZGainNode); 7013 positionZGainNode.disconnect(channelMergerNode); 7014 channelMergerNode.disconnect(scriptProcessorNode); 7015 scriptProcessorNode.disconnect(nativeContext.destination); 7016 }; 7017 return monitorConnections2(interceptConnections(nativePannerNodeFaker, pannerNode), whenConnected, whenDisconnected); 7018 }; 7019}; 7020
vendor: 652 bytes, lines 7021-7033
7021// node_modules/standardized-audio-context/build/es2019/factories/native-periodic-wave-factory.js 7022var createNativePeriodicWaveFactory = (createIndexSizeError2) => { 7023 return (nativeContext, { disableNormalization, imag, real }) => { 7024 const convertedImag = imag instanceof Float32Array ? imag : new Float32Array(imag); 7025 const convertedReal = real instanceof Float32Array ? real : new Float32Array(real); 7026 const nativePeriodicWave = nativeContext.createPeriodicWave(convertedReal, convertedImag, { disableNormalization }); 7027 if (Array.from(imag).length < 2) { 7028 throw createIndexSizeError2(); 7029 } 7030 return nativePeriodicWave; 7031 }; 7032}; 7033
vendor: 325 bytes, lines 7034-7038
7034// node_modules/standardized-audio-context/build/es2019/factories/native-script-processor-node.js 7035var createNativeScriptProcessorNode = (nativeContext, bufferSize, numberOfInputChannels, numberOfOutputChannels) => { 7036 return nativeContext.createScriptProcessor(bufferSize, numberOfInputChannels, numberOfOutputChannels); 7037}; 7038
vendor: 1,038 bytes, lines 7039-7063
7039// node_modules/standardized-audio-context/build/es2019/factories/native-stereo-panner-node-factory.js 7040var createNativeStereoPannerNodeFactory = (createNativeStereoPannerNodeFaker, createNotSupportedError2) => { 7041 return (nativeContext, options) => { 7042 const channelCountMode = options.channelCountMode; 7043 if (channelCountMode === "clamped-max") { 7044 throw createNotSupportedError2(); 7045 } 7046 if (nativeContext.createStereoPanner === void 0) { 7047 return createNativeStereoPannerNodeFaker(nativeContext, options); 7048 } 7049 const nativeStereoPannerNode = nativeContext.createStereoPanner(); 7050 assignNativeAudioNodeOptions(nativeStereoPannerNode, options); 7051 assignNativeAudioNodeAudioParamValue(nativeStereoPannerNode, options, "pan"); 7052 Object.defineProperty(nativeStereoPannerNode, "channelCountMode", { 7053 get: () => channelCountMode, 7054 set: (value) => { 7055 if (value !== channelCountMode) { 7056 throw createNotSupportedError2(); 7057 } 7058 } 7059 }); 7060 return nativeStereoPannerNode; 7061 }; 7062}; 7063
vendor: 13,667 bytes, lines 7064-7305
7064// node_modules/standardized-audio-context/build/es2019/factories/native-stereo-panner-node-faker-factory.js 7065var createNativeStereoPannerNodeFakerFactory = (createNativeChannelMergerNode2, createNativeChannelSplitterNode2, createNativeGainNode2, createNativeWaveShaperNode2, createNotSupportedError2, monitorConnections2) => { 7066 const CURVE_SIZE = 16385; 7067 const DC_CURVE = new Float32Array([1, 1]); 7068 const HALF_PI = Math.PI / 2; 7069 const SINGLE_CHANNEL_OPTIONS = { channelCount: 1, channelCountMode: "explicit", channelInterpretation: "discrete" }; 7070 const SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS = { ...SINGLE_CHANNEL_OPTIONS, oversample: "none" }; 7071 const buildInternalGraphForMono = (nativeContext, inputGainNode, panGainNode, channelMergerNode) => { 7072 const leftWaveShaperCurve = new Float32Array(CURVE_SIZE); 7073 const rightWaveShaperCurve = new Float32Array(CURVE_SIZE); 7074 for (let i = 0; i < CURVE_SIZE; i += 1) { 7075 const x = i / (CURVE_SIZE - 1) * HALF_PI; 7076 leftWaveShaperCurve[i] = Math.cos(x); 7077 rightWaveShaperCurve[i] = Math.sin(x); 7078 } 7079 const leftGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7080 const leftWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, curve: leftWaveShaperCurve }); 7081 const panWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, curve: DC_CURVE }); 7082 const rightGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7083 const rightWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, curve: rightWaveShaperCurve }); 7084 return { 7085 connectGraph() { 7086 inputGainNode.connect(leftGainNode); 7087 inputGainNode.connect(panWaveShaperNode.inputs === void 0 ? panWaveShaperNode : panWaveShaperNode.inputs[0]); 7088 inputGainNode.connect(rightGainNode); 7089 panWaveShaperNode.connect(panGainNode); 7090 panGainNode.connect(leftWaveShaperNode.inputs === void 0 ? leftWaveShaperNode : leftWaveShaperNode.inputs[0]); 7091 panGainNode.connect(rightWaveShaperNode.inputs === void 0 ? rightWaveShaperNode : rightWaveShaperNode.inputs[0]); 7092 leftWaveShaperNode.connect(leftGainNode.gain); 7093 rightWaveShaperNode.connect(rightGainNode.gain); 7094 leftGainNode.connect(channelMergerNode, 0, 0); 7095 rightGainNode.connect(channelMergerNode, 0, 1); 7096 }, 7097 disconnectGraph() { 7098 inputGainNode.disconnect(leftGainNode); 7099 inputGainNode.disconnect(panWaveShaperNode.inputs === void 0 ? panWaveShaperNode : panWaveShaperNode.inputs[0]); 7100 inputGainNode.disconnect(rightGainNode); 7101 panWaveShaperNode.disconnect(panGainNode); 7102 panGainNode.disconnect(leftWaveShaperNode.inputs === void 0 ? leftWaveShaperNode : leftWaveShaperNode.inputs[0]); 7103 panGainNode.disconnect(rightWaveShaperNode.inputs === void 0 ? rightWaveShaperNode : rightWaveShaperNode.inputs[0]); 7104 leftWaveShaperNode.disconnect(leftGainNode.gain); 7105 rightWaveShaperNode.disconnect(rightGainNode.gain); 7106 leftGainNode.disconnect(channelMergerNode, 0, 0); 7107 rightGainNode.disconnect(channelMergerNode, 0, 1); 7108 } 7109 }; 7110 }; 7111 const buildInternalGraphForStereo = (nativeContext, inputGainNode, panGainNode, channelMergerNode) => { 7112 const leftInputForLeftOutputWaveShaperCurve = new Float32Array(CURVE_SIZE); 7113 const leftInputForRightOutputWaveShaperCurve = new Float32Array(CURVE_SIZE); 7114 const rightInputForLeftOutputWaveShaperCurve = new Float32Array(CURVE_SIZE); 7115 const rightInputForRightOutputWaveShaperCurve = new Float32Array(CURVE_SIZE); 7116 const centerIndex = Math.floor(CURVE_SIZE / 2); 7117 for (let i = 0; i < CURVE_SIZE; i += 1) { 7118 if (i > centerIndex) { 7119 const x = (i - centerIndex) / (CURVE_SIZE - 1 - centerIndex) * HALF_PI; 7120 leftInputForLeftOutputWaveShaperCurve[i] = Math.cos(x); 7121 leftInputForRightOutputWaveShaperCurve[i] = Math.sin(x); 7122 rightInputForLeftOutputWaveShaperCurve[i] = 0; 7123 rightInputForRightOutputWaveShaperCurve[i] = 1; 7124 } else { 7125 const x = i / (CURVE_SIZE - 1 - centerIndex) * HALF_PI; 7126 leftInputForLeftOutputWaveShaperCurve[i] = 1; 7127 leftInputForRightOutputWaveShaperCurve[i] = 0; 7128 rightInputForLeftOutputWaveShaperCurve[i] = Math.cos(x); 7129 rightInputForRightOutputWaveShaperCurve[i] = Math.sin(x); 7130 } 7131 } 7132 const channelSplitterNode = createNativeChannelSplitterNode2(nativeContext, { 7133 channelCount: 2, 7134 channelCountMode: "explicit", 7135 channelInterpretation: "discrete", 7136 numberOfOutputs: 2 7137 }); 7138 const leftInputForLeftOutputGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7139 const leftInputForLeftOutputWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { 7140 ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, 7141 curve: leftInputForLeftOutputWaveShaperCurve 7142 }); 7143 const leftInputForRightOutputGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7144 const leftInputForRightOutputWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { 7145 ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, 7146 curve: leftInputForRightOutputWaveShaperCurve 7147 }); 7148 const panWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, curve: DC_CURVE }); 7149 const rightInputForLeftOutputGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7150 const rightInputForLeftOutputWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { 7151 ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, 7152 curve: rightInputForLeftOutputWaveShaperCurve 7153 }); 7154 const rightInputForRightOutputGainNode = createNativeGainNode2(nativeContext, { ...SINGLE_CHANNEL_OPTIONS, gain: 0 }); 7155 const rightInputForRightOutputWaveShaperNode = createNativeWaveShaperNode2(nativeContext, { 7156 ...SINGLE_CHANNEL_WAVE_SHAPER_OPTIONS, 7157 curve: rightInputForRightOutputWaveShaperCurve 7158 }); 7159 return { 7160 connectGraph() { 7161 inputGainNode.connect(channelSplitterNode); 7162 inputGainNode.connect(panWaveShaperNode.inputs === void 0 ? panWaveShaperNode : panWaveShaperNode.inputs[0]); 7163 channelSplitterNode.connect(leftInputForLeftOutputGainNode, 0); 7164 channelSplitterNode.connect(leftInputForRightOutputGainNode, 0); 7165 channelSplitterNode.connect(rightInputForLeftOutputGainNode, 1); 7166 channelSplitterNode.connect(rightInputForRightOutputGainNode, 1); 7167 panWaveShaperNode.connect(panGainNode); 7168 panGainNode.connect(leftInputForLeftOutputWaveShaperNode.inputs === void 0 ? leftInputForLeftOutputWaveShaperNode : leftInputForLeftOutputWaveShaperNode.inputs[0]); 7169 panGainNode.connect(leftInputForRightOutputWaveShaperNode.inputs === void 0 ? leftInputForRightOutputWaveShaperNode : leftInputForRightOutputWaveShaperNode.inputs[0]); 7170 panGainNode.connect(rightInputForLeftOutputWaveShaperNode.inputs === void 0 ? rightInputForLeftOutputWaveShaperNode : rightInputForLeftOutputWaveShaperNode.inputs[0]); 7171 panGainNode.connect(rightInputForRightOutputWaveShaperNode.inputs === void 0 ? rightInputForRightOutputWaveShaperNode : rightInputForRightOutputWaveShaperNode.inputs[0]); 7172 leftInputForLeftOutputWaveShaperNode.connect(leftInputForLeftOutputGainNode.gain); 7173 leftInputForRightOutputWaveShaperNode.connect(leftInputForRightOutputGainNode.gain); 7174 rightInputForLeftOutputWaveShaperNode.connect(rightInputForLeftOutputGainNode.gain); 7175 rightInputForRightOutputWaveShaperNode.connect(rightInputForRightOutputGainNode.gain); 7176 leftInputForLeftOutputGainNode.connect(channelMergerNode, 0, 0); 7177 rightInputForLeftOutputGainNode.connect(channelMergerNode, 0, 0); 7178 leftInputForRightOutputGainNode.connect(channelMergerNode, 0, 1); 7179 rightInputForRightOutputGainNode.connect(channelMergerNode, 0, 1); 7180 }, 7181 disconnectGraph() { 7182 inputGainNode.disconnect(channelSplitterNode); 7183 inputGainNode.disconnect(panWaveShaperNode.inputs === void 0 ? panWaveShaperNode : panWaveShaperNode.inputs[0]); 7184 channelSplitterNode.disconnect(leftInputForLeftOutputGainNode, 0); 7185 channelSplitterNode.disconnect(leftInputForRightOutputGainNode, 0); 7186 channelSplitterNode.disconnect(rightInputForLeftOutputGainNode, 1); 7187 channelSplitterNode.disconnect(rightInputForRightOutputGainNode, 1); 7188 panWaveShaperNode.disconnect(panGainNode); 7189 panGainNode.disconnect(leftInputForLeftOutputWaveShaperNode.inputs === void 0 ? leftInputForLeftOutputWaveShaperNode : leftInputForLeftOutputWaveShaperNode.inputs[0]); 7190 panGainNode.disconnect(leftInputForRightOutputWaveShaperNode.inputs === void 0 ? leftInputForRightOutputWaveShaperNode : leftInputForRightOutputWaveShaperNode.inputs[0]); 7191 panGainNode.disconnect(rightInputForLeftOutputWaveShaperNode.inputs === void 0 ? rightInputForLeftOutputWaveShaperNode : rightInputForLeftOutputWaveShaperNode.inputs[0]); 7192 panGainNode.disconnect(rightInputForRightOutputWaveShaperNode.inputs === void 0 ? rightInputForRightOutputWaveShaperNode : rightInputForRightOutputWaveShaperNode.inputs[0]); 7193 leftInputForLeftOutputWaveShaperNode.disconnect(leftInputForLeftOutputGainNode.gain); 7194 leftInputForRightOutputWaveShaperNode.disconnect(leftInputForRightOutputGainNode.gain); 7195 rightInputForLeftOutputWaveShaperNode.disconnect(rightInputForLeftOutputGainNode.gain); 7196 rightInputForRightOutputWaveShaperNode.disconnect(rightInputForRightOutputGainNode.gain); 7197 leftInputForLeftOutputGainNode.disconnect(channelMergerNode, 0, 0); 7198 rightInputForLeftOutputGainNode.disconnect(channelMergerNode, 0, 0); 7199 leftInputForRightOutputGainNode.disconnect(channelMergerNode, 0, 1); 7200 rightInputForRightOutputGainNode.disconnect(channelMergerNode, 0, 1); 7201 } 7202 }; 7203 }; 7204 const buildInternalGraph = (nativeContext, channelCount, inputGainNode, panGainNode, channelMergerNode) => { 7205 if (channelCount === 1) { 7206 return buildInternalGraphForMono(nativeContext, inputGainNode, panGainNode, channelMergerNode); 7207 } 7208 if (channelCount === 2) { 7209 return buildInternalGraphForStereo(nativeContext, inputGainNode, panGainNode, channelMergerNode); 7210 } 7211 throw createNotSupportedError2(); 7212 }; 7213 return (nativeContext, { channelCount, channelCountMode, pan, ...audioNodeOptions }) => { 7214 if (channelCountMode === "max") { 7215 throw createNotSupportedError2(); 7216 } 7217 const channelMergerNode = createNativeChannelMergerNode2(nativeContext, { 7218 ...audioNodeOptions, 7219 channelCount: 1, 7220 channelCountMode, 7221 numberOfInputs: 2 7222 }); 7223 const inputGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, channelCount, channelCountMode, gain: 1 }); 7224 const panGainNode = createNativeGainNode2(nativeContext, { 7225 channelCount: 1, 7226 channelCountMode: "explicit", 7227 channelInterpretation: "discrete", 7228 gain: pan 7229 }); 7230 let { connectGraph, disconnectGraph } = buildInternalGraph(nativeContext, channelCount, inputGainNode, panGainNode, channelMergerNode); 7231 Object.defineProperty(panGainNode.gain, "defaultValue", { get: () => 0 }); 7232 Object.defineProperty(panGainNode.gain, "maxValue", { get: () => 1 }); 7233 Object.defineProperty(panGainNode.gain, "minValue", { get: () => -1 }); 7234 const nativeStereoPannerNodeFakerFactory2 = { 7235 get bufferSize() { 7236 return void 0; 7237 }, 7238 get channelCount() { 7239 return inputGainNode.channelCount; 7240 }, 7241 set channelCount(value) { 7242 if (inputGainNode.channelCount !== value) { 7243 if (isConnected) { 7244 disconnectGraph(); 7245 } 7246 ({ connectGraph, disconnectGraph } = buildInternalGraph(nativeContext, value, inputGainNode, panGainNode, channelMergerNode)); 7247 if (isConnected) { 7248 connectGraph(); 7249 } 7250 } 7251 inputGainNode.channelCount = value; 7252 }, 7253 get channelCountMode() { 7254 return inputGainNode.channelCountMode; 7255 }, 7256 set channelCountMode(value) { 7257 if (value === "clamped-max" || value === "max") { 7258 throw createNotSupportedError2(); 7259 } 7260 inputGainNode.channelCountMode = value; 7261 }, 7262 get channelInterpretation() { 7263 return inputGainNode.channelInterpretation; 7264 }, 7265 set channelInterpretation(value) { 7266 inputGainNode.channelInterpretation = value; 7267 }, 7268 get context() { 7269 return inputGainNode.context; 7270 }, 7271 get inputs() { 7272 return [inputGainNode]; 7273 }, 7274 get numberOfInputs() { 7275 return inputGainNode.numberOfInputs; 7276 }, 7277 get numberOfOutputs() { 7278 return inputGainNode.numberOfOutputs; 7279 }, 7280 get pan() { 7281 return panGainNode.gain; 7282 }, 7283 addEventListener(...args) { 7284 return inputGainNode.addEventListener(args[0], args[1], args[2]); 7285 }, 7286 dispatchEvent(...args) { 7287 return inputGainNode.dispatchEvent(args[0]); 7288 }, 7289 removeEventListener(...args) { 7290 return inputGainNode.removeEventListener(args[0], args[1], args[2]); 7291 } 7292 }; 7293 let isConnected = false; 7294 const whenConnected = () => { 7295 connectGraph(); 7296 isConnected = true; 7297 }; 7298 const whenDisconnected = () => { 7299 disconnectGraph(); 7300 isConnected = false; 7301 }; 7302 return monitorConnections2(interceptConnections(nativeStereoPannerNodeFakerFactory2, channelMergerNode), whenConnected, whenDisconnected); 7303 }; 7304}; 7305
vendor: 2,471 bytes, lines 7306-7350
7306// node_modules/standardized-audio-context/build/es2019/factories/native-wave-shaper-node-factory.js 7307var createNativeWaveShaperNodeFactory = (createConnectedNativeAudioBufferSourceNode2, createInvalidStateError2, createNativeWaveShaperNodeFaker2, isDCCurve2, monitorConnections2, nativeAudioContextConstructor2, overwriteAccessors2) => { 7308 return (nativeContext, options) => { 7309 const nativeWaveShaperNode = nativeContext.createWaveShaper(); 7310 if (nativeAudioContextConstructor2 !== null && nativeAudioContextConstructor2.name === "webkitAudioContext" && nativeContext.createGain().gain.automationRate === void 0) { 7311 return createNativeWaveShaperNodeFaker2(nativeContext, options); 7312 } 7313 assignNativeAudioNodeOptions(nativeWaveShaperNode, options); 7314 const curve = options.curve === null || options.curve instanceof Float32Array ? options.curve : new Float32Array(options.curve); 7315 if (curve !== null && curve.length < 2) { 7316 throw createInvalidStateError2(); 7317 } 7318 assignNativeAudioNodeOption(nativeWaveShaperNode, { curve }, "curve"); 7319 assignNativeAudioNodeOption(nativeWaveShaperNode, options, "oversample"); 7320 let disconnectNativeAudioBufferSourceNode = null; 7321 let isConnected = false; 7322 overwriteAccessors2(nativeWaveShaperNode, "curve", (get) => () => get.call(nativeWaveShaperNode), (set) => (value) => { 7323 set.call(nativeWaveShaperNode, value); 7324 if (isConnected) { 7325 if (isDCCurve2(value) && disconnectNativeAudioBufferSourceNode === null) { 7326 disconnectNativeAudioBufferSourceNode = createConnectedNativeAudioBufferSourceNode2(nativeContext, nativeWaveShaperNode); 7327 } else if (!isDCCurve2(value) && disconnectNativeAudioBufferSourceNode !== null) { 7328 disconnectNativeAudioBufferSourceNode(); 7329 disconnectNativeAudioBufferSourceNode = null; 7330 } 7331 } 7332 return value; 7333 }); 7334 const whenConnected = () => { 7335 isConnected = true; 7336 if (isDCCurve2(nativeWaveShaperNode.curve)) { 7337 disconnectNativeAudioBufferSourceNode = createConnectedNativeAudioBufferSourceNode2(nativeContext, nativeWaveShaperNode); 7338 } 7339 }; 7340 const whenDisconnected = () => { 7341 isConnected = false; 7342 if (disconnectNativeAudioBufferSourceNode !== null) { 7343 disconnectNativeAudioBufferSourceNode(); 7344 disconnectNativeAudioBufferSourceNode = null; 7345 } 7346 }; 7347 return monitorConnections2(nativeWaveShaperNode, whenConnected, whenDisconnected); 7348 }; 7349}; 7350
vendor: 7,096 bytes, lines 7351-7500
7351// node_modules/standardized-audio-context/build/es2019/factories/native-wave-shaper-node-faker-factory.js 7352var createNativeWaveShaperNodeFakerFactory = (createConnectedNativeAudioBufferSourceNode2, createInvalidStateError2, createNativeGainNode2, isDCCurve2, monitorConnections2) => { 7353 return (nativeContext, { curve, oversample, ...audioNodeOptions }) => { 7354 const negativeWaveShaperNode = nativeContext.createWaveShaper(); 7355 const positiveWaveShaperNode = nativeContext.createWaveShaper(); 7356 assignNativeAudioNodeOptions(negativeWaveShaperNode, audioNodeOptions); 7357 assignNativeAudioNodeOptions(positiveWaveShaperNode, audioNodeOptions); 7358 const inputGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: 1 }); 7359 const invertGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: -1 }); 7360 const outputGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: 1 }); 7361 const revertGainNode = createNativeGainNode2(nativeContext, { ...audioNodeOptions, gain: -1 }); 7362 let disconnectNativeAudioBufferSourceNode = null; 7363 let isConnected = false; 7364 let unmodifiedCurve = null; 7365 const nativeWaveShaperNodeFaker = { 7366 get bufferSize() { 7367 return void 0; 7368 }, 7369 get channelCount() { 7370 return negativeWaveShaperNode.channelCount; 7371 }, 7372 set channelCount(value) { 7373 inputGainNode.channelCount = value; 7374 invertGainNode.channelCount = value; 7375 negativeWaveShaperNode.channelCount = value; 7376 outputGainNode.channelCount = value; 7377 positiveWaveShaperNode.channelCount = value; 7378 revertGainNode.channelCount = value; 7379 }, 7380 get channelCountMode() { 7381 return negativeWaveShaperNode.channelCountMode; 7382 }, 7383 set channelCountMode(value) { 7384 inputGainNode.channelCountMode = value; 7385 invertGainNode.channelCountMode = value; 7386 negativeWaveShaperNode.channelCountMode = value; 7387 outputGainNode.channelCountMode = value; 7388 positiveWaveShaperNode.channelCountMode = value; 7389 revertGainNode.channelCountMode = value; 7390 }, 7391 get channelInterpretation() { 7392 return negativeWaveShaperNode.channelInterpretation; 7393 }, 7394 set channelInterpretation(value) { 7395 inputGainNode.channelInterpretation = value; 7396 invertGainNode.channelInterpretation = value; 7397 negativeWaveShaperNode.channelInterpretation = value; 7398 outputGainNode.channelInterpretation = value; 7399 positiveWaveShaperNode.channelInterpretation = value; 7400 revertGainNode.channelInterpretation = value; 7401 }, 7402 get context() { 7403 return negativeWaveShaperNode.context; 7404 }, 7405 get curve() { 7406 return unmodifiedCurve; 7407 }, 7408 set curve(value) { 7409 if (value !== null && value.length < 2) { 7410 throw createInvalidStateError2(); 7411 } 7412 if (value === null) { 7413 negativeWaveShaperNode.curve = value; 7414 positiveWaveShaperNode.curve = value; 7415 } else { 7416 const curveLength = value.length; 7417 const negativeCurve = new Float32Array(curveLength + 2 - curveLength % 2); 7418 const positiveCurve = new Float32Array(curveLength + 2 - curveLength % 2); 7419 negativeCurve[0] = value[0]; 7420 positiveCurve[0] = -value[curveLength - 1]; 7421 const length = Math.ceil((curveLength + 1) / 2); 7422 const centerIndex = (curveLength + 1) / 2 - 1; 7423 for (let i = 1; i < length; i += 1) { 7424 const theoreticIndex = i / length * centerIndex; 7425 const lowerIndex = Math.floor(theoreticIndex); 7426 const upperIndex = Math.ceil(theoreticIndex); 7427 negativeCurve[i] = lowerIndex === upperIndex ? value[lowerIndex] : (1 - (theoreticIndex - lowerIndex)) * value[lowerIndex] + (1 - (upperIndex - theoreticIndex)) * value[upperIndex]; 7428 positiveCurve[i] = lowerIndex === upperIndex ? -value[curveLength - 1 - lowerIndex] : -((1 - (theoreticIndex - lowerIndex)) * value[curveLength - 1 - lowerIndex]) - (1 - (upperIndex - theoreticIndex)) * value[curveLength - 1 - upperIndex]; 7429 } 7430 negativeCurve[length] = curveLength % 2 === 1 ? value[length - 1] : (value[length - 2] + value[length - 1]) / 2; 7431 negativeWaveShaperNode.curve = negativeCurve; 7432 positiveWaveShaperNode.curve = positiveCurve; 7433 } 7434 unmodifiedCurve = value; 7435 if (isConnected) { 7436 if (isDCCurve2(unmodifiedCurve) && disconnectNativeAudioBufferSourceNode === null) { 7437 disconnectNativeAudioBufferSourceNode = createConnectedNativeAudioBufferSourceNode2(nativeContext, inputGainNode); 7438 } else if (disconnectNativeAudioBufferSourceNode !== null) { 7439 disconnectNativeAudioBufferSourceNode(); 7440 disconnectNativeAudioBufferSourceNode = null; 7441 } 7442 } 7443 }, 7444 get inputs() { 7445 return [inputGainNode]; 7446 }, 7447 get numberOfInputs() { 7448 return negativeWaveShaperNode.numberOfInputs; 7449 }, 7450 get numberOfOutputs() { 7451 return negativeWaveShaperNode.numberOfOutputs; 7452 }, 7453 get oversample() { 7454 return negativeWaveShaperNode.oversample; 7455 }, 7456 set oversample(value) { 7457 negativeWaveShaperNode.oversample = value; 7458 positiveWaveShaperNode.oversample = value; 7459 }, 7460 addEventListener(...args) { 7461 return inputGainNode.addEventListener(args[0], args[1], args[2]); 7462 }, 7463 dispatchEvent(...args) { 7464 return inputGainNode.dispatchEvent(args[0]); 7465 }, 7466 removeEventListener(...args) { 7467 return inputGainNode.removeEventListener(args[0], args[1], args[2]); 7468 } 7469 }; 7470 if (curve !== null) { 7471 nativeWaveShaperNodeFaker.curve = curve instanceof Float32Array ? curve : new Float32Array(curve); 7472 } 7473 if (oversample !== nativeWaveShaperNodeFaker.oversample) { 7474 nativeWaveShaperNodeFaker.oversample = oversample; 7475 } 7476 const whenConnected = () => { 7477 inputGainNode.connect(negativeWaveShaperNode).connect(outputGainNode); 7478 inputGainNode.connect(invertGainNode).connect(positiveWaveShaperNode).connect(revertGainNode).connect(outputGainNode); 7479 isConnected = true; 7480 if (isDCCurve2(unmodifiedCurve)) { 7481 disconnectNativeAudioBufferSourceNode = createConnectedNativeAudioBufferSourceNode2(nativeContext, inputGainNode); 7482 } 7483 }; 7484 const whenDisconnected = () => { 7485 inputGainNode.disconnect(negativeWaveShaperNode); 7486 negativeWaveShaperNode.disconnect(outputGainNode); 7487 inputGainNode.disconnect(invertGainNode); 7488 invertGainNode.disconnect(positiveWaveShaperNode); 7489 positiveWaveShaperNode.disconnect(revertGainNode); 7490 revertGainNode.disconnect(outputGainNode); 7491 isConnected = false; 7492 if (disconnectNativeAudioBufferSourceNode !== null) { 7493 disconnectNativeAudioBufferSourceNode(); 7494 disconnectNativeAudioBufferSourceNode = null; 7495 } 7496 }; 7497 return monitorConnections2(interceptConnections(nativeWaveShaperNodeFaker, outputGainNode), whenConnected, whenDisconnected); 7498 }; 7499}; 7500
vendor: 169 bytes, lines 7501-7503
7501// node_modules/standardized-audio-context/build/es2019/factories/not-supported-error.js 7502var createNotSupportedError = () => new DOMException("", "NotSupportedError"); 7503
vendor: 2,693 bytes, lines 7504-7571
7504// node_modules/standardized-audio-context/build/es2019/factories/offline-audio-context-constructor.js 7505var DEFAULT_OPTIONS16 = { 7506 numberOfChannels: 1 7507}; 7508var createOfflineAudioContextConstructor = (baseAudioContextConstructor2, cacheTestResult2, createInvalidStateError2, createNativeOfflineAudioContext2, startRendering2) => { 7509 return class OfflineAudioContext extends baseAudioContextConstructor2 { 7510 constructor(a, b, c) { 7511 let options; 7512 if (typeof a === "number" && b !== void 0 && c !== void 0) { 7513 options = { length: b, numberOfChannels: a, sampleRate: c }; 7514 } else if (typeof a === "object") { 7515 options = a; 7516 } else { 7517 throw new Error("The given parameters are not valid."); 7518 } 7519 const { length, numberOfChannels, sampleRate } = { ...DEFAULT_OPTIONS16, ...options }; 7520 const nativeOfflineAudioContext = createNativeOfflineAudioContext2(numberOfChannels, length, sampleRate); 7521 if (!cacheTestResult2(testPromiseSupport, () => testPromiseSupport(nativeOfflineAudioContext))) { 7522 nativeOfflineAudioContext.addEventListener("statechange", /* @__PURE__ */ (() => { 7523 let i = 0; 7524 const delayStateChangeEvent = (event) => { 7525 if (this._state === "running") { 7526 if (i > 0) { 7527 nativeOfflineAudioContext.removeEventListener("statechange", delayStateChangeEvent); 7528 event.stopImmediatePropagation(); 7529 this._waitForThePromiseToSettle(event); 7530 } else { 7531 i += 1; 7532 } 7533 } 7534 }; 7535 return delayStateChangeEvent; 7536 })()); 7537 } 7538 super(nativeOfflineAudioContext, numberOfChannels); 7539 this._length = length; 7540 this._nativeOfflineAudioContext = nativeOfflineAudioContext; 7541 this._state = null; 7542 } 7543 get length() { 7544 if (this._nativeOfflineAudioContext.length === void 0) { 7545 return this._length; 7546 } 7547 return this._nativeOfflineAudioContext.length; 7548 } 7549 get state() { 7550 return this._state === null ? this._nativeOfflineAudioContext.state : this._state; 7551 } 7552 startRendering() { 7553 if (this._state === "running") { 7554 return Promise.reject(createInvalidStateError2()); 7555 } 7556 this._state = "running"; 7557 return startRendering2(this.destination, this._nativeOfflineAudioContext).finally(() => { 7558 this._state = null; 7559 deactivateAudioGraph(this); 7560 }); 7561 } 7562 _waitForThePromiseToSettle(event) { 7563 if (this._state === null) { 7564 this._nativeOfflineAudioContext.dispatchEvent(event); 7565 } else { 7566 setTimeout(() => this._waitForThePromiseToSettle(event)); 7567 } 7568 } 7569 }; 7570}; 7571
vendor: 3,590 bytes, lines 7572-7657
7572// node_modules/standardized-audio-context/build/es2019/factories/oscillator-node-constructor.js 7573var DEFAULT_OPTIONS17 = { 7574 channelCount: 2, 7575 channelCountMode: "max", 7576 // This attribute has no effect for nodes with no inputs. 7577 channelInterpretation: "speakers", 7578 // This attribute has no effect for nodes with no inputs. 7579 detune: 0, 7580 frequency: 440, 7581 periodicWave: void 0, 7582 type: "sine" 7583}; 7584var createOscillatorNodeConstructor = (audioNodeConstructor2, createAudioParam2, createNativeOscillatorNode2, createOscillatorNodeRenderer2, getNativeContext2, isNativeOfflineAudioContext2, wrapEventListener2) => { 7585 return class OscillatorNode extends audioNodeConstructor2 { 7586 constructor(context2, options) { 7587 const nativeContext = getNativeContext2(context2); 7588 const mergedOptions = { ...DEFAULT_OPTIONS17, ...options }; 7589 const nativeOscillatorNode = createNativeOscillatorNode2(nativeContext, mergedOptions); 7590 const isOffline = isNativeOfflineAudioContext2(nativeContext); 7591 const oscillatorNodeRenderer = isOffline ? createOscillatorNodeRenderer2() : null; 7592 const nyquist = context2.sampleRate / 2; 7593 super(context2, false, nativeOscillatorNode, oscillatorNodeRenderer); 7594 this._detune = createAudioParam2(this, isOffline, nativeOscillatorNode.detune, 153600, -153600); 7595 this._frequency = createAudioParam2(this, isOffline, nativeOscillatorNode.frequency, nyquist, -nyquist); 7596 this._nativeOscillatorNode = nativeOscillatorNode; 7597 this._onended = null; 7598 this._oscillatorNodeRenderer = oscillatorNodeRenderer; 7599 if (this._oscillatorNodeRenderer !== null && mergedOptions.periodicWave !== void 0) { 7600 this._oscillatorNodeRenderer.periodicWave = mergedOptions.periodicWave; 7601 } 7602 } 7603 get detune() { 7604 return this._detune; 7605 } 7606 get frequency() { 7607 return this._frequency; 7608 } 7609 get onended() { 7610 return this._onended; 7611 } 7612 set onended(value) { 7613 const wrappedListener = typeof value === "function" ? wrapEventListener2(this, value) : null; 7614 this._nativeOscillatorNode.onended = wrappedListener; 7615 const nativeOnEnded = this._nativeOscillatorNode.onended; 7616 this._onended = nativeOnEnded !== null && nativeOnEnded === wrappedListener ? value : nativeOnEnded; 7617 } 7618 get type() { 7619 return this._nativeOscillatorNode.type; 7620 } 7621 set type(value) { 7622 this._nativeOscillatorNode.type = value; 7623 if (this._oscillatorNodeRenderer !== null) { 7624 this._oscillatorNodeRenderer.periodicWave = null; 7625 } 7626 } 7627 setPeriodicWave(periodicWave) { 7628 this._nativeOscillatorNode.setPeriodicWave(periodicWave); 7629 if (this._oscillatorNodeRenderer !== null) { 7630 this._oscillatorNodeRenderer.periodicWave = periodicWave; 7631 } 7632 } 7633 start(when = 0) { 7634 this._nativeOscillatorNode.start(when); 7635 if (this._oscillatorNodeRenderer !== null) { 7636 this._oscillatorNodeRenderer.start = when; 7637 } 7638 if (this.context.state !== "closed") { 7639 setInternalStateToActive(this); 7640 const resetInternalStateToPassive = () => { 7641 this._nativeOscillatorNode.removeEventListener("ended", resetInternalStateToPassive); 7642 if (isActiveAudioNode(this)) { 7643 setInternalStateToPassive(this); 7644 } 7645 }; 7646 this._nativeOscillatorNode.addEventListener("ended", resetInternalStateToPassive); 7647 } 7648 } 7649 stop(when = 0) { 7650 this._nativeOscillatorNode.stop(when); 7651 if (this._oscillatorNodeRenderer !== null) { 7652 this._oscillatorNodeRenderer.stop = when; 7653 } 7654 } 7655 }; 7656}; 7657
vendor: 2,778 bytes, lines 7658-7717
7658// node_modules/standardized-audio-context/build/es2019/factories/oscillator-node-renderer-factory.js 7659var createOscillatorNodeRendererFactory = (connectAudioParam2, createNativeOscillatorNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 7660 return () => { 7661 const renderedNativeOscillatorNodes = /* @__PURE__ */ new WeakMap(); 7662 let periodicWave = null; 7663 let start2 = null; 7664 let stop = null; 7665 const createOscillatorNode = async (proxy, nativeOfflineAudioContext) => { 7666 let nativeOscillatorNode = getNativeAudioNode2(proxy); 7667 const nativeOscillatorNodeIsOwnedByContext = isOwnedByContext(nativeOscillatorNode, nativeOfflineAudioContext); 7668 if (!nativeOscillatorNodeIsOwnedByContext) { 7669 const options = { 7670 channelCount: nativeOscillatorNode.channelCount, 7671 channelCountMode: nativeOscillatorNode.channelCountMode, 7672 channelInterpretation: nativeOscillatorNode.channelInterpretation, 7673 detune: nativeOscillatorNode.detune.value, 7674 frequency: nativeOscillatorNode.frequency.value, 7675 periodicWave: periodicWave === null ? void 0 : periodicWave, 7676 type: nativeOscillatorNode.type 7677 }; 7678 nativeOscillatorNode = createNativeOscillatorNode2(nativeOfflineAudioContext, options); 7679 if (start2 !== null) { 7680 nativeOscillatorNode.start(start2); 7681 } 7682 if (stop !== null) { 7683 nativeOscillatorNode.stop(stop); 7684 } 7685 } 7686 renderedNativeOscillatorNodes.set(nativeOfflineAudioContext, nativeOscillatorNode); 7687 if (!nativeOscillatorNodeIsOwnedByContext) { 7688 await renderAutomation2(nativeOfflineAudioContext, proxy.detune, nativeOscillatorNode.detune); 7689 await renderAutomation2(nativeOfflineAudioContext, proxy.frequency, nativeOscillatorNode.frequency); 7690 } else { 7691 await connectAudioParam2(nativeOfflineAudioContext, proxy.detune, nativeOscillatorNode.detune); 7692 await connectAudioParam2(nativeOfflineAudioContext, proxy.frequency, nativeOscillatorNode.frequency); 7693 } 7694 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeOscillatorNode); 7695 return nativeOscillatorNode; 7696 }; 7697 return { 7698 set periodicWave(value) { 7699 periodicWave = value; 7700 }, 7701 set start(value) { 7702 start2 = value; 7703 }, 7704 set stop(value) { 7705 stop = value; 7706 }, 7707 render(proxy, nativeOfflineAudioContext) { 7708 const renderedNativeOscillatorNode = renderedNativeOscillatorNodes.get(nativeOfflineAudioContext); 7709 if (renderedNativeOscillatorNode !== void 0) { 7710 return Promise.resolve(renderedNativeOscillatorNode); 7711 } 7712 return createOscillatorNode(proxy, nativeOfflineAudioContext); 7713 } 7714 }; 7715 }; 7716}; 7717
vendor: 3,941 bytes, lines 7718-7824
7718// node_modules/standardized-audio-context/build/es2019/factories/panner-node-constructor.js 7719var DEFAULT_OPTIONS18 = { 7720 channelCount: 2, 7721 channelCountMode: "clamped-max", 7722 channelInterpretation: "speakers", 7723 coneInnerAngle: 360, 7724 coneOuterAngle: 360, 7725 coneOuterGain: 0, 7726 distanceModel: "inverse", 7727 maxDistance: 1e4, 7728 orientationX: 1, 7729 orientationY: 0, 7730 orientationZ: 0, 7731 panningModel: "equalpower", 7732 positionX: 0, 7733 positionY: 0, 7734 positionZ: 0, 7735 refDistance: 1, 7736 rolloffFactor: 1 7737}; 7738var createPannerNodeConstructor = (audioNodeConstructor2, createAudioParam2, createNativePannerNode2, createPannerNodeRenderer2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 7739 return class PannerNode extends audioNodeConstructor2 { 7740 constructor(context2, options) { 7741 const nativeContext = getNativeContext2(context2); 7742 const mergedOptions = { ...DEFAULT_OPTIONS18, ...options }; 7743 const nativePannerNode = createNativePannerNode2(nativeContext, mergedOptions); 7744 const isOffline = isNativeOfflineAudioContext2(nativeContext); 7745 const pannerNodeRenderer = isOffline ? createPannerNodeRenderer2() : null; 7746 super(context2, false, nativePannerNode, pannerNodeRenderer); 7747 this._nativePannerNode = nativePannerNode; 7748 this._orientationX = createAudioParam2(this, isOffline, nativePannerNode.orientationX, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7749 this._orientationY = createAudioParam2(this, isOffline, nativePannerNode.orientationY, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7750 this._orientationZ = createAudioParam2(this, isOffline, nativePannerNode.orientationZ, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7751 this._positionX = createAudioParam2(this, isOffline, nativePannerNode.positionX, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7752 this._positionY = createAudioParam2(this, isOffline, nativePannerNode.positionY, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7753 this._positionZ = createAudioParam2(this, isOffline, nativePannerNode.positionZ, MOST_POSITIVE_SINGLE_FLOAT, MOST_NEGATIVE_SINGLE_FLOAT); 7754 setAudioNodeTailTime2(this, 1); 7755 } 7756 get coneInnerAngle() { 7757 return this._nativePannerNode.coneInnerAngle; 7758 } 7759 set coneInnerAngle(value) { 7760 this._nativePannerNode.coneInnerAngle = value; 7761 } 7762 get coneOuterAngle() { 7763 return this._nativePannerNode.coneOuterAngle; 7764 } 7765 set coneOuterAngle(value) { 7766 this._nativePannerNode.coneOuterAngle = value; 7767 } 7768 get coneOuterGain() { 7769 return this._nativePannerNode.coneOuterGain; 7770 } 7771 set coneOuterGain(value) { 7772 this._nativePannerNode.coneOuterGain = value; 7773 } 7774 get distanceModel() { 7775 return this._nativePannerNode.distanceModel; 7776 } 7777 set distanceModel(value) { 7778 this._nativePannerNode.distanceModel = value; 7779 } 7780 get maxDistance() { 7781 return this._nativePannerNode.maxDistance; 7782 } 7783 set maxDistance(value) { 7784 this._nativePannerNode.maxDistance = value; 7785 } 7786 get orientationX() { 7787 return this._orientationX; 7788 } 7789 get orientationY() { 7790 return this._orientationY; 7791 } 7792 get orientationZ() { 7793 return this._orientationZ; 7794 } 7795 get panningModel() { 7796 return this._nativePannerNode.panningModel; 7797 } 7798 set panningModel(value) { 7799 this._nativePannerNode.panningModel = value; 7800 } 7801 get positionX() { 7802 return this._positionX; 7803 } 7804 get positionY() { 7805 return this._positionY; 7806 } 7807 get positionZ() { 7808 return this._positionZ; 7809 } 7810 get refDistance() { 7811 return this._nativePannerNode.refDistance; 7812 } 7813 set refDistance(value) { 7814 this._nativePannerNode.refDistance = value; 7815 } 7816 get rolloffFactor() { 7817 return this._nativePannerNode.rolloffFactor; 7818 } 7819 set rolloffFactor(value) { 7820 this._nativePannerNode.rolloffFactor = value; 7821 } 7822 }; 7823}; 7824
vendor: 9,192 bytes, lines 7825-7987
7825// node_modules/standardized-audio-context/build/es2019/factories/panner-node-renderer-factory.js 7826var createPannerNodeRendererFactory = (connectAudioParam2, createNativeChannelMergerNode2, createNativeConstantSourceNode2, createNativeGainNode2, createNativePannerNode2, getNativeAudioNode2, nativeOfflineAudioContextConstructor2, renderAutomation2, renderInputsOfAudioNode2, renderNativeOfflineAudioContext2) => { 7827 return () => { 7828 const renderedNativeAudioNodes = /* @__PURE__ */ new WeakMap(); 7829 let renderedBufferPromise = null; 7830 const createAudioNode = async (proxy, nativeOfflineAudioContext) => { 7831 let nativeGainNode = null; 7832 let nativePannerNode = getNativeAudioNode2(proxy); 7833 const commonAudioNodeOptions = { 7834 channelCount: nativePannerNode.channelCount, 7835 channelCountMode: nativePannerNode.channelCountMode, 7836 channelInterpretation: nativePannerNode.channelInterpretation 7837 }; 7838 const commonNativePannerNodeOptions = { 7839 ...commonAudioNodeOptions, 7840 coneInnerAngle: nativePannerNode.coneInnerAngle, 7841 coneOuterAngle: nativePannerNode.coneOuterAngle, 7842 coneOuterGain: nativePannerNode.coneOuterGain, 7843 distanceModel: nativePannerNode.distanceModel, 7844 maxDistance: nativePannerNode.maxDistance, 7845 panningModel: nativePannerNode.panningModel, 7846 refDistance: nativePannerNode.refDistance, 7847 rolloffFactor: nativePannerNode.rolloffFactor 7848 }; 7849 const nativePannerNodeIsOwnedByContext = isOwnedByContext(nativePannerNode, nativeOfflineAudioContext); 7850 if ("bufferSize" in nativePannerNode) { 7851 nativeGainNode = createNativeGainNode2(nativeOfflineAudioContext, { ...commonAudioNodeOptions, gain: 1 }); 7852 } else if (!nativePannerNodeIsOwnedByContext) { 7853 const options = { 7854 ...commonNativePannerNodeOptions, 7855 orientationX: nativePannerNode.orientationX.value, 7856 orientationY: nativePannerNode.orientationY.value, 7857 orientationZ: nativePannerNode.orientationZ.value, 7858 positionX: nativePannerNode.positionX.value, 7859 positionY: nativePannerNode.positionY.value, 7860 positionZ: nativePannerNode.positionZ.value 7861 }; 7862 nativePannerNode = createNativePannerNode2(nativeOfflineAudioContext, options); 7863 } 7864 renderedNativeAudioNodes.set(nativeOfflineAudioContext, nativeGainNode === null ? nativePannerNode : nativeGainNode); 7865 if (nativeGainNode !== null) { 7866 if (renderedBufferPromise === null) { 7867 if (nativeOfflineAudioContextConstructor2 === null) { 7868 throw new Error("Missing the native OfflineAudioContext constructor."); 7869 } 7870 const partialOfflineAudioContext = new nativeOfflineAudioContextConstructor2( 7871 6, 7872 // Bug #17: Safari does not yet expose the length. 7873 proxy.context.length, 7874 nativeOfflineAudioContext.sampleRate 7875 ); 7876 const nativeChannelMergerNode = createNativeChannelMergerNode2(partialOfflineAudioContext, { 7877 channelCount: 1, 7878 channelCountMode: "explicit", 7879 channelInterpretation: "speakers", 7880 numberOfInputs: 6 7881 }); 7882 nativeChannelMergerNode.connect(partialOfflineAudioContext.destination); 7883 renderedBufferPromise = (async () => { 7884 const nativeConstantSourceNodes = await Promise.all([ 7885 proxy.orientationX, 7886 proxy.orientationY, 7887 proxy.orientationZ, 7888 proxy.positionX, 7889 proxy.positionY, 7890 proxy.positionZ 7891 ].map(async (audioParam, index) => { 7892 const nativeConstantSourceNode = createNativeConstantSourceNode2(partialOfflineAudioContext, { 7893 channelCount: 1, 7894 channelCountMode: "explicit", 7895 channelInterpretation: "discrete", 7896 offset: index === 0 ? 1 : 0 7897 }); 7898 await renderAutomation2(partialOfflineAudioContext, audioParam, nativeConstantSourceNode.offset); 7899 return nativeConstantSourceNode; 7900 })); 7901 for (let i = 0; i < 6; i += 1) { 7902 nativeConstantSourceNodes[i].connect(nativeChannelMergerNode, 0, i); 7903 nativeConstantSourceNodes[i].start(0); 7904 } 7905 return renderNativeOfflineAudioContext2(partialOfflineAudioContext); 7906 })(); 7907 } 7908 const renderedBuffer = await renderedBufferPromise; 7909 const inputGainNode = createNativeGainNode2(nativeOfflineAudioContext, { ...commonAudioNodeOptions, gain: 1 }); 7910 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, inputGainNode); 7911 const channelDatas = []; 7912 for (let i = 0; i < renderedBuffer.numberOfChannels; i += 1) { 7913 channelDatas.push(renderedBuffer.getChannelData(i)); 7914 } 7915 let lastOrientation = [channelDatas[0][0], channelDatas[1][0], channelDatas[2][0]]; 7916 let lastPosition = [channelDatas[3][0], channelDatas[4][0], channelDatas[5][0]]; 7917 let gateGainNode = createNativeGainNode2(nativeOfflineAudioContext, { ...commonAudioNodeOptions, gain: 1 }); 7918 let partialPannerNode = createNativePannerNode2(nativeOfflineAudioContext, { 7919 ...commonNativePannerNodeOptions, 7920 orientationX: lastOrientation[0], 7921 orientationY: lastOrientation[1], 7922 orientationZ: lastOrientation[2], 7923 positionX: lastPosition[0], 7924 positionY: lastPosition[1], 7925 positionZ: lastPosition[2] 7926 }); 7927 inputGainNode.connect(gateGainNode).connect(partialPannerNode.inputs[0]); 7928 partialPannerNode.connect(nativeGainNode); 7929 for (let i = 128; i < renderedBuffer.length; i += 128) { 7930 const orientation = [channelDatas[0][i], channelDatas[1][i], channelDatas[2][i]]; 7931 const positon = [channelDatas[3][i], channelDatas[4][i], channelDatas[5][i]]; 7932 if (orientation.some((value, index) => value !== lastOrientation[index]) || positon.some((value, index) => value !== lastPosition[index])) { 7933 lastOrientation = orientation; 7934 lastPosition = positon; 7935 const currentTime = i / nativeOfflineAudioContext.sampleRate; 7936 gateGainNode.gain.setValueAtTime(0, currentTime); 7937 gateGainNode = createNativeGainNode2(nativeOfflineAudioContext, { ...commonAudioNodeOptions, gain: 0 }); 7938 partialPannerNode = createNativePannerNode2(nativeOfflineAudioContext, { 7939 ...commonNativePannerNodeOptions, 7940 orientationX: lastOrientation[0], 7941 orientationY: lastOrientation[1], 7942 orientationZ: lastOrientation[2], 7943 positionX: lastPosition[0], 7944 positionY: lastPosition[1], 7945 positionZ: lastPosition[2] 7946 }); 7947 gateGainNode.gain.setValueAtTime(1, currentTime); 7948 inputGainNode.connect(gateGainNode).connect(partialPannerNode.inputs[0]); 7949 partialPannerNode.connect(nativeGainNode); 7950 } 7951 } 7952 return nativeGainNode; 7953 } 7954 if (!nativePannerNodeIsOwnedByContext) { 7955 await renderAutomation2(nativeOfflineAudioContext, proxy.orientationX, nativePannerNode.orientationX); 7956 await renderAutomation2(nativeOfflineAudioContext, proxy.orientationY, nativePannerNode.orientationY); 7957 await renderAutomation2(nativeOfflineAudioContext, proxy.orientationZ, nativePannerNode.orientationZ); 7958 await renderAutomation2(nativeOfflineAudioContext, proxy.positionX, nativePannerNode.positionX); 7959 await renderAutomation2(nativeOfflineAudioContext, proxy.positionY, nativePannerNode.positionY); 7960 await renderAutomation2(nativeOfflineAudioContext, proxy.positionZ, nativePannerNode.positionZ); 7961 } else { 7962 await connectAudioParam2(nativeOfflineAudioContext, proxy.orientationX, nativePannerNode.orientationX); 7963 await connectAudioParam2(nativeOfflineAudioContext, proxy.orientationY, nativePannerNode.orientationY); 7964 await connectAudioParam2(nativeOfflineAudioContext, proxy.orientationZ, nativePannerNode.orientationZ); 7965 await connectAudioParam2(nativeOfflineAudioContext, proxy.positionX, nativePannerNode.positionX); 7966 await connectAudioParam2(nativeOfflineAudioContext, proxy.positionY, nativePannerNode.positionY); 7967 await connectAudioParam2(nativeOfflineAudioContext, proxy.positionZ, nativePannerNode.positionZ); 7968 } 7969 if (isNativeAudioNodeFaker(nativePannerNode)) { 7970 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativePannerNode.inputs[0]); 7971 } else { 7972 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativePannerNode); 7973 } 7974 return nativePannerNode; 7975 }; 7976 return { 7977 render(proxy, nativeOfflineAudioContext) { 7978 const renderedNativeGainNodeOrNativePannerNode = renderedNativeAudioNodes.get(nativeOfflineAudioContext); 7979 if (renderedNativeGainNodeOrNativePannerNode !== void 0) { 7980 return Promise.resolve(renderedNativeGainNodeOrNativePannerNode); 7981 } 7982 return createAudioNode(proxy, nativeOfflineAudioContext); 7983 } 7984 }; 7985 }; 7986}; 7987
vendor: 891 bytes, lines 7988-8006
7988// node_modules/standardized-audio-context/build/es2019/factories/periodic-wave-constructor.js 7989var DEFAULT_OPTIONS19 = { 7990 disableNormalization: false 7991}; 7992var createPeriodicWaveConstructor = (createNativePeriodicWave2, getNativeContext2, periodicWaveStore, sanitizePeriodicWaveOptions2) => { 7993 return class PeriodicWave { 7994 constructor(context2, options) { 7995 const nativeContext = getNativeContext2(context2); 7996 const mergedOptions = sanitizePeriodicWaveOptions2({ ...DEFAULT_OPTIONS19, ...options }); 7997 const periodicWave = createNativePeriodicWave2(nativeContext, mergedOptions); 7998 periodicWaveStore.add(periodicWave); 7999 return periodicWave; 8000 } 8001 static [Symbol.hasInstance](instance) { 8002 return instance !== null && typeof instance === "object" && Object.getPrototypeOf(instance) === PeriodicWave.prototype || periodicWaveStore.has(instance); 8003 } 8004 }; 8005}; 8006
vendor: 463 bytes, lines 8007-8015
8007// node_modules/standardized-audio-context/build/es2019/factories/render-automation.js 8008var createRenderAutomation = (getAudioParamRenderer, renderInputsOfAudioParam2) => { 8009 return (nativeOfflineAudioContext, audioParam, nativeAudioParam) => { 8010 const audioParamRenderer = getAudioParamRenderer(audioParam); 8011 audioParamRenderer.replay(nativeAudioParam); 8012 return renderInputsOfAudioParam2(audioParam, nativeOfflineAudioContext, nativeAudioParam); 8013 }; 8014}; 8015
vendor: 1,023 bytes, lines 8016-8030
8016// node_modules/standardized-audio-context/build/es2019/factories/render-inputs-of-audio-node.js 8017var createRenderInputsOfAudioNode = (getAudioNodeConnections2, getAudioNodeRenderer2, isPartOfACycle2) => { 8018 return async (audioNode, nativeOfflineAudioContext, nativeAudioNode) => { 8019 const audioNodeConnections = getAudioNodeConnections2(audioNode); 8020 await Promise.all(audioNodeConnections.activeInputs.map((connections, input) => Array.from(connections).map(async ([source, output]) => { 8021 const audioNodeRenderer = getAudioNodeRenderer2(source); 8022 const renderedNativeAudioNode = await audioNodeRenderer.render(source, nativeOfflineAudioContext); 8023 const destination = audioNode.context.destination; 8024 if (!isPartOfACycle2(source) && (audioNode !== destination || !isPartOfACycle2(audioNode))) { 8025 renderedNativeAudioNode.connect(nativeAudioNode, output, input); 8026 } 8027 })).reduce((allRenderingPromises, renderingPromises) => [...allRenderingPromises, ...renderingPromises], [])); 8028 }; 8029}; 8030
vendor: 761 bytes, lines 8031-8044
8031// node_modules/standardized-audio-context/build/es2019/factories/render-inputs-of-audio-param.js 8032var createRenderInputsOfAudioParam = (getAudioNodeRenderer2, getAudioParamConnections2, isPartOfACycle2) => { 8033 return async (audioParam, nativeOfflineAudioContext, nativeAudioParam) => { 8034 const audioParamConnections = getAudioParamConnections2(audioParam); 8035 await Promise.all(Array.from(audioParamConnections.activeInputs).map(async ([source, output]) => { 8036 const audioNodeRenderer = getAudioNodeRenderer2(source); 8037 const renderedNativeAudioNode = await audioNodeRenderer.render(source, nativeOfflineAudioContext); 8038 if (!isPartOfACycle2(source)) { 8039 renderedNativeAudioNode.connect(nativeAudioParam, output); 8040 } 8041 })); 8042 }; 8043}; 8044
vendor: 1,708 bytes, lines 8045-8078
8045// node_modules/standardized-audio-context/build/es2019/factories/render-native-offline-audio-context.js 8046var createRenderNativeOfflineAudioContext = (cacheTestResult2, createNativeGainNode2, createNativeScriptProcessorNode2, testOfflineAudioContextCurrentTimeSupport) => { 8047 return (nativeOfflineAudioContext) => { 8048 if (cacheTestResult2(testPromiseSupport, () => testPromiseSupport(nativeOfflineAudioContext))) { 8049 return Promise.resolve(cacheTestResult2(testOfflineAudioContextCurrentTimeSupport, testOfflineAudioContextCurrentTimeSupport)).then((isOfflineAudioContextCurrentTimeSupported) => { 8050 if (!isOfflineAudioContextCurrentTimeSupported) { 8051 const scriptProcessorNode = createNativeScriptProcessorNode2(nativeOfflineAudioContext, 512, 0, 1); 8052 nativeOfflineAudioContext.oncomplete = () => { 8053 scriptProcessorNode.onaudioprocess = null; 8054 scriptProcessorNode.disconnect(); 8055 }; 8056 scriptProcessorNode.onaudioprocess = () => nativeOfflineAudioContext.currentTime; 8057 scriptProcessorNode.connect(nativeOfflineAudioContext.destination); 8058 } 8059 return nativeOfflineAudioContext.startRendering(); 8060 }); 8061 } 8062 return new Promise((resolve) => { 8063 const gainNode = createNativeGainNode2(nativeOfflineAudioContext, { 8064 channelCount: 1, 8065 channelCountMode: "explicit", 8066 channelInterpretation: "discrete", 8067 gain: 0 8068 }); 8069 nativeOfflineAudioContext.oncomplete = (event) => { 8070 gainNode.disconnect(); 8071 resolve(event.renderedBuffer); 8072 }; 8073 gainNode.connect(nativeOfflineAudioContext.destination); 8074 nativeOfflineAudioContext.startRendering(); 8075 }); 8076 }; 8077}; 8078
vendor: 336 bytes, lines 8079-8085
8079// node_modules/standardized-audio-context/build/es2019/factories/set-active-audio-worklet-node-inputs.js 8080var createSetActiveAudioWorkletNodeInputs = (activeAudioWorkletNodeInputsStore2) => { 8081 return (nativeAudioWorkletNode, activeInputs) => { 8082 activeAudioWorkletNodeInputsStore2.set(nativeAudioWorkletNode, activeInputs); 8083 }; 8084}; 8085
vendor: 246 bytes, lines 8086-8090
8086// node_modules/standardized-audio-context/build/es2019/factories/set-audio-node-tail-time.js 8087var createSetAudioNodeTailTime = (audioNodeTailTimeStore2) => { 8088 return (audioNode, tailTime) => audioNodeTailTimeStore2.set(audioNode, tailTime); 8089}; 8090
vendor: 1,309 bytes, lines 8091-8104
8091// node_modules/standardized-audio-context/build/es2019/factories/start-rendering.js 8092var createStartRendering = (audioBufferStore2, cacheTestResult2, getAudioNodeRenderer2, getUnrenderedAudioWorkletNodes2, renderNativeOfflineAudioContext2, testAudioBufferCopyChannelMethodsOutOfBoundsSupport2, wrapAudioBufferCopyChannelMethods2, wrapAudioBufferCopyChannelMethodsOutOfBounds2) => { 8093 return (destination, nativeOfflineAudioContext) => getAudioNodeRenderer2(destination).render(destination, nativeOfflineAudioContext).then(() => Promise.all(Array.from(getUnrenderedAudioWorkletNodes2(nativeOfflineAudioContext)).map((audioWorkletNode) => getAudioNodeRenderer2(audioWorkletNode).render(audioWorkletNode, nativeOfflineAudioContext)))).then(() => renderNativeOfflineAudioContext2(nativeOfflineAudioContext)).then((audioBuffer) => { 8094 if (typeof audioBuffer.copyFromChannel !== "function") { 8095 wrapAudioBufferCopyChannelMethods2(audioBuffer); 8096 wrapAudioBufferGetChannelDataMethod(audioBuffer); 8097 } else if (!cacheTestResult2(testAudioBufferCopyChannelMethodsOutOfBoundsSupport2, () => testAudioBufferCopyChannelMethodsOutOfBoundsSupport2(audioBuffer))) { 8098 wrapAudioBufferCopyChannelMethodsOutOfBounds2(audioBuffer); 8099 } 8100 audioBufferStore2.add(audioBuffer); 8101 return audioBuffer; 8102 }); 8103}; 8104
vendor: 1,289 bytes, lines 8105-8132
8105// node_modules/standardized-audio-context/build/es2019/factories/stereo-panner-node-constructor.js 8106var DEFAULT_OPTIONS20 = { 8107 channelCount: 2, 8108 /* 8109 * Bug #105: The channelCountMode should be 'clamped-max' according to the spec but is set to 'explicit' to achieve consistent 8110 * behavior. 8111 */ 8112 channelCountMode: "explicit", 8113 channelInterpretation: "speakers", 8114 pan: 0 8115}; 8116var createStereoPannerNodeConstructor = (audioNodeConstructor2, createAudioParam2, createNativeStereoPannerNode2, createStereoPannerNodeRenderer2, getNativeContext2, isNativeOfflineAudioContext2) => { 8117 return class StereoPannerNode extends audioNodeConstructor2 { 8118 constructor(context2, options) { 8119 const nativeContext = getNativeContext2(context2); 8120 const mergedOptions = { ...DEFAULT_OPTIONS20, ...options }; 8121 const nativeStereoPannerNode = createNativeStereoPannerNode2(nativeContext, mergedOptions); 8122 const isOffline = isNativeOfflineAudioContext2(nativeContext); 8123 const stereoPannerNodeRenderer = isOffline ? createStereoPannerNodeRenderer2() : null; 8124 super(context2, false, nativeStereoPannerNode, stereoPannerNodeRenderer); 8125 this._pan = createAudioParam2(this, isOffline, nativeStereoPannerNode.pan); 8126 } 8127 get pan() { 8128 return this._pan; 8129 } 8130 }; 8131}; 8132
vendor: 2,190 bytes, lines 8133-8173
8133// node_modules/standardized-audio-context/build/es2019/factories/stereo-panner-node-renderer-factory.js 8134var createStereoPannerNodeRendererFactory = (connectAudioParam2, createNativeStereoPannerNode2, getNativeAudioNode2, renderAutomation2, renderInputsOfAudioNode2) => { 8135 return () => { 8136 const renderedNativeStereoPannerNodes = /* @__PURE__ */ new WeakMap(); 8137 const createStereoPannerNode = async (proxy, nativeOfflineAudioContext) => { 8138 let nativeStereoPannerNode = getNativeAudioNode2(proxy); 8139 const nativeStereoPannerNodeIsOwnedByContext = isOwnedByContext(nativeStereoPannerNode, nativeOfflineAudioContext); 8140 if (!nativeStereoPannerNodeIsOwnedByContext) { 8141 const options = { 8142 channelCount: nativeStereoPannerNode.channelCount, 8143 channelCountMode: nativeStereoPannerNode.channelCountMode, 8144 channelInterpretation: nativeStereoPannerNode.channelInterpretation, 8145 pan: nativeStereoPannerNode.pan.value 8146 }; 8147 nativeStereoPannerNode = createNativeStereoPannerNode2(nativeOfflineAudioContext, options); 8148 } 8149 renderedNativeStereoPannerNodes.set(nativeOfflineAudioContext, nativeStereoPannerNode); 8150 if (!nativeStereoPannerNodeIsOwnedByContext) { 8151 await renderAutomation2(nativeOfflineAudioContext, proxy.pan, nativeStereoPannerNode.pan); 8152 } else { 8153 await connectAudioParam2(nativeOfflineAudioContext, proxy.pan, nativeStereoPannerNode.pan); 8154 } 8155 if (isNativeAudioNodeFaker(nativeStereoPannerNode)) { 8156 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeStereoPannerNode.inputs[0]); 8157 } else { 8158 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeStereoPannerNode); 8159 } 8160 return nativeStereoPannerNode; 8161 }; 8162 return { 8163 render(proxy, nativeOfflineAudioContext) { 8164 const renderedNativeStereoPannerNode = renderedNativeStereoPannerNodes.get(nativeOfflineAudioContext); 8165 if (renderedNativeStereoPannerNode !== void 0) { 8166 return Promise.resolve(renderedNativeStereoPannerNode); 8167 } 8168 return createStereoPannerNode(proxy, nativeOfflineAudioContext); 8169 } 8170 }; 8171 }; 8172}; 8173
vendor: 434 bytes, lines 8174-8188
8174// node_modules/standardized-audio-context/build/es2019/factories/test-audio-buffer-constructor-support.js 8175var createTestAudioBufferConstructorSupport = (nativeAudioBufferConstructor2) => { 8176 return () => { 8177 if (nativeAudioBufferConstructor2 === null) { 8178 return false; 8179 } 8180 try { 8181 new nativeAudioBufferConstructor2({ length: 1, sampleRate: 44100 }); 8182 } catch { 8183 return false; 8184 } 8185 return true; 8186 }; 8187}; 8188
vendor: 1,625 bytes, lines 8189-8222
8189// node_modules/standardized-audio-context/build/es2019/factories/test-audio-worklet-processor-post-message-support.js 8190var createTestAudioWorkletProcessorPostMessageSupport = (nativeAudioWorkletNodeConstructor2, nativeOfflineAudioContextConstructor2) => { 8191 return async () => { 8192 if (nativeAudioWorkletNodeConstructor2 === null) { 8193 return true; 8194 } 8195 if (nativeOfflineAudioContextConstructor2 === null) { 8196 return false; 8197 } 8198 const blob = new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'], { 8199 type: "application/javascript; charset=utf-8" 8200 }); 8201 const offlineAudioContext = new nativeOfflineAudioContextConstructor2(1, 128, 44100); 8202 const url = URL.createObjectURL(blob); 8203 let isEmittingMessageEvents = false; 8204 let isEmittingProcessorErrorEvents = false; 8205 try { 8206 await offlineAudioContext.audioWorklet.addModule(url); 8207 const audioWorkletNode = new nativeAudioWorkletNodeConstructor2(offlineAudioContext, "a", { numberOfOutputs: 0 }); 8208 const oscillator = offlineAudioContext.createOscillator(); 8209 audioWorkletNode.port.onmessage = () => isEmittingMessageEvents = true; 8210 audioWorkletNode.onprocessorerror = () => isEmittingProcessorErrorEvents = true; 8211 oscillator.connect(audioWorkletNode); 8212 oscillator.start(0); 8213 await offlineAudioContext.startRendering(); 8214 await new Promise((resolve) => setTimeout(resolve)); 8215 } catch { 8216 } finally { 8217 URL.revokeObjectURL(url); 8218 } 8219 return isEmittingMessageEvents && !isEmittingProcessorErrorEvents; 8220 }; 8221}; 8222
vendor: 905 bytes, lines 8223-8245
8223// node_modules/standardized-audio-context/build/es2019/factories/test-offline-audio-context-current-time-support.js 8224var createTestOfflineAudioContextCurrentTimeSupport = (createNativeGainNode2, nativeOfflineAudioContextConstructor2) => { 8225 return () => { 8226 if (nativeOfflineAudioContextConstructor2 === null) { 8227 return Promise.resolve(false); 8228 } 8229 const nativeOfflineAudioContext = new nativeOfflineAudioContextConstructor2(1, 1, 44100); 8230 const gainNode = createNativeGainNode2(nativeOfflineAudioContext, { 8231 channelCount: 1, 8232 channelCountMode: "explicit", 8233 channelInterpretation: "discrete", 8234 gain: 0 8235 }); 8236 return new Promise((resolve) => { 8237 nativeOfflineAudioContext.oncomplete = () => { 8238 gainNode.disconnect(); 8239 resolve(nativeOfflineAudioContext.currentTime !== 0); 8240 }; 8241 nativeOfflineAudioContext.startRendering(); 8242 }); 8243 }; 8244}; 8245
vendor: 153 bytes, lines 8246-8248
8246// node_modules/standardized-audio-context/build/es2019/factories/unknown-error.js 8247var createUnknownError = () => new DOMException("", "UnknownError"); 8248
vendor: 1,836 bytes, lines 8249-8296
8249// node_modules/standardized-audio-context/build/es2019/factories/wave-shaper-node-constructor.js 8250var DEFAULT_OPTIONS21 = { 8251 channelCount: 2, 8252 channelCountMode: "max", 8253 channelInterpretation: "speakers", 8254 curve: null, 8255 oversample: "none" 8256}; 8257var createWaveShaperNodeConstructor = (audioNodeConstructor2, createInvalidStateError2, createNativeWaveShaperNode2, createWaveShaperNodeRenderer2, getNativeContext2, isNativeOfflineAudioContext2, setAudioNodeTailTime2) => { 8258 return class WaveShaperNode extends audioNodeConstructor2 { 8259 constructor(context2, options) { 8260 const nativeContext = getNativeContext2(context2); 8261 const mergedOptions = { ...DEFAULT_OPTIONS21, ...options }; 8262 const nativeWaveShaperNode = createNativeWaveShaperNode2(nativeContext, mergedOptions); 8263 const isOffline = isNativeOfflineAudioContext2(nativeContext); 8264 const waveShaperNodeRenderer = isOffline ? createWaveShaperNodeRenderer2() : null; 8265 super(context2, true, nativeWaveShaperNode, waveShaperNodeRenderer); 8266 this._isCurveNullified = false; 8267 this._nativeWaveShaperNode = nativeWaveShaperNode; 8268 setAudioNodeTailTime2(this, 1); 8269 } 8270 get curve() { 8271 if (this._isCurveNullified) { 8272 return null; 8273 } 8274 return this._nativeWaveShaperNode.curve; 8275 } 8276 set curve(value) { 8277 if (value === null) { 8278 this._isCurveNullified = true; 8279 this._nativeWaveShaperNode.curve = new Float32Array([0, 0]); 8280 } else { 8281 if (value.length < 2) { 8282 throw createInvalidStateError2(); 8283 } 8284 this._isCurveNullified = false; 8285 this._nativeWaveShaperNode.curve = value; 8286 } 8287 } 8288 get oversample() { 8289 return this._nativeWaveShaperNode.oversample; 8290 } 8291 set oversample(value) { 8292 this._nativeWaveShaperNode.oversample = value; 8293 } 8294 }; 8295}; 8296
vendor: 1,877 bytes, lines 8297-8333
8297// node_modules/standardized-audio-context/build/es2019/factories/wave-shaper-node-renderer-factory.js 8298var createWaveShaperNodeRendererFactory = (createNativeWaveShaperNode2, getNativeAudioNode2, renderInputsOfAudioNode2) => { 8299 return () => { 8300 const renderedNativeWaveShaperNodes = /* @__PURE__ */ new WeakMap(); 8301 const createWaveShaperNode = async (proxy, nativeOfflineAudioContext) => { 8302 let nativeWaveShaperNode = getNativeAudioNode2(proxy); 8303 const nativeWaveShaperNodeIsOwnedByContext = isOwnedByContext(nativeWaveShaperNode, nativeOfflineAudioContext); 8304 if (!nativeWaveShaperNodeIsOwnedByContext) { 8305 const options = { 8306 channelCount: nativeWaveShaperNode.channelCount, 8307 channelCountMode: nativeWaveShaperNode.channelCountMode, 8308 channelInterpretation: nativeWaveShaperNode.channelInterpretation, 8309 curve: nativeWaveShaperNode.curve, 8310 oversample: nativeWaveShaperNode.oversample 8311 }; 8312 nativeWaveShaperNode = createNativeWaveShaperNode2(nativeOfflineAudioContext, options); 8313 } 8314 renderedNativeWaveShaperNodes.set(nativeOfflineAudioContext, nativeWaveShaperNode); 8315 if (isNativeAudioNodeFaker(nativeWaveShaperNode)) { 8316 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeWaveShaperNode.inputs[0]); 8317 } else { 8318 await renderInputsOfAudioNode2(proxy, nativeOfflineAudioContext, nativeWaveShaperNode); 8319 } 8320 return nativeWaveShaperNode; 8321 }; 8322 return { 8323 render(proxy, nativeOfflineAudioContext) { 8324 const renderedNativeWaveShaperNode = renderedNativeWaveShaperNodes.get(nativeOfflineAudioContext); 8325 if (renderedNativeWaveShaperNode !== void 0) { 8326 return Promise.resolve(renderedNativeWaveShaperNode); 8327 } 8328 return createWaveShaperNode(proxy, nativeOfflineAudioContext); 8329 } 8330 }; 8331 }; 8332}; 8333
vendor: 149 bytes, lines 8334-8336
8334// node_modules/standardized-audio-context/build/es2019/factories/window.js 8335var createWindow = () => typeof window === "undefined" ? null : window; 8336
vendor: 1,707 bytes, lines 8337-8368
8337// node_modules/standardized-audio-context/build/es2019/factories/wrap-audio-buffer-copy-channel-methods.js 8338var createWrapAudioBufferCopyChannelMethods = (convertNumberToUnsignedLong2, createIndexSizeError2) => { 8339 return (audioBuffer) => { 8340 audioBuffer.copyFromChannel = (destination, channelNumberAsNumber, bufferOffsetAsNumber = 0) => { 8341 const bufferOffset = convertNumberToUnsignedLong2(bufferOffsetAsNumber); 8342 const channelNumber = convertNumberToUnsignedLong2(channelNumberAsNumber); 8343 if (channelNumber >= audioBuffer.numberOfChannels) { 8344 throw createIndexSizeError2(); 8345 } 8346 const audioBufferLength = audioBuffer.length; 8347 const channelData = audioBuffer.getChannelData(channelNumber); 8348 const destinationLength = destination.length; 8349 for (let i = bufferOffset < 0 ? -bufferOffset : 0; i + bufferOffset < audioBufferLength && i < destinationLength; i += 1) { 8350 destination[i] = channelData[i + bufferOffset]; 8351 } 8352 }; 8353 audioBuffer.copyToChannel = (source, channelNumberAsNumber, bufferOffsetAsNumber = 0) => { 8354 const bufferOffset = convertNumberToUnsignedLong2(bufferOffsetAsNumber); 8355 const channelNumber = convertNumberToUnsignedLong2(channelNumberAsNumber); 8356 if (channelNumber >= audioBuffer.numberOfChannels) { 8357 throw createIndexSizeError2(); 8358 } 8359 const audioBufferLength = audioBuffer.length; 8360 const channelData = audioBuffer.getChannelData(channelNumber); 8361 const sourceLength = source.length; 8362 for (let i = bufferOffset < 0 ? -bufferOffset : 0; i + bufferOffset < audioBufferLength && i < sourceLength; i += 1) { 8363 channelData[i + bufferOffset] = source[i]; 8364 } 8365 }; 8366 }; 8367}; 8368
vendor: 1,274 bytes, lines 8369-8392
8369// node_modules/standardized-audio-context/build/es2019/factories/wrap-audio-buffer-copy-channel-methods-out-of-bounds.js 8370var createWrapAudioBufferCopyChannelMethodsOutOfBounds = (convertNumberToUnsignedLong2) => { 8371 return (audioBuffer) => { 8372 audioBuffer.copyFromChannel = /* @__PURE__ */ ((copyFromChannel2) => { 8373 return (destination, channelNumberAsNumber, bufferOffsetAsNumber = 0) => { 8374 const bufferOffset = convertNumberToUnsignedLong2(bufferOffsetAsNumber); 8375 const channelNumber = convertNumberToUnsignedLong2(channelNumberAsNumber); 8376 if (bufferOffset < audioBuffer.length) { 8377 return copyFromChannel2.call(audioBuffer, destination, channelNumber, bufferOffset); 8378 } 8379 }; 8380 })(audioBuffer.copyFromChannel); 8381 audioBuffer.copyToChannel = /* @__PURE__ */ ((copyToChannel2) => { 8382 return (source, channelNumberAsNumber, bufferOffsetAsNumber = 0) => { 8383 const bufferOffset = convertNumberToUnsignedLong2(bufferOffsetAsNumber); 8384 const channelNumber = convertNumberToUnsignedLong2(channelNumberAsNumber); 8385 if (bufferOffset < audioBuffer.length) { 8386 return copyToChannel2.call(audioBuffer, source, channelNumber, bufferOffset); 8387 } 8388 }; 8389 })(audioBuffer.copyToChannel); 8390 }; 8391}; 8392
vendor: 801 bytes, lines 8393-8408
8393// node_modules/standardized-audio-context/build/es2019/factories/wrap-audio-buffer-source-node-stop-method-nullified-buffer.js 8394var createWrapAudioBufferSourceNodeStopMethodNullifiedBuffer = (overwriteAccessors2) => { 8395 return (nativeAudioBufferSourceNode, nativeContext) => { 8396 const nullifiedBuffer = nativeContext.createBuffer(1, 1, 44100); 8397 if (nativeAudioBufferSourceNode.buffer === null) { 8398 nativeAudioBufferSourceNode.buffer = nullifiedBuffer; 8399 } 8400 overwriteAccessors2(nativeAudioBufferSourceNode, "buffer", (get) => () => { 8401 const value = get.call(nativeAudioBufferSourceNode); 8402 return value === nullifiedBuffer ? null : value; 8403 }, (set) => (value) => { 8404 return set.call(nativeAudioBufferSourceNode, value === null ? nullifiedBuffer : value); 8405 }); 8406 }; 8407}; 8408
vendor: 1,112 bytes, lines 8409-8437
8409// node_modules/standardized-audio-context/build/es2019/factories/wrap-channel-merger-node.js 8410var createWrapChannelMergerNode = (createInvalidStateError2, monitorConnections2) => { 8411 return (nativeContext, channelMergerNode) => { 8412 channelMergerNode.channelCount = 1; 8413 channelMergerNode.channelCountMode = "explicit"; 8414 Object.defineProperty(channelMergerNode, "channelCount", { 8415 get: () => 1, 8416 set: () => { 8417 throw createInvalidStateError2(); 8418 } 8419 }); 8420 Object.defineProperty(channelMergerNode, "channelCountMode", { 8421 get: () => "explicit", 8422 set: () => { 8423 throw createInvalidStateError2(); 8424 } 8425 }); 8426 const audioBufferSourceNode = nativeContext.createBufferSource(); 8427 const whenConnected = () => { 8428 const length = channelMergerNode.numberOfInputs; 8429 for (let i = 0; i < length; i += 1) { 8430 audioBufferSourceNode.connect(channelMergerNode, 0, i); 8431 } 8432 }; 8433 const whenDisconnected = () => audioBufferSourceNode.disconnect(channelMergerNode); 8434 monitorConnections2(channelMergerNode, whenConnected, whenDisconnected); 8435 }; 8436}; 8437
vendor: 334 bytes, lines 8438-8446
8438// node_modules/standardized-audio-context/build/es2019/helpers/get-first-sample.js 8439var getFirstSample = (audioBuffer, buffer, channelNumber) => { 8440 if (audioBuffer.copyFromChannel === void 0) { 8441 return audioBuffer.getChannelData(channelNumber)[0]; 8442 } 8443 audioBuffer.copyFromChannel(buffer, channelNumber); 8444 return buffer[0]; 8445}; 8446
vendor: 325 bytes, lines 8447-8458
8447// node_modules/standardized-audio-context/build/es2019/helpers/is-dc-curve.js 8448var isDCCurve = (curve) => { 8449 if (curve === null) { 8450 return false; 8451 } 8452 const length = curve.length; 8453 if (length % 2 !== 0) { 8454 return curve[Math.floor(length / 2)] !== 0; 8455 } 8456 return curve[length / 2 - 1] + curve[length / 2] !== 0; 8457}; 8458
vendor: 468 bytes, lines 8459-8468
8459// node_modules/standardized-audio-context/build/es2019/helpers/overwrite-accessors.js 8460var overwriteAccessors = (object, property, createGetter, createSetter) => { 8461 let prototype = object; 8462 while (!prototype.hasOwnProperty(property)) { 8463 prototype = Object.getPrototypeOf(prototype); 8464 } 8465 const { get, set } = Object.getOwnPropertyDescriptor(prototype, property); 8466 Object.defineProperty(object, property, { get: createGetter(get), set: createSetter(set) }); 8467}; 8468
vendor: 843 bytes, lines 8469-8483
8469// node_modules/standardized-audio-context/build/es2019/helpers/sanitize-audio-worklet-node-options.js 8470var sanitizeAudioWorkletNodeOptions = (options) => { 8471 return { 8472 ...options, 8473 outputChannelCount: options.outputChannelCount !== void 0 ? options.outputChannelCount : options.numberOfInputs === 1 && options.numberOfOutputs === 1 ? ( 8474 /* 8475 * Bug #61: This should be the computedNumberOfChannels, but unfortunately that is almost impossible to fake. That's why 8476 * the channelCountMode is required to be 'explicit' as long as there is not a native implementation in every browser. That 8477 * makes sure the computedNumberOfChannels is equivilant to the channelCount which makes it much easier to compute. 8478 */ 8479 [options.channelCount] 8480 ) : Array.from({ length: options.numberOfOutputs }, () => 1) 8481 }; 8482}; 8483
vendor: 221 bytes, lines 8484-8488
8484// node_modules/standardized-audio-context/build/es2019/helpers/sanitize-channel-splitter-options.js 8485var sanitizeChannelSplitterOptions = (options) => { 8486 return { ...options, channelCount: options.numberOfOutputs }; 8487}; 8488
vendor: 502 bytes, lines 8489-8503
8489// node_modules/standardized-audio-context/build/es2019/helpers/sanitize-periodic-wave-options.js 8490var sanitizePeriodicWaveOptions = (options) => { 8491 const { imag, real } = options; 8492 if (imag === void 0) { 8493 if (real === void 0) { 8494 return { ...options, imag: [0, 0], real: [0, 0] }; 8495 } 8496 return { ...options, imag: Array.from(real, () => 0), real }; 8497 } 8498 if (real === void 0) { 8499 return { ...options, imag, real: Array.from(imag, () => 0) }; 8500 } 8501 return { ...options, imag, real }; 8502}; 8503
vendor: 372 bytes, lines 8504-8515
8504// node_modules/standardized-audio-context/build/es2019/helpers/set-value-at-time-until-possible.js 8505var setValueAtTimeUntilPossible = (audioParam, value, startTime) => { 8506 try { 8507 audioParam.setValueAtTime(value, startTime); 8508 } catch (err) { 8509 if (err.code !== 9) { 8510 throw err; 8511 } 8512 setValueAtTimeUntilPossible(audioParam, value, startTime + 1e-7); 8513 } 8514}; 8515
vendor: 438 bytes, lines 8516-8527
8516// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-buffer-source-node-start-method-consecutive-calls-support.js 8517var testAudioBufferSourceNodeStartMethodConsecutiveCallsSupport = (nativeContext) => { 8518 const nativeAudioBufferSourceNode = nativeContext.createBufferSource(); 8519 nativeAudioBufferSourceNode.start(); 8520 try { 8521 nativeAudioBufferSourceNode.start(); 8522 } catch { 8523 return true; 8524 } 8525 return false; 8526}; 8527
vendor: 526 bytes, lines 8528-8540
8528// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-buffer-source-node-start-method-offset-clamping-support.js 8529var testAudioBufferSourceNodeStartMethodOffsetClampingSupport = (nativeContext) => { 8530 const nativeAudioBufferSourceNode = nativeContext.createBufferSource(); 8531 const nativeAudioBuffer = nativeContext.createBuffer(1, 1, 44100); 8532 nativeAudioBufferSourceNode.buffer = nativeAudioBuffer; 8533 try { 8534 nativeAudioBufferSourceNode.start(0, 1); 8535 } catch { 8536 return false; 8537 } 8538 return true; 8539}; 8540
vendor: 433 bytes, lines 8541-8552
8541// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-buffer-source-node-stop-method-nullified-buffer-support.js 8542var testAudioBufferSourceNodeStopMethodNullifiedBufferSupport = (nativeContext) => { 8543 const nativeAudioBufferSourceNode = nativeContext.createBufferSource(); 8544 nativeAudioBufferSourceNode.start(); 8545 try { 8546 nativeAudioBufferSourceNode.stop(); 8547 } catch { 8548 return false; 8549 } 8550 return true; 8551}; 8552
vendor: 436 bytes, lines 8553-8563
8553// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-scheduled-source-node-start-method-negative-parameters-support.js 8554var testAudioScheduledSourceNodeStartMethodNegativeParametersSupport = (nativeContext) => { 8555 const nativeAudioBufferSourceNode = nativeContext.createOscillator(); 8556 try { 8557 nativeAudioBufferSourceNode.start(-1); 8558 } catch (err) { 8559 return err instanceof RangeError; 8560 } 8561 return false; 8562}; 8563
vendor: 608 bytes, lines 8564-8578
8564// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-scheduled-source-node-stop-method-consecutive-calls-support.js 8565var testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport = (nativeContext) => { 8566 const nativeAudioBuffer = nativeContext.createBuffer(1, 1, 44100); 8567 const nativeAudioBufferSourceNode = nativeContext.createBufferSource(); 8568 nativeAudioBufferSourceNode.buffer = nativeAudioBuffer; 8569 nativeAudioBufferSourceNode.start(); 8570 nativeAudioBufferSourceNode.stop(); 8571 try { 8572 nativeAudioBufferSourceNode.stop(); 8573 return true; 8574 } catch { 8575 return false; 8576 } 8577}; 8578
vendor: 433 bytes, lines 8579-8589
8579// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-scheduled-source-node-stop-method-negative-parameters-support.js 8580var testAudioScheduledSourceNodeStopMethodNegativeParametersSupport = (nativeContext) => { 8581 const nativeAudioBufferSourceNode = nativeContext.createOscillator(); 8582 try { 8583 nativeAudioBufferSourceNode.stop(-1); 8584 } catch (err) { 8585 return err instanceof RangeError; 8586 } 8587 return false; 8588}; 8589
vendor: 352 bytes, lines 8590-8600
8590// node_modules/standardized-audio-context/build/es2019/helpers/test-audio-worklet-node-options-clonability.js 8591var testAudioWorkletNodeOptionsClonability = (audioWorkletNodeOptions) => { 8592 const { port1, port2 } = new MessageChannel(); 8593 try { 8594 port1.postMessage(audioWorkletNodeOptions); 8595 } finally { 8596 port1.close(); 8597 port2.close(); 8598 } 8599}; 8600
vendor: 820 bytes, lines 8601-8615
8601// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-buffer-source-node-start-method-offset-clamping.js 8602var wrapAudioBufferSourceNodeStartMethodOffsetClamping = (nativeAudioBufferSourceNode) => { 8603 nativeAudioBufferSourceNode.start = /* @__PURE__ */ ((start2) => { 8604 return (when = 0, offset = 0, duration) => { 8605 const buffer = nativeAudioBufferSourceNode.buffer; 8606 const clampedOffset = buffer === null ? offset : Math.min(buffer.duration, offset); 8607 if (buffer !== null && clampedOffset > buffer.duration - 0.5 / nativeAudioBufferSourceNode.context.sampleRate) { 8608 start2.call(nativeAudioBufferSourceNode, when, 0, 0); 8609 } else { 8610 start2.call(nativeAudioBufferSourceNode, when, clampedOffset, duration); 8611 } 8612 }; 8613 })(nativeAudioBufferSourceNode.start); 8614}; 8615
vendor: 1,268 bytes, lines 8616-8644
8616// node_modules/standardized-audio-context/build/es2019/helpers/wrap-audio-scheduled-source-node-stop-method-consecutive-calls.js 8617var wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls = (nativeAudioScheduledSourceNode, nativeContext) => { 8618 const nativeGainNode = nativeContext.createGain(); 8619 nativeAudioScheduledSourceNode.connect(nativeGainNode); 8620 const disconnectGainNode = /* @__PURE__ */ ((disconnect2) => { 8621 return () => { 8622 disconnect2.call(nativeAudioScheduledSourceNode, nativeGainNode); 8623 nativeAudioScheduledSourceNode.removeEventListener("ended", disconnectGainNode); 8624 }; 8625 })(nativeAudioScheduledSourceNode.disconnect); 8626 nativeAudioScheduledSourceNode.addEventListener("ended", disconnectGainNode); 8627 interceptConnections(nativeAudioScheduledSourceNode, nativeGainNode); 8628 nativeAudioScheduledSourceNode.stop = /* @__PURE__ */ ((stop) => { 8629 let isStopped = false; 8630 return (when = 0) => { 8631 if (isStopped) { 8632 try { 8633 stop.call(nativeAudioScheduledSourceNode, when); 8634 } catch { 8635 nativeGainNode.gain.setValueAtTime(0, when); 8636 } 8637 } else { 8638 stop.call(nativeAudioScheduledSourceNode, when); 8639 isStopped = true; 8640 } 8641 }; 8642 })(nativeAudioScheduledSourceNode.stop); 8643}; 8644
vendor: 475 bytes, lines 8645-8659
8645// node_modules/standardized-audio-context/build/es2019/helpers/wrap-event-listener.js 8646var wrapEventListener = (target, eventListener) => { 8647 return (event) => { 8648 const descriptor = { value: target }; 8649 Object.defineProperties(event, { 8650 currentTarget: descriptor, 8651 target: descriptor 8652 }); 8653 if (typeof eventListener === "function") { 8654 return eventListener.call(target, event); 8655 } 8656 return eventListener.handleEvent.call(target, event); 8657 }; 8658}; 8659
vendor: 23,784 bytes, lines 8660-8800
8660// node_modules/standardized-audio-context/build/es2019/module.js 8661var addActiveInputConnectionToAudioNode = createAddActiveInputConnectionToAudioNode(insertElementInSet); 8662var addPassiveInputConnectionToAudioNode = createAddPassiveInputConnectionToAudioNode(insertElementInSet); 8663var deleteActiveInputConnectionToAudioNode = createDeleteActiveInputConnectionToAudioNode(pickElementFromSet); 8664var audioNodeTailTimeStore = /* @__PURE__ */ new WeakMap(); 8665var getAudioNodeTailTime = createGetAudioNodeTailTime(audioNodeTailTimeStore); 8666var cacheTestResult = createCacheTestResult(/* @__PURE__ */ new Map(), /* @__PURE__ */ new WeakMap()); 8667var window2 = createWindow(); 8668var createNativeAnalyserNode = createNativeAnalyserNodeFactory(cacheTestResult, createIndexSizeError); 8669var getAudioNodeRenderer = createGetAudioNodeRenderer(getAudioNodeConnections); 8670var renderInputsOfAudioNode = createRenderInputsOfAudioNode(getAudioNodeConnections, getAudioNodeRenderer, isPartOfACycle); 8671var createAnalyserNodeRenderer = createAnalyserNodeRendererFactory(createNativeAnalyserNode, getNativeAudioNode, renderInputsOfAudioNode); 8672var getNativeContext = createGetNativeContext(CONTEXT_STORE); 8673var nativeOfflineAudioContextConstructor = createNativeOfflineAudioContextConstructor(window2); 8674var isNativeOfflineAudioContext = createIsNativeOfflineAudioContext(nativeOfflineAudioContextConstructor); 8675var audioParamAudioNodeStore = /* @__PURE__ */ new WeakMap(); 8676var eventTargetConstructor = createEventTargetConstructor(wrapEventListener); 8677var nativeAudioContextConstructor = createNativeAudioContextConstructor(window2); 8678var isNativeAudioContext = createIsNativeAudioContext(nativeAudioContextConstructor); 8679var isNativeAudioNode2 = createIsNativeAudioNode(window2); 8680var isNativeAudioParam = createIsNativeAudioParam(window2); 8681var nativeAudioWorkletNodeConstructor = createNativeAudioWorkletNodeConstructor(window2); 8682var audioNodeConstructor = createAudioNodeConstructor(createAddAudioNodeConnections(AUDIO_NODE_CONNECTIONS_STORE), createAddConnectionToAudioNode(addActiveInputConnectionToAudioNode, addPassiveInputConnectionToAudioNode, connectNativeAudioNodeToNativeAudioNode, deleteActiveInputConnectionToAudioNode, disconnectNativeAudioNodeFromNativeAudioNode, getAudioNodeConnections, getAudioNodeTailTime, getEventListenersOfAudioNode, getNativeAudioNode, insertElementInSet, isActiveAudioNode, isPartOfACycle, isPassiveAudioNode), cacheTestResult, createIncrementCycleCounterFactory(CYCLE_COUNTERS, disconnectNativeAudioNodeFromNativeAudioNode, getAudioNodeConnections, getNativeAudioNode, getNativeAudioParam, isActiveAudioNode), createIndexSizeError, createInvalidAccessError, createNotSupportedError, createDecrementCycleCounter(connectNativeAudioNodeToNativeAudioNode, CYCLE_COUNTERS, getAudioNodeConnections, getNativeAudioNode, getNativeAudioParam, getNativeContext, isActiveAudioNode, isNativeOfflineAudioContext), createDetectCycles(audioParamAudioNodeStore, getAudioNodeConnections, getValueForKey), eventTargetConstructor, getNativeContext, isNativeAudioContext, isNativeAudioNode2, isNativeAudioParam, isNativeOfflineAudioContext, nativeAudioWorkletNodeConstructor); 8683var analyserNodeConstructor = createAnalyserNodeConstructor(audioNodeConstructor, createAnalyserNodeRenderer, createIndexSizeError, createNativeAnalyserNode, getNativeContext, isNativeOfflineAudioContext); 8684var audioBufferStore = /* @__PURE__ */ new WeakSet(); 8685var nativeAudioBufferConstructor = createNativeAudioBufferConstructor(window2); 8686var convertNumberToUnsignedLong = createConvertNumberToUnsignedLong(new Uint32Array(1)); 8687var wrapAudioBufferCopyChannelMethods = createWrapAudioBufferCopyChannelMethods(convertNumberToUnsignedLong, createIndexSizeError); 8688var wrapAudioBufferCopyChannelMethodsOutOfBounds = createWrapAudioBufferCopyChannelMethodsOutOfBounds(convertNumberToUnsignedLong); 8689var audioBufferConstructor = createAudioBufferConstructor(audioBufferStore, cacheTestResult, createNotSupportedError, nativeAudioBufferConstructor, nativeOfflineAudioContextConstructor, createTestAudioBufferConstructorSupport(nativeAudioBufferConstructor), wrapAudioBufferCopyChannelMethods, wrapAudioBufferCopyChannelMethodsOutOfBounds); 8690var addSilentConnection = createAddSilentConnection(createNativeGainNode); 8691var renderInputsOfAudioParam = createRenderInputsOfAudioParam(getAudioNodeRenderer, getAudioParamConnections, isPartOfACycle); 8692var connectAudioParam = createConnectAudioParam(renderInputsOfAudioParam); 8693var createNativeAudioBufferSourceNode = createNativeAudioBufferSourceNodeFactory(addSilentConnection, cacheTestResult, testAudioBufferSourceNodeStartMethodConsecutiveCallsSupport, testAudioBufferSourceNodeStartMethodOffsetClampingSupport, testAudioBufferSourceNodeStopMethodNullifiedBufferSupport, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport, testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport, wrapAudioBufferSourceNodeStartMethodOffsetClamping, createWrapAudioBufferSourceNodeStopMethodNullifiedBuffer(overwriteAccessors), wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls); 8694var renderAutomation = createRenderAutomation(createGetAudioParamRenderer(getAudioParamConnections), renderInputsOfAudioParam); 8695var createAudioBufferSourceNodeRenderer = createAudioBufferSourceNodeRendererFactory(connectAudioParam, createNativeAudioBufferSourceNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8696var createAudioParam = createAudioParamFactory(createAddAudioParamConnections(AUDIO_PARAM_CONNECTIONS_STORE), audioParamAudioNodeStore, AUDIO_PARAM_STORE, createAudioParamRenderer, import_automation_events2.createCancelAndHoldAutomationEvent, import_automation_events2.createCancelScheduledValuesAutomationEvent, import_automation_events2.createExponentialRampToValueAutomationEvent, import_automation_events2.createLinearRampToValueAutomationEvent, import_automation_events2.createSetTargetAutomationEvent, import_automation_events2.createSetValueAutomationEvent, import_automation_events2.createSetValueCurveAutomationEvent, nativeAudioContextConstructor, setValueAtTimeUntilPossible); 8697var audioBufferSourceNodeConstructor = createAudioBufferSourceNodeConstructor(audioNodeConstructor, createAudioBufferSourceNodeRenderer, createAudioParam, createInvalidStateError, createNativeAudioBufferSourceNode, getNativeContext, isNativeOfflineAudioContext, wrapEventListener); 8698var audioDestinationNodeConstructor = createAudioDestinationNodeConstructor(audioNodeConstructor, createAudioDestinationNodeRenderer, createIndexSizeError, createInvalidStateError, createNativeAudioDestinationNodeFactory(createNativeGainNode, overwriteAccessors), getNativeContext, isNativeOfflineAudioContext, renderInputsOfAudioNode); 8699var createBiquadFilterNodeRenderer = createBiquadFilterNodeRendererFactory(connectAudioParam, createNativeBiquadFilterNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8700var setAudioNodeTailTime = createSetAudioNodeTailTime(audioNodeTailTimeStore); 8701var biquadFilterNodeConstructor = createBiquadFilterNodeConstructor(audioNodeConstructor, createAudioParam, createBiquadFilterNodeRenderer, createInvalidAccessError, createNativeBiquadFilterNode, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8702var monitorConnections = createMonitorConnections(insertElementInSet, isNativeAudioNode2); 8703var wrapChannelMergerNode = createWrapChannelMergerNode(createInvalidStateError, monitorConnections); 8704var createNativeChannelMergerNode = createNativeChannelMergerNodeFactory(nativeAudioContextConstructor, wrapChannelMergerNode); 8705var createChannelMergerNodeRenderer = createChannelMergerNodeRendererFactory(createNativeChannelMergerNode, getNativeAudioNode, renderInputsOfAudioNode); 8706var channelMergerNodeConstructor = createChannelMergerNodeConstructor(audioNodeConstructor, createChannelMergerNodeRenderer, createNativeChannelMergerNode, getNativeContext, isNativeOfflineAudioContext); 8707var createChannelSplitterNodeRenderer = createChannelSplitterNodeRendererFactory(createNativeChannelSplitterNode, getNativeAudioNode, renderInputsOfAudioNode); 8708var channelSplitterNodeConstructor = createChannelSplitterNodeConstructor(audioNodeConstructor, createChannelSplitterNodeRenderer, createNativeChannelSplitterNode, getNativeContext, isNativeOfflineAudioContext, sanitizeChannelSplitterOptions); 8709var createNativeConstantSourceNodeFaker = createNativeConstantSourceNodeFakerFactory(addSilentConnection, createNativeAudioBufferSourceNode, createNativeGainNode, monitorConnections); 8710var createNativeConstantSourceNode = createNativeConstantSourceNodeFactory(addSilentConnection, cacheTestResult, createNativeConstantSourceNodeFaker, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport); 8711var createConstantSourceNodeRenderer = createConstantSourceNodeRendererFactory(connectAudioParam, createNativeConstantSourceNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8712var constantSourceNodeConstructor = createConstantSourceNodeConstructor(audioNodeConstructor, createAudioParam, createConstantSourceNodeRenderer, createNativeConstantSourceNode, getNativeContext, isNativeOfflineAudioContext, wrapEventListener); 8713var createNativeConvolverNode = createNativeConvolverNodeFactory(createNotSupportedError, overwriteAccessors); 8714var createConvolverNodeRenderer = createConvolverNodeRendererFactory(createNativeConvolverNode, getNativeAudioNode, renderInputsOfAudioNode); 8715var convolverNodeConstructor = createConvolverNodeConstructor(audioNodeConstructor, createConvolverNodeRenderer, createNativeConvolverNode, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8716var createDelayNodeRenderer = createDelayNodeRendererFactory(connectAudioParam, createNativeDelayNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8717var delayNodeConstructor = createDelayNodeConstructor(audioNodeConstructor, createAudioParam, createDelayNodeRenderer, createNativeDelayNode, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8718var createNativeDynamicsCompressorNode = createNativeDynamicsCompressorNodeFactory(createNotSupportedError); 8719var createDynamicsCompressorNodeRenderer = createDynamicsCompressorNodeRendererFactory(connectAudioParam, createNativeDynamicsCompressorNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8720var dynamicsCompressorNodeConstructor = createDynamicsCompressorNodeConstructor(audioNodeConstructor, createAudioParam, createDynamicsCompressorNodeRenderer, createNativeDynamicsCompressorNode, createNotSupportedError, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8721var createGainNodeRenderer = createGainNodeRendererFactory(connectAudioParam, createNativeGainNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8722var gainNodeConstructor = createGainNodeConstructor(audioNodeConstructor, createAudioParam, createGainNodeRenderer, createNativeGainNode, getNativeContext, isNativeOfflineAudioContext); 8723var createNativeIIRFilterNodeFaker = createNativeIIRFilterNodeFakerFactory(createInvalidAccessError, createInvalidStateError, createNativeScriptProcessorNode, createNotSupportedError); 8724var renderNativeOfflineAudioContext = createRenderNativeOfflineAudioContext(cacheTestResult, createNativeGainNode, createNativeScriptProcessorNode, createTestOfflineAudioContextCurrentTimeSupport(createNativeGainNode, nativeOfflineAudioContextConstructor)); 8725var createIIRFilterNodeRenderer = createIIRFilterNodeRendererFactory(createNativeAudioBufferSourceNode, getNativeAudioNode, nativeOfflineAudioContextConstructor, renderInputsOfAudioNode, renderNativeOfflineAudioContext); 8726var createNativeIIRFilterNode = createNativeIIRFilterNodeFactory(createNativeIIRFilterNodeFaker); 8727var iIRFilterNodeConstructor = createIIRFilterNodeConstructor(audioNodeConstructor, createNativeIIRFilterNode, createIIRFilterNodeRenderer, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8728var createAudioListener = createAudioListenerFactory(createAudioParam, createNativeChannelMergerNode, createNativeConstantSourceNode, createNativeScriptProcessorNode, createNotSupportedError, getFirstSample, isNativeOfflineAudioContext, overwriteAccessors); 8729var unrenderedAudioWorkletNodeStore = /* @__PURE__ */ new WeakMap(); 8730var minimalBaseAudioContextConstructor = createMinimalBaseAudioContextConstructor(audioDestinationNodeConstructor, createAudioListener, eventTargetConstructor, isNativeOfflineAudioContext, unrenderedAudioWorkletNodeStore, wrapEventListener); 8731var createNativeOscillatorNode = createNativeOscillatorNodeFactory(addSilentConnection, cacheTestResult, testAudioScheduledSourceNodeStartMethodNegativeParametersSupport, testAudioScheduledSourceNodeStopMethodConsecutiveCallsSupport, testAudioScheduledSourceNodeStopMethodNegativeParametersSupport, wrapAudioScheduledSourceNodeStopMethodConsecutiveCalls); 8732var createOscillatorNodeRenderer = createOscillatorNodeRendererFactory(connectAudioParam, createNativeOscillatorNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8733var oscillatorNodeConstructor = createOscillatorNodeConstructor(audioNodeConstructor, createAudioParam, createNativeOscillatorNode, createOscillatorNodeRenderer, getNativeContext, isNativeOfflineAudioContext, wrapEventListener); 8734var createConnectedNativeAudioBufferSourceNode = createConnectedNativeAudioBufferSourceNodeFactory(createNativeAudioBufferSourceNode); 8735var createNativeWaveShaperNodeFaker = createNativeWaveShaperNodeFakerFactory(createConnectedNativeAudioBufferSourceNode, createInvalidStateError, createNativeGainNode, isDCCurve, monitorConnections); 8736var createNativeWaveShaperNode = createNativeWaveShaperNodeFactory(createConnectedNativeAudioBufferSourceNode, createInvalidStateError, createNativeWaveShaperNodeFaker, isDCCurve, monitorConnections, nativeAudioContextConstructor, overwriteAccessors); 8737var createNativePannerNodeFaker = createNativePannerNodeFakerFactory(connectNativeAudioNodeToNativeAudioNode, createInvalidStateError, createNativeChannelMergerNode, createNativeGainNode, createNativeScriptProcessorNode, createNativeWaveShaperNode, createNotSupportedError, disconnectNativeAudioNodeFromNativeAudioNode, getFirstSample, monitorConnections); 8738var createNativePannerNode = createNativePannerNodeFactory(createNativePannerNodeFaker); 8739var createPannerNodeRenderer = createPannerNodeRendererFactory(connectAudioParam, createNativeChannelMergerNode, createNativeConstantSourceNode, createNativeGainNode, createNativePannerNode, getNativeAudioNode, nativeOfflineAudioContextConstructor, renderAutomation, renderInputsOfAudioNode, renderNativeOfflineAudioContext); 8740var pannerNodeConstructor = createPannerNodeConstructor(audioNodeConstructor, createAudioParam, createNativePannerNode, createPannerNodeRenderer, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8741var createNativePeriodicWave = createNativePeriodicWaveFactory(createIndexSizeError); 8742var periodicWaveConstructor = createPeriodicWaveConstructor(createNativePeriodicWave, getNativeContext, /* @__PURE__ */ new WeakSet(), sanitizePeriodicWaveOptions); 8743var nativeStereoPannerNodeFakerFactory = createNativeStereoPannerNodeFakerFactory(createNativeChannelMergerNode, createNativeChannelSplitterNode, createNativeGainNode, createNativeWaveShaperNode, createNotSupportedError, monitorConnections); 8744var createNativeStereoPannerNode = createNativeStereoPannerNodeFactory(nativeStereoPannerNodeFakerFactory, createNotSupportedError); 8745var createStereoPannerNodeRenderer = createStereoPannerNodeRendererFactory(connectAudioParam, createNativeStereoPannerNode, getNativeAudioNode, renderAutomation, renderInputsOfAudioNode); 8746var stereoPannerNodeConstructor = createStereoPannerNodeConstructor(audioNodeConstructor, createAudioParam, createNativeStereoPannerNode, createStereoPannerNodeRenderer, getNativeContext, isNativeOfflineAudioContext); 8747var createWaveShaperNodeRenderer = createWaveShaperNodeRendererFactory(createNativeWaveShaperNode, getNativeAudioNode, renderInputsOfAudioNode); 8748var waveShaperNodeConstructor = createWaveShaperNodeConstructor(audioNodeConstructor, createInvalidStateError, createNativeWaveShaperNode, createWaveShaperNodeRenderer, getNativeContext, isNativeOfflineAudioContext, setAudioNodeTailTime); 8749var isSecureContext = createIsSecureContext(window2); 8750var exposeCurrentFrameAndCurrentTime = createExposeCurrentFrameAndCurrentTime(window2); 8751var backupOfflineAudioContextStore = /* @__PURE__ */ new WeakMap(); 8752var getOrCreateBackupOfflineAudioContext = createGetOrCreateBackupOfflineAudioContext(backupOfflineAudioContextStore, nativeOfflineAudioContextConstructor); 8753var addAudioWorkletModule = isSecureContext ? createAddAudioWorkletModule( 8754 cacheTestResult, 8755 createNotSupportedError, 8756 createEvaluateSource(window2), 8757 exposeCurrentFrameAndCurrentTime, 8758 createFetchSource(createAbortError), 8759 getNativeContext, 8760 getOrCreateBackupOfflineAudioContext, 8761 isNativeOfflineAudioContext, 8762 nativeAudioWorkletNodeConstructor, 8763 /* @__PURE__ */ new WeakMap(), 8764 /* @__PURE__ */ new WeakMap(), 8765 createTestAudioWorkletProcessorPostMessageSupport(nativeAudioWorkletNodeConstructor, nativeOfflineAudioContextConstructor), 8766 // @todo window is guaranteed to be defined because isSecureContext checks that as well. 8767 window2 8768) : void 0; 8769var isNativeContext = createIsNativeContext(isNativeAudioContext, isNativeOfflineAudioContext); 8770var decodeAudioData = createDecodeAudioData(audioBufferStore, cacheTestResult, createDataCloneError, createEncodingError, /* @__PURE__ */ new WeakSet(), getNativeContext, isNativeContext, testAudioBufferCopyChannelMethodsOutOfBoundsSupport, testPromiseSupport, wrapAudioBufferCopyChannelMethods, wrapAudioBufferCopyChannelMethodsOutOfBounds); 8771var baseAudioContextConstructor = createBaseAudioContextConstructor(addAudioWorkletModule, analyserNodeConstructor, audioBufferConstructor, audioBufferSourceNodeConstructor, biquadFilterNodeConstructor, channelMergerNodeConstructor, channelSplitterNodeConstructor, constantSourceNodeConstructor, convolverNodeConstructor, decodeAudioData, delayNodeConstructor, dynamicsCompressorNodeConstructor, gainNodeConstructor, iIRFilterNodeConstructor, minimalBaseAudioContextConstructor, oscillatorNodeConstructor, pannerNodeConstructor, periodicWaveConstructor, stereoPannerNodeConstructor, waveShaperNodeConstructor); 8772var mediaElementAudioSourceNodeConstructor = createMediaElementAudioSourceNodeConstructor(audioNodeConstructor, createNativeMediaElementAudioSourceNode, getNativeContext, isNativeOfflineAudioContext); 8773var mediaStreamAudioDestinationNodeConstructor = createMediaStreamAudioDestinationNodeConstructor(audioNodeConstructor, createNativeMediaStreamAudioDestinationNode, getNativeContext, isNativeOfflineAudioContext); 8774var mediaStreamAudioSourceNodeConstructor = createMediaStreamAudioSourceNodeConstructor(audioNodeConstructor, createNativeMediaStreamAudioSourceNode, getNativeContext, isNativeOfflineAudioContext); 8775var createNativeMediaStreamTrackAudioSourceNode = createNativeMediaStreamTrackAudioSourceNodeFactory(createInvalidStateError, isNativeOfflineAudioContext); 8776var mediaStreamTrackAudioSourceNodeConstructor = createMediaStreamTrackAudioSourceNodeConstructor(audioNodeConstructor, createNativeMediaStreamTrackAudioSourceNode, getNativeContext); 8777var audioContextConstructor = createAudioContextConstructor(baseAudioContextConstructor, createInvalidStateError, createNotSupportedError, createUnknownError, mediaElementAudioSourceNodeConstructor, mediaStreamAudioDestinationNodeConstructor, mediaStreamAudioSourceNodeConstructor, mediaStreamTrackAudioSourceNodeConstructor, nativeAudioContextConstructor); 8778var getUnrenderedAudioWorkletNodes = createGetUnrenderedAudioWorkletNodes(unrenderedAudioWorkletNodeStore); 8779var addUnrenderedAudioWorkletNode = createAddUnrenderedAudioWorkletNode(getUnrenderedAudioWorkletNodes); 8780var connectMultipleOutputs = createConnectMultipleOutputs(createIndexSizeError); 8781var deleteUnrenderedAudioWorkletNode = createDeleteUnrenderedAudioWorkletNode(getUnrenderedAudioWorkletNodes); 8782var disconnectMultipleOutputs = createDisconnectMultipleOutputs(createIndexSizeError); 8783var activeAudioWorkletNodeInputsStore = /* @__PURE__ */ new WeakMap(); 8784var getActiveAudioWorkletNodeInputs = createGetActiveAudioWorkletNodeInputs(activeAudioWorkletNodeInputsStore, getValueForKey); 8785var createNativeAudioWorkletNodeFaker = createNativeAudioWorkletNodeFakerFactory(connectMultipleOutputs, createIndexSizeError, createInvalidStateError, createNativeChannelMergerNode, createNativeChannelSplitterNode, createNativeConstantSourceNode, createNativeGainNode, createNativeScriptProcessorNode, createNotSupportedError, disconnectMultipleOutputs, exposeCurrentFrameAndCurrentTime, getActiveAudioWorkletNodeInputs, monitorConnections); 8786var createNativeAudioWorkletNode = createNativeAudioWorkletNodeFactory(createInvalidStateError, createNativeAudioWorkletNodeFaker, createNativeGainNode, createNotSupportedError, monitorConnections); 8787var createAudioWorkletNodeRenderer = createAudioWorkletNodeRendererFactory(connectAudioParam, connectMultipleOutputs, createNativeAudioBufferSourceNode, createNativeChannelMergerNode, createNativeChannelSplitterNode, createNativeConstantSourceNode, createNativeGainNode, deleteUnrenderedAudioWorkletNode, disconnectMultipleOutputs, exposeCurrentFrameAndCurrentTime, getNativeAudioNode, nativeAudioWorkletNodeConstructor, nativeOfflineAudioContextConstructor, renderAutomation, renderInputsOfAudioNode, renderNativeOfflineAudioContext); 8788var getBackupOfflineAudioContext = createGetBackupOfflineAudioContext(backupOfflineAudioContextStore); 8789var setActiveAudioWorkletNodeInputs = createSetActiveAudioWorkletNodeInputs(activeAudioWorkletNodeInputsStore); 8790var audioWorkletNodeConstructor = isSecureContext ? createAudioWorkletNodeConstructor(addUnrenderedAudioWorkletNode, audioNodeConstructor, createAudioParam, createAudioWorkletNodeRenderer, createNativeAudioWorkletNode, getAudioNodeConnections, getBackupOfflineAudioContext, getNativeContext, isNativeOfflineAudioContext, nativeAudioWorkletNodeConstructor, sanitizeAudioWorkletNodeOptions, setActiveAudioWorkletNodeInputs, testAudioWorkletNodeOptionsClonability, wrapEventListener) : void 0; 8791var minimalAudioContextConstructor = createMinimalAudioContextConstructor(createInvalidStateError, createNotSupportedError, createUnknownError, minimalBaseAudioContextConstructor, nativeAudioContextConstructor); 8792var createNativeOfflineAudioContext = createCreateNativeOfflineAudioContext(createNotSupportedError, nativeOfflineAudioContextConstructor); 8793var startRendering = createStartRendering(audioBufferStore, cacheTestResult, getAudioNodeRenderer, getUnrenderedAudioWorkletNodes, renderNativeOfflineAudioContext, testAudioBufferCopyChannelMethodsOutOfBoundsSupport, wrapAudioBufferCopyChannelMethods, wrapAudioBufferCopyChannelMethodsOutOfBounds); 8794var minimalOfflineAudioContextConstructor = createMinimalOfflineAudioContextConstructor(cacheTestResult, createInvalidStateError, createNativeOfflineAudioContext, minimalBaseAudioContextConstructor, startRendering); 8795var offlineAudioContextConstructor = createOfflineAudioContextConstructor(baseAudioContextConstructor, cacheTestResult, createInvalidStateError, createNativeOfflineAudioContext, startRendering); 8796var isAnyAudioContext = createIsAnyAudioContext(CONTEXT_STORE, isNativeAudioContext); 8797var isAnyAudioNode = createIsAnyAudioNode(AUDIO_NODE_STORE, isNativeAudioNode2); 8798var isAnyAudioParam = createIsAnyAudioParam(AUDIO_PARAM_STORE, isNativeAudioParam); 8799var isAnyOfflineAudioContext = createIsAnyOfflineAudioContext(CONTEXT_STORE, isNativeOfflineAudioContext); 8800
vendor: 689 bytes, lines 8801-8829
8801// node_modules/tone/build/esm/core/util/TypeCheck.js 8802function isUndef(arg) { 8803 return arg === void 0; 8804} 8805function isDefined(arg) { 8806 return arg !== void 0; 8807} 8808function isFunction(arg) { 8809 return typeof arg === "function"; 8810} 8811function isNumber(arg) { 8812 return typeof arg === "number"; 8813} 8814function isObject(arg) { 8815 return Object.prototype.toString.call(arg) === "[object Object]" && arg.constructor === Object; 8816} 8817function isBoolean(arg) { 8818 return typeof arg === "boolean"; 8819} 8820function isArray(arg) { 8821 return Array.isArray(arg); 8822} 8823function isString(arg) { 8824 return typeof arg === "string"; 8825} 8826function isNote(arg) { 8827 return isString(arg) && /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(arg); 8828} 8829
vendor: 1,175 bytes, lines 8830-8864
8830// node_modules/tone/build/esm/core/util/Debug.js 8831function assert(statement, error) { 8832 if (!statement) { 8833 throw new Error(error); 8834 } 8835} 8836function assertRange(value, gte, lte = Infinity) { 8837 if (!(gte <= value && value <= lte)) { 8838 throw new RangeError(`Value must be within [${gte}, ${lte}], got: ${value}`); 8839 } 8840} 8841function assertContextRunning(context2) { 8842 if (!context2.isOffline && context2.state !== "running") { 8843 warn('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.'); 8844 } 8845} 8846var isInsideScheduledCallback = false; 8847var printedScheduledWarning = false; 8848function enterScheduledCallback(insideCallback) { 8849 isInsideScheduledCallback = insideCallback; 8850} 8851function assertUsedScheduleTime(time) { 8852 if (isUndef(time) && isInsideScheduledCallback && !printedScheduledWarning) { 8853 printedScheduledWarning = true; 8854 warn("Events scheduled inside of scheduled callbacks should use the passed in scheduling time. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"); 8855 } 8856} 8857var defaultLogger = console; 8858function log(...args) { 8859 defaultLogger.log(...args); 8860} 8861function warn(...args) { 8862 defaultLogger.warn(...args); 8863} 8864
vendor: 918 bytes, lines 8865-8878
8865// node_modules/tone/build/esm/core/context/AudioContext.js 8866function createAudioContext(options) { 8867 return new audioContextConstructor(options); 8868} 8869function createOfflineAudioContext(channels, length, sampleRate) { 8870 return new offlineAudioContextConstructor(channels, length, sampleRate); 8871} 8872var theWindow = typeof self === "object" ? self : null; 8873var hasAudioContext = theWindow && (theWindow.hasOwnProperty("AudioContext") || theWindow.hasOwnProperty("webkitAudioContext")); 8874function createAudioWorkletNode(context2, name, options) { 8875 assert(isDefined(audioWorkletNodeConstructor), "AudioWorkletNode only works in a secure context (https or localhost)"); 8876 return new (context2 instanceof (theWindow === null || theWindow === void 0 ? void 0 : theWindow.BaseAudioContext) ? theWindow === null || theWindow === void 0 ? void 0 : theWindow.AudioWorkletNode : audioWorkletNodeConstructor)(context2, name, options); 8877} 8878
vendor: 1,287 bytes, lines 8879-8913
8879// node_modules/tslib/tslib.es6.mjs 8880function __decorate(decorators, target, key, desc) { 8881 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 8882 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 8883 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8884 return c > 3 && r && Object.defineProperty(target, key, r), r; 8885} 8886function __awaiter(thisArg, _arguments, P, generator) { 8887 function adopt(value) { 8888 return value instanceof P ? value : new P(function(resolve) { 8889 resolve(value); 8890 }); 8891 } 8892 return new (P || (P = Promise))(function(resolve, reject) { 8893 function fulfilled(value) { 8894 try { 8895 step(generator.next(value)); 8896 } catch (e) { 8897 reject(e); 8898 } 8899 } 8900 function rejected(value) { 8901 try { 8902 step(generator["throw"](value)); 8903 } catch (e) { 8904 reject(e); 8905 } 8906 } 8907 function step(result) { 8908 result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); 8909 } 8910 step((generator = generator.apply(thisArg, _arguments || [])).next()); 8911 }); 8912} 8913
vendor: 2,503 bytes, lines 8914-9018
8914// node_modules/tone/build/esm/core/clock/Ticker.js 8915var Ticker = class { 8916 constructor(callback, type, updateInterval, contextSampleRate) { 8917 this._callback = callback; 8918 this._type = type; 8919 this._minimumUpdateInterval = Math.max(128 / (contextSampleRate || 44100), 1e-3); 8920 this.updateInterval = updateInterval; 8921 this._createClock(); 8922 } 8923 /** 8924 * Generate a web worker 8925 */ 8926 _createWorker() { 8927 const blob = new Blob([ 8928 /* javascript */ 8929 ` 8930 // the initial timeout time 8931 let timeoutTime = ${(this._updateInterval * 1e3).toFixed(1)}; 8932 // onmessage callback 8933 self.onmessage = function(msg){ 8934 timeoutTime = parseInt(msg.data); 8935 }; 8936 // the tick function which posts a message 8937 // and schedules a new tick 8938 function tick(){ 8939 setTimeout(tick, timeoutTime); 8940 self.postMessage('tick'); 8941 } 8942 // call tick initially 8943 tick(); 8944 ` 8945 ], { type: "text/javascript" }); 8946 const blobUrl = URL.createObjectURL(blob); 8947 const worker = new Worker(blobUrl); 8948 worker.onmessage = this._callback.bind(this); 8949 this._worker = worker; 8950 } 8951 /** 8952 * Create a timeout loop 8953 */ 8954 _createTimeout() { 8955 this._timeout = setTimeout(() => { 8956 this._createTimeout(); 8957 this._callback(); 8958 }, this._updateInterval * 1e3); 8959 } 8960 /** 8961 * Create the clock source. 8962 */ 8963 _createClock() { 8964 if (this._type === "worker") { 8965 try { 8966 this._createWorker(); 8967 } catch (e) { 8968 this._type = "timeout"; 8969 this._createClock(); 8970 } 8971 } else if (this._type === "timeout") { 8972 this._createTimeout(); 8973 } 8974 } 8975 /** 8976 * Clean up the current clock source 8977 */ 8978 _disposeClock() { 8979 if (this._timeout) { 8980 clearTimeout(this._timeout); 8981 } 8982 if (this._worker) { 8983 this._worker.terminate(); 8984 this._worker.onmessage = null; 8985 } 8986 } 8987 /** 8988 * The rate in seconds the ticker will update 8989 */ 8990 get updateInterval() { 8991 return this._updateInterval; 8992 } 8993 set updateInterval(interval) { 8994 var _a; 8995 this._updateInterval = Math.max(interval, this._minimumUpdateInterval); 8996 if (this._type === "worker") { 8997 (_a = this._worker) === null || _a === void 0 ? void 0 : _a.postMessage(this._updateInterval * 1e3); 8998 } 8999 } 9000 /** 9001 * The type of the ticker, either a worker or a timeout 9002 */ 9003 get type() { 9004 return this._type; 9005 } 9006 set type(type) { 9007 this._disposeClock(); 9008 this._type = type; 9009 this._createClock(); 9010 } 9011 /** 9012 * Clean up 9013 */ 9014 dispose() { 9015 this._disposeClock(); 9016 } 9017}; 9018
vendor: 412 bytes, lines 9019-9035
9019// node_modules/tone/build/esm/core/util/AdvancedTypeCheck.js 9020function isAudioParam(arg) { 9021 return isAnyAudioParam(arg); 9022} 9023function isAudioNode2(arg) { 9024 return isAnyAudioNode(arg); 9025} 9026function isOfflineAudioContext(arg) { 9027 return isAnyOfflineAudioContext(arg); 9028} 9029function isAudioContext(arg) { 9030 return isAnyAudioContext(arg); 9031} 9032function isAudioBuffer(arg) { 9033 return arg instanceof audioBufferConstructor; 9034} 9035
vendor: 1,948 bytes, lines 9036-9104
9036// node_modules/tone/build/esm/core/util/Defaults.js 9037function noCopy(key, arg) { 9038 return key === "value" || isAudioParam(arg) || isAudioNode2(arg) || isAudioBuffer(arg); 9039} 9040function deepMerge(target, ...sources) { 9041 if (!sources.length) { 9042 return target; 9043 } 9044 const source = sources.shift(); 9045 if (isObject(target) && isObject(source)) { 9046 for (const key in source) { 9047 if (noCopy(key, source[key])) { 9048 target[key] = source[key]; 9049 } else if (isObject(source[key])) { 9050 if (!target[key]) { 9051 Object.assign(target, { [key]: {} }); 9052 } 9053 deepMerge(target[key], source[key]); 9054 } else { 9055 Object.assign(target, { [key]: source[key] }); 9056 } 9057 } 9058 } 9059 return deepMerge(target, ...sources); 9060} 9061function deepEquals(arrayA, arrayB) { 9062 return arrayA.length === arrayB.length && arrayA.every((element, index) => arrayB[index] === element); 9063} 9064function optionsFromArguments(defaults, argsArray, keys = [], objKey) { 9065 const opts = {}; 9066 const args = Array.from(argsArray); 9067 if (isObject(args[0]) && objKey && !Reflect.has(args[0], objKey)) { 9068 const partOfDefaults = Object.keys(args[0]).some((key) => Reflect.has(defaults, key)); 9069 if (!partOfDefaults) { 9070 deepMerge(opts, { [objKey]: args[0] }); 9071 keys.splice(keys.indexOf(objKey), 1); 9072 args.shift(); 9073 } 9074 } 9075 if (args.length === 1 && isObject(args[0])) { 9076 deepMerge(opts, args[0]); 9077 } else { 9078 for (let i = 0; i < keys.length; i++) { 9079 if (isDefined(args[i])) { 9080 opts[keys[i]] = args[i]; 9081 } 9082 } 9083 } 9084 return deepMerge(defaults, opts); 9085} 9086function getDefaultsFromInstance(instance) { 9087 return instance.constructor.getDefaults(); 9088} 9089function defaultArg(given, fallback) { 9090 if (isUndef(given)) { 9091 return fallback; 9092 } else { 9093 return given; 9094 } 9095} 9096function omitFromObject(obj, omit) { 9097 omit.forEach((prop) => { 9098 if (Reflect.has(obj, prop)) { 9099 delete obj[prop]; 9100 } 9101 }); 9102 return obj; 9103} 9104
vendor: 1,436 bytes, lines 9105-9160
9105// node_modules/tone/build/esm/core/Tone.js 9106var Tone = class { 9107 constructor() { 9108 this.debug = false; 9109 this._wasDisposed = false; 9110 } 9111 /** 9112 * Returns all of the default options belonging to the class. 9113 */ 9114 static getDefaults() { 9115 return {}; 9116 } 9117 /** 9118 * Prints the outputs to the console log for debugging purposes. 9119 * Prints the contents only if either the object has a property 9120 * called `debug` set to true, or a variable called TONE_DEBUG_CLASS 9121 * is set to the name of the class. 9122 * @example 9123 * const osc = new Tone.Oscillator(); 9124 * // prints all logs originating from this oscillator 9125 * osc.debug = true; 9126 * // calls to start/stop will print in the console 9127 * osc.start(); 9128 */ 9129 log(...args) { 9130 if (this.debug || theWindow && this.toString() === theWindow.TONE_DEBUG_CLASS) { 9131 log(this, ...args); 9132 } 9133 } 9134 /** 9135 * disconnect and dispose. 9136 */ 9137 dispose() { 9138 this._wasDisposed = true; 9139 return this; 9140 } 9141 /** 9142 * Indicates if the instance was disposed. 'Disposing' an 9143 * instance means that all of the Web Audio nodes that were 9144 * created for the instance are disconnected and freed for garbage collection. 9145 */ 9146 get disposed() { 9147 return this._wasDisposed; 9148 } 9149 /** 9150 * Convert the class to a string 9151 * @example 9152 * const osc = new Tone.Oscillator(); 9153 * console.log(osc.toString()); 9154 */ 9155 toString() { 9156 return this.name; 9157 } 9158}; 9159Tone.version = version; 9160
vendor: 360 bytes, lines 9161-9178
9161// node_modules/tone/build/esm/core/util/Math.js 9162var EPSILON = 1e-6; 9163function GT(a, b) { 9164 return a > b + EPSILON; 9165} 9166function GTE(a, b) { 9167 return GT(a, b) || EQ(a, b); 9168} 9169function LT(a, b) { 9170 return a + EPSILON < b; 9171} 9172function EQ(a, b) { 9173 return Math.abs(a - b) < EPSILON; 9174} 9175function clamp(value, min, max) { 9176 return Math.max(Math.min(value, max), min); 9177} 9178
vendor: 9,182 bytes, lines 9179-9489
9179// node_modules/tone/build/esm/core/util/Timeline.js 9180var Timeline = class _Timeline extends Tone { 9181 constructor() { 9182 super(); 9183 this.name = "Timeline"; 9184 this._timeline = []; 9185 const options = optionsFromArguments(_Timeline.getDefaults(), arguments, ["memory"]); 9186 this.memory = options.memory; 9187 this.increasing = options.increasing; 9188 } 9189 static getDefaults() { 9190 return { 9191 memory: Infinity, 9192 increasing: false 9193 }; 9194 } 9195 /** 9196 * The number of items in the timeline. 9197 */ 9198 get length() { 9199 return this._timeline.length; 9200 } 9201 /** 9202 * Insert an event object onto the timeline. Events must have a "time" attribute. 9203 * @param event The event object to insert into the timeline. 9204 */ 9205 add(event) { 9206 assert(Reflect.has(event, "time"), "Timeline: events must have a time attribute"); 9207 event.time = event.time.valueOf(); 9208 if (this.increasing && this.length) { 9209 const lastValue = this._timeline[this.length - 1]; 9210 assert(GTE(event.time, lastValue.time), "The time must be greater than or equal to the last scheduled time"); 9211 this._timeline.push(event); 9212 } else { 9213 const index = this._search(event.time); 9214 this._timeline.splice(index + 1, 0, event); 9215 } 9216 if (this.length > this.memory) { 9217 const diff = this.length - this.memory; 9218 this._timeline.splice(0, diff); 9219 } 9220 return this; 9221 } 9222 /** 9223 * Remove an event from the timeline. 9224 * @param {Object} event The event object to remove from the list. 9225 * @returns {Timeline} this 9226 */ 9227 remove(event) { 9228 const index = this._timeline.indexOf(event); 9229 if (index !== -1) { 9230 this._timeline.splice(index, 1); 9231 } 9232 return this; 9233 } 9234 /** 9235 * Get the nearest event whose time is less than or equal to the given time. 9236 * @param time The time to query. 9237 */ 9238 get(time, param = "time") { 9239 const index = this._search(time, param); 9240 if (index !== -1) { 9241 return this._timeline[index]; 9242 } else { 9243 return null; 9244 } 9245 } 9246 /** 9247 * Return the first event in the timeline without removing it 9248 * @returns {Object} The first event object 9249 * @deprecated 9250 */ 9251 peek() { 9252 return this._timeline[0]; 9253 } 9254 /** 9255 * Return the first event in the timeline and remove it 9256 * @deprecated 9257 */ 9258 shift() { 9259 return this._timeline.shift(); 9260 } 9261 /** 9262 * Get the event which is scheduled after the given time. 9263 * @param time The time to query. 9264 */ 9265 getAfter(time, param = "time") { 9266 const index = this._search(time, param); 9267 if (index + 1 < this._timeline.length) { 9268 return this._timeline[index + 1]; 9269 } else { 9270 return null; 9271 } 9272 } 9273 /** 9274 * Get the event before the event at the given time. 9275 * @param time The time to query. 9276 */ 9277 getBefore(time) { 9278 const len = this._timeline.length; 9279 if (len > 0 && this._timeline[len - 1].time < time) { 9280 return this._timeline[len - 1]; 9281 } 9282 const index = this._search(time); 9283 if (index - 1 >= 0) { 9284 return this._timeline[index - 1]; 9285 } else { 9286 return null; 9287 } 9288 } 9289 /** 9290 * Cancel events at and after the given time 9291 * @param after The time to query. 9292 */ 9293 cancel(after) { 9294 if (this._timeline.length > 1) { 9295 let index = this._search(after); 9296 if (index >= 0) { 9297 if (EQ(this._timeline[index].time, after)) { 9298 for (let i = index; i >= 0; i--) { 9299 if (EQ(this._timeline[i].time, after)) { 9300 index = i; 9301 } else { 9302 break; 9303 } 9304 } 9305 this._timeline = this._timeline.slice(0, index); 9306 } else { 9307 this._timeline = this._timeline.slice(0, index + 1); 9308 } 9309 } else { 9310 this._timeline = []; 9311 } 9312 } else if (this._timeline.length === 1) { 9313 if (GTE(this._timeline[0].time, after)) { 9314 this._timeline = []; 9315 } 9316 } 9317 return this; 9318 } 9319 /** 9320 * Cancel events before or equal to the given time. 9321 * @param time The time to cancel before. 9322 */ 9323 cancelBefore(time) { 9324 const index = this._search(time); 9325 if (index >= 0) { 9326 this._timeline = this._timeline.slice(index + 1); 9327 } 9328 return this; 9329 } 9330 /** 9331 * Returns the previous event if there is one. null otherwise 9332 * @param event The event to find the previous one of 9333 * @return The event right before the given event 9334 */ 9335 previousEvent(event) { 9336 const index = this._timeline.indexOf(event); 9337 if (index > 0) { 9338 return this._timeline[index - 1]; 9339 } else { 9340 return null; 9341 } 9342 } 9343 /** 9344 * Does a binary search on the timeline array and returns the 9345 * nearest event index whose time is after or equal to the given time. 9346 * If a time is searched before the first index in the timeline, -1 is returned. 9347 * If the time is after the end, the index of the last item is returned. 9348 */ 9349 _search(time, param = "time") { 9350 if (this._timeline.length === 0) { 9351 return -1; 9352 } 9353 let beginning = 0; 9354 const len = this._timeline.length; 9355 let end = len; 9356 if (len > 0 && this._timeline[len - 1][param] <= time) { 9357 return len - 1; 9358 } 9359 while (beginning < end) { 9360 let midPoint = Math.floor(beginning + (end - beginning) / 2); 9361 const event = this._timeline[midPoint]; 9362 const nextEvent = this._timeline[midPoint + 1]; 9363 if (EQ(event[param], time)) { 9364 for (let i = midPoint; i < this._timeline.length; i++) { 9365 const testEvent = this._timeline[i]; 9366 if (EQ(testEvent[param], time)) { 9367 midPoint = i; 9368 } else { 9369 break; 9370 } 9371 } 9372 return midPoint; 9373 } else if (LT(event[param], time) && GT(nextEvent[param], time)) { 9374 return midPoint; 9375 } else if (GT(event[param], time)) { 9376 end = midPoint; 9377 } else { 9378 beginning = midPoint + 1; 9379 } 9380 } 9381 return -1; 9382 } 9383 /** 9384 * Internal iterator. Applies extra safety checks for 9385 * removing items from the array. 9386 */ 9387 _iterate(callback, lowerBound = 0, upperBound = this._timeline.length - 1) { 9388 this._timeline.slice(lowerBound, upperBound + 1).forEach(callback); 9389 } 9390 /** 9391 * Iterate over everything in the array 9392 * @param callback The callback to invoke with every item 9393 */ 9394 forEach(callback) { 9395 this._iterate(callback); 9396 return this; 9397 } 9398 /** 9399 * Iterate over everything in the array at or before the given time. 9400 * @param time The time to check if items are before 9401 * @param callback The callback to invoke with every item 9402 */ 9403 forEachBefore(time, callback) { 9404 const upperBound = this._search(time); 9405 if (upperBound !== -1) { 9406 this._iterate(callback, 0, upperBound); 9407 } 9408 return this; 9409 } 9410 /** 9411 * Iterate over everything in the array after the given time. 9412 * @param time The time to check if items are before 9413 * @param callback The callback to invoke with every item 9414 */ 9415 forEachAfter(time, callback) { 9416 const lowerBound = this._search(time); 9417 this._iterate(callback, lowerBound + 1); 9418 return this; 9419 } 9420 /** 9421 * Iterate over everything in the array between the startTime and endTime. 9422 * The timerange is inclusive of the startTime, but exclusive of the endTime. 9423 * range = [startTime, endTime). 9424 * @param startTime The time to check if items are before 9425 * @param endTime The end of the test interval. 9426 * @param callback The callback to invoke with every item 9427 */ 9428 forEachBetween(startTime, endTime, callback) { 9429 let lowerBound = this._search(startTime); 9430 let upperBound = this._search(endTime); 9431 if (lowerBound !== -1 && upperBound !== -1) { 9432 if (this._timeline[lowerBound].time !== startTime) { 9433 lowerBound += 1; 9434 } 9435 if (this._timeline[upperBound].time === endTime) { 9436 upperBound -= 1; 9437 } 9438 this._iterate(callback, lowerBound, upperBound); 9439 } else if (lowerBound === -1) { 9440 this._iterate(callback, 0, upperBound); 9441 } 9442 return this; 9443 } 9444 /** 9445 * Iterate over everything in the array at or after the given time. Similar to 9446 * forEachAfter, but includes the item(s) at the given time. 9447 * @param time The time to check if items are before 9448 * @param callback The callback to invoke with every item 9449 */ 9450 forEachFrom(time, callback) { 9451 let lowerBound = this._search(time); 9452 while (lowerBound >= 0 && this._timeline[lowerBound].time >= time) { 9453 lowerBound--; 9454 } 9455 this._iterate(callback, lowerBound + 1); 9456 return this; 9457 } 9458 /** 9459 * Iterate over everything in the array at the given time 9460 * @param time The time to check if items are before 9461 * @param callback The callback to invoke with every item 9462 */ 9463 forEachAtTime(time, callback) { 9464 const upperBound = this._search(time); 9465 if (upperBound !== -1 && EQ(this._timeline[upperBound].time, time)) { 9466 let lowerBound = upperBound; 9467 for (let i = upperBound; i >= 0; i--) { 9468 if (EQ(this._timeline[i].time, time)) { 9469 lowerBound = i; 9470 } else { 9471 break; 9472 } 9473 } 9474 this._iterate((event) => { 9475 callback(event); 9476 }, lowerBound, upperBound); 9477 } 9478 return this; 9479 } 9480 /** 9481 * Clean up. 9482 */ 9483 dispose() { 9484 super.dispose(); 9485 this._timeline = []; 9486 return this; 9487 } 9488}; 9489
vendor: 408 bytes, lines 9490-9505
9490// node_modules/tone/build/esm/core/context/ContextInitialization.js 9491var notifyNewContext = []; 9492function onContextInit(cb) { 9493 notifyNewContext.push(cb); 9494} 9495function initializeContext(ctx) { 9496 notifyNewContext.forEach((cb) => cb(ctx)); 9497} 9498var notifyCloseContext = []; 9499function onContextClose(cb) { 9500 notifyCloseContext.push(cb); 9501} 9502function closeContext(ctx) { 9503 notifyCloseContext.forEach((cb) => cb(ctx)); 9504} 9505
vendor: 2,857 bytes, lines 9506-9605
9506// node_modules/tone/build/esm/core/util/Emitter.js 9507var Emitter = class _Emitter extends Tone { 9508 constructor() { 9509 super(...arguments); 9510 this.name = "Emitter"; 9511 } 9512 /** 9513 * Bind a callback to a specific event. 9514 * @param event The name of the event to listen for. 9515 * @param callback The callback to invoke when the event is emitted 9516 */ 9517 on(event, callback) { 9518 const events = event.split(/\W+/); 9519 events.forEach((eventName) => { 9520 if (isUndef(this._events)) { 9521 this._events = {}; 9522 } 9523 if (!this._events.hasOwnProperty(eventName)) { 9524 this._events[eventName] = []; 9525 } 9526 this._events[eventName].push(callback); 9527 }); 9528 return this; 9529 } 9530 /** 9531 * Bind a callback which is only invoked once 9532 * @param event The name of the event to listen for. 9533 * @param callback The callback to invoke when the event is emitted 9534 */ 9535 once(event, callback) { 9536 const boundCallback = (...args) => { 9537 callback(...args); 9538 this.off(event, boundCallback); 9539 }; 9540 this.on(event, boundCallback); 9541 return this; 9542 } 9543 /** 9544 * Remove the event listener. 9545 * @param event The event to stop listening to. 9546 * @param callback The callback which was bound to the event with Emitter.on. 9547 * If no callback is given, all callbacks events are removed. 9548 */ 9549 off(event, callback) { 9550 const events = event.split(/\W+/); 9551 events.forEach((eventName) => { 9552 if (isUndef(this._events)) { 9553 this._events = {}; 9554 } 9555 if (this._events.hasOwnProperty(eventName)) { 9556 if (isUndef(callback)) { 9557 this._events[eventName] = []; 9558 } else { 9559 const eventList = this._events[eventName]; 9560 for (let i = eventList.length - 1; i >= 0; i--) { 9561 if (eventList[i] === callback) { 9562 eventList.splice(i, 1); 9563 } 9564 } 9565 } 9566 } 9567 }); 9568 return this; 9569 } 9570 /** 9571 * Invoke all of the callbacks bound to the event 9572 * with any arguments passed in. 9573 * @param event The name of the event. 9574 * @param args The arguments to pass to the functions listening. 9575 */ 9576 emit(event, ...args) { 9577 if (this._events) { 9578 if (this._events.hasOwnProperty(event)) { 9579 const eventList = this._events[event].slice(0); 9580 for (let i = 0, len = eventList.length; i < len; i++) { 9581 eventList[i].apply(this, args); 9582 } 9583 } 9584 } 9585 return this; 9586 } 9587 /** 9588 * Add Emitter functions (on/off/emit) to the object 9589 */ 9590 static mixin(constr) { 9591 ["on", "once", "off", "emit"].forEach((name) => { 9592 const property = Object.getOwnPropertyDescriptor(_Emitter.prototype, name); 9593 Object.defineProperty(constr.prototype, name, property); 9594 }); 9595 } 9596 /** 9597 * Clean up 9598 */ 9599 dispose() { 9600 super.dispose(); 9601 this._events = void 0; 9602 return this; 9603 } 9604}; 9605
vendor: 397 bytes, lines 9606-9621
9606// node_modules/tone/build/esm/core/context/BaseContext.js 9607var BaseContext = class extends Emitter { 9608 constructor() { 9609 super(...arguments); 9610 this.isOffline = false; 9611 } 9612 /* 9613 * This is a placeholder so that JSON.stringify does not throw an error 9614 * This matches what JSON.stringify(audioContext) returns on a native 9615 * audioContext instance. 9616 */ 9617 toJSON() { 9618 return {}; 9619 } 9620}; 9621
vendor: 12,812 bytes, lines 9622-10046
9622// node_modules/tone/build/esm/core/context/Context.js 9623var Context = class _Context extends BaseContext { 9624 constructor() { 9625 var _a, _b; 9626 super(); 9627 this.name = "Context"; 9628 this._constants = /* @__PURE__ */ new Map(); 9629 this._timeouts = new Timeline(); 9630 this._timeoutIds = 0; 9631 this._initialized = false; 9632 this._closeStarted = false; 9633 this.isOffline = false; 9634 this._workletPromise = null; 9635 const options = optionsFromArguments(_Context.getDefaults(), arguments, [ 9636 "context" 9637 ]); 9638 if (options.context) { 9639 this._context = options.context; 9640 this._latencyHint = ((_a = arguments[0]) === null || _a === void 0 ? void 0 : _a.latencyHint) || ""; 9641 } else { 9642 this._context = createAudioContext({ 9643 latencyHint: options.latencyHint 9644 }); 9645 this._latencyHint = options.latencyHint; 9646 } 9647 this._ticker = new Ticker(this.emit.bind(this, "tick"), options.clockSource, options.updateInterval, this._context.sampleRate); 9648 this.on("tick", this._timeoutLoop.bind(this)); 9649 this._context.onstatechange = () => { 9650 this.emit("statechange", this.state); 9651 }; 9652 this[((_b = arguments[0]) === null || _b === void 0 ? void 0 : _b.hasOwnProperty("updateInterval")) ? "_lookAhead" : "lookAhead"] = options.lookAhead; 9653 } 9654 static getDefaults() { 9655 return { 9656 clockSource: "worker", 9657 latencyHint: "interactive", 9658 lookAhead: 0.1, 9659 updateInterval: 0.05 9660 }; 9661 } 9662 /** 9663 * Finish setting up the context. **You usually do not need to do this manually.** 9664 */ 9665 initialize() { 9666 if (!this._initialized) { 9667 initializeContext(this); 9668 this._initialized = true; 9669 } 9670 return this; 9671 } 9672 //--------------------------- 9673 // BASE AUDIO CONTEXT METHODS 9674 //--------------------------- 9675 createAnalyser() { 9676 return this._context.createAnalyser(); 9677 } 9678 createOscillator() { 9679 return this._context.createOscillator(); 9680 } 9681 createBufferSource() { 9682 return this._context.createBufferSource(); 9683 } 9684 createBiquadFilter() { 9685 return this._context.createBiquadFilter(); 9686 } 9687 createBuffer(numberOfChannels, length, sampleRate) { 9688 return this._context.createBuffer(numberOfChannels, length, sampleRate); 9689 } 9690 createChannelMerger(numberOfInputs) { 9691 return this._context.createChannelMerger(numberOfInputs); 9692 } 9693 createChannelSplitter(numberOfOutputs) { 9694 return this._context.createChannelSplitter(numberOfOutputs); 9695 } 9696 createConstantSource() { 9697 return this._context.createConstantSource(); 9698 } 9699 createConvolver() { 9700 return this._context.createConvolver(); 9701 } 9702 createDelay(maxDelayTime) { 9703 return this._context.createDelay(maxDelayTime); 9704 } 9705 createDynamicsCompressor() { 9706 return this._context.createDynamicsCompressor(); 9707 } 9708 createGain() { 9709 return this._context.createGain(); 9710 } 9711 createIIRFilter(feedForward, feedback) { 9712 return this._context.createIIRFilter(feedForward, feedback); 9713 } 9714 createPanner() { 9715 return this._context.createPanner(); 9716 } 9717 createPeriodicWave(real, imag, constraints) { 9718 return this._context.createPeriodicWave(real, imag, constraints); 9719 } 9720 createStereoPanner() { 9721 return this._context.createStereoPanner(); 9722 } 9723 createWaveShaper() { 9724 return this._context.createWaveShaper(); 9725 } 9726 createMediaStreamSource(stream) { 9727 assert(isAudioContext(this._context), "Not available if OfflineAudioContext"); 9728 const context2 = this._context; 9729 return context2.createMediaStreamSource(stream); 9730 } 9731 createMediaElementSource(element) { 9732 assert(isAudioContext(this._context), "Not available if OfflineAudioContext"); 9733 const context2 = this._context; 9734 return context2.createMediaElementSource(element); 9735 } 9736 createMediaStreamDestination() { 9737 assert(isAudioContext(this._context), "Not available if OfflineAudioContext"); 9738 const context2 = this._context; 9739 return context2.createMediaStreamDestination(); 9740 } 9741 decodeAudioData(audioData) { 9742 return this._context.decodeAudioData(audioData); 9743 } 9744 /** 9745 * The current time in seconds of the AudioContext. 9746 */ 9747 get currentTime() { 9748 return this._context.currentTime; 9749 } 9750 /** 9751 * The current time in seconds of the AudioContext. 9752 */ 9753 get state() { 9754 return this._context.state; 9755 } 9756 /** 9757 * The current time in seconds of the AudioContext. 9758 */ 9759 get sampleRate() { 9760 return this._context.sampleRate; 9761 } 9762 /** 9763 * The listener 9764 */ 9765 get listener() { 9766 this.initialize(); 9767 return this._listener; 9768 } 9769 set listener(l) { 9770 assert(!this._initialized, "The listener cannot be set after initialization."); 9771 this._listener = l; 9772 } 9773 /** 9774 * There is only one Transport per Context. It is created on initialization. 9775 */ 9776 get transport() { 9777 this.initialize(); 9778 return this._transport; 9779 } 9780 set transport(t) { 9781 assert(!this._initialized, "The transport cannot be set after initialization."); 9782 this._transport = t; 9783 } 9784 /** 9785 * This is the Draw object for the context which is useful for synchronizing the draw frame with the Tone.js clock. 9786 */ 9787 get draw() { 9788 this.initialize(); 9789 return this._draw; 9790 } 9791 set draw(d) { 9792 assert(!this._initialized, "Draw cannot be set after initialization."); 9793 this._draw = d; 9794 } 9795 /** 9796 * A reference to the Context's destination node. 9797 */ 9798 get destination() { 9799 this.initialize(); 9800 return this._destination; 9801 } 9802 set destination(d) { 9803 assert(!this._initialized, "The destination cannot be set after initialization."); 9804 this._destination = d; 9805 } 9806 /** 9807 * Create an audio worklet node from a name and options. The module 9808 * must first be loaded using {@link addAudioWorkletModule}. 9809 */ 9810 createAudioWorkletNode(name, options) { 9811 return createAudioWorkletNode(this.rawContext, name, options); 9812 } 9813 /** 9814 * Add an AudioWorkletProcessor module 9815 * @param url The url of the module 9816 */ 9817 addAudioWorkletModule(url) { 9818 return __awaiter(this, void 0, void 0, function* () { 9819 assert(isDefined(this.rawContext.audioWorklet), "AudioWorkletNode is only available in a secure context (https or localhost)"); 9820 if (!this._workletPromise) { 9821 this._workletPromise = this.rawContext.audioWorklet.addModule(url); 9822 } 9823 yield this._workletPromise; 9824 }); 9825 } 9826 /** 9827 * Returns a promise which resolves when all of the worklets have been loaded on this context 9828 */ 9829 workletsAreReady() { 9830 return __awaiter(this, void 0, void 0, function* () { 9831 (yield this._workletPromise) ? this._workletPromise : Promise.resolve(); 9832 }); 9833 } 9834 //--------------------------- 9835 // TICKER 9836 //--------------------------- 9837 /** 9838 * How often the interval callback is invoked. 9839 * This number corresponds to how responsive the scheduling 9840 * can be. Setting to 0 will result in the lowest practial interval 9841 * based on context properties. context.updateInterval + context.lookAhead 9842 * gives you the total latency between scheduling an event and hearing it. 9843 */ 9844 get updateInterval() { 9845 return this._ticker.updateInterval; 9846 } 9847 set updateInterval(interval) { 9848 this._ticker.updateInterval = interval; 9849 } 9850 /** 9851 * What the source of the clock is, either "worker" (default), 9852 * "timeout", or "offline" (none). 9853 */ 9854 get clockSource() { 9855 return this._ticker.type; 9856 } 9857 set clockSource(type) { 9858 this._ticker.type = type; 9859 } 9860 /** 9861 * The amount of time into the future events are scheduled. Giving Web Audio 9862 * a short amount of time into the future to schedule events can reduce clicks and 9863 * improve performance. This value can be set to 0 to get the lowest latency. 9864 * Adjusting this value also affects the {@link updateInterval}. 9865 */ 9866 get lookAhead() { 9867 return this._lookAhead; 9868 } 9869 set lookAhead(time) { 9870 this._lookAhead = time; 9871 this.updateInterval = time ? time / 2 : 0.01; 9872 } 9873 /** 9874 * The type of playback, which affects tradeoffs between audio 9875 * output latency and responsiveness. 9876 * In addition to setting the value in seconds, the latencyHint also 9877 * accepts the strings "interactive" (prioritizes low latency), 9878 * "playback" (prioritizes sustained playback), "balanced" (balances 9879 * latency and performance). 9880 * @example 9881 * // prioritize sustained playback 9882 * const context = new Tone.Context({ latencyHint: "playback" }); 9883 * // set this context as the global Context 9884 * Tone.setContext(context); 9885 * // the global context is gettable with Tone.getContext() 9886 * console.log(Tone.getContext().latencyHint); 9887 */ 9888 get latencyHint() { 9889 return this._latencyHint; 9890 } 9891 /** 9892 * The unwrapped AudioContext or OfflineAudioContext 9893 */ 9894 get rawContext() { 9895 return this._context; 9896 } 9897 /** 9898 * The current audio context time plus a short {@link lookAhead}. 9899 * @example 9900 * setInterval(() => { 9901 * console.log("now", Tone.now()); 9902 * }, 100); 9903 */ 9904 now() { 9905 return this._context.currentTime + this._lookAhead; 9906 } 9907 /** 9908 * The current audio context time without the {@link lookAhead}. 9909 * In most cases it is better to use {@link now} instead of {@link immediate} since 9910 * with {@link now} the {@link lookAhead} is applied equally to _all_ components including internal components, 9911 * to making sure that everything is scheduled in sync. Mixing {@link now} and {@link immediate} 9912 * can cause some timing issues. If no lookAhead is desired, you can set the {@link lookAhead} to `0`. 9913 */ 9914 immediate() { 9915 return this._context.currentTime; 9916 } 9917 /** 9918 * Starts the audio context from a suspended state. This is required 9919 * to initially start the AudioContext. 9920 * @see {@link start} 9921 */ 9922 resume() { 9923 if (isAudioContext(this._context)) { 9924 return this._context.resume(); 9925 } else { 9926 return Promise.resolve(); 9927 } 9928 } 9929 /** 9930 * Close the context. Once closed, the context can no longer be used and 9931 * any AudioNodes created from the context will be silent. 9932 */ 9933 close() { 9934 return __awaiter(this, void 0, void 0, function* () { 9935 if (isAudioContext(this._context) && this.state !== "closed" && !this._closeStarted) { 9936 this._closeStarted = true; 9937 yield this._context.close(); 9938 } 9939 if (this._initialized) { 9940 closeContext(this); 9941 } 9942 }); 9943 } 9944 /** 9945 * **Internal** Generate a looped buffer at some constant value. 9946 */ 9947 getConstant(val) { 9948 if (this._constants.has(val)) { 9949 return this._constants.get(val); 9950 } else { 9951 const buffer = this._context.createBuffer(1, 128, this._context.sampleRate); 9952 const arr = buffer.getChannelData(0); 9953 for (let i = 0; i < arr.length; i++) { 9954 arr[i] = val; 9955 } 9956 const constant = this._context.createBufferSource(); 9957 constant.channelCount = 1; 9958 constant.channelCountMode = "explicit"; 9959 constant.buffer = buffer; 9960 constant.loop = true; 9961 constant.start(0); 9962 this._constants.set(val, constant); 9963 return constant; 9964 } 9965 } 9966 /** 9967 * Clean up. Also closes the audio context. 9968 */ 9969 dispose() { 9970 super.dispose(); 9971 this._ticker.dispose(); 9972 this._timeouts.dispose(); 9973 Object.keys(this._constants).map((val) => this._constants[val].disconnect()); 9974 this.close(); 9975 return this; 9976 } 9977 //--------------------------- 9978 // TIMEOUTS 9979 //--------------------------- 9980 /** 9981 * The private loop which keeps track of the context scheduled timeouts 9982 * Is invoked from the clock source 9983 */ 9984 _timeoutLoop() { 9985 const now = this.now(); 9986 this._timeouts.forEachBefore(now, (event) => { 9987 event.callback(); 9988 this._timeouts.remove(event); 9989 }); 9990 } 9991 /** 9992 * A setTimeout which is guaranteed by the clock source. 9993 * Also runs in the offline context. 9994 * @param fn The callback to invoke 9995 * @param timeout The timeout in seconds 9996 * @returns ID to use when invoking Context.clearTimeout 9997 */ 9998 setTimeout(fn, timeout) { 9999 this._timeoutIds++; 10000 const now = this.now(); 10001 this._timeouts.add({ 10002 callback: fn, 10003 id: this._timeoutIds, 10004 time: now + timeout 10005 }); 10006 return this._timeoutIds; 10007 } 10008 /** 10009 * Clears a previously scheduled timeout with Tone.context.setTimeout 10010 * @param id The ID returned from setTimeout 10011 */ 10012 clearTimeout(id) { 10013 this._timeouts.forEach((event) => { 10014 if (event.id === id) { 10015 this._timeouts.remove(event); 10016 } 10017 }); 10018 return this; 10019 } 10020 /** 10021 * Clear the function scheduled by {@link setInterval} 10022 */ 10023 clearInterval(id) { 10024 return this.clearTimeout(id); 10025 } 10026 /** 10027 * Adds a repeating event to the context's callback clock 10028 */ 10029 setInterval(fn, interval) { 10030 const id = ++this._timeoutIds; 10031 const intervalFn = () => { 10032 const now = this.now(); 10033 this._timeouts.add({ 10034 callback: () => { 10035 fn(); 10036 intervalFn(); 10037 }, 10038 id, 10039 time: now + interval 10040 }); 10041 }; 10042 intervalFn(); 10043 return id; 10044 } 10045}; 10046
vendor: 2,402 bytes, lines 10047-10185
10047// node_modules/tone/build/esm/core/context/DummyContext.js 10048var DummyContext = class extends BaseContext { 10049 constructor() { 10050 super(...arguments); 10051 this.lookAhead = 0; 10052 this.latencyHint = 0; 10053 this.isOffline = false; 10054 } 10055 //--------------------------- 10056 // BASE AUDIO CONTEXT METHODS 10057 //--------------------------- 10058 createAnalyser() { 10059 return {}; 10060 } 10061 createOscillator() { 10062 return {}; 10063 } 10064 createBufferSource() { 10065 return {}; 10066 } 10067 createBiquadFilter() { 10068 return {}; 10069 } 10070 createBuffer(_numberOfChannels, _length, _sampleRate) { 10071 return {}; 10072 } 10073 createChannelMerger(_numberOfInputs) { 10074 return {}; 10075 } 10076 createChannelSplitter(_numberOfOutputs) { 10077 return {}; 10078 } 10079 createConstantSource() { 10080 return {}; 10081 } 10082 createConvolver() { 10083 return {}; 10084 } 10085 createDelay(_maxDelayTime) { 10086 return {}; 10087 } 10088 createDynamicsCompressor() { 10089 return {}; 10090 } 10091 createGain() { 10092 return {}; 10093 } 10094 createIIRFilter(_feedForward, _feedback) { 10095 return {}; 10096 } 10097 createPanner() { 10098 return {}; 10099 } 10100 createPeriodicWave(_real, _imag, _constraints) { 10101 return {}; 10102 } 10103 createStereoPanner() { 10104 return {}; 10105 } 10106 createWaveShaper() { 10107 return {}; 10108 } 10109 createMediaStreamSource(_stream) { 10110 return {}; 10111 } 10112 createMediaElementSource(_element) { 10113 return {}; 10114 } 10115 createMediaStreamDestination() { 10116 return {}; 10117 } 10118 decodeAudioData(_audioData) { 10119 return Promise.resolve({}); 10120 } 10121 //--------------------------- 10122 // TONE AUDIO CONTEXT METHODS 10123 //--------------------------- 10124 createAudioWorkletNode(_name, _options) { 10125 return {}; 10126 } 10127 get rawContext() { 10128 return {}; 10129 } 10130 addAudioWorkletModule(_url) { 10131 return __awaiter(this, void 0, void 0, function* () { 10132 return Promise.resolve(); 10133 }); 10134 } 10135 resume() { 10136 return Promise.resolve(); 10137 } 10138 setTimeout(_fn, _timeout) { 10139 return 0; 10140 } 10141 clearTimeout(_id) { 10142 return this; 10143 } 10144 setInterval(_fn, _interval) { 10145 return 0; 10146 } 10147 clearInterval(_id) { 10148 return this; 10149 } 10150 getConstant(_val) { 10151 return {}; 10152 } 10153 get currentTime() { 10154 return 0; 10155 } 10156 get state() { 10157 return {}; 10158 } 10159 get sampleRate() { 10160 return 0; 10161 } 10162 get listener() { 10163 return {}; 10164 } 10165 get transport() { 10166 return {}; 10167 } 10168 get draw() { 10169 return {}; 10170 } 10171 set draw(_d) { 10172 } 10173 get destination() { 10174 return {}; 10175 } 10176 set destination(_d) { 10177 } 10178 now() { 10179 return 0; 10180 } 10181 immediate() { 10182 return 0; 10183 } 10184}; 10185
vendor: 524 bytes, lines 10186-10208
10186// node_modules/tone/build/esm/core/util/Interface.js 10187function readOnly(target, property) { 10188 if (isArray(property)) { 10189 property.forEach((str) => readOnly(target, str)); 10190 } else { 10191 Object.defineProperty(target, property, { 10192 enumerable: true, 10193 writable: false 10194 }); 10195 } 10196} 10197function writable(target, property) { 10198 if (isArray(property)) { 10199 property.forEach((str) => writable(target, str)); 10200 } else { 10201 Object.defineProperty(target, property, { 10202 writable: true 10203 }); 10204 } 10205} 10206var noOp = () => { 10207}; 10208
vendor: 9,031 bytes, lines 10209-10508
10209// node_modules/tone/build/esm/core/context/ToneAudioBuffer.js 10210var ToneAudioBuffer = class _ToneAudioBuffer extends Tone { 10211 constructor() { 10212 super(); 10213 this.name = "ToneAudioBuffer"; 10214 this.onload = noOp; 10215 const options = optionsFromArguments(_ToneAudioBuffer.getDefaults(), arguments, ["url", "onload", "onerror"]); 10216 this.reverse = options.reverse; 10217 this.onload = options.onload; 10218 if (isString(options.url)) { 10219 this.load(options.url).catch(options.onerror); 10220 } else if (options.url) { 10221 this.set(options.url); 10222 } 10223 } 10224 static getDefaults() { 10225 return { 10226 onerror: noOp, 10227 onload: noOp, 10228 reverse: false 10229 }; 10230 } 10231 /** 10232 * The sample rate of the AudioBuffer 10233 */ 10234 get sampleRate() { 10235 if (this._buffer) { 10236 return this._buffer.sampleRate; 10237 } else { 10238 return getContext().sampleRate; 10239 } 10240 } 10241 /** 10242 * Pass in an AudioBuffer or ToneAudioBuffer to set the value of this buffer. 10243 */ 10244 set(buffer) { 10245 if (buffer instanceof _ToneAudioBuffer) { 10246 if (buffer.loaded) { 10247 this._buffer = buffer.get(); 10248 } else { 10249 buffer.onload = () => { 10250 this.set(buffer); 10251 this.onload(this); 10252 }; 10253 } 10254 } else { 10255 this._buffer = buffer; 10256 } 10257 if (this._reversed) { 10258 this._reverse(); 10259 } 10260 return this; 10261 } 10262 /** 10263 * The audio buffer stored in the object. 10264 */ 10265 get() { 10266 return this._buffer; 10267 } 10268 /** 10269 * Makes an fetch request for the selected url then decodes the file as an audio buffer. 10270 * Invokes the callback once the audio buffer loads. 10271 * @param url The url of the buffer to load. filetype support depends on the browser. 10272 * @returns A Promise which resolves with this ToneAudioBuffer 10273 */ 10274 load(url) { 10275 return __awaiter(this, void 0, void 0, function* () { 10276 const doneLoading = _ToneAudioBuffer.load(url).then((audioBuffer) => { 10277 this.set(audioBuffer); 10278 this.onload(this); 10279 }); 10280 _ToneAudioBuffer.downloads.push(doneLoading); 10281 try { 10282 yield doneLoading; 10283 } finally { 10284 const index = _ToneAudioBuffer.downloads.indexOf(doneLoading); 10285 _ToneAudioBuffer.downloads.splice(index, 1); 10286 } 10287 return this; 10288 }); 10289 } 10290 /** 10291 * clean up 10292 */ 10293 dispose() { 10294 super.dispose(); 10295 this._buffer = void 0; 10296 return this; 10297 } 10298 /** 10299 * Set the audio buffer from the array. 10300 * To create a multichannel AudioBuffer, pass in a multidimensional array. 10301 * @param array The array to fill the audio buffer 10302 */ 10303 fromArray(array) { 10304 const isMultidimensional = isArray(array) && array[0].length > 0; 10305 const channels = isMultidimensional ? array.length : 1; 10306 const len = isMultidimensional ? array[0].length : array.length; 10307 const context2 = getContext(); 10308 const buffer = context2.createBuffer(channels, len, context2.sampleRate); 10309 const multiChannelArray = !isMultidimensional && channels === 1 ? [array] : array; 10310 for (let c = 0; c < channels; c++) { 10311 buffer.copyToChannel(multiChannelArray[c], c); 10312 } 10313 this._buffer = buffer; 10314 return this; 10315 } 10316 /** 10317 * Sums multiple channels into 1 channel 10318 * @param chanNum Optionally only copy a single channel from the array. 10319 */ 10320 toMono(chanNum) { 10321 if (isNumber(chanNum)) { 10322 this.fromArray(this.toArray(chanNum)); 10323 } else { 10324 let outputArray = new Float32Array(this.length); 10325 const numChannels = this.numberOfChannels; 10326 for (let channel = 0; channel < numChannels; channel++) { 10327 const channelArray = this.toArray(channel); 10328 for (let i = 0; i < channelArray.length; i++) { 10329 outputArray[i] += channelArray[i]; 10330 } 10331 } 10332 outputArray = outputArray.map((sample) => sample / numChannels); 10333 this.fromArray(outputArray); 10334 } 10335 return this; 10336 } 10337 /** 10338 * Get the buffer as an array. Single channel buffers will return a 1-dimensional 10339 * Float32Array, and multichannel buffers will return multidimensional arrays. 10340 * @param channel Optionally only copy a single channel from the array. 10341 */ 10342 toArray(channel) { 10343 if (isNumber(channel)) { 10344 return this.getChannelData(channel); 10345 } else if (this.numberOfChannels === 1) { 10346 return this.toArray(0); 10347 } else { 10348 const ret = []; 10349 for (let c = 0; c < this.numberOfChannels; c++) { 10350 ret[c] = this.getChannelData(c); 10351 } 10352 return ret; 10353 } 10354 } 10355 /** 10356 * Returns the Float32Array representing the PCM audio data for the specific channel. 10357 * @param channel The channel number to return 10358 * @return The audio as a TypedArray 10359 */ 10360 getChannelData(channel) { 10361 if (this._buffer) { 10362 return this._buffer.getChannelData(channel); 10363 } else { 10364 return new Float32Array(0); 10365 } 10366 } 10367 /** 10368 * Cut a subsection of the array and return a buffer of the 10369 * subsection. Does not modify the original buffer 10370 * @param start The time to start the slice 10371 * @param end The end time to slice. If none is given will default to the end of the buffer 10372 */ 10373 slice(start2, end = this.duration) { 10374 assert(this.loaded, "Buffer is not loaded"); 10375 const startSamples = Math.floor(start2 * this.sampleRate); 10376 const endSamples = Math.floor(end * this.sampleRate); 10377 assert(startSamples < endSamples, "The start time must be less than the end time"); 10378 const length = endSamples - startSamples; 10379 const retBuffer = getContext().createBuffer(this.numberOfChannels, length, this.sampleRate); 10380 for (let channel = 0; channel < this.numberOfChannels; channel++) { 10381 retBuffer.copyToChannel(this.getChannelData(channel).subarray(startSamples, endSamples), channel); 10382 } 10383 return new _ToneAudioBuffer(retBuffer); 10384 } 10385 /** 10386 * Reverse the buffer. 10387 */ 10388 _reverse() { 10389 if (this.loaded) { 10390 for (let i = 0; i < this.numberOfChannels; i++) { 10391 this.getChannelData(i).reverse(); 10392 } 10393 } 10394 return this; 10395 } 10396 /** 10397 * If the buffer is loaded or not 10398 */ 10399 get loaded() { 10400 return this.length > 0; 10401 } 10402 /** 10403 * The duration of the buffer in seconds. 10404 */ 10405 get duration() { 10406 if (this._buffer) { 10407 return this._buffer.duration; 10408 } else { 10409 return 0; 10410 } 10411 } 10412 /** 10413 * The length of the buffer in samples 10414 */ 10415 get length() { 10416 if (this._buffer) { 10417 return this._buffer.length; 10418 } else { 10419 return 0; 10420 } 10421 } 10422 /** 10423 * The number of discrete audio channels. Returns 0 if no buffer is loaded. 10424 */ 10425 get numberOfChannels() { 10426 if (this._buffer) { 10427 return this._buffer.numberOfChannels; 10428 } else { 10429 return 0; 10430 } 10431 } 10432 /** 10433 * Reverse the buffer. 10434 */ 10435 get reverse() { 10436 return this._reversed; 10437 } 10438 set reverse(rev) { 10439 if (this._reversed !== rev) { 10440 this._reversed = rev; 10441 this._reverse(); 10442 } 10443 } 10444 /** 10445 * Create a ToneAudioBuffer from the array. To create a multichannel AudioBuffer, 10446 * pass in a multidimensional array. 10447 * @param array The array to fill the audio buffer 10448 * @return A ToneAudioBuffer created from the array 10449 */ 10450 static fromArray(array) { 10451 return new _ToneAudioBuffer().fromArray(array); 10452 } 10453 /** 10454 * Creates a ToneAudioBuffer from a URL, returns a promise which resolves to a ToneAudioBuffer 10455 * @param url The url to load. 10456 * @return A promise which resolves to a ToneAudioBuffer 10457 */ 10458 static fromUrl(url) { 10459 return __awaiter(this, void 0, void 0, function* () { 10460 const buffer = new _ToneAudioBuffer(); 10461 return yield buffer.load(url); 10462 }); 10463 } 10464 /** 10465 * Loads a url using fetch and returns the AudioBuffer. 10466 */ 10467 static load(url) { 10468 return __awaiter(this, void 0, void 0, function* () { 10469 const baseUrl = _ToneAudioBuffer.baseUrl === "" || _ToneAudioBuffer.baseUrl.endsWith("/") ? _ToneAudioBuffer.baseUrl : _ToneAudioBuffer.baseUrl + "/"; 10470 const response = yield fetch(baseUrl + url); 10471 if (!response.ok) { 10472 throw new Error(`could not load url: ${url}`); 10473 } 10474 const arrayBuffer = yield response.arrayBuffer(); 10475 const audioBuffer = yield getContext().decodeAudioData(arrayBuffer); 10476 return audioBuffer; 10477 }); 10478 } 10479 /** 10480 * Checks a url's extension to see if the current browser can play that file type. 10481 * @param url The url/extension to test 10482 * @return If the file extension can be played 10483 * @static 10484 * @example 10485 * Tone.ToneAudioBuffer.supportsType("wav"); // returns true 10486 * Tone.ToneAudioBuffer.supportsType("path/to/file.wav"); // returns true 10487 */ 10488 static supportsType(url) { 10489 const extensions = url.split("."); 10490 const extension = extensions[extensions.length - 1]; 10491 const response = document.createElement("audio").canPlayType("audio/" + extension); 10492 return response !== ""; 10493 } 10494 /** 10495 * Returns a Promise which resolves when all of the buffers have loaded 10496 */ 10497 static loaded() { 10498 return __awaiter(this, void 0, void 0, function* () { 10499 yield Promise.resolve(); 10500 while (_ToneAudioBuffer.downloads.length) { 10501 yield _ToneAudioBuffer.downloads[0]; 10502 } 10503 }); 10504 } 10505}; 10506ToneAudioBuffer.baseUrl = ""; 10507ToneAudioBuffer.downloads = []; 10508
vendor: 1,988 bytes, lines 10509-10571
10509// node_modules/tone/build/esm/core/context/OfflineContext.js 10510var OfflineContext = class extends Context { 10511 constructor() { 10512 super({ 10513 clockSource: "offline", 10514 context: isOfflineAudioContext(arguments[0]) ? arguments[0] : createOfflineAudioContext(arguments[0], arguments[1] * arguments[2], arguments[2]), 10515 lookAhead: 0, 10516 updateInterval: isOfflineAudioContext(arguments[0]) ? 128 / arguments[0].sampleRate : 128 / arguments[2] 10517 }); 10518 this.name = "OfflineContext"; 10519 this._currentTime = 0; 10520 this.isOffline = true; 10521 this._duration = isOfflineAudioContext(arguments[0]) ? arguments[0].length / arguments[0].sampleRate : arguments[1]; 10522 } 10523 /** 10524 * Override the now method to point to the internal clock time 10525 */ 10526 now() { 10527 return this._currentTime; 10528 } 10529 /** 10530 * Same as this.now() 10531 */ 10532 get currentTime() { 10533 return this._currentTime; 10534 } 10535 /** 10536 * Render just the clock portion of the audio context. 10537 */ 10538 _renderClock(asynchronous) { 10539 return __awaiter(this, void 0, void 0, function* () { 10540 let index = 0; 10541 while (this._duration - this._currentTime >= 0) { 10542 this.emit("tick"); 10543 this._currentTime += 128 / this.sampleRate; 10544 index++; 10545 const yieldEvery = Math.floor(this.sampleRate / 128); 10546 if (asynchronous && index % yieldEvery === 0) { 10547 yield new Promise((done) => setTimeout(done, 1)); 10548 } 10549 } 10550 }); 10551 } 10552 /** 10553 * Render the output of the OfflineContext 10554 * @param asynchronous If the clock should be rendered asynchronously, which will not block the main thread, but be slightly slower. 10555 */ 10556 render() { 10557 return __awaiter(this, arguments, void 0, function* (asynchronous = true) { 10558 yield this.workletsAreReady(); 10559 yield this._renderClock(asynchronous); 10560 const buffer = yield this._context.startRendering(); 10561 return new ToneAudioBuffer(buffer); 10562 }); 10563 } 10564 /** 10565 * Close the context 10566 */ 10567 close() { 10568 return Promise.resolve(); 10569 } 10570}; 10571
vendor: 894 bytes, lines 10572-10604
10572// node_modules/tone/build/esm/core/Global.js 10573var dummyContext = new DummyContext(); 10574var globalContext = dummyContext; 10575function getContext() { 10576 if (globalContext === dummyContext && hasAudioContext) { 10577 setContext(new Context()); 10578 } 10579 return globalContext; 10580} 10581function setContext(context2, disposeOld = false) { 10582 if (disposeOld) { 10583 globalContext.dispose(); 10584 } 10585 if (isAudioContext(context2)) { 10586 globalContext = new Context(context2); 10587 } else if (isOfflineAudioContext(context2)) { 10588 globalContext = new OfflineContext(context2); 10589 } else { 10590 globalContext = context2; 10591 } 10592} 10593function start() { 10594 return globalContext.resume(); 10595} 10596if (theWindow && !theWindow.TONE_SILENCE_LOGGING) { 10597 let prefix = "v"; 10598 if (version === "dev") { 10599 prefix = ""; 10600 } 10601 const printString = ` * Tone.js ${prefix}${version} * `; 10602 console.log(`%c${printString}`, "background: #000; color: #fff"); 10603} 10604
vendor: 571 bytes, lines 10605-10631
10605// node_modules/tone/build/esm/core/type/Conversions.js 10606function dbToGain(db) { 10607 return Math.pow(10, db / 20); 10608} 10609function gainToDb(gain) { 10610 return 20 * (Math.log(gain) / Math.LN10); 10611} 10612function intervalToFrequencyRatio(interval) { 10613 return Math.pow(2, interval / 12); 10614} 10615var A4 = 440; 10616function getA4() { 10617 return A4; 10618} 10619function setA4(freq) { 10620 A4 = freq; 10621} 10622function ftom(frequency) { 10623 return Math.round(ftomf(frequency)); 10624} 10625function ftomf(frequency) { 10626 return 69 + 12 * Math.log2(frequency / A4); 10627} 10628function mtof(midi) { 10629 return A4 * Math.pow(2, (midi - 69) / 12); 10630} 10631
vendor: 6,275 bytes, lines 10632-10871
10632// node_modules/tone/build/esm/core/type/TimeBase.js 10633var TimeBaseClass = class _TimeBaseClass extends Tone { 10634 /** 10635 * @param context The context associated with the time value. Used to compute 10636 * Transport and context-relative timing. 10637 * @param value The time value as a number, string or object 10638 * @param units Unit values 10639 */ 10640 constructor(context2, value, units) { 10641 super(); 10642 this.defaultUnits = "s"; 10643 this._val = value; 10644 this._units = units; 10645 this.context = context2; 10646 this._expressions = this._getExpressions(); 10647 } 10648 /** 10649 * All of the time encoding expressions 10650 */ 10651 _getExpressions() { 10652 return { 10653 hz: { 10654 method: (value) => { 10655 return this._frequencyToUnits(parseFloat(value)); 10656 }, 10657 regexp: /^(\d+(?:\.\d+)?)hz$/i 10658 }, 10659 i: { 10660 method: (value) => { 10661 return this._ticksToUnits(parseInt(value, 10)); 10662 }, 10663 regexp: /^(\d+)i$/i 10664 }, 10665 m: { 10666 method: (value) => { 10667 return this._beatsToUnits(parseInt(value, 10) * this._getTimeSignature()); 10668 }, 10669 regexp: /^(\d+)m$/i 10670 }, 10671 n: { 10672 method: (value, dot) => { 10673 const numericValue = parseInt(value, 10); 10674 const scalar = dot === "." ? 1.5 : 1; 10675 if (numericValue === 1) { 10676 return this._beatsToUnits(this._getTimeSignature()) * scalar; 10677 } else { 10678 return this._beatsToUnits(4 / numericValue) * scalar; 10679 } 10680 }, 10681 regexp: /^(\d+)n(\.?)$/i 10682 }, 10683 number: { 10684 method: (value) => { 10685 return this._expressions[this.defaultUnits].method.call(this, value); 10686 }, 10687 regexp: /^(\d+(?:\.\d+)?)$/ 10688 }, 10689 s: { 10690 method: (value) => { 10691 return this._secondsToUnits(parseFloat(value)); 10692 }, 10693 regexp: /^(\d+(?:\.\d+)?)s$/ 10694 }, 10695 samples: { 10696 method: (value) => { 10697 return parseInt(value, 10) / this.context.sampleRate; 10698 }, 10699 regexp: /^(\d+)samples$/ 10700 }, 10701 t: { 10702 method: (value) => { 10703 const numericValue = parseInt(value, 10); 10704 return this._beatsToUnits(8 / (Math.floor(numericValue) * 3)); 10705 }, 10706 regexp: /^(\d+)t$/i 10707 }, 10708 tr: { 10709 method: (m, q, s) => { 10710 let total = 0; 10711 if (m && m !== "0") { 10712 total += this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); 10713 } 10714 if (q && q !== "0") { 10715 total += this._beatsToUnits(parseFloat(q)); 10716 } 10717 if (s && s !== "0") { 10718 total += this._beatsToUnits(parseFloat(s) / 4); 10719 } 10720 return total; 10721 }, 10722 regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/ 10723 } 10724 }; 10725 } 10726 //------------------------------------- 10727 // VALUE OF 10728 //------------------------------------- 10729 /** 10730 * Evaluate the time value. Returns the time in seconds. 10731 */ 10732 valueOf() { 10733 if (this._val instanceof _TimeBaseClass) { 10734 this.fromType(this._val); 10735 } 10736 if (isUndef(this._val)) { 10737 return this._noArg(); 10738 } else if (isString(this._val) && isUndef(this._units)) { 10739 for (const units in this._expressions) { 10740 if (this._expressions[units].regexp.test(this._val.trim())) { 10741 this._units = units; 10742 break; 10743 } 10744 } 10745 } else if (isObject(this._val)) { 10746 let total = 0; 10747 for (const typeName in this._val) { 10748 if (isDefined(this._val[typeName])) { 10749 const quantity = this._val[typeName]; 10750 const time = ( 10751 // @ts-ignore 10752 new this.constructor(this.context, typeName).valueOf() * quantity 10753 ); 10754 total += time; 10755 } 10756 } 10757 return total; 10758 } 10759 if (isDefined(this._units)) { 10760 const expr = this._expressions[this._units]; 10761 const matching = this._val.toString().trim().match(expr.regexp); 10762 if (matching) { 10763 return expr.method.apply(this, matching.slice(1)); 10764 } else { 10765 return expr.method.call(this, this._val); 10766 } 10767 } else if (isString(this._val)) { 10768 return parseFloat(this._val); 10769 } else { 10770 return this._val; 10771 } 10772 } 10773 //------------------------------------- 10774 // UNIT CONVERSIONS 10775 //------------------------------------- 10776 /** 10777 * Returns the value of a frequency in the current units 10778 */ 10779 _frequencyToUnits(freq) { 10780 return 1 / freq; 10781 } 10782 /** 10783 * Return the value of the beats in the current units 10784 */ 10785 _beatsToUnits(beats) { 10786 return 60 / this._getBpm() * beats; 10787 } 10788 /** 10789 * Returns the value of a second in the current units 10790 */ 10791 _secondsToUnits(seconds) { 10792 return seconds; 10793 } 10794 /** 10795 * Returns the value of a tick in the current time units 10796 */ 10797 _ticksToUnits(ticks) { 10798 return ticks * this._beatsToUnits(1) / this._getPPQ(); 10799 } 10800 /** 10801 * With no arguments, return 'now' 10802 */ 10803 _noArg() { 10804 return this._now(); 10805 } 10806 //------------------------------------- 10807 // TEMPO CONVERSIONS 10808 //------------------------------------- 10809 /** 10810 * Return the bpm 10811 */ 10812 _getBpm() { 10813 return this.context.transport.bpm.value; 10814 } 10815 /** 10816 * Return the timeSignature 10817 */ 10818 _getTimeSignature() { 10819 return this.context.transport.timeSignature; 10820 } 10821 /** 10822 * Return the PPQ or 192 if Transport is not available 10823 */ 10824 _getPPQ() { 10825 return this.context.transport.PPQ; 10826 } 10827 //------------------------------------- 10828 // CONVERSION INTERFACE 10829 //------------------------------------- 10830 /** 10831 * Coerce a time type into this units type. 10832 * @param type Any time type units 10833 */ 10834 fromType(type) { 10835 this._units = void 0; 10836 switch (this.defaultUnits) { 10837 case "s": 10838 this._val = type.toSeconds(); 10839 break; 10840 case "i": 10841 this._val = type.toTicks(); 10842 break; 10843 case "hz": 10844 this._val = type.toFrequency(); 10845 break; 10846 case "midi": 10847 this._val = type.toMidi(); 10848 break; 10849 } 10850 return this; 10851 } 10852 /** 10853 * Return the value in hertz 10854 */ 10855 toFrequency() { 10856 return 1 / this.toSeconds(); 10857 } 10858 /** 10859 * Return the time in samples 10860 */ 10861 toSamples() { 10862 return this.toSeconds() * this.context.sampleRate; 10863 } 10864 /** 10865 * Return the time in milliseconds. 10866 */ 10867 toMilliseconds() { 10868 return this.toSeconds() * 1e3; 10869 } 10870}; 10871
vendor: 3,775 bytes, lines 10872-10989
10872// node_modules/tone/build/esm/core/type/Time.js 10873var TimeClass = class _TimeClass extends TimeBaseClass { 10874 constructor() { 10875 super(...arguments); 10876 this.name = "TimeClass"; 10877 } 10878 _getExpressions() { 10879 return Object.assign(super._getExpressions(), { 10880 now: { 10881 method: (capture) => { 10882 return this._now() + new this.constructor(this.context, capture).valueOf(); 10883 }, 10884 regexp: /^\+(.+)/ 10885 }, 10886 quantize: { 10887 method: (capture) => { 10888 const quantTo = new _TimeClass(this.context, capture).valueOf(); 10889 return this._secondsToUnits(this.context.transport.nextSubdivision(quantTo)); 10890 }, 10891 regexp: /^@(.+)/ 10892 } 10893 }); 10894 } 10895 /** 10896 * Quantize the time by the given subdivision. Optionally add a 10897 * percentage which will move the time value towards the ideal 10898 * quantized value by that percentage. 10899 * @param subdiv The subdivision to quantize to 10900 * @param percent Move the time value towards the quantized value by a percentage. 10901 * @example 10902 * Tone.Time(21).quantize(2); // returns 22 10903 * Tone.Time(0.6).quantize("4n", 0.5); // returns 0.55 10904 */ 10905 quantize(subdiv, percent = 1) { 10906 const subdivision = new this.constructor(this.context, subdiv).valueOf(); 10907 const value = this.valueOf(); 10908 const multiple = Math.round(value / subdivision); 10909 const ideal = multiple * subdivision; 10910 const diff = ideal - value; 10911 return value + diff * percent; 10912 } 10913 //------------------------------------- 10914 // CONVERSIONS 10915 //------------------------------------- 10916 /** 10917 * Convert a Time to Notation. The notation values are will be the 10918 * closest representation between 1m to 128th note. 10919 * @return {Notation} 10920 * @example 10921 * // if the Transport is at 120bpm: 10922 * Tone.Time(2).toNotation(); // returns "1m" 10923 */ 10924 toNotation() { 10925 const time = this.toSeconds(); 10926 const testNotations = ["1m"]; 10927 for (let power = 1; power < 9; power++) { 10928 const subdiv = Math.pow(2, power); 10929 testNotations.push(subdiv + "n."); 10930 testNotations.push(subdiv + "n"); 10931 testNotations.push(subdiv + "t"); 10932 } 10933 testNotations.push("0"); 10934 let closest = testNotations[0]; 10935 let closestSeconds = new _TimeClass(this.context, testNotations[0]).toSeconds(); 10936 testNotations.forEach((notation) => { 10937 const notationSeconds = new _TimeClass(this.context, notation).toSeconds(); 10938 if (Math.abs(notationSeconds - time) < Math.abs(closestSeconds - time)) { 10939 closest = notation; 10940 closestSeconds = notationSeconds; 10941 } 10942 }); 10943 return closest; 10944 } 10945 /** 10946 * Return the time encoded as Bars:Beats:Sixteenths. 10947 */ 10948 toBarsBeatsSixteenths() { 10949 const quarterTime = this._beatsToUnits(1); 10950 let quarters = this.valueOf() / quarterTime; 10951 quarters = parseFloat(quarters.toFixed(4)); 10952 const measures = Math.floor(quarters / this._getTimeSignature()); 10953 let sixteenths = quarters % 1 * 4; 10954 quarters = Math.floor(quarters) % this._getTimeSignature(); 10955 const sixteenthString = sixteenths.toString(); 10956 if (sixteenthString.length > 3) { 10957 sixteenths = parseFloat(parseFloat(sixteenthString).toFixed(3)); 10958 } 10959 const progress = [measures, quarters, sixteenths]; 10960 return progress.join(":"); 10961 } 10962 /** 10963 * Return the time in ticks. 10964 */ 10965 toTicks() { 10966 const quarterTime = this._beatsToUnits(1); 10967 const quarters = this.valueOf() / quarterTime; 10968 return quarters * this._getPPQ(); 10969 } 10970 /** 10971 * Return the time in seconds. 10972 */ 10973 toSeconds() { 10974 return this.valueOf(); 10975 } 10976 /** 10977 * Return the value as a midi note. 10978 */ 10979 toMidi() { 10980 return ftom(this.toFrequency()); 10981 } 10982 _now() { 10983 return this.context.now(); 10984 } 10985}; 10986function Time(value, units) { 10987 return new TimeClass(getContext(), value, units); 10988} 10989
vendor: 5,925 bytes, lines 10990-11255
10990// node_modules/tone/build/esm/core/type/Frequency.js 10991var FrequencyClass = class _FrequencyClass extends TimeClass { 10992 constructor() { 10993 super(...arguments); 10994 this.name = "Frequency"; 10995 this.defaultUnits = "hz"; 10996 } 10997 /** 10998 * The [concert tuning pitch](https://en.wikipedia.org/wiki/Concert_pitch) which is used 10999 * to generate all the other pitch values from notes. A4's values in Hertz. 11000 */ 11001 static get A4() { 11002 return getA4(); 11003 } 11004 static set A4(freq) { 11005 setA4(freq); 11006 } 11007 //------------------------------------- 11008 // AUGMENT BASE EXPRESSIONS 11009 //------------------------------------- 11010 _getExpressions() { 11011 return Object.assign({}, super._getExpressions(), { 11012 midi: { 11013 regexp: /^(\d+(?:\.\d+)?midi)/, 11014 method(value) { 11015 if (this.defaultUnits === "midi") { 11016 return value; 11017 } else { 11018 return _FrequencyClass.mtof(value); 11019 } 11020 } 11021 }, 11022 note: { 11023 regexp: /^([a-g]{1}(?:b|#|##|x|bb|###|#x|x#|bbb)?)(-?[0-9]+)/i, 11024 method(pitch, octave) { 11025 const index = noteToScaleIndex[pitch.toLowerCase()]; 11026 const noteNumber = index + (parseInt(octave, 10) + 1) * 12; 11027 if (this.defaultUnits === "midi") { 11028 return noteNumber; 11029 } else { 11030 return _FrequencyClass.mtof(noteNumber); 11031 } 11032 } 11033 }, 11034 tr: { 11035 regexp: /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/, 11036 method(m, q, s) { 11037 let total = 1; 11038 if (m && m !== "0") { 11039 total *= this._beatsToUnits(this._getTimeSignature() * parseFloat(m)); 11040 } 11041 if (q && q !== "0") { 11042 total *= this._beatsToUnits(parseFloat(q)); 11043 } 11044 if (s && s !== "0") { 11045 total *= this._beatsToUnits(parseFloat(s) / 4); 11046 } 11047 return total; 11048 } 11049 } 11050 }); 11051 } 11052 //------------------------------------- 11053 // EXPRESSIONS 11054 //------------------------------------- 11055 /** 11056 * Transposes the frequency by the given number of semitones. 11057 * @return A new transposed frequency 11058 * @example 11059 * Tone.Frequency("A4").transpose(3); // "C5" 11060 */ 11061 transpose(interval) { 11062 return new _FrequencyClass(this.context, this.valueOf() * intervalToFrequencyRatio(interval)); 11063 } 11064 /** 11065 * Takes an array of semitone intervals and returns 11066 * an array of frequencies transposed by those intervals. 11067 * @return Returns an array of Frequencies 11068 * @example 11069 * Tone.Frequency("A4").harmonize([0, 3, 7]); // ["A4", "C5", "E5"] 11070 */ 11071 harmonize(intervals) { 11072 return intervals.map((interval) => { 11073 return this.transpose(interval); 11074 }); 11075 } 11076 //------------------------------------- 11077 // UNIT CONVERSIONS 11078 //------------------------------------- 11079 /** 11080 * Return the value of the frequency as a MIDI note 11081 * @example 11082 * Tone.Frequency("C4").toMidi(); // 60 11083 */ 11084 toMidi() { 11085 return ftom(this.valueOf()); 11086 } 11087 /** 11088 * Return the value of the frequency in Scientific Pitch Notation 11089 * @example 11090 * Tone.Frequency(69, "midi").toNote(); // "A4" 11091 */ 11092 toNote() { 11093 const freq = this.toFrequency(); 11094 const log2 = Math.log2(freq / _FrequencyClass.A4); 11095 let noteNumber = Math.round(12 * log2) + 57; 11096 const octave = Math.floor(noteNumber / 12); 11097 if (octave < 0) { 11098 noteNumber += -12 * octave; 11099 } 11100 const noteName = scaleIndexToNote[noteNumber % 12]; 11101 return noteName + octave.toString(); 11102 } 11103 /** 11104 * Return the duration of one cycle in seconds. 11105 */ 11106 toSeconds() { 11107 return 1 / super.toSeconds(); 11108 } 11109 /** 11110 * Return the duration of one cycle in ticks 11111 */ 11112 toTicks() { 11113 const quarterTime = this._beatsToUnits(1); 11114 const quarters = this.valueOf() / quarterTime; 11115 return Math.floor(quarters * this._getPPQ()); 11116 } 11117 //------------------------------------- 11118 // UNIT CONVERSIONS HELPERS 11119 //------------------------------------- 11120 /** 11121 * With no arguments, return 0 11122 */ 11123 _noArg() { 11124 return 0; 11125 } 11126 /** 11127 * Returns the value of a frequency in the current units 11128 */ 11129 _frequencyToUnits(freq) { 11130 return freq; 11131 } 11132 /** 11133 * Returns the value of a tick in the current time units 11134 */ 11135 _ticksToUnits(ticks) { 11136 return 1 / (ticks * 60 / (this._getBpm() * this._getPPQ())); 11137 } 11138 /** 11139 * Return the value of the beats in the current units 11140 */ 11141 _beatsToUnits(beats) { 11142 return 1 / super._beatsToUnits(beats); 11143 } 11144 /** 11145 * Returns the value of a second in the current units 11146 */ 11147 _secondsToUnits(seconds) { 11148 return 1 / seconds; 11149 } 11150 /** 11151 * Convert a MIDI note to frequency value. 11152 * @param midi The midi number to convert. 11153 * @return The corresponding frequency value 11154 */ 11155 static mtof(midi) { 11156 return mtof(midi); 11157 } 11158 /** 11159 * Convert a frequency value to a MIDI note. 11160 * @param frequency The value to frequency value to convert. 11161 */ 11162 static ftom(frequency) { 11163 return ftom(frequency); 11164 } 11165}; 11166var noteToScaleIndex = { 11167 cbbb: -3, 11168 cbb: -2, 11169 cb: -1, 11170 c: 0, 11171 "c#": 1, 11172 cx: 2, 11173 "c##": 2, 11174 "c###": 3, 11175 "cx#": 3, 11176 "c#x": 3, 11177 dbbb: -1, 11178 dbb: 0, 11179 db: 1, 11180 d: 2, 11181 "d#": 3, 11182 dx: 4, 11183 "d##": 4, 11184 "d###": 5, 11185 "dx#": 5, 11186 "d#x": 5, 11187 ebbb: 1, 11188 ebb: 2, 11189 eb: 3, 11190 e: 4, 11191 "e#": 5, 11192 ex: 6, 11193 "e##": 6, 11194 "e###": 7, 11195 "ex#": 7, 11196 "e#x": 7, 11197 fbbb: 2, 11198 fbb: 3, 11199 fb: 4, 11200 f: 5, 11201 "f#": 6, 11202 fx: 7, 11203 "f##": 7, 11204 "f###": 8, 11205 "fx#": 8, 11206 "f#x": 8, 11207 gbbb: 4, 11208 gbb: 5, 11209 gb: 6, 11210 g: 7, 11211 "g#": 8, 11212 gx: 9, 11213 "g##": 9, 11214 "g###": 10, 11215 "gx#": 10, 11216 "g#x": 10, 11217 abbb: 6, 11218 abb: 7, 11219 ab: 8, 11220 a: 9, 11221 "a#": 10, 11222 ax: 11, 11223 "a##": 11, 11224 "a###": 12, 11225 "ax#": 12, 11226 "a#x": 12, 11227 bbbb: 8, 11228 bbb: 9, 11229 bb: 10, 11230 b: 11, 11231 "b#": 12, 11232 bx: 13, 11233 "b##": 13, 11234 "b###": 14, 11235 "bx#": 14, 11236 "b#x": 14 11237}; 11238var scaleIndexToNote = [ 11239 "C", 11240 "C#", 11241 "D", 11242 "D#", 11243 "E", 11244 "F", 11245 "F#", 11246 "G", 11247 "G#", 11248 "A", 11249 "A#", 11250 "B" 11251]; 11252function Frequency(value, units) { 11253 return new FrequencyClass(getContext(), value, units); 11254} 11255
vendor: 325 bytes, lines 11256-11269
11256// node_modules/tone/build/esm/core/type/TransportTime.js 11257var TransportTimeClass = class extends TimeClass { 11258 constructor() { 11259 super(...arguments); 11260 this.name = "TransportTime"; 11261 } 11262 /** 11263 * Return the current time in whichever context is relevant 11264 */ 11265 _now() { 11266 return this.context.transport.seconds; 11267 } 11268}; 11269
vendor: 4,415 bytes, lines 11270-11419
11270// node_modules/tone/build/esm/core/context/ToneWithContext.js 11271var ToneWithContext = class _ToneWithContext extends Tone { 11272 constructor() { 11273 super(); 11274 const options = optionsFromArguments(_ToneWithContext.getDefaults(), arguments, ["context"]); 11275 if (this.defaultContext) { 11276 this.context = this.defaultContext; 11277 } else { 11278 this.context = options.context; 11279 } 11280 } 11281 static getDefaults() { 11282 return { 11283 context: getContext() 11284 }; 11285 } 11286 /** 11287 * Return the current time of the Context clock plus the lookAhead. 11288 * @example 11289 * setInterval(() => { 11290 * console.log(Tone.now()); 11291 * }, 100); 11292 */ 11293 now() { 11294 return this.context.currentTime + this.context.lookAhead; 11295 } 11296 /** 11297 * Return the current time of the Context clock without any lookAhead. 11298 * @example 11299 * setInterval(() => { 11300 * console.log(Tone.immediate()); 11301 * }, 100); 11302 */ 11303 immediate() { 11304 return this.context.currentTime; 11305 } 11306 /** 11307 * The duration in seconds of one sample. 11308 */ 11309 get sampleTime() { 11310 return 1 / this.context.sampleRate; 11311 } 11312 /** 11313 * The number of seconds of 1 processing block (128 samples) 11314 * @example 11315 * console.log(Tone.Destination.blockTime); 11316 */ 11317 get blockTime() { 11318 return 128 / this.context.sampleRate; 11319 } 11320 /** 11321 * Convert the incoming time to seconds. 11322 * This is calculated against the current {@link TransportClass} bpm 11323 * @example 11324 * const gain = new Tone.Gain(); 11325 * setInterval(() => console.log(gain.toSeconds("4n")), 100); 11326 * // ramp the tempo to 60 bpm over 30 seconds 11327 * Tone.getTransport().bpm.rampTo(60, 30); 11328 */ 11329 toSeconds(time) { 11330 assertUsedScheduleTime(time); 11331 return new TimeClass(this.context, time).toSeconds(); 11332 } 11333 /** 11334 * Convert the input to a frequency number 11335 * @example 11336 * const gain = new Tone.Gain(); 11337 * console.log(gain.toFrequency("4n")); 11338 */ 11339 toFrequency(freq) { 11340 return new FrequencyClass(this.context, freq).toFrequency(); 11341 } 11342 /** 11343 * Convert the input time into ticks 11344 * @example 11345 * const gain = new Tone.Gain(); 11346 * console.log(gain.toTicks("4n")); 11347 */ 11348 toTicks(time) { 11349 return new TransportTimeClass(this.context, time).toTicks(); 11350 } 11351 //------------------------------------- 11352 // GET/SET 11353 //------------------------------------- 11354 /** 11355 * Get a subset of the properties which are in the partial props 11356 */ 11357 _getPartialProperties(props) { 11358 const options = this.get(); 11359 Object.keys(options).forEach((name) => { 11360 if (isUndef(props[name])) { 11361 delete options[name]; 11362 } 11363 }); 11364 return options; 11365 } 11366 /** 11367 * Get the object's attributes. 11368 * @example 11369 * const osc = new Tone.Oscillator(); 11370 * console.log(osc.get()); 11371 */ 11372 get() { 11373 const defaults = getDefaultsFromInstance(this); 11374 Object.keys(defaults).forEach((attribute) => { 11375 if (Reflect.has(this, attribute)) { 11376 const member = this[attribute]; 11377 if (isDefined(member) && isDefined(member.value) && isDefined(member.setValueAtTime)) { 11378 defaults[attribute] = member.value; 11379 } else if (member instanceof _ToneWithContext) { 11380 defaults[attribute] = member._getPartialProperties(defaults[attribute]); 11381 } else if (isArray(member) || isNumber(member) || isString(member) || isBoolean(member)) { 11382 defaults[attribute] = member; 11383 } else { 11384 delete defaults[attribute]; 11385 } 11386 } 11387 }); 11388 return defaults; 11389 } 11390 /** 11391 * Set multiple properties at once with an object. 11392 * @example 11393 * const filter = new Tone.Filter().toDestination(); 11394 * // set values using an object 11395 * filter.set({ 11396 * frequency: "C6", 11397 * type: "highpass" 11398 * }); 11399 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/Analogsynth_octaves_highmid.mp3").connect(filter); 11400 * player.autostart = true; 11401 */ 11402 set(props) { 11403 Object.keys(props).forEach((attribute) => { 11404 if (Reflect.has(this, attribute) && isDefined(this[attribute])) { 11405 if (this[attribute] && isDefined(this[attribute].value) && isDefined(this[attribute].setValueAtTime)) { 11406 if (this[attribute].value !== props[attribute]) { 11407 this[attribute].value = props[attribute]; 11408 } 11409 } else if (this[attribute] instanceof _ToneWithContext) { 11410 this[attribute].set(props[attribute]); 11411 } else { 11412 this[attribute] = props[attribute]; 11413 } 11414 } 11415 }); 11416 return this; 11417 } 11418}; 11419
vendor: 1,913 bytes, lines 11420-11489
11420// node_modules/tone/build/esm/core/util/StateTimeline.js 11421var StateTimeline = class extends Timeline { 11422 constructor(initial = "stopped") { 11423 super(); 11424 this.name = "StateTimeline"; 11425 this._initial = initial; 11426 this.setStateAtTime(this._initial, 0); 11427 } 11428 /** 11429 * Returns the scheduled state scheduled before or at 11430 * the given time. 11431 * @param time The time to query. 11432 * @return The name of the state input in setStateAtTime. 11433 */ 11434 getValueAtTime(time) { 11435 const event = this.get(time); 11436 if (event !== null) { 11437 return event.state; 11438 } else { 11439 return this._initial; 11440 } 11441 } 11442 /** 11443 * Add a state to the timeline. 11444 * @param state The name of the state to set. 11445 * @param time The time to query. 11446 * @param options Any additional options that are needed in the timeline. 11447 */ 11448 setStateAtTime(state, time, options) { 11449 assertRange(time, 0); 11450 this.add(Object.assign({}, options, { 11451 state, 11452 time 11453 })); 11454 return this; 11455 } 11456 /** 11457 * Return the event before the time with the given state 11458 * @param state The state to look for 11459 * @param time When to check before 11460 * @return The event with the given state before the time 11461 */ 11462 getLastState(state, time) { 11463 const index = this._search(time); 11464 for (let i = index; i >= 0; i--) { 11465 const event = this._timeline[i]; 11466 if (event.state === state) { 11467 return event; 11468 } 11469 } 11470 } 11471 /** 11472 * Return the event after the time with the given state 11473 * @param state The state to look for 11474 * @param time When to check from 11475 * @return The event with the given state after the time 11476 */ 11477 getNextState(state, time) { 11478 const index = this._search(time); 11479 if (index !== -1) { 11480 for (let i = index; i < this._timeline.length; i++) { 11481 const event = this._timeline[i]; 11482 if (event.state === state) { 11483 return event; 11484 } 11485 } 11486 } 11487 } 11488}; 11489
vendor: 14,516 bytes, lines 11490-11872
11490// node_modules/tone/build/esm/core/context/Param.js 11491var Param = class _Param extends ToneWithContext { 11492 constructor() { 11493 const options = optionsFromArguments(_Param.getDefaults(), arguments, [ 11494 "param", 11495 "units", 11496 "convert" 11497 ]); 11498 super(options); 11499 this.name = "Param"; 11500 this.overridden = false; 11501 this._minOutput = 1e-7; 11502 assert(isDefined(options.param) && (isAudioParam(options.param) || options.param instanceof _Param), "param must be an AudioParam"); 11503 while (!isAudioParam(options.param)) { 11504 options.param = options.param._param; 11505 } 11506 this._swappable = isDefined(options.swappable) ? options.swappable : false; 11507 if (this._swappable) { 11508 this.input = this.context.createGain(); 11509 this._param = options.param; 11510 this.input.connect(this._param); 11511 } else { 11512 this._param = this.input = options.param; 11513 } 11514 this._events = new Timeline(1e3); 11515 this._initialValue = this._param.defaultValue; 11516 this.units = options.units; 11517 this.convert = options.convert; 11518 this._minValue = options.minValue; 11519 this._maxValue = options.maxValue; 11520 if (isDefined(options.value) && options.value !== this._toType(this._initialValue)) { 11521 this.setValueAtTime(options.value, 0); 11522 } 11523 } 11524 static getDefaults() { 11525 return Object.assign(ToneWithContext.getDefaults(), { 11526 convert: true, 11527 units: "number" 11528 }); 11529 } 11530 get value() { 11531 const now = this.now(); 11532 return this.getValueAtTime(now); 11533 } 11534 set value(value) { 11535 this.cancelScheduledValues(this.now()); 11536 this.setValueAtTime(value, this.now()); 11537 } 11538 get minValue() { 11539 if (isDefined(this._minValue)) { 11540 return this._minValue; 11541 } else if (this.units === "time" || this.units === "frequency" || this.units === "normalRange" || this.units === "positive" || this.units === "transportTime" || this.units === "ticks" || this.units === "bpm" || this.units === "hertz" || this.units === "samples") { 11542 return 0; 11543 } else if (this.units === "audioRange") { 11544 return -1; 11545 } else if (this.units === "decibels") { 11546 return -Infinity; 11547 } else { 11548 return this._param.minValue; 11549 } 11550 } 11551 get maxValue() { 11552 if (isDefined(this._maxValue)) { 11553 return this._maxValue; 11554 } else if (this.units === "normalRange" || this.units === "audioRange") { 11555 return 1; 11556 } else { 11557 return this._param.maxValue; 11558 } 11559 } 11560 /** 11561 * Type guard based on the unit name 11562 */ 11563 _is(arg, type) { 11564 return this.units === type; 11565 } 11566 /** 11567 * Make sure the value is always in the defined range 11568 */ 11569 _assertRange(value) { 11570 if (isDefined(this.maxValue) && isDefined(this.minValue)) { 11571 assertRange(value, this._fromType(this.minValue), this._fromType(this.maxValue)); 11572 } 11573 return value; 11574 } 11575 /** 11576 * Convert the given value from the type specified by Param.units 11577 * into the destination value (such as Gain or Frequency). 11578 */ 11579 _fromType(val) { 11580 if (this.convert && !this.overridden) { 11581 if (this._is(val, "time")) { 11582 return this.toSeconds(val); 11583 } else if (this._is(val, "decibels")) { 11584 return dbToGain(val); 11585 } else if (this._is(val, "frequency")) { 11586 return this.toFrequency(val); 11587 } else { 11588 return val; 11589 } 11590 } else if (this.overridden) { 11591 return 0; 11592 } else { 11593 return val; 11594 } 11595 } 11596 /** 11597 * Convert the parameters value into the units specified by Param.units. 11598 */ 11599 _toType(val) { 11600 if (this.convert && this.units === "decibels") { 11601 return gainToDb(val); 11602 } else { 11603 return val; 11604 } 11605 } 11606 //------------------------------------- 11607 // ABSTRACT PARAM INTERFACE 11608 // all docs are generated from ParamInterface.ts 11609 //------------------------------------- 11610 setValueAtTime(value, time) { 11611 const computedTime = this.toSeconds(time); 11612 const numericValue = this._fromType(value); 11613 assert(isFinite(numericValue) && isFinite(computedTime), `Invalid argument(s) to setValueAtTime: ${JSON.stringify(value)}, ${JSON.stringify(time)}`); 11614 this._assertRange(numericValue); 11615 this.log(this.units, "setValueAtTime", value, computedTime); 11616 this._events.add({ 11617 time: computedTime, 11618 type: "setValueAtTime", 11619 value: numericValue 11620 }); 11621 this._param.setValueAtTime(numericValue, computedTime); 11622 return this; 11623 } 11624 getValueAtTime(time) { 11625 const computedTime = Math.max(this.toSeconds(time), 0); 11626 const after = this._events.getAfter(computedTime); 11627 const before = this._events.get(computedTime); 11628 let value = this._initialValue; 11629 if (before === null) { 11630 value = this._initialValue; 11631 } else if (before.type === "setTargetAtTime" && (after === null || after.type === "setValueAtTime")) { 11632 const previous = this._events.getBefore(before.time); 11633 let previousVal; 11634 if (previous === null) { 11635 previousVal = this._initialValue; 11636 } else { 11637 previousVal = previous.value; 11638 } 11639 if (before.type === "setTargetAtTime") { 11640 value = this._exponentialApproach(before.time, previousVal, before.value, before.constant, computedTime); 11641 } 11642 } else if (after === null) { 11643 value = before.value; 11644 } else if (after.type === "linearRampToValueAtTime" || after.type === "exponentialRampToValueAtTime") { 11645 let beforeValue = before.value; 11646 if (before.type === "setTargetAtTime") { 11647 const previous = this._events.getBefore(before.time); 11648 if (previous === null) { 11649 beforeValue = this._initialValue; 11650 } else { 11651 beforeValue = previous.value; 11652 } 11653 } 11654 if (after.type === "linearRampToValueAtTime") { 11655 value = this._linearInterpolate(before.time, beforeValue, after.time, after.value, computedTime); 11656 } else { 11657 value = this._exponentialInterpolate(before.time, beforeValue, after.time, after.value, computedTime); 11658 } 11659 } else { 11660 value = before.value; 11661 } 11662 return this._toType(value); 11663 } 11664 setRampPoint(time) { 11665 time = this.toSeconds(time); 11666 let currentVal = this.getValueAtTime(time); 11667 this.cancelAndHoldAtTime(time); 11668 if (this._fromType(currentVal) === 0) { 11669 currentVal = this._toType(this._minOutput); 11670 } 11671 this.setValueAtTime(currentVal, time); 11672 return this; 11673 } 11674 linearRampToValueAtTime(value, endTime) { 11675 const numericValue = this._fromType(value); 11676 const computedTime = this.toSeconds(endTime); 11677 assert(isFinite(numericValue) && isFinite(computedTime), `Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(value)}, ${JSON.stringify(endTime)}`); 11678 this._assertRange(numericValue); 11679 this._events.add({ 11680 time: computedTime, 11681 type: "linearRampToValueAtTime", 11682 value: numericValue 11683 }); 11684 this.log(this.units, "linearRampToValueAtTime", value, computedTime); 11685 this._param.linearRampToValueAtTime(numericValue, computedTime); 11686 return this; 11687 } 11688 exponentialRampToValueAtTime(value, endTime) { 11689 let numericValue = this._fromType(value); 11690 numericValue = EQ(numericValue, 0) ? this._minOutput : numericValue; 11691 this._assertRange(numericValue); 11692 const computedTime = this.toSeconds(endTime); 11693 assert(isFinite(numericValue) && isFinite(computedTime), `Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(value)}, ${JSON.stringify(endTime)}`); 11694 this._events.add({ 11695 time: computedTime, 11696 type: "exponentialRampToValueAtTime", 11697 value: numericValue 11698 }); 11699 this.log(this.units, "exponentialRampToValueAtTime", value, computedTime); 11700 this._param.exponentialRampToValueAtTime(numericValue, computedTime); 11701 return this; 11702 } 11703 exponentialRampTo(value, rampTime, startTime) { 11704 startTime = this.toSeconds(startTime); 11705 this.setRampPoint(startTime); 11706 this.exponentialRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); 11707 return this; 11708 } 11709 linearRampTo(value, rampTime, startTime) { 11710 startTime = this.toSeconds(startTime); 11711 this.setRampPoint(startTime); 11712 this.linearRampToValueAtTime(value, startTime + this.toSeconds(rampTime)); 11713 return this; 11714 } 11715 targetRampTo(value, rampTime, startTime) { 11716 startTime = this.toSeconds(startTime); 11717 this.setRampPoint(startTime); 11718 this.exponentialApproachValueAtTime(value, startTime, rampTime); 11719 return this; 11720 } 11721 exponentialApproachValueAtTime(value, time, rampTime) { 11722 time = this.toSeconds(time); 11723 rampTime = this.toSeconds(rampTime); 11724 const timeConstant = Math.log(rampTime + 1) / Math.log(200); 11725 this.setTargetAtTime(value, time, timeConstant); 11726 this.cancelAndHoldAtTime(time + rampTime * 0.9); 11727 this.linearRampToValueAtTime(value, time + rampTime); 11728 return this; 11729 } 11730 setTargetAtTime(value, startTime, timeConstant) { 11731 const numericValue = this._fromType(value); 11732 assert(isFinite(timeConstant) && timeConstant > 0, "timeConstant must be a number greater than 0"); 11733 const computedTime = this.toSeconds(startTime); 11734 this._assertRange(numericValue); 11735 assert(isFinite(numericValue) && isFinite(computedTime), `Invalid argument(s) to setTargetAtTime: ${JSON.stringify(value)}, ${JSON.stringify(startTime)}`); 11736 this._events.add({ 11737 constant: timeConstant, 11738 time: computedTime, 11739 type: "setTargetAtTime", 11740 value: numericValue 11741 }); 11742 this.log(this.units, "setTargetAtTime", value, computedTime, timeConstant); 11743 this._param.setTargetAtTime(numericValue, computedTime, timeConstant); 11744 return this; 11745 } 11746 setValueCurveAtTime(values, startTime, duration, scaling = 1) { 11747 duration = this.toSeconds(duration); 11748 startTime = this.toSeconds(startTime); 11749 const startingValue = this._fromType(values[0]) * scaling; 11750 this.setValueAtTime(this._toType(startingValue), startTime); 11751 const segTime = duration / (values.length - 1); 11752 for (let i = 1; i < values.length; i++) { 11753 const numericValue = this._fromType(values[i]) * scaling; 11754 this.linearRampToValueAtTime(this._toType(numericValue), startTime + i * segTime); 11755 } 11756 return this; 11757 } 11758 cancelScheduledValues(time) { 11759 const computedTime = this.toSeconds(time); 11760 assert(isFinite(computedTime), `Invalid argument to cancelScheduledValues: ${JSON.stringify(time)}`); 11761 this._events.cancel(computedTime); 11762 this._param.cancelScheduledValues(computedTime); 11763 this.log(this.units, "cancelScheduledValues", computedTime); 11764 return this; 11765 } 11766 cancelAndHoldAtTime(time) { 11767 const computedTime = this.toSeconds(time); 11768 const valueAtTime = this._fromType(this.getValueAtTime(computedTime)); 11769 assert(isFinite(computedTime), `Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(time)}`); 11770 this.log(this.units, "cancelAndHoldAtTime", computedTime, "value=" + valueAtTime); 11771 const before = this._events.get(computedTime); 11772 const after = this._events.getAfter(computedTime); 11773 if (before && EQ(before.time, computedTime)) { 11774 if (after) { 11775 this._param.cancelScheduledValues(after.time); 11776 this._events.cancel(after.time); 11777 } else { 11778 this._param.cancelAndHoldAtTime(computedTime); 11779 this._events.cancel(computedTime + this.sampleTime); 11780 } 11781 } else if (after) { 11782 this._param.cancelScheduledValues(after.time); 11783 this._events.cancel(after.time); 11784 if (after.type === "linearRampToValueAtTime") { 11785 this.linearRampToValueAtTime(this._toType(valueAtTime), computedTime); 11786 } else if (after.type === "exponentialRampToValueAtTime") { 11787 this.exponentialRampToValueAtTime(this._toType(valueAtTime), computedTime); 11788 } 11789 } 11790 this._events.add({ 11791 time: computedTime, 11792 type: "setValueAtTime", 11793 value: valueAtTime 11794 }); 11795 this._param.setValueAtTime(valueAtTime, computedTime); 11796 return this; 11797 } 11798 rampTo(value, rampTime = 0.1, startTime) { 11799 if (this.units === "frequency" || this.units === "bpm" || this.units === "decibels") { 11800 this.exponentialRampTo(value, rampTime, startTime); 11801 } else { 11802 this.linearRampTo(value, rampTime, startTime); 11803 } 11804 return this; 11805 } 11806 /** 11807 * Apply all of the previously scheduled events to the passed in Param or AudioParam. 11808 * The applied values will start at the context's current time and schedule 11809 * all of the events which are scheduled on this Param onto the passed in param. 11810 */ 11811 apply(param) { 11812 const now = this.context.currentTime; 11813 param.setValueAtTime(this.getValueAtTime(now), now); 11814 const previousEvent = this._events.get(now); 11815 if (previousEvent && previousEvent.type === "setTargetAtTime") { 11816 const nextEvent = this._events.getAfter(previousEvent.time); 11817 const endTime = nextEvent ? nextEvent.time : now + 2; 11818 const subdivisions = (endTime - now) / 10; 11819 for (let i = now; i < endTime; i += subdivisions) { 11820 param.linearRampToValueAtTime(this.getValueAtTime(i), i); 11821 } 11822 } 11823 this._events.forEachAfter(this.context.currentTime, (event) => { 11824 if (event.type === "cancelScheduledValues") { 11825 param.cancelScheduledValues(event.time); 11826 } else if (event.type === "setTargetAtTime") { 11827 param.setTargetAtTime(event.value, event.time, event.constant); 11828 } else { 11829 param[event.type](event.value, event.time); 11830 } 11831 }); 11832 return this; 11833 } 11834 /** 11835 * Replace the Param's internal AudioParam. Will apply scheduled curves 11836 * onto the parameter and replace the connections. 11837 */ 11838 setParam(param) { 11839 assert(this._swappable, "The Param must be assigned as 'swappable' in the constructor"); 11840 const input = this.input; 11841 input.disconnect(this._param); 11842 this.apply(param); 11843 this._param = param; 11844 input.connect(this._param); 11845 return this; 11846 } 11847 dispose() { 11848 super.dispose(); 11849 this._events.dispose(); 11850 return this; 11851 } 11852 get defaultValue() { 11853 return this._toType(this._param.defaultValue); 11854 } 11855 //------------------------------------- 11856 // AUTOMATION CURVE CALCULATIONS 11857 // MIT License, copyright (c) 2014 Jordan Santell 11858 //------------------------------------- 11859 // Calculates the the value along the curve produced by setTargetAtTime 11860 _exponentialApproach(t0, v0, v1, timeConstant, t) { 11861 return v1 + (v0 - v1) * Math.exp(-(t - t0) / timeConstant); 11862 } 11863 // Calculates the the value along the curve produced by linearRampToValueAtTime 11864 _linearInterpolate(t0, v0, t1, v1, t) { 11865 return v0 + (v1 - v0) * ((t - t0) / (t1 - t0)); 11866 } 11867 // Calculates the the value along the curve produced by exponentialRampToValueAtTime 11868 _exponentialInterpolate(t0, v0, t1, v1, t) { 11869 return v0 * Math.pow(v1 / v0, (t - t0) / (t1 - t0)); 11870 } 11871}; 11872
vendor: 8,867 bytes, lines 11873-12144
11873// node_modules/tone/build/esm/core/context/ToneAudioNode.js 11874var ToneAudioNode = class _ToneAudioNode extends ToneWithContext { 11875 constructor() { 11876 super(...arguments); 11877 this._internalChannels = []; 11878 } 11879 /** 11880 * The number of inputs feeding into the AudioNode. 11881 * For source nodes, this will be 0. 11882 * @example 11883 * const node = new Tone.Gain(); 11884 * console.log(node.numberOfInputs); 11885 */ 11886 get numberOfInputs() { 11887 if (isDefined(this.input)) { 11888 if (isAudioParam(this.input) || this.input instanceof Param) { 11889 return 1; 11890 } else { 11891 return this.input.numberOfInputs; 11892 } 11893 } else { 11894 return 0; 11895 } 11896 } 11897 /** 11898 * The number of outputs of the AudioNode. 11899 * @example 11900 * const node = new Tone.Gain(); 11901 * console.log(node.numberOfOutputs); 11902 */ 11903 get numberOfOutputs() { 11904 if (isDefined(this.output)) { 11905 return this.output.numberOfOutputs; 11906 } else { 11907 return 0; 11908 } 11909 } 11910 //------------------------------------- 11911 // AUDIO PROPERTIES 11912 //------------------------------------- 11913 /** 11914 * Used to decide which nodes to get/set properties on 11915 */ 11916 _isAudioNode(node) { 11917 return isDefined(node) && (node instanceof _ToneAudioNode || isAudioNode2(node)); 11918 } 11919 /** 11920 * Get all of the audio nodes (either internal or input/output) which together 11921 * make up how the class node responds to channel input/output 11922 */ 11923 _getInternalNodes() { 11924 const nodeList = this._internalChannels.slice(0); 11925 if (this._isAudioNode(this.input)) { 11926 nodeList.push(this.input); 11927 } 11928 if (this._isAudioNode(this.output)) { 11929 if (this.input !== this.output) { 11930 nodeList.push(this.output); 11931 } 11932 } 11933 return nodeList; 11934 } 11935 /** 11936 * Set the audio options for this node such as channelInterpretation 11937 * channelCount, etc. 11938 * @param options 11939 */ 11940 _setChannelProperties(options) { 11941 const nodeList = this._getInternalNodes(); 11942 nodeList.forEach((node) => { 11943 node.channelCount = options.channelCount; 11944 node.channelCountMode = options.channelCountMode; 11945 node.channelInterpretation = options.channelInterpretation; 11946 }); 11947 } 11948 /** 11949 * Get the current audio options for this node such as channelInterpretation 11950 * channelCount, etc. 11951 */ 11952 _getChannelProperties() { 11953 const nodeList = this._getInternalNodes(); 11954 assert(nodeList.length > 0, "ToneAudioNode does not have any internal nodes"); 11955 const node = nodeList[0]; 11956 return { 11957 channelCount: node.channelCount, 11958 channelCountMode: node.channelCountMode, 11959 channelInterpretation: node.channelInterpretation 11960 }; 11961 } 11962 /** 11963 * channelCount is the number of channels used when up-mixing and down-mixing 11964 * connections to any inputs to the node. The default value is 2 except for 11965 * specific nodes where its value is specially determined. 11966 */ 11967 get channelCount() { 11968 return this._getChannelProperties().channelCount; 11969 } 11970 set channelCount(channelCount) { 11971 const props = this._getChannelProperties(); 11972 this._setChannelProperties(Object.assign(props, { channelCount })); 11973 } 11974 /** 11975 * channelCountMode determines how channels will be counted when up-mixing and 11976 * down-mixing connections to any inputs to the node. 11977 * The default value is "max". This attribute has no effect for nodes with no inputs. 11978 * * "max" - computedNumberOfChannels is the maximum of the number of channels of all connections to an input. In this mode channelCount is ignored. 11979 * * "clamped-max" - computedNumberOfChannels is determined as for "max" and then clamped to a maximum value of the given channelCount. 11980 * * "explicit" - computedNumberOfChannels is the exact value as specified by the channelCount. 11981 */ 11982 get channelCountMode() { 11983 return this._getChannelProperties().channelCountMode; 11984 } 11985 set channelCountMode(channelCountMode) { 11986 const props = this._getChannelProperties(); 11987 this._setChannelProperties(Object.assign(props, { channelCountMode })); 11988 } 11989 /** 11990 * channelInterpretation determines how individual channels will be treated 11991 * when up-mixing and down-mixing connections to any inputs to the node. 11992 * The default value is "speakers". 11993 */ 11994 get channelInterpretation() { 11995 return this._getChannelProperties().channelInterpretation; 11996 } 11997 set channelInterpretation(channelInterpretation) { 11998 const props = this._getChannelProperties(); 11999 this._setChannelProperties(Object.assign(props, { channelInterpretation })); 12000 } 12001 //------------------------------------- 12002 // CONNECTIONS 12003 //------------------------------------- 12004 /** 12005 * connect the output of a ToneAudioNode to an AudioParam, AudioNode, or ToneAudioNode 12006 * @param destination The output to connect to 12007 * @param outputNum The output to connect from 12008 * @param inputNum The input to connect to 12009 */ 12010 connect(destination, outputNum = 0, inputNum = 0) { 12011 connect(this, destination, outputNum, inputNum); 12012 return this; 12013 } 12014 /** 12015 * Connect the output to the context's destination node. 12016 * @example 12017 * const osc = new Tone.Oscillator("C2").start(); 12018 * osc.toDestination(); 12019 */ 12020 toDestination() { 12021 this.connect(this.context.destination); 12022 return this; 12023 } 12024 /** 12025 * Connect the output to the context's destination node. 12026 * @see {@link toDestination} 12027 * @deprecated 12028 */ 12029 toMaster() { 12030 warn("toMaster() has been renamed toDestination()"); 12031 return this.toDestination(); 12032 } 12033 /** 12034 * disconnect the output 12035 */ 12036 disconnect(destination, outputNum = 0, inputNum = 0) { 12037 disconnect(this, destination, outputNum, inputNum); 12038 return this; 12039 } 12040 /** 12041 * Connect the output of this node to the rest of the nodes in series. 12042 * @example 12043 * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/handdrum-loop.mp3"); 12044 * player.autostart = true; 12045 * const filter = new Tone.AutoFilter(4).start(); 12046 * const distortion = new Tone.Distortion(0.5); 12047 * // connect the player to the filter, distortion and then to the master output 12048 * player.chain(filter, distortion, Tone.Destination); 12049 */ 12050 chain(...nodes) { 12051 connectSeries(this, ...nodes); 12052 return this; 12053 } 12054 /** 12055 * connect the output of this node to the rest of the nodes in parallel. 12056 * @example 12057 * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3"); 12058 * player.autostart = true; 12059 * const pitchShift = new Tone.PitchShift(4).toDestination(); 12060 * const filter = new Tone.Filter("G5").toDestination(); 12061 * // connect a node to the pitch shift and filter in parallel 12062 * player.fan(pitchShift, filter); 12063 */ 12064 fan(...nodes) { 12065 nodes.forEach((node) => this.connect(node)); 12066 return this; 12067 } 12068 /** 12069 * Dispose and disconnect 12070 */ 12071 dispose() { 12072 super.dispose(); 12073 if (isDefined(this.input)) { 12074 if (this.input instanceof _ToneAudioNode) { 12075 this.input.dispose(); 12076 } else if (isAudioNode2(this.input)) { 12077 this.input.disconnect(); 12078 } 12079 } 12080 if (isDefined(this.output)) { 12081 if (this.output instanceof _ToneAudioNode) { 12082 this.output.dispose(); 12083 } else if (isAudioNode2(this.output)) { 12084 this.output.disconnect(); 12085 } 12086 } 12087 this._internalChannels = []; 12088 return this; 12089 } 12090}; 12091function connectSeries(...nodes) { 12092 const first = nodes.shift(); 12093 nodes.reduce((prev, current) => { 12094 if (prev instanceof ToneAudioNode) { 12095 prev.connect(current); 12096 } else if (isAudioNode2(prev)) { 12097 connect(prev, current); 12098 } 12099 return current; 12100 }, first); 12101} 12102function connect(srcNode, dstNode, outputNumber = 0, inputNumber = 0) { 12103 assert(isDefined(srcNode), "Cannot connect from undefined node"); 12104 assert(isDefined(dstNode), "Cannot connect to undefined node"); 12105 if (dstNode instanceof ToneAudioNode || isAudioNode2(dstNode)) { 12106 assert(dstNode.numberOfInputs > 0, "Cannot connect to node with no inputs"); 12107 } 12108 assert(srcNode.numberOfOutputs > 0, "Cannot connect from node with no outputs"); 12109 while (dstNode instanceof ToneAudioNode || dstNode instanceof Param) { 12110 if (isDefined(dstNode.input)) { 12111 dstNode = dstNode.input; 12112 } 12113 } 12114 while (srcNode instanceof ToneAudioNode) { 12115 if (isDefined(srcNode.output)) { 12116 srcNode = srcNode.output; 12117 } 12118 } 12119 if (isAudioParam(dstNode)) { 12120 srcNode.connect(dstNode, outputNumber); 12121 } else { 12122 srcNode.connect(dstNode, outputNumber, inputNumber); 12123 } 12124} 12125function disconnect(srcNode, dstNode, outputNumber = 0, inputNumber = 0) { 12126 if (isDefined(dstNode)) { 12127 while (dstNode instanceof ToneAudioNode) { 12128 dstNode = dstNode.input; 12129 } 12130 } 12131 while (!isAudioNode2(srcNode)) { 12132 if (isDefined(srcNode.output)) { 12133 srcNode = srcNode.output; 12134 } 12135 } 12136 if (isAudioParam(dstNode)) { 12137 srcNode.disconnect(dstNode, outputNumber); 12138 } else if (isAudioNode2(dstNode)) { 12139 srcNode.disconnect(dstNode, outputNumber, inputNumber); 12140 } else { 12141 srcNode.disconnect(); 12142 } 12143} 12144
vendor: 966 bytes, lines 12145-12185
12145// node_modules/tone/build/esm/core/context/Gain.js 12146var Gain = class _Gain extends ToneAudioNode { 12147 constructor() { 12148 const options = optionsFromArguments(_Gain.getDefaults(), arguments, [ 12149 "gain", 12150 "units" 12151 ]); 12152 super(options); 12153 this.name = "Gain"; 12154 this._gainNode = this.context.createGain(); 12155 this.input = this._gainNode; 12156 this.output = this._gainNode; 12157 this.gain = new Param({ 12158 context: this.context, 12159 convert: options.convert, 12160 param: this._gainNode.gain, 12161 units: options.units, 12162 value: options.gain, 12163 minValue: options.minValue, 12164 maxValue: options.maxValue 12165 }); 12166 readOnly(this, "gain"); 12167 } 12168 static getDefaults() { 12169 return Object.assign(ToneAudioNode.getDefaults(), { 12170 convert: true, 12171 gain: 1, 12172 units: "gain" 12173 }); 12174 } 12175 /** 12176 * Clean up. 12177 */ 12178 dispose() { 12179 super.dispose(); 12180 this._gainNode.disconnect(); 12181 this.gain.dispose(); 12182 return this; 12183 } 12184}; 12185
vendor: 3,999 bytes, lines 12186-12320
12186// node_modules/tone/build/esm/source/OneShotSource.js 12187var OneShotSource = class extends ToneAudioNode { 12188 constructor(options) { 12189 super(options); 12190 this.onended = noOp; 12191 this._startTime = -1; 12192 this._stopTime = -1; 12193 this._timeout = -1; 12194 this.output = new Gain({ 12195 context: this.context, 12196 gain: 0 12197 }); 12198 this._gainNode = this.output; 12199 this.getStateAtTime = function(time) { 12200 const computedTime = this.toSeconds(time); 12201 if (this._startTime !== -1 && computedTime >= this._startTime && (this._stopTime === -1 || computedTime <= this._stopTime)) { 12202 return "started"; 12203 } else { 12204 return "stopped"; 12205 } 12206 }; 12207 this._fadeIn = options.fadeIn; 12208 this._fadeOut = options.fadeOut; 12209 this._curve = options.curve; 12210 this.onended = options.onended; 12211 } 12212 static getDefaults() { 12213 return Object.assign(ToneAudioNode.getDefaults(), { 12214 curve: "linear", 12215 fadeIn: 0, 12216 fadeOut: 0, 12217 onended: noOp 12218 }); 12219 } 12220 /** 12221 * Start the source at the given time 12222 * @param time When to start the source 12223 */ 12224 _startGain(time, gain = 1) { 12225 assert(this._startTime === -1, "Source cannot be started more than once"); 12226 const fadeInTime = this.toSeconds(this._fadeIn); 12227 this._startTime = time + fadeInTime; 12228 this._startTime = Math.max(this._startTime, this.context.currentTime); 12229 if (fadeInTime > 0) { 12230 this._gainNode.gain.setValueAtTime(0, time); 12231 if (this._curve === "linear") { 12232 this._gainNode.gain.linearRampToValueAtTime(gain, time + fadeInTime); 12233 } else { 12234 this._gainNode.gain.exponentialApproachValueAtTime(gain, time, fadeInTime); 12235 } 12236 } else { 12237 this._gainNode.gain.setValueAtTime(gain, time); 12238 } 12239 return this; 12240 } 12241 /** 12242 * Stop the source node at the given time. 12243 * @param time When to stop the source 12244 */ 12245 stop(time) { 12246 this.log("stop", time); 12247 this._stopGain(this.toSeconds(time)); 12248 return this; 12249 } 12250 /** 12251 * Stop the source at the given time 12252 * @param time When to stop the source 12253 */ 12254 _stopGain(time) { 12255 assert(this._startTime !== -1, "'start' must be called before 'stop'"); 12256 this.cancelStop(); 12257 const fadeOutTime = this.toSeconds(this._fadeOut); 12258 this._stopTime = this.toSeconds(time) + fadeOutTime; 12259 this._stopTime = Math.max(this._stopTime, this.now()); 12260 if (fadeOutTime > 0) { 12261 if (this._curve === "linear") { 12262 this._gainNode.gain.linearRampTo(0, fadeOutTime, time); 12263 } else { 12264 this._gainNode.gain.targetRampTo(0, fadeOutTime, time); 12265 } 12266 } else { 12267 this._gainNode.gain.cancelAndHoldAtTime(time); 12268 this._gainNode.gain.setValueAtTime(0, time); 12269 } 12270 this.context.clearTimeout(this._timeout); 12271 this._timeout = this.context.setTimeout(() => { 12272 const additionalTail = this._curve === "exponential" ? fadeOutTime * 2 : 0; 12273 this._stopSource(this.now() + additionalTail); 12274 this._onended(); 12275 }, this._stopTime - this.context.currentTime); 12276 return this; 12277 } 12278 /** 12279 * Invoke the onended callback 12280 */ 12281 _onended() { 12282 if (this.onended === noOp) { 12283 return; 12284 } 12285 this.onended(this); 12286 this.onended = noOp; 12287 if (!this.context.isOffline) { 12288 const disposeCallback = () => this.dispose(); 12289 if (typeof requestIdleCallback !== "undefined") { 12290 requestIdleCallback(disposeCallback); 12291 } else { 12292 setTimeout(disposeCallback, 10); 12293 } 12294 } 12295 } 12296 /** 12297 * Get the playback state at the current time 12298 */ 12299 get state() { 12300 return this.getStateAtTime(this.now()); 12301 } 12302 /** 12303 * Cancel a scheduled stop event 12304 */ 12305 cancelStop() { 12306 this.log("cancelStop"); 12307 assert(this._startTime !== -1, "Source is not started"); 12308 this._gainNode.gain.cancelScheduledValues(this._startTime + this.sampleTime); 12309 this.context.clearTimeout(this._timeout); 12310 this._stopTime = -1; 12311 return this; 12312 } 12313 dispose() { 12314 super.dispose(); 12315 this._gainNode.dispose(); 12316 this.onended = noOp; 12317 return this; 12318 } 12319}; 12320
vendor: 1,352 bytes, lines 12321-12370
12321// node_modules/tone/build/esm/signal/ToneConstantSource.js 12322var ToneConstantSource = class _ToneConstantSource extends OneShotSource { 12323 constructor() { 12324 const options = optionsFromArguments(_ToneConstantSource.getDefaults(), arguments, ["offset"]); 12325 super(options); 12326 this.name = "ToneConstantSource"; 12327 this._source = this.context.createConstantSource(); 12328 connect(this._source, this._gainNode); 12329 this.offset = new Param({ 12330 context: this.context, 12331 convert: options.convert, 12332 param: this._source.offset, 12333 units: options.units, 12334 value: options.offset, 12335 minValue: options.minValue, 12336 maxValue: options.maxValue 12337 }); 12338 } 12339 static getDefaults() { 12340 return Object.assign(OneShotSource.getDefaults(), { 12341 convert: true, 12342 offset: 1, 12343 units: "number" 12344 }); 12345 } 12346 /** 12347 * Start the source node at the given time 12348 * @param time When to start the source 12349 */ 12350 start(time) { 12351 const computedTime = this.toSeconds(time); 12352 this.log("start", computedTime); 12353 this._startGain(computedTime); 12354 this._source.start(computedTime); 12355 return this; 12356 } 12357 _stopSource(time) { 12358 this._source.stop(time); 12359 } 12360 dispose() { 12361 super.dispose(); 12362 if (this.state === "started") { 12363 this.stop(); 12364 } 12365 this._source.disconnect(); 12366 this.offset.dispose(); 12367 return this; 12368 } 12369}; 12370
vendor: 3,972 bytes, lines 12371-12514
12371// node_modules/tone/build/esm/signal/Signal.js 12372var Signal = class _Signal extends ToneAudioNode { 12373 constructor() { 12374 const options = optionsFromArguments(_Signal.getDefaults(), arguments, [ 12375 "value", 12376 "units" 12377 ]); 12378 super(options); 12379 this.name = "Signal"; 12380 this.override = true; 12381 this.output = this._constantSource = new ToneConstantSource({ 12382 context: this.context, 12383 convert: options.convert, 12384 offset: options.value, 12385 units: options.units, 12386 minValue: options.minValue, 12387 maxValue: options.maxValue 12388 }); 12389 this._constantSource.start(0); 12390 this.input = this._param = this._constantSource.offset; 12391 } 12392 static getDefaults() { 12393 return Object.assign(ToneAudioNode.getDefaults(), { 12394 convert: true, 12395 units: "number", 12396 value: 0 12397 }); 12398 } 12399 connect(destination, outputNum = 0, inputNum = 0) { 12400 connectSignal(this, destination, outputNum, inputNum); 12401 return this; 12402 } 12403 dispose() { 12404 super.dispose(); 12405 this._param.dispose(); 12406 this._constantSource.dispose(); 12407 return this; 12408 } 12409 //------------------------------------- 12410 // ABSTRACT PARAM INTERFACE 12411 // just a proxy for the ConstantSourceNode's offset AudioParam 12412 // all docs are generated from AbstractParam.ts 12413 //------------------------------------- 12414 setValueAtTime(value, time) { 12415 this._param.setValueAtTime(value, time); 12416 return this; 12417 } 12418 getValueAtTime(time) { 12419 return this._param.getValueAtTime(time); 12420 } 12421 setRampPoint(time) { 12422 this._param.setRampPoint(time); 12423 return this; 12424 } 12425 linearRampToValueAtTime(value, time) { 12426 this._param.linearRampToValueAtTime(value, time); 12427 return this; 12428 } 12429 exponentialRampToValueAtTime(value, time) { 12430 this._param.exponentialRampToValueAtTime(value, time); 12431 return this; 12432 } 12433 exponentialRampTo(value, rampTime, startTime) { 12434 this._param.exponentialRampTo(value, rampTime, startTime); 12435 return this; 12436 } 12437 linearRampTo(value, rampTime, startTime) { 12438 this._param.linearRampTo(value, rampTime, startTime); 12439 return this; 12440 } 12441 targetRampTo(value, rampTime, startTime) { 12442 this._param.targetRampTo(value, rampTime, startTime); 12443 return this; 12444 } 12445 exponentialApproachValueAtTime(value, time, rampTime) { 12446 this._param.exponentialApproachValueAtTime(value, time, rampTime); 12447 return this; 12448 } 12449 setTargetAtTime(value, startTime, timeConstant) { 12450 this._param.setTargetAtTime(value, startTime, timeConstant); 12451 return this; 12452 } 12453 setValueCurveAtTime(values, startTime, duration, scaling) { 12454 this._param.setValueCurveAtTime(values, startTime, duration, scaling); 12455 return this; 12456 } 12457 cancelScheduledValues(time) { 12458 this._param.cancelScheduledValues(time); 12459 return this; 12460 } 12461 cancelAndHoldAtTime(time) { 12462 this._param.cancelAndHoldAtTime(time); 12463 return this; 12464 } 12465 rampTo(value, rampTime, startTime) { 12466 this._param.rampTo(value, rampTime, startTime); 12467 return this; 12468 } 12469 get value() { 12470 return this._param.value; 12471 } 12472 set value(value) { 12473 this._param.value = value; 12474 } 12475 get convert() { 12476 return this._param.convert; 12477 } 12478 set convert(convert) { 12479 this._param.convert = convert; 12480 } 12481 get units() { 12482 return this._param.units; 12483 } 12484 get overridden() { 12485 return this._param.overridden; 12486 } 12487 set overridden(overridden) { 12488 this._param.overridden = overridden; 12489 } 12490 get maxValue() { 12491 return this._param.maxValue; 12492 } 12493 get minValue() { 12494 return this._param.minValue; 12495 } 12496 /** 12497 * @see {@link Param.apply}. 12498 */ 12499 apply(param) { 12500 this._param.apply(param); 12501 return this; 12502 } 12503}; 12504function connectSignal(signal, destination, outputNum, inputNum) { 12505 if (destination instanceof Param || isAudioParam(destination) || destination instanceof Signal && destination.override) { 12506 destination.cancelScheduledValues(0); 12507 destination.setValueAtTime(0, 0); 12508 if (destination instanceof Signal) { 12509 destination.overridden = true; 12510 } 12511 } 12512 connect(signal, destination, outputNum, inputNum); 12513} 12514
vendor: 7,625 bytes, lines 12515-12717
12515// node_modules/tone/build/esm/core/clock/TickParam.js 12516var TickParam = class _TickParam extends Param { 12517 constructor() { 12518 const options = optionsFromArguments(_TickParam.getDefaults(), arguments, ["value"]); 12519 super(options); 12520 this.name = "TickParam"; 12521 this._events = new Timeline(Infinity); 12522 this._multiplier = 1; 12523 this._multiplier = options.multiplier; 12524 this._events.cancel(0); 12525 this._events.add({ 12526 ticks: 0, 12527 time: 0, 12528 type: "setValueAtTime", 12529 value: this._fromType(options.value) 12530 }); 12531 this.setValueAtTime(options.value, 0); 12532 } 12533 static getDefaults() { 12534 return Object.assign(Param.getDefaults(), { 12535 multiplier: 1, 12536 units: "hertz", 12537 value: 1 12538 }); 12539 } 12540 setTargetAtTime(value, time, constant) { 12541 time = this.toSeconds(time); 12542 this.setRampPoint(time); 12543 const computedValue = this._fromType(value); 12544 const prevEvent = this._events.get(time); 12545 const segments = Math.round(Math.max(1 / constant, 1)); 12546 for (let i = 0; i <= segments; i++) { 12547 const segTime = constant * i + time; 12548 const rampVal = this._exponentialApproach(prevEvent.time, prevEvent.value, computedValue, constant, segTime); 12549 this.linearRampToValueAtTime(this._toType(rampVal), segTime); 12550 } 12551 return this; 12552 } 12553 setValueAtTime(value, time) { 12554 const computedTime = this.toSeconds(time); 12555 super.setValueAtTime(value, time); 12556 const event = this._events.get(computedTime); 12557 const previousEvent = this._events.previousEvent(event); 12558 const ticksUntilTime = this._getTicksUntilEvent(previousEvent, computedTime); 12559 event.ticks = Math.max(ticksUntilTime, 0); 12560 return this; 12561 } 12562 linearRampToValueAtTime(value, time) { 12563 const computedTime = this.toSeconds(time); 12564 super.linearRampToValueAtTime(value, time); 12565 const event = this._events.get(computedTime); 12566 const previousEvent = this._events.previousEvent(event); 12567 const ticksUntilTime = this._getTicksUntilEvent(previousEvent, computedTime); 12568 event.ticks = Math.max(ticksUntilTime, 0); 12569 return this; 12570 } 12571 exponentialRampToValueAtTime(value, time) { 12572 time = this.toSeconds(time); 12573 const computedVal = this._fromType(value); 12574 const prevEvent = this._events.get(time); 12575 const segments = Math.round(Math.max((time - prevEvent.time) * 10, 1)); 12576 const segmentDur = (time - prevEvent.time) / segments; 12577 for (let i = 0; i <= segments; i++) { 12578 const segTime = segmentDur * i + prevEvent.time; 12579 const rampVal = this._exponentialInterpolate(prevEvent.time, prevEvent.value, time, computedVal, segTime); 12580 this.linearRampToValueAtTime(this._toType(rampVal), segTime); 12581 } 12582 return this; 12583 } 12584 /** 12585 * Returns the tick value at the time. Takes into account 12586 * any automation curves scheduled on the signal. 12587 * @param event The time to get the tick count at 12588 * @return The number of ticks which have elapsed at the time given any automations. 12589 */ 12590 _getTicksUntilEvent(event, time) { 12591 if (event === null) { 12592 event = { 12593 ticks: 0, 12594 time: 0, 12595 type: "setValueAtTime", 12596 value: 0 12597 }; 12598 } else if (isUndef(event.ticks)) { 12599 const previousEvent = this._events.previousEvent(event); 12600 event.ticks = this._getTicksUntilEvent(previousEvent, event.time); 12601 } 12602 const val0 = this._fromType(this.getValueAtTime(event.time)); 12603 let val1 = this._fromType(this.getValueAtTime(time)); 12604 const onTheLineEvent = this._events.get(time); 12605 if (onTheLineEvent && onTheLineEvent.time === time && onTheLineEvent.type === "setValueAtTime") { 12606 val1 = this._fromType(this.getValueAtTime(time - this.sampleTime)); 12607 } 12608 return 0.5 * (time - event.time) * (val0 + val1) + event.ticks; 12609 } 12610 /** 12611 * Returns the tick value at the time. Takes into account 12612 * any automation curves scheduled on the signal. 12613 * @param time The time to get the tick count at 12614 * @return The number of ticks which have elapsed at the time given any automations. 12615 */ 12616 getTicksAtTime(time) { 12617 const computedTime = this.toSeconds(time); 12618 const event = this._events.get(computedTime); 12619 return Math.max(this._getTicksUntilEvent(event, computedTime), 0); 12620 } 12621 /** 12622 * Return the elapsed time of the number of ticks from the given time 12623 * @param ticks The number of ticks to calculate 12624 * @param time The time to get the next tick from 12625 * @return The duration of the number of ticks from the given time in seconds 12626 */ 12627 getDurationOfTicks(ticks, time) { 12628 const computedTime = this.toSeconds(time); 12629 const currentTick = this.getTicksAtTime(time); 12630 return this.getTimeOfTick(currentTick + ticks) - computedTime; 12631 } 12632 /** 12633 * Given a tick, returns the time that tick occurs at. 12634 * @return The time that the tick occurs. 12635 */ 12636 getTimeOfTick(tick) { 12637 const before = this._events.get(tick, "ticks"); 12638 const after = this._events.getAfter(tick, "ticks"); 12639 if (before && before.ticks === tick) { 12640 return before.time; 12641 } else if (before && after && after.type === "linearRampToValueAtTime" && before.value !== after.value) { 12642 const val0 = this._fromType(this.getValueAtTime(before.time)); 12643 const val1 = this._fromType(this.getValueAtTime(after.time)); 12644 const delta = (val1 - val0) / (after.time - before.time); 12645 const k = Math.sqrt(Math.pow(val0, 2) - 2 * delta * (before.ticks - tick)); 12646 const sol1 = (-val0 + k) / delta; 12647 const sol2 = (-val0 - k) / delta; 12648 return (sol1 > 0 ? sol1 : sol2) + before.time; 12649 } else if (before) { 12650 if (before.value === 0) { 12651 return Infinity; 12652 } else { 12653 return before.time + (tick - before.ticks) / before.value; 12654 } 12655 } else { 12656 return tick / this._initialValue; 12657 } 12658 } 12659 /** 12660 * Convert some number of ticks their the duration in seconds accounting 12661 * for any automation curves starting at the given time. 12662 * @param ticks The number of ticks to convert to seconds. 12663 * @param when When along the automation timeline to convert the ticks. 12664 * @return The duration in seconds of the ticks. 12665 */ 12666 ticksToTime(ticks, when) { 12667 return this.getDurationOfTicks(ticks, when); 12668 } 12669 /** 12670 * The inverse of {@link ticksToTime}. Convert a duration in 12671 * seconds to the corresponding number of ticks accounting for any 12672 * automation curves starting at the given time. 12673 * @param duration The time interval to convert to ticks. 12674 * @param when When along the automation timeline to convert the ticks. 12675 * @return The duration in ticks. 12676 */ 12677 timeToTicks(duration, when) { 12678 const computedTime = this.toSeconds(when); 12679 const computedDuration = this.toSeconds(duration); 12680 const startTicks = this.getTicksAtTime(computedTime); 12681 const endTicks = this.getTicksAtTime(computedTime + computedDuration); 12682 return endTicks - startTicks; 12683 } 12684 /** 12685 * Convert from the type when the unit value is BPM 12686 */ 12687 _fromType(val) { 12688 if (this.units === "bpm" && this.multiplier) { 12689 return 1 / (60 / val / this.multiplier); 12690 } else { 12691 return super._fromType(val); 12692 } 12693 } 12694 /** 12695 * Special case of type conversion where the units === "bpm" 12696 */ 12697 _toType(val) { 12698 if (this.units === "bpm" && this.multiplier) { 12699 return val / this.multiplier * 60; 12700 } else { 12701 return super._toType(val); 12702 } 12703 } 12704 /** 12705 * A multiplier on the bpm value. Useful for setting a PPQ relative to the base frequency value. 12706 */ 12707 get multiplier() { 12708 return this._multiplier; 12709 } 12710 set multiplier(m) { 12711 const currentVal = this.value; 12712 this._multiplier = m; 12713 this.cancelScheduledValues(0); 12714 this.setValueAtTime(currentVal, 0); 12715 } 12716}; 12717
vendor: 1,394 bytes, lines 12718-12770
12718// node_modules/tone/build/esm/core/clock/TickSignal.js 12719var TickSignal = class _TickSignal extends Signal { 12720 constructor() { 12721 const options = optionsFromArguments(_TickSignal.getDefaults(), arguments, ["value"]); 12722 super(options); 12723 this.name = "TickSignal"; 12724 this.input = this._param = new TickParam({ 12725 context: this.context, 12726 convert: options.convert, 12727 multiplier: options.multiplier, 12728 param: this._constantSource.offset, 12729 units: options.units, 12730 value: options.value 12731 }); 12732 } 12733 static getDefaults() { 12734 return Object.assign(Signal.getDefaults(), { 12735 multiplier: 1, 12736 units: "hertz", 12737 value: 1 12738 }); 12739 } 12740 ticksToTime(ticks, when) { 12741 return this._param.ticksToTime(ticks, when); 12742 } 12743 timeToTicks(duration, when) { 12744 return this._param.timeToTicks(duration, when); 12745 } 12746 getTimeOfTick(tick) { 12747 return this._param.getTimeOfTick(tick); 12748 } 12749 getDurationOfTicks(ticks, time) { 12750 return this._param.getDurationOfTicks(ticks, time); 12751 } 12752 getTicksAtTime(time) { 12753 return this._param.getTicksAtTime(time); 12754 } 12755 /** 12756 * A multiplier on the bpm value. Useful for setting a PPQ relative to the base frequency value. 12757 */ 12758 get multiplier() { 12759 return this._param.multiplier; 12760 } 12761 set multiplier(m) { 12762 this._param.multiplier = m; 12763 } 12764 dispose() { 12765 super.dispose(); 12766 this._param.dispose(); 12767 return this; 12768 } 12769}; 12770
vendor: 9,792 bytes, lines 12771-13060
12771// node_modules/tone/build/esm/core/clock/TickSource.js 12772var TickSource = class _TickSource extends ToneWithContext { 12773 constructor() { 12774 const options = optionsFromArguments(_TickSource.getDefaults(), arguments, ["frequency"]); 12775 super(options); 12776 this.name = "TickSource"; 12777 this._state = new StateTimeline(); 12778 this._tickOffset = new Timeline(); 12779 this._ticksAtTime = new Timeline(); 12780 this._secondsAtTime = new Timeline(); 12781 this.frequency = new TickSignal({ 12782 context: this.context, 12783 units: options.units, 12784 value: options.frequency 12785 }); 12786 readOnly(this, "frequency"); 12787 this._state.setStateAtTime("stopped", 0); 12788 this.setTicksAtTime(0, 0); 12789 } 12790 static getDefaults() { 12791 return Object.assign({ 12792 frequency: 1, 12793 units: "hertz" 12794 }, ToneWithContext.getDefaults()); 12795 } 12796 /** 12797 * Returns the playback state of the source, either "started", "stopped" or "paused". 12798 */ 12799 get state() { 12800 return this.getStateAtTime(this.now()); 12801 } 12802 /** 12803 * Start the clock at the given time. Optionally pass in an offset 12804 * of where to start the tick counter from. 12805 * @param time The time the clock should start 12806 * @param offset The number of ticks to start the source at 12807 */ 12808 start(time, offset) { 12809 const computedTime = this.toSeconds(time); 12810 if (this._state.getValueAtTime(computedTime) !== "started") { 12811 this._state.setStateAtTime("started", computedTime); 12812 if (isDefined(offset)) { 12813 this.setTicksAtTime(offset, computedTime); 12814 } 12815 this._ticksAtTime.cancel(computedTime); 12816 this._secondsAtTime.cancel(computedTime); 12817 } 12818 return this; 12819 } 12820 /** 12821 * Stop the clock. Stopping the clock resets the tick counter to 0. 12822 * @param time The time when the clock should stop. 12823 */ 12824 stop(time) { 12825 const computedTime = this.toSeconds(time); 12826 if (this._state.getValueAtTime(computedTime) === "stopped") { 12827 const event = this._state.get(computedTime); 12828 if (event && event.time > 0) { 12829 this._tickOffset.cancel(event.time); 12830 this._state.cancel(event.time); 12831 } 12832 } 12833 this._state.cancel(computedTime); 12834 this._state.setStateAtTime("stopped", computedTime); 12835 this.setTicksAtTime(0, computedTime); 12836 this._ticksAtTime.cancel(computedTime); 12837 this._secondsAtTime.cancel(computedTime); 12838 return this; 12839 } 12840 /** 12841 * Pause the clock. Pausing does not reset the tick counter. 12842 * @param time The time when the clock should stop. 12843 */ 12844 pause(time) { 12845 const computedTime = this.toSeconds(time); 12846 if (this._state.getValueAtTime(computedTime) === "started") { 12847 this._state.setStateAtTime("paused", computedTime); 12848 this._ticksAtTime.cancel(computedTime); 12849 this._secondsAtTime.cancel(computedTime); 12850 } 12851 return this; 12852 } 12853 /** 12854 * Cancel start/stop/pause and setTickAtTime events scheduled after the given time. 12855 * @param time When to clear the events after 12856 */ 12857 cancel(time) { 12858 time = this.toSeconds(time); 12859 this._state.cancel(time); 12860 this._tickOffset.cancel(time); 12861 this._ticksAtTime.cancel(time); 12862 this._secondsAtTime.cancel(time); 12863 return this; 12864 } 12865 /** 12866 * Get the elapsed ticks at the given time 12867 * @param time When to get the tick value 12868 * @return The number of ticks 12869 */ 12870 getTicksAtTime(time) { 12871 const computedTime = this.toSeconds(time); 12872 const stopEvent = this._state.getLastState("stopped", computedTime); 12873 const memoizedEvent = this._ticksAtTime.get(computedTime); 12874 const tmpEvent = { 12875 state: "paused", 12876 time: computedTime 12877 }; 12878 this._state.add(tmpEvent); 12879 let lastState = memoizedEvent ? memoizedEvent : stopEvent; 12880 let elapsedTicks = memoizedEvent ? memoizedEvent.ticks : 0; 12881 let eventToMemoize = null; 12882 this._state.forEachBetween(lastState.time, computedTime + this.sampleTime, (e) => { 12883 let periodStartTime = lastState.time; 12884 const offsetEvent = this._tickOffset.get(e.time); 12885 if (offsetEvent && offsetEvent.time >= lastState.time) { 12886 elapsedTicks = offsetEvent.ticks; 12887 periodStartTime = offsetEvent.time; 12888 } 12889 if (lastState.state === "started" && e.state !== "started") { 12890 elapsedTicks += this.frequency.getTicksAtTime(e.time) - this.frequency.getTicksAtTime(periodStartTime); 12891 if (e.time !== tmpEvent.time) { 12892 eventToMemoize = { 12893 state: e.state, 12894 time: e.time, 12895 ticks: elapsedTicks 12896 }; 12897 } 12898 } 12899 lastState = e; 12900 }); 12901 this._state.remove(tmpEvent); 12902 if (eventToMemoize) { 12903 this._ticksAtTime.add(eventToMemoize); 12904 } 12905 return elapsedTicks; 12906 } 12907 /** 12908 * The number of times the callback was invoked. Starts counting at 0 12909 * and increments after the callback was invoked. Returns -1 when stopped. 12910 */ 12911 get ticks() { 12912 return this.getTicksAtTime(this.now()); 12913 } 12914 set ticks(t) { 12915 this.setTicksAtTime(t, this.now()); 12916 } 12917 /** 12918 * The time since ticks=0 that the TickSource has been running. Accounts 12919 * for tempo curves 12920 */ 12921 get seconds() { 12922 return this.getSecondsAtTime(this.now()); 12923 } 12924 set seconds(s) { 12925 const now = this.now(); 12926 const ticks = this.frequency.timeToTicks(s, now); 12927 this.setTicksAtTime(ticks, now); 12928 } 12929 /** 12930 * Return the elapsed seconds at the given time. 12931 * @param time When to get the elapsed seconds 12932 * @return The number of elapsed seconds 12933 */ 12934 getSecondsAtTime(time) { 12935 time = this.toSeconds(time); 12936 const stopEvent = this._state.getLastState("stopped", time); 12937 const tmpEvent = { state: "paused", time }; 12938 this._state.add(tmpEvent); 12939 const memoizedEvent = this._secondsAtTime.get(time); 12940 let lastState = memoizedEvent ? memoizedEvent : stopEvent; 12941 let elapsedSeconds = memoizedEvent ? memoizedEvent.seconds : 0; 12942 let eventToMemoize = null; 12943 this._state.forEachBetween(lastState.time, time + this.sampleTime, (e) => { 12944 let periodStartTime = lastState.time; 12945 const offsetEvent = this._tickOffset.get(e.time); 12946 if (offsetEvent && offsetEvent.time >= lastState.time) { 12947 elapsedSeconds = offsetEvent.seconds; 12948 periodStartTime = offsetEvent.time; 12949 } 12950 if (lastState.state === "started" && e.state !== "started") { 12951 elapsedSeconds += e.time - periodStartTime; 12952 if (e.time !== tmpEvent.time) { 12953 eventToMemoize = { 12954 state: e.state, 12955 time: e.time, 12956 seconds: elapsedSeconds 12957 }; 12958 } 12959 } 12960 lastState = e; 12961 }); 12962 this._state.remove(tmpEvent); 12963 if (eventToMemoize) { 12964 this._secondsAtTime.add(eventToMemoize); 12965 } 12966 return elapsedSeconds; 12967 } 12968 /** 12969 * Set the clock's ticks at the given time. 12970 * @param ticks The tick value to set 12971 * @param time When to set the tick value 12972 */ 12973 setTicksAtTime(ticks, time) { 12974 time = this.toSeconds(time); 12975 this._tickOffset.cancel(time); 12976 this._tickOffset.add({ 12977 seconds: this.frequency.getDurationOfTicks(ticks, time), 12978 ticks, 12979 time 12980 }); 12981 this._ticksAtTime.cancel(time); 12982 this._secondsAtTime.cancel(time); 12983 return this; 12984 } 12985 /** 12986 * Returns the scheduled state at the given time. 12987 * @param time The time to query. 12988 */ 12989 getStateAtTime(time) { 12990 time = this.toSeconds(time); 12991 return this._state.getValueAtTime(time); 12992 } 12993 /** 12994 * Get the time of the given tick. The second argument 12995 * is when to test before. Since ticks can be set (with setTicksAtTime) 12996 * there may be multiple times for a given tick value. 12997 * @param tick The tick number. 12998 * @param before When to measure the tick value from. 12999 * @return The time of the tick 13000 */ 13001 getTimeOfTick(tick, before = this.now()) { 13002 const offset = this._tickOffset.get(before); 13003 const event = this._state.get(before); 13004 const startTime = Math.max(offset.time, event.time); 13005 const absoluteTicks = this.frequency.getTicksAtTime(startTime) + tick - offset.ticks; 13006 return this.frequency.getTimeOfTick(absoluteTicks); 13007 } 13008 /** 13009 * Invoke the callback event at all scheduled ticks between the 13010 * start time and the end time 13011 * @param startTime The beginning of the search range 13012 * @param endTime The end of the search range 13013 * @param callback The callback to invoke with each tick 13014 */ 13015 forEachTickBetween(startTime, endTime, callback) { 13016 let lastStateEvent = this._state.get(startTime); 13017 this._state.forEachBetween(startTime, endTime, (event) => { 13018 if (lastStateEvent && lastStateEvent.state === "started" && event.state !== "started") { 13019 this.forEachTickBetween(Math.max(lastStateEvent.time, startTime), event.time - this.sampleTime, callback); 13020 } 13021 lastStateEvent = event; 13022 }); 13023 let error = null; 13024 if (lastStateEvent && lastStateEvent.state === "started") { 13025 const maxStartTime = Math.max(lastStateEvent.time, startTime); 13026 const startTicks = this.frequency.getTicksAtTime(maxStartTime); 13027 const ticksAtStart = this.frequency.getTicksAtTime(lastStateEvent.time); 13028 const diff = startTicks - ticksAtStart; 13029 let offset = Math.ceil(diff) - diff; 13030 offset = EQ(offset, 1) ? 0 : offset; 13031 let nextTickTime = this.frequency.getTimeOfTick(startTicks + offset); 13032 while (nextTickTime < endTime) { 13033 try { 13034 callback(nextTickTime, Math.round(this.getTicksAtTime(nextTickTime))); 13035 } catch (e) { 13036 error = e; 13037 break; 13038 } 13039 nextTickTime += this.frequency.getDurationOfTicks(1, nextTickTime); 13040 } 13041 } 13042 if (error) { 13043 throw error; 13044 } 13045 return this; 13046 } 13047 /** 13048 * Clean up 13049 */ 13050 dispose() { 13051 super.dispose(); 13052 this._state.dispose(); 13053 this._tickOffset.dispose(); 13054 this._ticksAtTime.dispose(); 13055 this._secondsAtTime.dispose(); 13056 this.frequency.dispose(); 13057 return this; 13058 } 13059}; 13060
vendor: 6,406 bytes, lines 13061-13274
13061// node_modules/tone/build/esm/core/clock/Clock.js 13062var Clock = class _Clock extends ToneWithContext { 13063 constructor() { 13064 const options = optionsFromArguments(_Clock.getDefaults(), arguments, [ 13065 "callback", 13066 "frequency" 13067 ]); 13068 super(options); 13069 this.name = "Clock"; 13070 this.callback = noOp; 13071 this._lastUpdate = 0; 13072 this._state = new StateTimeline("stopped"); 13073 this._boundLoop = this._loop.bind(this); 13074 this.callback = options.callback; 13075 this._tickSource = new TickSource({ 13076 context: this.context, 13077 frequency: options.frequency, 13078 units: options.units 13079 }); 13080 this._lastUpdate = 0; 13081 this.frequency = this._tickSource.frequency; 13082 readOnly(this, "frequency"); 13083 this._state.setStateAtTime("stopped", 0); 13084 this.context.on("tick", this._boundLoop); 13085 } 13086 static getDefaults() { 13087 return Object.assign(ToneWithContext.getDefaults(), { 13088 callback: noOp, 13089 frequency: 1, 13090 units: "hertz" 13091 }); 13092 } 13093 /** 13094 * Returns the playback state of the source, either "started", "stopped" or "paused". 13095 */ 13096 get state() { 13097 return this._state.getValueAtTime(this.now()); 13098 } 13099 /** 13100 * Start the clock at the given time. Optionally pass in an offset 13101 * of where to start the tick counter from. 13102 * @param time The time the clock should start 13103 * @param offset Where the tick counter starts counting from. 13104 */ 13105 start(time, offset) { 13106 assertContextRunning(this.context); 13107 const computedTime = this.toSeconds(time); 13108 this.log("start", computedTime); 13109 if (this._state.getValueAtTime(computedTime) !== "started") { 13110 this._state.setStateAtTime("started", computedTime); 13111 this._tickSource.start(computedTime, offset); 13112 if (computedTime < this._lastUpdate) { 13113 this.emit("start", computedTime, offset); 13114 } 13115 } 13116 return this; 13117 } 13118 /** 13119 * Stop the clock. Stopping the clock resets the tick counter to 0. 13120 * @param time The time when the clock should stop. 13121 * @example 13122 * const clock = new Tone.Clock(time => { 13123 * console.log(time); 13124 * }, 1); 13125 * clock.start(); 13126 * // stop the clock after 10 seconds 13127 * clock.stop("+10"); 13128 */ 13129 stop(time) { 13130 const computedTime = this.toSeconds(time); 13131 this.log("stop", computedTime); 13132 this._state.cancel(computedTime); 13133 this._state.setStateAtTime("stopped", computedTime); 13134 this._tickSource.stop(computedTime); 13135 if (computedTime < this._lastUpdate) { 13136 this.emit("stop", computedTime); 13137 } 13138 return this; 13139 } 13140 /** 13141 * Pause the clock. Pausing does not reset the tick counter. 13142 * @param time The time when the clock should stop. 13143 */ 13144 pause(time) { 13145 const computedTime = this.toSeconds(time); 13146 if (this._state.getValueAtTime(computedTime) === "started") { 13147 this._state.setStateAtTime("paused", computedTime); 13148 this._tickSource.pause(computedTime); 13149 if (computedTime < this._lastUpdate) { 13150 this.emit("pause", computedTime); 13151 } 13152 } 13153 return this; 13154 } 13155 /** 13156 * The number of times the callback was invoked. Starts counting at 0 13157 * and increments after the callback was invoked. 13158 */ 13159 get ticks() { 13160 return Math.ceil(this.getTicksAtTime(this.now())); 13161 } 13162 set ticks(t) { 13163 this._tickSource.ticks = t; 13164 } 13165 /** 13166 * The time since ticks=0 that the Clock has been running. Accounts for tempo curves 13167 */ 13168 get seconds() { 13169 return this._tickSource.seconds; 13170 } 13171 set seconds(s) { 13172 this._tickSource.seconds = s; 13173 } 13174 /** 13175 * Return the elapsed seconds at the given time. 13176 * @param time When to get the elapsed seconds 13177 * @return The number of elapsed seconds 13178 */ 13179 getSecondsAtTime(time) { 13180 return this._tickSource.getSecondsAtTime(time); 13181 } 13182 /** 13183 * Set the clock's ticks at the given time. 13184 * @param ticks The tick value to set 13185 * @param time When to set the tick value 13186 */ 13187 setTicksAtTime(ticks, time) { 13188 this._tickSource.setTicksAtTime(ticks, time); 13189 return this; 13190 } 13191 /** 13192 * Get the time of the given tick. The second argument 13193 * is when to test before. Since ticks can be set (with setTicksAtTime) 13194 * there may be multiple times for a given tick value. 13195 * @param tick The tick number. 13196 * @param before When to measure the tick value from. 13197 * @return The time of the tick 13198 */ 13199 getTimeOfTick(tick, before = this.now()) { 13200 return this._tickSource.getTimeOfTick(tick, before); 13201 } 13202 /** 13203 * Get the clock's ticks at the given time. 13204 * @param time When to get the tick value 13205 * @return The tick value at the given time. 13206 */ 13207 getTicksAtTime(time) { 13208 return this._tickSource.getTicksAtTime(time); 13209 } 13210 /** 13211 * Get the time of the next tick 13212 * @param offset The tick number. 13213 */ 13214 nextTickTime(offset, when) { 13215 const computedTime = this.toSeconds(when); 13216 const currentTick = this.getTicksAtTime(computedTime); 13217 return this._tickSource.getTimeOfTick(currentTick + offset, computedTime); 13218 } 13219 /** 13220 * The scheduling loop. 13221 */ 13222 _loop() { 13223 const startTime = this._lastUpdate; 13224 const endTime = this.now(); 13225 this._lastUpdate = endTime; 13226 this.log("loop", startTime, endTime); 13227 if (startTime !== endTime) { 13228 this._state.forEachBetween(startTime, endTime, (e) => { 13229 switch (e.state) { 13230 case "started": 13231 const offset = this._tickSource.getTicksAtTime(e.time); 13232 this.emit("start", e.time, offset); 13233 break; 13234 case "stopped": 13235 if (e.time !== 0) { 13236 this.emit("stop", e.time); 13237 } 13238 break; 13239 case "paused": 13240 this.emit("pause", e.time); 13241 break; 13242 } 13243 }); 13244 this._tickSource.forEachTickBetween(startTime, endTime, (time, ticks) => { 13245 this.callback(time, ticks); 13246 }); 13247 } 13248 } 13249 /** 13250 * Returns the scheduled state at the given time. 13251 * @param time The time to query. 13252 * @return The name of the state input in setStateAtTime. 13253 * @example 13254 * const clock = new Tone.Clock(); 13255 * clock.start("+0.1"); 13256 * clock.getStateAtTime("+0.1"); // returns "started" 13257 */ 13258 getStateAtTime(time) { 13259 const computedTime = this.toSeconds(time); 13260 return this._state.getValueAtTime(computedTime); 13261 } 13262 /** 13263 * Clean up 13264 */ 13265 dispose() { 13266 super.dispose(); 13267 this.context.off("tick", this._boundLoop); 13268 this._tickSource.dispose(); 13269 this._state.dispose(); 13270 return this; 13271 } 13272}; 13273Emitter.mixin(Clock); 13274
vendor: 1,226 bytes, lines 13275-13320
13275// node_modules/tone/build/esm/core/context/Delay.js 13276var Delay = class _Delay extends ToneAudioNode { 13277 constructor() { 13278 const options = optionsFromArguments(_Delay.getDefaults(), arguments, [ 13279 "delayTime", 13280 "maxDelay" 13281 ]); 13282 super(options); 13283 this.name = "Delay"; 13284 const maxDelayInSeconds = this.toSeconds(options.maxDelay); 13285 this._maxDelay = Math.max(maxDelayInSeconds, this.toSeconds(options.delayTime)); 13286 this._delayNode = this.input = this.output = this.context.createDelay(maxDelayInSeconds); 13287 this.delayTime = new Param({ 13288 context: this.context, 13289 param: this._delayNode.delayTime, 13290 units: "time", 13291 value: options.delayTime, 13292 minValue: 0, 13293 maxValue: this.maxDelay 13294 }); 13295 readOnly(this, "delayTime"); 13296 } 13297 static getDefaults() { 13298 return Object.assign(ToneAudioNode.getDefaults(), { 13299 delayTime: 0, 13300 maxDelay: 1 13301 }); 13302 } 13303 /** 13304 * The maximum delay time. This cannot be changed after 13305 * the value is passed into the constructor. 13306 */ 13307 get maxDelay() { 13308 return this._maxDelay; 13309 } 13310 /** 13311 * Clean up. 13312 */ 13313 dispose() { 13314 super.dispose(); 13315 this._delayNode.disconnect(); 13316 this.delayTime.dispose(); 13317 return this; 13318 } 13319}; 13320
vendor: 1,314 bytes, lines 13321-13374
13321// node_modules/tone/build/esm/component/channel/Volume.js 13322var Volume = class _Volume extends ToneAudioNode { 13323 constructor() { 13324 const options = optionsFromArguments(_Volume.getDefaults(), arguments, [ 13325 "volume" 13326 ]); 13327 super(options); 13328 this.name = "Volume"; 13329 this.input = this.output = new Gain({ 13330 context: this.context, 13331 gain: options.volume, 13332 units: "decibels" 13333 }); 13334 this.volume = this.output.gain; 13335 readOnly(this, "volume"); 13336 this._unmutedVolume = options.volume; 13337 this.mute = options.mute; 13338 } 13339 static getDefaults() { 13340 return Object.assign(ToneAudioNode.getDefaults(), { 13341 mute: false, 13342 volume: 0 13343 }); 13344 } 13345 /** 13346 * Mute the output. 13347 * @example 13348 * const vol = new Tone.Volume(-12).toDestination(); 13349 * const osc = new Tone.Oscillator().connect(vol).start(); 13350 * // mute the output 13351 * vol.mute = true; 13352 */ 13353 get mute() { 13354 return this.volume.value === -Infinity; 13355 } 13356 set mute(mute) { 13357 if (!this.mute && mute) { 13358 this._unmutedVolume = this.volume.value; 13359 this.volume.value = -Infinity; 13360 } else if (this.mute && !mute) { 13361 this.volume.value = this._unmutedVolume; 13362 } 13363 } 13364 /** 13365 * clean up 13366 */ 13367 dispose() { 13368 super.dispose(); 13369 this.input.dispose(); 13370 this.volume.dispose(); 13371 return this; 13372 } 13373}; 13374
vendor: 2,251 bytes, lines 13375-13453
13375// node_modules/tone/build/esm/core/context/Destination.js 13376var DestinationClass = class _DestinationClass extends ToneAudioNode { 13377 constructor() { 13378 const options = optionsFromArguments(_DestinationClass.getDefaults(), arguments); 13379 super(options); 13380 this.name = "Destination"; 13381 this.input = new Volume({ context: this.context }); 13382 this.output = new Gain({ context: this.context }); 13383 this.volume = this.input.volume; 13384 connectSeries(this.input, this.output, this.context.rawContext.destination); 13385 this.mute = options.mute; 13386 this._internalChannels = [ 13387 this.input, 13388 this.context.rawContext.destination, 13389 this.output 13390 ]; 13391 } 13392 static getDefaults() { 13393 return Object.assign(ToneAudioNode.getDefaults(), { 13394 mute: false, 13395 volume: 0 13396 }); 13397 } 13398 /** 13399 * Mute the output. 13400 * @example 13401 * const oscillator = new Tone.Oscillator().start().toDestination(); 13402 * setTimeout(() => { 13403 * // mute the output 13404 * Tone.Destination.mute = true; 13405 * }, 1000); 13406 */ 13407 get mute() { 13408 return this.input.mute; 13409 } 13410 set mute(mute) { 13411 this.input.mute = mute; 13412 } 13413 /** 13414 * Add a master effects chain. NOTE: this will disconnect any nodes which were previously 13415 * chained in the master effects chain. 13416 * @param args All arguments will be connected in a row and the Master will be routed through it. 13417 * @example 13418 * // route all audio through a filter and compressor 13419 * const lowpass = new Tone.Filter(800, "lowpass"); 13420 * const compressor = new Tone.Compressor(-18); 13421 * Tone.Destination.chain(lowpass, compressor); 13422 */ 13423 chain(...args) { 13424 this.input.disconnect(); 13425 args.unshift(this.input); 13426 args.push(this.output); 13427 connectSeries(...args); 13428 return this; 13429 } 13430 /** 13431 * The maximum number of channels the system can output 13432 * @example 13433 * console.log(Tone.Destination.maxChannelCount); 13434 */ 13435 get maxChannelCount() { 13436 return this.context.rawContext.destination.maxChannelCount; 13437 } 13438 /** 13439 * Clean up 13440 */ 13441 dispose() { 13442 super.dispose(); 13443 this.volume.dispose(); 13444 return this; 13445 } 13446}; 13447onContextInit((context2) => { 13448 context2.destination = new DestinationClass({ context: context2 }); 13449}); 13450onContextClose((context2) => { 13451 context2.destination.dispose(); 13452}); 13453
vendor: 1,998 bytes, lines 13454-13529
13454// node_modules/tone/build/esm/core/context/Listener.js 13455var ListenerClass = class extends ToneAudioNode { 13456 constructor() { 13457 super(...arguments); 13458 this.name = "Listener"; 13459 this.positionX = new Param({ 13460 context: this.context, 13461 param: this.context.rawContext.listener.positionX 13462 }); 13463 this.positionY = new Param({ 13464 context: this.context, 13465 param: this.context.rawContext.listener.positionY 13466 }); 13467 this.positionZ = new Param({ 13468 context: this.context, 13469 param: this.context.rawContext.listener.positionZ 13470 }); 13471 this.forwardX = new Param({ 13472 context: this.context, 13473 param: this.context.rawContext.listener.forwardX 13474 }); 13475 this.forwardY = new Param({ 13476 context: this.context, 13477 param: this.context.rawContext.listener.forwardY 13478 }); 13479 this.forwardZ = new Param({ 13480 context: this.context, 13481 param: this.context.rawContext.listener.forwardZ 13482 }); 13483 this.upX = new Param({ 13484 context: this.context, 13485 param: this.context.rawContext.listener.upX 13486 }); 13487 this.upY = new Param({ 13488 context: this.context, 13489 param: this.context.rawContext.listener.upY 13490 }); 13491 this.upZ = new Param({ 13492 context: this.context, 13493 param: this.context.rawContext.listener.upZ 13494 }); 13495 } 13496 static getDefaults() { 13497 return Object.assign(ToneAudioNode.getDefaults(), { 13498 positionX: 0, 13499 positionY: 0, 13500 positionZ: 0, 13501 forwardX: 0, 13502 forwardY: 0, 13503 forwardZ: -1, 13504 upX: 0, 13505 upY: 1, 13506 upZ: 0 13507 }); 13508 } 13509 dispose() { 13510 super.dispose(); 13511 this.positionX.dispose(); 13512 this.positionY.dispose(); 13513 this.positionZ.dispose(); 13514 this.forwardX.dispose(); 13515 this.forwardY.dispose(); 13516 this.forwardZ.dispose(); 13517 this.upX.dispose(); 13518 this.upY.dispose(); 13519 this.upZ.dispose(); 13520 return this; 13521 } 13522}; 13523onContextInit((context2) => { 13524 context2.listener = new ListenerClass({ context: context2 }); 13525}); 13526onContextClose((context2) => { 13527 context2.listener.dispose(); 13528}); 13529
vendor: 565 bytes, lines 13530-13543
13530// node_modules/tone/build/esm/core/context/Offline.js 13531function Offline(callback_1, duration_1) { 13532 return __awaiter(this, arguments, void 0, function* (callback, duration, channels = 2, sampleRate = getContext().sampleRate) { 13533 const originalContext = getContext(); 13534 const context2 = new OfflineContext(channels, duration, sampleRate); 13535 setContext(context2); 13536 yield callback(context2); 13537 const bufferPromise = context2.render(); 13538 setContext(originalContext); 13539 const buffer = yield bufferPromise; 13540 return new ToneAudioBuffer(buffer); 13541 }); 13542} 13543
vendor: 2,505 bytes, lines 13544-13623
13544// node_modules/tone/build/esm/core/context/ToneAudioBuffers.js 13545var ToneAudioBuffers = class _ToneAudioBuffers extends Tone { 13546 constructor() { 13547 super(); 13548 this.name = "ToneAudioBuffers"; 13549 this._buffers = /* @__PURE__ */ new Map(); 13550 this._loadingCount = 0; 13551 const options = optionsFromArguments(_ToneAudioBuffers.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls"); 13552 this.baseUrl = options.baseUrl; 13553 Object.keys(options.urls).forEach((name) => { 13554 this._loadingCount++; 13555 const url = options.urls[name]; 13556 this.add(name, url, this._bufferLoaded.bind(this, options.onload), options.onerror); 13557 }); 13558 } 13559 static getDefaults() { 13560 return { 13561 baseUrl: "", 13562 onerror: noOp, 13563 onload: noOp, 13564 urls: {} 13565 }; 13566 } 13567 /** 13568 * True if the buffers object has a buffer by that name. 13569 * @param name The key or index of the buffer. 13570 */ 13571 has(name) { 13572 return this._buffers.has(name.toString()); 13573 } 13574 /** 13575 * Get a buffer by name. If an array was loaded, 13576 * then use the array index. 13577 * @param name The key or index of the buffer. 13578 */ 13579 get(name) { 13580 assert(this.has(name), `ToneAudioBuffers has no buffer named: ${name}`); 13581 return this._buffers.get(name.toString()); 13582 } 13583 /** 13584 * A buffer was loaded. decrement the counter. 13585 */ 13586 _bufferLoaded(callback) { 13587 this._loadingCount--; 13588 if (this._loadingCount === 0 && callback) { 13589 callback(); 13590 } 13591 } 13592 /** 13593 * If the buffers are loaded or not 13594 */ 13595 get loaded() { 13596 return Array.from(this._buffers).every(([_, buffer]) => buffer.loaded); 13597 } 13598 /** 13599 * Add a buffer by name and url to the Buffers 13600 * @param name A unique name to give the buffer 13601 * @param url Either the url of the bufer, or a buffer which will be added with the given name. 13602 * @param callback The callback to invoke when the url is loaded. 13603 * @param onerror Invoked if the buffer can't be loaded 13604 */ 13605 add(name, url, callback = noOp, onerror = noOp) { 13606 if (isString(url)) { 13607 if (this.baseUrl && url.trim().substring(0, 11).toLowerCase() === "data:audio/") { 13608 this.baseUrl = ""; 13609 } 13610 this._buffers.set(name.toString(), new ToneAudioBuffer(this.baseUrl + url, callback, onerror)); 13611 } else { 13612 this._buffers.set(name.toString(), new ToneAudioBuffer(url, callback, onerror)); 13613 } 13614 return this; 13615 } 13616 dispose() { 13617 super.dispose(); 13618 this._buffers.forEach((buffer) => buffer.dispose()); 13619 this._buffers.clear(); 13620 return this; 13621 } 13622}; 13623
vendor: 1,423 bytes, lines 13624-13681
13624// node_modules/tone/build/esm/core/type/Midi.js 13625var MidiClass = class _MidiClass extends FrequencyClass { 13626 constructor() { 13627 super(...arguments); 13628 this.name = "MidiClass"; 13629 this.defaultUnits = "midi"; 13630 } 13631 /** 13632 * Returns the value of a frequency in the current units 13633 */ 13634 _frequencyToUnits(freq) { 13635 return ftom(super._frequencyToUnits(freq)); 13636 } 13637 /** 13638 * Returns the value of a tick in the current time units 13639 */ 13640 _ticksToUnits(ticks) { 13641 return ftom(super._ticksToUnits(ticks)); 13642 } 13643 /** 13644 * Return the value of the beats in the current units 13645 */ 13646 _beatsToUnits(beats) { 13647 return ftom(super._beatsToUnits(beats)); 13648 } 13649 /** 13650 * Returns the value of a second in the current units 13651 */ 13652 _secondsToUnits(seconds) { 13653 return ftom(super._secondsToUnits(seconds)); 13654 } 13655 /** 13656 * Return the value of the frequency as a MIDI note 13657 * @example 13658 * Tone.Midi(60).toMidi(); // 60 13659 */ 13660 toMidi() { 13661 return this.valueOf(); 13662 } 13663 /** 13664 * Return the value of the frequency as a MIDI note 13665 * @example 13666 * Tone.Midi(60).toFrequency(); // 261.6255653005986 13667 */ 13668 toFrequency() { 13669 return mtof(this.toMidi()); 13670 } 13671 /** 13672 * Transposes the frequency by the given number of semitones. 13673 * @return A new transposed MidiClass 13674 * @example 13675 * Tone.Midi("A4").transpose(3); // "C5" 13676 */ 13677 transpose(interval) { 13678 return new _MidiClass(this.context, this.toMidi() + interval); 13679 } 13680}; 13681
vendor: 963 bytes, lines 13682-13726
13682// node_modules/tone/build/esm/core/type/Ticks.js 13683var TicksClass = class extends TransportTimeClass { 13684 constructor() { 13685 super(...arguments); 13686 this.name = "Ticks"; 13687 this.defaultUnits = "i"; 13688 } 13689 /** 13690 * Get the current time in the given units 13691 */ 13692 _now() { 13693 return this.context.transport.ticks; 13694 } 13695 /** 13696 * Return the value of the beats in the current units 13697 */ 13698 _beatsToUnits(beats) { 13699 return this._getPPQ() * beats; 13700 } 13701 /** 13702 * Returns the value of a second in the current units 13703 */ 13704 _secondsToUnits(seconds) { 13705 return Math.floor(seconds / (60 / this._getBpm()) * this._getPPQ()); 13706 } 13707 /** 13708 * Returns the value of a tick in the current time units 13709 */ 13710 _ticksToUnits(ticks) { 13711 return ticks; 13712 } 13713 /** 13714 * Return the time in ticks 13715 */ 13716 toTicks() { 13717 return this.valueOf(); 13718 } 13719 /** 13720 * Return the time in seconds 13721 */ 13722 toSeconds() { 13723 return this.valueOf() / this._getPPQ() * (60 / this._getBpm()); 13724 } 13725}; 13726
vendor: 1,944 bytes, lines 13727-13795
13727// node_modules/tone/build/esm/core/util/Draw.js 13728var DrawClass = class extends ToneWithContext { 13729 constructor() { 13730 super(...arguments); 13731 this.name = "Draw"; 13732 this.expiration = 0.25; 13733 this.anticipation = 8e-3; 13734 this._events = new Timeline(); 13735 this._boundDrawLoop = this._drawLoop.bind(this); 13736 this._animationFrame = -1; 13737 } 13738 /** 13739 * Schedule a function at the given time to be invoked 13740 * on the nearest animation frame. 13741 * @param callback Callback is invoked at the given time. 13742 * @param time The time relative to the AudioContext time to invoke the callback. 13743 * @example 13744 * Tone.Transport.scheduleRepeat(time => { 13745 * Tone.Draw.schedule(() => console.log(time), time); 13746 * }, 1); 13747 * Tone.Transport.start(); 13748 */ 13749 schedule(callback, time) { 13750 this._events.add({ 13751 callback, 13752 time: this.toSeconds(time) 13753 }); 13754 if (this._events.length === 1) { 13755 this._animationFrame = requestAnimationFrame(this._boundDrawLoop); 13756 } 13757 return this; 13758 } 13759 /** 13760 * Cancel events scheduled after the given time 13761 * @param after Time after which scheduled events will be removed from the scheduling timeline. 13762 */ 13763 cancel(after) { 13764 this._events.cancel(this.toSeconds(after)); 13765 return this; 13766 } 13767 /** 13768 * The draw loop 13769 */ 13770 _drawLoop() { 13771 const now = this.context.currentTime; 13772 this._events.forEachBefore(now + this.anticipation, (event) => { 13773 if (now - event.time <= this.expiration) { 13774 event.callback(); 13775 } 13776 this._events.remove(event); 13777 }); 13778 if (this._events.length > 0) { 13779 this._animationFrame = requestAnimationFrame(this._boundDrawLoop); 13780 } 13781 } 13782 dispose() { 13783 super.dispose(); 13784 this._events.dispose(); 13785 cancelAnimationFrame(this._animationFrame); 13786 return this; 13787 } 13788}; 13789onContextInit((context2) => { 13790 context2.draw = new DrawClass({ context: context2 }); 13791}); 13792onContextClose((context2) => { 13793 context2.draw.dispose(); 13794}); 13795
vendor: 11,600 bytes, lines 13796-14260
13796// node_modules/tone/build/esm/core/util/IntervalTimeline.js 13797var IntervalTimeline = class extends Tone { 13798 constructor() { 13799 super(...arguments); 13800 this.name = "IntervalTimeline"; 13801 this._root = null; 13802 this._length = 0; 13803 } 13804 /** 13805 * The event to add to the timeline. All events must 13806 * have a time and duration value 13807 * @param event The event to add to the timeline 13808 */ 13809 add(event) { 13810 assert(isDefined(event.time), "Events must have a time property"); 13811 assert(isDefined(event.duration), "Events must have a duration parameter"); 13812 event.time = event.time.valueOf(); 13813 let node = new IntervalNode(event.time, event.time + event.duration, event); 13814 if (this._root === null) { 13815 this._root = node; 13816 } else { 13817 this._root.insert(node); 13818 } 13819 this._length++; 13820 while (node !== null) { 13821 node.updateHeight(); 13822 node.updateMax(); 13823 this._rebalance(node); 13824 node = node.parent; 13825 } 13826 return this; 13827 } 13828 /** 13829 * Remove an event from the timeline. 13830 * @param event The event to remove from the timeline 13831 */ 13832 remove(event) { 13833 if (this._root !== null) { 13834 const results = []; 13835 this._root.search(event.time, results); 13836 for (const node of results) { 13837 if (node.event === event) { 13838 this._removeNode(node); 13839 this._length--; 13840 break; 13841 } 13842 } 13843 } 13844 return this; 13845 } 13846 /** 13847 * The number of items in the timeline. 13848 * @readOnly 13849 */ 13850 get length() { 13851 return this._length; 13852 } 13853 /** 13854 * Remove events whose time time is after the given time 13855 * @param after The time to query. 13856 */ 13857 cancel(after) { 13858 this.forEachFrom(after, (event) => this.remove(event)); 13859 return this; 13860 } 13861 /** 13862 * Set the root node as the given node 13863 */ 13864 _setRoot(node) { 13865 this._root = node; 13866 if (this._root !== null) { 13867 this._root.parent = null; 13868 } 13869 } 13870 /** 13871 * Replace the references to the node in the node's parent 13872 * with the replacement node. 13873 */ 13874 _replaceNodeInParent(node, replacement) { 13875 if (node.parent !== null) { 13876 if (node.isLeftChild()) { 13877 node.parent.left = replacement; 13878 } else { 13879 node.parent.right = replacement; 13880 } 13881 this._rebalance(node.parent); 13882 } else { 13883 this._setRoot(replacement); 13884 } 13885 } 13886 /** 13887 * Remove the node from the tree and replace it with 13888 * a successor which follows the schema. 13889 */ 13890 _removeNode(node) { 13891 if (node.left === null && node.right === null) { 13892 this._replaceNodeInParent(node, null); 13893 } else if (node.right === null) { 13894 this._replaceNodeInParent(node, node.left); 13895 } else if (node.left === null) { 13896 this._replaceNodeInParent(node, node.right); 13897 } else { 13898 const balance = node.getBalance(); 13899 let replacement; 13900 let temp = null; 13901 if (balance > 0) { 13902 if (node.left.right === null) { 13903 replacement = node.left; 13904 replacement.right = node.right; 13905 temp = replacement; 13906 } else { 13907 replacement = node.left.right; 13908 while (replacement.right !== null) { 13909 replacement = replacement.right; 13910 } 13911 if (replacement.parent) { 13912 replacement.parent.right = replacement.left; 13913 temp = replacement.parent; 13914 replacement.left = node.left; 13915 replacement.right = node.right; 13916 } 13917 } 13918 } else if (node.right.left === null) { 13919 replacement = node.right; 13920 replacement.left = node.left; 13921 temp = replacement; 13922 } else { 13923 replacement = node.right.left; 13924 while (replacement.left !== null) { 13925 replacement = replacement.left; 13926 } 13927 if (replacement.parent) { 13928 replacement.parent.left = replacement.right; 13929 temp = replacement.parent; 13930 replacement.left = node.left; 13931 replacement.right = node.right; 13932 } 13933 } 13934 if (node.parent !== null) { 13935 if (node.isLeftChild()) { 13936 node.parent.left = replacement; 13937 } else { 13938 node.parent.right = replacement; 13939 } 13940 } else { 13941 this._setRoot(replacement); 13942 } 13943 if (temp) { 13944 this._rebalance(temp); 13945 } 13946 } 13947 node.dispose(); 13948 } 13949 /** 13950 * Rotate the tree to the left 13951 */ 13952 _rotateLeft(node) { 13953 const parent = node.parent; 13954 const isLeftChild = node.isLeftChild(); 13955 const pivotNode = node.right; 13956 if (pivotNode) { 13957 node.right = pivotNode.left; 13958 pivotNode.left = node; 13959 } 13960 if (parent !== null) { 13961 if (isLeftChild) { 13962 parent.left = pivotNode; 13963 } else { 13964 parent.right = pivotNode; 13965 } 13966 } else { 13967 this._setRoot(pivotNode); 13968 } 13969 } 13970 /** 13971 * Rotate the tree to the right 13972 */ 13973 _rotateRight(node) { 13974 const parent = node.parent; 13975 const isLeftChild = node.isLeftChild(); 13976 const pivotNode = node.left; 13977 if (pivotNode) { 13978 node.left = pivotNode.right; 13979 pivotNode.right = node; 13980 } 13981 if (parent !== null) { 13982 if (isLeftChild) { 13983 parent.left = pivotNode; 13984 } else { 13985 parent.right = pivotNode; 13986 } 13987 } else { 13988 this._setRoot(pivotNode); 13989 } 13990 } 13991 /** 13992 * Balance the BST 13993 */ 13994 _rebalance(node) { 13995 const balance = node.getBalance(); 13996 if (balance > 1 && node.left) { 13997 if (node.left.getBalance() < 0) { 13998 this._rotateLeft(node.left); 13999 } else { 14000 this._rotateRight(node); 14001 } 14002 } else if (balance < -1 && node.right) { 14003 if (node.right.getBalance() > 0) { 14004 this._rotateRight(node.right); 14005 } else { 14006 this._rotateLeft(node); 14007 } 14008 } 14009 } 14010 /** 14011 * Get an event whose time and duration span the give time. Will 14012 * return the match whose "time" value is closest to the given time. 14013 * @return The event which spans the desired time 14014 */ 14015 get(time) { 14016 if (this._root !== null) { 14017 const results = []; 14018 this._root.search(time, results); 14019 if (results.length > 0) { 14020 let max = results[0]; 14021 for (let i = 1; i < results.length; i++) { 14022 if (results[i].low > max.low) { 14023 max = results[i]; 14024 } 14025 } 14026 return max.event; 14027 } 14028 } 14029 return null; 14030 } 14031 /** 14032 * Iterate over everything in the timeline. 14033 * @param callback The callback to invoke with every item 14034 */ 14035 forEach(callback) { 14036 if (this._root !== null) { 14037 const allNodes = []; 14038 this._root.traverse((node) => allNodes.push(node)); 14039 allNodes.forEach((node) => { 14040 if (node.event) { 14041 callback(node.event); 14042 } 14043 }); 14044 } 14045 return this; 14046 } 14047 /** 14048 * Iterate over everything in the array in which the given time 14049 * overlaps with the time and duration time of the event. 14050 * @param time The time to check if items are overlapping 14051 * @param callback The callback to invoke with every item 14052 */ 14053 forEachAtTime(time, callback) { 14054 if (this._root !== null) { 14055 const results = []; 14056 this._root.search(time, results); 14057 results.forEach((node) => { 14058 if (node.event) { 14059 callback(node.event); 14060 } 14061 }); 14062 } 14063 return this; 14064 } 14065 /** 14066 * Iterate over everything in the array in which the time is greater 14067 * than or equal to the given time. 14068 * @param time The time to check if items are before 14069 * @param callback The callback to invoke with every item 14070 */ 14071 forEachFrom(time, callback) { 14072 if (this._root !== null) { 14073 const results = []; 14074 this._root.searchAfter(time, results); 14075 results.forEach((node) => { 14076 if (node.event) { 14077 callback(node.event); 14078 } 14079 }); 14080 } 14081 return this; 14082 } 14083 /** 14084 * Clean up 14085 */ 14086 dispose() { 14087 super.dispose(); 14088 if (this._root !== null) { 14089 this._root.traverse((node) => node.dispose()); 14090 } 14091 this._root = null; 14092 return this; 14093 } 14094}; 14095var IntervalNode = class { 14096 constructor(low, high, event) { 14097 this._left = null; 14098 this._right = null; 14099 this.parent = null; 14100 this.height = 0; 14101 this.event = event; 14102 this.low = low; 14103 this.high = high; 14104 this.max = this.high; 14105 } 14106 /** 14107 * Insert a node into the correct spot in the tree 14108 */ 14109 insert(node) { 14110 if (node.low <= this.low) { 14111 if (this.left === null) { 14112 this.left = node; 14113 } else { 14114 this.left.insert(node); 14115 } 14116 } else if (this.right === null) { 14117 this.right = node; 14118 } else { 14119 this.right.insert(node); 14120 } 14121 } 14122 /** 14123 * Search the tree for nodes which overlap 14124 * with the given point 14125 * @param point The point to query 14126 * @param results The array to put the results 14127 */ 14128 search(point, results) { 14129 if (point > this.max) { 14130 return; 14131 } 14132 if (this.left !== null) { 14133 this.left.search(point, results); 14134 } 14135 if (this.low <= point && this.high > point) { 14136 results.push(this); 14137 } 14138 if (this.low > point) { 14139 return; 14140 } 14141 if (this.right !== null) { 14142 this.right.search(point, results); 14143 } 14144 } 14145 /** 14146 * Search the tree for nodes which are less 14147 * than the given point 14148 * @param point The point to query 14149 * @param results The array to put the results 14150 */ 14151 searchAfter(point, results) { 14152 if (this.low >= point) { 14153 results.push(this); 14154 if (this.left !== null) { 14155 this.left.searchAfter(point, results); 14156 } 14157 } 14158 if (this.right !== null) { 14159 this.right.searchAfter(point, results); 14160 } 14161 } 14162 /** 14163 * Invoke the callback on this element and both it's branches 14164 * @param {Function} callback 14165 */ 14166 traverse(callback) { 14167 callback(this); 14168 if (this.left !== null) { 14169 this.left.traverse(callback); 14170 } 14171 if (this.right !== null) { 14172 this.right.traverse(callback); 14173 } 14174 } 14175 /** 14176 * Update the height of the node 14177 */ 14178 updateHeight() { 14179 if (this.left !== null && this.right !== null) { 14180 this.height = Math.max(this.left.height, this.right.height) + 1; 14181 } else if (this.right !== null) { 14182 this.height = this.right.height + 1; 14183 } else if (this.left !== null) { 14184 this.height = this.left.height + 1; 14185 } else { 14186 this.height = 0; 14187 } 14188 } 14189 /** 14190 * Update the height of the node 14191 */ 14192 updateMax() { 14193 this.max = this.high; 14194 if (this.left !== null) { 14195 this.max = Math.max(this.max, this.left.max); 14196 } 14197 if (this.right !== null) { 14198 this.max = Math.max(this.max, this.right.max); 14199 } 14200 } 14201 /** 14202 * The balance is how the leafs are distributed on the node 14203 * @return Negative numbers are balanced to the right 14204 */ 14205 getBalance() { 14206 let balance = 0; 14207 if (this.left !== null && this.right !== null) { 14208 balance = this.left.height - this.right.height; 14209 } else if (this.left !== null) { 14210 balance = this.left.height + 1; 14211 } else if (this.right !== null) { 14212 balance = -(this.right.height + 1); 14213 } 14214 return balance; 14215 } 14216 /** 14217 * @returns true if this node is the left child of its parent 14218 */ 14219 isLeftChild() { 14220 return this.parent !== null && this.parent.left === this; 14221 } 14222 /** 14223 * get/set the left node 14224 */ 14225 get left() { 14226 return this._left; 14227 } 14228 set left(node) { 14229 this._left = node; 14230 if (node !== null) { 14231 node.parent = this; 14232 } 14233 this.updateHeight(); 14234 this.updateMax(); 14235 } 14236 /** 14237 * get/set the right node 14238 */ 14239 get right() { 14240 return this._right; 14241 } 14242 set right(node) { 14243 this._right = node; 14244 if (node !== null) { 14245 node.parent = this; 14246 } 14247 this.updateHeight(); 14248 this.updateMax(); 14249 } 14250 /** 14251 * null out references. 14252 */ 14253 dispose() { 14254 this.parent = null; 14255 this._left = null; 14256 this._right = null; 14257 this.event = null; 14258 } 14259}; 14260
vendor: 726 bytes, lines 14261-14296
14261// node_modules/tone/build/esm/core/util/TimelineValue.js 14262var TimelineValue = class extends Tone { 14263 /** 14264 * @param initialValue The value to return if there is no scheduled values 14265 */ 14266 constructor(initialValue) { 14267 super(); 14268 this.name = "TimelineValue"; 14269 this._timeline = new Timeline({ 14270 memory: 10 14271 }); 14272 this._initialValue = initialValue; 14273 } 14274 /** 14275 * Set the value at the given time 14276 */ 14277 set(value, time) { 14278 this._timeline.add({ 14279 value, 14280 time 14281 }); 14282 return this; 14283 } 14284 /** 14285 * Get the value at the given time 14286 */ 14287 get(time) { 14288 const event = this._timeline.get(time); 14289 if (event) { 14290 return event.value; 14291 } else { 14292 return this._initialValue; 14293 } 14294 } 14295}; 14296
vendor: 383 bytes, lines 14297-14309
14297// node_modules/tone/build/esm/signal/SignalOperator.js 14298var SignalOperator = class _SignalOperator extends ToneAudioNode { 14299 constructor() { 14300 super(optionsFromArguments(_SignalOperator.getDefaults(), arguments, [ 14301 "context" 14302 ])); 14303 } 14304 connect(destination, outputNum = 0, inputNum = 0) { 14305 connectSignal(this, destination, outputNum, inputNum); 14306 return this; 14307 } 14308}; 14309
vendor: 2,494 bytes, lines 14310-14383
14310// node_modules/tone/build/esm/signal/WaveShaper.js 14311var WaveShaper = class _WaveShaper extends SignalOperator { 14312 constructor() { 14313 const options = optionsFromArguments(_WaveShaper.getDefaults(), arguments, ["mapping", "length"]); 14314 super(options); 14315 this.name = "WaveShaper"; 14316 this._shaper = this.context.createWaveShaper(); 14317 this.input = this._shaper; 14318 this.output = this._shaper; 14319 if (isArray(options.mapping) || options.mapping instanceof Float32Array) { 14320 this.curve = Float32Array.from(options.mapping); 14321 } else if (isFunction(options.mapping)) { 14322 this.setMap(options.mapping, options.length); 14323 } 14324 } 14325 static getDefaults() { 14326 return Object.assign(Signal.getDefaults(), { 14327 length: 1024 14328 }); 14329 } 14330 /** 14331 * Uses a mapping function to set the value of the curve. 14332 * @param mapping The function used to define the values. 14333 * The mapping function take two arguments: 14334 * the first is the value at the current position 14335 * which goes from -1 to 1 over the number of elements 14336 * in the curve array. The second argument is the array position. 14337 * @example 14338 * const shaper = new Tone.WaveShaper(); 14339 * // map the input signal from [-1, 1] to [0, 10] 14340 * shaper.setMap((val, index) => (val + 1) * 5); 14341 */ 14342 setMap(mapping, length = 1024) { 14343 const array = new Float32Array(length); 14344 for (let i = 0, len = length; i < len; i++) { 14345 const normalized = i / (len - 1) * 2 - 1; 14346 array[i] = mapping(normalized, i); 14347 } 14348 this.curve = array; 14349 return this; 14350 } 14351 /** 14352 * The array to set as the waveshaper curve. For linear curves 14353 * array length does not make much difference, but for complex curves 14354 * longer arrays will provide smoother interpolation. 14355 */ 14356 get curve() { 14357 return this._shaper.curve; 14358 } 14359 set curve(mapping) { 14360 this._shaper.curve = mapping; 14361 } 14362 /** 14363 * Specifies what type of oversampling (if any) should be used when 14364 * applying the shaping curve. Can either be "none", "2x" or "4x". 14365 */ 14366 get oversample() { 14367 return this._shaper.oversample; 14368 } 14369 set oversample(oversampling) { 14370 const isOverSampleType = ["none", "2x", "4x"].some((str) => str.includes(oversampling)); 14371 assert(isOverSampleType, "oversampling must be either 'none', '2x', or '4x'"); 14372 this._shaper.oversample = oversampling; 14373 } 14374 /** 14375 * Clean up. 14376 */ 14377 dispose() { 14378 super.dispose(); 14379 this._shaper.disconnect(); 14380 return this; 14381 } 14382}; 14383
vendor: 1,102 bytes, lines 14384-14432
14384// node_modules/tone/build/esm/signal/Pow.js 14385var Pow = class _Pow extends SignalOperator { 14386 constructor() { 14387 const options = optionsFromArguments(_Pow.getDefaults(), arguments, [ 14388 "value" 14389 ]); 14390 super(options); 14391 this.name = "Pow"; 14392 this._exponentScaler = this.input = this.output = new WaveShaper({ 14393 context: this.context, 14394 mapping: this._expFunc(options.value), 14395 length: 8192 14396 }); 14397 this._exponent = options.value; 14398 } 14399 static getDefaults() { 14400 return Object.assign(SignalOperator.getDefaults(), { 14401 value: 1 14402 }); 14403 } 14404 /** 14405 * the function which maps the waveshaper 14406 * @param exponent exponent value 14407 */ 14408 _expFunc(exponent) { 14409 return (val) => { 14410 return Math.pow(Math.abs(val), exponent); 14411 }; 14412 } 14413 /** 14414 * The value of the exponent. 14415 */ 14416 get value() { 14417 return this._exponent; 14418 } 14419 set value(exponent) { 14420 this._exponent = exponent; 14421 this._exponentScaler.setMap(this._expFunc(this._exponent)); 14422 } 14423 /** 14424 * Clean up. 14425 */ 14426 dispose() { 14427 super.dispose(); 14428 this._exponentScaler.dispose(); 14429 return this; 14430 } 14431}; 14432
vendor: 1,277 bytes, lines 14433-14483
14433// node_modules/tone/build/esm/core/clock/TransportEvent.js 14434var TransportEvent = class _TransportEvent { 14435 /** 14436 * @param transport The transport object which the event belongs to 14437 */ 14438 constructor(transport, opts) { 14439 this.id = _TransportEvent._eventId++; 14440 this._remainderTime = 0; 14441 const options = Object.assign(_TransportEvent.getDefaults(), opts); 14442 this.transport = transport; 14443 this.callback = options.callback; 14444 this._once = options.once; 14445 this.time = Math.floor(options.time); 14446 this._remainderTime = options.time - this.time; 14447 } 14448 static getDefaults() { 14449 return { 14450 callback: noOp, 14451 once: false, 14452 time: 0 14453 }; 14454 } 14455 /** 14456 * Get the time and remainder time. 14457 */ 14458 get floatTime() { 14459 return this.time + this._remainderTime; 14460 } 14461 /** 14462 * Invoke the event callback. 14463 * @param time The AudioContext time in seconds of the event 14464 */ 14465 invoke(time) { 14466 if (this.callback) { 14467 const tickDuration = this.transport.bpm.getDurationOfTicks(1, time); 14468 this.callback(time + this._remainderTime * tickDuration); 14469 if (this._once) { 14470 this.transport.clear(this.id); 14471 } 14472 } 14473 } 14474 /** 14475 * Clean up 14476 */ 14477 dispose() { 14478 this.callback = void 0; 14479 return this; 14480 } 14481}; 14482TransportEvent._eventId = 0; 14483
vendor: 2,876 bytes, lines 14484-14568
14484// node_modules/tone/build/esm/core/clock/TransportRepeatEvent.js 14485var TransportRepeatEvent = class _TransportRepeatEvent extends TransportEvent { 14486 /** 14487 * @param transport The transport object which the event belongs to 14488 */ 14489 constructor(transport, opts) { 14490 super(transport, opts); 14491 this._currentId = -1; 14492 this._nextId = -1; 14493 this._nextTick = this.time; 14494 this._boundRestart = this._restart.bind(this); 14495 const options = Object.assign(_TransportRepeatEvent.getDefaults(), opts); 14496 this.duration = options.duration; 14497 this._interval = options.interval; 14498 this._nextTick = options.time; 14499 this.transport.on("start", this._boundRestart); 14500 this.transport.on("loopStart", this._boundRestart); 14501 this.transport.on("ticks", this._boundRestart); 14502 this.context = this.transport.context; 14503 this._restart(); 14504 } 14505 static getDefaults() { 14506 return Object.assign({}, TransportEvent.getDefaults(), { 14507 duration: Infinity, 14508 interval: 1, 14509 once: false 14510 }); 14511 } 14512 /** 14513 * Invoke the callback. Returns the tick time which 14514 * the next event should be scheduled at. 14515 * @param time The AudioContext time in seconds of the event 14516 */ 14517 invoke(time) { 14518 this._createEvents(time); 14519 super.invoke(time); 14520 } 14521 /** 14522 * Create an event on the transport on the nextTick 14523 */ 14524 _createEvent() { 14525 if (LT(this._nextTick, this.floatTime + this.duration)) { 14526 return this.transport.scheduleOnce(this.invoke.bind(this), new TicksClass(this.context, this._nextTick).toSeconds()); 14527 } 14528 return -1; 14529 } 14530 /** 14531 * Push more events onto the timeline to keep up with the position of the timeline 14532 */ 14533 _createEvents(time) { 14534 if (LT(this._nextTick + this._interval, this.floatTime + this.duration)) { 14535 this._nextTick += this._interval; 14536 this._currentId = this._nextId; 14537 this._nextId = this.transport.scheduleOnce(this.invoke.bind(this), new TicksClass(this.context, this._nextTick).toSeconds()); 14538 } 14539 } 14540 /** 14541 * Re-compute the events when the transport time has changed from a start/ticks/loopStart event 14542 */ 14543 _restart(time) { 14544 this.transport.clear(this._currentId); 14545 this.transport.clear(this._nextId); 14546 this._nextTick = this.floatTime; 14547 const ticks = this.transport.getTicksAtTime(time); 14548 if (GT(ticks, this.time)) { 14549 this._nextTick = this.floatTime + Math.ceil((ticks - this.floatTime) / this._interval) * this._interval; 14550 } 14551 this._currentId = this._createEvent(); 14552 this._nextTick += this._interval; 14553 this._nextId = this._createEvent(); 14554 } 14555 /** 14556 * Clean up 14557 */ 14558 dispose() { 14559 super.dispose(); 14560 this.transport.clear(this._currentId); 14561 this.transport.clear(this._nextId); 14562 this.transport.off("start", this._boundRestart); 14563 this.transport.off("loopStart", this._boundRestart); 14564 this.transport.off("ticks", this._boundRestart); 14565 return this; 14566 } 14567}; 14568
vendor: 16,022 bytes, lines 14569-15080
14569// node_modules/tone/build/esm/core/clock/Transport.js 14570var TransportClass = class _TransportClass extends ToneWithContext { 14571 constructor() { 14572 const options = optionsFromArguments(_TransportClass.getDefaults(), arguments); 14573 super(options); 14574 this.name = "Transport"; 14575 this._loop = new TimelineValue(false); 14576 this._loopStart = 0; 14577 this._loopEnd = 0; 14578 this._scheduledEvents = {}; 14579 this._timeline = new Timeline(); 14580 this._repeatedEvents = new IntervalTimeline(); 14581 this._syncedSignals = []; 14582 this._swingAmount = 0; 14583 this._ppq = options.ppq; 14584 this._clock = new Clock({ 14585 callback: this._processTick.bind(this), 14586 context: this.context, 14587 frequency: 0, 14588 units: "bpm" 14589 }); 14590 this._bindClockEvents(); 14591 this.bpm = this._clock.frequency; 14592 this._clock.frequency.multiplier = options.ppq; 14593 this.bpm.setValueAtTime(options.bpm, 0); 14594 readOnly(this, "bpm"); 14595 this._timeSignature = options.timeSignature; 14596 this._swingTicks = options.ppq / 2; 14597 } 14598 static getDefaults() { 14599 return Object.assign(ToneWithContext.getDefaults(), { 14600 bpm: 120, 14601 loopEnd: "4m", 14602 loopStart: 0, 14603 ppq: 192, 14604 swing: 0, 14605 swingSubdivision: "8n", 14606 timeSignature: 4 14607 }); 14608 } 14609 //------------------------------------- 14610 // TICKS 14611 //------------------------------------- 14612 /** 14613 * called on every tick 14614 * @param tickTime clock relative tick time 14615 */ 14616 _processTick(tickTime, ticks) { 14617 if (this._loop.get(tickTime)) { 14618 if (ticks >= this._loopEnd) { 14619 this.emit("loopEnd", tickTime); 14620 this._clock.setTicksAtTime(this._loopStart, tickTime); 14621 ticks = this._loopStart; 14622 this.emit("loopStart", tickTime, this._clock.getSecondsAtTime(tickTime)); 14623 this.emit("loop", tickTime); 14624 } 14625 } 14626 if (this._swingAmount > 0 && ticks % this._ppq !== 0 && // not on a downbeat 14627 ticks % (this._swingTicks * 2) !== 0) { 14628 const progress = ticks % (this._swingTicks * 2) / (this._swingTicks * 2); 14629 const amount = Math.sin(progress * Math.PI) * this._swingAmount; 14630 tickTime += new TicksClass(this.context, this._swingTicks * 2 / 3).toSeconds() * amount; 14631 } 14632 enterScheduledCallback(true); 14633 this._timeline.forEachAtTime(ticks, (event) => event.invoke(tickTime)); 14634 enterScheduledCallback(false); 14635 } 14636 //------------------------------------- 14637 // SCHEDULABLE EVENTS 14638 //------------------------------------- 14639 /** 14640 * Schedule an event along the timeline. 14641 * @param callback The callback to be invoked at the time. 14642 * @param time The time to invoke the callback at. 14643 * @return The id of the event which can be used for canceling the event. 14644 * @example 14645 * // schedule an event on the 16th measure 14646 * Tone.getTransport().schedule((time) => { 14647 * // invoked on measure 16 14648 * console.log("measure 16!"); 14649 * }, "16:0:0"); 14650 */ 14651 schedule(callback, time) { 14652 const event = new TransportEvent(this, { 14653 callback, 14654 time: new TransportTimeClass(this.context, time).toTicks() 14655 }); 14656 return this._addEvent(event, this._timeline); 14657 } 14658 /** 14659 * Schedule a repeated event along the timeline. The event will fire 14660 * at the `interval` starting at the `startTime` and for the specified 14661 * `duration`. 14662 * @param callback The callback to invoke. 14663 * @param interval The duration between successive callbacks. Must be a positive number. 14664 * @param startTime When along the timeline the events should start being invoked. 14665 * @param duration How long the event should repeat. 14666 * @return The ID of the scheduled event. Use this to cancel the event. 14667 * @example 14668 * const osc = new Tone.Oscillator().toDestination().start(); 14669 * // a callback invoked every eighth note after the first measure 14670 * Tone.getTransport().scheduleRepeat((time) => { 14671 * osc.start(time).stop(time + 0.1); 14672 * }, "8n", "1m"); 14673 */ 14674 scheduleRepeat(callback, interval, startTime, duration = Infinity) { 14675 const event = new TransportRepeatEvent(this, { 14676 callback, 14677 duration: new TimeClass(this.context, duration).toTicks(), 14678 interval: new TimeClass(this.context, interval).toTicks(), 14679 time: new TransportTimeClass(this.context, startTime).toTicks() 14680 }); 14681 return this._addEvent(event, this._repeatedEvents); 14682 } 14683 /** 14684 * Schedule an event that will be removed after it is invoked. 14685 * @param callback The callback to invoke once. 14686 * @param time The time the callback should be invoked. 14687 * @returns The ID of the scheduled event. 14688 */ 14689 scheduleOnce(callback, time) { 14690 const event = new TransportEvent(this, { 14691 callback, 14692 once: true, 14693 time: new TransportTimeClass(this.context, time).toTicks() 14694 }); 14695 return this._addEvent(event, this._timeline); 14696 } 14697 /** 14698 * Clear the passed in event id from the timeline 14699 * @param eventId The id of the event. 14700 */ 14701 clear(eventId) { 14702 if (this._scheduledEvents.hasOwnProperty(eventId)) { 14703 const item = this._scheduledEvents[eventId.toString()]; 14704 item.timeline.remove(item.event); 14705 item.event.dispose(); 14706 delete this._scheduledEvents[eventId.toString()]; 14707 } 14708 return this; 14709 } 14710 /** 14711 * Add an event to the correct timeline. Keep track of the 14712 * timeline it was added to. 14713 * @returns the event id which was just added 14714 */ 14715 _addEvent(event, timeline) { 14716 this._scheduledEvents[event.id.toString()] = { 14717 event, 14718 timeline 14719 }; 14720 timeline.add(event); 14721 return event.id; 14722 } 14723 /** 14724 * Remove scheduled events from the timeline after 14725 * the given time. Repeated events will be removed 14726 * if their startTime is after the given time 14727 * @param after Clear all events after this time. 14728 */ 14729 cancel(after = 0) { 14730 const computedAfter = this.toTicks(after); 14731 this._timeline.forEachFrom(computedAfter, (event) => this.clear(event.id)); 14732 this._repeatedEvents.forEachFrom(computedAfter, (event) => this.clear(event.id)); 14733 return this; 14734 } 14735 //------------------------------------- 14736 // START/STOP/PAUSE 14737 //------------------------------------- 14738 /** 14739 * Bind start/stop/pause events from the clock and emit them. 14740 */ 14741 _bindClockEvents() { 14742 this._clock.on("start", (time, offset) => { 14743 offset = new TicksClass(this.context, offset).toSeconds(); 14744 this.emit("start", time, offset); 14745 }); 14746 this._clock.on("stop", (time) => { 14747 this.emit("stop", time); 14748 }); 14749 this._clock.on("pause", (time) => { 14750 this.emit("pause", time); 14751 }); 14752 } 14753 /** 14754 * Returns the playback state of the source, either "started", "stopped", or "paused" 14755 */ 14756 get state() { 14757 return this._clock.getStateAtTime(this.now()); 14758 } 14759 /** 14760 * Start the transport and all sources synced to the transport. 14761 * @param time The time when the transport should start. 14762 * @param offset The timeline offset to start the transport. 14763 * @example 14764 * // start the transport in one second starting at beginning of the 5th measure. 14765 * Tone.getTransport().start("+1", "4:0:0"); 14766 */ 14767 start(time, offset) { 14768 this.context.resume(); 14769 let offsetTicks; 14770 if (isDefined(offset)) { 14771 offsetTicks = this.toTicks(offset); 14772 } 14773 this._clock.start(time, offsetTicks); 14774 return this; 14775 } 14776 /** 14777 * Stop the transport and all sources synced to the transport. 14778 * @param time The time when the transport should stop. 14779 * @example 14780 * Tone.getTransport().stop(); 14781 */ 14782 stop(time) { 14783 this._clock.stop(time); 14784 return this; 14785 } 14786 /** 14787 * Pause the transport and all sources synced to the transport. 14788 */ 14789 pause(time) { 14790 this._clock.pause(time); 14791 return this; 14792 } 14793 /** 14794 * Toggle the current state of the transport. If it is 14795 * started, it will stop it, otherwise it will start the Transport. 14796 * @param time The time of the event 14797 */ 14798 toggle(time) { 14799 time = this.toSeconds(time); 14800 if (this._clock.getStateAtTime(time) !== "started") { 14801 this.start(time); 14802 } else { 14803 this.stop(time); 14804 } 14805 return this; 14806 } 14807 //------------------------------------- 14808 // SETTERS/GETTERS 14809 //------------------------------------- 14810 /** 14811 * The time signature as just the numerator over 4. 14812 * For example 4/4 would be just 4 and 6/8 would be 3. 14813 * @example 14814 * // common time 14815 * Tone.getTransport().timeSignature = 4; 14816 * // 7/8 14817 * Tone.getTransport().timeSignature = [7, 8]; 14818 * // this will be reduced to a single number 14819 * Tone.getTransport().timeSignature; // returns 3.5 14820 */ 14821 get timeSignature() { 14822 return this._timeSignature; 14823 } 14824 set timeSignature(timeSig) { 14825 if (isArray(timeSig)) { 14826 timeSig = timeSig[0] / timeSig[1] * 4; 14827 } 14828 this._timeSignature = timeSig; 14829 } 14830 /** 14831 * When the Transport.loop = true, this is the starting position of the loop. 14832 */ 14833 get loopStart() { 14834 return new TimeClass(this.context, this._loopStart, "i").toSeconds(); 14835 } 14836 set loopStart(startPosition) { 14837 this._loopStart = this.toTicks(startPosition); 14838 } 14839 /** 14840 * When the Transport.loop = true, this is the ending position of the loop. 14841 */ 14842 get loopEnd() { 14843 return new TimeClass(this.context, this._loopEnd, "i").toSeconds(); 14844 } 14845 set loopEnd(endPosition) { 14846 this._loopEnd = this.toTicks(endPosition); 14847 } 14848 /** 14849 * If the transport loops or not. 14850 */ 14851 get loop() { 14852 return this._loop.get(this.now()); 14853 } 14854 set loop(loop) { 14855 this._loop.set(loop, this.now()); 14856 } 14857 /** 14858 * Set the loop start and stop at the same time. 14859 * @example 14860 * // loop over the first measure 14861 * Tone.getTransport().setLoopPoints(0, "1m"); 14862 * Tone.getTransport().loop = true; 14863 */ 14864 setLoopPoints(startPosition, endPosition) { 14865 this.loopStart = startPosition; 14866 this.loopEnd = endPosition; 14867 return this; 14868 } 14869 /** 14870 * The swing value. Between 0-1 where 1 equal to the note + half the subdivision. 14871 */ 14872 get swing() { 14873 return this._swingAmount; 14874 } 14875 set swing(amount) { 14876 this._swingAmount = amount; 14877 } 14878 /** 14879 * Set the subdivision which the swing will be applied to. 14880 * The default value is an 8th note. Value must be less 14881 * than a quarter note. 14882 */ 14883 get swingSubdivision() { 14884 return new TicksClass(this.context, this._swingTicks).toNotation(); 14885 } 14886 set swingSubdivision(subdivision) { 14887 this._swingTicks = this.toTicks(subdivision); 14888 } 14889 /** 14890 * The Transport's position in Bars:Beats:Sixteenths. 14891 * Setting the value will jump to that position right away. 14892 */ 14893 get position() { 14894 const now = this.now(); 14895 const ticks = this._clock.getTicksAtTime(now); 14896 return new TicksClass(this.context, ticks).toBarsBeatsSixteenths(); 14897 } 14898 set position(progress) { 14899 const ticks = this.toTicks(progress); 14900 this.ticks = ticks; 14901 } 14902 /** 14903 * The Transport's position in seconds. 14904 * Setting the value will jump to that position right away. 14905 */ 14906 get seconds() { 14907 return this._clock.seconds; 14908 } 14909 set seconds(s) { 14910 const now = this.now(); 14911 const ticks = this._clock.frequency.timeToTicks(s, now); 14912 this.ticks = ticks; 14913 } 14914 /** 14915 * The Transport's loop position as a normalized value. Always 14916 * returns 0 if the Transport.loop = false. 14917 */ 14918 get progress() { 14919 if (this.loop) { 14920 const now = this.now(); 14921 const ticks = this._clock.getTicksAtTime(now); 14922 return (ticks - this._loopStart) / (this._loopEnd - this._loopStart); 14923 } else { 14924 return 0; 14925 } 14926 } 14927 /** 14928 * The Transport's current tick position. 14929 */ 14930 get ticks() { 14931 return this._clock.ticks; 14932 } 14933 set ticks(t) { 14934 if (this._clock.ticks !== t) { 14935 const now = this.now(); 14936 if (this.state === "started") { 14937 const ticks = this._clock.getTicksAtTime(now); 14938 const remainingTick = this._clock.frequency.getDurationOfTicks(Math.ceil(ticks) - ticks, now); 14939 const time = now + remainingTick; 14940 this.emit("stop", time); 14941 this._clock.setTicksAtTime(t, time); 14942 this.emit("start", time, this._clock.getSecondsAtTime(time)); 14943 } else { 14944 this.emit("ticks", now); 14945 this._clock.setTicksAtTime(t, now); 14946 } 14947 } 14948 } 14949 /** 14950 * Get the clock's ticks at the given time. 14951 * @param time When to get the tick value 14952 * @return The tick value at the given time. 14953 */ 14954 getTicksAtTime(time) { 14955 return this._clock.getTicksAtTime(time); 14956 } 14957 /** 14958 * Return the elapsed seconds at the given time. 14959 * @param time When to get the elapsed seconds 14960 * @return The number of elapsed seconds 14961 */ 14962 getSecondsAtTime(time) { 14963 return this._clock.getSecondsAtTime(time); 14964 } 14965 /** 14966 * Pulses Per Quarter note. This is the smallest resolution 14967 * the Transport timing supports. This should be set once 14968 * on initialization and not set again. Changing this value 14969 * after other objects have been created can cause problems. 14970 */ 14971 get PPQ() { 14972 return this._clock.frequency.multiplier; 14973 } 14974 set PPQ(ppq) { 14975 this._clock.frequency.multiplier = ppq; 14976 } 14977 //------------------------------------- 14978 // SYNCING 14979 //------------------------------------- 14980 /** 14981 * Returns the time aligned to the next subdivision 14982 * of the Transport. If the Transport is not started, 14983 * it will return 0. 14984 * Note: this will not work precisely during tempo ramps. 14985 * @param subdivision The subdivision to quantize to 14986 * @return The context time of the next subdivision. 14987 * @example 14988 * // the transport must be started, otherwise returns 0 14989 * Tone.getTransport().start(); 14990 * Tone.getTransport().nextSubdivision("4n"); 14991 */ 14992 nextSubdivision(subdivision) { 14993 subdivision = this.toTicks(subdivision); 14994 if (this.state !== "started") { 14995 return 0; 14996 } else { 14997 const now = this.now(); 14998 const transportPos = this.getTicksAtTime(now); 14999 const remainingTicks = subdivision - transportPos % subdivision; 15000 return this._clock.nextTickTime(remainingTicks, now); 15001 } 15002 } 15003 /** 15004 * Attaches the signal to the tempo control signal so that 15005 * any changes in the tempo will change the signal in the same 15006 * ratio. 15007 * 15008 * @param signal 15009 * @param ratio Optionally pass in the ratio between the two signals. 15010 * Otherwise it will be computed based on their current values. 15011 */ 15012 syncSignal(signal, ratio) { 15013 const now = this.now(); 15014 let source = this.bpm; 15015 let sourceValue = 1 / (60 / source.getValueAtTime(now) / this.PPQ); 15016 let nodes = []; 15017 if (signal.units === "time") { 15018 const scaleFactor = 1 / 64 / sourceValue; 15019 const scaleBefore = new Gain(scaleFactor); 15020 const reciprocal = new Pow(-1); 15021 const scaleAfter = new Gain(scaleFactor); 15022 source.chain(scaleBefore, reciprocal, scaleAfter); 15023 source = scaleAfter; 15024 sourceValue = 1 / sourceValue; 15025 nodes = [scaleBefore, reciprocal, scaleAfter]; 15026 } 15027 if (!ratio) { 15028 if (signal.getValueAtTime(now) !== 0) { 15029 ratio = signal.getValueAtTime(now) / sourceValue; 15030 } else { 15031 ratio = 0; 15032 } 15033 } 15034 const ratioSignal = new Gain(ratio); 15035 source.connect(ratioSignal); 15036 ratioSignal.connect(signal._param); 15037 nodes.push(ratioSignal); 15038 this._syncedSignals.push({ 15039 initial: signal.value, 15040 nodes, 15041 signal 15042 }); 15043 signal.value = 0; 15044 return this; 15045 } 15046 /** 15047 * Unsyncs a previously synced signal from the transport's control. 15048 * @see {@link syncSignal}. 15049 */ 15050 unsyncSignal(signal) { 15051 for (let i = this._syncedSignals.length - 1; i >= 0; i--) { 15052 const syncedSignal = this._syncedSignals[i]; 15053 if (syncedSignal.signal === signal) { 15054 syncedSignal.nodes.forEach((node) => node.dispose()); 15055 syncedSignal.signal.value = syncedSignal.initial; 15056 this._syncedSignals.splice(i, 1); 15057 } 15058 } 15059 return this; 15060 } 15061 /** 15062 * Clean up. 15063 */ 15064 dispose() { 15065 super.dispose(); 15066 this._clock.dispose(); 15067 writable(this, "bpm"); 15068 this._timeline.dispose(); 15069 this._repeatedEvents.dispose(); 15070 return this; 15071 } 15072}; 15073Emitter.mixin(TransportClass); 15074onContextInit((context2) => { 15075 context2.transport = new TransportClass({ context: context2 }); 15076}); 15077onContextClose((context2) => { 15078 context2.transport.dispose(); 15079}); 15080
vendor: 7,539 bytes, lines 15081-15304
15081// node_modules/tone/build/esm/source/Source.js 15082var Source = class extends ToneAudioNode { 15083 constructor(options) { 15084 super(options); 15085 this.input = void 0; 15086 this._state = new StateTimeline("stopped"); 15087 this._synced = false; 15088 this._scheduled = []; 15089 this._syncedStart = noOp; 15090 this._syncedStop = noOp; 15091 this._state.memory = 100; 15092 this._state.increasing = true; 15093 this._volume = this.output = new Volume({ 15094 context: this.context, 15095 mute: options.mute, 15096 volume: options.volume 15097 }); 15098 this.volume = this._volume.volume; 15099 readOnly(this, "volume"); 15100 this.onstop = options.onstop; 15101 } 15102 static getDefaults() { 15103 return Object.assign(ToneAudioNode.getDefaults(), { 15104 mute: false, 15105 onstop: noOp, 15106 volume: 0 15107 }); 15108 } 15109 /** 15110 * Returns the playback state of the source, either "started" or "stopped". 15111 * @example 15112 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/ahntone_c3.mp3", () => { 15113 * player.start(); 15114 * console.log(player.state); 15115 * }).toDestination(); 15116 */ 15117 get state() { 15118 if (this._synced) { 15119 if (this.context.transport.state === "started") { 15120 return this._state.getValueAtTime(this.context.transport.seconds); 15121 } else { 15122 return "stopped"; 15123 } 15124 } else { 15125 return this._state.getValueAtTime(this.now()); 15126 } 15127 } 15128 /** 15129 * Mute the output. 15130 * @example 15131 * const osc = new Tone.Oscillator().toDestination().start(); 15132 * // mute the output 15133 * osc.mute = true; 15134 */ 15135 get mute() { 15136 return this._volume.mute; 15137 } 15138 set mute(mute) { 15139 this._volume.mute = mute; 15140 } 15141 /** 15142 * Ensure that the scheduled time is not before the current time. 15143 * Should only be used when scheduled unsynced. 15144 */ 15145 _clampToCurrentTime(time) { 15146 if (this._synced) { 15147 return time; 15148 } else { 15149 return Math.max(time, this.context.currentTime); 15150 } 15151 } 15152 /** 15153 * Start the source at the specified time. If no time is given, 15154 * start the source now. 15155 * @param time When the source should be started. 15156 * @example 15157 * const source = new Tone.Oscillator().toDestination(); 15158 * source.start("+0.5"); // starts the source 0.5 seconds from now 15159 */ 15160 start(time, offset, duration) { 15161 let computedTime = isUndef(time) && this._synced ? this.context.transport.seconds : this.toSeconds(time); 15162 computedTime = this._clampToCurrentTime(computedTime); 15163 if (!this._synced && this._state.getValueAtTime(computedTime) === "started") { 15164 assert(GT(computedTime, this._state.get(computedTime).time), "Start time must be strictly greater than previous start time"); 15165 this._state.cancel(computedTime); 15166 this._state.setStateAtTime("started", computedTime); 15167 this.log("restart", computedTime); 15168 this.restart(computedTime, offset, duration); 15169 } else { 15170 this.log("start", computedTime); 15171 this._state.setStateAtTime("started", computedTime); 15172 if (this._synced) { 15173 const event = this._state.get(computedTime); 15174 if (event) { 15175 event.offset = this.toSeconds(defaultArg(offset, 0)); 15176 event.duration = duration ? this.toSeconds(duration) : void 0; 15177 } 15178 const sched = this.context.transport.schedule((t) => { 15179 this._start(t, offset, duration); 15180 }, computedTime); 15181 this._scheduled.push(sched); 15182 if (this.context.transport.state === "started" && this.context.transport.getSecondsAtTime(this.immediate()) > computedTime) { 15183 this._syncedStart(this.now(), this.context.transport.seconds); 15184 } 15185 } else { 15186 assertContextRunning(this.context); 15187 this._start(computedTime, offset, duration); 15188 } 15189 } 15190 return this; 15191 } 15192 /** 15193 * Stop the source at the specified time. If no time is given, 15194 * stop the source now. 15195 * @param time When the source should be stopped. 15196 * @example 15197 * const source = new Tone.Oscillator().toDestination(); 15198 * source.start(); 15199 * source.stop("+0.5"); // stops the source 0.5 seconds from now 15200 */ 15201 stop(time) { 15202 let computedTime = isUndef(time) && this._synced ? this.context.transport.seconds : this.toSeconds(time); 15203 computedTime = this._clampToCurrentTime(computedTime); 15204 if (this._state.getValueAtTime(computedTime) === "started" || isDefined(this._state.getNextState("started", computedTime))) { 15205 this.log("stop", computedTime); 15206 if (!this._synced) { 15207 this._stop(computedTime); 15208 } else { 15209 const sched = this.context.transport.schedule(this._stop.bind(this), computedTime); 15210 this._scheduled.push(sched); 15211 } 15212 this._state.cancel(computedTime); 15213 this._state.setStateAtTime("stopped", computedTime); 15214 } 15215 return this; 15216 } 15217 /** 15218 * Restart the source. 15219 */ 15220 restart(time, offset, duration) { 15221 time = this.toSeconds(time); 15222 if (this._state.getValueAtTime(time) === "started") { 15223 this._state.cancel(time); 15224 this._restart(time, offset, duration); 15225 } 15226 return this; 15227 } 15228 /** 15229 * Sync the source to the Transport so that all subsequent 15230 * calls to `start` and `stop` are synced to the TransportTime 15231 * instead of the AudioContext time. 15232 * 15233 * @example 15234 * const osc = new Tone.Oscillator().toDestination(); 15235 * // sync the source so that it plays between 0 and 0.3 on the Transport's timeline 15236 * osc.sync().start(0).stop(0.3); 15237 * // start the transport. 15238 * Tone.Transport.start(); 15239 * // set it to loop once a second 15240 * Tone.Transport.loop = true; 15241 * Tone.Transport.loopEnd = 1; 15242 */ 15243 sync() { 15244 if (!this._synced) { 15245 this._synced = true; 15246 this._syncedStart = (time, offset) => { 15247 if (GT(offset, 0)) { 15248 const stateEvent = this._state.get(offset); 15249 if (stateEvent && stateEvent.state === "started" && stateEvent.time !== offset) { 15250 const startOffset = offset - this.toSeconds(stateEvent.time); 15251 let duration; 15252 if (stateEvent.duration) { 15253 duration = this.toSeconds(stateEvent.duration) - startOffset; 15254 } 15255 this._start(time, this.toSeconds(stateEvent.offset) + startOffset, duration); 15256 } 15257 } 15258 }; 15259 this._syncedStop = (time) => { 15260 const seconds = this.context.transport.getSecondsAtTime(Math.max(time - this.sampleTime, 0)); 15261 if (this._state.getValueAtTime(seconds) === "started") { 15262 this._stop(time); 15263 } 15264 }; 15265 this.context.transport.on("start", this._syncedStart); 15266 this.context.transport.on("loopStart", this._syncedStart); 15267 this.context.transport.on("stop", this._syncedStop); 15268 this.context.transport.on("pause", this._syncedStop); 15269 this.context.transport.on("loopEnd", this._syncedStop); 15270 } 15271 return this; 15272 } 15273 /** 15274 * Unsync the source to the Transport. 15275 * @see {@link sync} 15276 */ 15277 unsync() { 15278 if (this._synced) { 15279 this.context.transport.off("stop", this._syncedStop); 15280 this.context.transport.off("pause", this._syncedStop); 15281 this.context.transport.off("loopEnd", this._syncedStop); 15282 this.context.transport.off("start", this._syncedStart); 15283 this.context.transport.off("loopStart", this._syncedStart); 15284 } 15285 this._synced = false; 15286 this._scheduled.forEach((id) => this.context.transport.clear(id)); 15287 this._scheduled = []; 15288 this._state.cancel(0); 15289 this._stop(0); 15290 return this; 15291 } 15292 /** 15293 * Clean up. 15294 */ 15295 dispose() { 15296 super.dispose(); 15297 this.onstop = noOp; 15298 this.unsync(); 15299 this._volume.dispose(); 15300 this._state.dispose(); 15301 return this; 15302 } 15303}; 15304
vendor: 4,587 bytes, lines 15305-15466
15305// node_modules/tone/build/esm/source/buffer/ToneBufferSource.js 15306var ToneBufferSource = class _ToneBufferSource extends OneShotSource { 15307 constructor() { 15308 const options = optionsFromArguments(_ToneBufferSource.getDefaults(), arguments, ["url", "onload"]); 15309 super(options); 15310 this.name = "ToneBufferSource"; 15311 this._source = this.context.createBufferSource(); 15312 this._internalChannels = [this._source]; 15313 this._sourceStarted = false; 15314 this._sourceStopped = false; 15315 connect(this._source, this._gainNode); 15316 this._source.onended = () => this._stopSource(); 15317 this.playbackRate = new Param({ 15318 context: this.context, 15319 param: this._source.playbackRate, 15320 units: "positive", 15321 value: options.playbackRate 15322 }); 15323 this.loop = options.loop; 15324 this.loopStart = options.loopStart; 15325 this.loopEnd = options.loopEnd; 15326 this._buffer = new ToneAudioBuffer(options.url, options.onload, options.onerror); 15327 this._internalChannels.push(this._source); 15328 } 15329 static getDefaults() { 15330 return Object.assign(OneShotSource.getDefaults(), { 15331 url: new ToneAudioBuffer(), 15332 loop: false, 15333 loopEnd: 0, 15334 loopStart: 0, 15335 onload: noOp, 15336 onerror: noOp, 15337 playbackRate: 1 15338 }); 15339 } 15340 /** 15341 * The fadeIn time of the amplitude envelope. 15342 */ 15343 get fadeIn() { 15344 return this._fadeIn; 15345 } 15346 set fadeIn(t) { 15347 this._fadeIn = t; 15348 } 15349 /** 15350 * The fadeOut time of the amplitude envelope. 15351 */ 15352 get fadeOut() { 15353 return this._fadeOut; 15354 } 15355 set fadeOut(t) { 15356 this._fadeOut = t; 15357 } 15358 /** 15359 * The curve applied to the fades, either "linear" or "exponential" 15360 */ 15361 get curve() { 15362 return this._curve; 15363 } 15364 set curve(t) { 15365 this._curve = t; 15366 } 15367 /** 15368 * Start the buffer 15369 * @param time When the player should start. 15370 * @param offset The offset from the beginning of the sample to start at. 15371 * @param duration How long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset) 15372 * @param gain The gain to play the buffer back at. 15373 */ 15374 start(time, offset, duration, gain = 1) { 15375 assert(this.buffer.loaded, "buffer is either not set or not loaded"); 15376 const computedTime = this.toSeconds(time); 15377 this._startGain(computedTime, gain); 15378 if (this.loop) { 15379 offset = defaultArg(offset, this.loopStart); 15380 } else { 15381 offset = defaultArg(offset, 0); 15382 } 15383 let computedOffset = Math.max(this.toSeconds(offset), 0); 15384 if (this.loop) { 15385 const loopEnd = this.toSeconds(this.loopEnd) || this.buffer.duration; 15386 const loopStart = this.toSeconds(this.loopStart); 15387 const loopDuration = loopEnd - loopStart; 15388 if (GTE(computedOffset, loopEnd)) { 15389 computedOffset = (computedOffset - loopStart) % loopDuration + loopStart; 15390 } 15391 if (EQ(computedOffset, this.buffer.duration)) { 15392 computedOffset = 0; 15393 } 15394 } 15395 this._source.buffer = this.buffer.get(); 15396 this._source.loopEnd = this.toSeconds(this.loopEnd) || this.buffer.duration; 15397 if (LT(computedOffset, this.buffer.duration)) { 15398 this._sourceStarted = true; 15399 this._source.start(computedTime, computedOffset); 15400 } 15401 if (isDefined(duration)) { 15402 let computedDur = this.toSeconds(duration); 15403 computedDur = Math.max(computedDur, 0); 15404 this.stop(computedTime + computedDur); 15405 } 15406 return this; 15407 } 15408 _stopSource(time) { 15409 if (!this._sourceStopped && this._sourceStarted) { 15410 this._sourceStopped = true; 15411 this._source.stop(this.toSeconds(time)); 15412 this._onended(); 15413 } 15414 } 15415 /** 15416 * If loop is true, the loop will start at this position. 15417 */ 15418 get loopStart() { 15419 return this._source.loopStart; 15420 } 15421 set loopStart(loopStart) { 15422 this._source.loopStart = this.toSeconds(loopStart); 15423 } 15424 /** 15425 * If loop is true, the loop will end at this position. 15426 */ 15427 get loopEnd() { 15428 return this._source.loopEnd; 15429 } 15430 set loopEnd(loopEnd) { 15431 this._source.loopEnd = this.toSeconds(loopEnd); 15432 } 15433 /** 15434 * The audio buffer belonging to the player. 15435 */ 15436 get buffer() { 15437 return this._buffer; 15438 } 15439 set buffer(buffer) { 15440 this._buffer.set(buffer); 15441 } 15442 /** 15443 * If the buffer should loop once it's over. 15444 */ 15445 get loop() { 15446 return this._source.loop; 15447 } 15448 set loop(loop) { 15449 this._source.loop = loop; 15450 if (this._sourceStarted) { 15451 this.cancelStop(); 15452 } 15453 } 15454 /** 15455 * Clean up. 15456 */ 15457 dispose() { 15458 super.dispose(); 15459 this._source.onended = null; 15460 this._source.disconnect(); 15461 this._buffer.dispose(); 15462 this.playbackRate.dispose(); 15463 return this; 15464 } 15465}; 15466
vendor: 4,869 bytes, lines 15467-15652
15467// node_modules/tone/build/esm/source/Noise.js 15468var Noise = class _Noise extends Source { 15469 constructor() { 15470 const options = optionsFromArguments(_Noise.getDefaults(), arguments, [ 15471 "type" 15472 ]); 15473 super(options); 15474 this.name = "Noise"; 15475 this._source = null; 15476 this._playbackRate = options.playbackRate; 15477 this.type = options.type; 15478 this._fadeIn = options.fadeIn; 15479 this._fadeOut = options.fadeOut; 15480 } 15481 static getDefaults() { 15482 return Object.assign(Source.getDefaults(), { 15483 fadeIn: 0, 15484 fadeOut: 0, 15485 playbackRate: 1, 15486 type: "white" 15487 }); 15488 } 15489 /** 15490 * The type of the noise. Can be "white", "brown", or "pink". 15491 * @example 15492 * const noise = new Tone.Noise().toDestination().start(); 15493 * noise.type = "brown"; 15494 */ 15495 get type() { 15496 return this._type; 15497 } 15498 set type(type) { 15499 assert(type in _noiseBuffers, "Noise: invalid type: " + type); 15500 if (this._type !== type) { 15501 this._type = type; 15502 if (this.state === "started") { 15503 const now = this.now(); 15504 this._stop(now); 15505 this._start(now); 15506 } 15507 } 15508 } 15509 /** 15510 * The playback rate of the noise. Affects 15511 * the "frequency" of the noise. 15512 */ 15513 get playbackRate() { 15514 return this._playbackRate; 15515 } 15516 set playbackRate(rate) { 15517 this._playbackRate = rate; 15518 if (this._source) { 15519 this._source.playbackRate.value = rate; 15520 } 15521 } 15522 /** 15523 * internal start method 15524 */ 15525 _start(time) { 15526 const buffer = _noiseBuffers[this._type]; 15527 this._source = new ToneBufferSource({ 15528 url: buffer, 15529 context: this.context, 15530 fadeIn: this._fadeIn, 15531 fadeOut: this._fadeOut, 15532 loop: true, 15533 onended: () => this.onstop(this), 15534 playbackRate: this._playbackRate 15535 }).connect(this.output); 15536 this._source.start(this.toSeconds(time), Math.random() * (buffer.duration - 1e-3)); 15537 } 15538 /** 15539 * internal stop method 15540 */ 15541 _stop(time) { 15542 if (this._source) { 15543 this._source.stop(this.toSeconds(time)); 15544 this._source = null; 15545 } 15546 } 15547 /** 15548 * The fadeIn time of the amplitude envelope. 15549 */ 15550 get fadeIn() { 15551 return this._fadeIn; 15552 } 15553 set fadeIn(time) { 15554 this._fadeIn = time; 15555 if (this._source) { 15556 this._source.fadeIn = this._fadeIn; 15557 } 15558 } 15559 /** 15560 * The fadeOut time of the amplitude envelope. 15561 */ 15562 get fadeOut() { 15563 return this._fadeOut; 15564 } 15565 set fadeOut(time) { 15566 this._fadeOut = time; 15567 if (this._source) { 15568 this._source.fadeOut = this._fadeOut; 15569 } 15570 } 15571 _restart(time) { 15572 this._stop(time); 15573 this._start(time); 15574 } 15575 /** 15576 * Clean up. 15577 */ 15578 dispose() { 15579 super.dispose(); 15580 if (this._source) { 15581 this._source.disconnect(); 15582 } 15583 return this; 15584 } 15585}; 15586var BUFFER_LENGTH = 44100 * 5; 15587var NUM_CHANNELS = 2; 15588var _noiseCache = { 15589 brown: null, 15590 pink: null, 15591 white: null 15592}; 15593var _noiseBuffers = { 15594 get brown() { 15595 if (!_noiseCache.brown) { 15596 const buffer = []; 15597 for (let channelNum = 0; channelNum < NUM_CHANNELS; channelNum++) { 15598 const channel = new Float32Array(BUFFER_LENGTH); 15599 buffer[channelNum] = channel; 15600 let lastOut = 0; 15601 for (let i = 0; i < BUFFER_LENGTH; i++) { 15602 const white = Math.random() * 2 - 1; 15603 channel[i] = (lastOut + 0.02 * white) / 1.02; 15604 lastOut = channel[i]; 15605 channel[i] *= 3.5; 15606 } 15607 } 15608 _noiseCache.brown = new ToneAudioBuffer().fromArray(buffer); 15609 } 15610 return _noiseCache.brown; 15611 }, 15612 get pink() { 15613 if (!_noiseCache.pink) { 15614 const buffer = []; 15615 for (let channelNum = 0; channelNum < NUM_CHANNELS; channelNum++) { 15616 const channel = new Float32Array(BUFFER_LENGTH); 15617 buffer[channelNum] = channel; 15618 let b0, b1, b2, b3, b4, b5, b6; 15619 b0 = b1 = b2 = b3 = b4 = b5 = b6 = 0; 15620 for (let i = 0; i < BUFFER_LENGTH; i++) { 15621 const white = Math.random() * 2 - 1; 15622 b0 = 0.99886 * b0 + white * 0.0555179; 15623 b1 = 0.99332 * b1 + white * 0.0750759; 15624 b2 = 0.969 * b2 + white * 0.153852; 15625 b3 = 0.8665 * b3 + white * 0.3104856; 15626 b4 = 0.55 * b4 + white * 0.5329522; 15627 b5 = -0.7616 * b5 - white * 0.016898; 15628 channel[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + white * 0.5362; 15629 channel[i] *= 0.11; 15630 b6 = white * 0.115926; 15631 } 15632 } 15633 _noiseCache.pink = new ToneAudioBuffer().fromArray(buffer); 15634 } 15635 return _noiseCache.pink; 15636 }, 15637 get white() { 15638 if (!_noiseCache.white) { 15639 const buffer = []; 15640 for (let channelNum = 0; channelNum < NUM_CHANNELS; channelNum++) { 15641 const channel = new Float32Array(BUFFER_LENGTH); 15642 buffer[channelNum] = channel; 15643 for (let i = 0; i < BUFFER_LENGTH; i++) { 15644 channel[i] = Math.random() * 2 - 1; 15645 } 15646 } 15647 _noiseCache.white = new ToneAudioBuffer().fromArray(buffer); 15648 } 15649 return _noiseCache.white; 15650 } 15651}; 15652
vendor: 659 bytes, lines 15653-15670
15653// node_modules/tone/build/esm/source/oscillator/OscillatorInterface.js 15654function generateWaveform(instance, length) { 15655 return __awaiter(this, void 0, void 0, function* () { 15656 const duration = length / instance.context.sampleRate; 15657 const context2 = new OfflineContext(1, duration, instance.context.sampleRate); 15658 const clone = new instance.constructor(Object.assign(instance.get(), { 15659 // should do 2 iterations 15660 frequency: 2 / duration, 15661 // zero out the detune 15662 detune: 0, 15663 context: context2 15664 })).toDestination(); 15665 clone.start(0); 15666 const buffer = yield context2.render(); 15667 return buffer.getChannelData(0); 15668 }); 15669} 15670
vendor: 2,120 bytes, lines 15671-15747
15671// node_modules/tone/build/esm/source/oscillator/ToneOscillatorNode.js 15672var ToneOscillatorNode = class _ToneOscillatorNode extends OneShotSource { 15673 constructor() { 15674 const options = optionsFromArguments(_ToneOscillatorNode.getDefaults(), arguments, ["frequency", "type"]); 15675 super(options); 15676 this.name = "ToneOscillatorNode"; 15677 this._oscillator = this.context.createOscillator(); 15678 this._internalChannels = [this._oscillator]; 15679 connect(this._oscillator, this._gainNode); 15680 this.type = options.type; 15681 this.frequency = new Param({ 15682 context: this.context, 15683 param: this._oscillator.frequency, 15684 units: "frequency", 15685 value: options.frequency 15686 }); 15687 this.detune = new Param({ 15688 context: this.context, 15689 param: this._oscillator.detune, 15690 units: "cents", 15691 value: options.detune 15692 }); 15693 readOnly(this, ["frequency", "detune"]); 15694 } 15695 static getDefaults() { 15696 return Object.assign(OneShotSource.getDefaults(), { 15697 detune: 0, 15698 frequency: 440, 15699 type: "sine" 15700 }); 15701 } 15702 /** 15703 * Start the oscillator node at the given time 15704 * @param time When to start the oscillator 15705 */ 15706 start(time) { 15707 const computedTime = this.toSeconds(time); 15708 this.log("start", computedTime); 15709 this._startGain(computedTime); 15710 this._oscillator.start(computedTime); 15711 return this; 15712 } 15713 _stopSource(time) { 15714 this._oscillator.stop(time); 15715 } 15716 /** 15717 * Sets an arbitrary custom periodic waveform given a PeriodicWave. 15718 * @param periodicWave PeriodicWave should be created with context.createPeriodicWave 15719 */ 15720 setPeriodicWave(periodicWave) { 15721 this._oscillator.setPeriodicWave(periodicWave); 15722 return this; 15723 } 15724 /** 15725 * The oscillator type. Either 'sine', 'sawtooth', 'square', or 'triangle' 15726 */ 15727 get type() { 15728 return this._oscillator.type; 15729 } 15730 set type(type) { 15731 this._oscillator.type = type; 15732 } 15733 /** 15734 * Clean up. 15735 */ 15736 dispose() { 15737 super.dispose(); 15738 if (this.state === "started") { 15739 this.stop(); 15740 } 15741 this._oscillator.disconnect(); 15742 this.frequency.dispose(); 15743 this.detune.dispose(); 15744 return this; 15745 } 15746}; 15747
vendor: 9,820 bytes, lines 15748-16076
15748// node_modules/tone/build/esm/source/oscillator/Oscillator.js 15749var Oscillator = class _Oscillator extends Source { 15750 constructor() { 15751 const options = optionsFromArguments(_Oscillator.getDefaults(), arguments, ["frequency", "type"]); 15752 super(options); 15753 this.name = "Oscillator"; 15754 this._oscillator = null; 15755 this.frequency = new Signal({ 15756 context: this.context, 15757 units: "frequency", 15758 value: options.frequency 15759 }); 15760 readOnly(this, "frequency"); 15761 this.detune = new Signal({ 15762 context: this.context, 15763 units: "cents", 15764 value: options.detune 15765 }); 15766 readOnly(this, "detune"); 15767 this._partials = options.partials; 15768 this._partialCount = options.partialCount; 15769 this._type = options.type; 15770 if (options.partialCount && options.type !== "custom") { 15771 this._type = this.baseType + options.partialCount.toString(); 15772 } 15773 this.phase = options.phase; 15774 } 15775 static getDefaults() { 15776 return Object.assign(Source.getDefaults(), { 15777 detune: 0, 15778 frequency: 440, 15779 partialCount: 0, 15780 partials: [], 15781 phase: 0, 15782 type: "sine" 15783 }); 15784 } 15785 /** 15786 * start the oscillator 15787 */ 15788 _start(time) { 15789 const computedTime = this.toSeconds(time); 15790 const oscillator = new ToneOscillatorNode({ 15791 context: this.context, 15792 onended: () => this.onstop(this) 15793 }); 15794 this._oscillator = oscillator; 15795 if (this._wave) { 15796 this._oscillator.setPeriodicWave(this._wave); 15797 } else { 15798 this._oscillator.type = this._type; 15799 } 15800 this._oscillator.connect(this.output); 15801 this.frequency.connect(this._oscillator.frequency); 15802 this.detune.connect(this._oscillator.detune); 15803 this._oscillator.start(computedTime); 15804 } 15805 /** 15806 * stop the oscillator 15807 */ 15808 _stop(time) { 15809 const computedTime = this.toSeconds(time); 15810 if (this._oscillator) { 15811 this._oscillator.stop(computedTime); 15812 } 15813 } 15814 /** 15815 * Restart the oscillator. Does not stop the oscillator, but instead 15816 * just cancels any scheduled 'stop' from being invoked. 15817 */ 15818 _restart(time) { 15819 const computedTime = this.toSeconds(time); 15820 this.log("restart", computedTime); 15821 if (this._oscillator) { 15822 this._oscillator.cancelStop(); 15823 } 15824 this._state.cancel(computedTime); 15825 return this; 15826 } 15827 /** 15828 * Sync the signal to the Transport's bpm. Any changes to the transports bpm, 15829 * will also affect the oscillators frequency. 15830 * @example 15831 * const osc = new Tone.Oscillator().toDestination().start(); 15832 * osc.frequency.value = 440; 15833 * // the ratio between the bpm and the frequency will be maintained 15834 * osc.syncFrequency(); 15835 * // double the tempo 15836 * Tone.Transport.bpm.value *= 2; 15837 * // the frequency of the oscillator is doubled to 880 15838 */ 15839 syncFrequency() { 15840 this.context.transport.syncSignal(this.frequency); 15841 return this; 15842 } 15843 /** 15844 * Unsync the oscillator's frequency from the Transport. 15845 * @see {@link syncFrequency} 15846 */ 15847 unsyncFrequency() { 15848 this.context.transport.unsyncSignal(this.frequency); 15849 return this; 15850 } 15851 /** 15852 * Get a cached periodic wave. Avoids having to recompute 15853 * the oscillator values when they have already been computed 15854 * with the same values. 15855 */ 15856 _getCachedPeriodicWave() { 15857 if (this._type === "custom") { 15858 const oscProps = _Oscillator._periodicWaveCache.find((description) => { 15859 return description.phase === this._phase && deepEquals(description.partials, this._partials); 15860 }); 15861 return oscProps; 15862 } else { 15863 const oscProps = _Oscillator._periodicWaveCache.find((description) => { 15864 return description.type === this._type && description.phase === this._phase; 15865 }); 15866 this._partialCount = oscProps ? oscProps.partialCount : this._partialCount; 15867 return oscProps; 15868 } 15869 } 15870 get type() { 15871 return this._type; 15872 } 15873 set type(type) { 15874 this._type = type; 15875 const isBasicType = ["sine", "square", "sawtooth", "triangle"].indexOf(type) !== -1; 15876 if (this._phase === 0 && isBasicType) { 15877 this._wave = void 0; 15878 this._partialCount = 0; 15879 if (this._oscillator !== null) { 15880 this._oscillator.type = type; 15881 } 15882 } else { 15883 const cache = this._getCachedPeriodicWave(); 15884 if (isDefined(cache)) { 15885 const { partials, wave } = cache; 15886 this._wave = wave; 15887 this._partials = partials; 15888 if (this._oscillator !== null) { 15889 this._oscillator.setPeriodicWave(this._wave); 15890 } 15891 } else { 15892 const [real, imag] = this._getRealImaginary(type, this._phase); 15893 const periodicWave = this.context.createPeriodicWave(real, imag); 15894 this._wave = periodicWave; 15895 if (this._oscillator !== null) { 15896 this._oscillator.setPeriodicWave(this._wave); 15897 } 15898 _Oscillator._periodicWaveCache.push({ 15899 imag, 15900 partialCount: this._partialCount, 15901 partials: this._partials, 15902 phase: this._phase, 15903 real, 15904 type: this._type, 15905 wave: this._wave 15906 }); 15907 if (_Oscillator._periodicWaveCache.length > 100) { 15908 _Oscillator._periodicWaveCache.shift(); 15909 } 15910 } 15911 } 15912 } 15913 get baseType() { 15914 return this._type.replace(this.partialCount.toString(), ""); 15915 } 15916 set baseType(baseType) { 15917 if (this.partialCount && this._type !== "custom" && baseType !== "custom") { 15918 this.type = baseType + this.partialCount; 15919 } else { 15920 this.type = baseType; 15921 } 15922 } 15923 get partialCount() { 15924 return this._partialCount; 15925 } 15926 set partialCount(p) { 15927 assertRange(p, 0); 15928 let type = this._type; 15929 const partial = /^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type); 15930 if (partial) { 15931 type = partial[1]; 15932 } 15933 if (this._type !== "custom") { 15934 if (p === 0) { 15935 this.type = type; 15936 } else { 15937 this.type = type + p.toString(); 15938 } 15939 } else { 15940 const fullPartials = new Float32Array(p); 15941 this._partials.forEach((v, i) => fullPartials[i] = v); 15942 this._partials = Array.from(fullPartials); 15943 this.type = this._type; 15944 } 15945 } 15946 /** 15947 * Returns the real and imaginary components based 15948 * on the oscillator type. 15949 * @returns [real: Float32Array, imaginary: Float32Array] 15950 */ 15951 _getRealImaginary(type, phase) { 15952 const fftSize = 4096; 15953 let periodicWaveSize = fftSize / 2; 15954 const real = new Float32Array(periodicWaveSize); 15955 const imag = new Float32Array(periodicWaveSize); 15956 let partialCount = 1; 15957 if (type === "custom") { 15958 partialCount = this._partials.length + 1; 15959 this._partialCount = this._partials.length; 15960 periodicWaveSize = partialCount; 15961 if (this._partials.length === 0) { 15962 return [real, imag]; 15963 } 15964 } else { 15965 const partial = /^(sine|triangle|square|sawtooth)(\d+)$/.exec(type); 15966 if (partial) { 15967 partialCount = parseInt(partial[2], 10) + 1; 15968 this._partialCount = parseInt(partial[2], 10); 15969 type = partial[1]; 15970 partialCount = Math.max(partialCount, 2); 15971 periodicWaveSize = partialCount; 15972 } else { 15973 this._partialCount = 0; 15974 } 15975 this._partials = []; 15976 } 15977 for (let n = 1; n < periodicWaveSize; ++n) { 15978 const piFactor = 2 / (n * Math.PI); 15979 let b; 15980 switch (type) { 15981 case "sine": 15982 b = n <= partialCount ? 1 : 0; 15983 this._partials[n - 1] = b; 15984 break; 15985 case "square": 15986 b = n & 1 ? 2 * piFactor : 0; 15987 this._partials[n - 1] = b; 15988 break; 15989 case "sawtooth": 15990 b = piFactor * (n & 1 ? 1 : -1); 15991 this._partials[n - 1] = b; 15992 break; 15993 case "triangle": 15994 if (n & 1) { 15995 b = 2 * (piFactor * piFactor) * (n - 1 >> 1 & 1 ? -1 : 1); 15996 } else { 15997 b = 0; 15998 } 15999 this._partials[n - 1] = b; 16000 break; 16001 case "custom": 16002 b = this._partials[n - 1]; 16003 break; 16004 default: 16005 throw new TypeError("Oscillator: invalid type: " + type); 16006 } 16007 if (b !== 0) { 16008 real[n] = -b * Math.sin(phase * n); 16009 imag[n] = b * Math.cos(phase * n); 16010 } else { 16011 real[n] = 0; 16012 imag[n] = 0; 16013 } 16014 } 16015 return [real, imag]; 16016 } 16017 /** 16018 * Compute the inverse FFT for a given phase. 16019 */ 16020 _inverseFFT(real, imag, phase) { 16021 let sum = 0; 16022 const len = real.length; 16023 for (let i = 0; i < len; i++) { 16024 sum += real[i] * Math.cos(i * phase) + imag[i] * Math.sin(i * phase); 16025 } 16026 return sum; 16027 } 16028 /** 16029 * Returns the initial value of the oscillator when stopped. 16030 * E.g. a "sine" oscillator with phase = 90 would return an initial value of -1. 16031 */ 16032 getInitialValue() { 16033 const [real, imag] = this._getRealImaginary(this._type, 0); 16034 let maxValue = 0; 16035 const twoPi = Math.PI * 2; 16036 const testPositions = 32; 16037 for (let i = 0; i < testPositions; i++) { 16038 maxValue = Math.max(this._inverseFFT(real, imag, i / testPositions * twoPi), maxValue); 16039 } 16040 return clamp(-this._inverseFFT(real, imag, this._phase) / maxValue, -1, 1); 16041 } 16042 get partials() { 16043 return this._partials.slice(0, this.partialCount); 16044 } 16045 set partials(partials) { 16046 this._partials = partials; 16047 this._partialCount = this._partials.length; 16048 if (partials.length) { 16049 this.type = "custom"; 16050 } 16051 } 16052 get phase() { 16053 return this._phase * (180 / Math.PI); 16054 } 16055 set phase(phase) { 16056 this._phase = phase * Math.PI / 180; 16057 this.type = this._type; 16058 } 16059 asArray() { 16060 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16061 return generateWaveform(this, length); 16062 }); 16063 } 16064 dispose() { 16065 super.dispose(); 16066 if (this._oscillator !== null) { 16067 this._oscillator.dispose(); 16068 } 16069 this._wave = void 0; 16070 this.frequency.dispose(); 16071 this.detune.dispose(); 16072 return this; 16073 } 16074}; 16075Oscillator._periodicWaveCache = []; 16076
vendor: 456 bytes, lines 16077-16098
16077// node_modules/tone/build/esm/signal/AudioToGain.js 16078var AudioToGain = class extends SignalOperator { 16079 constructor() { 16080 super(...arguments); 16081 this.name = "AudioToGain"; 16082 this._norm = new WaveShaper({ 16083 context: this.context, 16084 mapping: (x) => (x + 1) / 2 16085 }); 16086 this.input = this._norm; 16087 this.output = this._norm; 16088 } 16089 /** 16090 * clean up 16091 */ 16092 dispose() { 16093 super.dispose(); 16094 this._norm.dispose(); 16095 return this; 16096 } 16097}; 16098
vendor: 729 bytes, lines 16099-16125
16099// node_modules/tone/build/esm/signal/Multiply.js 16100var Multiply = class _Multiply extends Signal { 16101 constructor() { 16102 const options = optionsFromArguments(_Multiply.getDefaults(), arguments, ["value"]); 16103 super(options); 16104 this.name = "Multiply"; 16105 this.override = false; 16106 this._mult = this.input = this.output = new Gain({ 16107 context: this.context, 16108 minValue: options.minValue, 16109 maxValue: options.maxValue 16110 }); 16111 this.factor = this._param = this._mult.gain; 16112 this.factor.setValueAtTime(options.value, 0); 16113 } 16114 static getDefaults() { 16115 return Object.assign(Signal.getDefaults(), { 16116 value: 0 16117 }); 16118 } 16119 dispose() { 16120 super.dispose(); 16121 this._mult.dispose(); 16122 return this; 16123 } 16124}; 16125
vendor: 3,139 bytes, lines 16126-16247
16126// node_modules/tone/build/esm/source/oscillator/AMOscillator.js 16127var AMOscillator = class _AMOscillator extends Source { 16128 constructor() { 16129 const options = optionsFromArguments(_AMOscillator.getDefaults(), arguments, ["frequency", "type", "modulationType"]); 16130 super(options); 16131 this.name = "AMOscillator"; 16132 this._modulationScale = new AudioToGain({ context: this.context }); 16133 this._modulationNode = new Gain({ 16134 context: this.context 16135 }); 16136 this._carrier = new Oscillator({ 16137 context: this.context, 16138 detune: options.detune, 16139 frequency: options.frequency, 16140 onstop: () => this.onstop(this), 16141 phase: options.phase, 16142 type: options.type 16143 }); 16144 this.frequency = this._carrier.frequency, this.detune = this._carrier.detune; 16145 this._modulator = new Oscillator({ 16146 context: this.context, 16147 phase: options.phase, 16148 type: options.modulationType 16149 }); 16150 this.harmonicity = new Multiply({ 16151 context: this.context, 16152 units: "positive", 16153 value: options.harmonicity 16154 }); 16155 this.frequency.chain(this.harmonicity, this._modulator.frequency); 16156 this._modulator.chain(this._modulationScale, this._modulationNode.gain); 16157 this._carrier.chain(this._modulationNode, this.output); 16158 readOnly(this, ["frequency", "detune", "harmonicity"]); 16159 } 16160 static getDefaults() { 16161 return Object.assign(Oscillator.getDefaults(), { 16162 harmonicity: 1, 16163 modulationType: "square" 16164 }); 16165 } 16166 /** 16167 * start the oscillator 16168 */ 16169 _start(time) { 16170 this._modulator.start(time); 16171 this._carrier.start(time); 16172 } 16173 /** 16174 * stop the oscillator 16175 */ 16176 _stop(time) { 16177 this._modulator.stop(time); 16178 this._carrier.stop(time); 16179 } 16180 _restart(time) { 16181 this._modulator.restart(time); 16182 this._carrier.restart(time); 16183 } 16184 /** 16185 * The type of the carrier oscillator 16186 */ 16187 get type() { 16188 return this._carrier.type; 16189 } 16190 set type(type) { 16191 this._carrier.type = type; 16192 } 16193 get baseType() { 16194 return this._carrier.baseType; 16195 } 16196 set baseType(baseType) { 16197 this._carrier.baseType = baseType; 16198 } 16199 get partialCount() { 16200 return this._carrier.partialCount; 16201 } 16202 set partialCount(partialCount) { 16203 this._carrier.partialCount = partialCount; 16204 } 16205 /** 16206 * The type of the modulator oscillator 16207 */ 16208 get modulationType() { 16209 return this._modulator.type; 16210 } 16211 set modulationType(type) { 16212 this._modulator.type = type; 16213 } 16214 get phase() { 16215 return this._carrier.phase; 16216 } 16217 set phase(phase) { 16218 this._carrier.phase = phase; 16219 this._modulator.phase = phase; 16220 } 16221 get partials() { 16222 return this._carrier.partials; 16223 } 16224 set partials(partials) { 16225 this._carrier.partials = partials; 16226 } 16227 asArray() { 16228 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16229 return generateWaveform(this, length); 16230 }); 16231 } 16232 /** 16233 * Clean up. 16234 */ 16235 dispose() { 16236 super.dispose(); 16237 this.frequency.dispose(); 16238 this.detune.dispose(); 16239 this.harmonicity.dispose(); 16240 this._carrier.dispose(); 16241 this._modulator.dispose(); 16242 this._modulationNode.dispose(); 16243 this._modulationScale.dispose(); 16244 return this; 16245 } 16246}; 16247
vendor: 3,495 bytes, lines 16248-16386
16248// node_modules/tone/build/esm/source/oscillator/FMOscillator.js 16249var FMOscillator = class _FMOscillator extends Source { 16250 constructor() { 16251 const options = optionsFromArguments(_FMOscillator.getDefaults(), arguments, ["frequency", "type", "modulationType"]); 16252 super(options); 16253 this.name = "FMOscillator"; 16254 this._modulationNode = new Gain({ 16255 context: this.context, 16256 gain: 0 16257 }); 16258 this._carrier = new Oscillator({ 16259 context: this.context, 16260 detune: options.detune, 16261 frequency: 0, 16262 onstop: () => this.onstop(this), 16263 phase: options.phase, 16264 type: options.type 16265 }); 16266 this.detune = this._carrier.detune; 16267 this.frequency = new Signal({ 16268 context: this.context, 16269 units: "frequency", 16270 value: options.frequency 16271 }); 16272 this._modulator = new Oscillator({ 16273 context: this.context, 16274 phase: options.phase, 16275 type: options.modulationType 16276 }); 16277 this.harmonicity = new Multiply({ 16278 context: this.context, 16279 units: "positive", 16280 value: options.harmonicity 16281 }); 16282 this.modulationIndex = new Multiply({ 16283 context: this.context, 16284 units: "positive", 16285 value: options.modulationIndex 16286 }); 16287 this.frequency.connect(this._carrier.frequency); 16288 this.frequency.chain(this.harmonicity, this._modulator.frequency); 16289 this.frequency.chain(this.modulationIndex, this._modulationNode); 16290 this._modulator.connect(this._modulationNode.gain); 16291 this._modulationNode.connect(this._carrier.frequency); 16292 this._carrier.connect(this.output); 16293 this.detune.connect(this._modulator.detune); 16294 readOnly(this, [ 16295 "modulationIndex", 16296 "frequency", 16297 "detune", 16298 "harmonicity" 16299 ]); 16300 } 16301 static getDefaults() { 16302 return Object.assign(Oscillator.getDefaults(), { 16303 harmonicity: 1, 16304 modulationIndex: 2, 16305 modulationType: "square" 16306 }); 16307 } 16308 /** 16309 * start the oscillator 16310 */ 16311 _start(time) { 16312 this._modulator.start(time); 16313 this._carrier.start(time); 16314 } 16315 /** 16316 * stop the oscillator 16317 */ 16318 _stop(time) { 16319 this._modulator.stop(time); 16320 this._carrier.stop(time); 16321 } 16322 _restart(time) { 16323 this._modulator.restart(time); 16324 this._carrier.restart(time); 16325 return this; 16326 } 16327 get type() { 16328 return this._carrier.type; 16329 } 16330 set type(type) { 16331 this._carrier.type = type; 16332 } 16333 get baseType() { 16334 return this._carrier.baseType; 16335 } 16336 set baseType(baseType) { 16337 this._carrier.baseType = baseType; 16338 } 16339 get partialCount() { 16340 return this._carrier.partialCount; 16341 } 16342 set partialCount(partialCount) { 16343 this._carrier.partialCount = partialCount; 16344 } 16345 /** 16346 * The type of the modulator oscillator 16347 */ 16348 get modulationType() { 16349 return this._modulator.type; 16350 } 16351 set modulationType(type) { 16352 this._modulator.type = type; 16353 } 16354 get phase() { 16355 return this._carrier.phase; 16356 } 16357 set phase(phase) { 16358 this._carrier.phase = phase; 16359 this._modulator.phase = phase; 16360 } 16361 get partials() { 16362 return this._carrier.partials; 16363 } 16364 set partials(partials) { 16365 this._carrier.partials = partials; 16366 } 16367 asArray() { 16368 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16369 return generateWaveform(this, length); 16370 }); 16371 } 16372 /** 16373 * Clean up. 16374 */ 16375 dispose() { 16376 super.dispose(); 16377 this.frequency.dispose(); 16378 this.harmonicity.dispose(); 16379 this._carrier.dispose(); 16380 this._modulator.dispose(); 16381 this._modulationNode.dispose(); 16382 this.modulationIndex.dispose(); 16383 return this; 16384 } 16385}; 16386
vendor: 3,078 bytes, lines 16387-16509
16387// node_modules/tone/build/esm/source/oscillator/PulseOscillator.js 16388var PulseOscillator = class _PulseOscillator extends Source { 16389 constructor() { 16390 const options = optionsFromArguments(_PulseOscillator.getDefaults(), arguments, ["frequency", "width"]); 16391 super(options); 16392 this.name = "PulseOscillator"; 16393 this._widthGate = new Gain({ 16394 context: this.context, 16395 gain: 0 16396 }); 16397 this._thresh = new WaveShaper({ 16398 context: this.context, 16399 mapping: (val) => val <= 0 ? -1 : 1 16400 }); 16401 this.width = new Signal({ 16402 context: this.context, 16403 units: "audioRange", 16404 value: options.width 16405 }); 16406 this._triangle = new Oscillator({ 16407 context: this.context, 16408 detune: options.detune, 16409 frequency: options.frequency, 16410 onstop: () => this.onstop(this), 16411 phase: options.phase, 16412 type: "triangle" 16413 }); 16414 this.frequency = this._triangle.frequency; 16415 this.detune = this._triangle.detune; 16416 this._triangle.chain(this._thresh, this.output); 16417 this.width.chain(this._widthGate, this._thresh); 16418 readOnly(this, ["width", "frequency", "detune"]); 16419 } 16420 static getDefaults() { 16421 return Object.assign(Source.getDefaults(), { 16422 detune: 0, 16423 frequency: 440, 16424 phase: 0, 16425 type: "pulse", 16426 width: 0.2 16427 }); 16428 } 16429 /** 16430 * start the oscillator 16431 */ 16432 _start(time) { 16433 time = this.toSeconds(time); 16434 this._triangle.start(time); 16435 this._widthGate.gain.setValueAtTime(1, time); 16436 } 16437 /** 16438 * stop the oscillator 16439 */ 16440 _stop(time) { 16441 time = this.toSeconds(time); 16442 this._triangle.stop(time); 16443 this._widthGate.gain.cancelScheduledValues(time); 16444 this._widthGate.gain.setValueAtTime(0, time); 16445 } 16446 _restart(time) { 16447 this._triangle.restart(time); 16448 this._widthGate.gain.cancelScheduledValues(time); 16449 this._widthGate.gain.setValueAtTime(1, time); 16450 } 16451 /** 16452 * The phase of the oscillator in degrees. 16453 */ 16454 get phase() { 16455 return this._triangle.phase; 16456 } 16457 set phase(phase) { 16458 this._triangle.phase = phase; 16459 } 16460 /** 16461 * The type of the oscillator. Always returns "pulse". 16462 */ 16463 get type() { 16464 return "pulse"; 16465 } 16466 /** 16467 * The baseType of the oscillator. Always returns "pulse". 16468 */ 16469 get baseType() { 16470 return "pulse"; 16471 } 16472 /** 16473 * The partials of the waveform. Cannot set partials for this waveform type 16474 */ 16475 get partials() { 16476 return []; 16477 } 16478 /** 16479 * No partials for this waveform type. 16480 */ 16481 get partialCount() { 16482 return 0; 16483 } 16484 /** 16485 * *Internal use* The carrier oscillator type is fed through the 16486 * waveshaper node to create the pulse. Using different carrier oscillators 16487 * changes oscillator's behavior. 16488 */ 16489 set carrierType(type) { 16490 this._triangle.type = type; 16491 } 16492 asArray() { 16493 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16494 return generateWaveform(this, length); 16495 }); 16496 } 16497 /** 16498 * Clean up method. 16499 */ 16500 dispose() { 16501 super.dispose(); 16502 this._triangle.dispose(); 16503 this.width.dispose(); 16504 this._widthGate.dispose(); 16505 this._thresh.dispose(); 16506 return this; 16507 } 16508}; 16509
vendor: 4,847 bytes, lines 16510-16685
16510// node_modules/tone/build/esm/source/oscillator/FatOscillator.js 16511var FatOscillator = class _FatOscillator extends Source { 16512 constructor() { 16513 const options = optionsFromArguments(_FatOscillator.getDefaults(), arguments, ["frequency", "type", "spread"]); 16514 super(options); 16515 this.name = "FatOscillator"; 16516 this._oscillators = []; 16517 this.frequency = new Signal({ 16518 context: this.context, 16519 units: "frequency", 16520 value: options.frequency 16521 }); 16522 this.detune = new Signal({ 16523 context: this.context, 16524 units: "cents", 16525 value: options.detune 16526 }); 16527 this._spread = options.spread; 16528 this._type = options.type; 16529 this._phase = options.phase; 16530 this._partials = options.partials; 16531 this._partialCount = options.partialCount; 16532 this.count = options.count; 16533 readOnly(this, ["frequency", "detune"]); 16534 } 16535 static getDefaults() { 16536 return Object.assign(Oscillator.getDefaults(), { 16537 count: 3, 16538 spread: 20, 16539 type: "sawtooth" 16540 }); 16541 } 16542 /** 16543 * start the oscillator 16544 */ 16545 _start(time) { 16546 time = this.toSeconds(time); 16547 this._forEach((osc) => osc.start(time)); 16548 } 16549 /** 16550 * stop the oscillator 16551 */ 16552 _stop(time) { 16553 time = this.toSeconds(time); 16554 this._forEach((osc) => osc.stop(time)); 16555 } 16556 _restart(time) { 16557 this._forEach((osc) => osc.restart(time)); 16558 } 16559 /** 16560 * Iterate over all of the oscillators 16561 */ 16562 _forEach(iterator) { 16563 for (let i = 0; i < this._oscillators.length; i++) { 16564 iterator(this._oscillators[i], i); 16565 } 16566 } 16567 /** 16568 * The type of the oscillator 16569 */ 16570 get type() { 16571 return this._type; 16572 } 16573 set type(type) { 16574 this._type = type; 16575 this._forEach((osc) => osc.type = type); 16576 } 16577 /** 16578 * The detune spread between the oscillators. If "count" is 16579 * set to 3 oscillators and the "spread" is set to 40, 16580 * the three oscillators would be detuned like this: [-20, 0, 20] 16581 * for a total detune spread of 40 cents. 16582 * @example 16583 * const fatOsc = new Tone.FatOscillator().toDestination().start(); 16584 * fatOsc.spread = 70; 16585 */ 16586 get spread() { 16587 return this._spread; 16588 } 16589 set spread(spread) { 16590 this._spread = spread; 16591 if (this._oscillators.length > 1) { 16592 const start2 = -spread / 2; 16593 const step = spread / (this._oscillators.length - 1); 16594 this._forEach((osc, i) => osc.detune.value = start2 + step * i); 16595 } 16596 } 16597 /** 16598 * The number of detuned oscillators. Must be an integer greater than 1. 16599 * @example 16600 * const fatOsc = new Tone.FatOscillator("C#3", "sawtooth").toDestination().start(); 16601 * // use 4 sawtooth oscillators 16602 * fatOsc.count = 4; 16603 */ 16604 get count() { 16605 return this._oscillators.length; 16606 } 16607 set count(count) { 16608 assertRange(count, 1); 16609 if (this._oscillators.length !== count) { 16610 this._forEach((osc) => osc.dispose()); 16611 this._oscillators = []; 16612 for (let i = 0; i < count; i++) { 16613 const osc = new Oscillator({ 16614 context: this.context, 16615 volume: -6 - count * 1.1, 16616 type: this._type, 16617 phase: this._phase + i / count * 360, 16618 partialCount: this._partialCount, 16619 onstop: i === 0 ? () => this.onstop(this) : noOp 16620 }); 16621 if (this.type === "custom") { 16622 osc.partials = this._partials; 16623 } 16624 this.frequency.connect(osc.frequency); 16625 this.detune.connect(osc.detune); 16626 osc.detune.overridden = false; 16627 osc.connect(this.output); 16628 this._oscillators[i] = osc; 16629 } 16630 this.spread = this._spread; 16631 if (this.state === "started") { 16632 this._forEach((osc) => osc.start()); 16633 } 16634 } 16635 } 16636 get phase() { 16637 return this._phase; 16638 } 16639 set phase(phase) { 16640 this._phase = phase; 16641 this._forEach((osc, i) => osc.phase = this._phase + i / this.count * 360); 16642 } 16643 get baseType() { 16644 return this._oscillators[0].baseType; 16645 } 16646 set baseType(baseType) { 16647 this._forEach((osc) => osc.baseType = baseType); 16648 this._type = this._oscillators[0].type; 16649 } 16650 get partials() { 16651 return this._oscillators[0].partials; 16652 } 16653 set partials(partials) { 16654 this._partials = partials; 16655 this._partialCount = this._partials.length; 16656 if (partials.length) { 16657 this._type = "custom"; 16658 this._forEach((osc) => osc.partials = partials); 16659 } 16660 } 16661 get partialCount() { 16662 return this._oscillators[0].partialCount; 16663 } 16664 set partialCount(partialCount) { 16665 this._partialCount = partialCount; 16666 this._forEach((osc) => osc.partialCount = partialCount); 16667 this._type = this._oscillators[0].type; 16668 } 16669 asArray() { 16670 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16671 return generateWaveform(this, length); 16672 }); 16673 } 16674 /** 16675 * Clean up. 16676 */ 16677 dispose() { 16678 super.dispose(); 16679 this.frequency.dispose(); 16680 this.detune.dispose(); 16681 this._forEach((osc) => osc.dispose()); 16682 return this; 16683 } 16684}; 16685
vendor: 2,661 bytes, lines 16686-16797
16686// node_modules/tone/build/esm/source/oscillator/PWMOscillator.js 16687var PWMOscillator = class _PWMOscillator extends Source { 16688 constructor() { 16689 const options = optionsFromArguments(_PWMOscillator.getDefaults(), arguments, ["frequency", "modulationFrequency"]); 16690 super(options); 16691 this.name = "PWMOscillator"; 16692 this.sourceType = "pwm"; 16693 this._scale = new Multiply({ 16694 context: this.context, 16695 value: 2 16696 }); 16697 this._pulse = new PulseOscillator({ 16698 context: this.context, 16699 frequency: options.modulationFrequency 16700 }); 16701 this._pulse.carrierType = "sine"; 16702 this.modulationFrequency = this._pulse.frequency; 16703 this._modulator = new Oscillator({ 16704 context: this.context, 16705 detune: options.detune, 16706 frequency: options.frequency, 16707 onstop: () => this.onstop(this), 16708 phase: options.phase 16709 }); 16710 this.frequency = this._modulator.frequency; 16711 this.detune = this._modulator.detune; 16712 this._modulator.chain(this._scale, this._pulse.width); 16713 this._pulse.connect(this.output); 16714 readOnly(this, ["modulationFrequency", "frequency", "detune"]); 16715 } 16716 static getDefaults() { 16717 return Object.assign(Source.getDefaults(), { 16718 detune: 0, 16719 frequency: 440, 16720 modulationFrequency: 0.4, 16721 phase: 0, 16722 type: "pwm" 16723 }); 16724 } 16725 /** 16726 * start the oscillator 16727 */ 16728 _start(time) { 16729 time = this.toSeconds(time); 16730 this._modulator.start(time); 16731 this._pulse.start(time); 16732 } 16733 /** 16734 * stop the oscillator 16735 */ 16736 _stop(time) { 16737 time = this.toSeconds(time); 16738 this._modulator.stop(time); 16739 this._pulse.stop(time); 16740 } 16741 /** 16742 * restart the oscillator 16743 */ 16744 _restart(time) { 16745 this._modulator.restart(time); 16746 this._pulse.restart(time); 16747 } 16748 /** 16749 * The type of the oscillator. Always returns "pwm". 16750 */ 16751 get type() { 16752 return "pwm"; 16753 } 16754 /** 16755 * The baseType of the oscillator. Always returns "pwm". 16756 */ 16757 get baseType() { 16758 return "pwm"; 16759 } 16760 /** 16761 * The partials of the waveform. Cannot set partials for this waveform type 16762 */ 16763 get partials() { 16764 return []; 16765 } 16766 /** 16767 * No partials for this waveform type. 16768 */ 16769 get partialCount() { 16770 return 0; 16771 } 16772 /** 16773 * The phase of the oscillator in degrees. 16774 */ 16775 get phase() { 16776 return this._modulator.phase; 16777 } 16778 set phase(phase) { 16779 this._modulator.phase = phase; 16780 } 16781 asArray() { 16782 return __awaiter(this, arguments, void 0, function* (length = 1024) { 16783 return generateWaveform(this, length); 16784 }); 16785 } 16786 /** 16787 * Clean up. 16788 */ 16789 dispose() { 16790 super.dispose(); 16791 this._pulse.dispose(); 16792 this._scale.dispose(); 16793 this._modulator.dispose(); 16794 return this; 16795 } 16796}; 16797
vendor: 9,196 bytes, lines 16798-17100
16798// node_modules/tone/build/esm/source/oscillator/OmniOscillator.js 16799var OmniOscillatorSourceMap = { 16800 am: AMOscillator, 16801 fat: FatOscillator, 16802 fm: FMOscillator, 16803 oscillator: Oscillator, 16804 pulse: PulseOscillator, 16805 pwm: PWMOscillator 16806}; 16807var OmniOscillator = class _OmniOscillator extends Source { 16808 constructor() { 16809 const options = optionsFromArguments(_OmniOscillator.getDefaults(), arguments, ["frequency", "type"]); 16810 super(options); 16811 this.name = "OmniOscillator"; 16812 this.frequency = new Signal({ 16813 context: this.context, 16814 units: "frequency", 16815 value: options.frequency 16816 }); 16817 this.detune = new Signal({ 16818 context: this.context, 16819 units: "cents", 16820 value: options.detune 16821 }); 16822 readOnly(this, ["frequency", "detune"]); 16823 this.set(options); 16824 } 16825 static getDefaults() { 16826 return Object.assign(Oscillator.getDefaults(), FMOscillator.getDefaults(), AMOscillator.getDefaults(), FatOscillator.getDefaults(), PulseOscillator.getDefaults(), PWMOscillator.getDefaults()); 16827 } 16828 /** 16829 * start the oscillator 16830 */ 16831 _start(time) { 16832 this._oscillator.start(time); 16833 } 16834 /** 16835 * start the oscillator 16836 */ 16837 _stop(time) { 16838 this._oscillator.stop(time); 16839 } 16840 _restart(time) { 16841 this._oscillator.restart(time); 16842 return this; 16843 } 16844 /** 16845 * The type of the oscillator. Can be any of the basic types: sine, square, triangle, sawtooth. Or 16846 * prefix the basic types with "fm", "am", or "fat" to use the FMOscillator, AMOscillator or FatOscillator 16847 * types. The oscillator could also be set to "pwm" or "pulse". All of the parameters of the 16848 * oscillator's class are accessible when the oscillator is set to that type, but throws an error 16849 * when it's not. 16850 * @example 16851 * const omniOsc = new Tone.OmniOscillator().toDestination().start(); 16852 * omniOsc.type = "pwm"; 16853 * // modulationFrequency is parameter which is available 16854 * // only when the type is "pwm". 16855 * omniOsc.modulationFrequency.value = 0.5; 16856 */ 16857 get type() { 16858 let prefix = ""; 16859 if (["am", "fm", "fat"].some((p) => this._sourceType === p)) { 16860 prefix = this._sourceType; 16861 } 16862 return prefix + this._oscillator.type; 16863 } 16864 set type(type) { 16865 if (type.substr(0, 2) === "fm") { 16866 this._createNewOscillator("fm"); 16867 this._oscillator = this._oscillator; 16868 this._oscillator.type = type.substr(2); 16869 } else if (type.substr(0, 2) === "am") { 16870 this._createNewOscillator("am"); 16871 this._oscillator = this._oscillator; 16872 this._oscillator.type = type.substr(2); 16873 } else if (type.substr(0, 3) === "fat") { 16874 this._createNewOscillator("fat"); 16875 this._oscillator = this._oscillator; 16876 this._oscillator.type = type.substr(3); 16877 } else if (type === "pwm") { 16878 this._createNewOscillator("pwm"); 16879 this._oscillator = this._oscillator; 16880 } else if (type === "pulse") { 16881 this._createNewOscillator("pulse"); 16882 } else { 16883 this._createNewOscillator("oscillator"); 16884 this._oscillator = this._oscillator; 16885 this._oscillator.type = type; 16886 } 16887 } 16888 /** 16889 * The value is an empty array when the type is not "custom". 16890 * This is not available on "pwm" and "pulse" oscillator types. 16891 * @see {@link Oscillator.partials} 16892 */ 16893 get partials() { 16894 return this._oscillator.partials; 16895 } 16896 set partials(partials) { 16897 if (!this._getOscType(this._oscillator, "pulse") && !this._getOscType(this._oscillator, "pwm")) { 16898 this._oscillator.partials = partials; 16899 } 16900 } 16901 get partialCount() { 16902 return this._oscillator.partialCount; 16903 } 16904 set partialCount(partialCount) { 16905 if (!this._getOscType(this._oscillator, "pulse") && !this._getOscType(this._oscillator, "pwm")) { 16906 this._oscillator.partialCount = partialCount; 16907 } 16908 } 16909 set(props) { 16910 if (Reflect.has(props, "type") && props.type) { 16911 this.type = props.type; 16912 } 16913 super.set(props); 16914 return this; 16915 } 16916 /** 16917 * connect the oscillator to the frequency and detune signals 16918 */ 16919 _createNewOscillator(oscType) { 16920 if (oscType !== this._sourceType) { 16921 this._sourceType = oscType; 16922 const OscConstructor = OmniOscillatorSourceMap[oscType]; 16923 const now = this.now(); 16924 if (this._oscillator) { 16925 const oldOsc = this._oscillator; 16926 oldOsc.stop(now); 16927 this.context.setTimeout(() => oldOsc.dispose(), this.blockTime); 16928 } 16929 this._oscillator = new OscConstructor({ 16930 context: this.context 16931 }); 16932 this.frequency.connect(this._oscillator.frequency); 16933 this.detune.connect(this._oscillator.detune); 16934 this._oscillator.connect(this.output); 16935 this._oscillator.onstop = () => this.onstop(this); 16936 if (this.state === "started") { 16937 this._oscillator.start(now); 16938 } 16939 } 16940 } 16941 get phase() { 16942 return this._oscillator.phase; 16943 } 16944 set phase(phase) { 16945 this._oscillator.phase = phase; 16946 } 16947 /** 16948 * The source type of the oscillator. 16949 * @example 16950 * const omniOsc = new Tone.OmniOscillator(440, "fmsquare"); 16951 * console.log(omniOsc.sourceType); // 'fm' 16952 */ 16953 get sourceType() { 16954 return this._sourceType; 16955 } 16956 set sourceType(sType) { 16957 let baseType = "sine"; 16958 if (this._oscillator.type !== "pwm" && this._oscillator.type !== "pulse") { 16959 baseType = this._oscillator.type; 16960 } 16961 if (sType === "fm") { 16962 this.type = "fm" + baseType; 16963 } else if (sType === "am") { 16964 this.type = "am" + baseType; 16965 } else if (sType === "fat") { 16966 this.type = "fat" + baseType; 16967 } else if (sType === "oscillator") { 16968 this.type = baseType; 16969 } else if (sType === "pulse") { 16970 this.type = "pulse"; 16971 } else if (sType === "pwm") { 16972 this.type = "pwm"; 16973 } 16974 } 16975 _getOscType(osc, sourceType) { 16976 return osc instanceof OmniOscillatorSourceMap[sourceType]; 16977 } 16978 /** 16979 * The base type of the oscillator. 16980 * @see {@link Oscillator.baseType} 16981 * @example 16982 * const omniOsc = new Tone.OmniOscillator(440, "fmsquare4"); 16983 * console.log(omniOsc.sourceType, omniOsc.baseType, omniOsc.partialCount); 16984 */ 16985 get baseType() { 16986 return this._oscillator.baseType; 16987 } 16988 set baseType(baseType) { 16989 if (!this._getOscType(this._oscillator, "pulse") && !this._getOscType(this._oscillator, "pwm") && baseType !== "pulse" && baseType !== "pwm") { 16990 this._oscillator.baseType = baseType; 16991 } 16992 } 16993 /** 16994 * The width of the oscillator when sourceType === "pulse". 16995 * @see {@link PWMOscillator} 16996 */ 16997 get width() { 16998 if (this._getOscType(this._oscillator, "pulse")) { 16999 return this._oscillator.width; 17000 } else { 17001 return void 0; 17002 } 17003 } 17004 /** 17005 * The number of detuned oscillators when sourceType === "fat". 17006 * @see {@link FatOscillator.count} 17007 */ 17008 get count() { 17009 if (this._getOscType(this._oscillator, "fat")) { 17010 return this._oscillator.count; 17011 } else { 17012 return void 0; 17013 } 17014 } 17015 set count(count) { 17016 if (this._getOscType(this._oscillator, "fat") && isNumber(count)) { 17017 this._oscillator.count = count; 17018 } 17019 } 17020 /** 17021 * The detune spread between the oscillators when sourceType === "fat". 17022 * @see {@link FatOscillator.count} 17023 */ 17024 get spread() { 17025 if (this._getOscType(this._oscillator, "fat")) { 17026 return this._oscillator.spread; 17027 } else { 17028 return void 0; 17029 } 17030 } 17031 set spread(spread) { 17032 if (this._getOscType(this._oscillator, "fat") && isNumber(spread)) { 17033 this._oscillator.spread = spread; 17034 } 17035 } 17036 /** 17037 * The type of the modulator oscillator. Only if the oscillator is set to "am" or "fm" types. 17038 * @see {@link AMOscillator} or {@link FMOscillator} 17039 */ 17040 get modulationType() { 17041 if (this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) { 17042 return this._oscillator.modulationType; 17043 } else { 17044 return void 0; 17045 } 17046 } 17047 set modulationType(mType) { 17048 if ((this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) && isString(mType)) { 17049 this._oscillator.modulationType = mType; 17050 } 17051 } 17052 /** 17053 * The modulation index when the sourceType === "fm" 17054 * @see {@link FMOscillator}. 17055 */ 17056 get modulationIndex() { 17057 if (this._getOscType(this._oscillator, "fm")) { 17058 return this._oscillator.modulationIndex; 17059 } else { 17060 return void 0; 17061 } 17062 } 17063 /** 17064 * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. 17065 * @see {@link AMOscillator} or {@link FMOscillator} 17066 */ 17067 get harmonicity() { 17068 if (this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) { 17069 return this._oscillator.harmonicity; 17070 } else { 17071 return void 0; 17072 } 17073 } 17074 /** 17075 * The modulationFrequency Signal of the oscillator when sourceType === "pwm" 17076 * see {@link PWMOscillator} 17077 * @min 0.1 17078 * @max 5 17079 */ 17080 get modulationFrequency() { 17081 if (this._getOscType(this._oscillator, "pwm")) { 17082 return this._oscillator.modulationFrequency; 17083 } else { 17084 return void 0; 17085 } 17086 } 17087 asArray() { 17088 return __awaiter(this, arguments, void 0, function* (length = 1024) { 17089 return generateWaveform(this, length); 17090 }); 17091 } 17092 dispose() { 17093 super.dispose(); 17094 this.detune.dispose(); 17095 this.frequency.dispose(); 17096 this._oscillator.dispose(); 17097 return this; 17098 } 17099}; 17100
vendor: 609 bytes, lines 17101-17124
17101// node_modules/tone/build/esm/signal/Add.js 17102var Add = class _Add extends Signal { 17103 constructor() { 17104 super(optionsFromArguments(_Add.getDefaults(), arguments, ["value"])); 17105 this.override = false; 17106 this.name = "Add"; 17107 this._sum = new Gain({ context: this.context }); 17108 this.input = this._sum; 17109 this.output = this._sum; 17110 this.addend = this._param; 17111 connectSeries(this._constantSource, this._sum); 17112 } 17113 static getDefaults() { 17114 return Object.assign(Signal.getDefaults(), { 17115 value: 0 17116 }); 17117 } 17118 dispose() { 17119 super.dispose(); 17120 this._sum.dispose(); 17121 return this; 17122 } 17123}; 17124
vendor: 1,358 bytes, lines 17125-17186
17125// node_modules/tone/build/esm/signal/Scale.js 17126var Scale = class _Scale extends SignalOperator { 17127 constructor() { 17128 const options = optionsFromArguments(_Scale.getDefaults(), arguments, [ 17129 "min", 17130 "max" 17131 ]); 17132 super(options); 17133 this.name = "Scale"; 17134 this._mult = this.input = new Multiply({ 17135 context: this.context, 17136 value: options.max - options.min 17137 }); 17138 this._add = this.output = new Add({ 17139 context: this.context, 17140 value: options.min 17141 }); 17142 this._min = options.min; 17143 this._max = options.max; 17144 this.input.connect(this.output); 17145 } 17146 static getDefaults() { 17147 return Object.assign(SignalOperator.getDefaults(), { 17148 max: 1, 17149 min: 0 17150 }); 17151 } 17152 /** 17153 * The minimum output value. This number is output when the value input value is 0. 17154 */ 17155 get min() { 17156 return this._min; 17157 } 17158 set min(min) { 17159 this._min = min; 17160 this._setRange(); 17161 } 17162 /** 17163 * The maximum output value. This number is output when the value input value is 1. 17164 */ 17165 get max() { 17166 return this._max; 17167 } 17168 set max(max) { 17169 this._max = max; 17170 this._setRange(); 17171 } 17172 /** 17173 * set the values 17174 */ 17175 _setRange() { 17176 this._add.value = this._min; 17177 this._mult.value = this._max - this._min; 17178 } 17179 dispose() { 17180 super.dispose(); 17181 this._add.dispose(); 17182 this._mult.dispose(); 17183 return this; 17184 } 17185}; 17186
vendor: 511 bytes, lines 17187-17206
17187// node_modules/tone/build/esm/signal/Zero.js 17188var Zero = class _Zero extends SignalOperator { 17189 constructor() { 17190 super(optionsFromArguments(_Zero.getDefaults(), arguments)); 17191 this.name = "Zero"; 17192 this._gain = new Gain({ context: this.context }); 17193 this.output = this._gain; 17194 this.input = void 0; 17195 connect(this.context.getConstant(0), this._gain); 17196 } 17197 /** 17198 * clean up 17199 */ 17200 dispose() { 17201 super.dispose(); 17202 disconnect(this.context.getConstant(0), this._gain); 17203 return this; 17204 } 17205}; 17206
vendor: 5,077 bytes, lines 17207-17407
17207// node_modules/tone/build/esm/source/oscillator/LFO.js 17208var LFO = class _LFO extends ToneAudioNode { 17209 constructor() { 17210 const options = optionsFromArguments(_LFO.getDefaults(), arguments, [ 17211 "frequency", 17212 "min", 17213 "max" 17214 ]); 17215 super(options); 17216 this.name = "LFO"; 17217 this._stoppedValue = 0; 17218 this._units = "number"; 17219 this.convert = true; 17220 this._fromType = Param.prototype._fromType; 17221 this._toType = Param.prototype._toType; 17222 this._is = Param.prototype._is; 17223 this._clampValue = Param.prototype._clampValue; 17224 this._oscillator = new Oscillator(options); 17225 this.frequency = this._oscillator.frequency; 17226 this._amplitudeGain = new Gain({ 17227 context: this.context, 17228 gain: options.amplitude, 17229 units: "normalRange" 17230 }); 17231 this.amplitude = this._amplitudeGain.gain; 17232 this._stoppedSignal = new Signal({ 17233 context: this.context, 17234 units: "audioRange", 17235 value: 0 17236 }); 17237 this._zeros = new Zero({ context: this.context }); 17238 this._a2g = new AudioToGain({ context: this.context }); 17239 this._scaler = this.output = new Scale({ 17240 context: this.context, 17241 max: options.max, 17242 min: options.min 17243 }); 17244 this.units = options.units; 17245 this.min = options.min; 17246 this.max = options.max; 17247 this._oscillator.chain(this._amplitudeGain, this._a2g, this._scaler); 17248 this._zeros.connect(this._a2g); 17249 this._stoppedSignal.connect(this._a2g); 17250 readOnly(this, ["amplitude", "frequency"]); 17251 this.phase = options.phase; 17252 } 17253 static getDefaults() { 17254 return Object.assign(Oscillator.getDefaults(), { 17255 amplitude: 1, 17256 frequency: "4n", 17257 max: 1, 17258 min: 0, 17259 type: "sine", 17260 units: "number" 17261 }); 17262 } 17263 /** 17264 * Start the LFO. 17265 * @param time The time the LFO will start 17266 */ 17267 start(time) { 17268 time = this.toSeconds(time); 17269 this._stoppedSignal.setValueAtTime(0, time); 17270 this._oscillator.start(time); 17271 return this; 17272 } 17273 /** 17274 * Stop the LFO. 17275 * @param time The time the LFO will stop 17276 */ 17277 stop(time) { 17278 time = this.toSeconds(time); 17279 this._stoppedSignal.setValueAtTime(this._stoppedValue, time); 17280 this._oscillator.stop(time); 17281 return this; 17282 } 17283 /** 17284 * Sync the start/stop/pause to the transport 17285 * and the frequency to the bpm of the transport 17286 * @example 17287 * const lfo = new Tone.LFO("8n"); 17288 * lfo.sync().start(0); 17289 * // the rate of the LFO will always be an eighth note, even as the tempo changes 17290 */ 17291 sync() { 17292 this._oscillator.sync(); 17293 this._oscillator.syncFrequency(); 17294 return this; 17295 } 17296 /** 17297 * unsync the LFO from transport control 17298 */ 17299 unsync() { 17300 this._oscillator.unsync(); 17301 this._oscillator.unsyncFrequency(); 17302 return this; 17303 } 17304 /** 17305 * After the oscillator waveform is updated, reset the `_stoppedSignal` value to match the updated waveform 17306 */ 17307 _setStoppedValue() { 17308 this._stoppedValue = this._oscillator.getInitialValue(); 17309 this._stoppedSignal.value = this._stoppedValue; 17310 } 17311 /** 17312 * The minimum output of the LFO. 17313 */ 17314 get min() { 17315 return this._toType(this._scaler.min); 17316 } 17317 set min(min) { 17318 min = this._fromType(min); 17319 this._scaler.min = min; 17320 } 17321 /** 17322 * The maximum output of the LFO. 17323 */ 17324 get max() { 17325 return this._toType(this._scaler.max); 17326 } 17327 set max(max) { 17328 max = this._fromType(max); 17329 this._scaler.max = max; 17330 } 17331 /** 17332 * The type of the oscillator. 17333 * @see {@link Oscillator.type} 17334 */ 17335 get type() { 17336 return this._oscillator.type; 17337 } 17338 set type(type) { 17339 this._oscillator.type = type; 17340 this._setStoppedValue(); 17341 } 17342 /** 17343 * The oscillator's partials array. 17344 * @see {@link Oscillator.partials} 17345 */ 17346 get partials() { 17347 return this._oscillator.partials; 17348 } 17349 set partials(partials) { 17350 this._oscillator.partials = partials; 17351 this._setStoppedValue(); 17352 } 17353 /** 17354 * The phase of the LFO. 17355 */ 17356 get phase() { 17357 return this._oscillator.phase; 17358 } 17359 set phase(phase) { 17360 this._oscillator.phase = phase; 17361 this._setStoppedValue(); 17362 } 17363 /** 17364 * The output units of the LFO. 17365 */ 17366 get units() { 17367 return this._units; 17368 } 17369 set units(val) { 17370 const currentMin = this.min; 17371 const currentMax = this.max; 17372 this._units = val; 17373 this.min = currentMin; 17374 this.max = currentMax; 17375 } 17376 /** 17377 * Returns the playback state of the source, either "started" or "stopped". 17378 */ 17379 get state() { 17380 return this._oscillator.state; 17381 } 17382 /** 17383 * @param node the destination to connect to 17384 * @param outputNum the optional output number 17385 * @param inputNum the input number 17386 */ 17387 connect(node, outputNum, inputNum) { 17388 if (node instanceof Param || node instanceof Signal) { 17389 this.convert = node.convert; 17390 this.units = node.units; 17391 } 17392 connectSignal(this, node, outputNum, inputNum); 17393 return this; 17394 } 17395 dispose() { 17396 super.dispose(); 17397 this._oscillator.dispose(); 17398 this._stoppedSignal.dispose(); 17399 this._zeros.dispose(); 17400 this._scaler.dispose(); 17401 this._a2g.dispose(); 17402 this._amplitudeGain.dispose(); 17403 this.amplitude.dispose(); 17404 return this; 17405 } 17406}; 17407
vendor: 937 bytes, lines 17408-17441
17408// node_modules/tone/build/esm/core/util/Decorator.js 17409function range(min, max = Infinity) { 17410 const valueMap = /* @__PURE__ */ new WeakMap(); 17411 return function(target, propertyKey) { 17412 Reflect.defineProperty(target, propertyKey, { 17413 configurable: true, 17414 enumerable: true, 17415 get: function() { 17416 return valueMap.get(this); 17417 }, 17418 set: function(newValue) { 17419 assertRange(newValue, min, max); 17420 valueMap.set(this, newValue); 17421 } 17422 }); 17423 }; 17424} 17425function timeRange(min, max = Infinity) { 17426 const valueMap = /* @__PURE__ */ new WeakMap(); 17427 return function(target, propertyKey) { 17428 Reflect.defineProperty(target, propertyKey, { 17429 configurable: true, 17430 enumerable: true, 17431 get: function() { 17432 return valueMap.get(this); 17433 }, 17434 set: function(newValue) { 17435 assertRange(this.toSeconds(newValue), min, max); 17436 valueMap.set(this, newValue); 17437 } 17438 }); 17439 }; 17440} 17441
vendor: 9,538 bytes, lines 17442-17750
17442// node_modules/tone/build/esm/source/buffer/Player.js 17443var Player = class _Player extends Source { 17444 constructor() { 17445 const options = optionsFromArguments(_Player.getDefaults(), arguments, [ 17446 "url", 17447 "onload" 17448 ]); 17449 super(options); 17450 this.name = "Player"; 17451 this._activeSources = /* @__PURE__ */ new Set(); 17452 this._buffer = new ToneAudioBuffer({ 17453 onload: this._onload.bind(this, options.onload), 17454 onerror: options.onerror, 17455 reverse: options.reverse, 17456 url: options.url 17457 }); 17458 this.autostart = options.autostart; 17459 this._loop = options.loop; 17460 this._loopStart = options.loopStart; 17461 this._loopEnd = options.loopEnd; 17462 this._playbackRate = options.playbackRate; 17463 this.fadeIn = options.fadeIn; 17464 this.fadeOut = options.fadeOut; 17465 } 17466 static getDefaults() { 17467 return Object.assign(Source.getDefaults(), { 17468 autostart: false, 17469 fadeIn: 0, 17470 fadeOut: 0, 17471 loop: false, 17472 loopEnd: 0, 17473 loopStart: 0, 17474 onload: noOp, 17475 onerror: noOp, 17476 playbackRate: 1, 17477 reverse: false 17478 }); 17479 } 17480 /** 17481 * Load the audio file as an audio buffer. 17482 * Decodes the audio asynchronously and invokes 17483 * the callback once the audio buffer loads. 17484 * Note: this does not need to be called if a url 17485 * was passed in to the constructor. Only use this 17486 * if you want to manually load a new url. 17487 * @param url The url of the buffer to load. Filetype support depends on the browser. 17488 */ 17489 load(url) { 17490 return __awaiter(this, void 0, void 0, function* () { 17491 yield this._buffer.load(url); 17492 this._onload(); 17493 return this; 17494 }); 17495 } 17496 /** 17497 * Internal callback when the buffer is loaded. 17498 */ 17499 _onload(callback = noOp) { 17500 callback(); 17501 if (this.autostart) { 17502 this.start(); 17503 } 17504 } 17505 /** 17506 * Internal callback when the buffer is done playing. 17507 */ 17508 _onSourceEnd(source) { 17509 this.onstop(this); 17510 this._activeSources.delete(source); 17511 if (this._activeSources.size === 0 && !this._synced && this._state.getValueAtTime(this.now()) === "started") { 17512 this._state.cancel(this.now()); 17513 this._state.setStateAtTime("stopped", this.now()); 17514 } 17515 } 17516 /** 17517 * Play the buffer at the given startTime. Optionally add an offset 17518 * and/or duration which will play the buffer from a position 17519 * within the buffer for the given duration. 17520 * 17521 * @param time When the player should start. 17522 * @param offset The offset from the beginning of the sample to start at. 17523 * @param duration How long the sample should play. If no duration is given, it will default to the full length of the sample (minus any offset) 17524 */ 17525 start(time, offset, duration) { 17526 super.start(time, offset, duration); 17527 return this; 17528 } 17529 /** 17530 * Internal start method 17531 */ 17532 _start(startTime, offset, duration) { 17533 if (this._loop) { 17534 offset = defaultArg(offset, this._loopStart); 17535 } else { 17536 offset = defaultArg(offset, 0); 17537 } 17538 const computedOffset = this.toSeconds(offset); 17539 const origDuration = duration; 17540 duration = defaultArg(duration, Math.max(this._buffer.duration - computedOffset, 0)); 17541 let computedDuration = this.toSeconds(duration); 17542 computedDuration = computedDuration / this._playbackRate; 17543 startTime = this.toSeconds(startTime); 17544 const source = new ToneBufferSource({ 17545 url: this._buffer, 17546 context: this.context, 17547 fadeIn: this.fadeIn, 17548 fadeOut: this.fadeOut, 17549 loop: this._loop, 17550 loopEnd: this._loopEnd, 17551 loopStart: this._loopStart, 17552 onended: this._onSourceEnd.bind(this), 17553 playbackRate: this._playbackRate 17554 }).connect(this.output); 17555 if (!this._loop && !this._synced) { 17556 this._state.cancel(startTime + computedDuration); 17557 this._state.setStateAtTime("stopped", startTime + computedDuration, { 17558 implicitEnd: true 17559 }); 17560 } 17561 this._activeSources.add(source); 17562 if (this._loop && isUndef(origDuration)) { 17563 source.start(startTime, computedOffset); 17564 } else { 17565 source.start(startTime, computedOffset, computedDuration - this.toSeconds(this.fadeOut)); 17566 } 17567 } 17568 /** 17569 * Stop playback. 17570 */ 17571 _stop(time) { 17572 const computedTime = this.toSeconds(time); 17573 this._activeSources.forEach((source) => source.stop(computedTime)); 17574 } 17575 /** 17576 * Stop and then restart the player from the beginning (or offset) 17577 * @param time When the player should start. 17578 * @param offset The offset from the beginning of the sample to start at. 17579 * @param duration How long the sample should play. If no duration is given, 17580 * it will default to the full length of the sample (minus any offset) 17581 */ 17582 restart(time, offset, duration) { 17583 super.restart(time, offset, duration); 17584 return this; 17585 } 17586 _restart(time, offset, duration) { 17587 var _a; 17588 (_a = [...this._activeSources].pop()) === null || _a === void 0 ? void 0 : _a.stop(time); 17589 this._start(time, offset, duration); 17590 } 17591 /** 17592 * Seek to a specific time in the player's buffer. If the 17593 * source is no longer playing at that time, it will stop. 17594 * @param offset The time to seek to. 17595 * @param when The time for the seek event to occur. 17596 * @example 17597 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/gurgling_theremin_1.mp3", () => { 17598 * player.start(); 17599 * // seek to the offset in 1 second from now 17600 * player.seek(0.4, "+1"); 17601 * }).toDestination(); 17602 */ 17603 seek(offset, when) { 17604 const computedTime = this.toSeconds(when); 17605 if (this._state.getValueAtTime(computedTime) === "started") { 17606 const computedOffset = this.toSeconds(offset); 17607 this._stop(computedTime); 17608 this._start(computedTime, computedOffset); 17609 } 17610 return this; 17611 } 17612 /** 17613 * Set the loop start and end. Will only loop if loop is set to true. 17614 * @param loopStart The loop start time 17615 * @param loopEnd The loop end time 17616 * @example 17617 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/malevoices_aa2_F3.mp3").toDestination(); 17618 * // loop between the given points 17619 * player.setLoopPoints(0.2, 0.3); 17620 * player.loop = true; 17621 * player.autostart = true; 17622 */ 17623 setLoopPoints(loopStart, loopEnd) { 17624 this.loopStart = loopStart; 17625 this.loopEnd = loopEnd; 17626 return this; 17627 } 17628 /** 17629 * If loop is true, the loop will start at this position. 17630 */ 17631 get loopStart() { 17632 return this._loopStart; 17633 } 17634 set loopStart(loopStart) { 17635 this._loopStart = loopStart; 17636 if (this.buffer.loaded) { 17637 assertRange(this.toSeconds(loopStart), 0, this.buffer.duration); 17638 } 17639 this._activeSources.forEach((source) => { 17640 source.loopStart = loopStart; 17641 }); 17642 } 17643 /** 17644 * If loop is true, the loop will end at this position. 17645 */ 17646 get loopEnd() { 17647 return this._loopEnd; 17648 } 17649 set loopEnd(loopEnd) { 17650 this._loopEnd = loopEnd; 17651 if (this.buffer.loaded) { 17652 assertRange(this.toSeconds(loopEnd), 0, this.buffer.duration); 17653 } 17654 this._activeSources.forEach((source) => { 17655 source.loopEnd = loopEnd; 17656 }); 17657 } 17658 /** 17659 * The audio buffer belonging to the player. 17660 */ 17661 get buffer() { 17662 return this._buffer; 17663 } 17664 set buffer(buffer) { 17665 this._buffer.set(buffer); 17666 } 17667 /** 17668 * If the buffer should loop once it's over. 17669 * @example 17670 * const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/breakbeat.mp3").toDestination(); 17671 * player.loop = true; 17672 * player.autostart = true; 17673 */ 17674 get loop() { 17675 return this._loop; 17676 } 17677 set loop(loop) { 17678 if (this._loop === loop) { 17679 return; 17680 } 17681 this._loop = loop; 17682 this._activeSources.forEach((source) => { 17683 source.loop = loop; 17684 }); 17685 if (loop) { 17686 const stopEvent = this._state.getNextState("stopped", this.now()); 17687 if (stopEvent) { 17688 this._state.cancel(stopEvent.time); 17689 } 17690 } 17691 } 17692 /** 17693 * Normal speed is 1. The pitch will change with the playback rate. 17694 * @example 17695 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/femalevoices_aa2_A5.mp3").toDestination(); 17696 * // play at 1/4 speed 17697 * player.playbackRate = 0.25; 17698 * // play as soon as the buffer is loaded 17699 * player.autostart = true; 17700 */ 17701 get playbackRate() { 17702 return this._playbackRate; 17703 } 17704 set playbackRate(rate) { 17705 this._playbackRate = rate; 17706 const now = this.now(); 17707 const stopEvent = this._state.getNextState("stopped", now); 17708 if (stopEvent && stopEvent.implicitEnd) { 17709 this._state.cancel(stopEvent.time); 17710 this._activeSources.forEach((source) => source.cancelStop()); 17711 } 17712 this._activeSources.forEach((source) => { 17713 source.playbackRate.setValueAtTime(rate, now); 17714 }); 17715 } 17716 /** 17717 * If the buffer should be reversed. Note that this sets the underlying {@link ToneAudioBuffer.reverse}, so 17718 * if multiple players are pointing at the same ToneAudioBuffer, they will all be reversed. 17719 * @example 17720 * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/chime_1.mp3").toDestination(); 17721 * player.autostart = true; 17722 * player.reverse = true; 17723 */ 17724 get reverse() { 17725 return this._buffer.reverse; 17726 } 17727 set reverse(rev) { 17728 this._buffer.reverse = rev; 17729 } 17730 /** 17731 * If the buffer is loaded 17732 */ 17733 get loaded() { 17734 return this._buffer.loaded; 17735 } 17736 dispose() { 17737 super.dispose(); 17738 this._activeSources.forEach((source) => source.dispose()); 17739 this._activeSources.clear(); 17740 this._buffer.dispose(); 17741 return this; 17742 } 17743}; 17744__decorate([ 17745 timeRange(0) 17746], Player.prototype, "fadeIn", void 0); 17747__decorate([ 17748 timeRange(0) 17749], Player.prototype, "fadeOut", void 0); 17750
vendor: 464 bytes, lines 17751-17772
17751// node_modules/tone/build/esm/signal/GainToAudio.js 17752var GainToAudio = class extends SignalOperator { 17753 constructor() { 17754 super(...arguments); 17755 this.name = "GainToAudio"; 17756 this._norm = new WaveShaper({ 17757 context: this.context, 17758 mapping: (x) => Math.abs(x) * 2 - 1 17759 }); 17760 this.input = this._norm; 17761 this.output = this._norm; 17762 } 17763 /** 17764 * clean up 17765 */ 17766 dispose() { 17767 super.dispose(); 17768 this._norm.dispose(); 17769 return this; 17770 } 17771}; 17772
vendor: 12,037 bytes, lines 17773-18156
17773// node_modules/tone/build/esm/component/envelope/Envelope.js 17774var Envelope = class _Envelope extends ToneAudioNode { 17775 constructor() { 17776 const options = optionsFromArguments(_Envelope.getDefaults(), arguments, ["attack", "decay", "sustain", "release"]); 17777 super(options); 17778 this.name = "Envelope"; 17779 this._sig = new Signal({ 17780 context: this.context, 17781 value: 0 17782 }); 17783 this.output = this._sig; 17784 this.input = void 0; 17785 this.attack = options.attack; 17786 this.decay = options.decay; 17787 this.sustain = options.sustain; 17788 this.release = options.release; 17789 this.attackCurve = options.attackCurve; 17790 this.releaseCurve = options.releaseCurve; 17791 this.decayCurve = options.decayCurve; 17792 } 17793 static getDefaults() { 17794 return Object.assign(ToneAudioNode.getDefaults(), { 17795 attack: 0.01, 17796 attackCurve: "linear", 17797 decay: 0.1, 17798 decayCurve: "exponential", 17799 release: 1, 17800 releaseCurve: "exponential", 17801 sustain: 0.5 17802 }); 17803 } 17804 /** 17805 * Read the current value of the envelope. Useful for 17806 * synchronizing visual output to the envelope. 17807 */ 17808 get value() { 17809 return this.getValueAtTime(this.now()); 17810 } 17811 /** 17812 * Get the curve 17813 * @param curve 17814 * @param direction In/Out 17815 * @return The curve name 17816 */ 17817 _getCurve(curve, direction) { 17818 if (isString(curve)) { 17819 return curve; 17820 } else { 17821 let curveName; 17822 for (curveName in EnvelopeCurves) { 17823 if (EnvelopeCurves[curveName][direction] === curve) { 17824 return curveName; 17825 } 17826 } 17827 return curve; 17828 } 17829 } 17830 /** 17831 * Assign a the curve to the given name using the direction 17832 * @param name 17833 * @param direction In/Out 17834 * @param curve 17835 */ 17836 _setCurve(name, direction, curve) { 17837 if (isString(curve) && Reflect.has(EnvelopeCurves, curve)) { 17838 const curveDef = EnvelopeCurves[curve]; 17839 if (isObject(curveDef)) { 17840 if (name !== "_decayCurve") { 17841 this[name] = curveDef[direction]; 17842 } 17843 } else { 17844 this[name] = curveDef; 17845 } 17846 } else if (isArray(curve) && name !== "_decayCurve") { 17847 this[name] = curve; 17848 } else { 17849 throw new Error("Envelope: invalid curve: " + curve); 17850 } 17851 } 17852 /** 17853 * The shape of the attack. 17854 * Can be any of these strings: 17855 * * "linear" 17856 * * "exponential" 17857 * * "sine" 17858 * * "cosine" 17859 * * "bounce" 17860 * * "ripple" 17861 * * "step" 17862 * 17863 * Can also be an array which describes the curve. Values 17864 * in the array are evenly subdivided and linearly 17865 * interpolated over the duration of the attack. 17866 * @example 17867 * return Tone.Offline(() => { 17868 * const env = new Tone.Envelope(0.4).toDestination(); 17869 * env.attackCurve = "linear"; 17870 * env.triggerAttack(); 17871 * }, 1, 1); 17872 */ 17873 get attackCurve() { 17874 return this._getCurve(this._attackCurve, "In"); 17875 } 17876 set attackCurve(curve) { 17877 this._setCurve("_attackCurve", "In", curve); 17878 } 17879 /** 17880 * The shape of the release. See the attack curve types. 17881 * @example 17882 * return Tone.Offline(() => { 17883 * const env = new Tone.Envelope({ 17884 * release: 0.8 17885 * }).toDestination(); 17886 * env.triggerAttack(); 17887 * // release curve could also be defined by an array 17888 * env.releaseCurve = [1, 0.3, 0.4, 0.2, 0.7, 0]; 17889 * env.triggerRelease(0.2); 17890 * }, 1, 1); 17891 */ 17892 get releaseCurve() { 17893 return this._getCurve(this._releaseCurve, "Out"); 17894 } 17895 set releaseCurve(curve) { 17896 this._setCurve("_releaseCurve", "Out", curve); 17897 } 17898 /** 17899 * The shape of the decay either "linear" or "exponential" 17900 * @example 17901 * return Tone.Offline(() => { 17902 * const env = new Tone.Envelope({ 17903 * sustain: 0.1, 17904 * decay: 0.5 17905 * }).toDestination(); 17906 * env.decayCurve = "linear"; 17907 * env.triggerAttack(); 17908 * }, 1, 1); 17909 */ 17910 get decayCurve() { 17911 return this._getCurve(this._decayCurve, "Out"); 17912 } 17913 set decayCurve(curve) { 17914 this._setCurve("_decayCurve", "Out", curve); 17915 } 17916 /** 17917 * Trigger the attack/decay portion of the ADSR envelope. 17918 * @param time When the attack should start. 17919 * @param velocity The velocity of the envelope scales the vales. 17920 * number between 0-1 17921 * @example 17922 * const env = new Tone.AmplitudeEnvelope().toDestination(); 17923 * const osc = new Tone.Oscillator().connect(env).start(); 17924 * // trigger the attack 0.5 seconds from now with a velocity of 0.2 17925 * env.triggerAttack("+0.5", 0.2); 17926 */ 17927 triggerAttack(time, velocity = 1) { 17928 this.log("triggerAttack", time, velocity); 17929 time = this.toSeconds(time); 17930 const originalAttack = this.toSeconds(this.attack); 17931 let attack = originalAttack; 17932 const decay = this.toSeconds(this.decay); 17933 const currentValue = this.getValueAtTime(time); 17934 if (currentValue > 0) { 17935 const attackRate = 1 / attack; 17936 const remainingDistance = 1 - currentValue; 17937 attack = remainingDistance / attackRate; 17938 } 17939 if (attack < this.sampleTime) { 17940 this._sig.cancelScheduledValues(time); 17941 this._sig.setValueAtTime(velocity, time); 17942 } else if (this._attackCurve === "linear") { 17943 this._sig.linearRampTo(velocity, attack, time); 17944 } else if (this._attackCurve === "exponential") { 17945 this._sig.targetRampTo(velocity, attack, time); 17946 } else { 17947 this._sig.cancelAndHoldAtTime(time); 17948 let curve = this._attackCurve; 17949 for (let i = 1; i < curve.length; i++) { 17950 if (curve[i - 1] <= currentValue && currentValue <= curve[i]) { 17951 curve = this._attackCurve.slice(i); 17952 curve[0] = currentValue; 17953 break; 17954 } 17955 } 17956 this._sig.setValueCurveAtTime(curve, time, attack, velocity); 17957 } 17958 if (decay && this.sustain < 1) { 17959 const decayValue = velocity * this.sustain; 17960 const decayStart = time + attack; 17961 this.log("decay", decayStart); 17962 if (this._decayCurve === "linear") { 17963 this._sig.linearRampToValueAtTime(decayValue, decay + decayStart); 17964 } else { 17965 this._sig.exponentialApproachValueAtTime(decayValue, decayStart, decay); 17966 } 17967 } 17968 return this; 17969 } 17970 /** 17971 * Triggers the release of the envelope. 17972 * @param time When the release portion of the envelope should start. 17973 * @example 17974 * const env = new Tone.AmplitudeEnvelope().toDestination(); 17975 * const osc = new Tone.Oscillator({ 17976 * type: "sawtooth" 17977 * }).connect(env).start(); 17978 * env.triggerAttack(); 17979 * // trigger the release half a second after the attack 17980 * env.triggerRelease("+0.5"); 17981 */ 17982 triggerRelease(time) { 17983 this.log("triggerRelease", time); 17984 time = this.toSeconds(time); 17985 const currentValue = this.getValueAtTime(time); 17986 if (currentValue > 0) { 17987 const release = this.toSeconds(this.release); 17988 if (release < this.sampleTime) { 17989 this._sig.setValueAtTime(0, time); 17990 } else if (this._releaseCurve === "linear") { 17991 this._sig.linearRampTo(0, release, time); 17992 } else if (this._releaseCurve === "exponential") { 17993 this._sig.targetRampTo(0, release, time); 17994 } else { 17995 assert(isArray(this._releaseCurve), "releaseCurve must be either 'linear', 'exponential' or an array"); 17996 this._sig.cancelAndHoldAtTime(time); 17997 this._sig.setValueCurveAtTime(this._releaseCurve, time, release, currentValue); 17998 } 17999 } 18000 return this; 18001 } 18002 /** 18003 * Get the scheduled value at the given time. This will 18004 * return the unconverted (raw) value. 18005 * @example 18006 * const env = new Tone.Envelope(0.5, 1, 0.4, 2); 18007 * env.triggerAttackRelease(2); 18008 * setInterval(() => console.log(env.getValueAtTime(Tone.now())), 100); 18009 */ 18010 getValueAtTime(time) { 18011 return this._sig.getValueAtTime(time); 18012 } 18013 /** 18014 * triggerAttackRelease is shorthand for triggerAttack, then waiting 18015 * some duration, then triggerRelease. 18016 * @param duration The duration of the sustain. 18017 * @param time When the attack should be triggered. 18018 * @param velocity The velocity of the envelope. 18019 * @example 18020 * const env = new Tone.AmplitudeEnvelope().toDestination(); 18021 * const osc = new Tone.Oscillator().connect(env).start(); 18022 * // trigger the release 0.5 seconds after the attack 18023 * env.triggerAttackRelease(0.5); 18024 */ 18025 triggerAttackRelease(duration, time, velocity = 1) { 18026 time = this.toSeconds(time); 18027 this.triggerAttack(time, velocity); 18028 this.triggerRelease(time + this.toSeconds(duration)); 18029 return this; 18030 } 18031 /** 18032 * Cancels all scheduled envelope changes after the given time. 18033 */ 18034 cancel(after) { 18035 this._sig.cancelScheduledValues(this.toSeconds(after)); 18036 return this; 18037 } 18038 /** 18039 * Connect the envelope to a destination node. 18040 */ 18041 connect(destination, outputNumber = 0, inputNumber = 0) { 18042 connectSignal(this, destination, outputNumber, inputNumber); 18043 return this; 18044 } 18045 /** 18046 * Render the envelope curve to an array of the given length. 18047 * Good for visualizing the envelope curve. Rescales the duration of the 18048 * envelope to fit the length. 18049 */ 18050 asArray() { 18051 return __awaiter(this, arguments, void 0, function* (length = 1024) { 18052 const duration = length / this.context.sampleRate; 18053 const context2 = new OfflineContext(1, duration, this.context.sampleRate); 18054 const attackPortion = this.toSeconds(this.attack) + this.toSeconds(this.decay); 18055 const envelopeDuration = attackPortion + this.toSeconds(this.release); 18056 const sustainTime = envelopeDuration * 0.1; 18057 const totalDuration = envelopeDuration + sustainTime; 18058 const clone = new this.constructor(Object.assign(this.get(), { 18059 attack: duration * this.toSeconds(this.attack) / totalDuration, 18060 decay: duration * this.toSeconds(this.decay) / totalDuration, 18061 release: duration * this.toSeconds(this.release) / totalDuration, 18062 context: context2 18063 })); 18064 clone._sig.toDestination(); 18065 clone.triggerAttackRelease(duration * (attackPortion + sustainTime) / totalDuration, 0); 18066 const buffer = yield context2.render(); 18067 return buffer.getChannelData(0); 18068 }); 18069 } 18070 dispose() { 18071 super.dispose(); 18072 this._sig.dispose(); 18073 return this; 18074 } 18075}; 18076__decorate([ 18077 timeRange(0) 18078], Envelope.prototype, "attack", void 0); 18079__decorate([ 18080 timeRange(0) 18081], Envelope.prototype, "decay", void 0); 18082__decorate([ 18083 range(0, 1) 18084], Envelope.prototype, "sustain", void 0); 18085__decorate([ 18086 timeRange(0) 18087], Envelope.prototype, "release", void 0); 18088var EnvelopeCurves = (() => { 18089 const curveLen = 128; 18090 let i; 18091 let k; 18092 const cosineCurve = []; 18093 for (i = 0; i < curveLen; i++) { 18094 cosineCurve[i] = Math.sin(i / (curveLen - 1) * (Math.PI / 2)); 18095 } 18096 const rippleCurve = []; 18097 const rippleCurveFreq = 6.4; 18098 for (i = 0; i < curveLen - 1; i++) { 18099 k = i / (curveLen - 1); 18100 const sineWave = Math.sin(k * (Math.PI * 2) * rippleCurveFreq - Math.PI / 2) + 1; 18101 rippleCurve[i] = sineWave / 10 + k * 0.83; 18102 } 18103 rippleCurve[curveLen - 1] = 1; 18104 const stairsCurve = []; 18105 const steps = 5; 18106 for (i = 0; i < curveLen; i++) { 18107 stairsCurve[i] = Math.ceil(i / (curveLen - 1) * steps) / steps; 18108 } 18109 const sineCurve = []; 18110 for (i = 0; i < curveLen; i++) { 18111 k = i / (curveLen - 1); 18112 sineCurve[i] = 0.5 * (1 - Math.cos(Math.PI * k)); 18113 } 18114 const bounceCurve = []; 18115 for (i = 0; i < curveLen; i++) { 18116 k = i / (curveLen - 1); 18117 const freq = Math.pow(k, 3) * 4 + 0.2; 18118 const val = Math.cos(freq * Math.PI * 2 * k); 18119 bounceCurve[i] = Math.abs(val * (1 - k)); 18120 } 18121 function invertCurve(curve) { 18122 const out = new Array(curve.length); 18123 for (let j = 0; j < curve.length; j++) { 18124 out[j] = 1 - curve[j]; 18125 } 18126 return out; 18127 } 18128 function reverseCurve(curve) { 18129 return curve.slice(0).reverse(); 18130 } 18131 return { 18132 bounce: { 18133 In: invertCurve(bounceCurve), 18134 Out: bounceCurve 18135 }, 18136 cosine: { 18137 In: cosineCurve, 18138 Out: reverseCurve(cosineCurve) 18139 }, 18140 exponential: "exponential", 18141 linear: "linear", 18142 ripple: { 18143 In: rippleCurve, 18144 Out: invertCurve(rippleCurve) 18145 }, 18146 sine: { 18147 In: sineCurve, 18148 Out: invertCurve(sineCurve) 18149 }, 18150 step: { 18151 In: stairsCurve, 18152 Out: invertCurve(stairsCurve) 18153 } 18154 }; 18155})(); 18156
vendor: 4,057 bytes, lines 18157-18277
18157// node_modules/tone/build/esm/instrument/Instrument.js 18158var Instrument = class _Instrument extends ToneAudioNode { 18159 constructor() { 18160 const options = optionsFromArguments(_Instrument.getDefaults(), arguments); 18161 super(options); 18162 this._scheduledEvents = []; 18163 this._synced = false; 18164 this._original_triggerAttack = this.triggerAttack; 18165 this._original_triggerRelease = this.triggerRelease; 18166 this._syncedRelease = (time) => this._original_triggerRelease(time); 18167 this._volume = this.output = new Volume({ 18168 context: this.context, 18169 volume: options.volume 18170 }); 18171 this.volume = this._volume.volume; 18172 readOnly(this, "volume"); 18173 } 18174 static getDefaults() { 18175 return Object.assign(ToneAudioNode.getDefaults(), { 18176 volume: 0 18177 }); 18178 } 18179 /** 18180 * Sync the instrument to the Transport. All subsequent calls of 18181 * {@link triggerAttack} and {@link triggerRelease} will be scheduled along the transport. 18182 * @example 18183 * const fmSynth = new Tone.FMSynth().toDestination(); 18184 * fmSynth.volume.value = -6; 18185 * fmSynth.sync(); 18186 * // schedule 3 notes when the transport first starts 18187 * fmSynth.triggerAttackRelease("C4", "8n", 0); 18188 * fmSynth.triggerAttackRelease("E4", "8n", "8n"); 18189 * fmSynth.triggerAttackRelease("G4", "8n", "4n"); 18190 * // start the transport to hear the notes 18191 * Tone.Transport.start(); 18192 */ 18193 sync() { 18194 if (this._syncState()) { 18195 this._syncMethod("triggerAttack", 1); 18196 this._syncMethod("triggerRelease", 0); 18197 this.context.transport.on("stop", this._syncedRelease); 18198 this.context.transport.on("pause", this._syncedRelease); 18199 this.context.transport.on("loopEnd", this._syncedRelease); 18200 } 18201 return this; 18202 } 18203 /** 18204 * set _sync 18205 */ 18206 _syncState() { 18207 let changed = false; 18208 if (!this._synced) { 18209 this._synced = true; 18210 changed = true; 18211 } 18212 return changed; 18213 } 18214 /** 18215 * Wrap the given method so that it can be synchronized 18216 * @param method Which method to wrap and sync 18217 * @param timePosition What position the time argument appears in 18218 */ 18219 _syncMethod(method, timePosition) { 18220 const originalMethod = this["_original_" + method] = this[method]; 18221 this[method] = (...args) => { 18222 const time = args[timePosition]; 18223 const id = this.context.transport.schedule((t) => { 18224 args[timePosition] = t; 18225 originalMethod.apply(this, args); 18226 }, time); 18227 this._scheduledEvents.push(id); 18228 }; 18229 } 18230 /** 18231 * Unsync the instrument from the Transport 18232 */ 18233 unsync() { 18234 this._scheduledEvents.forEach((id) => this.context.transport.clear(id)); 18235 this._scheduledEvents = []; 18236 if (this._synced) { 18237 this._synced = false; 18238 this.triggerAttack = this._original_triggerAttack; 18239 this.triggerRelease = this._original_triggerRelease; 18240 this.context.transport.off("stop", this._syncedRelease); 18241 this.context.transport.off("pause", this._syncedRelease); 18242 this.context.transport.off("loopEnd", this._syncedRelease); 18243 } 18244 return this; 18245 } 18246 /** 18247 * Trigger the attack and then the release after the duration. 18248 * @param note The note to trigger. 18249 * @param duration How long the note should be held for before 18250 * triggering the release. This value must be greater than 0. 18251 * @param time When the note should be triggered. 18252 * @param velocity The velocity the note should be triggered at. 18253 * @example 18254 * const synth = new Tone.Synth().toDestination(); 18255 * // trigger "C4" for the duration of an 8th note 18256 * synth.triggerAttackRelease("C4", "8n"); 18257 */ 18258 triggerAttackRelease(note, duration, time, velocity) { 18259 const computedTime = this.toSeconds(time); 18260 const computedDuration = this.toSeconds(duration); 18261 this.triggerAttack(note, computedTime, velocity); 18262 this.triggerRelease(computedTime + computedDuration); 18263 return this; 18264 } 18265 /** 18266 * clean up 18267 * @returns {Instrument} this 18268 */ 18269 dispose() { 18270 super.dispose(); 18271 this._volume.dispose(); 18272 this.unsync(); 18273 this._scheduledEvents = []; 18274 return this; 18275 } 18276}; 18277
vendor: 2,563 bytes, lines 18278-18351
18278// node_modules/tone/build/esm/instrument/Monophonic.js 18279var Monophonic = class _Monophonic extends Instrument { 18280 constructor() { 18281 const options = optionsFromArguments(_Monophonic.getDefaults(), arguments); 18282 super(options); 18283 this.portamento = options.portamento; 18284 this.onsilence = options.onsilence; 18285 } 18286 static getDefaults() { 18287 return Object.assign(Instrument.getDefaults(), { 18288 detune: 0, 18289 onsilence: noOp, 18290 portamento: 0 18291 }); 18292 } 18293 /** 18294 * Trigger the attack of the note optionally with a given velocity. 18295 * @param note The note to trigger. 18296 * @param time When the note should start. 18297 * @param velocity The velocity determines how "loud" the note will be. 18298 * @example 18299 * const synth = new Tone.Synth().toDestination(); 18300 * // trigger the note a half second from now at half velocity 18301 * synth.triggerAttack("C4", "+0.5", 0.5); 18302 */ 18303 triggerAttack(note, time, velocity = 1) { 18304 this.log("triggerAttack", note, time, velocity); 18305 const seconds = this.toSeconds(time); 18306 this._triggerEnvelopeAttack(seconds, velocity); 18307 this.setNote(note, seconds); 18308 return this; 18309 } 18310 /** 18311 * Trigger the release portion of the envelope. 18312 * @param time If no time is given, the release happens immediately. 18313 * @example 18314 * const synth = new Tone.Synth().toDestination(); 18315 * synth.triggerAttack("C4"); 18316 * // trigger the release a second from now 18317 * synth.triggerRelease("+1"); 18318 */ 18319 triggerRelease(time) { 18320 this.log("triggerRelease", time); 18321 const seconds = this.toSeconds(time); 18322 this._triggerEnvelopeRelease(seconds); 18323 return this; 18324 } 18325 /** 18326 * Set the note at the given time. If no time is given, the note 18327 * will set immediately. 18328 * @param note The note to change to. 18329 * @param time The time when the note should be set. 18330 * @example 18331 * const synth = new Tone.Synth().toDestination(); 18332 * synth.triggerAttack("C4"); 18333 * // change to F#6 in one quarter note from now. 18334 * synth.setNote("F#6", "+4n"); 18335 */ 18336 setNote(note, time) { 18337 const computedTime = this.toSeconds(time); 18338 const computedFrequency = note instanceof FrequencyClass ? note.toFrequency() : note; 18339 if (this.portamento > 0 && this.getLevelAtTime(computedTime) > 0.05) { 18340 const portTime = this.toSeconds(this.portamento); 18341 this.frequency.exponentialRampTo(computedFrequency, portTime, computedTime); 18342 } else { 18343 this.frequency.setValueAtTime(computedFrequency, computedTime); 18344 } 18345 return this; 18346 } 18347}; 18348__decorate([ 18349 timeRange(0) 18350], Monophonic.prototype, "portamento", void 0); 18351
vendor: 726 bytes, lines 18352-18381
18352// node_modules/tone/build/esm/component/envelope/AmplitudeEnvelope.js 18353var AmplitudeEnvelope = class _AmplitudeEnvelope extends Envelope { 18354 constructor() { 18355 super(optionsFromArguments(_AmplitudeEnvelope.getDefaults(), arguments, [ 18356 "attack", 18357 "decay", 18358 "sustain", 18359 "release" 18360 ])); 18361 this.name = "AmplitudeEnvelope"; 18362 this._gainNode = new Gain({ 18363 context: this.context, 18364 gain: 0 18365 }); 18366 this.output = this._gainNode; 18367 this.input = this._gainNode; 18368 this._sig.connect(this._gainNode.gain); 18369 this.output = this._gainNode; 18370 this.input = this._gainNode; 18371 } 18372 /** 18373 * Clean up 18374 */ 18375 dispose() { 18376 super.dispose(); 18377 this._gainNode.dispose(); 18378 return this; 18379 } 18380}; 18381
vendor: 2,308 bytes, lines 18382-18454
18382// node_modules/tone/build/esm/instrument/Synth.js 18383var Synth = class _Synth extends Monophonic { 18384 constructor() { 18385 const options = optionsFromArguments(_Synth.getDefaults(), arguments); 18386 super(options); 18387 this.name = "Synth"; 18388 this.oscillator = new OmniOscillator(Object.assign({ 18389 context: this.context, 18390 detune: options.detune, 18391 onstop: () => this.onsilence(this) 18392 }, options.oscillator)); 18393 this.frequency = this.oscillator.frequency; 18394 this.detune = this.oscillator.detune; 18395 this.envelope = new AmplitudeEnvelope(Object.assign({ 18396 context: this.context 18397 }, options.envelope)); 18398 this.oscillator.chain(this.envelope, this.output); 18399 readOnly(this, ["oscillator", "frequency", "detune", "envelope"]); 18400 } 18401 static getDefaults() { 18402 return Object.assign(Monophonic.getDefaults(), { 18403 envelope: Object.assign(omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())), { 18404 attack: 5e-3, 18405 decay: 0.1, 18406 release: 1, 18407 sustain: 0.3 18408 }), 18409 oscillator: Object.assign(omitFromObject(OmniOscillator.getDefaults(), [ 18410 ...Object.keys(Source.getDefaults()), 18411 "frequency", 18412 "detune" 18413 ]), { 18414 type: "triangle" 18415 }) 18416 }); 18417 } 18418 /** 18419 * start the attack portion of the envelope 18420 * @param time the time the attack should start 18421 * @param velocity the velocity of the note (0-1) 18422 */ 18423 _triggerEnvelopeAttack(time, velocity) { 18424 this.envelope.triggerAttack(time, velocity); 18425 this.oscillator.start(time); 18426 if (this.envelope.sustain === 0) { 18427 const computedAttack = this.toSeconds(this.envelope.attack); 18428 const computedDecay = this.toSeconds(this.envelope.decay); 18429 this.oscillator.stop(time + computedAttack + computedDecay); 18430 } 18431 } 18432 /** 18433 * start the release portion of the envelope 18434 * @param time the time the release should start 18435 */ 18436 _triggerEnvelopeRelease(time) { 18437 this.envelope.triggerRelease(time); 18438 this.oscillator.stop(time + this.toSeconds(this.envelope.release)); 18439 } 18440 getLevelAtTime(time) { 18441 time = this.toSeconds(time); 18442 return this.envelope.getValueAtTime(time); 18443 } 18444 /** 18445 * clean up 18446 */ 18447 dispose() { 18448 super.dispose(); 18449 this.oscillator.dispose(); 18450 this.envelope.dispose(); 18451 return this; 18452 } 18453}; 18454
vendor: 3,196 bytes, lines 18455-18567
18455// node_modules/tone/build/esm/instrument/ModulationSynth.js 18456var ModulationSynth = class _ModulationSynth extends Monophonic { 18457 constructor() { 18458 const options = optionsFromArguments(_ModulationSynth.getDefaults(), arguments); 18459 super(options); 18460 this.name = "ModulationSynth"; 18461 this._carrier = new Synth({ 18462 context: this.context, 18463 oscillator: options.oscillator, 18464 envelope: options.envelope, 18465 onsilence: () => this.onsilence(this), 18466 volume: -10 18467 }); 18468 this._modulator = new Synth({ 18469 context: this.context, 18470 oscillator: options.modulation, 18471 envelope: options.modulationEnvelope, 18472 volume: -10 18473 }); 18474 this.oscillator = this._carrier.oscillator; 18475 this.envelope = this._carrier.envelope; 18476 this.modulation = this._modulator.oscillator; 18477 this.modulationEnvelope = this._modulator.envelope; 18478 this.frequency = new Signal({ 18479 context: this.context, 18480 units: "frequency" 18481 }); 18482 this.detune = new Signal({ 18483 context: this.context, 18484 value: options.detune, 18485 units: "cents" 18486 }); 18487 this.harmonicity = new Multiply({ 18488 context: this.context, 18489 value: options.harmonicity, 18490 minValue: 0 18491 }); 18492 this._modulationNode = new Gain({ 18493 context: this.context, 18494 gain: 0 18495 }); 18496 readOnly(this, [ 18497 "frequency", 18498 "harmonicity", 18499 "oscillator", 18500 "envelope", 18501 "modulation", 18502 "modulationEnvelope", 18503 "detune" 18504 ]); 18505 } 18506 static getDefaults() { 18507 return Object.assign(Monophonic.getDefaults(), { 18508 harmonicity: 3, 18509 oscillator: Object.assign(omitFromObject(OmniOscillator.getDefaults(), [ 18510 ...Object.keys(Source.getDefaults()), 18511 "frequency", 18512 "detune" 18513 ]), { 18514 type: "sine" 18515 }), 18516 envelope: Object.assign(omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())), { 18517 attack: 0.01, 18518 decay: 0.01, 18519 sustain: 1, 18520 release: 0.5 18521 }), 18522 modulation: Object.assign(omitFromObject(OmniOscillator.getDefaults(), [ 18523 ...Object.keys(Source.getDefaults()), 18524 "frequency", 18525 "detune" 18526 ]), { 18527 type: "square" 18528 }), 18529 modulationEnvelope: Object.assign(omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())), { 18530 attack: 0.5, 18531 decay: 0, 18532 sustain: 1, 18533 release: 0.5 18534 }) 18535 }); 18536 } 18537 /** 18538 * Trigger the attack portion of the note 18539 */ 18540 _triggerEnvelopeAttack(time, velocity) { 18541 this._carrier._triggerEnvelopeAttack(time, velocity); 18542 this._modulator._triggerEnvelopeAttack(time, velocity); 18543 } 18544 /** 18545 * Trigger the release portion of the note 18546 */ 18547 _triggerEnvelopeRelease(time) { 18548 this._carrier._triggerEnvelopeRelease(time); 18549 this._modulator._triggerEnvelopeRelease(time); 18550 return this; 18551 } 18552 getLevelAtTime(time) { 18553 time = this.toSeconds(time); 18554 return this.envelope.getValueAtTime(time); 18555 } 18556 dispose() { 18557 super.dispose(); 18558 this._carrier.dispose(); 18559 this._modulator.dispose(); 18560 this.frequency.dispose(); 18561 this.detune.dispose(); 18562 this.harmonicity.dispose(); 18563 this._modulationNode.dispose(); 18564 return this; 18565 } 18566}; 18567
vendor: 732 bytes, lines 18568-18588
18568// node_modules/tone/build/esm/instrument/AMSynth.js 18569var AMSynth = class _AMSynth extends ModulationSynth { 18570 constructor() { 18571 super(optionsFromArguments(_AMSynth.getDefaults(), arguments)); 18572 this.name = "AMSynth"; 18573 this._modulationScale = new AudioToGain({ 18574 context: this.context 18575 }); 18576 this.frequency.connect(this._carrier.frequency); 18577 this.frequency.chain(this.harmonicity, this._modulator.frequency); 18578 this.detune.fan(this._carrier.detune, this._modulator.detune); 18579 this._modulator.chain(this._modulationScale, this._modulationNode.gain); 18580 this._carrier.chain(this._modulationNode, this.output); 18581 } 18582 dispose() { 18583 super.dispose(); 18584 this._modulationScale.dispose(); 18585 return this; 18586 } 18587}; 18588
vendor: 2,884 bytes, lines 18589-18687
18589// node_modules/tone/build/esm/component/filter/BiquadFilter.js 18590var BiquadFilter = class _BiquadFilter extends ToneAudioNode { 18591 constructor() { 18592 const options = optionsFromArguments(_BiquadFilter.getDefaults(), arguments, ["frequency", "type"]); 18593 super(options); 18594 this.name = "BiquadFilter"; 18595 this._filter = this.context.createBiquadFilter(); 18596 this.input = this.output = this._filter; 18597 this.Q = new Param({ 18598 context: this.context, 18599 units: "number", 18600 value: options.Q, 18601 param: this._filter.Q 18602 }); 18603 this.frequency = new Param({ 18604 context: this.context, 18605 units: "frequency", 18606 value: options.frequency, 18607 param: this._filter.frequency 18608 }); 18609 this.detune = new Param({ 18610 context: this.context, 18611 units: "cents", 18612 value: options.detune, 18613 param: this._filter.detune 18614 }); 18615 this.gain = new Param({ 18616 context: this.context, 18617 units: "decibels", 18618 convert: false, 18619 value: options.gain, 18620 param: this._filter.gain 18621 }); 18622 this.type = options.type; 18623 } 18624 static getDefaults() { 18625 return Object.assign(ToneAudioNode.getDefaults(), { 18626 Q: 1, 18627 type: "lowpass", 18628 frequency: 350, 18629 detune: 0, 18630 gain: 0 18631 }); 18632 } 18633 /** 18634 * The type of this BiquadFilterNode. For a complete list of types and their attributes, see the 18635 * [Web Audio API](https://webaudio.github.io/web-audio-api/#dom-biquadfiltertype-lowpass) 18636 */ 18637 get type() { 18638 return this._filter.type; 18639 } 18640 set type(type) { 18641 const types = [ 18642 "lowpass", 18643 "highpass", 18644 "bandpass", 18645 "lowshelf", 18646 "highshelf", 18647 "notch", 18648 "allpass", 18649 "peaking" 18650 ]; 18651 assert(types.indexOf(type) !== -1, `Invalid filter type: ${type}`); 18652 this._filter.type = type; 18653 } 18654 /** 18655 * Get the frequency response curve. This curve represents how the filter 18656 * responses to frequencies between 20hz-20khz. 18657 * @param len The number of values to return 18658 * @return The frequency response curve between 20-20kHz 18659 */ 18660 getFrequencyResponse(len = 128) { 18661 const freqValues = new Float32Array(len); 18662 for (let i = 0; i < len; i++) { 18663 const norm = Math.pow(i / len, 2); 18664 const freq = norm * (2e4 - 20) + 20; 18665 freqValues[i] = freq; 18666 } 18667 const magValues = new Float32Array(len); 18668 const phaseValues = new Float32Array(len); 18669 const filterClone = this.context.createBiquadFilter(); 18670 filterClone.type = this.type; 18671 filterClone.Q.value = this.Q.value; 18672 filterClone.frequency.value = this.frequency.value; 18673 filterClone.gain.value = this.gain.value; 18674 filterClone.getFrequencyResponse(freqValues, magValues, phaseValues); 18675 return magValues; 18676 } 18677 dispose() { 18678 super.dispose(); 18679 this._filter.disconnect(); 18680 this.Q.dispose(); 18681 this.frequency.dispose(); 18682 this.gain.dispose(); 18683 this.detune.dispose(); 18684 return this; 18685 } 18686}; 18687
vendor: 4,144 bytes, lines 18688-18830
18688// node_modules/tone/build/esm/component/filter/Filter.js 18689var Filter = class _Filter extends ToneAudioNode { 18690 constructor() { 18691 const options = optionsFromArguments(_Filter.getDefaults(), arguments, [ 18692 "frequency", 18693 "type", 18694 "rolloff" 18695 ]); 18696 super(options); 18697 this.name = "Filter"; 18698 this.input = new Gain({ context: this.context }); 18699 this.output = new Gain({ context: this.context }); 18700 this._filters = []; 18701 this._filters = []; 18702 this.Q = new Signal({ 18703 context: this.context, 18704 units: "positive", 18705 value: options.Q 18706 }); 18707 this.frequency = new Signal({ 18708 context: this.context, 18709 units: "frequency", 18710 value: options.frequency 18711 }); 18712 this.detune = new Signal({ 18713 context: this.context, 18714 units: "cents", 18715 value: options.detune 18716 }); 18717 this.gain = new Signal({ 18718 context: this.context, 18719 units: "decibels", 18720 convert: false, 18721 value: options.gain 18722 }); 18723 this._type = options.type; 18724 this.rolloff = options.rolloff; 18725 readOnly(this, ["detune", "frequency", "gain", "Q"]); 18726 } 18727 static getDefaults() { 18728 return Object.assign(ToneAudioNode.getDefaults(), { 18729 Q: 1, 18730 detune: 0, 18731 frequency: 350, 18732 gain: 0, 18733 rolloff: -12, 18734 type: "lowpass" 18735 }); 18736 } 18737 /** 18738 * The type of the filter. Types: "lowpass", "highpass", 18739 * "bandpass", "lowshelf", "highshelf", "notch", "allpass", or "peaking". 18740 */ 18741 get type() { 18742 return this._type; 18743 } 18744 set type(type) { 18745 const types = [ 18746 "lowpass", 18747 "highpass", 18748 "bandpass", 18749 "lowshelf", 18750 "highshelf", 18751 "notch", 18752 "allpass", 18753 "peaking" 18754 ]; 18755 assert(types.indexOf(type) !== -1, `Invalid filter type: ${type}`); 18756 this._type = type; 18757 this._filters.forEach((filter) => filter.type = type); 18758 } 18759 /** 18760 * The rolloff of the filter which is the drop in db 18761 * per octave. Implemented internally by cascading filters. 18762 * Only accepts the values -12, -24, -48 and -96. 18763 */ 18764 get rolloff() { 18765 return this._rolloff; 18766 } 18767 set rolloff(rolloff) { 18768 const rolloffNum = isNumber(rolloff) ? rolloff : parseInt(rolloff, 10); 18769 const possibilities = [-12, -24, -48, -96]; 18770 let cascadingCount = possibilities.indexOf(rolloffNum); 18771 assert(cascadingCount !== -1, `rolloff can only be ${possibilities.join(", ")}`); 18772 cascadingCount += 1; 18773 this._rolloff = rolloffNum; 18774 this.input.disconnect(); 18775 this._filters.forEach((filter) => filter.disconnect()); 18776 this._filters = new Array(cascadingCount); 18777 for (let count = 0; count < cascadingCount; count++) { 18778 const filter = new BiquadFilter({ 18779 context: this.context 18780 }); 18781 filter.type = this._type; 18782 this.frequency.connect(filter.frequency); 18783 this.detune.connect(filter.detune); 18784 this.Q.connect(filter.Q); 18785 this.gain.connect(filter.gain); 18786 this._filters[count] = filter; 18787 } 18788 this._internalChannels = this._filters; 18789 connectSeries(this.input, ...this._internalChannels, this.output); 18790 } 18791 /** 18792 * Get the frequency response curve. This curve represents how the filter 18793 * responses to frequencies between 20hz-20khz. 18794 * @param len The number of values to return 18795 * @return The frequency response curve between 20-20kHz 18796 */ 18797 getFrequencyResponse(len = 128) { 18798 const filterClone = new BiquadFilter({ 18799 context: this.context, 18800 frequency: this.frequency.value, 18801 gain: this.gain.value, 18802 Q: this.Q.value, 18803 type: this._type, 18804 detune: this.detune.value 18805 }); 18806 const totalResponse = new Float32Array(len).map(() => 1); 18807 this._filters.forEach(() => { 18808 const response = filterClone.getFrequencyResponse(len); 18809 response.forEach((val, i) => totalResponse[i] *= val); 18810 }); 18811 filterClone.dispose(); 18812 return totalResponse; 18813 } 18814 /** 18815 * Clean up. 18816 */ 18817 dispose() { 18818 super.dispose(); 18819 this._filters.forEach((filter) => { 18820 filter.dispose(); 18821 }); 18822 writable(this, ["detune", "frequency", "gain", "Q"]); 18823 this.frequency.dispose(); 18824 this.Q.dispose(); 18825 this.detune.dispose(); 18826 this.gain.dispose(); 18827 return this; 18828 } 18829}; 18830
vendor: 1,003 bytes, lines 18831-18860
18831// node_modules/tone/build/esm/instrument/FMSynth.js 18832var FMSynth = class _FMSynth extends ModulationSynth { 18833 constructor() { 18834 const options = optionsFromArguments(_FMSynth.getDefaults(), arguments); 18835 super(options); 18836 this.name = "FMSynth"; 18837 this.modulationIndex = new Multiply({ 18838 context: this.context, 18839 value: options.modulationIndex 18840 }); 18841 this.frequency.connect(this._carrier.frequency); 18842 this.frequency.chain(this.harmonicity, this._modulator.frequency); 18843 this.frequency.chain(this.modulationIndex, this._modulationNode); 18844 this.detune.fan(this._carrier.detune, this._modulator.detune); 18845 this._modulator.connect(this._modulationNode.gain); 18846 this._modulationNode.connect(this._carrier.frequency); 18847 this._carrier.connect(this.output); 18848 } 18849 static getDefaults() { 18850 return Object.assign(ModulationSynth.getDefaults(), { 18851 modulationIndex: 10 18852 }); 18853 } 18854 dispose() { 18855 super.dispose(); 18856 this.modulationIndex.dispose(); 18857 return this; 18858 } 18859}; 18860
vendor: 5,108 bytes, lines 18861-19030
18861// node_modules/tone/build/esm/instrument/MetalSynth.js 18862var inharmRatios = [1, 1.483, 1.932, 2.546, 2.63, 3.897]; 18863var MetalSynth = class _MetalSynth extends Monophonic { 18864 constructor() { 18865 const options = optionsFromArguments(_MetalSynth.getDefaults(), arguments); 18866 super(options); 18867 this.name = "MetalSynth"; 18868 this._oscillators = []; 18869 this._freqMultipliers = []; 18870 this.detune = new Signal({ 18871 context: this.context, 18872 units: "cents", 18873 value: options.detune 18874 }); 18875 this.frequency = new Signal({ 18876 context: this.context, 18877 units: "frequency" 18878 }); 18879 this._amplitude = new Gain({ 18880 context: this.context, 18881 gain: 0 18882 }).connect(this.output); 18883 this._highpass = new Filter({ 18884 // Q: -3.0102999566398125, 18885 Q: 0, 18886 context: this.context, 18887 type: "highpass" 18888 }).connect(this._amplitude); 18889 for (let i = 0; i < inharmRatios.length; i++) { 18890 const osc = new FMOscillator({ 18891 context: this.context, 18892 harmonicity: options.harmonicity, 18893 modulationIndex: options.modulationIndex, 18894 modulationType: "square", 18895 onstop: i === 0 ? () => this.onsilence(this) : noOp, 18896 type: "square" 18897 }); 18898 osc.connect(this._highpass); 18899 this._oscillators[i] = osc; 18900 const mult = new Multiply({ 18901 context: this.context, 18902 value: inharmRatios[i] 18903 }); 18904 this._freqMultipliers[i] = mult; 18905 this.frequency.chain(mult, osc.frequency); 18906 this.detune.connect(osc.detune); 18907 } 18908 this._filterFreqScaler = new Scale({ 18909 context: this.context, 18910 max: 7e3, 18911 min: this.toFrequency(options.resonance) 18912 }); 18913 this.envelope = new Envelope({ 18914 attack: options.envelope.attack, 18915 attackCurve: "linear", 18916 context: this.context, 18917 decay: options.envelope.decay, 18918 release: options.envelope.release, 18919 sustain: 0 18920 }); 18921 this.envelope.chain(this._filterFreqScaler, this._highpass.frequency); 18922 this.envelope.connect(this._amplitude.gain); 18923 this._octaves = options.octaves; 18924 this.octaves = options.octaves; 18925 } 18926 static getDefaults() { 18927 return deepMerge(Monophonic.getDefaults(), { 18928 envelope: Object.assign(omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())), { 18929 attack: 1e-3, 18930 decay: 1.4, 18931 release: 0.2 18932 }), 18933 harmonicity: 5.1, 18934 modulationIndex: 32, 18935 octaves: 1.5, 18936 resonance: 4e3 18937 }); 18938 } 18939 /** 18940 * Trigger the attack. 18941 * @param time When the attack should be triggered. 18942 * @param velocity The velocity that the envelope should be triggered at. 18943 */ 18944 _triggerEnvelopeAttack(time, velocity = 1) { 18945 this.envelope.triggerAttack(time, velocity); 18946 this._oscillators.forEach((osc) => osc.start(time)); 18947 if (this.envelope.sustain === 0) { 18948 this._oscillators.forEach((osc) => { 18949 osc.stop(time + this.toSeconds(this.envelope.attack) + this.toSeconds(this.envelope.decay)); 18950 }); 18951 } 18952 return this; 18953 } 18954 /** 18955 * Trigger the release of the envelope. 18956 * @param time When the release should be triggered. 18957 */ 18958 _triggerEnvelopeRelease(time) { 18959 this.envelope.triggerRelease(time); 18960 this._oscillators.forEach((osc) => osc.stop(time + this.toSeconds(this.envelope.release))); 18961 return this; 18962 } 18963 getLevelAtTime(time) { 18964 time = this.toSeconds(time); 18965 return this.envelope.getValueAtTime(time); 18966 } 18967 /** 18968 * The modulationIndex of the oscillators which make up the source. 18969 * see {@link FMOscillator.modulationIndex} 18970 * @min 1 18971 * @max 100 18972 */ 18973 get modulationIndex() { 18974 return this._oscillators[0].modulationIndex.value; 18975 } 18976 set modulationIndex(val) { 18977 this._oscillators.forEach((osc) => osc.modulationIndex.value = val); 18978 } 18979 /** 18980 * The harmonicity of the oscillators which make up the source. 18981 * see Tone.FMOscillator.harmonicity 18982 * @min 0.1 18983 * @max 10 18984 */ 18985 get harmonicity() { 18986 return this._oscillators[0].harmonicity.value; 18987 } 18988 set harmonicity(val) { 18989 this._oscillators.forEach((osc) => osc.harmonicity.value = val); 18990 } 18991 /** 18992 * The lower level of the highpass filter which is attached to the envelope. 18993 * This value should be between [0, 7000] 18994 * @min 0 18995 * @max 7000 18996 */ 18997 get resonance() { 18998 return this._filterFreqScaler.min; 18999 } 19000 set resonance(val) { 19001 this._filterFreqScaler.min = this.toFrequency(val); 19002 this.octaves = this._octaves; 19003 } 19004 /** 19005 * The number of octaves above the "resonance" frequency 19006 * that the filter ramps during the attack/decay envelope 19007 * @min 0 19008 * @max 8 19009 */ 19010 get octaves() { 19011 return this._octaves; 19012 } 19013 set octaves(val) { 19014 this._octaves = val; 19015 this._filterFreqScaler.max = this._filterFreqScaler.min * Math.pow(2, val); 19016 } 19017 dispose() { 19018 super.dispose(); 19019 this._oscillators.forEach((osc) => osc.dispose()); 19020 this._freqMultipliers.forEach((freqMult) => freqMult.dispose()); 19021 this.frequency.dispose(); 19022 this.detune.dispose(); 19023 this._filterFreqScaler.dispose(); 19024 this._amplitude.dispose(); 19025 this.envelope.dispose(); 19026 this._highpass.dispose(); 19027 return this; 19028 } 19029}; 19030
vendor: 1,383 bytes, lines 19031-19077
19031// node_modules/tone/build/esm/instrument/MembraneSynth.js 19032var MembraneSynth = class _MembraneSynth extends Synth { 19033 constructor() { 19034 const options = optionsFromArguments(_MembraneSynth.getDefaults(), arguments); 19035 super(options); 19036 this.name = "MembraneSynth"; 19037 this.portamento = 0; 19038 this.pitchDecay = options.pitchDecay; 19039 this.octaves = options.octaves; 19040 readOnly(this, ["oscillator", "envelope"]); 19041 } 19042 static getDefaults() { 19043 return deepMerge(Monophonic.getDefaults(), Synth.getDefaults(), { 19044 envelope: { 19045 attack: 1e-3, 19046 attackCurve: "exponential", 19047 decay: 0.4, 19048 release: 1.4, 19049 sustain: 0.01 19050 }, 19051 octaves: 10, 19052 oscillator: { 19053 type: "sine" 19054 }, 19055 pitchDecay: 0.05 19056 }); 19057 } 19058 setNote(note, time) { 19059 const seconds = this.toSeconds(time); 19060 const hertz = this.toFrequency(note instanceof FrequencyClass ? note.toFrequency() : note); 19061 const maxNote = hertz * this.octaves; 19062 this.oscillator.frequency.setValueAtTime(maxNote, seconds); 19063 this.oscillator.frequency.exponentialRampToValueAtTime(hertz, seconds + this.toSeconds(this.pitchDecay)); 19064 return this; 19065 } 19066 dispose() { 19067 super.dispose(); 19068 return this; 19069 } 19070}; 19071__decorate([ 19072 range(0) 19073], MembraneSynth.prototype, "octaves", void 0); 19074__decorate([ 19075 timeRange(0) 19076], MembraneSynth.prototype, "pitchDecay", void 0); 19077
vendor: 2,609 bytes, lines 19078-19159
19078// node_modules/tone/build/esm/instrument/NoiseSynth.js 19079var NoiseSynth = class _NoiseSynth extends Instrument { 19080 constructor() { 19081 const options = optionsFromArguments(_NoiseSynth.getDefaults(), arguments); 19082 super(options); 19083 this.name = "NoiseSynth"; 19084 this.noise = new Noise(Object.assign({ 19085 context: this.context 19086 }, options.noise)); 19087 this.envelope = new AmplitudeEnvelope(Object.assign({ 19088 context: this.context 19089 }, options.envelope)); 19090 this.noise.chain(this.envelope, this.output); 19091 } 19092 static getDefaults() { 19093 return Object.assign(Instrument.getDefaults(), { 19094 envelope: Object.assign(omitFromObject(Envelope.getDefaults(), Object.keys(ToneAudioNode.getDefaults())), { 19095 decay: 0.1, 19096 sustain: 0 19097 }), 19098 noise: Object.assign(omitFromObject(Noise.getDefaults(), Object.keys(Source.getDefaults())), { 19099 type: "white" 19100 }) 19101 }); 19102 } 19103 /** 19104 * Start the attack portion of the envelopes. Unlike other 19105 * instruments, Tone.NoiseSynth doesn't have a note. 19106 * @example 19107 * const noiseSynth = new Tone.NoiseSynth().toDestination(); 19108 * noiseSynth.triggerAttack(); 19109 */ 19110 triggerAttack(time, velocity = 1) { 19111 time = this.toSeconds(time); 19112 this.envelope.triggerAttack(time, velocity); 19113 this.noise.start(time); 19114 if (this.envelope.sustain === 0) { 19115 this.noise.stop(time + this.toSeconds(this.envelope.attack) + this.toSeconds(this.envelope.decay)); 19116 } 19117 return this; 19118 } 19119 /** 19120 * Start the release portion of the envelopes. 19121 */ 19122 triggerRelease(time) { 19123 time = this.toSeconds(time); 19124 this.envelope.triggerRelease(time); 19125 this.noise.stop(time + this.toSeconds(this.envelope.release)); 19126 return this; 19127 } 19128 sync() { 19129 if (this._syncState()) { 19130 this._syncMethod("triggerAttack", 0); 19131 this._syncMethod("triggerRelease", 0); 19132 } 19133 return this; 19134 } 19135 /** 19136 * Trigger the attack and then the release after the duration. 19137 * @param duration The amount of time to hold the note for 19138 * @param time The time the note should start 19139 * @param velocity The volume of the note (0-1) 19140 * @example 19141 * const noiseSynth = new Tone.NoiseSynth().toDestination(); 19142 * // hold the note for 0.5 seconds 19143 * noiseSynth.triggerAttackRelease(0.5); 19144 */ 19145 triggerAttackRelease(duration, time, velocity = 1) { 19146 time = this.toSeconds(time); 19147 duration = this.toSeconds(duration); 19148 this.triggerAttack(time, velocity); 19149 this.triggerRelease(time + duration); 19150 return this; 19151 } 19152 dispose() { 19153 super.dispose(); 19154 this.noise.dispose(); 19155 this.envelope.dispose(); 19156 return this; 19157 } 19158}; 19159
vendor: 460 bytes, lines 19160-19175
19160// node_modules/tone/build/esm/core/worklet/WorkletGlobalScope.js 19161var workletContext = /* @__PURE__ */ new Set(); 19162function addToWorklet(classOrFunction) { 19163 workletContext.add(classOrFunction); 19164} 19165function registerProcessor(name, classDesc) { 19166 const processor = ( 19167 /* javascript */ 19168 `registerProcessor("${name}", ${classDesc})` 19169 ); 19170 workletContext.add(processor); 19171} 19172function getWorkletGlobalScope() { 19173 return Array.from(workletContext).join("\n"); 19174} 19175
vendor: 1,023 bytes, lines 19176-19205
19176// node_modules/tone/build/esm/core/worklet/ToneAudioWorklet.js 19177var ToneAudioWorklet = class extends ToneAudioNode { 19178 constructor(options) { 19179 super(options); 19180 this.name = "ToneAudioWorklet"; 19181 this.workletOptions = {}; 19182 this.onprocessorerror = noOp; 19183 const blobUrl = URL.createObjectURL(new Blob([getWorkletGlobalScope()], { type: "text/javascript" })); 19184 const name = this._audioWorkletName(); 19185 this._dummyGain = this.context.createGain(); 19186 this._dummyParam = this._dummyGain.gain; 19187 this.context.addAudioWorkletModule(blobUrl).then(() => { 19188 if (!this.disposed) { 19189 this._worklet = this.context.createAudioWorkletNode(name, this.workletOptions); 19190 this._worklet.onprocessorerror = this.onprocessorerror.bind(this); 19191 this.onReady(this._worklet); 19192 } 19193 }); 19194 } 19195 dispose() { 19196 super.dispose(); 19197 this._dummyGain.disconnect(); 19198 if (this._worklet) { 19199 this._worklet.port.postMessage("dispose"); 19200 this._worklet.disconnect(); 19201 } 19202 return this; 19203 } 19204}; 19205
vendor: 842 bytes, lines 19206-19242
19206// node_modules/tone/build/esm/core/worklet/ToneAudioWorkletProcessor.worklet.js 19207var toneAudioWorkletProcessor = ( 19208 /* javascript */ 19209 ` 19210 /** 19211 * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}. 19212 */ 19213 class ToneAudioWorkletProcessor extends AudioWorkletProcessor { 19214 19215 constructor(options) { 19216 19217 super(options); 19218 /** 19219 * If the processor was disposed or not. Keep alive until it's disposed. 19220 */ 19221 this.disposed = false; 19222 /** 19223 * The number of samples in the processing block 19224 */ 19225 this.blockSize = 128; 19226 /** 19227 * the sample rate 19228 */ 19229 this.sampleRate = sampleRate; 19230 19231 this.port.onmessage = (event) => { 19232 // when it receives a dispose 19233 if (event.data === "dispose") { 19234 this.disposed = true; 19235 } 19236 }; 19237 } 19238 } 19239` 19240); 19241addToWorklet(toneAudioWorkletProcessor); 19242
vendor: 2,066 bytes, lines 19243-19316
19243// node_modules/tone/build/esm/core/worklet/SingleIOProcessor.worklet.js 19244var singleIOProcess = ( 19245 /* javascript */ 19246 ` 19247 /** 19248 * Abstract class for a single input/output processor. 19249 * has a 'generate' function which processes one sample at a time 19250 */ 19251 class SingleIOProcessor extends ToneAudioWorkletProcessor { 19252 19253 constructor(options) { 19254 super(Object.assign(options, { 19255 numberOfInputs: 1, 19256 numberOfOutputs: 1 19257 })); 19258 /** 19259 * Holds the name of the parameter and a single value of that 19260 * parameter at the current sample 19261 * @type { [name: string]: number } 19262 */ 19263 this.params = {} 19264 } 19265 19266 /** 19267 * Generate an output sample from the input sample and parameters 19268 * @abstract 19269 * @param input number 19270 * @param channel number 19271 * @param parameters { [name: string]: number } 19272 * @returns number 19273 */ 19274 generate(){} 19275 19276 /** 19277 * Update the private params object with the 19278 * values of the parameters at the given index 19279 * @param parameters { [name: string]: Float32Array }, 19280 * @param index number 19281 */ 19282 updateParams(parameters, index) { 19283 for (const paramName in parameters) { 19284 const param = parameters[paramName]; 19285 if (param.length > 1) { 19286 this.params[paramName] = parameters[paramName][index]; 19287 } else { 19288 this.params[paramName] = parameters[paramName][0]; 19289 } 19290 } 19291 } 19292 19293 /** 19294 * Process a single frame of the audio 19295 * @param inputs Float32Array[][] 19296 * @param outputs Float32Array[][] 19297 */ 19298 process(inputs, outputs, parameters) { 19299 const input = inputs[0]; 19300 const output = outputs[0]; 19301 // get the parameter values 19302 const channelCount = Math.max(input && input.length || 0, output.length); 19303 for (let sample = 0; sample < this.blockSize; sample++) { 19304 this.updateParams(parameters, sample); 19305 for (let channel = 0; channel < channelCount; channel++) { 19306 const inputSample = input && input.length ? input[channel][sample] : 0; 19307 output[channel][sample] = this.generate(inputSample, channel, this.params); 19308 } 19309 } 19310 return !this.disposed; 19311 } 19312 }; 19313` 19314); 19315addToWorklet(singleIOProcess); 19316
vendor: 1,136 bytes, lines 19317-19367
19317// node_modules/tone/build/esm/core/worklet/DelayLine.worklet.js 19318var delayLine = ( 19319 /* javascript */ 19320 ` 19321 /** 19322 * A multichannel buffer for use within an AudioWorkletProcessor as a delay line 19323 */ 19324 class DelayLine { 19325 19326 constructor(size, channels) { 19327 this.buffer = []; 19328 this.writeHead = [] 19329 this.size = size; 19330 19331 // create the empty channels 19332 for (let i = 0; i < channels; i++) { 19333 this.buffer[i] = new Float32Array(this.size); 19334 this.writeHead[i] = 0; 19335 } 19336 } 19337 19338 /** 19339 * Push a value onto the end 19340 * @param channel number 19341 * @param value number 19342 */ 19343 push(channel, value) { 19344 this.writeHead[channel] += 1; 19345 if (this.writeHead[channel] > this.size) { 19346 this.writeHead[channel] = 0; 19347 } 19348 this.buffer[channel][this.writeHead[channel]] = value; 19349 } 19350 19351 /** 19352 * Get the recorded value of the channel given the delay 19353 * @param channel number 19354 * @param delay number delay samples 19355 */ 19356 get(channel, delay) { 19357 let readHead = this.writeHead[channel] - Math.floor(delay); 19358 if (readHead < 0) { 19359 readHead += this.size; 19360 } 19361 return this.buffer[channel][readHead]; 19362 } 19363 } 19364` 19365); 19366addToWorklet(delayLine); 19367
vendor: 956 bytes, lines 19368-19405
19368// node_modules/tone/build/esm/component/filter/FeedbackCombFilter.worklet.js 19369var workletName = "feedback-comb-filter"; 19370var feedbackCombFilter = ( 19371 /* javascript */ 19372 ` 19373 class FeedbackCombFilterWorklet extends SingleIOProcessor { 19374 19375 constructor(options) { 19376 super(options); 19377 this.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2); 19378 } 19379 19380 static get parameterDescriptors() { 19381 return [{ 19382 name: "delayTime", 19383 defaultValue: 0.1, 19384 minValue: 0, 19385 maxValue: 1, 19386 automationRate: "k-rate" 19387 }, { 19388 name: "feedback", 19389 defaultValue: 0.5, 19390 minValue: 0, 19391 maxValue: 0.9999, 19392 automationRate: "k-rate" 19393 }]; 19394 } 19395 19396 generate(input, channel, parameters) { 19397 const delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate); 19398 this.delayLine.push(channel, input + delayedSample * parameters.feedback); 19399 return delayedSample; 19400 } 19401 } 19402` 19403); 19404registerProcessor(workletName, feedbackCombFilter); 19405
vendor: 1,560 bytes, lines 19406-19460
19406// node_modules/tone/build/esm/component/filter/FeedbackCombFilter.js 19407var FeedbackCombFilter = class _FeedbackCombFilter extends ToneAudioWorklet { 19408 constructor() { 19409 const options = optionsFromArguments(_FeedbackCombFilter.getDefaults(), arguments, ["delayTime", "resonance"]); 19410 super(options); 19411 this.name = "FeedbackCombFilter"; 19412 this.input = new Gain({ context: this.context }); 19413 this.output = new Gain({ context: this.context }); 19414 this.delayTime = new Param({ 19415 context: this.context, 19416 value: options.delayTime, 19417 units: "time", 19418 minValue: 0, 19419 maxValue: 1, 19420 param: this._dummyParam, 19421 swappable: true 19422 }); 19423 this.resonance = new Param({ 19424 context: this.context, 19425 value: options.resonance, 19426 units: "normalRange", 19427 param: this._dummyParam, 19428 swappable: true 19429 }); 19430 readOnly(this, ["resonance", "delayTime"]); 19431 } 19432 _audioWorkletName() { 19433 return workletName; 19434 } 19435 /** 19436 * The default parameters 19437 */ 19438 static getDefaults() { 19439 return Object.assign(ToneAudioNode.getDefaults(), { 19440 delayTime: 0.1, 19441 resonance: 0.5 19442 }); 19443 } 19444 onReady(node) { 19445 connectSeries(this.input, node, this.output); 19446 const delayTime = node.parameters.get("delayTime"); 19447 this.delayTime.setParam(delayTime); 19448 const feedback = node.parameters.get("feedback"); 19449 this.resonance.setParam(feedback); 19450 } 19451 dispose() { 19452 super.dispose(); 19453 this.input.dispose(); 19454 this.output.dispose(); 19455 this.delayTime.dispose(); 19456 this.resonance.dispose(); 19457 return this; 19458 } 19459}; 19460
vendor: 2,615 bytes, lines 19461-19550
19461// node_modules/tone/build/esm/component/filter/OnePoleFilter.js 19462var OnePoleFilter = class _OnePoleFilter extends ToneAudioNode { 19463 constructor() { 19464 const options = optionsFromArguments(_OnePoleFilter.getDefaults(), arguments, ["frequency", "type"]); 19465 super(options); 19466 this.name = "OnePoleFilter"; 19467 this._frequency = options.frequency; 19468 this._type = options.type; 19469 this.input = new Gain({ context: this.context }); 19470 this.output = new Gain({ context: this.context }); 19471 this._createFilter(); 19472 } 19473 static getDefaults() { 19474 return Object.assign(ToneAudioNode.getDefaults(), { 19475 frequency: 880, 19476 type: "lowpass" 19477 }); 19478 } 19479 /** 19480 * Create a filter and dispose the old one 19481 */ 19482 _createFilter() { 19483 const oldFilter = this._filter; 19484 const freq = this.toFrequency(this._frequency); 19485 const t = 1 / (2 * Math.PI * freq); 19486 if (this._type === "lowpass") { 19487 const a0 = 1 / (t * this.context.sampleRate); 19488 const b1 = a0 - 1; 19489 this._filter = this.context.createIIRFilter([a0, 0], [1, b1]); 19490 } else { 19491 const b1 = 1 / (t * this.context.sampleRate) - 1; 19492 this._filter = this.context.createIIRFilter([1, -1], [1, b1]); 19493 } 19494 this.input.chain(this._filter, this.output); 19495 if (oldFilter) { 19496 this.context.setTimeout(() => { 19497 if (!this.disposed) { 19498 this.input.disconnect(oldFilter); 19499 oldFilter.disconnect(); 19500 } 19501 }, this.blockTime); 19502 } 19503 } 19504 /** 19505 * The frequency value. 19506 */ 19507 get frequency() { 19508 return this._frequency; 19509 } 19510 set frequency(fq) { 19511 this._frequency = fq; 19512 this._createFilter(); 19513 } 19514 /** 19515 * The OnePole Filter type, either "highpass" or "lowpass" 19516 */ 19517 get type() { 19518 return this._type; 19519 } 19520 set type(t) { 19521 this._type = t; 19522 this._createFilter(); 19523 } 19524 /** 19525 * Get the frequency response curve. This curve represents how the filter 19526 * responses to frequencies between 20hz-20khz. 19527 * @param len The number of values to return 19528 * @return The frequency response curve between 20-20kHz 19529 */ 19530 getFrequencyResponse(len = 128) { 19531 const freqValues = new Float32Array(len); 19532 for (let i = 0; i < len; i++) { 19533 const norm = Math.pow(i / len, 2); 19534 const freq = norm * (2e4 - 20) + 20; 19535 freqValues[i] = freq; 19536 } 19537 const magValues = new Float32Array(len); 19538 const phaseValues = new Float32Array(len); 19539 this._filter.getFrequencyResponse(freqValues, magValues, phaseValues); 19540 return magValues; 19541 } 19542 dispose() { 19543 super.dispose(); 19544 this.input.dispose(); 19545 this.output.dispose(); 19546 this._filter.disconnect(); 19547 return this; 19548 } 19549}; 19550
vendor: 1,264 bytes, lines 19551-19594
19551// node_modules/tone/build/esm/component/filter/LowpassCombFilter.js 19552var LowpassCombFilter = class _LowpassCombFilter extends ToneAudioNode { 19553 constructor() { 19554 const options = optionsFromArguments(_LowpassCombFilter.getDefaults(), arguments, ["delayTime", "resonance", "dampening"]); 19555 super(options); 19556 this.name = "LowpassCombFilter"; 19557 this._combFilter = this.output = new FeedbackCombFilter({ 19558 context: this.context, 19559 delayTime: options.delayTime, 19560 resonance: options.resonance 19561 }); 19562 this.delayTime = this._combFilter.delayTime; 19563 this.resonance = this._combFilter.resonance; 19564 this._lowpass = this.input = new OnePoleFilter({ 19565 context: this.context, 19566 frequency: options.dampening, 19567 type: "lowpass" 19568 }); 19569 this._lowpass.connect(this._combFilter); 19570 } 19571 static getDefaults() { 19572 return Object.assign(ToneAudioNode.getDefaults(), { 19573 dampening: 3e3, 19574 delayTime: 0.1, 19575 resonance: 0.5 19576 }); 19577 } 19578 /** 19579 * The dampening control of the feedback 19580 */ 19581 get dampening() { 19582 return this._lowpass.frequency; 19583 } 19584 set dampening(fq) { 19585 this._lowpass.frequency = fq; 19586 } 19587 dispose() { 19588 super.dispose(); 19589 this._combFilter.dispose(); 19590 this._lowpass.dispose(); 19591 return this; 19592 } 19593}; 19594
vendor: 1,836 bytes, lines 19595-19660
19595// node_modules/tone/build/esm/instrument/PluckSynth.js 19596var PluckSynth = class _PluckSynth extends Instrument { 19597 constructor() { 19598 const options = optionsFromArguments(_PluckSynth.getDefaults(), arguments); 19599 super(options); 19600 this.name = "PluckSynth"; 19601 this._noise = new Noise({ 19602 context: this.context, 19603 type: "pink" 19604 }); 19605 this.attackNoise = options.attackNoise; 19606 this._lfcf = new LowpassCombFilter({ 19607 context: this.context, 19608 dampening: options.dampening, 19609 resonance: options.resonance 19610 }); 19611 this.resonance = options.resonance; 19612 this.release = options.release; 19613 this._noise.connect(this._lfcf); 19614 this._lfcf.connect(this.output); 19615 } 19616 static getDefaults() { 19617 return deepMerge(Instrument.getDefaults(), { 19618 attackNoise: 1, 19619 dampening: 4e3, 19620 resonance: 0.7, 19621 release: 1 19622 }); 19623 } 19624 /** 19625 * The dampening control. i.e. the lowpass filter frequency of the comb filter 19626 * @min 0 19627 * @max 7000 19628 */ 19629 get dampening() { 19630 return this._lfcf.dampening; 19631 } 19632 set dampening(fq) { 19633 this._lfcf.dampening = fq; 19634 } 19635 triggerAttack(note, time) { 19636 const freq = this.toFrequency(note); 19637 time = this.toSeconds(time); 19638 const delayAmount = 1 / freq; 19639 this._lfcf.delayTime.setValueAtTime(delayAmount, time); 19640 this._noise.start(time); 19641 this._noise.stop(time + delayAmount * this.attackNoise); 19642 this._lfcf.resonance.cancelScheduledValues(time); 19643 this._lfcf.resonance.setValueAtTime(this.resonance, time); 19644 return this; 19645 } 19646 /** 19647 * Ramp down the {@link resonance} to 0 over the duration of the release time. 19648 */ 19649 triggerRelease(time) { 19650 this._lfcf.resonance.linearRampTo(0, this.release, time); 19651 return this; 19652 } 19653 dispose() { 19654 super.dispose(); 19655 this._noise.dispose(); 19656 this._lfcf.dispose(); 19657 return this; 19658 } 19659}; 19660
vendor: 8,945 bytes, lines 19661-19916
19661// node_modules/tone/build/esm/instrument/PolySynth.js 19662var PolySynth = class _PolySynth extends Instrument { 19663 constructor() { 19664 const options = optionsFromArguments(_PolySynth.getDefaults(), arguments, ["voice", "options"]); 19665 super(options); 19666 this.name = "PolySynth"; 19667 this._availableVoices = []; 19668 this._activeVoices = []; 19669 this._voices = []; 19670 this._gcTimeout = -1; 19671 this._averageActiveVoices = 0; 19672 this._syncedRelease = (time) => this.releaseAll(time); 19673 assert(!isNumber(options.voice), "DEPRECATED: The polyphony count is no longer the first argument."); 19674 const defaults = options.voice.getDefaults(); 19675 this.options = Object.assign(defaults, options.options); 19676 this.voice = options.voice; 19677 this.maxPolyphony = options.maxPolyphony; 19678 this._dummyVoice = this._getNextAvailableVoice(); 19679 const index = this._voices.indexOf(this._dummyVoice); 19680 this._voices.splice(index, 1); 19681 this._gcTimeout = this.context.setInterval(this._collectGarbage.bind(this), 1); 19682 } 19683 static getDefaults() { 19684 return Object.assign(Instrument.getDefaults(), { 19685 maxPolyphony: 32, 19686 options: {}, 19687 voice: Synth 19688 }); 19689 } 19690 /** 19691 * The number of active voices. 19692 */ 19693 get activeVoices() { 19694 return this._activeVoices.length; 19695 } 19696 /** 19697 * Invoked when the source is done making sound, so that it can be 19698 * readded to the pool of available voices 19699 */ 19700 _makeVoiceAvailable(voice) { 19701 this._availableVoices.push(voice); 19702 const activeVoiceIndex = this._activeVoices.findIndex((e) => e.voice === voice); 19703 this._activeVoices.splice(activeVoiceIndex, 1); 19704 } 19705 /** 19706 * Get an available voice from the pool of available voices. 19707 * If one is not available and the maxPolyphony limit is reached, 19708 * steal a voice, otherwise return null. 19709 */ 19710 _getNextAvailableVoice() { 19711 if (this._availableVoices.length) { 19712 return this._availableVoices.shift(); 19713 } else if (this._voices.length < this.maxPolyphony) { 19714 const voice = new this.voice(Object.assign(this.options, { 19715 context: this.context, 19716 onsilence: this._makeVoiceAvailable.bind(this) 19717 })); 19718 assert(voice instanceof Monophonic, "Voice must extend Monophonic class"); 19719 voice.connect(this.output); 19720 this._voices.push(voice); 19721 return voice; 19722 } else { 19723 warn("Max polyphony exceeded. Note dropped."); 19724 } 19725 } 19726 /** 19727 * Occasionally check if there are any allocated voices which can be cleaned up. 19728 */ 19729 _collectGarbage() { 19730 this._averageActiveVoices = Math.max(this._averageActiveVoices * 0.95, this.activeVoices); 19731 if (this._availableVoices.length && this._voices.length > Math.ceil(this._averageActiveVoices + 1)) { 19732 const firstAvail = this._availableVoices.shift(); 19733 const index = this._voices.indexOf(firstAvail); 19734 this._voices.splice(index, 1); 19735 if (!this.context.isOffline) { 19736 firstAvail.dispose(); 19737 } 19738 } 19739 } 19740 /** 19741 * Internal method which triggers the attack 19742 */ 19743 _triggerAttack(notes, time, velocity) { 19744 notes.forEach((note) => { 19745 const midiNote = new MidiClass(this.context, note).toMidi(); 19746 const voice = this._getNextAvailableVoice(); 19747 if (voice) { 19748 voice.triggerAttack(note, time, velocity); 19749 this._activeVoices.push({ 19750 midi: midiNote, 19751 voice, 19752 released: false 19753 }); 19754 this.log("triggerAttack", note, time); 19755 } 19756 }); 19757 } 19758 /** 19759 * Internal method which triggers the release 19760 */ 19761 _triggerRelease(notes, time) { 19762 notes.forEach((note) => { 19763 const midiNote = new MidiClass(this.context, note).toMidi(); 19764 const event = this._activeVoices.find(({ midi, released }) => midi === midiNote && !released); 19765 if (event) { 19766 event.voice.triggerRelease(time); 19767 event.released = true; 19768 this.log("triggerRelease", note, time); 19769 } 19770 }); 19771 } 19772 /** 19773 * Schedule the attack/release events. If the time is in the future, then it should set a timeout 19774 * to wait for just-in-time scheduling 19775 */ 19776 _scheduleEvent(type, notes, time, velocity) { 19777 assert(!this.disposed, "Synth was already disposed"); 19778 if (time <= this.now()) { 19779 if (type === "attack") { 19780 this._triggerAttack(notes, time, velocity); 19781 } else { 19782 this._triggerRelease(notes, time); 19783 } 19784 } else { 19785 this.context.setTimeout(() => { 19786 if (!this.disposed) { 19787 this._scheduleEvent(type, notes, time, velocity); 19788 } 19789 }, time - this.now()); 19790 } 19791 } 19792 /** 19793 * Trigger the attack portion of the note 19794 * @param notes The notes to play. Accepts a single Frequency or an array of frequencies. 19795 * @param time The start time of the note. 19796 * @param velocity The velocity of the note. 19797 * @example 19798 * const synth = new Tone.PolySynth(Tone.FMSynth).toDestination(); 19799 * // trigger a chord immediately with a velocity of 0.2 19800 * synth.triggerAttack(["Ab3", "C4", "F5"], Tone.now(), 0.2); 19801 */ 19802 triggerAttack(notes, time, velocity) { 19803 if (!Array.isArray(notes)) { 19804 notes = [notes]; 19805 } 19806 const computedTime = this.toSeconds(time); 19807 this._scheduleEvent("attack", notes, computedTime, velocity); 19808 return this; 19809 } 19810 /** 19811 * Trigger the release of the note. Unlike monophonic instruments, 19812 * a note (or array of notes) needs to be passed in as the first argument. 19813 * @param notes The notes to play. Accepts a single Frequency or an array of frequencies. 19814 * @param time When the release will be triggered. 19815 * @example 19816 * const poly = new Tone.PolySynth(Tone.AMSynth).toDestination(); 19817 * poly.triggerAttack(["Ab3", "C4", "F5"]); 19818 * // trigger the release of the given notes. 19819 * poly.triggerRelease(["Ab3", "C4"], "+1"); 19820 * poly.triggerRelease("F5", "+3"); 19821 */ 19822 triggerRelease(notes, time) { 19823 if (!Array.isArray(notes)) { 19824 notes = [notes]; 19825 } 19826 const computedTime = this.toSeconds(time); 19827 this._scheduleEvent("release", notes, computedTime); 19828 return this; 19829 } 19830 /** 19831 * Trigger the attack and release after the specified duration 19832 * @param notes The notes to play. Accepts a single Frequency or an array of frequencies. 19833 * @param duration the duration of the note 19834 * @param time if no time is given, defaults to now 19835 * @param velocity the velocity of the attack (0-1) 19836 * @example 19837 * const poly = new Tone.PolySynth(Tone.AMSynth).toDestination(); 19838 * // can pass in an array of durations as well 19839 * poly.triggerAttackRelease(["Eb3", "G4", "Bb4", "D5"], [4, 3, 2, 1]); 19840 */ 19841 triggerAttackRelease(notes, duration, time, velocity) { 19842 const computedTime = this.toSeconds(time); 19843 this.triggerAttack(notes, computedTime, velocity); 19844 if (isArray(duration)) { 19845 assert(isArray(notes), "If the duration is an array, the notes must also be an array"); 19846 notes = notes; 19847 for (let i = 0; i < notes.length; i++) { 19848 const d = duration[Math.min(i, duration.length - 1)]; 19849 const durationSeconds = this.toSeconds(d); 19850 assert(durationSeconds > 0, "The duration must be greater than 0"); 19851 this.triggerRelease(notes[i], computedTime + durationSeconds); 19852 } 19853 } else { 19854 const durationSeconds = this.toSeconds(duration); 19855 assert(durationSeconds > 0, "The duration must be greater than 0"); 19856 this.triggerRelease(notes, computedTime + durationSeconds); 19857 } 19858 return this; 19859 } 19860 sync() { 19861 if (this._syncState()) { 19862 this._syncMethod("triggerAttack", 1); 19863 this._syncMethod("triggerRelease", 1); 19864 this.context.transport.on("stop", this._syncedRelease); 19865 this.context.transport.on("pause", this._syncedRelease); 19866 this.context.transport.on("loopEnd", this._syncedRelease); 19867 } 19868 return this; 19869 } 19870 /** 19871 * Set a member/attribute of the voices 19872 * @example 19873 * const poly = new Tone.PolySynth().toDestination(); 19874 * // set all of the voices using an options object for the synth type 19875 * poly.set({ 19876 * envelope: { 19877 * attack: 0.25 19878 * } 19879 * }); 19880 * poly.triggerAttackRelease("Bb3", 0.2); 19881 */ 19882 set(options) { 19883 const sanitizedOptions = omitFromObject(options, [ 19884 "onsilence", 19885 "context" 19886 ]); 19887 this.options = deepMerge(this.options, sanitizedOptions); 19888 this._voices.forEach((voice) => voice.set(sanitizedOptions)); 19889 this._dummyVoice.set(sanitizedOptions); 19890 return this; 19891 } 19892 get() { 19893 return this._dummyVoice.get(); 19894 } 19895 /** 19896 * Trigger the release portion of all the currently active voices immediately. 19897 * Useful for silencing the synth. 19898 */ 19899 releaseAll(time) { 19900 const computedTime = this.toSeconds(time); 19901 this._activeVoices.forEach(({ voice }) => { 19902 voice.triggerRelease(computedTime); 19903 }); 19904 return this; 19905 } 19906 dispose() { 19907 super.dispose(); 19908 this._dummyVoice.dispose(); 19909 this._voices.forEach((v) => v.dispose()); 19910 this._activeVoices = []; 19911 this._availableVoices = []; 19912 this.context.clearInterval(this._gcTimeout); 19913 return this; 19914 } 19915}; 19916
vendor: 6,642 bytes, lines 19917-20123
19917// node_modules/tone/build/esm/instrument/Sampler.js 19918var Sampler = class _Sampler extends Instrument { 19919 constructor() { 19920 const options = optionsFromArguments(_Sampler.getDefaults(), arguments, ["urls", "onload", "baseUrl"], "urls"); 19921 super(options); 19922 this.name = "Sampler"; 19923 this._activeSources = /* @__PURE__ */ new Map(); 19924 const urlMap = {}; 19925 Object.keys(options.urls).forEach((note) => { 19926 const noteNumber = parseInt(note, 10); 19927 assert(isNote(note) || isNumber(noteNumber) && isFinite(noteNumber), `url key is neither a note or midi pitch: ${note}`); 19928 if (isNote(note)) { 19929 const mid = new FrequencyClass(this.context, note).toMidi(); 19930 urlMap[mid] = options.urls[note]; 19931 } else if (isNumber(noteNumber) && isFinite(noteNumber)) { 19932 urlMap[noteNumber] = options.urls[noteNumber]; 19933 } 19934 }); 19935 this._buffers = new ToneAudioBuffers({ 19936 urls: urlMap, 19937 onload: options.onload, 19938 baseUrl: options.baseUrl, 19939 onerror: options.onerror 19940 }); 19941 this.attack = options.attack; 19942 this.release = options.release; 19943 this.curve = options.curve; 19944 if (this._buffers.loaded) { 19945 Promise.resolve().then(options.onload); 19946 } 19947 } 19948 static getDefaults() { 19949 return Object.assign(Instrument.getDefaults(), { 19950 attack: 0, 19951 baseUrl: "", 19952 curve: "exponential", 19953 onload: noOp, 19954 onerror: noOp, 19955 release: 0.1, 19956 urls: {} 19957 }); 19958 } 19959 /** 19960 * Returns the difference in steps between the given midi note at the closets sample. 19961 */ 19962 _findClosest(midi) { 19963 const MAX_INTERVAL = 96; 19964 let interval = 0; 19965 while (interval < MAX_INTERVAL) { 19966 if (this._buffers.has(midi + interval)) { 19967 return -interval; 19968 } else if (this._buffers.has(midi - interval)) { 19969 return interval; 19970 } 19971 interval++; 19972 } 19973 throw new Error(`No available buffers for note: ${midi}`); 19974 } 19975 /** 19976 * @param notes The note to play, or an array of notes. 19977 * @param time When to play the note 19978 * @param velocity The velocity to play the sample back. 19979 */ 19980 triggerAttack(notes, time, velocity = 1) { 19981 this.log("triggerAttack", notes, time, velocity); 19982 if (!Array.isArray(notes)) { 19983 notes = [notes]; 19984 } 19985 notes.forEach((note) => { 19986 const midiFloat = ftomf(new FrequencyClass(this.context, note).toFrequency()); 19987 const midi = Math.round(midiFloat); 19988 const remainder = midiFloat - midi; 19989 const difference = this._findClosest(midi); 19990 const closestNote = midi - difference; 19991 const buffer = this._buffers.get(closestNote); 19992 const playbackRate = intervalToFrequencyRatio(difference + remainder); 19993 const source = new ToneBufferSource({ 19994 url: buffer, 19995 context: this.context, 19996 curve: this.curve, 19997 fadeIn: this.attack, 19998 fadeOut: this.release, 19999 playbackRate 20000 }).connect(this.output); 20001 source.start(time, 0, buffer.duration / playbackRate, velocity); 20002 if (!isArray(this._activeSources.get(midi))) { 20003 this._activeSources.set(midi, []); 20004 } 20005 this._activeSources.get(midi).push(source); 20006 source.onended = () => { 20007 if (this._activeSources && this._activeSources.has(midi)) { 20008 const sources = this._activeSources.get(midi); 20009 const index = sources.indexOf(source); 20010 if (index !== -1) { 20011 sources.splice(index, 1); 20012 } 20013 } 20014 }; 20015 }); 20016 return this; 20017 } 20018 /** 20019 * @param notes The note to release, or an array of notes. 20020 * @param time When to release the note. 20021 */ 20022 triggerRelease(notes, time) { 20023 this.log("triggerRelease", notes, time); 20024 if (!Array.isArray(notes)) { 20025 notes = [notes]; 20026 } 20027 notes.forEach((note) => { 20028 const midi = new FrequencyClass(this.context, note).toMidi(); 20029 if (this._activeSources.has(midi) && this._activeSources.get(midi).length) { 20030 const sources = this._activeSources.get(midi); 20031 time = this.toSeconds(time); 20032 sources.forEach((source) => { 20033 source.stop(time); 20034 }); 20035 this._activeSources.set(midi, []); 20036 } 20037 }); 20038 return this; 20039 } 20040 /** 20041 * Release all currently active notes. 20042 * @param time When to release the notes. 20043 */ 20044 releaseAll(time) { 20045 const computedTime = this.toSeconds(time); 20046 this._activeSources.forEach((sources) => { 20047 while (sources.length) { 20048 const source = sources.shift(); 20049 source.stop(computedTime); 20050 } 20051 }); 20052 return this; 20053 } 20054 sync() { 20055 if (this._syncState()) { 20056 this._syncMethod("triggerAttack", 1); 20057 this._syncMethod("triggerRelease", 1); 20058 } 20059 return this; 20060 } 20061 /** 20062 * Invoke the attack phase, then after the duration, invoke the release. 20063 * @param notes The note to play and release, or an array of notes. 20064 * @param duration The time the note should be held 20065 * @param time When to start the attack 20066 * @param velocity The velocity of the attack 20067 */ 20068 triggerAttackRelease(notes, duration, time, velocity = 1) { 20069 const computedTime = this.toSeconds(time); 20070 this.triggerAttack(notes, computedTime, velocity); 20071 if (isArray(duration)) { 20072 assert(isArray(notes), "notes must be an array when duration is array"); 20073 notes.forEach((note, index) => { 20074 const d = duration[Math.min(index, duration.length - 1)]; 20075 this.triggerRelease(note, computedTime + this.toSeconds(d)); 20076 }); 20077 } else { 20078 this.triggerRelease(notes, computedTime + this.toSeconds(duration)); 20079 } 20080 return this; 20081 } 20082 /** 20083 * Add a note to the sampler. 20084 * @param note The buffer's pitch. 20085 * @param url Either the url of the buffer, or a buffer which will be added with the given name. 20086 * @param callback The callback to invoke when the url is loaded. 20087 */ 20088 add(note, url, callback) { 20089 assert(isNote(note) || isFinite(note), `note must be a pitch or midi: ${note}`); 20090 if (isNote(note)) { 20091 const mid = new FrequencyClass(this.context, note).toMidi(); 20092 this._buffers.add(mid, url, callback); 20093 } else { 20094 this._buffers.add(note, url, callback); 20095 } 20096 return this; 20097 } 20098 /** 20099 * If the buffers are loaded or not 20100 */ 20101 get loaded() { 20102 return this._buffers.loaded; 20103 } 20104 /** 20105 * Clean up 20106 */ 20107 dispose() { 20108 super.dispose(); 20109 this._buffers.dispose(); 20110 this._activeSources.forEach((sources) => { 20111 sources.forEach((source) => source.dispose()); 20112 }); 20113 this._activeSources.clear(); 20114 return this; 20115 } 20116}; 20117__decorate([ 20118 timeRange(0) 20119], Sampler.prototype, "attack", void 0); 20120__decorate([ 20121 timeRange(0) 20122], Sampler.prototype, "release", void 0); 20123
vendor: 7,611 bytes, lines 20124-20387
20124// node_modules/tone/build/esm/event/ToneEvent.js 20125var ToneEvent = class _ToneEvent extends ToneWithContext { 20126 constructor() { 20127 const options = optionsFromArguments(_ToneEvent.getDefaults(), arguments, ["callback", "value"]); 20128 super(options); 20129 this.name = "ToneEvent"; 20130 this._state = new StateTimeline("stopped"); 20131 this._startOffset = 0; 20132 this._loop = options.loop; 20133 this.callback = options.callback; 20134 this.value = options.value; 20135 this._loopStart = this.toTicks(options.loopStart); 20136 this._loopEnd = this.toTicks(options.loopEnd); 20137 this._playbackRate = options.playbackRate; 20138 this._probability = options.probability; 20139 this._humanize = options.humanize; 20140 this.mute = options.mute; 20141 this._playbackRate = options.playbackRate; 20142 this._state.increasing = true; 20143 this._rescheduleEvents(); 20144 } 20145 static getDefaults() { 20146 return Object.assign(ToneWithContext.getDefaults(), { 20147 callback: noOp, 20148 humanize: false, 20149 loop: false, 20150 loopEnd: "1m", 20151 loopStart: 0, 20152 mute: false, 20153 playbackRate: 1, 20154 probability: 1, 20155 value: null 20156 }); 20157 } 20158 /** 20159 * Reschedule all of the events along the timeline 20160 * with the updated values. 20161 * @param after Only reschedules events after the given time. 20162 */ 20163 _rescheduleEvents(after = -1) { 20164 this._state.forEachFrom(after, (event) => { 20165 let duration; 20166 if (event.state === "started") { 20167 if (event.id !== -1) { 20168 this.context.transport.clear(event.id); 20169 } 20170 const startTick = event.time + Math.round(this.startOffset / this._playbackRate); 20171 if (this._loop === true || isNumber(this._loop) && this._loop > 1) { 20172 duration = Infinity; 20173 if (isNumber(this._loop)) { 20174 duration = this._loop * this._getLoopDuration(); 20175 } 20176 const nextEvent = this._state.getAfter(startTick); 20177 if (nextEvent !== null) { 20178 duration = Math.min(duration, nextEvent.time - startTick); 20179 } 20180 if (duration !== Infinity) { 20181 duration = new TicksClass(this.context, duration); 20182 } 20183 const interval = new TicksClass(this.context, this._getLoopDuration()); 20184 event.id = this.context.transport.scheduleRepeat(this._tick.bind(this), interval, new TicksClass(this.context, startTick), duration); 20185 } else { 20186 event.id = this.context.transport.schedule(this._tick.bind(this), new TicksClass(this.context, startTick)); 20187 } 20188 } 20189 }); 20190 } 20191 /** 20192 * Returns the playback state of the note, either "started" or "stopped". 20193 */ 20194 get state() { 20195 return this._state.getValueAtTime(this.context.transport.ticks); 20196 } 20197 /** 20198 * The start from the scheduled start time. 20199 */ 20200 get startOffset() { 20201 return this._startOffset; 20202 } 20203 set startOffset(offset) { 20204 this._startOffset = offset; 20205 } 20206 /** 20207 * The probability of the notes being triggered. 20208 */ 20209 get probability() { 20210 return this._probability; 20211 } 20212 set probability(prob) { 20213 this._probability = prob; 20214 } 20215 /** 20216 * If set to true, will apply small random variation 20217 * to the callback time. If the value is given as a time, it will randomize 20218 * by that amount. 20219 * @example 20220 * const event = new Tone.ToneEvent(); 20221 * event.humanize = true; 20222 */ 20223 get humanize() { 20224 return this._humanize; 20225 } 20226 set humanize(variation) { 20227 this._humanize = variation; 20228 } 20229 /** 20230 * Start the note at the given time. 20231 * @param time When the event should start. 20232 */ 20233 start(time) { 20234 const ticks = this.toTicks(time); 20235 if (this._state.getValueAtTime(ticks) === "stopped") { 20236 this._state.add({ 20237 id: -1, 20238 state: "started", 20239 time: ticks 20240 }); 20241 this._rescheduleEvents(ticks); 20242 } 20243 return this; 20244 } 20245 /** 20246 * Stop the Event at the given time. 20247 * @param time When the event should stop. 20248 */ 20249 stop(time) { 20250 this.cancel(time); 20251 const ticks = this.toTicks(time); 20252 if (this._state.getValueAtTime(ticks) === "started") { 20253 this._state.setStateAtTime("stopped", ticks, { id: -1 }); 20254 const previousEvent = this._state.getBefore(ticks); 20255 let rescheduleTime = ticks; 20256 if (previousEvent !== null) { 20257 rescheduleTime = previousEvent.time; 20258 } 20259 this._rescheduleEvents(rescheduleTime); 20260 } 20261 return this; 20262 } 20263 /** 20264 * Cancel all scheduled events greater than or equal to the given time 20265 * @param time The time after which events will be cancel. 20266 */ 20267 cancel(time) { 20268 time = defaultArg(time, -Infinity); 20269 const ticks = this.toTicks(time); 20270 this._state.forEachFrom(ticks, (event) => { 20271 this.context.transport.clear(event.id); 20272 }); 20273 this._state.cancel(ticks); 20274 return this; 20275 } 20276 /** 20277 * The callback function invoker. Also 20278 * checks if the Event is done playing 20279 * @param time The time of the event in seconds 20280 */ 20281 _tick(time) { 20282 const ticks = this.context.transport.getTicksAtTime(time); 20283 if (!this.mute && this._state.getValueAtTime(ticks) === "started") { 20284 if (this.probability < 1 && Math.random() > this.probability) { 20285 return; 20286 } 20287 if (this.humanize) { 20288 let variation = 0.02; 20289 if (!isBoolean(this.humanize)) { 20290 variation = this.toSeconds(this.humanize); 20291 } 20292 time += (Math.random() * 2 - 1) * variation; 20293 } 20294 this.callback(time, this.value); 20295 } 20296 } 20297 /** 20298 * Get the duration of the loop. 20299 */ 20300 _getLoopDuration() { 20301 return (this._loopEnd - this._loopStart) / this._playbackRate; 20302 } 20303 /** 20304 * If the note should loop or not 20305 * between ToneEvent.loopStart and 20306 * ToneEvent.loopEnd. If set to true, 20307 * the event will loop indefinitely, 20308 * if set to a number greater than 1 20309 * it will play a specific number of 20310 * times, if set to false, 0 or 1, the 20311 * part will only play once. 20312 */ 20313 get loop() { 20314 return this._loop; 20315 } 20316 set loop(loop) { 20317 this._loop = loop; 20318 this._rescheduleEvents(); 20319 } 20320 /** 20321 * The playback rate of the event. Defaults to 1. 20322 * @example 20323 * const note = new Tone.ToneEvent(); 20324 * note.loop = true; 20325 * // repeat the note twice as fast 20326 * note.playbackRate = 2; 20327 */ 20328 get playbackRate() { 20329 return this._playbackRate; 20330 } 20331 set playbackRate(rate) { 20332 this._playbackRate = rate; 20333 this._rescheduleEvents(); 20334 } 20335 /** 20336 * The loopEnd point is the time the event will loop 20337 * if ToneEvent.loop is true. 20338 */ 20339 get loopEnd() { 20340 return new TicksClass(this.context, this._loopEnd).toSeconds(); 20341 } 20342 set loopEnd(loopEnd) { 20343 this._loopEnd = this.toTicks(loopEnd); 20344 if (this._loop) { 20345 this._rescheduleEvents(); 20346 } 20347 } 20348 /** 20349 * The time when the loop should start. 20350 */ 20351 get loopStart() { 20352 return new TicksClass(this.context, this._loopStart).toSeconds(); 20353 } 20354 set loopStart(loopStart) { 20355 this._loopStart = this.toTicks(loopStart); 20356 if (this._loop) { 20357 this._rescheduleEvents(); 20358 } 20359 } 20360 /** 20361 * The current progress of the loop interval. 20362 * Returns 0 if the event is not started yet or 20363 * it is not set to loop. 20364 */ 20365 get progress() { 20366 if (this._loop) { 20367 const ticks = this.context.transport.ticks; 20368 const lastEvent = this._state.get(ticks); 20369 if (lastEvent !== null && lastEvent.state === "started") { 20370 const loopDuration = this._getLoopDuration(); 20371 const progress = (ticks - lastEvent.time) % loopDuration; 20372 return progress / loopDuration; 20373 } else { 20374 return 0; 20375 } 20376 } else { 20377 return 0; 20378 } 20379 } 20380 dispose() { 20381 super.dispose(); 20382 this.cancel(); 20383 this._state.dispose(); 20384 return this; 20385 } 20386}; 20387
vendor: 9,323 bytes, lines 20388-20736
20388// node_modules/tone/build/esm/event/Part.js 20389var Part = class _Part extends ToneEvent { 20390 constructor() { 20391 const options = optionsFromArguments(_Part.getDefaults(), arguments, [ 20392 "callback", 20393 "events" 20394 ]); 20395 super(options); 20396 this.name = "Part"; 20397 this._state = new StateTimeline("stopped"); 20398 this._events = /* @__PURE__ */ new Set(); 20399 this._state.increasing = true; 20400 options.events.forEach((event) => { 20401 if (isArray(event)) { 20402 this.add(event[0], event[1]); 20403 } else { 20404 this.add(event); 20405 } 20406 }); 20407 } 20408 static getDefaults() { 20409 return Object.assign(ToneEvent.getDefaults(), { 20410 events: [] 20411 }); 20412 } 20413 /** 20414 * Start the part at the given time. 20415 * @param time When to start the part. 20416 * @param offset The offset from the start of the part to begin playing at. 20417 */ 20418 start(time, offset) { 20419 const ticks = this.toTicks(time); 20420 if (this._state.getValueAtTime(ticks) !== "started") { 20421 offset = defaultArg(offset, this._loop ? this._loopStart : 0); 20422 if (this._loop) { 20423 offset = defaultArg(offset, this._loopStart); 20424 } else { 20425 offset = defaultArg(offset, 0); 20426 } 20427 const computedOffset = this.toTicks(offset); 20428 this._state.add({ 20429 id: -1, 20430 offset: computedOffset, 20431 state: "started", 20432 time: ticks 20433 }); 20434 this._forEach((event) => { 20435 this._startNote(event, ticks, computedOffset); 20436 }); 20437 } 20438 return this; 20439 } 20440 /** 20441 * Start the event in the given event at the correct time given 20442 * the ticks and offset and looping. 20443 * @param event 20444 * @param ticks 20445 * @param offset 20446 */ 20447 _startNote(event, ticks, offset) { 20448 ticks -= offset; 20449 if (this._loop) { 20450 if (event.startOffset >= this._loopStart && event.startOffset < this._loopEnd) { 20451 if (event.startOffset < offset) { 20452 ticks += this._getLoopDuration(); 20453 } 20454 event.start(new TicksClass(this.context, ticks)); 20455 } else if (event.startOffset < this._loopStart && event.startOffset >= offset) { 20456 event.loop = false; 20457 event.start(new TicksClass(this.context, ticks)); 20458 } 20459 } else if (event.startOffset >= offset) { 20460 event.start(new TicksClass(this.context, ticks)); 20461 } 20462 } 20463 get startOffset() { 20464 return this._startOffset; 20465 } 20466 set startOffset(offset) { 20467 this._startOffset = offset; 20468 this._forEach((event) => { 20469 event.startOffset += this._startOffset; 20470 }); 20471 } 20472 /** 20473 * Stop the part at the given time. 20474 * @param time When to stop the part. 20475 */ 20476 stop(time) { 20477 const ticks = this.toTicks(time); 20478 this._state.cancel(ticks); 20479 this._state.setStateAtTime("stopped", ticks); 20480 this._forEach((event) => { 20481 event.stop(time); 20482 }); 20483 return this; 20484 } 20485 /** 20486 * Get/Set an Event's value at the given time. 20487 * If a value is passed in and no event exists at 20488 * the given time, one will be created with that value. 20489 * If two events are at the same time, the first one will 20490 * be returned. 20491 * @example 20492 * const part = new Tone.Part(); 20493 * part.at("1m"); // returns the part at the first measure 20494 * part.at("2m", "C2"); // set the value at "2m" to C2. 20495 * // if an event didn't exist at that time, it will be created. 20496 * @param time The time of the event to get or set. 20497 * @param value If a value is passed in, the value of the event at the given time will be set to it. 20498 */ 20499 at(time, value) { 20500 const timeInTicks = new TransportTimeClass(this.context, time).toTicks(); 20501 const tickTime = new TicksClass(this.context, 1).toSeconds(); 20502 const iterator = this._events.values(); 20503 let result = iterator.next(); 20504 while (!result.done) { 20505 const event = result.value; 20506 if (Math.abs(timeInTicks - event.startOffset) < tickTime) { 20507 if (isDefined(value)) { 20508 event.value = value; 20509 } 20510 return event; 20511 } 20512 result = iterator.next(); 20513 } 20514 if (isDefined(value)) { 20515 this.add(time, value); 20516 return this.at(time); 20517 } else { 20518 return null; 20519 } 20520 } 20521 add(time, value) { 20522 if (time instanceof Object && Reflect.has(time, "time")) { 20523 value = time; 20524 time = value.time; 20525 } 20526 const ticks = this.toTicks(time); 20527 let event; 20528 if (value instanceof ToneEvent) { 20529 event = value; 20530 event.callback = this._tick.bind(this); 20531 } else { 20532 event = new ToneEvent({ 20533 callback: this._tick.bind(this), 20534 context: this.context, 20535 value 20536 }); 20537 } 20538 event.startOffset = ticks; 20539 event.set({ 20540 humanize: this.humanize, 20541 loop: this.loop, 20542 loopEnd: this.loopEnd, 20543 loopStart: this.loopStart, 20544 playbackRate: this.playbackRate, 20545 probability: this.probability 20546 }); 20547 this._events.add(event); 20548 this._restartEvent(event); 20549 return this; 20550 } 20551 /** 20552 * Restart the given event 20553 */ 20554 _restartEvent(event) { 20555 this._state.forEach((stateEvent) => { 20556 if (stateEvent.state === "started") { 20557 this._startNote(event, stateEvent.time, stateEvent.offset); 20558 } else { 20559 event.stop(new TicksClass(this.context, stateEvent.time)); 20560 } 20561 }); 20562 } 20563 remove(time, value) { 20564 if (isObject(time) && time.hasOwnProperty("time")) { 20565 value = time; 20566 time = value.time; 20567 } 20568 time = this.toTicks(time); 20569 this._events.forEach((event) => { 20570 if (event.startOffset === time) { 20571 if (isUndef(value) || isDefined(value) && event.value === value) { 20572 this._events.delete(event); 20573 event.dispose(); 20574 } 20575 } 20576 }); 20577 return this; 20578 } 20579 /** 20580 * Remove all of the notes from the group. 20581 */ 20582 clear() { 20583 this._forEach((event) => event.dispose()); 20584 this._events.clear(); 20585 return this; 20586 } 20587 /** 20588 * Cancel scheduled state change events: i.e. "start" and "stop". 20589 * @param after The time after which to cancel the scheduled events. 20590 */ 20591 cancel(after) { 20592 this._forEach((event) => event.cancel(after)); 20593 this._state.cancel(this.toTicks(after)); 20594 return this; 20595 } 20596 /** 20597 * Iterate over all of the events 20598 */ 20599 _forEach(callback) { 20600 if (this._events) { 20601 this._events.forEach((event) => { 20602 if (event instanceof _Part) { 20603 event._forEach(callback); 20604 } else { 20605 callback(event); 20606 } 20607 }); 20608 } 20609 return this; 20610 } 20611 /** 20612 * Set the attribute of all of the events 20613 * @param attr the attribute to set 20614 * @param value The value to set it to 20615 */ 20616 _setAll(attr, value) { 20617 this._forEach((event) => { 20618 event[attr] = value; 20619 }); 20620 } 20621 /** 20622 * Internal tick method 20623 * @param time The time of the event in seconds 20624 */ 20625 _tick(time, value) { 20626 if (!this.mute) { 20627 this.callback(time, value); 20628 } 20629 } 20630 /** 20631 * Determine if the event should be currently looping 20632 * given the loop boundries of this Part. 20633 * @param event The event to test 20634 */ 20635 _testLoopBoundries(event) { 20636 if (this._loop && (event.startOffset < this._loopStart || event.startOffset >= this._loopEnd)) { 20637 event.cancel(0); 20638 } else if (event.state === "stopped") { 20639 this._restartEvent(event); 20640 } 20641 } 20642 get probability() { 20643 return this._probability; 20644 } 20645 set probability(prob) { 20646 this._probability = prob; 20647 this._setAll("probability", prob); 20648 } 20649 get humanize() { 20650 return this._humanize; 20651 } 20652 set humanize(variation) { 20653 this._humanize = variation; 20654 this._setAll("humanize", variation); 20655 } 20656 /** 20657 * If the part should loop or not 20658 * between Part.loopStart and 20659 * Part.loopEnd. If set to true, 20660 * the part will loop indefinitely, 20661 * if set to a number greater than 1 20662 * it will play a specific number of 20663 * times, if set to false, 0 or 1, the 20664 * part will only play once. 20665 * @example 20666 * const part = new Tone.Part(); 20667 * // loop the part 8 times 20668 * part.loop = 8; 20669 */ 20670 get loop() { 20671 return this._loop; 20672 } 20673 set loop(loop) { 20674 this._loop = loop; 20675 this._forEach((event) => { 20676 event.loopStart = this.loopStart; 20677 event.loopEnd = this.loopEnd; 20678 event.loop = loop; 20679 this._testLoopBoundries(event); 20680 }); 20681 } 20682 /** 20683 * The loopEnd point determines when it will 20684 * loop if Part.loop is true. 20685 */ 20686 get loopEnd() { 20687 return new TicksClass(this.context, this._loopEnd).toSeconds(); 20688 } 20689 set loopEnd(loopEnd) { 20690 this._loopEnd = this.toTicks(loopEnd); 20691 if (this._loop) { 20692 this._forEach((event) => { 20693 event.loopEnd = loopEnd; 20694 this._testLoopBoundries(event); 20695 }); 20696 } 20697 } 20698 /** 20699 * The loopStart point determines when it will 20700 * loop if Part.loop is true. 20701 */ 20702 get loopStart() { 20703 return new TicksClass(this.context, this._loopStart).toSeconds(); 20704 } 20705 set loopStart(loopStart) { 20706 this._loopStart = this.toTicks(loopStart); 20707 if (this._loop) { 20708 this._forEach((event) => { 20709 event.loopStart = this.loopStart; 20710 this._testLoopBoundries(event); 20711 }); 20712 } 20713 } 20714 /** 20715 * The playback rate of the part 20716 */ 20717 get playbackRate() { 20718 return this._playbackRate; 20719 } 20720 set playbackRate(rate) { 20721 this._playbackRate = rate; 20722 this._setAll("playbackRate", rate); 20723 } 20724 /** 20725 * The number of scheduled notes in the part. 20726 */ 20727 get length() { 20728 return this._events.size; 20729 } 20730 dispose() { 20731 super.dispose(); 20732 this.clear(); 20733 return this; 20734 } 20735}; 20736
vendor: 5,405 bytes, lines 20737-20946
20737// node_modules/tone/build/esm/event/Sequence.js 20738var Sequence = class _Sequence extends ToneEvent { 20739 constructor() { 20740 const options = optionsFromArguments(_Sequence.getDefaults(), arguments, ["callback", "events", "subdivision"]); 20741 super(options); 20742 this.name = "Sequence"; 20743 this._part = new Part({ 20744 callback: this._seqCallback.bind(this), 20745 context: this.context 20746 }); 20747 this._events = []; 20748 this._eventsArray = []; 20749 this._subdivision = this.toTicks(options.subdivision); 20750 this.events = options.events; 20751 this.loop = options.loop; 20752 this.loopStart = options.loopStart; 20753 this.loopEnd = options.loopEnd; 20754 this.playbackRate = options.playbackRate; 20755 this.probability = options.probability; 20756 this.humanize = options.humanize; 20757 this.mute = options.mute; 20758 this.playbackRate = options.playbackRate; 20759 } 20760 static getDefaults() { 20761 return Object.assign(omitFromObject(ToneEvent.getDefaults(), ["value"]), { 20762 events: [], 20763 loop: true, 20764 loopEnd: 0, 20765 loopStart: 0, 20766 subdivision: "8n" 20767 }); 20768 } 20769 /** 20770 * The internal callback for when an event is invoked 20771 */ 20772 _seqCallback(time, value) { 20773 if (value !== null && !this.mute) { 20774 this.callback(time, value); 20775 } 20776 } 20777 /** 20778 * The sequence 20779 */ 20780 get events() { 20781 return this._events; 20782 } 20783 set events(s) { 20784 this.clear(); 20785 this._eventsArray = s; 20786 this._events = this._createSequence(this._eventsArray); 20787 this._eventsUpdated(); 20788 } 20789 /** 20790 * Start the part at the given time. 20791 * @param time When to start the part. 20792 * @param offset The offset index to start at 20793 */ 20794 start(time, offset) { 20795 this._part.start(time, offset ? this._indexTime(offset) : offset); 20796 return this; 20797 } 20798 /** 20799 * Stop the part at the given time. 20800 * @param time When to stop the part. 20801 */ 20802 stop(time) { 20803 this._part.stop(time); 20804 return this; 20805 } 20806 /** 20807 * The subdivision of the sequence. This can only be 20808 * set in the constructor. The subdivision is the 20809 * interval between successive steps. 20810 */ 20811 get subdivision() { 20812 return new TicksClass(this.context, this._subdivision).toSeconds(); 20813 } 20814 /** 20815 * Create a sequence proxy which can be monitored to create subsequences 20816 */ 20817 _createSequence(array) { 20818 return new Proxy(array, { 20819 get: (target, property) => { 20820 return target[property]; 20821 }, 20822 set: (target, property, value) => { 20823 if (isString(property) && isFinite(parseInt(property, 10))) { 20824 if (isArray(value)) { 20825 target[property] = this._createSequence(value); 20826 } else { 20827 target[property] = value; 20828 } 20829 } else { 20830 target[property] = value; 20831 } 20832 this._eventsUpdated(); 20833 return true; 20834 } 20835 }); 20836 } 20837 /** 20838 * When the sequence has changed, all of the events need to be recreated 20839 */ 20840 _eventsUpdated() { 20841 this._part.clear(); 20842 this._rescheduleSequence(this._eventsArray, this._subdivision, this.startOffset); 20843 this.loopEnd = this.loopEnd; 20844 } 20845 /** 20846 * reschedule all of the events that need to be rescheduled 20847 */ 20848 _rescheduleSequence(sequence, subdivision, startOffset) { 20849 sequence.forEach((value, index) => { 20850 const eventOffset = index * subdivision + startOffset; 20851 if (isArray(value)) { 20852 this._rescheduleSequence(value, subdivision / value.length, eventOffset); 20853 } else { 20854 const startTime = new TicksClass(this.context, eventOffset, "i").toSeconds(); 20855 this._part.add(startTime, value); 20856 } 20857 }); 20858 } 20859 /** 20860 * Get the time of the index given the Sequence's subdivision 20861 * @param index 20862 * @return The time of that index 20863 */ 20864 _indexTime(index) { 20865 return new TicksClass(this.context, index * this._subdivision + this.startOffset).toSeconds(); 20866 } 20867 /** 20868 * Clear all of the events 20869 */ 20870 clear() { 20871 this._part.clear(); 20872 return this; 20873 } 20874 dispose() { 20875 super.dispose(); 20876 this._part.dispose(); 20877 return this; 20878 } 20879 //------------------------------------- 20880 // PROXY CALLS 20881 //------------------------------------- 20882 get loop() { 20883 return this._part.loop; 20884 } 20885 set loop(l) { 20886 this._part.loop = l; 20887 } 20888 /** 20889 * The index at which the sequence should start looping 20890 */ 20891 get loopStart() { 20892 return this._loopStart; 20893 } 20894 set loopStart(index) { 20895 this._loopStart = index; 20896 this._part.loopStart = this._indexTime(index); 20897 } 20898 /** 20899 * The index at which the sequence should end looping 20900 */ 20901 get loopEnd() { 20902 return this._loopEnd; 20903 } 20904 set loopEnd(index) { 20905 this._loopEnd = index; 20906 if (index === 0) { 20907 this._part.loopEnd = this._indexTime(this._eventsArray.length); 20908 } else { 20909 this._part.loopEnd = this._indexTime(index); 20910 } 20911 } 20912 get startOffset() { 20913 return this._part.startOffset; 20914 } 20915 set startOffset(start2) { 20916 this._part.startOffset = start2; 20917 } 20918 get playbackRate() { 20919 return this._part.playbackRate; 20920 } 20921 set playbackRate(rate) { 20922 this._part.playbackRate = rate; 20923 } 20924 get probability() { 20925 return this._part.probability; 20926 } 20927 set probability(prob) { 20928 this._part.probability = prob; 20929 } 20930 get progress() { 20931 return this._part.progress; 20932 } 20933 get humanize() { 20934 return this._part.humanize; 20935 } 20936 set humanize(variation) { 20937 this._part.humanize = variation; 20938 } 20939 /** 20940 * The number of scheduled events 20941 */ 20942 get length() { 20943 return this._part.length; 20944 } 20945}; 20946
vendor: 1,578 bytes, lines 20947-20999
20947// node_modules/tone/build/esm/component/channel/CrossFade.js 20948var CrossFade = class _CrossFade extends ToneAudioNode { 20949 constructor() { 20950 const options = optionsFromArguments(_CrossFade.getDefaults(), arguments, ["fade"]); 20951 super(options); 20952 this.name = "CrossFade"; 20953 this._panner = this.context.createStereoPanner(); 20954 this._split = this.context.createChannelSplitter(2); 20955 this._g2a = new GainToAudio({ context: this.context }); 20956 this.a = new Gain({ 20957 context: this.context, 20958 gain: 0 20959 }); 20960 this.b = new Gain({ 20961 context: this.context, 20962 gain: 0 20963 }); 20964 this.output = new Gain({ context: this.context }); 20965 this._internalChannels = [this.a, this.b]; 20966 this.fade = new Signal({ 20967 context: this.context, 20968 units: "normalRange", 20969 value: options.fade 20970 }); 20971 readOnly(this, "fade"); 20972 this.context.getConstant(1).connect(this._panner); 20973 this._panner.connect(this._split); 20974 this._panner.channelCount = 1; 20975 this._panner.channelCountMode = "explicit"; 20976 connect(this._split, this.a.gain, 0); 20977 connect(this._split, this.b.gain, 1); 20978 this.fade.chain(this._g2a, this._panner.pan); 20979 this.a.connect(this.output); 20980 this.b.connect(this.output); 20981 } 20982 static getDefaults() { 20983 return Object.assign(ToneAudioNode.getDefaults(), { 20984 fade: 0.5 20985 }); 20986 } 20987 dispose() { 20988 super.dispose(); 20989 this.a.dispose(); 20990 this.b.dispose(); 20991 this.output.dispose(); 20992 this.fade.dispose(); 20993 this._g2a.dispose(); 20994 this._panner.disconnect(); 20995 this._split.disconnect(); 20996 return this; 20997 } 20998}; 20999
vendor: 1,208 bytes, lines 21000-21039
21000// node_modules/tone/build/esm/effect/Effect.js 21001var Effect = class extends ToneAudioNode { 21002 constructor(options) { 21003 super(options); 21004 this.name = "Effect"; 21005 this._dryWet = new CrossFade({ context: this.context }); 21006 this.wet = this._dryWet.fade; 21007 this.effectSend = new Gain({ context: this.context }); 21008 this.effectReturn = new Gain({ context: this.context }); 21009 this.input = new Gain({ context: this.context }); 21010 this.output = this._dryWet; 21011 this.input.fan(this._dryWet.a, this.effectSend); 21012 this.effectReturn.connect(this._dryWet.b); 21013 this.wet.setValueAtTime(options.wet, 0); 21014 this._internalChannels = [this.effectReturn, this.effectSend]; 21015 readOnly(this, "wet"); 21016 } 21017 static getDefaults() { 21018 return Object.assign(ToneAudioNode.getDefaults(), { 21019 wet: 1 21020 }); 21021 } 21022 /** 21023 * chains the effect in between the effectSend and effectReturn 21024 */ 21025 connectEffect(effect) { 21026 this._internalChannels.push(effect); 21027 this.effectSend.chain(effect, this.effectReturn); 21028 return this; 21029 } 21030 dispose() { 21031 super.dispose(); 21032 this._dryWet.dispose(); 21033 this.effectSend.dispose(); 21034 this.effectReturn.dispose(); 21035 this.wet.dispose(); 21036 return this; 21037 } 21038}; 21039
vendor: 924 bytes, lines 21040-21075
21040// node_modules/tone/build/esm/component/channel/Panner.js 21041var Panner = class _Panner extends ToneAudioNode { 21042 constructor() { 21043 const options = optionsFromArguments(_Panner.getDefaults(), arguments, [ 21044 "pan" 21045 ]); 21046 super(options); 21047 this.name = "Panner"; 21048 this._panner = this.context.createStereoPanner(); 21049 this.input = this._panner; 21050 this.output = this._panner; 21051 this.pan = new Param({ 21052 context: this.context, 21053 param: this._panner.pan, 21054 value: options.pan, 21055 minValue: -1, 21056 maxValue: 1 21057 }); 21058 this._panner.channelCount = options.channelCount; 21059 this._panner.channelCountMode = "explicit"; 21060 readOnly(this, "pan"); 21061 } 21062 static getDefaults() { 21063 return Object.assign(ToneAudioNode.getDefaults(), { 21064 pan: 0, 21065 channelCount: 1 21066 }); 21067 } 21068 dispose() { 21069 super.dispose(); 21070 this._panner.disconnect(); 21071 this.pan.dispose(); 21072 return this; 21073 } 21074}; 21075
vendor: 592 bytes, lines 21076-21102
21076// node_modules/tone/build/esm/effect/BitCrusher.worklet.js 21077var workletName2 = "bit-crusher"; 21078var bitCrusherWorklet = ( 21079 /* javascript */ 21080 ` 21081 class BitCrusherWorklet extends SingleIOProcessor { 21082 21083 static get parameterDescriptors() { 21084 return [{ 21085 name: "bits", 21086 defaultValue: 12, 21087 minValue: 1, 21088 maxValue: 16, 21089 automationRate: 'k-rate' 21090 }]; 21091 } 21092 21093 generate(input, _channel, parameters) { 21094 const step = Math.pow(0.5, parameters.bits - 1); 21095 const val = step * Math.floor(input / step + 0.5); 21096 return val; 21097 } 21098 } 21099` 21100); 21101registerProcessor(workletName2, bitCrusherWorklet); 21102
vendor: 1,685 bytes, lines 21103-21165
21103// node_modules/tone/build/esm/effect/BitCrusher.js 21104var BitCrusher = class _BitCrusher extends Effect { 21105 constructor() { 21106 const options = optionsFromArguments(_BitCrusher.getDefaults(), arguments, ["bits"]); 21107 super(options); 21108 this.name = "BitCrusher"; 21109 this._bitCrusherWorklet = new BitCrusherWorklet({ 21110 context: this.context, 21111 bits: options.bits 21112 }); 21113 this.connectEffect(this._bitCrusherWorklet); 21114 this.bits = this._bitCrusherWorklet.bits; 21115 } 21116 static getDefaults() { 21117 return Object.assign(Effect.getDefaults(), { 21118 bits: 4 21119 }); 21120 } 21121 dispose() { 21122 super.dispose(); 21123 this._bitCrusherWorklet.dispose(); 21124 return this; 21125 } 21126}; 21127var BitCrusherWorklet = class _BitCrusherWorklet extends ToneAudioWorklet { 21128 constructor() { 21129 const options = optionsFromArguments(_BitCrusherWorklet.getDefaults(), arguments); 21130 super(options); 21131 this.name = "BitCrusherWorklet"; 21132 this.input = new Gain({ context: this.context }); 21133 this.output = new Gain({ context: this.context }); 21134 this.bits = new Param({ 21135 context: this.context, 21136 value: options.bits, 21137 units: "positive", 21138 minValue: 1, 21139 maxValue: 16, 21140 param: this._dummyParam, 21141 swappable: true 21142 }); 21143 } 21144 static getDefaults() { 21145 return Object.assign(ToneAudioWorklet.getDefaults(), { 21146 bits: 12 21147 }); 21148 } 21149 _audioWorkletName() { 21150 return workletName2; 21151 } 21152 onReady(node) { 21153 connectSeries(this.input, node, this.output); 21154 const bits = node.parameters.get("bits"); 21155 this.bits.setParam(bits); 21156 } 21157 dispose() { 21158 super.dispose(); 21159 this.input.dispose(); 21160 this.output.dispose(); 21161 this.bits.dispose(); 21162 return this; 21163 } 21164}; 21165
vendor: 628 bytes, lines 21166-21188
21166// node_modules/tone/build/esm/component/channel/Split.js 21167var Split = class _Split extends ToneAudioNode { 21168 constructor() { 21169 const options = optionsFromArguments(_Split.getDefaults(), arguments, [ 21170 "channels" 21171 ]); 21172 super(options); 21173 this.name = "Split"; 21174 this._splitter = this.input = this.output = this.context.createChannelSplitter(options.channels); 21175 this._internalChannels = [this._splitter]; 21176 } 21177 static getDefaults() { 21178 return Object.assign(ToneAudioNode.getDefaults(), { 21179 channels: 2 21180 }); 21181 } 21182 dispose() { 21183 super.dispose(); 21184 this._splitter.disconnect(); 21185 return this; 21186 } 21187}; 21188
vendor: 575 bytes, lines 21189-21210
21189// node_modules/tone/build/esm/component/channel/Merge.js 21190var Merge = class _Merge extends ToneAudioNode { 21191 constructor() { 21192 const options = optionsFromArguments(_Merge.getDefaults(), arguments, [ 21193 "channels" 21194 ]); 21195 super(options); 21196 this.name = "Merge"; 21197 this._merger = this.output = this.input = this.context.createChannelMerger(options.channels); 21198 } 21199 static getDefaults() { 21200 return Object.assign(ToneAudioNode.getDefaults(), { 21201 channels: 2 21202 }); 21203 } 21204 dispose() { 21205 super.dispose(); 21206 this._merger.disconnect(); 21207 return this; 21208 } 21209}; 21210
vendor: 1,428 bytes, lines 21211-21260
21211// node_modules/tone/build/esm/effect/StereoEffect.js 21212var StereoEffect = class extends ToneAudioNode { 21213 constructor(options) { 21214 super(options); 21215 this.name = "StereoEffect"; 21216 this.input = new Gain({ context: this.context }); 21217 this.input.channelCount = 2; 21218 this.input.channelCountMode = "explicit"; 21219 this._dryWet = this.output = new CrossFade({ 21220 context: this.context, 21221 fade: options.wet 21222 }); 21223 this.wet = this._dryWet.fade; 21224 this._split = new Split({ context: this.context, channels: 2 }); 21225 this._merge = new Merge({ context: this.context, channels: 2 }); 21226 this.input.connect(this._split); 21227 this.input.connect(this._dryWet.a); 21228 this._merge.connect(this._dryWet.b); 21229 readOnly(this, ["wet"]); 21230 } 21231 /** 21232 * Connect the left part of the effect 21233 */ 21234 connectEffectLeft(...nodes) { 21235 this._split.connect(nodes[0], 0, 0); 21236 connectSeries(...nodes); 21237 connect(nodes[nodes.length - 1], this._merge, 0, 0); 21238 } 21239 /** 21240 * Connect the right part of the effect 21241 */ 21242 connectEffectRight(...nodes) { 21243 this._split.connect(nodes[0], 1, 0); 21244 connectSeries(...nodes); 21245 connect(nodes[nodes.length - 1], this._merge, 0, 1); 21246 } 21247 static getDefaults() { 21248 return Object.assign(ToneAudioNode.getDefaults(), { 21249 wet: 1 21250 }); 21251 } 21252 dispose() { 21253 super.dispose(); 21254 this._dryWet.dispose(); 21255 this._split.dispose(); 21256 this._merge.dispose(); 21257 return this; 21258 } 21259}; 21260
vendor: 1,317 bytes, lines 21261-21298
21261// node_modules/tone/build/esm/effect/StereoFeedbackEffect.js 21262var StereoFeedbackEffect = class extends StereoEffect { 21263 constructor(options) { 21264 super(options); 21265 this.feedback = new Signal({ 21266 context: this.context, 21267 value: options.feedback, 21268 units: "normalRange" 21269 }); 21270 this._feedbackL = new Gain({ context: this.context }); 21271 this._feedbackR = new Gain({ context: this.context }); 21272 this._feedbackSplit = new Split({ context: this.context, channels: 2 }); 21273 this._feedbackMerge = new Merge({ context: this.context, channels: 2 }); 21274 this._merge.connect(this._feedbackSplit); 21275 this._feedbackMerge.connect(this._split); 21276 this._feedbackSplit.connect(this._feedbackL, 0, 0); 21277 this._feedbackL.connect(this._feedbackMerge, 0, 0); 21278 this._feedbackSplit.connect(this._feedbackR, 1, 0); 21279 this._feedbackR.connect(this._feedbackMerge, 0, 1); 21280 this.feedback.fan(this._feedbackL.gain, this._feedbackR.gain); 21281 readOnly(this, ["feedback"]); 21282 } 21283 static getDefaults() { 21284 return Object.assign(StereoEffect.getDefaults(), { 21285 feedback: 0.5 21286 }); 21287 } 21288 dispose() { 21289 super.dispose(); 21290 this.feedback.dispose(); 21291 this._feedbackL.dispose(); 21292 this._feedbackR.dispose(); 21293 this._feedbackSplit.dispose(); 21294 this._feedbackMerge.dispose(); 21295 return this; 21296 } 21297}; 21298
vendor: 3,567 bytes, lines 21299-21439
21299// node_modules/tone/build/esm/effect/Chorus.js 21300var Chorus = class _Chorus extends StereoFeedbackEffect { 21301 constructor() { 21302 const options = optionsFromArguments(_Chorus.getDefaults(), arguments, [ 21303 "frequency", 21304 "delayTime", 21305 "depth" 21306 ]); 21307 super(options); 21308 this.name = "Chorus"; 21309 this._depth = options.depth; 21310 this._delayTime = options.delayTime / 1e3; 21311 this._lfoL = new LFO({ 21312 context: this.context, 21313 frequency: options.frequency, 21314 min: 0, 21315 max: 1 21316 }); 21317 this._lfoR = new LFO({ 21318 context: this.context, 21319 frequency: options.frequency, 21320 min: 0, 21321 max: 1, 21322 phase: 180 21323 }); 21324 this._delayNodeL = new Delay({ context: this.context }); 21325 this._delayNodeR = new Delay({ context: this.context }); 21326 this.frequency = this._lfoL.frequency; 21327 readOnly(this, ["frequency"]); 21328 this._lfoL.frequency.connect(this._lfoR.frequency); 21329 this.connectEffectLeft(this._delayNodeL); 21330 this.connectEffectRight(this._delayNodeR); 21331 this._lfoL.connect(this._delayNodeL.delayTime); 21332 this._lfoR.connect(this._delayNodeR.delayTime); 21333 this.depth = this._depth; 21334 this.type = options.type; 21335 this.spread = options.spread; 21336 } 21337 static getDefaults() { 21338 return Object.assign(StereoFeedbackEffect.getDefaults(), { 21339 frequency: 1.5, 21340 delayTime: 3.5, 21341 depth: 0.7, 21342 type: "sine", 21343 spread: 180, 21344 feedback: 0, 21345 wet: 0.5 21346 }); 21347 } 21348 /** 21349 * The depth of the effect. A depth of 1 makes the delayTime 21350 * modulate between 0 and 2*delayTime (centered around the delayTime). 21351 */ 21352 get depth() { 21353 return this._depth; 21354 } 21355 set depth(depth) { 21356 this._depth = depth; 21357 const deviation = this._delayTime * depth; 21358 this._lfoL.min = Math.max(this._delayTime - deviation, 0); 21359 this._lfoL.max = this._delayTime + deviation; 21360 this._lfoR.min = Math.max(this._delayTime - deviation, 0); 21361 this._lfoR.max = this._delayTime + deviation; 21362 } 21363 /** 21364 * The delayTime in milliseconds of the chorus. A larger delayTime 21365 * will give a more pronounced effect. Nominal range a delayTime 21366 * is between 2 and 20ms. 21367 */ 21368 get delayTime() { 21369 return this._delayTime * 1e3; 21370 } 21371 set delayTime(delayTime) { 21372 this._delayTime = delayTime / 1e3; 21373 this.depth = this._depth; 21374 } 21375 /** 21376 * The oscillator type of the LFO. 21377 */ 21378 get type() { 21379 return this._lfoL.type; 21380 } 21381 set type(type) { 21382 this._lfoL.type = type; 21383 this._lfoR.type = type; 21384 } 21385 /** 21386 * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. 21387 * When set to 180, LFO's will be panned hard left and right respectively. 21388 */ 21389 get spread() { 21390 return this._lfoR.phase - this._lfoL.phase; 21391 } 21392 set spread(spread) { 21393 this._lfoL.phase = 90 - spread / 2; 21394 this._lfoR.phase = spread / 2 + 90; 21395 } 21396 /** 21397 * Start the effect. 21398 */ 21399 start(time) { 21400 this._lfoL.start(time); 21401 this._lfoR.start(time); 21402 return this; 21403 } 21404 /** 21405 * Stop the lfo 21406 */ 21407 stop(time) { 21408 this._lfoL.stop(time); 21409 this._lfoR.stop(time); 21410 return this; 21411 } 21412 /** 21413 * Sync the filter to the transport. 21414 * @see {@link LFO.sync} 21415 */ 21416 sync() { 21417 this._lfoL.sync(); 21418 this._lfoR.sync(); 21419 return this; 21420 } 21421 /** 21422 * Unsync the filter from the transport. 21423 */ 21424 unsync() { 21425 this._lfoL.unsync(); 21426 this._lfoR.unsync(); 21427 return this; 21428 } 21429 dispose() { 21430 super.dispose(); 21431 this._lfoL.dispose(); 21432 this._lfoR.dispose(); 21433 this._delayNodeL.dispose(); 21434 this._delayNodeR.dispose(); 21435 this.frequency.dispose(); 21436 return this; 21437 } 21438}; 21439
vendor: 1,413 bytes, lines 21440-21494
21440// node_modules/tone/build/esm/effect/Distortion.js 21441var Distortion = class _Distortion extends Effect { 21442 constructor() { 21443 const options = optionsFromArguments(_Distortion.getDefaults(), arguments, ["distortion"]); 21444 super(options); 21445 this.name = "Distortion"; 21446 this._shaper = new WaveShaper({ 21447 context: this.context, 21448 length: 4096 21449 }); 21450 this._distortion = options.distortion; 21451 this.connectEffect(this._shaper); 21452 this.distortion = options.distortion; 21453 this.oversample = options.oversample; 21454 } 21455 static getDefaults() { 21456 return Object.assign(Effect.getDefaults(), { 21457 distortion: 0.4, 21458 oversample: "none" 21459 }); 21460 } 21461 /** 21462 * The amount of distortion. Nominal range is between 0 and 1. 21463 */ 21464 get distortion() { 21465 return this._distortion; 21466 } 21467 set distortion(amount) { 21468 this._distortion = amount; 21469 const k = amount * 100; 21470 const deg = Math.PI / 180; 21471 this._shaper.setMap((x) => { 21472 if (Math.abs(x) < 1e-3) { 21473 return 0; 21474 } else { 21475 return (3 + k) * x * 20 * deg / (Math.PI + k * Math.abs(x)); 21476 } 21477 }); 21478 } 21479 /** 21480 * The oversampling of the effect. Can either be "none", "2x" or "4x". 21481 */ 21482 get oversample() { 21483 return this._shaper.oversample; 21484 } 21485 set oversample(oversampling) { 21486 this._shaper.oversample = oversampling; 21487 } 21488 dispose() { 21489 super.dispose(); 21490 this._shaper.dispose(); 21491 return this; 21492 } 21493}; 21494
vendor: 687 bytes, lines 21495-21521
21495// node_modules/tone/build/esm/effect/FeedbackEffect.js 21496var FeedbackEffect = class extends Effect { 21497 constructor(options) { 21498 super(options); 21499 this.name = "FeedbackEffect"; 21500 this._feedbackGain = new Gain({ 21501 context: this.context, 21502 gain: options.feedback, 21503 units: "normalRange" 21504 }); 21505 this.feedback = this._feedbackGain.gain; 21506 readOnly(this, "feedback"); 21507 this.effectReturn.chain(this._feedbackGain, this.effectSend); 21508 } 21509 static getDefaults() { 21510 return Object.assign(Effect.getDefaults(), { 21511 feedback: 0.125 21512 }); 21513 } 21514 dispose() { 21515 super.dispose(); 21516 this._feedbackGain.dispose(); 21517 this.feedback.dispose(); 21518 return this; 21519 } 21520}; 21521
vendor: 824 bytes, lines 21522-21550
21522// node_modules/tone/build/esm/effect/FeedbackDelay.js 21523var FeedbackDelay = class _FeedbackDelay extends FeedbackEffect { 21524 constructor() { 21525 const options = optionsFromArguments(_FeedbackDelay.getDefaults(), arguments, ["delayTime", "feedback"]); 21526 super(options); 21527 this.name = "FeedbackDelay"; 21528 this._delayNode = new Delay({ 21529 context: this.context, 21530 delayTime: options.delayTime, 21531 maxDelay: options.maxDelay 21532 }); 21533 this.delayTime = this._delayNode.delayTime; 21534 this.connectEffect(this._delayNode); 21535 readOnly(this, "delayTime"); 21536 } 21537 static getDefaults() { 21538 return Object.assign(FeedbackEffect.getDefaults(), { 21539 delayTime: 0.25, 21540 maxDelay: 1 21541 }); 21542 } 21543 dispose() { 21544 super.dispose(); 21545 this._delayNode.dispose(); 21546 this.delayTime.dispose(); 21547 return this; 21548 } 21549}; 21550
vendor: 207 bytes, lines 21551-21562
21551// node_modules/tone/build/esm/effect/Freeverb.js 21552var combFilterTunings = [ 21553 1557 / 44100, 21554 1617 / 44100, 21555 1491 / 44100, 21556 1422 / 44100, 21557 1277 / 44100, 21558 1356 / 44100, 21559 1188 / 44100, 21560 1116 / 44100 21561]; 21562
vendor: 142 bytes, lines 21563-21570
21563// node_modules/tone/build/esm/effect/JCReverb.js 21564var combFilterDelayTimes = [ 21565 1687 / 25e3, 21566 1601 / 25e3, 21567 2053 / 25e3, 21568 2251 / 25e3 21569]; 21570
vendor: 2,737 bytes, lines 21571-21669
21571// node_modules/tone/build/esm/effect/Phaser.js 21572var Phaser = class _Phaser extends StereoEffect { 21573 constructor() { 21574 const options = optionsFromArguments(_Phaser.getDefaults(), arguments, [ 21575 "frequency", 21576 "octaves", 21577 "baseFrequency" 21578 ]); 21579 super(options); 21580 this.name = "Phaser"; 21581 this._lfoL = new LFO({ 21582 context: this.context, 21583 frequency: options.frequency, 21584 min: 0, 21585 max: 1 21586 }); 21587 this._lfoR = new LFO({ 21588 context: this.context, 21589 frequency: options.frequency, 21590 min: 0, 21591 max: 1, 21592 phase: 180 21593 }); 21594 this._baseFrequency = this.toFrequency(options.baseFrequency); 21595 this._octaves = options.octaves; 21596 this.Q = new Signal({ 21597 context: this.context, 21598 value: options.Q, 21599 units: "positive" 21600 }); 21601 this._filtersL = this._makeFilters(options.stages, this._lfoL); 21602 this._filtersR = this._makeFilters(options.stages, this._lfoR); 21603 this.frequency = this._lfoL.frequency; 21604 this.frequency.value = options.frequency; 21605 this.connectEffectLeft(...this._filtersL); 21606 this.connectEffectRight(...this._filtersR); 21607 this._lfoL.frequency.connect(this._lfoR.frequency); 21608 this.baseFrequency = options.baseFrequency; 21609 this.octaves = options.octaves; 21610 this._lfoL.start(); 21611 this._lfoR.start(); 21612 readOnly(this, ["frequency", "Q"]); 21613 } 21614 static getDefaults() { 21615 return Object.assign(StereoEffect.getDefaults(), { 21616 frequency: 0.5, 21617 octaves: 3, 21618 stages: 10, 21619 Q: 10, 21620 baseFrequency: 350 21621 }); 21622 } 21623 _makeFilters(stages, connectToFreq) { 21624 const filters = []; 21625 for (let i = 0; i < stages; i++) { 21626 const filter = this.context.createBiquadFilter(); 21627 filter.type = "allpass"; 21628 this.Q.connect(filter.Q); 21629 connectToFreq.connect(filter.frequency); 21630 filters.push(filter); 21631 } 21632 return filters; 21633 } 21634 /** 21635 * The number of octaves the phase goes above the baseFrequency 21636 */ 21637 get octaves() { 21638 return this._octaves; 21639 } 21640 set octaves(octaves) { 21641 this._octaves = octaves; 21642 const max = this._baseFrequency * Math.pow(2, octaves); 21643 this._lfoL.max = max; 21644 this._lfoR.max = max; 21645 } 21646 /** 21647 * The the base frequency of the filters. 21648 */ 21649 get baseFrequency() { 21650 return this._baseFrequency; 21651 } 21652 set baseFrequency(freq) { 21653 this._baseFrequency = this.toFrequency(freq); 21654 this._lfoL.min = this._baseFrequency; 21655 this._lfoR.min = this._baseFrequency; 21656 this.octaves = this._octaves; 21657 } 21658 dispose() { 21659 super.dispose(); 21660 this.Q.dispose(); 21661 this._lfoL.dispose(); 21662 this._lfoR.dispose(); 21663 this._filtersL.forEach((f) => f.disconnect()); 21664 this._filtersR.forEach((f) => f.disconnect()); 21665 this.frequency.dispose(); 21666 return this; 21667 } 21668}; 21669
vendor: 2,835 bytes, lines 21670-21786
21670// node_modules/tone/build/esm/effect/Tremolo.js 21671var Tremolo = class _Tremolo extends StereoEffect { 21672 constructor() { 21673 const options = optionsFromArguments(_Tremolo.getDefaults(), arguments, [ 21674 "frequency", 21675 "depth" 21676 ]); 21677 super(options); 21678 this.name = "Tremolo"; 21679 this._lfoL = new LFO({ 21680 context: this.context, 21681 type: options.type, 21682 min: 1, 21683 max: 0 21684 }); 21685 this._lfoR = new LFO({ 21686 context: this.context, 21687 type: options.type, 21688 min: 1, 21689 max: 0 21690 }); 21691 this._amplitudeL = new Gain({ context: this.context }); 21692 this._amplitudeR = new Gain({ context: this.context }); 21693 this.frequency = new Signal({ 21694 context: this.context, 21695 value: options.frequency, 21696 units: "frequency" 21697 }); 21698 this.depth = new Signal({ 21699 context: this.context, 21700 value: options.depth, 21701 units: "normalRange" 21702 }); 21703 readOnly(this, ["frequency", "depth"]); 21704 this.connectEffectLeft(this._amplitudeL); 21705 this.connectEffectRight(this._amplitudeR); 21706 this._lfoL.connect(this._amplitudeL.gain); 21707 this._lfoR.connect(this._amplitudeR.gain); 21708 this.frequency.fan(this._lfoL.frequency, this._lfoR.frequency); 21709 this.depth.fan(this._lfoR.amplitude, this._lfoL.amplitude); 21710 this.spread = options.spread; 21711 } 21712 static getDefaults() { 21713 return Object.assign(StereoEffect.getDefaults(), { 21714 frequency: 10, 21715 type: "sine", 21716 depth: 0.5, 21717 spread: 180 21718 }); 21719 } 21720 /** 21721 * Start the tremolo. 21722 */ 21723 start(time) { 21724 this._lfoL.start(time); 21725 this._lfoR.start(time); 21726 return this; 21727 } 21728 /** 21729 * Stop the tremolo. 21730 */ 21731 stop(time) { 21732 this._lfoL.stop(time); 21733 this._lfoR.stop(time); 21734 return this; 21735 } 21736 /** 21737 * Sync the effect to the transport. 21738 */ 21739 sync() { 21740 this._lfoL.sync(); 21741 this._lfoR.sync(); 21742 this.context.transport.syncSignal(this.frequency); 21743 return this; 21744 } 21745 /** 21746 * Unsync the filter from the transport 21747 */ 21748 unsync() { 21749 this._lfoL.unsync(); 21750 this._lfoR.unsync(); 21751 this.context.transport.unsyncSignal(this.frequency); 21752 return this; 21753 } 21754 /** 21755 * The oscillator type. 21756 */ 21757 get type() { 21758 return this._lfoL.type; 21759 } 21760 set type(type) { 21761 this._lfoL.type = type; 21762 this._lfoR.type = type; 21763 } 21764 /** 21765 * Amount of stereo spread. When set to 0, both LFO's will be panned centrally. 21766 * When set to 180, LFO's will be panned hard left and right respectively. 21767 */ 21768 get spread() { 21769 return this._lfoR.phase - this._lfoL.phase; 21770 } 21771 set spread(spread) { 21772 this._lfoL.phase = 90 - spread / 2; 21773 this._lfoR.phase = spread / 2 + 90; 21774 } 21775 dispose() { 21776 super.dispose(); 21777 this._lfoL.dispose(); 21778 this._lfoR.dispose(); 21779 this._amplitudeL.dispose(); 21780 this._amplitudeR.dispose(); 21781 this.frequency.dispose(); 21782 this.depth.dispose(); 21783 return this; 21784 } 21785}; 21786
vendor: 2,979 bytes, lines 21787-21888
21787// node_modules/tone/build/esm/component/analysis/Analyser.js 21788var Analyser = class _Analyser extends ToneAudioNode { 21789 constructor() { 21790 const options = optionsFromArguments(_Analyser.getDefaults(), arguments, ["type", "size"]); 21791 super(options); 21792 this.name = "Analyser"; 21793 this._analysers = []; 21794 this._buffers = []; 21795 this.input = this.output = this._gain = new Gain({ context: this.context }); 21796 this._split = new Split({ 21797 context: this.context, 21798 channels: options.channels 21799 }); 21800 this.input.connect(this._split); 21801 assertRange(options.channels, 1); 21802 for (let channel = 0; channel < options.channels; channel++) { 21803 this._analysers[channel] = this.context.createAnalyser(); 21804 this._split.connect(this._analysers[channel], channel, 0); 21805 } 21806 this.size = options.size; 21807 this.type = options.type; 21808 this.smoothing = options.smoothing; 21809 } 21810 static getDefaults() { 21811 return Object.assign(ToneAudioNode.getDefaults(), { 21812 size: 1024, 21813 smoothing: 0.8, 21814 type: "fft", 21815 channels: 1 21816 }); 21817 } 21818 /** 21819 * Run the analysis given the current settings. If {@link channels} = 1, 21820 * it will return a Float32Array. If {@link channels} > 1, it will 21821 * return an array of Float32Arrays where each index in the array 21822 * represents the analysis done on a channel. 21823 */ 21824 getValue() { 21825 this._analysers.forEach((analyser, index) => { 21826 const buffer = this._buffers[index]; 21827 if (this._type === "fft") { 21828 analyser.getFloatFrequencyData(buffer); 21829 } else if (this._type === "waveform") { 21830 analyser.getFloatTimeDomainData(buffer); 21831 } 21832 }); 21833 if (this.channels === 1) { 21834 return this._buffers[0]; 21835 } else { 21836 return this._buffers; 21837 } 21838 } 21839 /** 21840 * The size of analysis. This must be a power of two in the range 16 to 16384. 21841 */ 21842 get size() { 21843 return this._analysers[0].frequencyBinCount; 21844 } 21845 set size(size) { 21846 this._analysers.forEach((analyser, index) => { 21847 analyser.fftSize = size * 2; 21848 this._buffers[index] = new Float32Array(size); 21849 }); 21850 } 21851 /** 21852 * The number of channels the analyser does the analysis on. Channel 21853 * separation is done using {@link Split} 21854 */ 21855 get channels() { 21856 return this._analysers.length; 21857 } 21858 /** 21859 * The analysis function returned by analyser.getValue(), either "fft" or "waveform". 21860 */ 21861 get type() { 21862 return this._type; 21863 } 21864 set type(type) { 21865 assert(type === "waveform" || type === "fft", `Analyser: invalid type: ${type}`); 21866 this._type = type; 21867 } 21868 /** 21869 * 0 represents no time averaging with the last analysis frame. 21870 */ 21871 get smoothing() { 21872 return this._analysers[0].smoothingTimeConstant; 21873 } 21874 set smoothing(val) { 21875 this._analysers.forEach((a) => a.smoothingTimeConstant = val); 21876 } 21877 /** 21878 * Clean up. 21879 */ 21880 dispose() { 21881 super.dispose(); 21882 this._analysers.forEach((a) => a.disconnect()); 21883 this._split.dispose(); 21884 this._gain.dispose(); 21885 return this; 21886 } 21887}; 21888
vendor: 471 bytes, lines 21889-21906
21889// node_modules/tone/build/esm/component/analysis/MeterBase.js 21890var MeterBase = class _MeterBase extends ToneAudioNode { 21891 constructor() { 21892 super(optionsFromArguments(_MeterBase.getDefaults(), arguments)); 21893 this.name = "MeterBase"; 21894 this.input = this.output = this._analyser = new Analyser({ 21895 context: this.context, 21896 size: 256, 21897 type: "waveform" 21898 }); 21899 } 21900 dispose() { 21901 super.dispose(); 21902 this._analyser.dispose(); 21903 return this; 21904 } 21905}; 21906
vendor: 2,107 bytes, lines 21907-21974
21907// node_modules/tone/build/esm/component/analysis/Meter.js 21908var Meter = class _Meter extends MeterBase { 21909 constructor() { 21910 const options = optionsFromArguments(_Meter.getDefaults(), arguments, [ 21911 "smoothing" 21912 ]); 21913 super(options); 21914 this.name = "Meter"; 21915 this.input = this.output = this._analyser = new Analyser({ 21916 context: this.context, 21917 size: 256, 21918 type: "waveform", 21919 channels: options.channelCount 21920 }); 21921 this.smoothing = options.smoothing, this.normalRange = options.normalRange; 21922 this._rms = new Array(options.channelCount); 21923 this._rms.fill(0); 21924 } 21925 static getDefaults() { 21926 return Object.assign(MeterBase.getDefaults(), { 21927 smoothing: 0.8, 21928 normalRange: false, 21929 channelCount: 1 21930 }); 21931 } 21932 /** 21933 * Use {@link getValue} instead. For the previous getValue behavior, use DCMeter. 21934 * @deprecated 21935 */ 21936 getLevel() { 21937 warn("'getLevel' has been changed to 'getValue'"); 21938 return this.getValue(); 21939 } 21940 /** 21941 * Get the current value of the incoming signal. 21942 * Output is in decibels when {@link normalRange} is `false`. 21943 * If {@link channels} = 1, then the output is a single number 21944 * representing the value of the input signal. When {@link channels} > 1, 21945 * then each channel is returned as a value in a number array. 21946 */ 21947 getValue() { 21948 const aValues = this._analyser.getValue(); 21949 const channelValues = this.channels === 1 ? [aValues] : aValues; 21950 const vals = channelValues.map((values, index) => { 21951 const totalSquared = values.reduce((total, current) => total + current * current, 0); 21952 const rms = Math.sqrt(totalSquared / values.length); 21953 this._rms[index] = Math.max(rms, this._rms[index] * this.smoothing); 21954 return this.normalRange ? this._rms[index] : gainToDb(this._rms[index]); 21955 }); 21956 if (this.channels === 1) { 21957 return vals[0]; 21958 } else { 21959 return vals; 21960 } 21961 } 21962 /** 21963 * The number of channels of analysis. 21964 */ 21965 get channels() { 21966 return this._analyser.channels; 21967 } 21968 dispose() { 21969 super.dispose(); 21970 this._analyser.dispose(); 21971 return this; 21972 } 21973}; 21974
vendor: 1,843 bytes, lines 21975-22033
21975// node_modules/tone/build/esm/component/analysis/FFT.js 21976var FFT = class _FFT extends MeterBase { 21977 constructor() { 21978 const options = optionsFromArguments(_FFT.getDefaults(), arguments, [ 21979 "size" 21980 ]); 21981 super(options); 21982 this.name = "FFT"; 21983 this.normalRange = options.normalRange; 21984 this._analyser.type = "fft"; 21985 this.size = options.size; 21986 } 21987 static getDefaults() { 21988 return Object.assign(ToneAudioNode.getDefaults(), { 21989 normalRange: false, 21990 size: 1024, 21991 smoothing: 0.8 21992 }); 21993 } 21994 /** 21995 * Gets the current frequency data from the connected audio source. 21996 * Returns the frequency data of length {@link size} as a Float32Array of decibel values. 21997 */ 21998 getValue() { 21999 const values = this._analyser.getValue(); 22000 return values.map((v) => this.normalRange ? dbToGain(v) : v); 22001 } 22002 /** 22003 * The size of analysis. This must be a power of two in the range 16 to 16384. 22004 * Determines the size of the array returned by {@link getValue} (i.e. the number of 22005 * frequency bins). Large FFT sizes may be costly to compute. 22006 */ 22007 get size() { 22008 return this._analyser.size; 22009 } 22010 set size(size) { 22011 this._analyser.size = size; 22012 } 22013 /** 22014 * 0 represents no time averaging with the last analysis frame. 22015 */ 22016 get smoothing() { 22017 return this._analyser.smoothing; 22018 } 22019 set smoothing(val) { 22020 this._analyser.smoothing = val; 22021 } 22022 /** 22023 * Returns the frequency value in hertz of each of the indices of the FFT's {@link getValue} response. 22024 * @example 22025 * const fft = new Tone.FFT(32); 22026 * console.log([0, 1, 2, 3, 4].map(index => fft.getFrequencyOfIndex(index))); 22027 */ 22028 getFrequencyOfIndex(index) { 22029 assert(0 <= index && index < this.size, `index must be greater than or equal to 0 and less than ${this.size}`); 22030 return index * this.context.sampleRate / (this.size * 2); 22031 } 22032}; 22033
vendor: 921 bytes, lines 22034-22066
22034// node_modules/tone/build/esm/component/analysis/Waveform.js 22035var Waveform = class _Waveform extends MeterBase { 22036 constructor() { 22037 const options = optionsFromArguments(_Waveform.getDefaults(), arguments, ["size"]); 22038 super(options); 22039 this.name = "Waveform"; 22040 this._analyser.type = "waveform"; 22041 this.size = options.size; 22042 } 22043 static getDefaults() { 22044 return Object.assign(MeterBase.getDefaults(), { 22045 size: 1024 22046 }); 22047 } 22048 /** 22049 * Return the waveform for the current time as a Float32Array where each value in the array 22050 * represents a sample in the waveform. 22051 */ 22052 getValue() { 22053 return this._analyser.getValue(); 22054 } 22055 /** 22056 * The size of analysis. This must be a power of two in the range 16 to 16384. 22057 * Determines the size of the array returned by {@link getValue}. 22058 */ 22059 get size() { 22060 return this._analyser.size; 22061 } 22062 set size(size) { 22063 this._analyser.size = size; 22064 } 22065}; 22066
vendor: 2,550 bytes, lines 22067-22162
22067// node_modules/tone/build/esm/component/channel/Solo.js 22068var Solo = class _Solo extends ToneAudioNode { 22069 constructor() { 22070 const options = optionsFromArguments(_Solo.getDefaults(), arguments, [ 22071 "solo" 22072 ]); 22073 super(options); 22074 this.name = "Solo"; 22075 this.input = this.output = new Gain({ 22076 context: this.context 22077 }); 22078 if (!_Solo._allSolos.has(this.context)) { 22079 _Solo._allSolos.set(this.context, /* @__PURE__ */ new Set()); 22080 } 22081 _Solo._allSolos.get(this.context).add(this); 22082 this.solo = options.solo; 22083 } 22084 static getDefaults() { 22085 return Object.assign(ToneAudioNode.getDefaults(), { 22086 solo: false 22087 }); 22088 } 22089 /** 22090 * Isolates this instance and mutes all other instances of Solo. 22091 * Only one instance can be soloed at a time. A soloed 22092 * instance will report `solo=false` when another instance is soloed. 22093 */ 22094 get solo() { 22095 return this._isSoloed(); 22096 } 22097 set solo(solo) { 22098 if (solo) { 22099 this._addSolo(); 22100 } else { 22101 this._removeSolo(); 22102 } 22103 _Solo._allSolos.get(this.context).forEach((instance) => instance._updateSolo()); 22104 } 22105 /** 22106 * If the current instance is muted, i.e. another instance is soloed 22107 */ 22108 get muted() { 22109 return this.input.gain.value === 0; 22110 } 22111 /** 22112 * Add this to the soloed array 22113 */ 22114 _addSolo() { 22115 if (!_Solo._soloed.has(this.context)) { 22116 _Solo._soloed.set(this.context, /* @__PURE__ */ new Set()); 22117 } 22118 _Solo._soloed.get(this.context).add(this); 22119 } 22120 /** 22121 * Remove this from the soloed array 22122 */ 22123 _removeSolo() { 22124 if (_Solo._soloed.has(this.context)) { 22125 _Solo._soloed.get(this.context).delete(this); 22126 } 22127 } 22128 /** 22129 * Is this on the soloed array 22130 */ 22131 _isSoloed() { 22132 return _Solo._soloed.has(this.context) && _Solo._soloed.get(this.context).has(this); 22133 } 22134 /** 22135 * Returns true if no one is soloed 22136 */ 22137 _noSolos() { 22138 return !_Solo._soloed.has(this.context) || // or has a solo set but doesn't include any items 22139 _Solo._soloed.has(this.context) && _Solo._soloed.get(this.context).size === 0; 22140 } 22141 /** 22142 * Solo the current instance and unsolo all other instances. 22143 */ 22144 _updateSolo() { 22145 if (this._isSoloed()) { 22146 this.input.gain.value = 1; 22147 } else if (this._noSolos()) { 22148 this.input.gain.value = 1; 22149 } else { 22150 this.input.gain.value = 0; 22151 } 22152 } 22153 dispose() { 22154 super.dispose(); 22155 _Solo._allSolos.get(this.context).delete(this); 22156 this._removeSolo(); 22157 return this; 22158 } 22159}; 22160Solo._allSolos = /* @__PURE__ */ new Map(); 22161Solo._soloed = /* @__PURE__ */ new Map(); 22162
vendor: 1,205 bytes, lines 22163-22213
22163// node_modules/tone/build/esm/component/channel/PanVol.js 22164var PanVol = class _PanVol extends ToneAudioNode { 22165 constructor() { 22166 const options = optionsFromArguments(_PanVol.getDefaults(), arguments, [ 22167 "pan", 22168 "volume" 22169 ]); 22170 super(options); 22171 this.name = "PanVol"; 22172 this._panner = this.input = new Panner({ 22173 context: this.context, 22174 pan: options.pan, 22175 channelCount: options.channelCount 22176 }); 22177 this.pan = this._panner.pan; 22178 this._volume = this.output = new Volume({ 22179 context: this.context, 22180 volume: options.volume 22181 }); 22182 this.volume = this._volume.volume; 22183 this._panner.connect(this._volume); 22184 this.mute = options.mute; 22185 readOnly(this, ["pan", "volume"]); 22186 } 22187 static getDefaults() { 22188 return Object.assign(ToneAudioNode.getDefaults(), { 22189 mute: false, 22190 pan: 0, 22191 volume: 0, 22192 channelCount: 1 22193 }); 22194 } 22195 /** 22196 * Mute/unmute the volume 22197 */ 22198 get mute() { 22199 return this._volume.mute; 22200 } 22201 set mute(mute) { 22202 this._volume.mute = mute; 22203 } 22204 dispose() { 22205 super.dispose(); 22206 this._panner.dispose(); 22207 this.pan.dispose(); 22208 this._volume.dispose(); 22209 this.volume.dispose(); 22210 return this; 22211 } 22212}; 22213
vendor: 3,004 bytes, lines 22214-22324
22214// node_modules/tone/build/esm/component/channel/Channel.js 22215var Channel = class _Channel extends ToneAudioNode { 22216 constructor() { 22217 const options = optionsFromArguments(_Channel.getDefaults(), arguments, [ 22218 "volume", 22219 "pan" 22220 ]); 22221 super(options); 22222 this.name = "Channel"; 22223 this._solo = this.input = new Solo({ 22224 solo: options.solo, 22225 context: this.context 22226 }); 22227 this._panVol = this.output = new PanVol({ 22228 context: this.context, 22229 pan: options.pan, 22230 volume: options.volume, 22231 mute: options.mute, 22232 channelCount: options.channelCount 22233 }); 22234 this.pan = this._panVol.pan; 22235 this.volume = this._panVol.volume; 22236 this._solo.connect(this._panVol); 22237 readOnly(this, ["pan", "volume"]); 22238 } 22239 static getDefaults() { 22240 return Object.assign(ToneAudioNode.getDefaults(), { 22241 pan: 0, 22242 volume: 0, 22243 mute: false, 22244 solo: false, 22245 channelCount: 1 22246 }); 22247 } 22248 /** 22249 * Solo/unsolo the channel. Soloing is only relative to other {@link Channel}s and {@link Solo} instances 22250 */ 22251 get solo() { 22252 return this._solo.solo; 22253 } 22254 set solo(solo) { 22255 this._solo.solo = solo; 22256 } 22257 /** 22258 * If the current instance is muted, i.e. another instance is soloed, 22259 * or the channel is muted 22260 */ 22261 get muted() { 22262 return this._solo.muted || this.mute; 22263 } 22264 /** 22265 * Mute/unmute the volume 22266 */ 22267 get mute() { 22268 return this._panVol.mute; 22269 } 22270 set mute(mute) { 22271 this._panVol.mute = mute; 22272 } 22273 /** 22274 * Get the gain node belonging to the bus name. Create it if 22275 * it doesn't exist 22276 * @param name The bus name 22277 */ 22278 _getBus(name) { 22279 if (!_Channel.buses.has(name)) { 22280 _Channel.buses.set(name, new Gain({ context: this.context })); 22281 } 22282 return _Channel.buses.get(name); 22283 } 22284 /** 22285 * Send audio to another channel using a string. `send` is a lot like 22286 * {@link connect}, except it uses a string instead of an object. This can 22287 * be useful in large applications to decouple sections since {@link send} 22288 * and {@link receive} can be invoked separately in order to connect an object 22289 * @param name The channel name to send the audio 22290 * @param volume The amount of the signal to send. 22291 * Defaults to 0db, i.e. send the entire signal 22292 * @returns Returns the gain node of this connection. 22293 */ 22294 send(name, volume = 0) { 22295 const bus = this._getBus(name); 22296 const sendKnob = new Gain({ 22297 context: this.context, 22298 units: "decibels", 22299 gain: volume 22300 }); 22301 this.connect(sendKnob); 22302 sendKnob.connect(bus); 22303 return sendKnob; 22304 } 22305 /** 22306 * Receive audio from a channel which was connected with {@link send}. 22307 * @param name The channel name to receive audio from. 22308 */ 22309 receive(name) { 22310 const bus = this._getBus(name); 22311 bus.connect(this); 22312 return this; 22313 } 22314 dispose() { 22315 super.dispose(); 22316 this._panVol.dispose(); 22317 this.pan.dispose(); 22318 this.volume.dispose(); 22319 this._solo.dispose(); 22320 return this; 22321 } 22322}; 22323Channel.buses = /* @__PURE__ */ new Map(); 22324
vendor: 2,264 bytes, lines 22325-22402
22325// node_modules/tone/build/esm/component/channel/MultibandSplit.js 22326var MultibandSplit = class _MultibandSplit extends ToneAudioNode { 22327 constructor() { 22328 const options = optionsFromArguments(_MultibandSplit.getDefaults(), arguments, ["lowFrequency", "highFrequency"]); 22329 super(options); 22330 this.name = "MultibandSplit"; 22331 this.input = new Gain({ context: this.context }); 22332 this.output = void 0; 22333 this.low = new Filter({ 22334 context: this.context, 22335 frequency: 0, 22336 type: "lowpass" 22337 }); 22338 this._lowMidFilter = new Filter({ 22339 context: this.context, 22340 frequency: 0, 22341 type: "highpass" 22342 }); 22343 this.mid = new Filter({ 22344 context: this.context, 22345 frequency: 0, 22346 type: "lowpass" 22347 }); 22348 this.high = new Filter({ 22349 context: this.context, 22350 frequency: 0, 22351 type: "highpass" 22352 }); 22353 this._internalChannels = [this.low, this.mid, this.high]; 22354 this.lowFrequency = new Signal({ 22355 context: this.context, 22356 units: "frequency", 22357 value: options.lowFrequency 22358 }); 22359 this.highFrequency = new Signal({ 22360 context: this.context, 22361 units: "frequency", 22362 value: options.highFrequency 22363 }); 22364 this.Q = new Signal({ 22365 context: this.context, 22366 units: "positive", 22367 value: options.Q 22368 }); 22369 this.input.fan(this.low, this.high); 22370 this.input.chain(this._lowMidFilter, this.mid); 22371 this.lowFrequency.fan(this.low.frequency, this._lowMidFilter.frequency); 22372 this.highFrequency.fan(this.mid.frequency, this.high.frequency); 22373 this.Q.connect(this.low.Q); 22374 this.Q.connect(this._lowMidFilter.Q); 22375 this.Q.connect(this.mid.Q); 22376 this.Q.connect(this.high.Q); 22377 readOnly(this, ["high", "mid", "low", "highFrequency", "lowFrequency"]); 22378 } 22379 static getDefaults() { 22380 return Object.assign(ToneAudioNode.getDefaults(), { 22381 Q: 1, 22382 highFrequency: 2500, 22383 lowFrequency: 400 22384 }); 22385 } 22386 /** 22387 * Clean up. 22388 */ 22389 dispose() { 22390 super.dispose(); 22391 writable(this, ["high", "mid", "low", "highFrequency", "lowFrequency"]); 22392 this.low.dispose(); 22393 this._lowMidFilter.dispose(); 22394 this.mid.dispose(); 22395 this.high.dispose(); 22396 this.lowFrequency.dispose(); 22397 this.highFrequency.dispose(); 22398 this.Q.dispose(); 22399 return this; 22400 } 22401}; 22402
vendor: 2,568 bytes, lines 22403-22484
22403// node_modules/tone/build/esm/component/dynamics/Compressor.js 22404var Compressor = class _Compressor extends ToneAudioNode { 22405 constructor() { 22406 const options = optionsFromArguments(_Compressor.getDefaults(), arguments, ["threshold", "ratio"]); 22407 super(options); 22408 this.name = "Compressor"; 22409 this._compressor = this.context.createDynamicsCompressor(); 22410 this.input = this._compressor; 22411 this.output = this._compressor; 22412 this.threshold = new Param({ 22413 minValue: this._compressor.threshold.minValue, 22414 maxValue: this._compressor.threshold.maxValue, 22415 context: this.context, 22416 convert: false, 22417 param: this._compressor.threshold, 22418 units: "decibels", 22419 value: options.threshold 22420 }); 22421 this.attack = new Param({ 22422 minValue: this._compressor.attack.minValue, 22423 maxValue: this._compressor.attack.maxValue, 22424 context: this.context, 22425 param: this._compressor.attack, 22426 units: "time", 22427 value: options.attack 22428 }); 22429 this.release = new Param({ 22430 minValue: this._compressor.release.minValue, 22431 maxValue: this._compressor.release.maxValue, 22432 context: this.context, 22433 param: this._compressor.release, 22434 units: "time", 22435 value: options.release 22436 }); 22437 this.knee = new Param({ 22438 minValue: this._compressor.knee.minValue, 22439 maxValue: this._compressor.knee.maxValue, 22440 context: this.context, 22441 convert: false, 22442 param: this._compressor.knee, 22443 units: "decibels", 22444 value: options.knee 22445 }); 22446 this.ratio = new Param({ 22447 minValue: this._compressor.ratio.minValue, 22448 maxValue: this._compressor.ratio.maxValue, 22449 context: this.context, 22450 convert: false, 22451 param: this._compressor.ratio, 22452 units: "positive", 22453 value: options.ratio 22454 }); 22455 readOnly(this, ["knee", "release", "attack", "ratio", "threshold"]); 22456 } 22457 static getDefaults() { 22458 return Object.assign(ToneAudioNode.getDefaults(), { 22459 attack: 3e-3, 22460 knee: 30, 22461 ratio: 12, 22462 release: 0.25, 22463 threshold: -24 22464 }); 22465 } 22466 /** 22467 * A read-only decibel value for metering purposes, representing the current amount of gain 22468 * reduction that the compressor is applying to the signal. If fed no signal the value will be 0 (no gain reduction). 22469 */ 22470 get reduction() { 22471 return this._compressor.reduction; 22472 } 22473 dispose() { 22474 super.dispose(); 22475 this._compressor.disconnect(); 22476 this.attack.dispose(); 22477 this.release.dispose(); 22478 this.threshold.dispose(); 22479 this.ratio.dispose(); 22480 this.knee.dispose(); 22481 return this; 22482 } 22483}; 22484
vendor: 2,135 bytes, lines 22485-22557
22485// node_modules/tone/build/esm/component/filter/EQ3.js 22486var EQ3 = class _EQ3 extends ToneAudioNode { 22487 constructor() { 22488 const options = optionsFromArguments(_EQ3.getDefaults(), arguments, [ 22489 "low", 22490 "mid", 22491 "high" 22492 ]); 22493 super(options); 22494 this.name = "EQ3"; 22495 this.output = new Gain({ context: this.context }); 22496 this._internalChannels = []; 22497 this.input = this._multibandSplit = new MultibandSplit({ 22498 context: this.context, 22499 highFrequency: options.highFrequency, 22500 lowFrequency: options.lowFrequency 22501 }); 22502 this._lowGain = new Gain({ 22503 context: this.context, 22504 gain: options.low, 22505 units: "decibels" 22506 }); 22507 this._midGain = new Gain({ 22508 context: this.context, 22509 gain: options.mid, 22510 units: "decibels" 22511 }); 22512 this._highGain = new Gain({ 22513 context: this.context, 22514 gain: options.high, 22515 units: "decibels" 22516 }); 22517 this.low = this._lowGain.gain; 22518 this.mid = this._midGain.gain; 22519 this.high = this._highGain.gain; 22520 this.Q = this._multibandSplit.Q; 22521 this.lowFrequency = this._multibandSplit.lowFrequency; 22522 this.highFrequency = this._multibandSplit.highFrequency; 22523 this._multibandSplit.low.chain(this._lowGain, this.output); 22524 this._multibandSplit.mid.chain(this._midGain, this.output); 22525 this._multibandSplit.high.chain(this._highGain, this.output); 22526 readOnly(this, ["low", "mid", "high", "lowFrequency", "highFrequency"]); 22527 this._internalChannels = [this._multibandSplit]; 22528 } 22529 static getDefaults() { 22530 return Object.assign(ToneAudioNode.getDefaults(), { 22531 high: 0, 22532 highFrequency: 2500, 22533 low: 0, 22534 lowFrequency: 400, 22535 mid: 0 22536 }); 22537 } 22538 /** 22539 * Clean up. 22540 */ 22541 dispose() { 22542 super.dispose(); 22543 writable(this, ["low", "mid", "high", "lowFrequency", "highFrequency"]); 22544 this._multibandSplit.dispose(); 22545 this.lowFrequency.dispose(); 22546 this.highFrequency.dispose(); 22547 this._lowGain.dispose(); 22548 this._midGain.dispose(); 22549 this._highGain.dispose(); 22550 this.low.dispose(); 22551 this.mid.dispose(); 22552 this.high.dispose(); 22553 this.Q.dispose(); 22554 return this; 22555 } 22556}; 22557
vendor: 260 bytes, lines 22558-22565
22558// node_modules/tone/build/esm/index.js 22559var Transport = getContext().transport; 22560var Destination = getContext().destination; 22561var Master = getContext().destination; 22562var Listener = getContext().listener; 22563var Draw = getContext().draw; 22564var context = getContext(); 22565
22566// app/javascript/components/daw/audio/AudioEngine.js 22567var DEFAULT_EFFECTS = { 22568 eq3: { 22569 enabled: false, 22570 low: 0, 22571 // dB (-12 to 12) 22572 mid: 0, 22573 // dB (-12 to 12) 22574 high: 0, 22575 // dB (-12 to 12) 22576 lowFrequency: 400, 22577 // Hz 22578 highFrequency: 2500 22579 // Hz 22580 }, 22581 compressor: { 22582 enabled: false, 22583 threshold: -24, 22584 // dB 22585 ratio: 4, 22586 // ratio 22587 attack: 3e-3, 22588 // seconds 22589 release: 0.25 22590 // seconds 22591 }, 22592 distortion: { 22593 enabled: false, 22594 amount: 0.4, 22595 type: "softclip" 22596 // 'softclip', 'hardclip', 'bitcrusher' 22597 }, 22598 phaser: { 22599 enabled: false, 22600 frequency: 0.5, 22601 // Hz (LFO rate) 22602 octaves: 3, 22603 // range of modulation 22604 baseFrequency: 1e3, 22605 // Hz 22606 wet: 0.5 22607 }, 22608 tremolo: { 22609 enabled: false, 22610 frequency: 4, 22611 // Hz (LFO rate) 22612 depth: 0.5, 22613 // 0-1 22614 wet: 1 22615 }, 22616 chorus: { 22617 enabled: false, 22618 frequency: 1.5, 22619 depth: 0.7, 22620 wet: 0.3 22621 }, 22622 delay: { 22623 enabled: false, 22624 time: "8n", 22625 // sync to BPM 22626 feedback: 0.3, 22627 wet: 0.3 22628 }, 22629 reverb: { 22630 enabled: false, 22631 roomSize: 0.5, 22632 wet: 0.3 22633 } 22634}; 22635var AudioEngine = class { 22636 constructor() { 22637 this.synths = /* @__PURE__ */ new Map(); 22638 this.drumSamplers = /* @__PURE__ */ new Map(); 22639 this.audioPlayers = /* @__PURE__ */ new Map(); 22640 this.channels = /* @__PURE__ */ new Map(); 22641 this.trackMeters = /* @__PURE__ */ new Map(); 22642 this.effects = /* @__PURE__ */ new Map(); 22643 this.lfos = /* @__PURE__ */ new Map(); 22644 this.masterVolume = null; 22645 this.masterMeter = null; 22646 this.waveformAnalyzer = null; 22647 this.fftAnalyzer = null; 22648 this.isInitialized = false; 22649 this.sequenceCallback = null; 22650 this.currentStep = 0; 22651 } 22652 // Safe disposal helper - handles disconnect, stop, and dispose in correct order 22653 // Each step is wrapped independently so failures don't prevent subsequent steps 22654 safeDispose(node) { 22655 if (!node) return; 22656 try { 22657 if (typeof node.disconnect === "function") node.disconnect(); 22658 } catch (e) { 22659 } 22660 try { 22661 if (typeof node.stop === "function") node.stop(); 22662 } catch (e) { 22663 } 22664 try { 22665 if (typeof node.dispose === "function") node.dispose(); 22666 } catch (e) { 22667 } 22668 } 22669 async init() { 22670 if (this.isInitialized) return true; 22671 try { 22672 await start(); 22673 this.waveformAnalyzer = new Waveform(2048); 22674 this.fftAnalyzer = new FFT(2048); 22675 this.masterMeter = new Meter({ smoothing: 0.8 }); 22676 this.masterVolume = new Volume(0); 22677 this.masterVolume.chain( 22678 this.waveformAnalyzer, 22679 this.fftAnalyzer, 22680 this.masterMeter, 22681 Destination 22682 ); 22683 Transport.bpm.value = 120; 22684 Transport.loop = true; 22685 Transport.loopStart = 0; 22686 Transport.loopEnd = "1m"; 22687 this.isInitialized = true; 22688 console.log("Audio engine initialized with analyzers"); 22689 return true; 22690 } catch (error) { 22691 console.error("Failed to initialize audio engine:", error); 22692 return false; 22693 } 22694 } 22695 // Create a meter for a track channel 22696 createTrackMeter(trackId, channel) { 22697 this.disposeTrackMeter(trackId); 22698 const meter = new Meter({ smoothing: 0.8 }); 22699 channel.connect(meter); 22700 this.trackMeters.set(trackId, meter); 22701 return meter; 22702 } 22703 // Dispose track meter 22704 disposeTrackMeter(trackId) { 22705 const meter = this.trackMeters.get(trackId); 22706 if (meter) { 22707 meter.dispose(); 22708 this.trackMeters.delete(trackId); 22709 } 22710 } 22711 // Get meter level for a track (returns dB value, typically -100 to 0) 22712 getTrackLevel(trackId) { 22713 const meter = this.trackMeters.get(trackId); 22714 if (meter) { 22715 return meter.getValue(); 22716 } 22717 return -100; 22718 } 22719 // Get master level 22720 getMasterLevel() { 22721 if (this.masterMeter) { 22722 return this.masterMeter.getValue(); 22723 } 22724 return -100; 22725 } 22726 // Create or update a synth for a track 22727 createSynth(trackId, settings = {}, effectsSettings = null) { 22728 this.disposeSynth(trackId); 22729 const { 22730 oscillator = "sawtooth", 22731 attack = 0.01, 22732 decay = 0.1, 22733 sustain = 0.5, 22734 release = 0.3, 22735 filterFreq = 2e3, 22736 filterRes = 1, 22737 lfo = null 22738 } = settings; 22739 const channel = new Channel().connect(this.masterVolume); 22740 this.channels.set(trackId, channel); 22741 this.createTrackMeter(trackId, channel);
22742 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 22743 effectsChain.output.connect(channel); 22744 const filter = new Filter({ 22745 frequency: filterFreq, 22746 type: "lowpass", 22747 Q: filterRes 22748 }).connect(effectsChain.input); 22749 const synth = new PolySynth(Synth, { 22750 oscillator: { type: oscillator }, 22751 envelope: { attack, decay, sustain, release } 22752 }).connect(filter); 22753 this.synths.set(trackId, { synth, filter, channel, baseFilterFreq: filterFreq }); 22754 if (lfo && lfo.enabled) { 22755 this.createLFO(trackId, lfo, filterFreq); 22756 } 22757 return synth; 22758 } 22759 // Create effects chain for a track 22760 // Chain order: EQ -> Compressor -> Distortion -> Phaser -> Tremolo -> Chorus -> Delay -> Reverb 22761 createEffectsChain(trackId, effectsSettings = null) { 22762 this.disposeEffects(trackId); 22763 const settings = effectsSettings || { ...DEFAULT_EFFECTS }; 22764 const anyEffectEnabled = settings.eq3?.enabled || settings.compressor?.enabled || settings.distortion?.enabled || settings.phaser?.enabled || settings.tremolo?.enabled || settings.chorus?.enabled || settings.delay?.enabled || settings.reverb?.enabled; 22765 if (!anyEffectEnabled) { 22766 const bypass = new Gain(1); 22767 this.effects.set(trackId, { 22768 bypass, 22769 isBypass: true, 22770 settings: { ...DEFAULT_EFFECTS, ...settings } 22771 }); 22772 return { 22773 input: bypass, 22774 output: bypass 22775 }; 22776 } 22777 const eq3 = new EQ3({ 22778 low: settings.eq3?.enabled ? settings.eq3?.low || 0 : 0, 22779 mid: settings.eq3?.enabled ? settings.eq3?.mid || 0 : 0, 22780 high: settings.eq3?.enabled ? settings.eq3?.high || 0 : 0, 22781 lowFrequency: settings.eq3?.lowFrequency || 400, 22782 highFrequency: settings.eq3?.highFrequency || 2500 22783 }); 22784 const compressor = new Compressor({ 22785 threshold: settings.compressor?.threshold || -24, 22786 ratio: settings.compressor?.ratio || 4, 22787 attack: settings.compressor?.attack || 3e-3, 22788 release: settings.compressor?.release || 0.25 22789 }); 22790 let distortion; 22791 const distType = settings.distortion?.type || "softclip"; 22792 if (distType === "bitcrusher") { 22793 distortion = new BitCrusher({ 22794 bits: Math.floor(4 + (1 - (settings.distortion?.amount || 0.4)) * 12) 22795 }); 22796 distortion.wet.value = settings.distortion?.enabled ? 1 : 0; 22797 } else { 22798 distortion = new Distortion({ 22799 distortion: settings.distortion?.amount || 0.4, 22800 oversample: distType === "hardclip" ? "none" : "4x" 22801 }); 22802 distortion.wet.value = settings.distortion?.enabled ? 1 : 0; 22803 } 22804 const phaser = new Phaser({ 22805 frequency: settings.phaser?.frequency || 0.5, 22806 octaves: settings.phaser?.octaves || 3, 22807 baseFrequency: settings.phaser?.baseFrequency || 1e3, 22808 wet: settings.phaser?.enabled ? settings.phaser?.wet || 0.5 : 0 22809 }); 22810 const tremolo = new Tremolo({ 22811 frequency: settings.tremolo?.frequency || 4, 22812 depth: settings.tremolo?.depth || 0.5, 22813 wet: settings.tremolo?.enabled ? settings.tremolo?.wet || 1 : 0 22814 }).start(); 22815 const chorus = new Chorus({ 22816 frequency: settings.chorus?.frequency || 1.5, 22817 depth: settings.chorus?.depth || 0.7, 22818 wet: settings.chorus?.enabled ? settings.chorus.wet : 0 22819 }).start(); 22820 const delay = new FeedbackDelay({ 22821 delayTime: settings.delay?.time || "8n", 22822 feedback: settings.delay?.feedback || 0.3, 22823 wet: settings.delay?.enabled ? settings.delay.wet : 0 22824 }); 22825 const reverb = null; 22826 eq3.connect(compressor); 22827 compressor.connect(distortion); 22828 distortion.connect(phaser); 22829 phaser.connect(tremolo); 22830 tremolo.connect(chorus); 22831 chorus.connect(delay); 22832 this.effects.set(trackId, { 22833 eq3, 22834 compressor, 22835 distortion, 22836 phaser, 22837 tremolo, 22838 chorus, 22839 delay, 22840 reverb, 22841 // null for now 22842 distortionType: distType, 22843 settings: { ...DEFAULT_EFFECTS, ...settings } 22844 }); 22845 return { 22846 input: eq3, 22847 output: delay 22848 // Changed from reverb to delay 22849 }; 22850 } 22851 // Update effects for a track
22852 updateEffects(trackId, effectsSettings) { 22853 const effectsData = this.effects.get(trackId); 22854 if (!effectsData) return; 22855 if (effectsData.isBypass) { 22856 const anyEnabled = effectsSettings.eq3?.enabled || effectsSettings.compressor?.enabled || effectsSettings.distortion?.enabled || effectsSettings.phaser?.enabled || effectsSettings.tremolo?.enabled || effectsSettings.chorus?.enabled || effectsSettings.delay?.enabled || effectsSettings.reverb?.enabled; 22857 if (anyEnabled) { 22858 console.log("[AudioEngine] Upgrading from bypass to full effects chain for track:", trackId); 22859 } 22860 return; 22861 } 22862 const { eq3, compressor, distortion, phaser, tremolo, chorus, delay, reverb } = effectsData; 22863 if (effectsSettings.eq3 !== void 0) { 22864 const eqSettings = effectsSettings.eq3; 22865 if (eqSettings.enabled !== void 0) { 22866 effectsData.settings.eq3.enabled = eqSettings.enabled; 22867 const isEnabled = eqSettings.enabled; 22868 eq3.low.rampTo(isEnabled ? effectsData.settings.eq3.low || 0 : 0, 0.1); 22869 eq3.mid.rampTo(isEnabled ? effectsData.settings.eq3.mid || 0 : 0, 0.1); 22870 eq3.high.rampTo(isEnabled ? effectsData.settings.eq3.high || 0 : 0, 0.1); 22871 } 22872 if (eqSettings.low !== void 0 && effectsData.settings.eq3.enabled) { 22873 eq3.low.rampTo(eqSettings.low, 0.1); 22874 } 22875 if (eqSettings.mid !== void 0 && effectsData.settings.eq3.enabled) { 22876 eq3.mid.rampTo(eqSettings.mid, 0.1); 22877 } 22878 if (eqSettings.high !== void 0 && effectsData.settings.eq3.enabled) { 22879 eq3.high.rampTo(eqSettings.high, 0.1); 22880 } 22881 if (eqSettings.lowFrequency !== void 0) { 22882 eq3.lowFrequency.rampTo(eqSettings.lowFrequency, 0.1); 22883 } 22884 if (eqSettings.highFrequency !== void 0) { 22885 eq3.highFrequency.rampTo(eqSettings.highFrequency, 0.1); 22886 } 22887 effectsData.settings.eq3 = { ...effectsData.settings.eq3, ...eqSettings }; 22888 } 22889 if (effectsSettings.compressor !== void 0) { 22890 const compSettings = effectsSettings.compressor; 22891 if (compSettings.enabled !== void 0) { 22892 effectsData.settings.compressor.enabled = compSettings.enabled; 22893 if (!compSettings.enabled) { 22894 compressor.threshold.rampTo(0, 0.1); 22895 } else { 22896 compressor.threshold.rampTo(effectsData.settings.compressor.threshold || -24, 0.1); 22897 } 22898 } 22899 if (compSettings.threshold !== void 0 && effectsData.settings.compressor.enabled) { 22900 compressor.threshold.rampTo(compSettings.threshold, 0.1); 22901 } 22902 if (compSettings.ratio !== void 0) { 22903 compressor.ratio.rampTo(compSettings.ratio, 0.1); 22904 } 22905 if (compSettings.attack !== void 0) { 22906 compressor.attack.rampTo(compSettings.attack, 0.1); 22907 } 22908 if (compSettings.release !== void 0) { 22909 compressor.release.rampTo(compSettings.release, 0.1); 22910 } 22911 effectsData.settings.compressor = { ...effectsData.settings.compressor, ...compSettings }; 22912 } 22913 if (effectsSettings.distortion !== void 0) { 22914 const distSettings = effectsSettings.distortion; 22915 if (distSettings.type !== void 0 && distSettings.type !== effectsData.distortionType) { 22916 this.recreateEffectsChain(trackId, { ...effectsData.settings, distortion: { ...effectsData.settings.distortion, ...distSettings } }); 22917 return; 22918 } 22919 if (distSettings.enabled !== void 0) { 22920 effectsData.settings.distortion.enabled = distSettings.enabled; 22921 } 22922 const isEnabled = effectsData.settings.distortion.enabled; 22923 if (distSettings.enabled !== void 0) { 22924 distortion.wet.rampTo(isEnabled ? 1 : 0, 0.1); 22925 } 22926 if (distSettings.amount !== void 0) { 22927 if (effectsData.distortionType !== "bitcrusher") { 22928 distortion.distortion = distSettings.amount; 22929 } else { 22930 distortion.bits = Math.floor(4 + (1 - distSettings.amount) * 12); 22931 } 22932 } 22933 effectsData.settings.distortion = { ...effectsData.settings.distortion, ...distSettings }; 22934 } 22935 if (effectsSettings.phaser !== void 0) { 22936 const phaserSettings = effectsSettings.phaser; 22937 if (phaserSettings.enabled !== void 0) { 22938 phaser.wet.rampTo(phaserSettings.enabled ? phaserSettings.wet ?? effectsData.settings.phaser.wet : 0, 0.1); 22939 } 22940 if (phaserSettings.wet !== void 0 && effectsData.settings.phaser.enabled) { 22941 phaser.wet.rampTo(phaserSettings.wet, 0.1); 22942 } 22943 if (phaserSettings.frequency !== void 0) { 22944 phaser.frequency.rampTo(phaserSettings.frequency, 0.1); 22945 } 22946 if (phaserSettings.octaves !== void 0) { 22947 phaser.octaves = phaserSettings.octaves; 22948 } 22949 if (phaserSettings.baseFrequency !== void 0) { 22950 phaser.baseFrequency = phaserSettings.baseFrequency; 22951 } 22952 effectsData.settings.phaser = { ...effectsData.settings.phaser, ...phaserSettings }; 22953 }
22954 if (effectsSettings.tremolo !== void 0) { 22955 const tremoloSettings = effectsSettings.tremolo; 22956 if (tremoloSettings.enabled !== void 0) { 22957 tremolo.wet.rampTo(tremoloSettings.enabled ? tremoloSettings.wet ?? effectsData.settings.tremolo.wet : 0, 0.1); 22958 } 22959 if (tremoloSettings.wet !== void 0 && effectsData.settings.tremolo.enabled) { 22960 tremolo.wet.rampTo(tremoloSettings.wet, 0.1); 22961 } 22962 if (tremoloSettings.frequency !== void 0) { 22963 tremolo.frequency.rampTo(tremoloSettings.frequency, 0.1); 22964 } 22965 if (tremoloSettings.depth !== void 0) { 22966 tremolo.depth.rampTo(tremoloSettings.depth, 0.1); 22967 } 22968 effectsData.settings.tremolo = { ...effectsData.settings.tremolo, ...tremoloSettings }; 22969 } 22970 if (effectsSettings.chorus !== void 0) { 22971 const chorusSettings = effectsSettings.chorus; 22972 if (chorusSettings.enabled !== void 0) { 22973 chorus.wet.rampTo(chorusSettings.enabled ? chorusSettings.wet ?? effectsData.settings.chorus.wet : 0, 0.1); 22974 } 22975 if (chorusSettings.wet !== void 0 && effectsData.settings.chorus.enabled) { 22976 chorus.wet.rampTo(chorusSettings.wet, 0.1); 22977 } 22978 if (chorusSettings.frequency !== void 0) { 22979 chorus.frequency.rampTo(chorusSettings.frequency, 0.1); 22980 } 22981 if (chorusSettings.depth !== void 0) { 22982 chorus.depth = chorusSettings.depth; 22983 } 22984 effectsData.settings.chorus = { ...effectsData.settings.chorus, ...chorusSettings }; 22985 } 22986 if (effectsSettings.delay !== void 0) { 22987 const delaySettings = effectsSettings.delay; 22988 if (delaySettings.enabled !== void 0) { 22989 delay.wet.rampTo(delaySettings.enabled ? delaySettings.wet ?? effectsData.settings.delay.wet : 0, 0.1); 22990 } 22991 if (delaySettings.wet !== void 0 && effectsData.settings.delay.enabled) { 22992 delay.wet.rampTo(delaySettings.wet, 0.1); 22993 } 22994 if (delaySettings.time !== void 0) { 22995 delay.delayTime.rampTo(delaySettings.time, 0.1); 22996 } 22997 if (delaySettings.feedback !== void 0) { 22998 delay.feedback.rampTo(delaySettings.feedback, 0.1); 22999 } 23000 effectsData.settings.delay = { ...effectsData.settings.delay, ...delaySettings }; 23001 } 23002 if (effectsSettings.reverb !== void 0) { 23003 effectsData.settings.reverb = { ...effectsData.settings.reverb, ...effectsSettings.reverb }; 23004 } 23005 this.effects.set(trackId, effectsData); 23006 } 23007 // Recreate effects chain (used when distortion type changes) 23008 recreateEffectsChain(trackId, newSettings) { 23009 const synthData = this.synths.get(trackId); 23010 const drumData = this.drumSamplers.get(trackId); 23011 const audioData = this.audioPlayers.get(trackId); 23012 const effectsData = this.effects.get(trackId); 23013 if (!effectsData) return; 23014 if (effectsData.isBypass) { 23015 this.safeDispose(effectsData.bypass); 23016 } else { 23017 try { 23018 if (effectsData.tremolo) effectsData.tremolo.stop(); 23019 } catch (e) { 23020 } 23021 try { 23022 if (effectsData.chorus) effectsData.chorus.stop(); 23023 } catch (e) { 23024 } 23025 this.safeDispose(effectsData.eq3); 23026 this.safeDispose(effectsData.compressor); 23027 this.safeDispose(effectsData.distortion); 23028 this.safeDispose(effectsData.phaser); 23029 this.safeDispose(effectsData.tremolo); 23030 this.safeDispose(effectsData.chorus); 23031 this.safeDispose(effectsData.delay); 23032 if (effectsData.reverb) this.safeDispose(effectsData.reverb); 23033 } 23034 this.effects.delete(trackId); 23035 const newChain = this.createEffectsChain(trackId, newSettings); 23036 const channel = this.channels.get(trackId); 23037 if (channel) { 23038 try { 23039 newChain.output.connect(channel); 23040 } catch (e) { 23041 } 23042 } 23043 try { 23044 if (synthData && synthData.filter) { 23045 synthData.filter.disconnect(); 23046 synthData.filter.connect(newChain.input); 23047 } else if (drumData) { 23048 Object.values(drumData.drums).forEach((drum) => { 23049 try { 23050 drum.disconnect(); 23051 drum.connect(newChain.input); 23052 } catch (e) { 23053 } 23054 }); 23055 } else if (audioData && audioData.player) { 23056 audioData.player.disconnect(); 23057 audioData.player.connect(newChain.input); 23058 } 23059 } catch (e) { 23060 console.warn("[AudioEngine] Error reconnecting to new effects chain:", e); 23061 } 23062 } 23063 // Dispose effects chain for a track 23064 disposeEffects(trackId) { 23065 const effectsData = this.effects.get(trackId);
23066 if (effectsData) { 23067 if (effectsData.isBypass) { 23068 this.safeDispose(effectsData.bypass); 23069 } else { 23070 if (effectsData.tremolo) { 23071 try { 23072 effectsData.tremolo.stop(); 23073 } catch (e) { 23074 } 23075 } 23076 if (effectsData.chorus) { 23077 try { 23078 effectsData.chorus.stop(); 23079 } catch (e) { 23080 } 23081 } 23082 this.safeDispose(effectsData.eq3); 23083 this.safeDispose(effectsData.compressor); 23084 this.safeDispose(effectsData.distortion); 23085 this.safeDispose(effectsData.phaser); 23086 this.safeDispose(effectsData.tremolo); 23087 this.safeDispose(effectsData.chorus); 23088 this.safeDispose(effectsData.delay); 23089 if (effectsData.reverb) this.safeDispose(effectsData.reverb); 23090 } 23091 this.effects.delete(trackId); 23092 } 23093 } 23094 // Create an LFO for wobble bass effect 23095 createLFO(trackId, lfoSettings, baseFilterFreq) { 23096 this.disposeLFO(trackId); 23097 const synthData = this.synths.get(trackId); 23098 if (!synthData) return null; 23099 const { 23100 rate = "8n", 23101 waveform = "sine", 23102 depth = 0.5, 23103 enabled = true 23104 } = lfoSettings; 23105 if (!enabled) return null; 23106 const minFreq = 100; 23107 const maxFreq = baseFilterFreq || synthData.baseFilterFreq || 2e3; 23108 const range2 = (maxFreq - minFreq) * depth; 23109 const lfo = new LFO({ 23110 frequency: rate, 23111 type: waveform, 23112 min: minFreq, 23113 max: minFreq + range2 23114 }).sync().start(0); 23115 lfo.connect(synthData.filter.frequency); 23116 this.lfos.set(trackId, { lfo, settings: lfoSettings, baseFilterFreq: maxFreq }); 23117 return lfo; 23118 } 23119 // Update LFO settings 23120 updateLFO(trackId, lfoSettings) { 23121 const synthData = this.synths.get(trackId); 23122 if (!synthData) return; 23123 const lfoData = this.lfos.get(trackId); 23124 const baseFilterFreq = synthData.baseFilterFreq || lfoData?.baseFilterFreq || 2e3; 23125 if (!lfoSettings.enabled) { 23126 this.disposeLFO(trackId); 23127 synthData.filter.frequency.cancelScheduledValues(0); 23128 synthData.filter.frequency.rampTo(baseFilterFreq, 0.1); 23129 return; 23130 } 23131 if (lfoData && lfoData.lfo) { 23132 const { lfo } = lfoData; 23133 const { 23134 rate = lfoData.settings.rate, 23135 waveform = lfoData.settings.waveform, 23136 depth = lfoData.settings.depth 23137 } = lfoSettings; 23138 if (waveform !== void 0) { 23139 lfo.type = waveform; 23140 } 23141 if (rate !== void 0) { 23142 lfo.frequency.value = rate; 23143 } 23144 if (depth !== void 0) { 23145 const minFreq = 100; 23146 const range2 = (baseFilterFreq - minFreq) * depth; 23147 lfo.min = minFreq; 23148 lfo.max = minFreq + range2; 23149 } 23150 this.lfos.set(trackId, { 23151 lfo, 23152 settings: { ...lfoData.settings, ...lfoSettings }, 23153 baseFilterFreq 23154 }); 23155 } else { 23156 this.createLFO(trackId, lfoSettings, baseFilterFreq); 23157 } 23158 } 23159 // Dispose LFO for a track 23160 disposeLFO(trackId) { 23161 const lfoData = this.lfos.get(trackId); 23162 if (lfoData && lfoData.lfo) { 23163 lfoData.lfo.stop(); 23164 lfoData.lfo.dispose(); 23165 this.lfos.delete(trackId); 23166 } 23167 } 23168 // Create a drum sampler for a track 23169 createDrumSampler(trackId, effectsSettings = null) { 23170 this.disposeDrumSampler(trackId); 23171 console.log("[AudioEngine] Creating drum sampler for track:", trackId); 23172 console.log("[AudioEngine] masterVolume exists:", !!this.masterVolume); 23173 console.log("[AudioEngine] Tone.context.state:", context.state); 23174 const channel = new Channel().connect(this.masterVolume); 23175 this.channels.set(trackId, channel); 23176 console.log("[AudioEngine] Channel created, volume:", channel.volume.value); 23177 this.createTrackMeter(trackId, channel); 23178 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 23179 console.log("[AudioEngine] Effects chain created, input:", effectsChain.input?.constructor?.name, "output:", effectsChain.output?.constructor?.name); 23180 effectsChain.output.connect(channel); 23181 console.log("[AudioEngine] Effects chain connected to channel"); 23182 const drums = { 23183 kick: new MembraneSynth({ 23184 pitchDecay: 0.05, 23185 octaves: 4, 23186 oscillator: { type: "sine" }, 23187 envelope: { attack: 1e-3, decay: 0.4, sustain: 0, release: 0.4 } 23188 }).connect(effectsChain.input),
23189 snare: new NoiseSynth({ 23190 noise: { type: "white" }, 23191 envelope: { attack: 1e-3, decay: 0.2, sustain: 0, release: 0.2 } 23192 }).connect(effectsChain.input), 23193 hihat: new MetalSynth({ 23194 frequency: 200, 23195 envelope: { attack: 1e-3, decay: 0.1, sustain: 0, release: 0.1 }, 23196 harmonicity: 5.1, 23197 modulationIndex: 32, 23198 resonance: 4e3, 23199 octaves: 1.5 23200 }).connect(effectsChain.input), 23201 clap: new NoiseSynth({ 23202 noise: { type: "pink" }, 23203 envelope: { attack: 5e-3, decay: 0.1, sustain: 0, release: 0.1 } 23204 }).connect(effectsChain.input), 23205 tom: new MembraneSynth({ 23206 pitchDecay: 0.08, 23207 octaves: 2, 23208 oscillator: { type: "sine" }, 23209 envelope: { attack: 1e-3, decay: 0.3, sustain: 0, release: 0.3 } 23210 }).connect(effectsChain.input), 23211 crash: new MetalSynth({ 23212 frequency: 300, 23213 envelope: { attack: 1e-3, decay: 1, sustain: 0, release: 1 }, 23214 harmonicity: 5.1, 23215 modulationIndex: 40, 23216 resonance: 5e3, 23217 octaves: 1.5 23218 }).connect(effectsChain.input), 23219 ride: new MetalSynth({ 23220 frequency: 400, 23221 envelope: { attack: 1e-3, decay: 0.4, sustain: 0.1, release: 0.4 }, 23222 harmonicity: 7, 23223 modulationIndex: 20, 23224 resonance: 6e3, 23225 octaves: 1 23226 }).connect(effectsChain.input), 23227 cowbell: new MetalSynth({ 23228 frequency: 560, 23229 envelope: { attack: 1e-3, decay: 0.2, sustain: 0, release: 0.2 }, 23230 harmonicity: 0.5, 23231 modulationIndex: 2, 23232 resonance: 800, 23233 octaves: 0 23234 }).connect(effectsChain.input) 23235 }; 23236 this.drumSamplers.set(trackId, { drums, channel }); 23237 return drums; 23238 } 23239 // Create a PluckSynth for guitar-like sounds 23240 // Note: PluckSynth cannot be used with PolySynth, so we create multiple instances for polyphony 23241 createPluckSynth(trackId, settings = {}, effectsSettings = null) { 23242 this.disposeSynth(trackId); 23243 const { 23244 attackNoise = 1, 23245 dampening = 4e3, 23246 resonance = 0.7, 23247 release = 1 23248 } = settings; 23249 const channel = new Channel().connect(this.masterVolume); 23250 this.channels.set(trackId, channel); 23251 this.createTrackMeter(trackId, channel); 23252 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 23253 effectsChain.output.connect(channel); 23254 const voiceCount = 8; 23255 const voices = []; 23256 for (let i = 0; i < voiceCount; i++) { 23257 const voice = new PluckSynth({ 23258 attackNoise, 23259 dampening, 23260 resonance, 23261 release 23262 }).connect(effectsChain.input); 23263 voices.push({ synth: voice, busy: false }); 23264 } 23265 const synth = { 23266 voices, 23267 currentVoice: 0, 23268 triggerAttackRelease: (note, duration, time, velocity) => { 23269 const voice = voices[synth.currentVoice]; 23270 voice.synth.triggerAttackRelease(note, duration, time, velocity); 23271 synth.currentVoice = (synth.currentVoice + 1) % voiceCount; 23272 }, 23273 dispose: () => { 23274 voices.forEach((v) => v.synth.dispose()); 23275 } 23276 }; 23277 this.synths.set(trackId, { synth, channel, synthType: "pluck", settings: { attackNoise, dampening, resonance, release } }); 23278 return synth; 23279 } 23280 // Create an FMSynth for rich, evolving timbres 23281 createFMSynth(trackId, settings = {}, effectsSettings = null) { 23282 this.disposeSynth(trackId); 23283 const { 23284 harmonicity = 3, 23285 modulationIndex = 10, 23286 attack = 0.01, 23287 decay = 0.1, 23288 sustain = 0.5, 23289 release = 0.5, 23290 modulationAttack = 0.5, 23291 modulationDecay = 0, 23292 modulationSustain = 1, 23293 modulationRelease = 0.5 23294 } = settings; 23295 const channel = new Channel().connect(this.masterVolume); 23296 this.channels.set(trackId, channel); 23297 this.createTrackMeter(trackId, channel); 23298 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 23299 effectsChain.output.connect(channel); 23300 const synth = new PolySynth(FMSynth, { 23301 harmonicity, 23302 modulationIndex, 23303 envelope: { attack, decay, sustain, release }, 23304 modulation: { type: "sine" }, 23305 modulationEnvelope: { 23306 attack: modulationAttack, 23307 decay: modulationDecay, 23308 sustain: modulationSustain, 23309 release: modulationRelease 23310 } 23311 }).connect(effectsChain.input); 23312 this.synths.set(trackId, { synth, channel, synthType: "fm", settings: { harmonicity, modulationIndex, attack, decay, sustain, release, modulationAttack, modulationDecay, modulationSustain, modulationRelease } }); 23313 return synth; 23314 } 23315 // Create an AMSynth for amplitude modulation sounds 23316 createAMSynth(trackId, settings = {}
23316, effectsSettings = null) { 23317 this.disposeSynth(trackId); 23318 const { 23319 harmonicity = 3, 23320 attack = 0.01, 23321 decay = 0.1, 23322 sustain = 0.5, 23323 release = 0.5, 23324 modulationAttack = 0.5, 23325 modulationDecay = 0, 23326 modulationSustain = 1, 23327 modulationRelease = 0.5 23328 } = settings; 23329 const channel = new Channel().connect(this.masterVolume); 23330 this.channels.set(trackId, channel); 23331 this.createTrackMeter(trackId, channel); 23332 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 23333 effectsChain.output.connect(channel); 23334 const synth = new PolySynth(AMSynth, { 23335 harmonicity, 23336 envelope: { attack, decay, sustain, release }, 23337 modulation: { type: "sine" }, 23338 modulationEnvelope: { 23339 attack: modulationAttack, 23340 decay: modulationDecay, 23341 sustain: modulationSustain, 23342 release: modulationRelease 23343 } 23344 }).connect(effectsChain.input); 23345 this.synths.set(trackId, { synth, channel, synthType: "am", settings: { harmonicity, attack, decay, sustain, release, modulationAttack, modulationDecay, modulationSustain, modulationRelease } }); 23346 return synth; 23347 } 23348 // Update Pluck synth settings 23349 updatePluckSettings(trackId, settings) { 23350 const synthData = this.synths.get(trackId); 23351 if (!synthData || synthData.synthType !== "pluck") return; 23352 const newSettings = { ...synthData.settings, ...settings }; 23353 const effectsData = this.effects.get(trackId); 23354 this.createPluckSynth(trackId, newSettings, effectsData?.settings); 23355 } 23356 // Update FM synth settings 23357 updateFMSettings(trackId, settings) { 23358 const synthData = this.synths.get(trackId); 23359 if (!synthData || synthData.synthType !== "fm") return; 23360 const { synth } = synthData; 23361 const newSettings = { ...synthData.settings, ...settings }; 23362 if (settings.harmonicity !== void 0) { 23363 synth.set({ harmonicity: settings.harmonicity }); 23364 } 23365 if (settings.modulationIndex !== void 0) { 23366 synth.set({ modulationIndex: settings.modulationIndex }); 23367 } 23368 if (settings.attack !== void 0 || settings.decay !== void 0 || settings.sustain !== void 0 || settings.release !== void 0) { 23369 synth.set({ 23370 envelope: { 23371 attack: newSettings.attack, 23372 decay: newSettings.decay, 23373 sustain: newSettings.sustain, 23374 release: newSettings.release 23375 } 23376 }); 23377 } 23378 if (settings.modulationAttack !== void 0 || settings.modulationDecay !== void 0 || settings.modulationSustain !== void 0 || settings.modulationRelease !== void 0) { 23379 synth.set({ 23380 modulationEnvelope: { 23381 attack: newSettings.modulationAttack, 23382 decay: newSettings.modulationDecay, 23383 sustain: newSettings.modulationSustain, 23384 release: newSettings.modulationRelease 23385 } 23386 }); 23387 } 23388 synthData.settings = newSettings; 23389 this.synths.set(trackId, synthData); 23390 } 23391 // Update AM synth settings 23392 updateAMSettings(trackId, settings) { 23393 const synthData = this.synths.get(trackId); 23394 if (!synthData || synthData.synthType !== "am") return; 23395 const { synth } = synthData; 23396 const newSettings = { ...synthData.settings, ...settings }; 23397 if (settings.harmonicity !== void 0) { 23398 synth.set({ harmonicity: settings.harmonicity }); 23399 } 23400 if (settings.attack !== void 0 || settings.decay !== void 0 || settings.sustain !== void 0 || settings.release !== void 0) { 23401 synth.set({ 23402 envelope: { 23403 attack: newSettings.attack, 23404 decay: newSettings.decay, 23405 sustain: newSettings.sustain, 23406 release: newSettings.release 23407 } 23408 }); 23409 } 23410 if (settings.modulationAttack !== void 0 || settings.modulationDecay !== void 0 || settings.modulationSustain !== void 0 || settings.modulationRelease !== void 0) { 23411 synth.set({ 23412 modulationEnvelope: { 23413 attack: newSettings.modulationAttack, 23414 decay: newSettings.modulationDecay, 23415 sustain: newSettings.modulationSustain, 23416 release: newSettings.modulationRelease 23417 } 23418 }); 23419 } 23420 synthData.settings = newSettings; 23421 this.synths.set(trackId, synthData); 23422 } 23423 // Create an audio player for a track
23424 createAudioPlayer(trackId, audioBuffer, effectsSettings = null) { 23425 this.disposeAudioPlayer(trackId); 23426 const channel = new Channel().connect(this.masterVolume); 23427 this.channels.set(trackId, channel); 23428 this.createTrackMeter(trackId, channel); 23429 const effectsChain = this.createEffectsChain(trackId, effectsSettings); 23430 effectsChain.output.connect(channel); 23431 const toneBuffer = new ToneAudioBuffer(audioBuffer); 23432 const player = new Player(toneBuffer).connect(effectsChain.input); 23433 player.loop = true; 23434 this.audioPlayers.set(trackId, { player, channel }); 23435 return player; 23436 } 23437 // Start/stop audio player 23438 startAudioPlayer(trackId, time = "+0") { 23439 const playerData = this.audioPlayers.get(trackId); 23440 if (playerData && playerData.player.loaded) { 23441 playerData.player.start(time); 23442 } 23443 } 23444 stopAudioPlayer(trackId) { 23445 const playerData = this.audioPlayers.get(trackId); 23446 if (playerData) { 23447 playerData.player.stop(); 23448 } 23449 } 23450 // Trigger a drum sound 23451 triggerDrum(trackId, drumType, time, velocity = 1) { 23452 const sampler = this.drumSamplers.get(trackId); 23453 if (!sampler) { 23454 return; 23455 } 23456 const { drums, channel } = sampler; 23457 const drum = drums[drumType]; 23458 if (!drum) { 23459 return; 23460 } 23461 try { 23462 switch (drumType) { 23463 case "kick": 23464 drum.triggerAttackRelease("C1", "8n", time, velocity); 23465 break; 23466 case "tom": 23467 drum.triggerAttackRelease("G1", "8n", time, velocity); 23468 break; 23469 case "hihat": 23470 case "ride": 23471 drum.triggerAttackRelease("16n", time, velocity * 0.3); 23472 break; 23473 case "crash": 23474 drum.triggerAttackRelease("4n", time, velocity * 0.4); 23475 break; 23476 case "cowbell": 23477 drum.triggerAttackRelease("16n", time, velocity * 0.5); 23478 break; 23479 default: 23480 drum.triggerAttackRelease("16n", time, velocity); 23481 } 23482 } catch (err) { 23483 console.warn("[AudioEngine] Error triggering drum:", err.message); 23484 } 23485 } 23486 // Trigger a synth note 23487 triggerNote(trackId, pitch, duration, time, velocity = 1) { 23488 const synthData = this.synths.get(trackId); 23489 if (!synthData) { 23490 return; 23491 } 23492 try { 23493 const { synth } = synthData; 23494 const note = Frequency(pitch, "midi").toNote(); 23495 synth.triggerAttackRelease(note, duration, time, velocity); 23496 } catch (err) { 23497 console.warn("[AudioEngine] Error triggering note:", err.message); 23498 } 23499 } 23500 // Update synth settings - recreates synth for reliable envelope updates 23501 updateSynthSettings(trackId, settings) { 23502 const synthData = this.synths.get(trackId); 23503 if (!synthData) return; 23504 const { synth, filter, channel, baseFilterFreq } = synthData; 23505 const needsRecreate = settings.oscillator !== void 0 || settings.attack !== void 0 || settings.decay !== void 0 || settings.sustain !== void 0 || settings.release !== void 0; 23506 if (needsRecreate) { 23507 const currentOsc = synth.get().oscillator?.type || "sawtooth"; 23508 const currentEnv = synth.get().envelope || {}; 23509 const newOsc = settings.oscillator || currentOsc; 23510 const newEnv = { 23511 attack: settings.attack ?? currentEnv.attack ?? 0.01, 23512 decay: settings.decay ?? currentEnv.decay ?? 0.1, 23513 sustain: settings.sustain ?? currentEnv.sustain ?? 0.5, 23514 release: settings.release ?? currentEnv.release ?? 0.3 23515 }; 23516 synth.dispose(); 23517 const newSynth = new PolySynth(Synth, { 23518 oscillator: { type: newOsc }, 23519 envelope: newEnv 23520 }).connect(filter); 23521 this.synths.set(trackId, { synth: newSynth, filter, channel, baseFilterFreq }); 23522 } 23523 const lfoData = this.lfos.get(trackId); 23524 if (settings.filterFreq !== void 0) { 23525 const currentSynthData = this.synths.get(trackId); 23526 if (currentSynthData) { 23527 currentSynthData.baseFilterFreq = settings.filterFreq; 23528 } 23529 if (lfoData && lfoData.lfo) { 23530 const depth = lfoData.settings.depth || 0.5; 23531 const minFreq = 100; 23532 const range2 = (settings.filterFreq - minFreq) * depth; 23533 lfoData.lfo.min = minFreq; 23534 lfoData.lfo.max = minFreq + range2; 23535 this.lfos.set(trackId, { ...lfoData, baseFilterFreq: settings.filterFreq }); 23536 } else { 23537 filter.frequency.rampTo(settings.filterFreq, 0.1); 23538 } 23539 } 23540 if (settings.filterRes !== void 0) { 23541 filter.Q.rampTo(settings.filterRes, 0.1); 23542 } 23543 if (settings.lfo !== void 0) { 23544 this.updateLFO(trackId, settings.lfo); 23545 } 23546 } 23547 // Set track volume 23548 setTrackVolume(trackId, volume) { 23549 const channel = this.channels.get(trackId); 23550 if (channel) { 23551 const dbValue = volume > 0 ? gainToDb(volume) : -Infinity; 23552 console.log("[AudioEngine] setTrackVolume:", trackId, "volume:", volume, "-> dB:", dbValue); 23553 channel.volume.value = dbValue; 23554 } else { 23555 console.warn("[AudioEngine] setTrackVolume: No channel found for track:", trackId); 23556 } 23557 } 23558 // Set track pan 23559 setTrackPan(trackId, pan) { 23560 const channel = this.channels.get(trackId); 23561 if (channel) { 23562 channel.pan.value = pan; 23563 } 23564 } 23565 // Set track mute 23566 setTrackMute(trackId, muted) { 23567 const channel = this.channels.get(trackId); 23568 if (channel) { 23569 channel.mute = muted; 23570 } 23571 } 23572 // Set master volume 23573 setMasterVolume(volume) { 23574 if (this.masterVolume) { 23575 this.masterVolume.volume.value = volume > 0 ? gainToDb(volume) : -Infinity; 23576 } 23577 } 23578 // Transport controls 23579 setBPM(bpm) { 23580 Transport.bpm.value = bpm; 23581 } 23582 setLoop(enabled, start2 = 0, end = "1m") { 23583 Transport.loop = enabled; 23584 Transport.loopStart = start2; 23585 Transport.loopEnd = end; 23586 } 23587 setLoopPoints(startStep, endStep, stepsPerMeasure = 16) { 23588 const startBars = startStep / stepsPerMeasure; 23589 const endBars = endStep / stepsPerMeasure; 23590 Transport.loopStart = `${startBars}m`; 23591 Transport.loopEnd = `${endBars}m`; 23592 } 23593 // Schedule sequence playback 23594 scheduleSequence(tracks, totalSteps, stepsPerMeasure, onStep) {
23595 console.log("[AudioEngine] Scheduling sequence with", tracks.length, "tracks,", totalSteps, "steps"); 23596 console.log("[AudioEngine] Track IDs:", tracks.map((t) => t.id)); 23597 console.log("[AudioEngine] Available synths:", Array.from(this.synths.keys())); 23598 console.log("[AudioEngine] Available drums:", Array.from(this.drumSamplers.keys())); 23599 Transport.cancel(); 23600 this.audioPlayers.forEach(({ player }) => { 23601 if (player.state === "started") { 23602 player.stop(); 23603 } 23604 }); 23605 const stepDuration = `${stepsPerMeasure}n`; 23606 this.scheduledTracks = tracks; 23607 const seq = new Sequence( 23608 (time, step) => { 23609 this.currentStep = step; 23610 if (step === 0) { 23611 tracks.forEach((track) => { 23612 if (track.type === "audio" && !track.muted) { 23613 const playerData = this.audioPlayers.get(track.id); 23614 if (playerData && playerData.player.loaded) { 23615 playerData.player.stop(); 23616 playerData.player.start(time); 23617 } 23618 } 23619 }); 23620 } 23621 if (onStep) { 23622 Draw.schedule(() => { 23623 onStep(step); 23624 }, time); 23625 } 23626 tracks.forEach((track) => { 23627 if (track.muted) return; 23628 const notesAtStep = track.notes.filter((n) => n.step === step); 23629 if (step === 0 && notesAtStep.length > 0) { 23630 console.log("[AudioEngine] Step 0 - triggering", notesAtStep.length, "notes for track", track.id, track.type); 23631 } 23632 notesAtStep.forEach((note) => { 23633 if (track.type === "drums") { 23634 const drumTypes = ["kick", "snare", "hihat", "clap", "tom", "crash", "ride", "cowbell"]; 23635 const drumType = drumTypes[note.pitch % drumTypes.length]; 23636 if (step === 0) console.log("[AudioEngine] Triggering drum:", drumType, "on track", track.id); 23637 this.triggerDrum(track.id, drumType, time, note.velocity / 127); 23638 } else if (track.type === "synth" || track.type === "pluck" || track.type === "fm" || track.type === "am") { 23639 const stepDurationSec = Time(`${stepsPerMeasure}n`).toSeconds(); 23640 const noteDurationSec = stepDurationSec * note.duration; 23641 if (step === 0) console.log("[AudioEngine] Triggering synth note:", note.pitch, "on track", track.id, track.type); 23642 this.triggerNote(track.id, note.pitch, noteDurationSec, time, note.velocity / 127); 23643 } 23644 }); 23645 }); 23646 }, 23647 [...Array(totalSteps).keys()], 23648 stepDuration 23649 ); 23650 seq.start(0); 23651 return seq; 23652 } 23653 play() { 23654 if (!this.isInitialized) return; 23655 Transport.start(); 23656 } 23657 pause() { 23658 Transport.pause(); 23659 this.audioPlayers.forEach(({ player }) => { 23660 if (player.state === "started") { 23661 player.stop(); 23662 } 23663 }); 23664 } 23665 stop() { 23666 Transport.stop(); 23667 Transport.position = 0; 23668 this.currentStep = 0; 23669 this.audioPlayers.forEach(({ player }) => { 23670 if (player.state === "started") { 23671 player.stop(); 23672 } 23673 }); 23674 } 23675 getPosition() { 23676 return Transport.position; 23677 } 23678 getCurrentStep(stepsPerMeasure = 16) { 23679 const [bars, beats, sixteenths] = Transport.position.split(":").map(Number); 23680 return Math.floor(bars * stepsPerMeasure + beats * (stepsPerMeasure / 4) + sixteenths * (stepsPerMeasure / 16)); 23681 } 23682 // Dispose channel for a track 23683 disposeChannel(trackId) { 23684 const channel = this.channels.get(trackId); 23685 if (channel) { 23686 this.safeDispose(channel); 23687 this.channels.delete(trackId); 23688 } 23689 } 23690 // Cleanup - dispose a synth and all its associated resources 23691 disposeSynth(trackId) { 23692 this.disposeLFO(trackId); 23693 this.disposeEffects(trackId); 23694 this.disposeTrackMeter(trackId); 23695 const synthData = this.synths.get(trackId); 23696 if (synthData) { 23697 if (synthData.synthType === "pluck" && synthData.synth.voices) { 23698 synthData.synth.voices.forEach((v) => this.safeDispose(v.synth)); 23699 } else { 23700 this.safeDispose(synthData.synth); 23701 } 23702 if (synthData.filter) { 23703 this.safeDispose(synthData.filter); 23704 } 23705 this.synths.delete(trackId); 23706 } 23707 this.disposeChannel(trackId); 23708 } 23709 disposeDrumSampler(trackId) { 23710 this.disposeEffects(trackId); 23711 this.disposeTrackMeter(trackId); 23712 const sampler = this.drumSamplers.get(trackId); 23713 if (sampler) {
23714 Object.values(sampler.drums).forEach((drum) => this.safeDispose(drum)); 23715 this.drumSamplers.delete(trackId); 23716 } 23717 this.disposeChannel(trackId); 23718 } 23719 disposeAudioPlayer(trackId) { 23720 this.disposeEffects(trackId); 23721 this.disposeTrackMeter(trackId); 23722 const playerData = this.audioPlayers.get(trackId); 23723 if (playerData) { 23724 if (playerData.player.state === "started") { 23725 playerData.player.stop(); 23726 } 23727 this.safeDispose(playerData.player); 23728 this.audioPlayers.delete(trackId); 23729 } 23730 this.disposeChannel(trackId); 23731 } 23732 // Dispose a complete track (any type) - single method to fully clean up a track 23733 disposeTrack(trackId) { 23734 if (this.synths.has(trackId)) { 23735 this.disposeSynth(trackId); 23736 } else if (this.drumSamplers.has(trackId)) { 23737 this.disposeDrumSampler(trackId); 23738 } else if (this.audioPlayers.has(trackId)) { 23739 this.disposeAudioPlayer(trackId); 23740 } else { 23741 this.disposeEffects(trackId); 23742 this.disposeTrackMeter(trackId); 23743 this.disposeChannel(trackId); 23744 } 23745 } 23746 // Check if a track has an instrument (synth, drums, or audio player) 23747 hasInstrument(trackId) { 23748 return this.synths.has(trackId) || this.drumSamplers.has(trackId) || this.audioPlayers.has(trackId); 23749 } 23750 // Get the type of instrument for a track 23751 getInstrumentType(trackId) { 23752 if (this.synths.has(trackId)) { 23753 const synthData = this.synths.get(trackId); 23754 return synthData.synthType || "synth"; 23755 } 23756 if (this.drumSamplers.has(trackId)) return "drums"; 23757 if (this.audioPlayers.has(trackId)) return "audio"; 23758 return null; 23759 } 23760 // Clean up instruments for tracks that no longer exist in state 23761 disposeOrphanedInstruments(validTrackIds) { 23762 const validSet = new Set(validTrackIds); 23763 const synthsToDispose = [...this.synths.keys()].filter((id) => !validSet.has(id)); 23764 const drumsToDispose = [...this.drumSamplers.keys()].filter((id) => !validSet.has(id)); 23765 const playersToDispose = [...this.audioPlayers.keys()].filter((id) => !validSet.has(id)); 23766 synthsToDispose.forEach((trackId) => { 23767 console.log("[AudioEngine] Disposing orphaned synth:", trackId); 23768 this.disposeSynth(trackId); 23769 }); 23770 drumsToDispose.forEach((trackId) => { 23771 console.log("[AudioEngine] Disposing orphaned drums:", trackId); 23772 this.disposeDrumSampler(trackId); 23773 }); 23774 playersToDispose.forEach((trackId) => { 23775 console.log("[AudioEngine] Disposing orphaned audio player:", trackId); 23776 this.disposeAudioPlayer(trackId); 23777 }); 23778 } 23779 dispose() { 23780 Transport.stop(); 23781 Transport.cancel(); 23782 this.synths.forEach((_, trackId) => this.disposeSynth(trackId)); 23783 this.drumSamplers.forEach((_, trackId) => this.disposeDrumSampler(trackId)); 23784 this.audioPlayers.forEach((_, trackId) => this.disposeAudioPlayer(trackId)); 23785 this.trackMeters.forEach((_, trackId) => this.disposeTrackMeter(trackId)); 23786 this.effects.forEach((_, trackId) => this.disposeEffects(trackId)); 23787 if (this.waveformAnalyzer) { 23788 this.waveformAnalyzer.dispose(); 23789 this.waveformAnalyzer = null; 23790 } 23791 if (this.fftAnalyzer) { 23792 this.fftAnalyzer.dispose(); 23793 this.fftAnalyzer = null; 23794 } 23795 if (this.masterMeter) { 23796 this.masterMeter.dispose(); 23797 this.masterMeter = null; 23798 } 23799 if (this.masterVolume) { 23800 this.masterVolume.dispose(); 23801 } 23802 this.isInitialized = false; 23803 } 23804}; 23805var audioEngineInstance = null; 23806function getAudioEngine() { 23807 if (!audioEngineInstance) { 23808 audioEngineInstance = new AudioEngine(); 23809 } 23810 return audioEngineInstance; 23811} 23812
23813// app/javascript/components/daw/components/TransportControls.jsx 23814var import_react2 = __toESM(require_react()); 23815var styles = { 23816 container: { 23817 display: "flex", 23818 alignItems: "center", 23819 gap: "1rem", 23820 padding: "0.75rem 1rem", 23821 background: "rgba(0,0,0,0.2)" 23822 }, 23823 transportButtons: { 23824 display: "flex", 23825 gap: "0.5rem" 23826 }, 23827 button: { 23828 width: "40px", 23829 height: "40px", 23830 borderRadius: "50%", 23831 border: "1px solid rgba(255,255,255,0.1)", 23832 background: "rgba(255,255,255,0.06)", 23833 color: "white", 23834 cursor: "pointer", 23835 display: "flex", 23836 alignItems: "center", 23837 justifyContent: "center", 23838 transition: "all 0.2s" 23839 }, 23840 playButton: { 23841 background: "linear-gradient(45deg, #10b981, #059669)" 23842 }, 23843 stopButton: { 23844 background: "rgba(239, 68, 68, 0.2)", 23845 borderColor: "rgba(239, 68, 68, 0.3)" 23846 }, 23847 controlGroup: { 23848 display: "flex", 23849 alignItems: "center", 23850 gap: "0.5rem" 23851 }, 23852 label: { 23853 fontSize: "0.75rem", 23854 color: "rgba(255,255,255,0.5)", 23855 textTransform: "uppercase", 23856 letterSpacing: "0.05em" 23857 }, 23858 input: { 23859 width: "60px", 23860 padding: "0.5rem", 23861 background: "rgba(255,255,255,0.05)", 23862 border: "1px solid rgba(255,255,255,0.1)", 23863 borderRadius: "0.25rem", 23864 color: "white", 23865 fontSize: "0.875rem", 23866 textAlign: "center" 23867 }, 23868 select: { 23869 padding: "0.5rem", 23870 background: "rgba(255,255,255,0.05)", 23871 border: "1px solid rgba(255,255,255,0.1)", 23872 borderRadius: "0.25rem", 23873 color: "white", 23874 fontSize: "0.875rem" 23875 }, 23876 loopButton: { 23877 padding: "0.5rem 0.75rem", 23878 borderRadius: "0.25rem", 23879 border: "1px solid rgba(255,255,255,0.1)", 23880 background: "rgba(255,255,255,0.06)", 23881 color: "white", 23882 cursor: "pointer", 23883 fontSize: "0.75rem", 23884 transition: "all 0.2s" 23885 }, 23886 loopActive: { 23887 background: "rgba(59, 130, 246, 0.3)", 23888 borderColor: "rgba(59, 130, 246, 0.5)" 23889 }, 23890 stepDisplay: { 23891 fontFamily: "monospace", 23892 fontSize: "1.25rem", 23893 color: "var(--accent-color)", 23894 minWidth: "80px", 23895 textAlign: "center" 23896 }, 23897 divider: { 23898 width: "1px", 23899 height: "24px", 23900 background: "rgba(255,255,255,0.1)", 23901 margin: "0 0.5rem" 23902 } 23903}; 23904function TransportControls() { 23905 const { state, actions } = useDAW(); 23906 const handleStop = () => { 23907 actions.setPlaying(false); 23908 actions.setCurrentStep(0); 23909 }; 23910 const formatStep = (step) => { 23911 const measure = Math.floor(step / state.stepsPerMeasure) + 1; 23912 const beat = step % state.stepsPerMeasure + 1; 23913 return `${measure}.${beat.toString().padStart(2, "0")}`; 23914 }; 23915 return /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.container }, /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.transportButtons }, /* @__PURE__ */ import_react2.default.createElement( 23916 "button", 23917 { 23918 style: { 23919 ...styles.button, 23920 ...state.isPlaying ? styles.playButton : {} 23921 }, 23922 onClick: () => actions.setPlaying(!state.isPlaying), 23923 title: state.isPlaying ? "Pause (Space)" : "Play (Space)" 23924 },
23925 state.isPlaying ? /* @__PURE__ */ import_react2.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ import_react2.default.createElement("rect", { x: "6", y: "4", width: "4", height: "16" }), /* @__PURE__ */ import_react2.default.createElement("rect", { x: "14", y: "4", width: "4", height: "16" })) : /* @__PURE__ */ import_react2.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ import_react2.default.createElement("polygon", { points: "5,3 19,12 5,21" })) 23926 ), /* @__PURE__ */ import_react2.default.createElement( 23927 "button", 23928 { 23929 style: { ...styles.button, ...styles.stopButton }, 23930 onClick: handleStop, 23931 title: "Stop (Enter)" 23932 }, 23933 /* @__PURE__ */ import_react2.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ import_react2.default.createElement("rect", { x: "4", y: "4", width: "16", height: "16" }))
23934 )), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.divider }), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.stepDisplay }, formatStep(state.currentStep)), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.divider }), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.controlGroup }, /* @__PURE__ */ import_react2.default.createElement("span", { style: styles.label }, "BPM"), /* @__PURE__ */ import_react2.default.createElement( 23935 "input", 23936 { 23937 type: "number", 23938 min: "40", 23939 max: "240", 23940 value: state.bpm, 23941 onChange: (e) => actions.setBPM(parseInt(e.target.value) || 120), 23942 style: styles.input 23943 } 23944 )), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.divider }), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.controlGroup }, /* @__PURE__ */ import_react2.default.createElement("span", { style: styles.label }, "Steps"), /* @__PURE__ */ import_react2.default.createElement( 23945 "select", 23946 { 23947 value: state.totalSteps, 23948 onChange: (e) => actions.setTotalSteps(parseInt(e.target.value)), 23949 style: styles.select 23950 }, 23951 /* @__PURE__ */ import_react2.default.createElement("option", { value: "8" }, "8"), 23952 /* @__PURE__ */ import_react2.default.createElement("option", { value: "16" }, "16"), 23953 /* @__PURE__ */ import_react2.default.createElement("option", { value: "32" }, "32"), 23954 /* @__PURE__ */ import_react2.default.createElement("option", { value: "64" }, "64")
23955 )), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.divider }), /* @__PURE__ */ import_react2.default.createElement( 23956 "button", 23957 { 23958 style: { 23959 ...styles.loopButton, 23960 ...state.isLooping ? styles.loopActive : {} 23961 }, 23962 onClick: () => actions.setLoop(!state.isLooping), 23963 title: "Toggle Loop" 23964 }, 23965 "Loop" 23966 ), /* @__PURE__ */ import_react2.default.createElement("div", { style: { flex: 1 } }), /* @__PURE__ */ import_react2.default.createElement("div", { style: styles.controlGroup }, /* @__PURE__ */ import_react2.default.createElement("span", { style: styles.label }, "Master"), /* @__PURE__ */ import_react2.default.createElement( 23967 "input", 23968 { 23969 type: "range", 23970 min: "0", 23971 max: "1", 23972 step: "0.01", 23973 value: state.masterVolume, 23974 onChange: (e) => actions.setMasterVolume(parseFloat(e.target.value)), 23975 style: { width: "80px" } 23976 } 23977 ), /* @__PURE__ */ import_react2.default.createElement("span", { style: { fontSize: "0.75rem", color: "rgba(255,255,255,0.5)", width: "36px" } }, Math.round(state.masterVolume * 100), "%"))); 23978} 23979
23980// app/javascript/components/daw/components/TrackList.jsx 23981var import_react3 = __toESM(require_react()); 23982var styles2 = { 23983 container: { 23984 display: "flex", 23985 flexDirection: "column", 23986 gap: "0.5rem", 23987 height: "100%" 23988 }, 23989 header: { 23990 display: "flex", 23991 justifyContent: "space-between", 23992 alignItems: "center" 23993 }, 23994 title: { 23995 fontSize: "0.7rem", 23996 color: "rgba(255,255,255,0.5)", 23997 textTransform: "uppercase", 23998 letterSpacing: "0.05em" 23999 }, 24000 addSelect: { 24001 padding: "0.3rem 0.5rem", 24002 fontSize: "0.65rem", 24003 background: "rgba(16, 185, 129, 0.15)", 24004 border: "1px solid rgba(16, 185, 129, 0.25)", 24005 borderRadius: "0.25rem", 24006 color: "#10b981", 24007 cursor: "pointer", 24008 fontWeight: 500 24009 }, 24010 trackList: { 24011 display: "flex", 24012 flexDirection: "column", 24013 gap: "0.25rem", 24014 flex: 1, 24015 overflowY: "auto", 24016 overflowX: "hidden" 24017 }, 24018 track: { 24019 padding: "0.5rem", 24020 background: "rgba(255,255,255,0.02)", 24021 border: "1px solid rgba(255,255,255,0.05)", 24022 borderRadius: "0.25rem", 24023 cursor: "pointer", 24024 transition: "all 0.15s" 24025 }, 24026 trackSelected: { 24027 background: "rgba(16, 185, 129, 0.1)", 24028 borderColor: "rgba(16, 185, 129, 0.3)" 24029 }, 24030 trackTop: { 24031 display: "flex", 24032 alignItems: "center", 24033 gap: "0.375rem", 24034 marginBottom: "0.375rem" 24035 }, 24036 trackInfo: { 24037 flex: 1, 24038 minWidth: 0 24039 }, 24040 trackName: { 24041 fontSize: "0.75rem", 24042 fontWeight: 500, 24043 color: "white", 24044 overflow: "hidden", 24045 textOverflow: "ellipsis", 24046 whiteSpace: "nowrap" 24047 }, 24048 trackNameInput: { 24049 fontSize: "0.75rem", 24050 fontWeight: 500, 24051 color: "white", 24052 background: "rgba(0,0,0,0.3)", 24053 border: "1px solid rgba(16, 185, 129, 0.4)", 24054 borderRadius: "0.2rem", 24055 padding: "0.1rem 0.25rem", 24056 width: "100%", 24057 outline: "none" 24058 }, 24059 trackType: { 24060 fontSize: "0.55rem", 24061 color: "rgba(255,255,255,0.35)", 24062 textTransform: "uppercase", 24063 letterSpacing: "0.03em" 24064 }, 24065 deleteBtn: { 24066 background: "none", 24067 border: "none", 24068 color: "rgba(255,255,255,0.25)", 24069 cursor: "pointer", 24070 fontSize: "0.9rem", 24071 padding: "0", 24072 lineHeight: 1, 24073 transition: "color 0.15s" 24074 }, 24075 controls: { 24076 display: "flex", 24077 alignItems: "center", 24078 gap: "0.25rem" 24079 }, 24080 msButton: { 24081 width: "20px", 24082 height: "20px", 24083 display: "flex", 24084 alignItems: "center", 24085 justifyContent: "center", 24086 fontSize: "0.55rem", 24087 fontWeight: 700, 24088 background: "rgba(255,255,255,0.05)", 24089 border: "1px solid rgba(255,255,255,0.08)", 24090 borderRadius: "0.2rem", 24091 color: "rgba(255,255,255,0.4)", 24092 cursor: "pointer", 24093 transition: "all 0.15s" 24094 }, 24095 muteActive: { 24096 background: "rgba(239, 68, 68, 0.25)", 24097 borderColor: "rgba(239, 68, 68, 0.4)", 24098 color: "#ef4444" 24099 }, 24100 soloActive: { 24101 background: "rgba(59, 130, 246, 0.25)", 24102 borderColor: "rgba(59, 130, 246, 0.4)", 24103 color: "#3b82f6" 24104 }, 24105 volumeContainer: { 24106 flex: 1, 24107 display: "flex", 24108 alignItems: "center", 24109 gap: "0.25rem", 24110 minWidth: 0 24111 }, 24112 volumeSlider: { 24113 flex: 1, 24114 height: "3px", 24115 appearance: "none", 24116 background: "rgba(255,255,255,0.1)", 24117 borderRadius: "2px", 24118 cursor: "pointer" 24119 }, 24120 volumeLabel: { 24121 fontSize: "0.5rem", 24122 color: "rgba(255,255,255,0.35)", 24123 width: "22px", 24124 textAlign: "right" 24125 } 24126}; 24127function TrackItem({ track, isSelected, onSelect, onUpdate, onDelete, audioEngine, allTracks }) { 24128 const [isEditing, setIsEditing] = (0, import_react3.useState)(false); 24129 const [editName, setEditName] = (0, import_react3.useState)(track.name); 24130 const inputRef = (0, import_react3.useRef)(null); 24131 (0, import_react3.useEffect)(() => { 24132 if (isEditing && inputRef.current) { 24133 inputRef.current.focus(); 24134 inputRef.current.select(); 24135 } 24136 }, [isEditing]); 24137 const handleDoubleClick = (e) => { 24138 e.stopPropagation(); 24139 setEditName(track.name); 24140 setIsEditing(true); 24141 }; 24142 const handleNameSubmit = () => { 24143 if (editName.trim()) { 24144 onUpdate(track.id, { name: editName.trim() }); 24145 } 24146 setIsEditing(false); 24147 }; 24148 const handleKeyDown = (e) => { 24149 if (e.key === "Enter") { 24150 handleNameSubmit(); 24151 } else if (e.key === "Escape") { 24152 setIsEditing(false); 24153 } 24154 }; 24155 const handleMute = (e) => { 24156 e.stopPropagation(); 24157 const newMuted = !track.muted; 24158 onUpdate(track.id, { muted: newMuted }); 24159 if (audioEngine) { 24160 audioEngine.setTrackMute(track.id, newMuted); 24161 } 24162 }; 24163 const handleSolo = (e) => { 24164 e.stopPropagation(); 24165 const newSolo = !track.solo; 24166 onUpdate(track.id, { solo: newSolo }); 24167 if (audioEngine) { 24168 const anyTrackSoloed = newSolo || allTracks.some((t) => t.id !== track.id && t.solo); 24169 allTracks.forEach((t) => { 24170 if (t.id === track.id) { 24171 if (newSolo) { 24172 audioEngine.setTrackMute(t.id, false); 24173 } 24174 } else { 24175 const shouldMute = anyTrackSoloed && !t.solo && t.id !== track.id; 24176 audioEngine.setTrackMute(t.id, shouldMute || t.muted); 24177 } 24178 }); 24179 if (!newSolo && !allTracks.some((t) => t.id !== track.id && t.solo)) { 24180 allTracks.forEach((t) => { 24181 audioEngine.setTrackMute(t.id, t.muted); 24182 }); 24183 } 24184 } 24185 }; 24186 const handleVolumeChange = (e) => { 24187 e.stopPropagation(); 24188 const volume = parseFloat(e.target.value); 24189 onUpdate(track.id, { volume }); 24190 if (audioEngine) { 24191 audioEngine.setTrackVolume(track.id, volume); 24192 } 24193 }; 24194 return /* @__PURE__ */ import_react3.default.createElement( 24195 "div", 24196 { 24197 style: { 24198 ...styles2.track, 24199 ...isSelected ? styles2.trackSelected : {} 24200 }, 24201 onClick: onSelect 24202 },
24203 /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.trackTop }, /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.trackInfo, onDoubleClick: handleDoubleClick }, isEditing ? /* @__PURE__ */ import_react3.default.createElement( 24204 "input", 24205 { 24206 ref: inputRef, 24207 type: "text", 24208 value: editName, 24209 onChange: (e) => setEditName(e.target.value), 24210 onBlur: handleNameSubmit, 24211 onKeyDown: handleKeyDown, 24212 onClick: (e) => e.stopPropagation(), 24213 style: styles2.trackNameInput 24214 } 24215 ) : /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.trackName, title: "Double-click to rename" }, track.name), /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.trackType }, track.type))), /* @__PURE__ */ import_react3.default.createElement( 24216 "button", 24217 { 24218 style: styles2.deleteBtn, 24219 onClick: (e) => { 24220 e.stopPropagation(); 24221 onDelete(track.id); 24222 }, 24223 onMouseOver: (e) => e.currentTarget.style.color = "#ef4444", 24224 onMouseOut: (e) => e.currentTarget.style.color = "rgba(255,255,255,0.25)", 24225 title: "Delete track" 24226 }, 24227 "\xD7" 24228 )), 24229 /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.controls }, /* @__PURE__ */ import_react3.default.createElement( 24230 "button", 24231 { 24232 style: { 24233 ...styles2.msButton, 24234 ...track.muted ? styles2.muteActive : {} 24235 }, 24236 onClick: handleMute, 24237 title: "Mute" 24238 }, 24239 "M" 24240 ), /* @__PURE__ */ import_react3.default.createElement( 24241 "button", 24242 { 24243 style: { 24244 ...styles2.msButton, 24245 ...track.solo ? styles2.soloActive : {} 24246 }, 24247 onClick: handleSolo, 24248 title: "Solo" 24249 }, 24250 "S" 24251 ), /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.volumeContainer }, /* @__PURE__ */ import_react3.default.createElement( 24252 "input", 24253 { 24254 type: "range", 24255 min: "0", 24256 max: "1", 24257 step: "0.01", 24258 value: track.volume, 24259 onChange: handleVolumeChange, 24260 onClick: (e) => e.stopPropagation(), 24261 style: styles2.volumeSlider 24262 } 24263 ), /* @__PURE__ */ import_react3.default.createElement("span", { style: styles2.volumeLabel }, Math.round(track.volume * 100)))) 24264 ); 24265} 24266function TrackList({ audioEngine }) { 24267 const { state, actions } = useDAW(); 24268 const handleAddTrack = (0, import_react3.useCallback)((e) => { 24269 const type = e.target.value; 24270 if (type) { 24271 actions.addTrack(type); 24272 e.target.value = ""; 24273 } 24274 }, [actions]); 24275 const handleDelete = (0, import_react3.useCallback)((trackId) => { 24276 if (state.tracks.length <= 1) return; 24277 if (audioEngine) { 24278 try { 24279 audioEngine.disposeTrack(trackId); 24280 } catch (err) { 24281 console.warn("[TrackList] Error disposing track:", err); 24282 } 24283 } 24284 actions.removeTrack(trackId); 24285 }, [actions, audioEngine, state.tracks.length]); 24286 return /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.container }, /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.header }, /* @__PURE__ */ import_react3.default.createElement("span", { style: styles2.title }, "Tracks"), /* @__PURE__ */ import_react3.default.createElement( 24287 "select", 24288 { 24289 style: styles2.addSelect, 24290 onChange: handleAddTrack, 24291 defaultValue: "" 24292 }, 24293 /* @__PURE__ */ import_react3.default.createElement("option", { value: "", disabled: true }, "+ Add"), 24294 /* @__PURE__ */ import_react3.default.createElement("option", { value: "synth" }, "Synth"), 24295 /* @__PURE__ */ import_react3.default.createElement("option", { value: "drums" }, "Drums"), 24296 /* @__PURE__ */ import_react3.default.createElement("option", { value: "pluck" }, "Pluck"), 24297 /* @__PURE__ */ import_react3.default.createElement("option", { value: "fm" }, "FM Synth"),
24298 /* @__PURE__ */ import_react3.default.createElement("option", { value: "am" }, "AM Synth") 24299 )), /* @__PURE__ */ import_react3.default.createElement("div", { style: styles2.trackList }, state.tracks.map((track) => /* @__PURE__ */ import_react3.default.createElement( 24300 TrackItem, 24301 { 24302 key: track.id, 24303 track, 24304 isSelected: track.id === state.selectedTrackId, 24305 onSelect: () => actions.selectTrack(track.id), 24306 onUpdate: actions.updateTrack, 24307 onDelete: handleDelete, 24308 audioEngine, 24309 allTracks: state.tracks 24310 } 24311 )))); 24312} 24313
24314// app/javascript/components/daw/components/PianoRoll.jsx 24315var import_react4 = __toESM(require_react()); 24316var PIANO_KEYS = [ 24317 { note: "C", midi: 60, isBlack: false }, 24318 { note: "C#", midi: 61, isBlack: true }, 24319 { note: "D", midi: 62, isBlack: false }, 24320 { note: "D#", midi: 63, isBlack: true }, 24321 { note: "E", midi: 64, isBlack: false }, 24322 { note: "F", midi: 65, isBlack: false }, 24323 { note: "F#", midi: 66, isBlack: true }, 24324 { note: "G", midi: 67, isBlack: false }, 24325 { note: "G#", midi: 68, isBlack: true }, 24326 { note: "A", midi: 69, isBlack: false }, 24327 { note: "A#", midi: 70, isBlack: true }, 24328 { note: "B", midi: 71, isBlack: false } 24329]; 24330var generateKeys = () => { 24331 const keys = []; 24332 for (let octave = 3; octave <= 5; octave++) { 24333 PIANO_KEYS.forEach((key) => { 24334 keys.push({ 24335 ...key, 24336 midi: key.midi + (octave - 4) * 12, 24337 label: `${key.note}${octave}` 24338 }); 24339 }); 24340 } 24341 return keys.reverse(); 24342}; 24343var ALL_KEYS = generateKeys(); 24344var ROW_HEIGHT = 25; 24345var KEY_WIDTH = 48; 24346var DEFAULT_STEP_WIDTH = 24; 24347var TARGET_FILL_RATIO = 0.8; 24348var BASE_STEP_COUNT = 16; 24349var MIN_STEP_WIDTH = 20; 24350var MAX_STEP_WIDTH = 60; 24351var styles3 = { 24352 container: { 24353 display: "flex", 24354 height: `${ALL_KEYS.length * ROW_HEIGHT}px`, 24355 maxHeight: "500px", 24356 overflow: "auto", 24357 background: "rgba(0,0,0,0.3)", 24358 position: "relative" 24359 }, 24360 keysContainer: { 24361 flexShrink: 0, 24362 width: `${KEY_WIDTH}px`, 24363 background: "rgba(0,0,0,0.4)", 24364 borderRight: "1px solid rgba(255,255,255,0.1)", 24365 position: "sticky", 24366 left: 0, 24367 zIndex: 10 24368 }, 24369 key: { 24370 height: `${ROW_HEIGHT}px`, 24371 display: "flex", 24372 alignItems: "center", 24373 justifyContent: "flex-end", 24374 paddingRight: "10px", 24375 fontSize: "0.75rem", 24376 fontFamily: "monospace", 24377 borderBottom: "1px solid rgba(255,255,255,0.05)", 24378 cursor: "pointer", 24379 transition: "background 0.1s" 24380 }, 24381 whiteKey: { 24382 background: "rgba(255,255,255,0.15)", 24383 color: "rgba(255,255,255,0.7)" 24384 }, 24385 blackKey: { 24386 background: "rgba(0,0,0,0.4)", 24387 color: "rgba(255,255,255,0.5)" 24388 }, 24389 gridContainer: { 24390 flex: 1, 24391 position: "relative" 24392 }, 24393 gridRow: { 24394 height: `${ROW_HEIGHT}px`, 24395 display: "flex", 24396 borderBottom: "1px solid rgba(255,255,255,0.05)" 24397 }, 24398 gridCell: { 24399 width: `${DEFAULT_STEP_WIDTH}px`, 24400 height: "100%", 24401 borderRight: "1px solid rgba(255,255,255,0.05)", 24402 cursor: "pointer", 24403 transition: "background 0.1s" 24404 }, 24405 barLine: { 24406 borderRightColor: "rgba(255,255,255,0.15)" 24407 }, 24408 note: { 24409 position: "absolute", 24410 height: `${ROW_HEIGHT - 4}px`, 24411 background: "linear-gradient(135deg, var(--accent-color, #10b981), #059669)", 24412 borderRadius: "3px", 24413 cursor: "pointer", 24414 boxShadow: "0 1px 3px rgba(0,0,0,0.3)", 24415 display: "flex", 24416 alignItems: "center", 24417 justifyContent: "flex-end", 24418 userSelect: "none" 24419 }, 24420 noteHover: { 24421 filter: "brightness(1.1)" 24422 }, 24423 noteResizing: { 24424 filter: "brightness(1.2)", 24425 boxShadow: "0 2px 8px rgba(16, 185, 129, 0.5)" 24426 }, 24427 resizeHandle: { 24428 position: "absolute", 24429 right: 0, 24430 top: 0, 24431 width: "8px", 24432 height: "100%", 24433 cursor: "ew-resize", 24434 background: "rgba(255,255,255,0.2)", 24435 borderRadius: "0 3px 3px 0", 24436 opacity: 0, 24437 transition: "opacity 0.15s" 24438 }, 24439 resizeHandleVisible: { 24440 opacity: 1 24441 }, 24442 playhead: { 24443 position: "absolute", 24444 top: 0, 24445 width: "2px", 24446 background: "#ef4444", 24447 zIndex: 30, 24448 pointerEvents: "none", 24449 boxShadow: "0 0 8px rgba(239, 68, 68, 0.6)" 24450 }, 24451 drumRow: { 24452 height: `${ROW_HEIGHT}px`, 24453 display: "flex", 24454 borderBottom: "1px solid rgba(255,255,255,0.1)" 24455 }, 24456 drumLabel: { 24457 width: `${KEY_WIDTH}px`, 24458 height: `${ROW_HEIGHT}px`, 24459 display: "flex", 24460 alignItems: "center", 24461 justifyContent: "flex-end", 24462 paddingRight: "8px", 24463 fontSize: "0.75rem", 24464 fontWeight: 500, 24465 color: "rgba(255,255,255,0.8)", 24466 background: "rgba(0,0,0,0.4)", 24467 borderRight: "1px solid rgba(255,255,255,0.1)", 24468 borderBottom: "1px solid rgba(255,255,255,0.05)", 24469 boxSizing: "border-box" 24470 } 24471};
24472var DRUM_LABELS = ["Kick", "Snare", "Hi-Hat", "Clap", "Tom", "Crash", "Ride", "Cowbell"]; 24473var DRUM_TYPES = ["kick", "snare", "hihat", "clap", "tom", "crash", "ride", "cowbell"]; 24474function DrumGrid({ track, audioEngine }) { 24475 const { state, actions } = useDAW(); 24476 const containerRef = (0, import_react4.useRef)(null); 24477 const [stepWidth, setStepWidth] = (0, import_react4.useState)(DEFAULT_STEP_WIDTH); 24478 (0, import_react4.useEffect)(() => { 24479 const container = containerRef.current; 24480 if (!container) return; 24481 const calculateStepWidth = () => { 24482 const containerWidth = container.clientWidth - KEY_WIDTH; 24483 const baseWidth = containerWidth * TARGET_FILL_RATIO / BASE_STEP_COUNT; 24484 const scaledWidth = baseWidth * (BASE_STEP_COUNT / Math.max(state.totalSteps, BASE_STEP_COUNT)); 24485 const newWidth = Math.min(MAX_STEP_WIDTH, Math.max(MIN_STEP_WIDTH, scaledWidth)); 24486 setStepWidth(newWidth); 24487 }; 24488 calculateStepWidth(); 24489 const resizeObserver = new ResizeObserver(calculateStepWidth); 24490 resizeObserver.observe(container); 24491 return () => resizeObserver.disconnect(); 24492 }, [state.totalSteps]); 24493 const handleCellClick = (0, import_react4.useCallback)((step, drumIndex) => { 24494 if (!track) return; 24495 const existingNote = track.notes.find((n) => n.step === step && n.pitch === drumIndex); 24496 if (existingNote) { 24497 actions.removeNote(track.id, existingNote.id); 24498 } else { 24499 if (audioEngine) { 24500 audioEngine.triggerDrum(track.id, DRUM_TYPES[drumIndex], "+0", 0.8); 24501 } 24502 actions.addNote(track.id, { 24503 pitch: drumIndex, 24504 step, 24505 duration: 1, 24506 velocity: 100 24507 }); 24508 } 24509 }, [track, actions, audioEngine]); 24510 const noteMap = (0, import_react4.useMemo)(() => { 24511 const map = /* @__PURE__ */ new Map(); 24512 track?.notes.forEach((note) => { 24513 const key = `${note.step}-${note.pitch}`; 24514 map.set(key, note); 24515 }); 24516 return map; 24517 }, [track?.notes]); 24518 const playheadLeft = KEY_WIDTH + state.currentStep * stepWidth + stepWidth / 2; 24519 return /* @__PURE__ */ import_react4.default.createElement("div", { style: { ...styles3.container, height: `${DRUM_LABELS.length * ROW_HEIGHT}px` }, ref: containerRef }, state.isPlaying && /* @__PURE__ */ import_react4.default.createElement( 24520 "div", 24521 { 24522 style: { 24523 ...styles3.playhead, 24524 left: `${playheadLeft}px`, 24525 height: `${DRUM_LABELS.length * ROW_HEIGHT}px` 24526 } 24527 } 24528 ), /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.keysContainer }, DRUM_LABELS.map((label, idx) => { 24529 const isSelected = state.selectedPitch === idx; 24530 return /* @__PURE__ */ import_react4.default.createElement( 24531 "div", 24532 { 24533 key: idx, 24534 style: { 24535 ...styles3.drumLabel, 24536 height: `${ROW_HEIGHT}px`, 24537 cursor: "pointer", 24538 background: isSelected ? "rgba(16, 185, 129, 0.2)" : "rgba(0,0,0,0.4)", 24539 borderLeft: isSelected ? "3px solid var(--accent-color, #10b981)" : "3px solid transparent" 24540 }, 24541 onClick: () => { 24542 actions.setSelectedPitch(idx); 24543 if (audioEngine && track) { 24544 audioEngine.triggerDrum(track.id, DRUM_TYPES[idx], "+0", 0.8); 24545 } 24546 } 24547 }, 24548 label 24549 ); 24550 })), /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.gridContainer }, DRUM_LABELS.map((_, drumIndex) => { 24551 const isSelected = state.selectedPitch === drumIndex; 24552 return /* @__PURE__ */ import_react4.default.createElement( 24553 "div", 24554 { 24555 key: drumIndex, 24556 style: { 24557 ...styles3.drumRow, 24558 background: isSelected ? "rgba(16, 185, 129, 0.05)" : "transparent" 24559 } 24560 }, 24561 Array.from({ length: state.totalSteps }).map((_2, step) => { 24562 const hasNote = noteMap.has(`${step}-${drumIndex}`); 24563 const isBarLine = (step + 1) % 4 === 0; 24564 return /* @__PURE__ */ import_react4.default.createElement( 24565 "div", 24566 { 24567 key: step, 24568 style: { 24569 width: `${stepWidth}px`, 24570 height: "100%", 24571 borderRight: isBarLine ? "1px solid rgba(255,255,255,0.15)" : "1px solid rgba(255,255,255,0.05)", 24572 cursor: "pointer", 24573 transition: "background 0.1s", 24574 background: hasNote ? "linear-gradient(135deg, var(--accent-color, #10b981), #059669)" : state.currentStep === step ? "rgba(255,255,255,0.08)" : "transparent" 24575 }, 24576 onClick: () => handleCellClick(step, drumIndex) 24577 } 24578 ); 24579 }) 24580 ); 24581 }))); 24582} 24583function SynthGrid({ track, audioEngine }) { 24584 const { state, actions } = useDAW(); 24585 const gridContainerRef = (0, import_react4.useRef)(null); 24586 const outerContainerRef = (0, import_react4.useRef)(null); 24587 const [stepWidth, setStepWidth] = (0, import_react4.useState)(DEFAULT_STEP_WIDTH); 24588 (0, import_react4.useEffect)(() => { 24589 const container = outerContainerRef.current; 24590 if (!container) return; 24591 const calculateStepWidth = () => { 24592 const containerWidth = container.clientWidth - KEY_WIDTH; 24593 const baseWidth = containerWidth * TARGET_FILL_RATIO / BASE_STEP_
24593COUNT; 24594 const scaledWidth = baseWidth * (BASE_STEP_COUNT / Math.max(state.totalSteps, BASE_STEP_COUNT)); 24595 const newWidth = Math.min(MAX_STEP_WIDTH, Math.max(MIN_STEP_WIDTH, scaledWidth)); 24596 setStepWidth(newWidth); 24597 }; 24598 calculateStepWidth(); 24599 const resizeObserver = new ResizeObserver(calculateStepWidth); 24600 resizeObserver.observe(container); 24601 return () => resizeObserver.disconnect(); 24602 }, [state.totalSteps]); 24603 const [resizingNote, setResizingNote] = (0, import_react4.useState)(null); 24604 const [hoveredNoteId, setHoveredNoteId] = (0, import_react4.useState)(null); 24605 const [isCreating, setIsCreating] = (0, import_react4.useState)(false); 24606 const [createStart, setCreateStart] = (0, import_react4.useState)(null); 24607 const [createPreview, setCreatePreview] = (0, import_react4.useState)(null); 24608 const handleResizeStart = (0, import_react4.useCallback)((e, note) => { 24609 e.stopPropagation(); 24610 e.preventDefault(); 24611 setResizingNote({ 24612 noteId: note.id, 24613 pitch: note.pitch, 24614 startStep: note.step, 24615 originalDuration: note.duration, 24616 startX: e.clientX 24617 }); 24618 }, []); 24619 (0, import_react4.useEffect)(() => { 24620 if (!resizingNote) return; 24621 const handleMouseMove = (e) => { 24622 const deltaX = e.clientX - resizingNote.startX; 24623 const stepDelta = Math.round(deltaX / stepWidth); 24624 const newDuration = Math.max(1, resizingNote.originalDuration + stepDelta); 24625 const maxDuration = state.totalSteps - resizingNote.startStep; 24626 const clampedDuration = Math.min(newDuration, maxDuration); 24627 actions.updateNote(track.id, resizingNote.noteId, { duration: clampedDuration }); 24628 }; 24629 const handleMouseUp = () => { 24630 setResizingNote(null); 24631 }; 24632 document.addEventListener("mousemove", handleMouseMove); 24633 document.addEventListener("mouseup", handleMouseUp); 24634 return () => { 24635 document.removeEventListener("mousemove", handleMouseMove); 24636 document.removeEventListener("mouseup", handleMouseUp); 24637 }; 24638 }, [resizingNote, actions, track?.id, state.totalSteps, stepWidth]); 24639 const handleGridMouseDown = (0, import_react4.useCallback)((e, step, midi) => { 24640 if (!track) return; 24641 const existingNote = track.notes.find( 24642 (n) => n.pitch === midi && step >= n.step && step < n.step + (n.duration || 1) 24643 ); 24644 if (existingNote) { 24645 actions.removeNote(track.id, existingNote.id); 24646 return; 24647 } 24648 setIsCreating(true); 24649 setCreateStart({ step, midi }); 24650 setCreatePreview({ step, midi, duration: 1 }); 24651 if (audioEngine) { 24652 audioEngine.triggerNote(track.id, midi, "16n", "+0", 0.8); 24653 } 24654 }, [track, actions, audioEngine]); 24655 (0, import_react4.useEffect)(() => { 24656 if (!isCreating || !createStart) return; 24657 const handleMouseMove = (e) => { 24658 if (!gridContainerRef.current) return; 24659 const rect = gridContainerRef.current.getBoundingClientRect(); 24660 const x = e.clientX - rect.left; 24661 const currentStep = Math.floor(x / stepWidth); 24662 const newDuration = Math.max(1, currentStep - createStart.step + 1); 24663 const maxDuration = state.totalSteps - createStart.step; 24664 const clampedDuration = Math.min(newDuration, maxDuration); 24665 setCreatePreview({ 24666 step: createStart.step, 24667 midi: createStart.midi, 24668 duration: clampedDuration 24669 }); 24670 }; 24671 const handleMouseUp = () => { 24672 if (createPreview && track) { 24673 actions.addNote(track.id, { 24674 pitch: createPreview.midi, 24675 step: createPreview.step, 24676 duration: createPreview.duration, 24677 velocity: 100 24678 }); 24679 } 24680 setIsCreating(false); 24681 setCreateStart(null); 24682 setCreatePreview(null); 24683 }; 24684 document.addEventListener("mousemove", handleMouseMove); 24685 document.addEventListener("mouseup", handleMouseUp); 24686 return () => { 24687 document.removeEventListener("mousemove", handleMouseMove); 24688 document.removeEventListener("mouseup", handleMouseUp); 24689 }; 24690 }, [isCreating, createStart, createPreview, actions, track?.id, state.totalSteps, stepWidth]); 24691 const notesByRow = (0, import_react4.useMemo)(() => { 24692 const map = /* @__PURE__ */ new Map();
24693 track?.notes.forEach((note) => { 24694 if (!map.has(note.pitch)) { 24695 map.set(note.pitch, []); 24696 } 24697 map.get(note.pitch).push(note); 24698 }); 24699 return map; 24700 }, [track?.notes]); 24701 const getMidiRowIndex = (0, import_react4.useCallback)((midi) => { 24702 return ALL_KEYS.findIndex((k) => k.midi === midi); 24703 }, []); 24704 const playheadLeft = KEY_WIDTH + state.currentStep * stepWidth + stepWidth / 2; 24705 return /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.container, ref: outerContainerRef }, state.isPlaying && /* @__PURE__ */ import_react4.default.createElement( 24706 "div", 24707 { 24708 style: { 24709 ...styles3.playhead, 24710 left: `${playheadLeft}px`, 24711 height: `${ALL_KEYS.length * ROW_HEIGHT}px` 24712 } 24713 } 24714 ), /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.keysContainer }, ALL_KEYS.map((key) => { 24715 const isSelected = state.selectedPitch === key.midi; 24716 return /* @__PURE__ */ import_react4.default.createElement( 24717 "div", 24718 { 24719 key: key.midi, 24720 style: { 24721 ...styles3.key, 24722 ...key.isBlack ? styles3.blackKey : styles3.whiteKey, 24723 background: isSelected ? "rgba(16, 185, 129, 0.3)" : key.isBlack ? "rgba(0,0,0,0.4)" : "rgba(255,255,255,0.08)", 24724 borderLeft: isSelected ? "3px solid var(--accent-color, #10b981)" : "3px solid transparent" 24725 }, 24726 onClick: () => { 24727 actions.setSelectedPitch(key.midi); 24728 if (audioEngine && track) { 24729 audioEngine.triggerNote(track.id, key.midi, "16n", "+0", 0.8); 24730 } 24731 } 24732 }, 24733 key.label 24734 ); 24735 })), /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.gridContainer, ref: gridContainerRef }, ALL_KEYS.map((key) => { 24736 const isSelected = state.selectedPitch === key.midi; 24737 return /* @__PURE__ */ import_react4.default.createElement( 24738 "div", 24739 { 24740 key: key.midi, 24741 style: { 24742 ...styles3.gridRow, 24743 background: isSelected ? "rgba(16, 185, 129, 0.08)" : key.isBlack ? "rgba(0,0,0,0.2)" : "transparent" 24744 } 24745 }, 24746 Array.from({ length: state.totalSteps }).map((_, step) => { 24747 const isBarLine = (step + 1) % 4 === 0; 24748 return /* @__PURE__ */ import_react4.default.createElement( 24749 "div", 24750 { 24751 key: step, 24752 style: { 24753 width: `${stepWidth}px`, 24754 height: "100%", 24755 borderRight: isBarLine ? "1px solid rgba(255,255,255,0.15)" : "1px solid rgba(255,255,255,0.05)", 24756 cursor: "pointer", 24757 transition: "background 0.1s", 24758 background: state.currentStep === step ? "rgba(255,255,255,0.05)" : "transparent" 24759 }, 24760 onMouseDown: (e) => handleGridMouseDown(e, step, key.midi) 24761 } 24762 ); 24763 }) 24764 ); 24765 }), track?.notes.map((note) => { 24766 const rowIndex = getMidiRowIndex(note.pitch); 24767 if (rowIndex === -1) return null; 24768 const duration = note.duration || 1; 24769 const isResizing = resizingNote?.noteId === note.id; 24770 const isHovered = hoveredNoteId === note.id; 24771 return /* @__PURE__ */ import_react4.default.createElement( 24772 "div", 24773 { 24774 key: note.id, 24775 style: { 24776 ...styles3.note, 24777 ...isHovered ? styles3.noteHover : {}, 24778 ...isResizing ? styles3.noteResizing : {}, 24779 top: `${rowIndex * ROW_HEIGHT + 2}px`, 24780 left: `${note.step * stepWidth + 1}px`, 24781 width: `${duration * stepWidth - 2}px`, 24782 zIndex: isResizing ? 20 : 5 24783 }, 24784 onMouseEnter: () => setHoveredNoteId(note.id), 24785 onMouseLeave: () => setHoveredNoteId(null), 24786 onClick: (e) => { 24787 e.stopPropagation(); 24788 actions.removeNote(track.id, note.id); 24789 } 24790 },
24791 /* @__PURE__ */ import_react4.default.createElement( 24792 "div", 24793 { 24794 style: { 24795 ...styles3.resizeHandle, 24796 ...isHovered || isResizing ? styles3.resizeHandleVisible : {} 24797 }, 24798 onMouseDown: (e) => handleResizeStart(e, note), 24799 onClick: (e) => e.stopPropagation() 24800 } 24801 ) 24802 ); 24803 }), createPreview && /* @__PURE__ */ import_react4.default.createElement( 24804 "div", 24805 { 24806 style: { 24807 ...styles3.note, 24808 top: `${getMidiRowIndex(createPreview.midi) * ROW_HEIGHT + 2}px`, 24809 left: `${createPreview.step * stepWidth + 1}px`, 24810 width: `${createPreview.duration * stepWidth - 2}px`, 24811 opacity: 0.6, 24812 zIndex: 15, 24813 pointerEvents: "none" 24814 } 24815 } 24816 ))); 24817} 24818function AudioWaveform({ track }) { 24819 const { state } = useDAW(); 24820 const canvasRef = import_react4.default.useRef(null); 24821 const containerRef = (0, import_react4.useRef)(null); 24822 const [stepWidth, setStepWidth] = (0, import_react4.useState)(DEFAULT_STEP_WIDTH); 24823 (0, import_react4.useEffect)(() => { 24824 const container = containerRef.current; 24825 if (!container) return; 24826 const calculateStepWidth = () => { 24827 const containerWidth = container.clientWidth - KEY_WIDTH; 24828 const baseWidth = containerWidth * TARGET_FILL_RATIO / BASE_STEP_COUNT; 24829 const scaledWidth = baseWidth * (BASE_STEP_COUNT / Math.max(state.totalSteps, BASE_STEP_COUNT)); 24830 const newWidth = Math.min(MAX_STEP_WIDTH, Math.max(MIN_STEP_WIDTH, scaledWidth)); 24831 setStepWidth(newWidth); 24832 }; 24833 calculateStepWidth(); 24834 const resizeObserver = new ResizeObserver(calculateStepWidth); 24835 resizeObserver.observe(container); 24836 return () => resizeObserver.disconnect(); 24837 }, [state.totalSteps]); 24838 import_react4.default.useEffect(() => { 24839 if (!track.audioData?.buffer || !canvasRef.current) return; 24840 const canvas = canvasRef.current; 24841 const ctx = canvas.getContext("2d"); 24842 const buffer = track.audioData.buffer; 24843 const data = buffer.getChannelData(0); 24844 canvas.width = state.totalSteps * stepWidth; 24845 canvas.height = 200; 24846 ctx.fillStyle = "rgba(0,0,0,0.3)"; 24847 ctx.fillRect(0, 0, canvas.width, canvas.height); 24848 ctx.strokeStyle = "var(--accent-color, #10b981)"; 24849 ctx.lineWidth = 1; 24850 ctx.beginPath(); 24851 const step = Math.ceil(data.length / canvas.width); 24852 const amp = canvas.height / 2; 24853 for (let i = 0; i < canvas.width; i++) { 24854 const idx = Math.floor(i * step); 24855 const val = data[idx] || 0; 24856 const y = amp + val * amp * 0.8; 24857 if (i === 0) { 24858 ctx.moveTo(i, y); 24859 } else { 24860 ctx.lineTo(i, y); 24861 } 24862 } 24863 ctx.stroke(); 24864 }, [track.audioData?.buffer, state.totalSteps, stepWidth]); 24865 const playheadLeft = KEY_WIDTH + state.currentStep * stepWidth + stepWidth / 2; 24866 return /* @__PURE__ */ import_react4.default.createElement("div", { style: { ...styles3.container, height: "200px" }, ref: containerRef }, state.isPlaying && /* @__PURE__ */ import_react4.default.createElement( 24867 "div", 24868 { 24869 style: { 24870 ...styles3.playhead, 24871 left: `${playheadLeft}px`, 24872 height: "200px" 24873 } 24874 } 24875 ), /* @__PURE__ */ import_react4.default.createElement("div", { style: { ...styles3.keysContainer, display: "flex", alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ import_react4.default.createElement("span", { style: { fontSize: "0.8rem", color: "rgba(255,255,255,0.6)", textAlign: "center" } }
24875, "Audio Track")), /* @__PURE__ */ import_react4.default.createElement("div", { style: styles3.gridContainer }, /* @__PURE__ */ import_react4.default.createElement("canvas", { ref: canvasRef, style: { width: "100%", height: "100%" } }))); 24876} 24877function PianoRoll({ track, audioEngine }) { 24878 if (!track) return null; 24879 if (track.type === "drums") { 24880 return /* @__PURE__ */ import_react4.default.createElement(DrumGrid, { track, audioEngine }); 24881 } 24882 if (track.type === "audio") { 24883 return /* @__PURE__ */ import_react4.default.createElement(AudioWaveform, { track }); 24884 } 24885 return /* @__PURE__ */ import_react4.default.createElement(SynthGrid, { track, audioEngine }); 24886} 24887
24888// app/javascript/components/daw/components/PatternHelpers.jsx 24889var import_react5 = __toESM(require_react()); 24890var styles4 = { 24891 container: { 24892 display: "flex", 24893 flexDirection: "column", 24894 gap: "0.5rem", 24895 minWidth: "200px" 24896 }, 24897 title: { 24898 fontSize: "0.75rem", 24899 color: "rgba(255,255,255,0.5)", 24900 textTransform: "uppercase", 24901 letterSpacing: "0.05em", 24902 marginBottom: "0.25rem" 24903 }, 24904 buttonGroup: { 24905 display: "flex", 24906 flexWrap: "wrap", 24907 gap: "0.25rem" 24908 }, 24909 button: { 24910 padding: "0.375rem 0.625rem", 24911 fontSize: "0.7rem", 24912 background: "rgba(255,255,255,0.06)", 24913 border: "1px solid rgba(255,255,255,0.1)", 24914 borderRadius: "0.25rem", 24915 color: "rgba(255,255,255,0.8)", 24916 cursor: "pointer", 24917 transition: "all 0.2s" 24918 }, 24919 dangerButton: { 24920 background: "rgba(239, 68, 68, 0.1)", 24921 borderColor: "rgba(239, 68, 68, 0.2)" 24922 }, 24923 successButton: { 24924 background: "rgba(16, 185, 129, 0.1)", 24925 borderColor: "rgba(16, 185, 129, 0.2)" 24926 } 24927}; 24928var NOTE_NAMES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]; 24929var DRUM_NAMES = ["Kick", "Snare", "Hi-Hat", "Clap", "Tom", "Crash", "Ride", "Cowbell"]; 24930function getPitchLabel(pitch, trackType) { 24931 if (trackType === "drums") { 24932 return DRUM_NAMES[pitch] || `Drum ${pitch}`; 24933 } 24934 const note = NOTE_NAMES[pitch % 12]; 24935 const octave = Math.floor(pitch / 12) - 1; 24936 return `${note}${octave}`; 24937} 24938function PatternHelpers({ track }) { 24939 const { state, actions } = useDAW(); 24940 if (!track) return null; 24941 const selectedPitch = state.selectedPitch; 24942 const hasSelection = selectedPitch !== null; 24943 const handleFill = (fillType) => { 24944 if (!hasSelection) return; 24945 actions.fillPattern(track.id, fillType, selectedPitch); 24946 }; 24947 const selectionLabel = hasSelection ? getPitchLabel(selectedPitch, track.type) : "Click a row to select"; 24948 return /* @__PURE__ */ import_react5.default.createElement("div", { style: styles4.container }, /* @__PURE__ */ import_react5.default.createElement("span", { style: styles4.title }, "Pattern"), /* @__PURE__ */ import_react5.default.createElement("div", { style: { 24949 fontSize: "0.7rem", 24950 color: hasSelection ? "var(--accent-color, #10b981)" : "rgba(255,255,255,0.4)", 24951 marginBottom: "0.25rem", 24952 fontStyle: hasSelection ? "normal" : "italic" 24953 } }, hasSelection ? `Selected: ${selectionLabel}` : selectionLabel), /* @__PURE__ */ import_react5.default.createElement("div", { style: styles4.buttonGroup }, /* @__PURE__ */ import_react5.default.createElement( 24954 "button", 24955 { 24956 style: { 24957 ...styles4.button, 24958 opacity: hasSelection ? 1 : 0.5, 24959 cursor: hasSelection ? "pointer" : "not-allowed" 24960 }, 24961 onClick: () => handleFill("every"), 24962 disabled: !hasSelection, 24963 onMouseOver: (e) => hasSelection && (e.currentTarget.style.background = "rgba(255,255,255,0.1)"), 24964 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 24965 }, 24966 "Fill 1/1" 24967 ), /* @__PURE__ */ import_react5.default.createElement( 24968 "button", 24969 { 24970 style: { 24971 ...styles4.button, 24972 opacity: hasSelection ? 1 : 0.5, 24973 cursor: hasSelection ? "pointer" : "not-allowed" 24974 }, 24975 onClick: () => handleFill("every2"), 24976 disabled: !hasSelection, 24977 onMouseOver: (e) => hasSelection && (e.currentTarget.style.background = "rgba(255,255,255,0.1)"), 24978 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 24979 }, 24980 "Fill 1/2" 24981 ), /* @__PURE__ */ import_react5.default.createElement( 24982 "button", 24983 { 24984 style: { 24985 ...styles4.button, 24986 opacity: hasSelection ? 1 : 0.5, 24987 cursor: hasSelection ? "pointer" : "not-allowed" 24988 }, 24989 onClick: () => handleFill("every4"), 24990 disabled: !hasSelection, 24991 onMouseOver: (e) => hasSelection && (e.currentTarget.style.background = "rgba(255,255,255,0.1)"), 24992 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 24993 }, 24994 "Fill 1/4"
24995 )), /* @__PURE__ */ import_react5.default.createElement("div", { style: styles4.buttonGroup }, /* @__PURE__ */ import_react5.default.createElement( 24996 "button", 24997 { 24998 style: { ...styles4.button, ...styles4.successButton }, 24999 onClick: () => actions.duplicatePattern(track.id), 25000 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.2)", 25001 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.1)" 25002 }, 25003 "Duplicate" 25004 ), /* @__PURE__ */ import_react5.default.createElement( 25005 "button", 25006 { 25007 style: { ...styles4.button, ...styles4.dangerButton }, 25008 onClick: () => actions.clearPattern(track.id), 25009 onMouseOver: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.2)", 25010 onMouseOut: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.1)" 25011 }, 25012 "Clear" 25013 ))); 25014} 25015
25016// app/javascript/components/daw/components/InstrumentPanel.jsx 25017var import_react6 = __toESM(require_react()); 25018var styles5 = { 25019 container: { 25020 display: "flex", 25021 flexDirection: "column", 25022 gap: "0.35rem" 25023 }, 25024 section: { 25025 background: "rgba(255,255,255,0.03)", 25026 borderRadius: "0.375rem", 25027 border: "1px solid rgba(255,255,255,0.08)", 25028 overflow: "hidden" 25029 }, 25030 sectionHeader: { 25031 display: "flex", 25032 alignItems: "center", 25033 justifyContent: "space-between", 25034 padding: "0.5rem", 25035 cursor: "pointer", 25036 background: "rgba(255,255,255,0.02)", 25037 borderBottom: "1px solid rgba(255,255,255,0.05)", 25038 transition: "background 0.15s" 25039 }, 25040 sectionTitle: { 25041 fontSize: "0.7rem", 25042 color: "rgba(255,255,255,0.7)", 25043 textTransform: "uppercase", 25044 letterSpacing: "0.05em", 25045 fontWeight: 600 25046 }, 25047 chevron: { 25048 fontSize: "0.6rem", 25049 color: "rgba(255,255,255,0.4)", 25050 transition: "transform 0.2s" 25051 }, 25052 sectionContent: { 25053 padding: "0.4rem" 25054 }, 25055 row: { 25056 display: "flex", 25057 gap: "0.35rem", 25058 alignItems: "center", 25059 marginBottom: "0.35rem" 25060 }, 25061 label: { 25062 fontSize: "0.6rem", 25063 color: "rgba(255,255,255,0.5)", 25064 width: "50px", 25065 flexShrink: 0 25066 }, 25067 select: { 25068 flex: 1, 25069 minWidth: 0, 25070 padding: "0.25rem 0.35rem", 25071 background: "rgba(255,255,255,0.05)", 25072 border: "1px solid rgba(255,255,255,0.1)", 25073 borderRadius: "0.25rem", 25074 color: "white", 25075 fontSize: "0.6rem" 25076 }, 25077 knobContainer: { 25078 display: "grid", 25079 gridTemplateColumns: "repeat(4, 1fr)", 25080 gap: "0.35rem" 25081 }, 25082 knob: { 25083 display: "flex", 25084 flexDirection: "column", 25085 alignItems: "center", 25086 gap: "0.1rem" 25087 }, 25088 knobDial: { 25089 width: "32px", 25090 height: "32px", 25091 borderRadius: "50%", 25092 background: "linear-gradient(145deg, rgba(255,255,255,0.08), rgba(0,0,0,0.2))", 25093 border: "1px solid rgba(255,255,255,0.1)", 25094 position: "relative", 25095 cursor: "pointer" 25096 }, 25097 knobIndicator: { 25098 position: "absolute", 25099 width: "2px", 25100 height: "10px", 25101 background: "var(--accent-color, #10b981)", 25102 left: "50%", 25103 top: "3px", 25104 transformOrigin: "bottom center", 25105 borderRadius: "1px" 25106 }, 25107 knobLabel: { 25108 fontSize: "0.55rem", 25109 color: "rgba(255,255,255,0.5)" 25110 }, 25111 knobValue: { 25112 fontSize: "0.5rem", 25113 color: "rgba(255,255,255,0.4)", 25114 fontFamily: "monospace" 25115 }, 25116 slider: { 25117 flex: 1, 25118 height: "4px" 25119 }, 25120 drumPads: { 25121 display: "grid", 25122 gridTemplateColumns: "repeat(4, 1fr)", 25123 gap: "0.4rem" 25124 }, 25125 drumPad: { 25126 aspectRatio: "1", 25127 display: "flex", 25128 alignItems: "center", 25129 justifyContent: "center", 25130 background: "rgba(255,255,255,0.06)", 25131 border: "1px solid rgba(255,255,255,0.1)", 25132 borderRadius: "0.375rem", 25133 color: "rgba(255,255,255,0.7)", 25134 fontSize: "0.6rem", 25135 cursor: "pointer", 25136 transition: "all 0.1s" 25137 }, 25138 toggle: { 25139 width: "32px", 25140 height: "18px", 25141 borderRadius: "9px", 25142 background: "rgba(255,255,255,0.1)", 25143 border: "1px solid rgba(255,255,255,0.2)", 25144 cursor: "pointer", 25145 position: "relative", 25146 transition: "all 0.2s", 25147 flexShrink: 0 25148 }, 25149 toggleActive: { 25150 background: "rgba(139, 92, 246, 0.6)", 25151 borderColor: "rgba(139, 92, 246, 0.8)" 25152 }, 25153 toggleKnob: { 25154 width: "14px", 25155 height: "14px", 25156 borderRadius: "50%", 25157 background: "white", 25158 position: "absolute", 25159 top: "1px", 25160 left: "1px", 25161 transition: "transform 0.2s" 25162 }, 25163 toggleKnobActive: { 25164 transform: "translateX(14px)" 25165 }, 25166 lfoSection: { 25167 background: "rgba(139, 92, 246, 0.08)", 25168 borderRadius: "0.375rem", 25169 padding: "0.5rem", 25170 marginTop: "0.5rem", 25171 border: "1px solid rgba(139, 92, 246, 0.2)" 25172 } 25173}; 25174var OSCILLATOR_TYPES = [ 25175 { value: "sine", label: "Sine" }, 25176 { value: "sawtooth", label: "Saw" }, 25177 { value: "square", label: "Square" }, 25178 { value: "triangle", label: "Tri" }, 25179 { value: "fatsawtooth", label: "Fat Saw" }, 25180 { value: "fatsquare", label: "Fat Sq" }, 25181 { value: "pulse", label: "Pulse" }, 25182 { value: "pwm", label: "PWM" } 25183]; 25184var LFO_RATES = [ 25185 { value: "1m", label: "1 Bar" }, 25186 { value: "2n", label: "1/2" }, 25187 { value: "4n", label: "1/4" }, 25188 { value: "8n", label: "1/8" }, 25189 { value: "16n", label: "1/16" }, 25190 { value: "32n", label: "1/32" } 25191]; 25192var LFO_WAVEFORMS = [ 25193 { value: "sine", label: "Sine" }, 25194 { value: "square", label: "Square" }, 25195 { value: "sawtooth", label: "Saw" }, 25196 { value: "triangle", label: "Tri" } 25197]; 25198var SYNTH_PRESETS = { 25199 init: { name: "Init", oscillator: "sawtooth", attack: 0.01, decay: 0.1, sustain: 0.5, release: 0.3, filterFreq: 2e3, filterRes: 1 }, 25200 bass: { name: "Bass", oscillator: "square", attack: 5e-3, decay: 0.2, sustain: 0.8, release: 0.1, filterFreq: 400, filterRes: 4 }, 25201 lead: { name: "Lead", oscillator: "sawtooth", attack: 0.01, decay: 0.1, sustain: 0.7, release: 0.2, filterFreq: 4e3, filterRes: 2 }, 25202 pad: { name: "Pad", oscillator: "triangle", attack: 0.5, decay: 0.3, sustain: 0.8, release: 1.5, filterFreq: 3e3, filterRes: 0.5 },
25203 pluck: { name: "Pluck", oscillator: "triangle", attack: 1e-3, decay: 0.3, sustain: 0, release: 0.2, filterFreq: 5e3, filterRes: 3 }, 25204 acid: { name: "Acid", oscillator: "sawtooth", attack: 1e-3, decay: 0.15, sustain: 0.2, release: 0.1, filterFreq: 800, filterRes: 15 } 25205}; 25206function CollapsibleSection({ title, children, defaultOpen = true, color }) { 25207 const [isOpen, setIsOpen] = (0, import_react6.useState)(defaultOpen); 25208 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.section }, /* @__PURE__ */ import_react6.default.createElement( 25209 "div", 25210 { 25211 style: styles5.sectionHeader, 25212 onClick: () => setIsOpen(!isOpen), 25213 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.05)", 25214 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.02)" 25215 }, 25216 /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.sectionTitle, color: color || "rgba(255,255,255,0.7)" } }, title), 25217 /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.chevron, transform: isOpen ? "rotate(0deg)" : "rotate(-90deg)" } }, "\u25BC") 25218 ), isOpen && /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.sectionContent }, children)); 25219} 25220function Knob({ label, value, min, max, step, onChange }) { 25221 const rotation = (value - min) / (max - min) * 270 - 135; 25222 const handleMouseDown = (e) => { 25223 const startY = e.clientY; 25224 const startValue = value; 25225 const handleMouseMove = (moveEvent) => { 25226 const delta = startY - moveEvent.clientY; 25227 const range2 = max - min; 25228 const newValue = Math.max(min, Math.min(max, startValue + delta / 100 * range2)); 25229 onChange(step < 1 ? newValue : Math.round(newValue / step) * step); 25230 }; 25231 const handleMouseUp = () => { 25232 document.removeEventListener("mousemove", handleMouseMove); 25233 document.removeEventListener("mouseup", handleMouseUp); 25234 }; 25235 document.addEventListener("mousemove", handleMouseMove); 25236 document.addEventListener("mouseup", handleMouseUp); 25237 }; 25238 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knob }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobDial, onMouseDown: handleMouseDown }, /* @__PURE__ */ import_react6.default.createElement("div", { style: { ...styles5.knobIndicator, transform: `translateX(-50%) rotate(${rotation}deg)` } })), /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.knobLabel }, label), /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.knobValue }, value.toFixed(step < 1 ? 2 : 0))); 25239} 25240function SynthEditor({ track, audioEngine }) { 25241 const { actions } = useDAW(); 25242 const lfo = track.instrument.lfo || { enabled: false, rate: "8n", waveform: "sine", depth: 0.5 }; 25243 const updateInstrument = (0, import_react6.useCallback)((key, value) => { 25244 const newInstrument = { ...track.instrument, [key]: value }; 25245 actions.updateTrack(track.id, { instrument: newInstrument }); 25246 if (audioEngine) { 25247 try { 25248 audioEngine.updateSynthSettings(track.id, { [key]: value }); 25249 } catch (err) { 25250 console.warn("[InstrumentPanel] Error updating synth:", err); 25251 } 25252 } 25253 }, [track, actions, audioEngine]); 25254 const updateLFO = (0, import_react6.useCallback)((lfoKey, lfoValue) => { 25255 const newLFO = { ...lfo, [lfoKey]: lfoValue }; 25256 const newInstrument = { ...track.instrument, lfo: newLFO }; 25257 actions.updateTrack(track.id, { instrument: newInstrument }); 25258 if (audioEngine) { 25259 try { 25260 audioEngine.updateSynthSettings(track.id, { lfo: newLFO }); 25261 } catch (err) { 25262 console.warn("[InstrumentPanel] Error updating LFO:", err); 25263 } 25264 } 25265 }, [track, lfo, actions, audioEngine]); 25266 const loadPreset = (0, import_react6.useCallback)((presetKey) => { 25267 const preset = SYNTH_PRESETS[presetKey]; 25268 if (!preset) return; 25269 const newInstrument = { ...preset, lfo: track.instrument.lfo }; 25270 actions.updateTrack(track.id, { instrument: newInstrument }); 25271 if (audioEngine) {
25272 try { 25273 audioEngine.updateSynthSettings(track.id, newInstrument); 25274 } catch (err) { 25275 console.warn("[InstrumentPanel] Error loading preset:", err); 25276 } 25277 } 25278 }, [track, actions, audioEngine]); 25279 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Synthesizer", defaultOpen: true, color: "#10b981" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Preset"), /* @__PURE__ */ import_react6.default.createElement("select", { onChange: (e) => loadPreset(e.target.value), style: styles5.select, defaultValue: "" }, /* @__PURE__ */ import_react6.default.createElement("option", { value: "", disabled: true }, "Load..."), Object.entries(SYNTH_PRESETS).map(([key, preset]) => /* @__PURE__ */ import_react6.default.createElement("option", { key, value: key }, preset.name)))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Wave"), /* @__PURE__ */ import_react6.default.createElement( 25280 "select", 25281 { 25282 value: track.instrument.oscillator, 25283 onChange: (e) => updateInstrument("oscillator", e.target.value), 25284 style: styles5.select 25285 }, 25286 OSCILLATOR_TYPES.map((type) => /* @__PURE__ */ import_react6.default.createElement("option", { key: type.value, value: type.value }, type.label)) 25287 ))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Envelope", defaultOpen: false, color: "#3b82f6" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobContainer }, /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Atk", value: track.instrument.attack, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("attack", v) }
25287), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Dec", value: track.instrument.decay, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("decay", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Sus", value: track.instrument.sustain, min: 0, max: 1, step: 0.01, onChange: (v) => updateInstrument("sustain", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Rel", value: track.instrument.release, min: 1e-3, max: 4, step: 0.01, onChange: (v) => updateInstrument("release", v) }))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Filter + LFO", defaultOpen: true, color: "#8b5cf6" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Cutoff"), /* @__PURE__ */ import_react6.default.createElement( 25288 "input", 25289 { 25290 type: "range", 25291 min: "100", 25292 max: "10000", 25293 step: "100", 25294 value: track.instrument.filterFreq, 25295 onChange: (e) => updateInstrument("filterFreq", parseInt(e.target.value)), 25296 style: styles5.slider 25297 } 25298 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "45px", textAlign: "right" } }, track.instrument.filterFreq, "Hz")), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Reso"), /* @__PURE__ */ import_react6.default.createElement( 25299 "input", 25300 { 25301 type: "range", 25302 min: "0", 25303 max: "20", 25304 step: "0.1", 25305 value: track.instrument.filterRes, 25306 onChange: (e) => updateInstrument("filterRes", parseFloat(e.target.value)), 25307 style: styles5.slider 25308 } 25309 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "45px", textAlign: "right" } }, track.instrument.filterRes.toFixed(1))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.lfoSection }, /* @__PURE__ */ import_react6.default.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "0.5rem" } }, /* @__PURE__ */ import_react6.default.createElement("span", { style: { fontSize: "0.65rem", color: "rgba(139, 92, 246, 0.9)", fontWeight: 600 } }, "LFO WOBBLE"), /* @__PURE__ */ import_react6.default.createElement( 25310 "div", 25311 { 25312 style: { ...styles5.toggle, ...lfo.enabled ? styles5.toggleActive : {} }, 25313 onClick: () => updateLFO("enabled", !lfo.enabled) 25314 }, 25315 /* @__PURE__ */ import_react6.default.createElement("div", { style: { ...styles5.toggleKnob, ...lfo.enabled ? styles5.toggleKnobActive : {} } })
25316 )), lfo.enabled && /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Rate"), /* @__PURE__ */ import_react6.default.createElement("select", { value: lfo.rate, onChange: (e) => updateLFO("rate", e.target.value), style: styles5.select }, LFO_RATES.map((rate) => /* @__PURE__ */ import_react6.default.createElement("option", { key: rate.value, value: rate.value }, rate.label)))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Shape"), /* @__PURE__ */ import_react6.default.createElement("select", { value: lfo.waveform, onChange: (e) => updateLFO("waveform", e.target.value), style: styles5.select }, LFO_WAVEFORMS.map((wf) => /* @__PURE__ */ import_react6.default.createElement("option", { key: wf.value, value: wf.value }, wf.label)))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Depth"), /* @__PURE__ */ import_react6.default.createElement( 25317 "input", 25318 { 25319 type: "range", 25320 min: "0", 25321 max: "1", 25322 step: "0.01", 25323 value: lfo.depth, 25324 onChange: (e) => updateLFO("depth", parseFloat(e.target.value)), 25325 style: styles5.slider 25326 } 25327 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, Math.round(lfo.depth * 100), "%")))))); 25328} 25329function DrumEditor({ track, audioEngine }) { 25330 const DRUMS = [ 25331 { name: "Kick", type: "kick", color: "#ef4444" }, 25332 { name: "Snare", type: "snare", color: "#f59e0b" }, 25333 { name: "HiHat", type: "hihat", color: "#10b981" }, 25334 { name: "Clap", type: "clap", color: "#3b82f6" }, 25335 { name: "Tom", type: "tom", color: "#8b5cf6" }, 25336 { name: "Crash", type: "crash", color: "#ec4899" }, 25337 { name: "Ride", type: "ride", color: "#06b6d4" }, 25338 { name: "Bell", type: "cowbell", color: "#f97316" } 25339 ]; 25340 const playDrum = (drumType) => { 25341 if (audioEngine) { 25342 try { 25343 audioEngine.triggerDrum(track.id, drumType, "+0", 1); 25344 } catch (err) { 25345 console.warn("[InstrumentPanel] Error playing drum:", err); 25346 } 25347 } 25348 }; 25349 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Drum Machine", defaultOpen: true, color: "#f59e0b" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.drumPads }, DRUMS.map((drum, idx) => /* @__PURE__ */ import_react6.default.createElement( 25350 "button", 25351 { 25352 key: idx, 25353 style: { ...styles5.drumPad, borderColor: drum.color }, 25354 onClick: () => playDrum(drum.type), 25355 onMouseDown: (e) => { 25356 e.currentTarget.style.background = `${drum.color}40`; 25357 e.currentTarget.style.transform = "scale(0.95)"; 25358 }, 25359 onMouseUp: (e) => { 25360 e.currentTarget.style.background = "rgba(255,255,255,0.06)"; 25361 e.currentTarget.style.transform = "scale(1)"; 25362 }, 25363 onMouseLeave: (e) => { 25364 e.currentTarget.style.background = "rgba(255,255,255,0.06)"; 25365 e.currentTarget.style.transform = "scale(1)"; 25366 } 25367 }, 25368 drum.name 25369 ))))); 25370} 25371function AudioEditor({ track }) { 25372 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Audio Track", defaultOpen: true, color: "#06b6d4" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Duration"), /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.knobValue }, track.audioData?.duration ? `${track.audioData.duration.toFixed(1)}
25372s` : "-")), /* @__PURE__ */ import_react6.default.createElement("p", { style: { fontSize: "0.6rem", color: "rgba(255,255,255,0.4)", margin: 0 } }, "Use mixer to adjust volume/pan"))); 25373} 25374function PluckEditor({ track, audioEngine }) { 25375 const { actions } = useDAW(); 25376 const updateInstrument = (0, import_react6.useCallback)((key, value) => { 25377 const newInstrument = { ...track.instrument, [key]: value }; 25378 actions.updateTrack(track.id, { instrument: newInstrument }); 25379 if (audioEngine) { 25380 try { 25381 audioEngine.updatePluckSettings(track.id, { [key]: value }); 25382 } catch (err) { 25383 console.warn("[InstrumentPanel] Error updating pluck:", err); 25384 } 25385 } 25386 }, [track, actions, audioEngine]); 25387 const playPreview = (0, import_react6.useCallback)(() => { 25388 if (audioEngine) { 25389 try { 25390 audioEngine.triggerNote(track.id, 60, "8n", "+0", 0.8); 25391 } catch (err) { 25392 console.warn("[InstrumentPanel] Error playing preview:", err); 25393 } 25394 } 25395 }, [track.id, audioEngine]); 25396 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Pluck / Guitar", defaultOpen: true, color: "#f59e0b" }, /* @__PURE__ */ import_react6.default.createElement("p", { style: { fontSize: "0.6rem", color: "rgba(255,255,255,0.5)", margin: "0 0 0.5rem 0" } }, "Karplus-Strong string synthesis for guitar-like sounds"), /* @__PURE__ */ import_react6.default.createElement( 25397 "button", 25398 { 25399 onClick: playPreview, 25400 style: { 25401 ...styles5.select, 25402 cursor: "pointer", 25403 textAlign: "center", 25404 marginBottom: "0.5rem", 25405 background: "rgba(245, 158, 11, 0.2)", 25406 borderColor: "rgba(245, 158, 11, 0.4)" 25407 } 25408 }, 25409 "Preview Sound" 25410 ), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Attack"), /* @__PURE__ */ import_react6.default.createElement( 25411 "input", 25412 { 25413 type: "range", 25414 min: "0.1", 25415 max: "10", 25416 step: "0.1", 25417 value: track.instrument.attackNoise, 25418 onChange: (e) => updateInstrument("attackNoise", parseFloat(e.target.value)), 25419 style: styles5.slider 25420 } 25421 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, track.instrument.attackNoise.toFixed(1))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Dampen"), /* @__PURE__ */ import_react6.default.createElement( 25422 "input", 25423 { 25424 type: "range", 25425 min: "500", 25426 max: "10000", 25427 step: "100", 25428 value: track.instrument.dampening, 25429 onChange: (e) => updateInstrument("dampening", parseInt(e.target.value)), 25430 style: styles5.slider 25431 } 25432 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "45px", textAlign: "right" } }, track.instrument.dampening, "Hz")), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Resonance"), /* @__PURE__ */ import_react6.default.createElement( 25433 "input", 25434 { 25435 type: "range", 25436 min: "0", 25437 max: "1", 25438 step: "0.01", 25439 value: track.instrument.resonance, 25440 onChange: (e) => updateInstrument("resonance", parseFloat(e.target.value)), 25441 style: styles5.slider 25442 } 25443 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }
25443, Math.round(track.instrument.resonance * 100), "%")), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Release"), /* @__PURE__ */ import_react6.default.createElement( 25444 "input", 25445 { 25446 type: "range", 25447 min: "0.1", 25448 max: "4", 25449 step: "0.1", 25450 value: track.instrument.release, 25451 onChange: (e) => updateInstrument("release", parseFloat(e.target.value)), 25452 style: styles5.slider 25453 } 25454 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, track.instrument.release.toFixed(1), "s")))); 25455} 25456function FMEditor({ track, audioEngine }) { 25457 const { actions } = useDAW(); 25458 const updateInstrument = (0, import_react6.useCallback)((key, value) => { 25459 const newInstrument = { ...track.instrument, [key]: value }; 25460 actions.updateTrack(track.id, { instrument: newInstrument }); 25461 if (audioEngine) { 25462 try { 25463 audioEngine.updateFMSettings(track.id, { [key]: value }); 25464 } catch (err) { 25465 console.warn("[InstrumentPanel] Error updating FM:", err); 25466 } 25467 } 25468 }, [track, actions, audioEngine]); 25469 const playPreview = (0, import_react6.useCallback)(() => { 25470 if (audioEngine) { 25471 try { 25472 audioEngine.triggerNote(track.id, 60, "4n", "+0", 0.8); 25473 } catch (err) { 25474 console.warn("[InstrumentPanel] Error playing preview:", err); 25475 } 25476 } 25477 }, [track.id, audioEngine]); 25478 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "FM Synthesis", defaultOpen: true, color: "#8b5cf6" }, /* @__PURE__ */ import_react6.default.createElement("p", { style: { fontSize: "0.6rem", color: "rgba(255,255,255,0.5)", margin: "0 0 0.5rem 0" } }, "Frequency modulation for rich, evolving timbres"), /* @__PURE__ */ import_react6.default.createElement( 25479 "button", 25480 { 25481 onClick: playPreview, 25482 style: { 25483 ...styles5.select, 25484 cursor: "pointer", 25485 textAlign: "center", 25486 marginBottom: "0.5rem", 25487 background: "rgba(139, 92, 246, 0.2)", 25488 borderColor: "rgba(139, 92, 246, 0.4)" 25489 } 25490 }, 25491 "Preview Sound" 25492 ), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Harmonic"), /* @__PURE__ */ import_react6.default.createElement( 25493 "input", 25494 { 25495 type: "range", 25496 min: "0.5", 25497 max: "10", 25498 step: "0.1", 25499 value: track.instrument.harmonicity, 25500 onChange: (e) => updateInstrument("harmonicity", parseFloat(e.target.value)), 25501 style: styles5.slider 25502 } 25503 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, track.instrument.harmonicity.toFixed(1))), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Mod Idx"), /* @__PURE__ */ import_react6.default.createElement( 25504 "input", 25505 { 25506 type: "range", 25507 min: "0", 25508 max: "50", 25509 step: "1", 25510 value: track.instrument.modulationIndex, 25511 onChange: (e) => updateInstrument("modulationIndex", parseInt(e.target.value)), 25512 style: styles5.slider 25513 } 25514 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, track.instrument.modulationIndex))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Carrier Envelope", defaultOpen: false, color: "#3b82f6" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobContainer }, /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Atk", value: track.instrument.attack, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("attack", v) }
25514), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Dec", value: track.instrument.decay, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("decay", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Sus", value: track.instrument.sustain, min: 0, max: 1, step: 0.01, onChange: (v) => updateInstrument("sustain", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Rel", value: track.instrument.release, min: 1e-3, max: 4, step: 0.01, onChange: (v) => updateInstrument("release", v) }))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Modulator Envelope", defaultOpen: false, color: "#ec4899" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobContainer }, /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Atk", value: track.instrument.modulationAttack, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("modulationAttack", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Dec", value: track.instrument.modulationDecay, min: 0, max: 2, step: 0.01, onChange: (v) => updateInstrument("modulationDecay", v) }
25514), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Sus", value: track.instrument.modulationSustain, min: 0, max: 1, step: 0.01, onChange: (v) => updateInstrument("modulationSustain", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Rel", value: track.instrument.modulationRelease, min: 1e-3, max: 4, step: 0.01, onChange: (v) => updateInstrument("modulationRelease", v) })))); 25515} 25516function AMEditor({ track, audioEngine }) { 25517 const { actions } = useDAW(); 25518 const updateInstrument = (0, import_react6.useCallback)((key, value) => { 25519 const newInstrument = { ...track.instrument, [key]: value }; 25520 actions.updateTrack(track.id, { instrument: newInstrument }); 25521 if (audioEngine) { 25522 try { 25523 audioEngine.updateAMSettings(track.id, { [key]: value }); 25524 } catch (err) { 25525 console.warn("[InstrumentPanel] Error updating AM:", err); 25526 } 25527 } 25528 }, [track, actions, audioEngine]); 25529 const playPreview = (0, import_react6.useCallback)(() => { 25530 if (audioEngine) { 25531 try { 25532 audioEngine.triggerNote(track.id, 60, "4n", "+0", 0.8); 25533 } catch (err) { 25534 console.warn("[InstrumentPanel] Error playing preview:", err); 25535 } 25536 } 25537 }, [track.id, audioEngine]); 25538 return /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.container }, /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "AM Synthesis", defaultOpen: true, color: "#06b6d4" }, /* @__PURE__ */ import_react6.default.createElement("p", { style: { fontSize: "0.6rem", color: "rgba(255,255,255,0.5)", margin: "0 0 0.5rem 0" } }, "Amplitude modulation for tremolo-like effects"), /* @__PURE__ */ import_react6.default.createElement( 25539 "button", 25540 { 25541 onClick: playPreview, 25542 style: { 25543 ...styles5.select, 25544 cursor: "pointer", 25545 textAlign: "center", 25546 marginBottom: "0.5rem", 25547 background: "rgba(6, 182, 212, 0.2)", 25548 borderColor: "rgba(6, 182, 212, 0.4)" 25549 } 25550 }, 25551 "Preview Sound" 25552 ), /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.row }, /* @__PURE__ */ import_react6.default.createElement("span", { style: styles5.label }, "Harmonic"), /* @__PURE__ */ import_react6.default.createElement( 25553 "input", 25554 { 25555 type: "range", 25556 min: "0.5", 25557 max: "10", 25558 step: "0.1", 25559 value: track.instrument.harmonicity, 25560 onChange: (e) => updateInstrument("harmonicity", parseFloat(e.target.value)), 25561 style: styles5.slider 25562 } 25563 ), /* @__PURE__ */ import_react6.default.createElement("span", { style: { ...styles5.knobValue, width: "35px", textAlign: "right" } }, track.instrument.harmonicity.toFixed(1)))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Carrier Envelope", defaultOpen: false, color: "#3b82f6" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobContainer }, /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Atk", value: track.instrument.attack, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("attack", v) }
25563), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Dec", value: track.instrument.decay, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("decay", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Sus", value: track.instrument.sustain, min: 0, max: 1, step: 0.01, onChange: (v) => updateInstrument("sustain", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Rel", value: track.instrument.release, min: 1e-3, max: 4, step: 0.01, onChange: (v) => updateInstrument("release", v) }))), /* @__PURE__ */ import_react6.default.createElement(CollapsibleSection, { title: "Modulator Envelope", defaultOpen: false, color: "#ec4899" }, /* @__PURE__ */ import_react6.default.createElement("div", { style: styles5.knobContainer }, /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Atk", value: track.instrument.modulationAttack, min: 1e-3, max: 2, step: 0.01, onChange: (v) => updateInstrument("modulationAttack", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Dec", value: track.instrument.modulationDecay, min: 0, max: 2, step: 0.01, onChange: (v) => updateInstrument("modulationDecay", v) }
25563), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Sus", value: track.instrument.modulationSustain, min: 0, max: 1, step: 0.01, onChange: (v) => updateInstrument("modulationSustain", v) }), /* @__PURE__ */ import_react6.default.createElement(Knob, { label: "Rel", value: track.instrument.modulationRelease, min: 1e-3, max: 4, step: 0.01, onChange: (v) => updateInstrument("modulationRelease", v) })))); 25564} 25565function InstrumentPanel({ track, audioEngine }) { 25566 if (!track) return null; 25567 if (track.type === "drums") { 25568 return /* @__PURE__ */ import_react6.default.createElement(DrumEditor, { track, audioEngine }); 25569 } 25570 if (track.type === "audio") { 25571 return /* @__PURE__ */ import_react6.default.createElement(AudioEditor, { track }); 25572 } 25573 if (track.type === "pluck") { 25574 return /* @__PURE__ */ import_react6.default.createElement(PluckEditor, { track, audioEngine }); 25575 } 25576 if (track.type === "fm") { 25577 return /* @__PURE__ */ import_react6.default.createElement(FMEditor, { track, audioEngine }); 25578 } 25579 if (track.type === "am") { 25580 return /* @__PURE__ */ import_react6.default.createElement(AMEditor, { track, audioEngine }); 25581 } 25582 return /* @__PURE__ */ import_react6.default.createElement(SynthEditor, { track, audioEngine }); 25583} 25584
25585// app/javascript/components/daw/components/EffectsPanel.jsx 25586var import_react7 = __toESM(require_react()); 25587var styles6 = { 25588 container: { 25589 display: "flex", 25590 flexDirection: "column", 25591 gap: "0.5rem", 25592 marginTop: "0.75rem" 25593 }, 25594 section: { 25595 background: "rgba(255,255,255,0.03)", 25596 borderRadius: "0.375rem", 25597 border: "1px solid rgba(255,255,255,0.08)", 25598 overflow: "hidden" 25599 }, 25600 sectionHeader: { 25601 display: "flex", 25602 alignItems: "center", 25603 justifyContent: "space-between", 25604 padding: "0.5rem", 25605 cursor: "pointer", 25606 background: "rgba(255,255,255,0.02)", 25607 borderBottom: "1px solid rgba(255,255,255,0.05)", 25608 transition: "background 0.15s" 25609 }, 25610 sectionTitle: { 25611 fontSize: "0.7rem", 25612 color: "rgba(255,255,255,0.7)", 25613 textTransform: "uppercase", 25614 letterSpacing: "0.05em", 25615 fontWeight: 600, 25616 display: "flex", 25617 alignItems: "center", 25618 gap: "0.5rem" 25619 }, 25620 chevron: { 25621 fontSize: "0.6rem", 25622 color: "rgba(255,255,255,0.4)", 25623 transition: "transform 0.2s" 25624 }, 25625 sectionContent: { 25626 padding: "0.35rem" 25627 }, 25628 effectsGrid: { 25629 display: "grid", 25630 gridTemplateColumns: "1fr 1fr", 25631 gap: "0.25rem" 25632 }, 25633 effectCard: { 25634 background: "rgba(0,0,0,0.2)", 25635 borderRadius: "0.25rem", 25636 padding: "0.3rem", 25637 border: "1px solid rgba(255,255,255,0.05)", 25638 minWidth: 0, 25639 overflow: "hidden" 25640 }, 25641 effectHeader: { 25642 display: "flex", 25643 alignItems: "center", 25644 justifyContent: "space-between", 25645 marginBottom: "0.25rem" 25646 }, 25647 effectTitle: { 25648 fontSize: "0.55rem", 25649 fontWeight: 600, 25650 color: "rgba(255,255,255,0.7)", 25651 textTransform: "uppercase" 25652 }, 25653 toggleButton: { 25654 padding: "0.1rem 0.3rem", 25655 fontSize: "0.5rem", 25656 fontWeight: 600, 25657 borderRadius: "0.2rem", 25658 border: "none", 25659 cursor: "pointer", 25660 transition: "all 0.15s" 25661 }, 25662 toggleButtonOff: { 25663 background: "rgba(255,255,255,0.1)", 25664 color: "rgba(255,255,255,0.4)" 25665 }, 25666 toggleButtonOn: { 25667 background: "rgba(16, 185, 129, 0.4)", 25668 color: "#10b981" 25669 }, 25670 row: { 25671 display: "flex", 25672 gap: "0.15rem", 25673 alignItems: "center", 25674 marginBottom: "0.15rem" 25675 }, 25676 label: { 25677 fontSize: "0.5rem", 25678 color: "rgba(255,255,255,0.5)", 25679 width: "26px", 25680 flexShrink: 0 25681 }, 25682 slider: { 25683 flex: 1, 25684 minWidth: 0, 25685 height: "3px", 25686 appearance: "none", 25687 background: "rgba(255,255,255,0.1)", 25688 borderRadius: "2px", 25689 cursor: "pointer" 25690 }, 25691 select: { 25692 flex: 1, 25693 minWidth: 0, 25694 padding: "0.1rem 0.15rem", 25695 background: "rgba(255,255,255,0.05)", 25696 border: "1px solid rgba(255,255,255,0.1)", 25697 borderRadius: "0.2rem", 25698 color: "white", 25699 fontSize: "0.5rem", 25700 cursor: "pointer" 25701 }, 25702 valueDisplay: { 25703 fontSize: "0.45rem", 25704 color: "rgba(255,255,255,0.4)", 25705 fontFamily: "monospace", 25706 width: "22px", 25707 textAlign: "right", 25708 flexShrink: 0 25709 }, 25710 disabled: { 25711 opacity: 0.4, 25712 pointerEvents: "none" 25713 } 25714}; 25715var DELAY_TIMES = [ 25716 { value: "2n", label: "1/2" }, 25717 { value: "4n", label: "1/4" }, 25718 { value: "8n", label: "1/8" }, 25719 { value: "16n", label: "1/16" } 25720]; 25721var DISTORTION_TYPES = [ 25722 { value: "softclip", label: "Soft" }, 25723 { value: "hardclip", label: "Hard" }, 25724 { value: "bitcrusher", label: "Crush" } 25725]; 25726var COMPRESSOR_RATIOS = [ 25727 { value: 2, label: "2:1" }, 25728 { value: 4, label: "4:1" }, 25729 { value: 8, label: "8:1" }, 25730 { value: 12, label: "12:1" }, 25731 { value: 20, label: "20:1" } 25732]; 25733function CollapsibleSection2({ title, children, defaultOpen = true, color, enabledCount = 0 }) { 25734 const [isOpen, setIsOpen] = (0, import_react7.useState)(defaultOpen); 25735 return /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.section }, /* @__PURE__ */ import_react7.default.createElement( 25736 "div", 25737 { 25738 style: styles6.sectionHeader, 25739 onClick: () => setIsOpen(!isOpen), 25740 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.05)", 25741 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.02)" 25742 }, 25743 /* @__PURE__ */ import_react7.default.createElement("span", { style: { ...styles6.sectionTitle, color: color || "rgba(255,255,255,0.7)" } }, title, enabledCount >
25743 0 && /* @__PURE__ */ import_react7.default.createElement("span", { style: { 25744 background: "rgba(16, 185, 129, 0.3)", 25745 color: "#10b981", 25746 padding: "0.1rem 0.3rem", 25747 borderRadius: "0.25rem", 25748 fontSize: "0.5rem" 25749 } }, enabledCount, " ON")), 25750 /* @__PURE__ */ import_react7.default.createElement("span", { style: { ...styles6.chevron, transform: isOpen ? "rotate(0deg)" : "rotate(-90deg)" } }, "\u25BC") 25751 ), isOpen && /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.sectionContent }, children)); 25752} 25753function EffectControl({ label, value, min, max, step, onChange, disabled }) { 25754 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.row, ...disabled ? styles6.disabled : {} } }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.label }, label), /* @__PURE__ */ import_react7.default.createElement( 25755 "input", 25756 { 25757 type: "range", 25758 min, 25759 max, 25760 step, 25761 value, 25762 onChange: (e) => onChange(parseFloat(e.target.value)), 25763 style: styles6.slider, 25764 disabled 25765 } 25766 ), /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.valueDisplay }, typeof value === "number" ? value.toFixed(step < 1 ? 2 : 0) : value)); 25767} 25768function ReverbCard({ track, audioEngine, onUpdate }) { 25769 const effects = track.effects?.reverb || {}; 25770 const enabled = effects.enabled || false; 25771 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25772 onUpdate("reverb", { [key]: value }); 25773 if (audioEngine) { 25774 audioEngine.updateEffects(track.id, { reverb: { [key]: value } }); 25775 } 25776 }, [track.id, audioEngine, onUpdate]); 25777 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Reverb"), /* @__PURE__ */ import_react7.default.createElement( 25778 "button", 25779 { 25780 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25781 onClick: () => handleUpdate("enabled", !enabled) 25782 }, 25783 enabled ? "ON" : "OFF"
25784 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Size", value: effects.roomSize || 0.5, min: 0.1, max: 1, step: 0.05, onChange: (v) => handleUpdate("roomSize", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Mix", value: effects.wet || 0.3, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("wet", v), disabled: !enabled }))); 25785} 25786function DelayCard({ track, audioEngine, onUpdate }) { 25787 const effects = track.effects?.delay || {}; 25788 const enabled = effects.enabled || false; 25789 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25790 onUpdate("delay", { [key]: value }); 25791 if (audioEngine) { 25792 audioEngine.updateEffects(track.id, { delay: { [key]: value } }); 25793 } 25794 }, [track.id, audioEngine, onUpdate]); 25795 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Delay"), /* @__PURE__ */ import_react7.default.createElement( 25796 "button", 25797 { 25798 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25799 onClick: () => handleUpdate("enabled", !enabled) 25800 }, 25801 enabled ? "ON" : "OFF"
25802 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.row }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.label }, "Time"), /* @__PURE__ */ import_react7.default.createElement("select", { style: styles6.select, value: effects.time || "8n", onChange: (e) => handleUpdate("time", e.target.value), disabled: !enabled }, DELAY_TIMES.map((t) => /* @__PURE__ */ import_react7.default.createElement("option", { key: t.value, value: t.value }, t.label)))), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Fdbk", value: effects.feedback || 0.3, min: 0, max: 0.9, step: 0.05, onChange: (v) => handleUpdate("feedback", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Mix", value: effects.wet || 0.3, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("wet", v), disabled: !enabled }))); 25803} 25804function DistortionCard({ track, audioEngine, onUpdate }) { 25805 const effects = track.effects?.distortion || {}; 25806 const enabled = effects.enabled || false; 25807 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25808 onUpdate("distortion", { [key]: value }); 25809 if (audioEngine) { 25810 audioEngine.updateEffects(track.id, { distortion: { [key]: value } }); 25811 } 25812 }, [track.id, audioEngine, onUpdate]); 25813 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Distort"), /* @__PURE__ */ import_react7.default.createElement( 25814 "button", 25815 { 25816 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25817 onClick: () => handleUpdate("enabled", !enabled) 25818 }, 25819 enabled ? "ON" : "OFF"
25820 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.row }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.label }, "Type"), /* @__PURE__ */ import_react7.default.createElement("select", { style: styles6.select, value: effects.type || "softclip", onChange: (e) => handleUpdate("type", e.target.value), disabled: !enabled }, DISTORTION_TYPES.map((t) => /* @__PURE__ */ import_react7.default.createElement("option", { key: t.value, value: t.value }, t.label)))), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Amt", value: effects.amount || 0.4, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("amount", v), disabled: !enabled }))); 25821} 25822function ChorusCard({ track, audioEngine, onUpdate }) { 25823 const effects = track.effects?.chorus || {}; 25824 const enabled = effects.enabled || false; 25825 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25826 onUpdate("chorus", { [key]: value }); 25827 if (audioEngine) { 25828 audioEngine.updateEffects(track.id, { chorus: { [key]: value } }); 25829 } 25830 }, [track.id, audioEngine, onUpdate]); 25831 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Chorus"), /* @__PURE__ */ import_react7.default.createElement( 25832 "button", 25833 { 25834 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25835 onClick: () => handleUpdate("enabled", !enabled) 25836 }, 25837 enabled ? "ON" : "OFF"
25838 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Rate", value: effects.frequency || 1.5, min: 0.1, max: 10, step: 0.1, onChange: (v) => handleUpdate("frequency", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Depth", value: effects.depth || 0.7, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("depth", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Mix", value: effects.wet || 0.3, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("wet", v), disabled: !enabled }))); 25839} 25840function PhaserCard({ track, audioEngine, onUpdate }) { 25841 const effects = track.effects?.phaser || {}; 25842 const enabled = effects.enabled || false; 25843 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25844 onUpdate("phaser", { [key]: value }); 25845 if (audioEngine) { 25846 audioEngine.updateEffects(track.id, { phaser: { [key]: value } }); 25847 } 25848 }, [track.id, audioEngine, onUpdate]); 25849 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Phaser"), /* @__PURE__ */ import_react7.default.createElement( 25850 "button", 25851 { 25852 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25853 onClick: () => handleUpdate("enabled", !enabled) 25854 }, 25855 enabled ? "ON" : "OFF"
25856 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Rate", value: effects.frequency || 0.5, min: 0.1, max: 8, step: 0.1, onChange: (v) => handleUpdate("frequency", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Oct", value: effects.octaves || 3, min: 1, max: 6, step: 1, onChange: (v) => handleUpdate("octaves", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Mix", value: effects.wet || 0.5, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("wet", v), disabled: !enabled }))); 25857} 25858function TremoloCard({ track, audioEngine, onUpdate }) { 25859 const effects = track.effects?.tremolo || {}; 25860 const enabled = effects.enabled || false; 25861 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25862 onUpdate("tremolo", { [key]: value }); 25863 if (audioEngine) { 25864 audioEngine.updateEffects(track.id, { tremolo: { [key]: value } }); 25865 } 25866 }, [track.id, audioEngine, onUpdate]); 25867 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Tremolo"), /* @__PURE__ */ import_react7.default.createElement( 25868 "button", 25869 { 25870 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25871 onClick: () => handleUpdate("enabled", !enabled) 25872 }, 25873 enabled ? "ON" : "OFF"
25874 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Rate", value: effects.frequency || 4, min: 0.5, max: 20, step: 0.5, onChange: (v) => handleUpdate("frequency", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Depth", value: effects.depth || 0.5, min: 0, max: 1, step: 0.05, onChange: (v) => handleUpdate("depth", v), disabled: !enabled }))); 25875} 25876function EQ3Card({ track, audioEngine, onUpdate }) { 25877 const effects = track.effects?.eq3 || {}; 25878 const enabled = effects.enabled || false; 25879 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25880 onUpdate("eq3", { [key]: value }); 25881 if (audioEngine) { 25882 audioEngine.updateEffects(track.id, { eq3: { [key]: value } }); 25883 } 25884 }, [track.id, audioEngine, onUpdate]); 25885 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "EQ3"), /* @__PURE__ */ import_react7.default.createElement( 25886 "button", 25887 { 25888 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25889 onClick: () => handleUpdate("enabled", !enabled) 25890 }, 25891 enabled ? "ON" : "OFF"
25892 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Low", value: effects.low || 0, min: -12, max: 12, step: 1, onChange: (v) => handleUpdate("low", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Mid", value: effects.mid || 0, min: -12, max: 12, step: 1, onChange: (v) => handleUpdate("mid", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "High", value: effects.high || 0, min: -12, max: 12, step: 1, onChange: (v) => handleUpdate("high", v), disabled: !enabled }))); 25893} 25894function CompressorCard({ track, audioEngine, onUpdate }) { 25895 const effects = track.effects?.compressor || {}; 25896 const enabled = effects.enabled || false; 25897 const handleUpdate = (0, import_react7.useCallback)((key, value) => { 25898 onUpdate("compressor", { [key]: value }); 25899 if (audioEngine) { 25900 audioEngine.updateEffects(track.id, { compressor: { [key]: value } }); 25901 } 25902 }, [track.id, audioEngine, onUpdate]); 25903 return /* @__PURE__ */ import_react7.default.createElement("div", { style: { ...styles6.effectCard, borderColor: enabled ? "rgba(16, 185, 129, 0.3)" : "rgba(255,255,255,0.05)" } }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectHeader }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.effectTitle }, "Comp"), /* @__PURE__ */ import_react7.default.createElement( 25904 "button", 25905 { 25906 style: { ...styles6.toggleButton, ...enabled ? styles6.toggleButtonOn : styles6.toggleButtonOff }, 25907 onClick: () => handleUpdate("enabled", !enabled) 25908 }, 25909 enabled ? "ON" : "OFF"
25910 )), /* @__PURE__ */ import_react7.default.createElement("div", { style: enabled ? {} : styles6.disabled }, /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Thrs", value: effects.threshold || -24, min: -60, max: 0, step: 1, onChange: (v) => handleUpdate("threshold", v), disabled: !enabled }), /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.row }, /* @__PURE__ */ import_react7.default.createElement("span", { style: styles6.label }, "Ratio"), /* @__PURE__ */ import_react7.default.createElement("select", { style: styles6.select, value: effects.ratio || 4, onChange: (e) => handleUpdate("ratio", parseFloat(e.target.value)), disabled: !enabled }, COMPRESSOR_RATIOS.map((r) => /* @__PURE__ */ import_react7.default.createElement("option", { key: r.value, value: r.value }, r.label)))), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Atk", value: (effects.attack || 3e-3) * 1e3, min: 0, max: 100, step: 1, onChange: (v) => handleUpdate("attack", v / 1e3), disabled: !enabled }
25910), /* @__PURE__ */ import_react7.default.createElement(EffectControl, { label: "Rel", value: (effects.release || 0.25) * 1e3, min: 10, max: 1e3, step: 10, onChange: (v) => handleUpdate("release", v / 1e3), disabled: !enabled }))); 25911} 25912function EffectsPanel({ track, audioEngine }) { 25913 const { actions } = useDAW(); 25914 const handleUpdateEffect = (0, import_react7.useCallback)((effectType, settings) => { 25915 if (!track) return; 25916 actions.updateTrackEffects(track.id, effectType, settings); 25917 }, [track, actions]); 25918 if (!track || !track.effects) { 25919 return null; 25920 } 25921 const enabledCount = [ 25922 track.effects.eq3?.enabled, 25923 track.effects.compressor?.enabled, 25924 track.effects.distortion?.enabled, 25925 track.effects.phaser?.enabled, 25926 track.effects.tremolo?.enabled, 25927 track.effects.chorus?.enabled, 25928 track.effects.delay?.enabled, 25929 track.effects.reverb?.enabled 25930 ].filter(Boolean).length; 25931 return /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.container }, /* @__PURE__ */ import_react7.default.createElement(CollapsibleSection2, { title: "Effects", defaultOpen: false, color: "#ec4899", enabledCount }, /* @__PURE__ */ import_react7.default.createElement("div", { style: styles6.effectsGrid }, /* @__PURE__ */ import_react7.default.createElement(EQ3Card, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(CompressorCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(DistortionCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(PhaserCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(TremoloCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(ChorusCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(DelayCard, { track, audioEngine, onUpdate: handleUpdateEffect }), /* @__PURE__ */ import_react7.default.createElement(ReverbCard, { track, audioEngine, onUpdate: handleUpdateEffect })))); 25932} 25933
25934// app/javascript/components/daw/components/MixerPanel.jsx 25935var import_react8 = __toESM(require_react()); 25936var styles7 = { 25937 container: { 25938 display: "flex", 25939 flexDirection: "column", 25940 gap: "0.5rem", 25941 flex: 1 25942 }, 25943 title: { 25944 fontSize: "0.75rem", 25945 color: "rgba(255,255,255,0.5)", 25946 textTransform: "uppercase", 25947 letterSpacing: "0.05em" 25948 }, 25949 channelStrips: { 25950 display: "flex", 25951 gap: "0.5rem", 25952 overflowX: "auto", 25953 paddingBottom: "0.25rem" 25954 }, 25955 channel: { 25956 display: "flex", 25957 flexDirection: "column", 25958 alignItems: "center", 25959 gap: "0.25rem", 25960 padding: "0.5rem", 25961 background: "rgba(255,255,255,0.03)", 25962 borderRadius: "0.25rem", 25963 minWidth: "50px" 25964 }, 25965 channelName: { 25966 fontSize: "0.6rem", 25967 color: "rgba(255,255,255,0.6)", 25968 textAlign: "center", 25969 overflow: "hidden", 25970 textOverflow: "ellipsis", 25971 whiteSpace: "nowrap", 25972 width: "100%" 25973 }, 25974 faderMeterContainer: { 25975 display: "flex", 25976 gap: "3px", 25977 alignItems: "stretch", 25978 height: "60px" 25979 }, 25980 fader: { 25981 width: "8px", 25982 height: "60px", 25983 appearance: "none", 25984 background: "rgba(255,255,255,0.1)", 25985 borderRadius: "4px", 25986 writingMode: "vertical-lr", 25987 direction: "rtl" 25988 }, 25989 volumeValue: { 25990 fontSize: "0.55rem", 25991 color: "rgba(255,255,255,0.4)", 25992 fontFamily: "monospace" 25993 }, 25994 panKnob: { 25995 width: "24px", 25996 height: "24px", 25997 borderRadius: "50%", 25998 background: "linear-gradient(145deg, rgba(255,255,255,0.08), rgba(0,0,0,0.2))", 25999 border: "1px solid rgba(255,255,255,0.1)", 26000 position: "relative", 26001 cursor: "pointer" 26002 }, 26003 panIndicator: { 26004 position: "absolute", 26005 width: "2px", 26006 height: "8px", 26007 background: "var(--accent-color, #10b981)", 26008 left: "50%", 26009 top: "2px", 26010 transformOrigin: "bottom center", 26011 borderRadius: "1px" 26012 }, 26013 panLabel: { 26014 fontSize: "0.5rem", 26015 color: "rgba(255,255,255,0.4)", 26016 fontFamily: "monospace" 26017 }, 26018 meterContainer: { 26019 width: "6px", 26020 height: "60px", 26021 background: "rgba(0,0,0,0.4)", 26022 borderRadius: "3px", 26023 overflow: "hidden", 26024 position: "relative" 26025 }, 26026 meterFill: { 26027 position: "absolute", 26028 bottom: 0, 26029 left: 0, 26030 right: 0, 26031 borderRadius: "3px", 26032 transition: "height 0.05s ease-out" 26033 }, 26034 meterSegments: { 26035 position: "absolute", 26036 top: 0, 26037 left: 0, 26038 right: 0, 26039 bottom: 0, 26040 display: "flex", 26041 flexDirection: "column", 26042 gap: "1px", 26043 padding: "1px", 26044 pointerEvents: "none" 26045 } 26046}; 26047function LevelMeter({ trackId, audioEngine }) { 26048 const [level, setLevel] = (0, import_react8.useState)(0); 26049 const animationRef = (0, import_react8.useRef)(null); 26050 const updateLevel = (0, import_react8.useCallback)(() => { 26051 if (audioEngine) { 26052 const dbLevel = audioEngine.getTrackLevel(trackId); 26053 const normalizedLevel = Math.max(0, Math.min(1, (dbLevel + 60) / 60)); 26054 setLevel(normalizedLevel); 26055 } 26056 animationRef.current = requestAnimationFrame(updateLevel); 26057 }, [audioEngine, trackId]); 26058 (0, import_react8.useEffect)(() => { 26059 animationRef.current = requestAnimationFrame(updateLevel); 26060 return () => { 26061 if (animationRef.current) { 26062 cancelAnimationFrame(animationRef.current); 26063 } 26064 }; 26065 }, [updateLevel]); 26066 const getGradient = () => { 26067 if (level > 0.9) { 26068 return "linear-gradient(to top, #10b981 0%, #fbbf24 70%, #ef4444 90%)"; 26069 } else if (level > 0.6) { 26070 return "linear-gradient(to top, #10b981 0%, #fbbf24 100%)"; 26071 } 26072 return "linear-gradient(to top, #059669, #10b981)"; 26073 }; 26074 return /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.meterContainer }, /* @__PURE__ */ import_react8.default.createElement( 26075 "div", 26076 { 26077 style: { 26078 ...styles7.meterFill, 26079 height: `${level * 100}%`, 26080 background: getGradient(), 26081 boxShadow: level > 0.1 ? "0 0 4px rgba(16, 185, 129, 0.5)" : "none" 26082 } 26083 } 26084 )); 26085} 26086function MasterMeter({ audioEngine }) { 26087 const [level, setLevel] = (0, import_react8.useState)(0); 26088 const animationRef = (0, import_react8.useRef)(null); 26089 const updateLevel = (0, import_react8.useCallback)(() => { 26090 if (audioEngine) { 26091 const dbLevel = audioEngine.getMasterLevel(); 26092 const normalizedLevel = Math.max(0, Math.min(1, (dbLevel + 60) / 60)); 26093 setLevel(normalizedLevel); 26094 } 26095 animationRef.current = requestAnimationFrame(updateLevel); 26096 }, [audioEngine]); 26097 (0, import_react8.useEffect)(() => { 26098 animationRef.current = requestAnimationFrame(updateLevel); 26099 return () => { 26100 if (animationRef.current) { 26101 cancelAnimationFrame(animationRef.current); 26102 } 26103 }; 26104 }, [updateLevel]); 26105 const getGradient = () => { 26106 if (level > 0.9) { 26107 return "linear-gradient(to top, #10b981 0%, #fbbf24 70%, #ef4444 90%)"; 26108 } else if (level > 0.6) { 26109 return "linear-gradient(to top, #10b981 0%, #fbbf24 100%)"; 26110 } 26111 return "linear-gradient(to top, #059669, #10b981)"; 26112 }; 26113 return /* @__PURE__ */ import_react8.default.createElement("div", { style: { ...styles7.channel, minWidth: "40px", background: "rgba(255,255,255,0.05)" } }
26113, /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.channelName }, "MST"), /* @__PURE__ */ import_react8.default.createElement("div", { style: { ...styles7.meterContainer, width: "10px", height: "60px" } }, /* @__PURE__ */ import_react8.default.createElement( 26114 "div", 26115 { 26116 style: { 26117 ...styles7.meterFill, 26118 height: `${level * 100}%`, 26119 background: getGradient(), 26120 boxShadow: level > 0.1 ? "0 0 6px rgba(16, 185, 129, 0.6)" : "none" 26121 } 26122 } 26123 )), /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.volumeValue }, level > 0 ? Math.round(level * 60 - 60) : "-inf")); 26124} 26125function ChannelStrip({ track, audioEngine, onUpdate }) { 26126 const handleVolumeChange = (e) => { 26127 const volume = parseFloat(e.target.value); 26128 onUpdate(track.id, { volume }); 26129 if (audioEngine) { 26130 audioEngine.setTrackVolume(track.id, volume); 26131 } 26132 }; 26133 const handlePanChange = (e) => { 26134 const startX = e.clientX; 26135 const startPan = track.pan; 26136 const handleMouseMove = (moveEvent) => { 26137 const delta = moveEvent.clientX - startX; 26138 const newPan = Math.max(-1, Math.min(1, startPan + delta / 50)); 26139 onUpdate(track.id, { pan: newPan }); 26140 if (audioEngine) { 26141 audioEngine.setTrackPan(track.id, newPan); 26142 } 26143 }; 26144 const handleMouseUp = () => { 26145 document.removeEventListener("mousemove", handleMouseMove); 26146 document.removeEventListener("mouseup", handleMouseUp); 26147 }; 26148 document.addEventListener("mousemove", handleMouseMove); 26149 document.addEventListener("mouseup", handleMouseUp); 26150 }; 26151 const panRotation = track.pan * 90; 26152 const formatPan = (pan) => { 26153 if (Math.abs(pan) < 0.05) return "C"; 26154 return pan < 0 ? `L${Math.round(Math.abs(pan) * 100)}` : `R${Math.round(pan * 100)}`; 26155 }; 26156 return /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.channel }, /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.channelName }, track.name), /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.panKnob, onMouseDown: handlePanChange }, /* @__PURE__ */ import_react8.default.createElement( 26157 "div", 26158 { 26159 style: { 26160 ...styles7.panIndicator, 26161 transform: `translateX(-50%) rotate(${panRotation}deg)` 26162 } 26163 }
26164 )), /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.panLabel }, formatPan(track.pan)), /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.faderMeterContainer }, /* @__PURE__ */ import_react8.default.createElement( 26165 "input", 26166 { 26167 type: "range", 26168 min: "0", 26169 max: "1", 26170 step: "0.01", 26171 value: track.volume, 26172 onChange: handleVolumeChange, 26173 style: styles7.fader 26174 } 26175 ), /* @__PURE__ */ import_react8.default.createElement(LevelMeter, { trackId: track.id, audioEngine })), /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.volumeValue }, Math.round(track.volume * 100))); 26176} 26177function MixerPanel({ audioEngine }) { 26178 const { state, actions } = useDAW(); 26179 return /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.container }, /* @__PURE__ */ import_react8.default.createElement("span", { style: styles7.title }, "Mixer"), /* @__PURE__ */ import_react8.default.createElement("div", { style: styles7.channelStrips }, state.tracks.map((track) => /* @__PURE__ */ import_react8.default.createElement( 26180 ChannelStrip, 26181 { 26182 key: track.id, 26183 track, 26184 audioEngine, 26185 onUpdate: actions.updateTrack 26186 }
26187 )), /* @__PURE__ */ import_react8.default.createElement(MasterMeter, { audioEngine }))); 26188} 26189
26190// app/javascript/components/daw/components/VisualizerPanel.jsx 26191var import_react9 = __toESM(require_react()); 26192function Oscilloscope({ audioEngine, height = 80 }) { 26193 const canvasRef = (0, import_react9.useRef)(null); 26194 const animationRef = (0, import_react9.useRef)(null); 26195 const peakRef = (0, import_react9.useRef)(0.1); 26196 const audioEngineRef = (0, import_react9.useRef)(audioEngine); 26197 (0, import_react9.useEffect)(() => { 26198 audioEngineRef.current = audioEngine; 26199 }, [audioEngine]); 26200 const draw = (0, import_react9.useCallback)(() => { 26201 const canvas = canvasRef.current; 26202 const engine = audioEngineRef.current; 26203 const waveform = engine?.waveformAnalyzer; 26204 if (!canvas || !waveform) { 26205 animationRef.current = requestAnimationFrame(draw); 26206 return; 26207 } 26208 const ctx = canvas.getContext("2d"); 26209 const dpr = window.devicePixelRatio || 1; 26210 const width = canvas.width / dpr; 26211 const canvasHeight = canvas.height / dpr; 26212 const values = waveform.getValue(); 26213 let currentPeak = 0; 26214 for (let i = 0; i < values.length; i++) { 26215 const absVal = Math.abs(values[i]); 26216 if (absVal > currentPeak) currentPeak = absVal; 26217 } 26218 if (currentPeak > peakRef.current) { 26219 peakRef.current = currentPeak; 26220 } else { 26221 peakRef.current = peakRef.current * 0.995 + currentPeak * 5e-3; 26222 } 26223 const displayPeak = Math.max(0.05, peakRef.current); 26224 const scaleFactor = 0.85 / displayPeak; 26225 ctx.fillStyle = "rgba(0, 0, 0, 0.25)"; 26226 ctx.fillRect(0, 0, width, canvasHeight); 26227 ctx.strokeStyle = "rgba(255, 255, 255, 0.05)"; 26228 ctx.lineWidth = 1; 26229 for (let i = 1; i < 4; i++) { 26230 ctx.beginPath(); 26231 ctx.moveTo(0, canvasHeight / 4 * i); 26232 ctx.lineTo(width, canvasHeight / 4 * i); 26233 ctx.stroke(); 26234 } 26235 ctx.strokeStyle = "rgba(255, 255, 255, 0.15)"; 26236 ctx.beginPath(); 26237 ctx.moveTo(0, canvasHeight / 2); 26238 ctx.lineTo(width, canvasHeight / 2); 26239 ctx.stroke(); 26240 const intensity = Math.min(1, currentPeak * 3); 26241 const r = Math.round(16 + intensity * 200); 26242 const g = Math.round(185 - intensity * 50); 26243 const b = Math.round(129 - intensity * 50); 26244 ctx.strokeStyle = `rgb(${r}, ${g}, ${b})`; 26245 ctx.lineWidth = 2; 26246 ctx.beginPath(); 26247 const sliceWidth = width / values.length; 26248 for (let i = 0; i < values.length; i++) { 26249 const x = i * sliceWidth; 26250 const scaledValue = values[i] * scaleFactor; 26251 const clampedValue = Math.max(-1, Math.min(1, scaledValue)); 26252 const y = (clampedValue + 1) / 2 * canvasHeight; 26253 if (i === 0) { 26254 ctx.moveTo(x, y); 26255 } else { 26256 ctx.lineTo(x, y); 26257 } 26258 } 26259 ctx.stroke(); 26260 ctx.shadowColor = `rgb(${r}, ${g}, ${b})`; 26261 ctx.shadowBlur = 10 + intensity * 15; 26262 ctx.stroke(); 26263 ctx.shadowBlur = 0; 26264 animationRef.current = requestAnimationFrame(draw); 26265 }, []); 26266 (0, import_react9.useEffect)(() => { 26267 const canvas = canvasRef.current; 26268 if (!canvas) return; 26269 const rect = canvas.getBoundingClientRect(); 26270 const dpr = window.devicePixelRatio || 1; 26271 canvas.width = rect.width * dpr; 26272 canvas.height = rect.height * dpr; 26273 const ctx = canvas.getContext("2d"); 26274 ctx.scale(dpr, dpr); 26275 canvas.style.width = `${rect.width}px`; 26276 canvas.style.height = `${rect.height}px`; 26277 }, [height]); 26278 (0, import_react9.useEffect)(() => { 26279 animationRef.current = requestAnimationFrame(draw); 26280 return () => { 26281 if (animationRef.current) { 26282 cancelAnimationFrame(animationRef.current); 26283 } 26284 }; 26285 }, [draw]); 26286 return /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26287 flex: 1, 26288 minWidth: "300px", 26289 background: "rgba(0,0,0,0.4)", 26290 borderRadius: "0.5rem", 26291 border: "1px solid rgba(255,255,255,0.08)", 26292 overflow: "hidden" 26293 } }, /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26294 padding: "0.5rem 0.75rem", 26295 fontSize: "0.7rem", 26296 color: "rgba(255,255,255,0.5)", 26297 textTransform: "uppercase", 26298 letterSpacing: "0.05em", 26299 borderBottom: "1px solid rgba(255,255,255,0.05)", 26300 background: "rgba(255,255,255,0.02)" 26301 } }
26301, "Oscilloscope"), /* @__PURE__ */ import_react9.default.createElement( 26302 "canvas", 26303 { 26304 ref: canvasRef, 26305 style: { width: "100%", height: `${height}px`, display: "block" } 26306 } 26307 )); 26308} 26309function generateLogBands(numBands, fftSize, sampleRate = 44100) { 26310 const bands = []; 26311 const minFreq = 20; 26312 const maxFreq = Math.min(2e4, sampleRate / 2); 26313 const logMin = Math.log10(minFreq); 26314 const logMax = Math.log10(maxFreq); 26315 const logStep = (logMax - logMin) / numBands; 26316 const freqPerBin = sampleRate / fftSize; 26317 for (let i = 0; i < numBands; i++) { 26318 const freqStart = Math.pow(10, logMin + logStep * i); 26319 const freqEnd = Math.pow(10, logMin + logStep * (i + 1)); 26320 const centerFreq = Math.sqrt(freqStart * freqEnd); 26321 const startBin = Math.floor(freqStart / freqPerBin); 26322 const endBin = Math.ceil(freqEnd / freqPerBin); 26323 bands.push({ 26324 startBin: Math.max(0, startBin), 26325 endBin: Math.min(fftSize / 2 - 1, endBin), 26326 centerFreq 26327 }); 26328 } 26329 return bands; 26330} 26331function SpectrumAnalyzer({ audioEngine, bands = 32, height = 80 }) { 26332 const canvasRef = (0, import_react9.useRef)(null); 26333 const animationRef = (0, import_react9.useRef)(null); 26334 const peaksRef = (0, import_react9.useRef)(new Array(bands).fill(-100)); 26335 const smoothedRef = (0, import_react9.useRef)(new Array(bands).fill(-100)); 26336 const bandMappingsRef = (0, import_react9.useRef)(null); 26337 const audioEngineRef = (0, import_react9.useRef)(audioEngine); 26338 (0, import_react9.useEffect)(() => { 26339 audioEngineRef.current = audioEngine; 26340 }, [audioEngine]); 26341 const draw = (0, import_react9.useCallback)(() => { 26342 const canvas = canvasRef.current; 26343 const engine = audioEngineRef.current; 26344 const fft = engine?.fftAnalyzer; 26345 if (!canvas || !fft) { 26346 animationRef.current = requestAnimationFrame(draw); 26347 return; 26348 } 26349 const ctx = canvas.getContext("2d"); 26350 const dpr = window.devicePixelRatio || 1; 26351 const width = canvas.width / dpr; 26352 const canvasHeight = canvas.height / dpr; 26353 const values = fft.getValue(); 26354 if (!bandMappingsRef.current || bandMappingsRef.current.length !== bands) { 26355 bandMappingsRef.current = generateLogBands(bands, values.length, 44100); 26356 } 26357 ctx.fillStyle = "rgba(0, 0, 0, 0.35)"; 26358 ctx.fillRect(0, 0, width, canvasHeight); 26359 ctx.strokeStyle = "rgba(255, 255, 255, 0.05)"; 26360 ctx.lineWidth = 1; 26361 for (let i = 1; i < 4; i++) { 26362 ctx.beginPath(); 26363 ctx.moveTo(0, canvasHeight / 4 * i); 26364 ctx.lineTo(width, canvasHeight / 4 * i); 26365 ctx.stroke(); 26366 } 26367 const barWidth = width / bands - 2; 26368 const barGap = 2; 26369 for (let i = 0; i < bands; i++) { 26370 const band = bandMappingsRef.current[i]; 26371 if (!band) continue; 26372 let maxVal = -Infinity; 26373 let sumVal = 0; 26374 let count = 0; 26375 for (let j = band.startBin; j <= band.endBin && j < values.length; j++) { 26376 const val = values[j]; 26377 if (val > maxVal) maxVal = val; 26378 sumVal += val; 26379 count++; 26380 } 26381 const safeMax = maxVal === -Infinity ? -100 : Math.max(-100, maxVal); 26382 const avgVal = count > 0 ? sumVal / count : -100; 26383 const safeAvg = !isFinite(avgVal) ? -100 : Math.max(-100, avgVal); 26384 const bandValue = safeMax * 0.7 + safeAvg * 0.3; 26385 let currentSmoothed = smoothedRef.current[i]; 26386 if (!isFinite(currentSmoothed)) currentSmoothed = -100; 26387 if (bandValue > currentSmoothed) { 26388 smoothedRef.current[i] = currentSmoothed * 0.3 + bandValue * 0.7; 26389 } else { 26390 smoothedRef.current[i] = currentSmoothed * 0.85 + bandValue * 0.15; 26391 } 26392 const dbMin = -80; 26393 const dbMax = 0; 26394 const normalizedValue = smoothedRef.current[i]; 26395 const normalized = Math.max(0, Math.min(1, (normalizedValue - dbMin) / (dbMax - dbMin))); 26396 const displayValue = Math.pow(normalized, 0.8); 26397 const barHeight = displayValue * canvasHeight * 0.95; 26398 if (displayValue > peaksRef.current[i]) { 26399 peaksRef.current[i] = displayValue; 26400 } else { 26401 peaksRef.current[i] = Math.max(0, peaksRef.current[i] - 8e-3); 26402 } 26403 const x = i * (barWidth + barGap) + barGap; 26404 const peakY = canvasHeight - peaksRef.current[i] * canvasHeight * 0.95; 26405 const gradient = ctx.createLinearGradient(x, canvasHeight, x, canvasHeight - barHeight); 26406 const freqRatio = i / bands; 26407 if (displayValue > 0.8) { 26408 gradient.addColorStop(0, `hsl(${120 - freqRatio * 30}, 70%, 45%)`); 26409 gradient.addColorStop(0.5, `hsl(${45 - freqRatio * 15}, 90%, 55%)`); 26410 gradient.addColorStop(1, `hsl(0, 90%, 55%)`); 26411 } else if (displayValue > 0.5) { 26412 gradient.addColorStop(0, `hsl(${130 - freqRatio * 20}, 65%, 40%)`); 26413 gradient.addColorStop(1, `hsl(${50 - freqRatio * 10}, 85%, 55%)`); 26414 } else { 26415 gradient.addColorStop(0, `hsl(${150 - freqRatio * 30}, 60%, 35%)`); 26416 gradient.addColorStop(1, `hsl(${160 - freqRatio * 40}, 70%, 50%)`); 26417 } 26418 ctx.fillStyle = gradient; 26419 ctx.fillRect(x, canvasHeight - barHeight, barWidth, barHeight); 26420 if (peaksRef.current[i] > 0.02) { 26421 ctx.fillStyle = displayValue > 0.8 ? "rgba(239, 68, 68, 0.9)" : `hsla(${160 - freqRatio * 40}, 80%, 60%, 0.8)`; 26422 ctx.fillRect(x, peakY - 2, barWidth, 2); 26423 } 26424 if (displayValue > 0.3) { 26425 ctx.shadowColor = `hsl(${150 - freqRatio * 30}, 70%, 50%)`; 26426 ctx.shadowBlur = 6 + displayValue * 8; 26427 ctx.fillRect(x, canvasHeight - 2, barWidth, 2); 26428 ctx.shadowBlur = 0; 26429 } 26430 } 26431 animationRef.current = requestAnimationFrame(draw); 26432 }, [bands]); 26433 (0, import_react9.useEffect)(() => { 26434 const canvas = canvasRef.current; 26435 if (!canvas) return; 26436 const rect = canvas.getBoundingClientRect(); 26437 const dpr = window.devicePixelRatio || 1; 26438 canvas.width = rect.width * dpr; 26439 canvas.height = rect.height * dpr; 26440 const ctx = canvas.getContext("2d"); 26441 ctx.scale(dpr, dpr); 26442 canvas.style.width = `${rect.width}px`; 26443 canvas.style.height = `${rect.height}px`; 26444 }, [height]); 26445 (0, import_react9.useEffect)(() => { 26446 peaksRef.current = new Array(bands).fill(0); 26447 smoothedRef.current = new Array(bands).fill(-100); 26448 bandMappingsRef.current = null; 26449 animationRef.current = requestAnimationFrame(draw); 26450 return () => { 26451 if (animationRef.current) { 26452 cancelAnimationFrame(animationRef.current); 26453 } 26454 }; 26455 }, [draw, bands]); 26456 return /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26457 flex: 1, 26458 minWidth: "300px", 26459 background: "rgba(0,0,0,0.4)", 26460 borderRadius: "0.5rem", 26461 border: "1px solid rgba(255,255,255,0.08)", 26462 overflow: "hidden" 26463 } }
26463, /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26464 padding: "0.5rem 0.75rem", 26465 fontSize: "0.7rem", 26466 color: "rgba(255,255,255,0.5)", 26467 textTransform: "uppercase", 26468 letterSpacing: "0.05em", 26469 borderBottom: "1px solid rgba(255,255,255,0.05)", 26470 background: "rgba(255,255,255,0.02)" 26471 } }, "Spectrum Analyzer"), /* @__PURE__ */ import_react9.default.createElement( 26472 "canvas", 26473 { 26474 ref: canvasRef, 26475 style: { width: "100%", height: `${height}px`, display: "block" } 26476 } 26477 )); 26478} 26479function VisualizerPanel({ audioEngine, large = false }) { 26480 const visualizerHeight = large ? 150 : 80; 26481 return /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26482 display: "flex", 26483 flexDirection: "column", 26484 gap: "0.75rem", 26485 width: "100%" 26486 } }, /* @__PURE__ */ import_react9.default.createElement("div", { style: { 26487 display: "flex", 26488 gap: "0.75rem", 26489 flexWrap: "wrap" 26490 } }, /* @__PURE__ */ import_react9.default.createElement(Oscilloscope, { audioEngine, height: visualizerHeight }), /* @__PURE__ */ import_react9.default.createElement(SpectrumAnalyzer, { audioEngine, bands: 48, height: visualizerHeight }))); 26491} 26492
26493// app/javascript/components/daw/components/ProjectPanel.jsx 26494var import_react12 = __toESM(require_react()); 26495
26496// app/javascript/components/daw/components/PatternLibrary.jsx 26497var import_react10 = __toESM(require_react()); 26498var styles8 = { 26499 overlay: { 26500 position: "fixed", 26501 top: 0, 26502 left: 0, 26503 right: 0, 26504 bottom: 0, 26505 background: "rgba(0,0,0,0.85)", 26506 display: "flex", 26507 alignItems: "center", 26508 justifyContent: "center", 26509 zIndex: 1e3 26510 }, 26511 modal: { 26512 background: "linear-gradient(180deg, rgba(20,20,25,1) 0%, rgba(12,12,16,1) 100%)", 26513 borderRadius: "0.5rem", 26514 border: "1px solid rgba(255,255,255,0.08)", 26515 width: "90%", 26516 maxWidth: "720px", 26517 maxHeight: "80vh", 26518 overflow: "hidden", 26519 display: "flex", 26520 flexDirection: "column", 26521 boxShadow: "0 25px 50px -12px rgba(0,0,0,0.5)" 26522 }, 26523 header: { 26524 padding: "0.75rem 1rem", 26525 borderBottom: "1px solid rgba(255,255,255,0.06)", 26526 display: "flex", 26527 justifyContent: "space-between", 26528 alignItems: "center", 26529 background: "rgba(255,255,255,0.02)" 26530 }, 26531 title: { 26532 fontSize: "0.75rem", 26533 fontWeight: 600, 26534 color: "rgba(255,255,255,0.7)", 26535 textTransform: "uppercase", 26536 letterSpacing: "0.05em" 26537 }, 26538 closeButton: { 26539 background: "rgba(255,255,255,0.06)", 26540 border: "1px solid rgba(255,255,255,0.1)", 26541 borderRadius: "0.25rem", 26542 color: "rgba(255,255,255,0.5)", 26543 fontSize: "1rem", 26544 cursor: "pointer", 26545 padding: "0.25rem 0.5rem", 26546 lineHeight: 1, 26547 transition: "all 0.15s" 26548 }, 26549 tabs: { 26550 display: "flex", 26551 borderBottom: "1px solid rgba(255,255,255,0.06)", 26552 background: "rgba(0,0,0,0.2)" 26553 }, 26554 tab: { 26555 flex: 1, 26556 padding: "0.625rem 1rem", 26557 background: "none", 26558 border: "none", 26559 borderBottom: "2px solid transparent", 26560 color: "rgba(255,255,255,0.4)", 26561 cursor: "pointer", 26562 fontSize: "0.7rem", 26563 fontWeight: 500, 26564 textTransform: "uppercase", 26565 letterSpacing: "0.03em", 26566 transition: "all 0.15s" 26567 }, 26568 activeTab: { 26569 color: "#10b981", 26570 borderBottomColor: "#10b981", 26571 background: "rgba(16, 185, 129, 0.05)" 26572 }, 26573 content: { 26574 flex: 1, 26575 overflow: "auto", 26576 padding: "1rem" 26577 }, 26578 grid: { 26579 display: "grid", 26580 gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))", 26581 gap: "0.5rem" 26582 }, 26583 card: { 26584 background: "rgba(255,255,255,0.03)", 26585 border: "1px solid rgba(255,255,255,0.06)", 26586 borderRadius: "0.375rem", 26587 padding: "0.75rem", 26588 cursor: "pointer", 26589 transition: "all 0.15s" 26590 }, 26591 cardHover: { 26592 background: "rgba(16, 185, 129, 0.08)", 26593 borderColor: "rgba(16, 185, 129, 0.25)" 26594 }, 26595 cardName: { 26596 fontWeight: 600, 26597 color: "white", 26598 marginBottom: "0.375rem", 26599 fontSize: "0.8rem" 26600 }, 26601 cardDescription: { 26602 fontSize: "0.65rem", 26603 color: "rgba(255,255,255,0.4)", 26604 marginBottom: "0.5rem", 26605 lineHeight: 1.4, 26606 display: "-webkit-box", 26607 WebkitLineClamp: 2, 26608 WebkitBoxOrient: "vertical", 26609 overflow: "hidden" 26610 }, 26611 cardMeta: { 26612 display: "flex", 26613 gap: "0.5rem", 26614 fontSize: "0.6rem", 26615 color: "rgba(255,255,255,0.35)", 26616 marginBottom: "0.5rem" 26617 }, 26618 tags: { 26619 display: "flex", 26620 flexWrap: "wrap", 26621 gap: "0.25rem" 26622 }, 26623 tag: { 26624 background: "rgba(255,255,255,0.08)", 26625 color: "rgba(255,255,255,0.5)", 26626 padding: "0.125rem 0.375rem", 26627 borderRadius: "0.2rem", 26628 fontSize: "0.55rem", 26629 textTransform: "uppercase", 26630 letterSpacing: "0.02em" 26631 }, 26632 templateBadge: { 26633 background: "rgba(16, 185, 129, 0.2)", 26634 color: "#34d399" 26635 }, 26636 cardActions: { 26637 display: "flex", 26638 gap: "0.25rem", 26639 marginTop: "0.5rem" 26640 }, 26641 actionButton: { 26642 flex: 1, 26643 padding: "0.3rem 0.4rem", 26644 fontSize: "0.6rem", 26645 fontWeight: 600, 26646 borderRadius: "0.25rem", 26647 border: "1px solid transparent", 26648 cursor: "pointer", 26649 transition: "all 0.15s", 26650 textTransform: "uppercase", 26651 letterSpacing: "0.02em" 26652 }, 26653 loadButton: { 26654 background: "rgba(16, 185, 129, 0.15)", 26655 borderColor: "rgba(16, 185, 129, 0.25)", 26656 color: "#10b981" 26657 }, 26658 mergeButton: { 26659 background: "rgba(255,255,255,0.06)", 26660 borderColor: "rgba(255,255,255,0.1)", 26661 color: "rgba(255,255,255,0.6)" 26662 }, 26663 deleteButton: { 26664 background: "rgba(239, 68, 68, 0.15)", 26665 borderColor: "rgba(239, 68, 68, 0.2)", 26666 color: "#f87171",
26667 flex: "none", 26668 width: "28px" 26669 }, 26670 // Quick Import styles 26671 importSection: { 26672 display: "flex", 26673 flexDirection: "column", 26674 gap: "0.75rem", 26675 height: "100%" 26676 }, 26677 importLabel: { 26678 fontSize: "0.7rem", 26679 color: "rgba(255,255,255,0.6)", 26680 textTransform: "uppercase", 26681 letterSpacing: "0.03em", 26682 fontWeight: 500 26683 }, 26684 importHint: { 26685 fontSize: "0.65rem", 26686 color: "rgba(255,255,255,0.35)" 26687 }, 26688 textarea: { 26689 flex: 1, 26690 minHeight: "220px", 26691 background: "rgba(0,0,0,0.3)", 26692 border: "1px solid rgba(255,255,255,0.08)", 26693 borderRadius: "0.375rem", 26694 padding: "0.75rem", 26695 color: "rgba(255,255,255,0.8)", 26696 fontSize: "0.7rem", 26697 fontFamily: "ui-monospace, SFMono-Regular, monospace", 26698 resize: "none", 26699 lineHeight: 1.5 26700 }, 26701 importActions: { 26702 display: "flex", 26703 gap: "0.5rem" 26704 }, 26705 importButton: { 26706 flex: 1, 26707 padding: "0.625rem 1rem", 26708 fontSize: "0.7rem", 26709 fontWeight: 600, 26710 borderRadius: "0.25rem", 26711 border: "1px solid transparent", 26712 cursor: "pointer", 26713 textTransform: "uppercase", 26714 letterSpacing: "0.03em", 26715 transition: "all 0.15s" 26716 }, 26717 primaryButton: { 26718 background: "rgba(16, 185, 129, 0.2)", 26719 borderColor: "rgba(16, 185, 129, 0.3)", 26720 color: "#10b981" 26721 }, 26722 secondaryButton: { 26723 background: "rgba(255,255,255,0.06)", 26724 borderColor: "rgba(255,255,255,0.1)", 26725 color: "rgba(255,255,255,0.7)" 26726 }, 26727 error: { 26728 color: "#f87171", 26729 fontSize: "0.65rem", 26730 padding: "0.5rem", 26731 background: "rgba(239, 68, 68, 0.1)", 26732 borderRadius: "0.25rem", 26733 border: "1px solid rgba(239, 68, 68, 0.2)" 26734 }, 26735 success: { 26736 color: "#34d399", 26737 fontSize: "0.65rem", 26738 padding: "0.5rem", 26739 background: "rgba(16, 185, 129, 0.1)", 26740 borderRadius: "0.25rem", 26741 border: "1px solid rgba(16, 185, 129, 0.2)" 26742 }, 26743 searchRow: { 26744 display: "flex", 26745 gap: "0.5rem", 26746 marginBottom: "0.75rem" 26747 }, 26748 searchInput: { 26749 flex: 1, 26750 padding: "0.5rem 0.75rem", 26751 background: "rgba(0,0,0,0.3)", 26752 border: "1px solid rgba(255,255,255,0.08)", 26753 borderRadius: "0.25rem", 26754 color: "white", 26755 fontSize: "0.75rem" 26756 }, 26757 filterSelect: { 26758 padding: "0.5rem 0.75rem", 26759 background: "rgba(0,0,0,0.3)", 26760 border: "1px solid rgba(255,255,255,0.08)", 26761 borderRadius: "0.25rem", 26762 color: "white", 26763 fontSize: "0.7rem" 26764 }, 26765 emptyState: { 26766 textAlign: "center", 26767 padding: "2rem", 26768 color: "rgba(255,255,255,0.3)", 26769 fontSize: "0.75rem" 26770 } 26771}; 26772function PatternLibrary({ isOpen, onClose }) { 26773 const { actions } = useDAW(); 26774 const [activeTab, setActiveTab] = (0, import_react10.useState)("library"); 26775 const [patterns, setPatterns] = (0, import_react10.useState)([]); 26776 const [loading, setLoading] = (0, import_react10.useState)(false); 26777 const [search, setSearch] = (0, import_react10.useState)(""); 26778 const [filterTemplates, setFilterTemplates] = (0, import_react10.useState)("all"); 26779 const [hoveredCard, setHoveredCard] = (0, import_react10.useState)(null); 26780 const [jsonInput, setJsonInput] = (0, import_react10.useState)(""); 26781 const [importError, setImportError] = (0, import_react10.useState)(""); 26782 const [importSuccess, setImportSuccess] = (0, import_react10.useState)(""); 26783 const fetchPatterns = (0, import_react10.useCallback)(async () => { 26784 setLoading(true); 26785 try { 26786 const params = new URLSearchParams(); 26787 if (search) params.set("q", search); 26788 if (filterTemplates === "templates") params.set("templates", "true"); 26789 if (filterTemplates === "user") params.set("templates", "false"); 26790 const response = await fetch(`/daw/patterns?${params}`); 26791 const data = await response.json(); 26792 setPatterns(data); 26793 } catch (err) { 26794 console.error("Failed to fetch patterns:", err); 26795 } finally { 26796 setLoading(false); 26797 } 26798 }, [search, filterTemplates]); 26799 (0, import_react10.useEffect)(() => { 26800 if (isOpen && activeTab === "library") { 26801 fetchPatterns(); 26802 } 26803 }, [isOpen, activeTab, fetchPatterns]); 26804 const handleLoad = (0, import_react10.useCallback)(async (pattern, mode = "replace") => { 26805 actions.preparePatternLoad(); 26806 await new Promise((resolve) => setTimeout(resolve, 50)); 26807 actions.loadPattern(pattern, mode); 26808 onClose(); 26809 }, [actions, onClose]); 26810 const handleDelete = (0, import_react10.useCallback)(async (pattern) => { 26811 if (!confirm(`Delete "${pattern.name}"?`)) return; 26812 try { 26813 await fetch(`/daw/patterns/${pattern.id}`, { method: "DELETE" }); 26814 fetchPatterns(); 26815 } catch (err) { 26816 console.error("Failed to delete pattern:", err); 26817 } 26818 }, [fetchPatterns]); 26819 const validateJson = (input) => { 26820 try { 26821 const parsed = JSON.parse(input); 26822 if (!parsed.name && !parsed.tracks) { 26823 return { valid: false, error: 'JSON must contain "name" or "tracks" field' }; 26824 } 26825 if (parsed.tracks) { 26826 if (!Array.isArray(parsed.tracks)) { 26827 return { valid: false, error: '"tracks" must be an array' }; 26828 } 26829 for (const track of parsed.tracks) { 26830 if (!track.type) { 26831 return { valid: false, error: 'Each track must have a "type" field' }; 26832 } 26833 if (!["synth", "drums", "pluck", "fm", "am", "audio"].includes(track.type)) { 26834 return { valid: false, error: `Invalid track type: "${track.type}"` }; 26835 } 26836 } 26837 } 26838 return { valid: true, data: parsed }; 26839 } catch (err) { 26840 return { valid: false, error: `Invalid JSON: ${err.message}` }; 26841 } 26842 }; 26843 const handleQuickLoad = (0, import_react10.useCallback)(async () => { 26844 setImportError(""); 26845 setImportSuccess(""); 26846 const { valid, error, data } = validateJson(jsonInput); 26847 if (!valid) { 26848 setImportError(error); 26849 return; 26850 } 26851 const pattern = { 26852 name: data.name || "Imported Pattern", 26853 bpm: data.bpm, 26854 total_steps: data.totalSteps || data.total_steps, 26855 steps_per_measure: data.stepsPerMeasure || data.steps_per_measure, 26856 data: { 26857 tracks: data.tracks || [] 26858 } 26859 }; 26860 actions.preparePatternLoad(); 26861 await new Promise((resolve) => setTimeout(resolve, 50)); 26862 actions.loadPattern(pattern, "replace"); 26863 setImportSuccess("Pattern loaded!"); 26864 setTimeout(() => { 26865 onClose(); 26866 }, 400); 26867 }, [jsonInput, actions, onClose]); 26868 const handleSaveToLibrary = (0, import_react10.useCallback)(async () => { 26869 setImportError(""); 26870 setImportSuccess(""); 26871 const { valid, error, data } = validateJson(jsonInput); 26872 if (!valid) { 26873 setImportError(error); 26874 return; 26875 } 26876 try { 26877 const response = await fetch("/daw/patterns", { 26878 method: "POST", 26879 headers: { "Content-Type": "application/json" }, 26880 body: JSON.stringify({ 26881 name: data.name || "Imported Pattern", 26882 description: data.description || "", 26883 bpm: data.bpm || 120, 26884 total_steps: data.totalSteps || data.total_steps || 16, 26885 steps_per_measure: data.stepsPerMeasure || data.steps_per_measure || 16, 26886 tags: data.tags || [], 26887 data: { tracks: data.tracks || [] } 26888 }) 26889 }); 26890 if (!response.ok) { 26891 const result = await response.json(); 26892 throw new Error(result.errors?.join(", ") || "Failed to save"); 26893 } 26894 setImportSuccess("Saved to library!"); 26895 setJsonInput(""); 26896 fetchPatterns(); 26897 } catch (err) { 26898 setImportError(err.message); 26899 } 26900 }, [jsonInput, fetchPatterns]); 26901 if (!isOpen) return null; 26902 return /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.overlay, onClick: onClose }
26902, /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.modal, onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.header }, /* @__PURE__ */ import_react10.default.createElement("span", { style: styles8.title }, "Pattern Library"), /* @__PURE__ */ import_react10.default.createElement( 26903 "button", 26904 { 26905 style: styles8.closeButton, 26906 onClick: onClose, 26907 onMouseOver: (e) => { 26908 e.currentTarget.style.background = "rgba(255,255,255,0.1)"; 26909 e.currentTarget.style.color = "white"; 26910 }, 26911 onMouseOut: (e) => { 26912 e.currentTarget.style.background = "rgba(255,255,255,0.06)"; 26913 e.currentTarget.style.color = "rgba(255,255,255,0.5)"; 26914 } 26915 }, 26916 "\xD7" 26917 )), /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.tabs }, /* @__PURE__ */ import_react10.default.createElement( 26918 "button", 26919 { 26920 style: { ...styles8.tab, ...activeTab === "library" ? styles8.activeTab : {} }, 26921 onClick: () => setActiveTab("library") 26922 }, 26923 "Browse" 26924 ), /* @__PURE__ */ import_react10.default.createElement( 26925 "button", 26926 { 26927 style: { ...styles8.tab, ...activeTab === "import" ? styles8.activeTab : {} }, 26928 onClick: () => setActiveTab("import") 26929 }, 26930 "Import JSON"
26931 )), /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.content }, activeTab === "library" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.searchRow }, /* @__PURE__ */ import_react10.default.createElement( 26932 "input", 26933 { 26934 type: "text", 26935 placeholder: "Search...", 26936 value: search, 26937 onChange: (e) => setSearch(e.target.value), 26938 style: styles8.searchInput 26939 } 26940 ), /* @__PURE__ */ import_react10.default.createElement( 26941 "select", 26942 { 26943 value: filterTemplates, 26944 onChange: (e) => setFilterTemplates(e.target.value), 26945 style: styles8.filterSelect 26946 }, 26947 /* @__PURE__ */ import_react10.default.createElement("option", { value: "all" }, "All"), 26948 /* @__PURE__ */ import_react10.default.createElement("option", { value: "templates" }, "Templates"), 26949 /* @__PURE__ */ import_react10.default.createElement("option", { value: "user" }, "My Patterns")
26950 )), loading ? /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.emptyState }, "Loading...") : patterns.length === 0 ? /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.emptyState }, "No patterns found") : /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.grid }, patterns.map((pattern) => /* @__PURE__ */ import_react10.default.createElement( 26951 "div", 26952 { 26953 key: pattern.id, 26954 style: { 26955 ...styles8.card, 26956 ...hoveredCard === pattern.id ? styles8.cardHover : {} 26957 }, 26958 onMouseEnter: () => setHoveredCard(pattern.id), 26959 onMouseLeave: () => setHoveredCard(null) 26960 }, 26961 /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.cardName }, pattern.name), 26962 pattern.description && /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.cardDescription }, pattern.description), 26963 /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.cardMeta }, /* @__PURE__ */ import_react10.default.createElement("span", null, pattern.bpm, " BPM"), /* @__PURE__ */ import_react10.default.createElement("span", null, pattern.trackCount || pattern.data?.tracks?.length || 0, " trk"), /* @__PURE__ */ import_react10.default.createElement("span", null, pattern.total_steps, " steps")), 26964 /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.tags }, pattern.is_template && /* @__PURE__ */ import_react10.default.createElement("span", { style: { ...styles8.tag, ...styles8.templateBadge } }, "TEMPLATE"), (pattern.tags || []).slice(0, 3).map((tag) => /* @__PURE__ */ import_react10.default.createElement("span", { key: tag, style: styles8.tag }, tag))), 26965 /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.cardActions }, /* @__PURE__ */ import_react10.default.createElement( 26966 "button", 26967 { 26968 style: { ...styles8.actionButton, ...styles8.loadButton }, 26969 onClick: () => handleLoad(pattern, "replace"), 26970 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.3)", 26971 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.15)" 26972 }, 26973 "Load" 26974 ), /* @__PURE__ */ import_react10.default.createElement( 26975 "button", 26976 { 26977 style: { ...styles8.actionButton, ...styles8.mergeButton }, 26978 onClick: () => handleLoad(pattern, "merge"), 26979 title: "Add tracks to current project", 26980 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.1)", 26981 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 26982 }, 26983 "+" 26984 ), !pattern.is_template && /* @__PURE__ */ import_react10.default.createElement( 26985 "button", 26986 { 26987 style: { ...styles8.actionButton, ...styles8.deleteButton }, 26988 onClick: () => handleDelete(pattern), 26989 title: "Delete", 26990 onMouseOver: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.25)", 26991 onMouseOut: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.15)" 26992 }, 26993 "\xD7" 26994 )) 26995 )))), activeTab === "import" && /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.importSection }, /* @__PURE__ */ import_react10.default.createElement("div", null, /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.importLabel }, "Paste Pattern JSON"), /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.importHint }, 'From Claude or exported patterns. Must include "tracks" array.')), /* @__PURE__ */ import_react10.default.createElement( 26996 "textarea", 26997 { 26998 style: styles8.textarea, 26999 placeholder: `{ 27000 "name": "My Pattern", 27001 "bpm": 120, 27002 "totalSteps": 16, 27003 "tracks": [ 27004 { 27005 "name": "Drums", 27006 "type": "drums", 27007 "notes": [ 27008 { "pitch": 0, "step": 0, "duration": 1, "velocity": 100 } 27009 ] 27010 } 27011 ] 27012}`, 27013 value: jsonInput, 27014 onChange: (e) => { 27015 setJsonInput(e.target.value); 27016 setImportError(""); 27017 setImportSuccess(""); 27018 } 27019 }
27020 ), importError && /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.error }, importError), importSuccess && /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.success }, importSuccess), /* @__PURE__ */ import_react10.default.createElement("div", { style: styles8.importActions }, /* @__PURE__ */ import_react10.default.createElement( 27021 "button", 27022 { 27023 style: { ...styles8.importButton, ...styles8.primaryButton }, 27024 onClick: handleQuickLoad, 27025 disabled: !jsonInput.trim(), 27026 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.35)", 27027 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.2)" 27028 }, 27029 "Load Now" 27030 ), /* @__PURE__ */ import_react10.default.createElement( 27031 "button", 27032 { 27033 style: { ...styles8.importButton, ...styles8.secondaryButton }, 27034 onClick: handleSaveToLibrary, 27035 disabled: !jsonInput.trim(), 27036 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.1)", 27037 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 27038 }, 27039 "Save to Library" 27040 )))))); 27041} 27042
27043// app/javascript/components/daw/components/SavePatternModal.jsx 27044var import_react11 = __toESM(require_react()); 27045var AVAILABLE_TAGS = [ 27046 "drums", 27047 "bass", 27048 "synth", 27049 "arp", 27050 "chords", 27051 "melody", 27052 "ambient", 27053 "techno", 27054 "house", 27055 "dubstep", 27056 "chill", 27057 "loop" 27058]; 27059var styles9 = { 27060 overlay: { 27061 position: "fixed", 27062 top: 0, 27063 left: 0, 27064 right: 0, 27065 bottom: 0, 27066 background: "rgba(0,0,0,0.85)", 27067 display: "flex", 27068 alignItems: "center", 27069 justifyContent: "center", 27070 zIndex: 1e3 27071 }, 27072 modal: { 27073 background: "linear-gradient(180deg, rgba(20,20,25,1) 0%, rgba(12,12,16,1) 100%)", 27074 borderRadius: "0.5rem", 27075 border: "1px solid rgba(255,255,255,0.08)", 27076 width: "90%", 27077 maxWidth: "420px", 27078 overflow: "hidden", 27079 boxShadow: "0 25px 50px -12px rgba(0,0,0,0.5)" 27080 }, 27081 header: { 27082 padding: "0.75rem 1rem", 27083 borderBottom: "1px solid rgba(255,255,255,0.06)", 27084 display: "flex", 27085 justifyContent: "space-between", 27086 alignItems: "center", 27087 background: "rgba(255,255,255,0.02)" 27088 }, 27089 title: { 27090 fontSize: "0.75rem", 27091 fontWeight: 600, 27092 color: "rgba(255,255,255,0.7)", 27093 textTransform: "uppercase", 27094 letterSpacing: "0.05em" 27095 }, 27096 closeButton: { 27097 background: "rgba(255,255,255,0.06)", 27098 border: "1px solid rgba(255,255,255,0.1)", 27099 borderRadius: "0.25rem", 27100 color: "rgba(255,255,255,0.5)", 27101 fontSize: "1rem", 27102 cursor: "pointer", 27103 padding: "0.25rem 0.5rem", 27104 lineHeight: 1, 27105 transition: "all 0.15s" 27106 }, 27107 content: { 27108 padding: "1rem", 27109 display: "flex", 27110 flexDirection: "column", 27111 gap: "0.875rem" 27112 }, 27113 field: { 27114 display: "flex", 27115 flexDirection: "column", 27116 gap: "0.375rem" 27117 }, 27118 label: { 27119 fontSize: "0.65rem", 27120 color: "rgba(255,255,255,0.5)", 27121 textTransform: "uppercase", 27122 letterSpacing: "0.03em", 27123 fontWeight: 500 27124 }, 27125 input: { 27126 padding: "0.5rem 0.625rem", 27127 background: "rgba(0,0,0,0.3)", 27128 border: "1px solid rgba(255,255,255,0.08)", 27129 borderRadius: "0.25rem", 27130 color: "white", 27131 fontSize: "0.8rem" 27132 }, 27133 textarea: { 27134 padding: "0.5rem 0.625rem", 27135 background: "rgba(0,0,0,0.3)", 27136 border: "1px solid rgba(255,255,255,0.08)", 27137 borderRadius: "0.25rem", 27138 color: "white", 27139 fontSize: "0.75rem", 27140 minHeight: "60px", 27141 resize: "vertical", 27142 lineHeight: 1.4 27143 }, 27144 tagsContainer: { 27145 display: "flex", 27146 flexWrap: "wrap", 27147 gap: "0.25rem" 27148 }, 27149 tagButton: { 27150 padding: "0.2rem 0.5rem", 27151 background: "rgba(255,255,255,0.06)", 27152 border: "1px solid rgba(255,255,255,0.08)", 27153 borderRadius: "0.2rem", 27154 color: "rgba(255,255,255,0.5)", 27155 fontSize: "0.6rem", 27156 cursor: "pointer", 27157 transition: "all 0.15s", 27158 textTransform: "uppercase", 27159 letterSpacing: "0.02em" 27160 }, 27161 tagSelected: { 27162 background: "rgba(16, 185, 129, 0.2)", 27163 borderColor: "rgba(16, 185, 129, 0.3)", 27164 color: "#10b981" 27165 }, 27166 meta: { 27167 display: "flex", 27168 gap: "0.75rem", 27169 padding: "0.5rem 0.625rem", 27170 background: "rgba(0,0,0,0.2)", 27171 borderRadius: "0.25rem", 27172 fontSize: "0.65rem", 27173 color: "rgba(255,255,255,0.4)" 27174 }, 27175 actions: { 27176 display: "flex", 27177 gap: "0.5rem", 27178 marginTop: "0.25rem" 27179 }, 27180 button: { 27181 flex: 1, 27182 padding: "0.625rem 1rem", 27183 fontSize: "0.7rem", 27184 fontWeight: 600, 27185 borderRadius: "0.25rem", 27186 border: "1px solid transparent", 27187 cursor: "pointer", 27188 textTransform: "uppercase", 27189 letterSpacing: "0.03em", 27190 transition: "all 0.15s" 27191 }, 27192 primaryButton: { 27193 background: "rgba(16, 185, 129, 0.2)", 27194 borderColor: "rgba(16, 185, 129, 0.3)", 27195 color: "#10b981" 27196 }, 27197 secondaryButton: { 27198 background: "rgba(255,255,255,0.06)", 27199 borderColor: "rgba(255,255,255,0.1)", 27200 color: "rgba(255,255,255,0.7)" 27201 }, 27202 error: { 27203 color: "#f87171", 27204 fontSize: "0.65rem", 27205 padding: "0.5rem", 27206 background: "rgba(239, 68, 68, 0.1)", 27207 borderRadius: "0.25rem", 27208 border: "1px solid rgba(239, 68, 68, 0.2)" 27209 }, 27210 success: { 27211 color: "#34d399", 27212 fontSize: "0.65rem", 27213 padding: "0.5rem", 27214 background: "rgba(16, 185, 129, 0.1)", 27215 borderRadius: "0.25rem", 27216 border: "1px solid rgba(16, 185, 129, 0.2)" 27217 } 27218}; 27219function SavePatternModal({ isOpen, onClose }) { 27220 const { state } = useDAW(); 27221 const [name, setName] = (0, import_react11.useState)(state.projectName || ""); 27222 const [description, setDescription] = (0, import_react11.useState)(""); 27223 const [selectedTags, setSelectedTags] = (0, import_react11.useState)([]); 27224 const [saving, setSaving] = (0, import_react11.useState)(false); 27225 const [error, setError] = (0, import_react11.useState)(""); 27226 const [success, setSuccess] = (0, import_react11.useState)(""); 27227 const toggleTag = (tag) => { 27228 setSelectedTags( 27229 (prev) => prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag] 27230 ); 27231 }; 27232 const handleSave = (0, import_react11.useCallback)(async () => { 27233 if (!name.trim()) { 27234 setError("Enter a pattern name"); 27235 return; 27236 } 27237 setSaving(true); 27238 setError(""); 27239 setSuccess(""); 27240 try { 27241 const patternData = { 27242 name: name.trim(), 27243 description: description.trim(), 27244 bpm: state.bpm, 27245 total_steps: state.totalSteps, 27246 steps_per_measure: state.stepsPerMeasure, 27247 tags: selectedTags, 27248 is_template: false, 27249 data: { 27250 tracks: state.tracks.map((track) => ({ 27251 name: track.name, 27252 type: track.type, 27253 instrument: track.instrument, 27254 effects: track.effects, 27255 muted: track.muted, 27256 solo: track.solo, 27257 volume: track.volume, 27258 pan: track.pan, 27259 notes: track.notes.map((note) => ({ 27260 pitch: note.pitch, 27261 step: note.step, 27262 duration: note.duration, 27263 velocity: note.velocity 27264 })) 27265 })) 27266 } 27267 }; 27268 const response = await fetch("/daw/patterns", { 27269 method: "POST", 27270 headers: { "Content-Type": "application/json" }, 27271 body: JSON.stringify(patternData) 27272 }); 27273 const result = await response.json(); 27274 if (!response.ok) { 27275 throw new Error(result.errors?.join(", ") || "Failed to save"); 27276 } 27277 setSuccess("Saved!"); 27278 setTimeout(() => { 27279 onClose(); 27280 }, 600); 27281 } catch (err) { 27282 setError(err.message); 27283 } finally { 27284 setSaving(false); 27285 } 27286 }, [name, description, selectedTags, state, onClose]); 27287 if (!isOpen) return null; 27288 const trackCount = state.tracks.length; 27289 const noteCount = state.tracks.reduce((sum, t) => sum + t.notes.length, 0); 27290 return /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.overlay, onClick: onClose }
27290, /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.modal, onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.header }, /* @__PURE__ */ import_react11.default.createElement("span", { style: styles9.title }, "Save to Library"), /* @__PURE__ */ import_react11.default.createElement( 27291 "button", 27292 { 27293 style: styles9.closeButton, 27294 onClick: onClose, 27295 onMouseOver: (e) => { 27296 e.currentTarget.style.background = "rgba(255,255,255,0.1)"; 27297 e.currentTarget.style.color = "white"; 27298 }, 27299 onMouseOut: (e) => { 27300 e.currentTarget.style.background = "rgba(255,255,255,0.06)"; 27301 e.currentTarget.style.color = "rgba(255,255,255,0.5)"; 27302 } 27303 }, 27304 "\xD7" 27305 )), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.content }, /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.field }, /* @__PURE__ */ import_react11.default.createElement("label", { style: styles9.label }, "Name"), /* @__PURE__ */ import_react11.default.createElement( 27306 "input", 27307 { 27308 type: "text", 27309 style: styles9.input, 27310 placeholder: "My Pattern", 27311 value: name, 27312 onChange: (e) => setName(e.target.value) 27313 }
27314 )), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.field }, /* @__PURE__ */ import_react11.default.createElement("label", { style: styles9.label }, "Description"), /* @__PURE__ */ import_react11.default.createElement( 27315 "textarea", 27316 { 27317 style: styles9.textarea, 27318 placeholder: "Optional description...", 27319 value: description, 27320 onChange: (e) => setDescription(e.target.value) 27321 } 27322 )), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.field }, /* @__PURE__ */ import_react11.default.createElement("label", { style: styles9.label }, "Tags"), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.tagsContainer }, AVAILABLE_TAGS.map((tag) => /* @__PURE__ */ import_react11.default.createElement( 27323 "button", 27324 { 27325 key: tag, 27326 style: { 27327 ...styles9.tagButton, 27328 ...selectedTags.includes(tag) ? styles9.tagSelected : {} 27329 }, 27330 onClick: () => toggleTag(tag) 27331 }, 27332 tag 27333 )))), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.meta }, /* @__PURE__ */ import_react11.default.createElement("span", null, state.bpm, " BPM"), /* @__PURE__ */ import_react11.default.createElement("span", null, trackCount, " track", trackCount !== 1 ? "s" : ""), /* @__PURE__ */ import_react11.default.createElement("span", null, noteCount, " note", noteCount !== 1 ? "s" : ""), /* @__PURE__ */ import_react11.default.createElement("span", null, state.totalSteps, " steps")), error && /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.error }
27333, error), success && /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.success }, success), /* @__PURE__ */ import_react11.default.createElement("div", { style: styles9.actions }, /* @__PURE__ */ import_react11.default.createElement( 27334 "button", 27335 { 27336 style: { ...styles9.button, ...styles9.secondaryButton }, 27337 onClick: onClose, 27338 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.1)", 27339 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 27340 }, 27341 "Cancel" 27342 ), /* @__PURE__ */ import_react11.default.createElement( 27343 "button", 27344 { 27345 style: { ...styles9.button, ...styles9.primaryButton }, 27346 onClick: handleSave, 27347 disabled: saving, 27348 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.35)", 27349 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.2)" 27350 }, 27351 saving ? "Saving..." : "Save" 27352 ))))); 27353} 27354
27355// app/javascript/components/daw/components/ProjectPanel.jsx 27356var STORAGE_KEY = "daw-projects"; 27357var styles10 = { 27358 container: { 27359 display: "flex", 27360 flexDirection: "column", 27361 gap: "0.5rem", 27362 minWidth: "180px" 27363 }, 27364 title: { 27365 fontSize: "0.75rem", 27366 color: "rgba(255,255,255,0.5)", 27367 textTransform: "uppercase", 27368 letterSpacing: "0.05em" 27369 }, 27370 row: { 27371 display: "flex", 27372 gap: "0.25rem" 27373 }, 27374 button: { 27375 flex: 1, 27376 padding: "0.375rem 0.5rem", 27377 fontSize: "0.7rem", 27378 background: "rgba(255,255,255,0.06)", 27379 border: "1px solid rgba(255,255,255,0.1)", 27380 borderRadius: "0.25rem", 27381 color: "rgba(255,255,255,0.8)", 27382 cursor: "pointer", 27383 transition: "all 0.2s" 27384 }, 27385 select: { 27386 flex: 1, 27387 padding: "0.375rem 0.5rem", 27388 background: "rgba(255,255,255,0.05)", 27389 border: "1px solid rgba(255,255,255,0.1)", 27390 borderRadius: "0.25rem", 27391 color: "white", 27392 fontSize: "0.7rem" 27393 }, 27394 input: { 27395 flex: 1, 27396 padding: "0.375rem 0.5rem", 27397 background: "rgba(255,255,255,0.05)", 27398 border: "1px solid rgba(255,255,255,0.1)", 27399 borderRadius: "0.25rem", 27400 color: "white", 27401 fontSize: "0.7rem" 27402 }, 27403 saveButton: { 27404 background: "rgba(16, 185, 129, 0.1)", 27405 borderColor: "rgba(16, 185, 129, 0.2)" 27406 }, 27407 deleteButton: { 27408 background: "rgba(239, 68, 68, 0.1)", 27409 borderColor: "rgba(239, 68, 68, 0.2)", 27410 flex: "none", 27411 width: "32px" 27412 } 27413}; 27414function getProjects() { 27415 try { 27416 const data = localStorage.getItem(STORAGE_KEY); 27417 return data ? JSON.parse(data) : {}; 27418 } catch { 27419 return {}; 27420 } 27421} 27422function saveProjects(projects) { 27423 localStorage.setItem(STORAGE_KEY, JSON.stringify(projects)); 27424} 27425function ProjectPanel() { 27426 const { state, actions } = useDAW(); 27427 const [projects, setProjects] = (0, import_react12.useState)({}); 27428 const [selectedProject, setSelectedProject] = (0, import_react12.useState)(""); 27429 const [showLibrary, setShowLibrary] = (0, import_react12.useState)(false); 27430 const [showSaveModal, setShowSaveModal] = (0, import_react12.useState)(false); 27431 const projectName = state.projectName || ""; 27432 const setProjectName = (name) => actions.setProjectName(name); 27433 (0, import_react12.useEffect)(() => { 27434 setProjects(getProjects()); 27435 }, []); 27436 const handleSave = (0, import_react12.useCallback)(() => { 27437 if (!projectName.trim()) return; 27438 const projectState = { 27439 ...state, 27440 audioInitialized: false 27441 // Don't persist this 27442 }; 27443 const updatedProjects = { 27444 ...projects, 27445 [projectName]: { 27446 state: projectState, 27447 savedAt: Date.now() 27448 } 27449 }; 27450 saveProjects(updatedProjects); 27451 setProjects(updatedProjects); 27452 setSelectedProject(projectName); 27453 }, [projectName, state, projects]); 27454 const handleLoad = (0, import_react12.useCallback)(() => { 27455 if (!selectedProject || !projects[selectedProject]) return; 27456 const projectData = projects[selectedProject]; 27457 actions.loadProject(projectData.state); 27458 setProjectName(selectedProject); 27459 }, [selectedProject, projects, actions]); 27460 const handleDelete = (0, import_react12.useCallback)(() => { 27461 if (!selectedProject || !projects[selectedProject]) return; 27462 const { [selectedProject]: _, ...rest } = projects; 27463 saveProjects(rest); 27464 setProjects(rest); 27465 setSelectedProject(""); 27466 }, [selectedProject, projects]); 27467 const handleNew = (0, import_react12.useCallback)(() => { 27468 actions.newProject(); 27469 setProjectName(""); 27470 setSelectedProject(""); 27471 }, [actions]); 27472 const projectList = Object.keys(projects); 27473 return /* @__PURE__ */ import_react12.default.createElement("div", { style: styles10.container }, /* @__PURE__ */ import_react12.default.createElement("span", { style: styles10.title }, "Project"), /* @__PURE__ */ import_react12.default.createElement("div", { style: styles10.row }, /* @__PURE__ */ import_react12.default.createElement( 27474 "input", 27475 { 27476 type: "text", 27477 placeholder: "Project name...", 27478 value: projectName, 27479 onChange: (e) => setProjectName(e.target.value), 27480 style: styles10.input 27481 } 27482 ), /* @__PURE__ */ import_react12.default.createElement( 27483 "button", 27484 { 27485 style: { ...styles10.button, ...styles10.saveButton, flex: "
27485none", width: "50px" }, 27486 onClick: handleSave, 27487 disabled: !projectName.trim(), 27488 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.2)", 27489 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.1)" 27490 }, 27491 "Save" 27492 )), /* @__PURE__ */ import_react12.default.createElement("div", { style: styles10.row }, /* @__PURE__ */ import_react12.default.createElement( 27493 "select", 27494 { 27495 value: selectedProject, 27496 onChange: (e) => setSelectedProject(e.target.value), 27497 style: styles10.select 27498 }, 27499 /* @__PURE__ */ import_react12.default.createElement("option", { value: "" }, "Select project..."), 27500 projectList.map((name) => /* @__PURE__ */ import_react12.default.createElement("option", { key: name, value: name }, name)) 27501 ), /* @__PURE__ */ import_react12.default.createElement( 27502 "button", 27503 { 27504 style: { ...styles10.button, flex: "none", width: "50px" }, 27505 onClick: handleLoad, 27506 disabled: !selectedProject, 27507 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.1)", 27508 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 27509 }, 27510 "Load" 27511 ), /* @__PURE__ */ import_react12.default.createElement( 27512 "button", 27513 { 27514 style: { ...styles10.button, ...styles10.deleteButton }, 27515 onClick: handleDelete, 27516 disabled: !selectedProject, 27517 title: "Delete selected project", 27518 onMouseOver: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.2)", 27519 onMouseOut: (e) => e.currentTarget.style.background = "rgba(239, 68, 68, 0.1)" 27520 }, 27521 "\xD7"
27522 )), /* @__PURE__ */ import_react12.default.createElement( 27523 "button", 27524 { 27525 style: styles10.button, 27526 onClick: handleNew, 27527 onMouseOver: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.1)", 27528 onMouseOut: (e) => e.currentTarget.style.background = "rgba(255,255,255,0.06)" 27529 }, 27530 "New Project" 27531 ), /* @__PURE__ */ import_react12.default.createElement("div", { style: { borderTop: "1px solid rgba(255,255,255,0.1)", marginTop: "0.5rem", paddingTop: "0.5rem" } }, /* @__PURE__ */ import_react12.default.createElement("span", { style: { ...styles10.title, marginBottom: "0.5rem", display: "block" } }, "Pattern Library"), /* @__PURE__ */ import_react12.default.createElement("div", { style: styles10.row }, /* @__PURE__ */ import_react12.default.createElement( 27532 "button", 27533 { 27534 style: { ...styles10.button, background: "rgba(139, 92, 246, 0.1)", borderColor: "rgba(139, 92, 246, 0.2)" }, 27535 onClick: () => setShowLibrary(true), 27536 onMouseOver: (e) => e.currentTarget.style.background = "rgba(139, 92, 246, 0.2)", 27537 onMouseOut: (e) => e.currentTarget.style.background = "rgba(139, 92, 246, 0.1)" 27538 }, 27539 "Browse" 27540 ), /* @__PURE__ */ import_react12.default.createElement( 27541 "button", 27542 { 27543 style: { ...styles10.button, ...styles10.saveButton }, 27544 onClick: () => setShowSaveModal(true), 27545 onMouseOver: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.2)", 27546 onMouseOut: (e) => e.currentTarget.style.background = "rgba(16, 185, 129, 0.1)" 27547 }, 27548 "Save to Library" 27549 ))), /* @__PURE__ */ import_react12.default.createElement(PatternLibrary, { isOpen: showLibrary, onClose: () => setShowLibrary(false) }
27549), /* @__PURE__ */ import_react12.default.createElement(SavePatternModal, { isOpen: showSaveModal, onClose: () => setShowSaveModal(false) })); 27550} 27551
27552// app/javascript/components/daw/components/ExportPanel.jsx 27553var import_react13 = __toESM(require_react()); 27554var styles11 = { 27555 container: { 27556 display: "flex", 27557 flexDirection: "column", 27558 gap: "0.5rem", 27559 minWidth: "160px" 27560 }, 27561 title: { 27562 fontSize: "0.75rem", 27563 color: "rgba(255,255,255,0.5)", 27564 textTransform: "uppercase", 27565 letterSpacing: "0.05em" 27566 }, 27567 row: { 27568 display: "flex", 27569 gap: "0.25rem" 27570 }, 27571 button: { 27572 flex: 1, 27573 padding: "0.5rem 0.75rem", 27574 fontSize: "0.75rem", 27575 background: "rgba(255,255,255,0.06)", 27576 border: "1px solid rgba(255,255,255,0.1)", 27577 borderRadius: "0.25rem", 27578 color: "rgba(255,255,255,0.8)", 27579 cursor: "pointer", 27580 transition: "all 0.2s" 27581 }, 27582 exportButton: { 27583 background: "linear-gradient(45deg, #10b981, #059669)", 27584 borderColor: "transparent", 27585 color: "white", 27586 fontWeight: 500 27587 }, 27588 progress: { 27589 height: "4px", 27590 background: "rgba(255,255,255,0.1)", 27591 borderRadius: "2px", 27592 overflow: "hidden" 27593 }, 27594 progressBar: { 27595 height: "100%", 27596 background: "var(--accent-color, #10b981)", 27597 transition: "width 0.1s" 27598 }, 27599 status: { 27600 fontSize: "0.65rem", 27601 color: "rgba(255,255,255,0.5)", 27602 textAlign: "center" 27603 }, 27604 select: { 27605 flex: 1, 27606 padding: "0.375rem 0.5rem", 27607 background: "rgba(255,255,255,0.05)", 27608 border: "1px solid rgba(255,255,255,0.1)", 27609 borderRadius: "0.25rem", 27610 color: "white", 27611 fontSize: "0.7rem" 27612 } 27613}; 27614function audioBufferToWav(buffer) { 27615 const numChannels = buffer.numberOfChannels; 27616 const sampleRate = buffer.sampleRate; 27617 const format = 1; 27618 const bitDepth = 16; 27619 const bytesPerSample = bitDepth / 8; 27620 const blockAlign = numChannels * bytesPerSample; 27621 const byteRate = sampleRate * blockAlign; 27622 const dataSize = buffer.length * blockAlign; 27623 const wavBuffer = new ArrayBuffer(44 + dataSize); 27624 const view = new DataView(wavBuffer); 27625 writeString(view, 0, "RIFF"); 27626 view.setUint32(4, 36 + dataSize, true); 27627 writeString(view, 8, "WAVE"); 27628 writeString(view, 12, "fmt "); 27629 view.setUint32(16, 16, true); 27630 view.setUint16(20, format, true); 27631 view.setUint16(22, numChannels, true); 27632 view.setUint32(24, sampleRate, true); 27633 view.setUint32(28, byteRate, true); 27634 view.setUint16(32, blockAlign, true); 27635 view.setUint16(34, bitDepth, true); 27636 writeString(view, 36, "data"); 27637 view.setUint32(40, dataSize, true); 27638 const offset = 44; 27639 const channels = []; 27640 for (let i = 0; i < numChannels; i++) { 27641 channels.push(buffer.getChannelData(i)); 27642 } 27643 let pos = offset; 27644 for (let i = 0; i < buffer.length; i++) { 27645 for (let ch = 0; ch < numChannels; ch++) { 27646 const sample = Math.max(-1, Math.min(1, channels[ch][i])); 27647 const intSample = sample < 0 ? sample * 32768 : sample * 32767; 27648 view.setInt16(pos, intSample, true); 27649 pos += 2; 27650 } 27651 } 27652 return new Blob([wavBuffer], { type: "audio/wav" }); 27653} 27654function writeString(view, offset, string) { 27655 for (let i = 0; i < string.length; i++) { 27656 view.setUint8(offset + i, string.charCodeAt(i)); 27657 } 27658} 27659function ExportPanel() { 27660 const { state } = useDAW(); 27661 const [isExporting, setIsExporting] = (0, import_react13.useState)(false); 27662 const [progress, setProgress] = (0, import_react13.useState)(0); 27663 const [status, setStatus] = (0, import_react13.useState)(""); 27664 const hasContent = state.tracks.some( 27665 (track) => track.notes.length > 0 || track.type === "audio" && track.audioData?.buffer 27666 ); 27667 const handleExportWav = (0, import_react13.useCallback)(async () => { 27668 if (isExporting) return; 27669 if (!hasContent) { 27670 setStatus("No content to export!"); 27671 setTimeout(() => setStatus(""), 2e3); 27672 return; 27673 } 27674 setIsExporting(true); 27675 setProgress(0); 27676 setStatus("Rendering audio..."); 27677 try { 27678 const durationInMeasures = state.totalSteps / state.stepsPerMeasure; 27679 const beatsPerMeasure = 4; 27680 const secondsPerBeat = 60 / state.bpm; 27681 let duration = durationInMeasures * beatsPerMeasure * secondsPerBeat; 27682 state.tracks.forEach((track) => { 27683 if (track.type === "audio" && track.audioData?.duration) { 27684 duration = Math.max(duration, track.audioData.duration); 27685 } 27686 }); 27687 duration += 0.5; 27688 console.log("Exporting with duration:", duration, "seconds"); 27689 const buffer = await Offline(({ transport }) => { 27690 transport.bpm.value = state.bpm; 27691 const masterVol = new Volume( 27692 state.masterVolume > 0 ? gainToDb(state.masterVolume) : -Infinity 27693 ).toDestination(); 27694 state.tracks.forEach((track) => { 27695 if (track.muted) return; 27696 const channel = new Channel({ 27697 volume: track.volume > 0 ? gainToDb(track.volume) : -Infinity, 27698 pan: track.pan 27699 }).connect(masterVol); 27700 if (track.type === "synth") { 27701 const filter = new Filter({ 27702 frequency: track.instrument?.filterFreq || 2e3, 27703 type: "lowpass", 27704 Q: track.instrument?.filterRes || 1 27705 }).connect(channel); 27706 const synth = new PolySynth(Synth, { 27707 oscillator: { type: track.instrument?.oscillator || "sawtooth" }, 27708 envelope: { 27709 attack: track.instrument?.attack || 0.01, 27710 decay: track.instrument?.decay || 0.1, 27711 sustain: track.instrument?.sustain || 0.5, 27712 release: track.instrument?.release || 0.3 27713 } 27714 }).connect(filter);
27715 track.notes.forEach((note) => { 27716 const time = note.step / state.stepsPerMeasure * beatsPerMeasure * secondsPerBeat; 27717 const noteDuration = note.duration / state.stepsPerMeasure * beatsPerMeasure * secondsPerBeat; 27718 const pitch = Frequency(note.pitch, "midi").toNote(); 27719 transport.schedule((t) => { 27720 synth.triggerAttackRelease(pitch, noteDuration, t, note.velocity / 127); 27721 }, time); 27722 }); 27723 } else if (track.type === "drums") { 27724 const drums = { 27725 kick: new MembraneSynth({ 27726 pitchDecay: 0.05, 27727 octaves: 4, 27728 oscillator: { type: "sine" }, 27729 envelope: { attack: 1e-3, decay: 0.4, sustain: 0, release: 0.4 } 27730 }).connect(channel), 27731 snare: new NoiseSynth({ 27732 noise: { type: "white" }, 27733 envelope: { attack: 1e-3, decay: 0.2, sustain: 0, release: 0.2 } 27734 }).connect(channel), 27735 hihat: new MetalSynth({ 27736 frequency: 200, 27737 envelope: { attack: 1e-3, decay: 0.1, sustain: 0, release: 0.1 }, 27738 harmonicity: 5.1, 27739 modulationIndex: 32, 27740 resonance: 4e3, 27741 octaves: 1.5 27742 }).connect(channel), 27743 clap: new NoiseSynth({ 27744 noise: { type: "pink" }, 27745 envelope: { attack: 5e-3, decay: 0.1, sustain: 0, release: 0.1 } 27746 }).connect(channel), 27747 tom: new MembraneSynth({ 27748 pitchDecay: 0.08, 27749 octaves: 2, 27750 oscillator: { type: "sine" }, 27751 envelope: { attack: 1e-3, decay: 0.3, sustain: 0, release: 0.3 } 27752 }).connect(channel), 27753 crash: new MetalSynth({ 27754 frequency: 300, 27755 envelope: { attack: 1e-3, decay: 1, sustain: 0, release: 1 }, 27756 harmonicity: 5.1, 27757 modulationIndex: 40, 27758 resonance: 5e3, 27759 octaves: 1.5 27760 }).connect(channel), 27761 ride: new MetalSynth({ 27762 frequency: 400, 27763 envelope: { attack: 1e-3, decay: 0.4, sustain: 0.1, release: 0.4 }, 27764 harmonicity: 7, 27765 modulationIndex: 20, 27766 resonance: 6e3, 27767 octaves: 1 27768 }).connect(channel), 27769 cowbell: new MetalSynth({ 27770 frequency: 560, 27771 envelope: { attack: 1e-3, decay: 0.2, sustain: 0, release: 0.2 }, 27772 harmonicity: 0.5, 27773 modulationIndex: 2, 27774 resonance: 800, 27775 octaves: 0 27776 }).connect(channel) 27777 }; 27778 const drumTypes = ["kick", "snare", "hihat", "clap", "tom", "crash", "ride", "cowbell"]; 27779 track.notes.forEach((note) => { 27780 const time = note.step / state.stepsPerMeasure * beatsPerMeasure * secondsPerBeat; 27781 const drumType = drumTypes[note.pitch % drumTypes.length]; 27782 const drum = drums[drumType]; 27783 const velocity = note.velocity / 127; 27784 transport.schedule((t) => { 27785 if (drumType === "kick") { 27786 drum.triggerAttackRelease("C1", "8n", t, velocity); 27787 } else if (drumType === "tom") { 27788 drum.triggerAttackRelease("G1", "8n", t, velocity); 27789 } else if (drumType === "hihat" || drumType === "ride") { 27790 drum.triggerAttackRelease("16n", t, velocity * 0.3); 27791 } else if (drumType === "crash") { 27792 drum.triggerAttackRelease("4n", t, velocity * 0.4); 27793 } else if (drumType === "cowbell") { 27794 drum.triggerAttackRelease("16n", t, velocity * 0.5); 27795 } else { 27796 drum.triggerAttackRelease("16n", t, velocity); 27797 } 27798 }, time); 27799 }); 27800 } else if (track.type === "audio" && track.audioData?.buffer) { 27801 const toneBuffer = new ToneAudioBuffer(track.audioData.buffer); 27802 const player = new Player(toneBuffer).connect(channel); 27803 player.start(0); 27804 } 27805 }); 27806 transport.start(); 27807 }, duration); 27808 setProgress(50); 27809 setStatus("Encoding WAV..."); 27810 const wavBlob = audioBufferToWav(buffer); 27811 setProgress(100); 27812 setStatus("Download starting..."); 27813 const url = URL.createObjectURL(wavBlob); 27814 const a = document.createElement("a"); 27815 a.href = url; 27816 const filename = state.projectName?.trim() ? `${state.projectName.trim().replace(/[^a-zA-Z0-9-_]/g, "-")}.wav` : "austnnet-midi.wav"; 27817 a.download = filename; 27818 document.body.appendChild(a); 27819 a.click(); 27820 document.body.removeChild(a); 27821 URL.revokeObjectURL(url); 27822 setStatus("Export complete!"); 27823 setTimeout(() => { 27824 setStatus(""); 27825 setProgress(0); 27826 }, 2e3); 27827 } catch (error) { 27828 console.error("Export failed:", error); 27829 setStatus(`Export failed: ${error.message}`); 27830 setTimeout(() => { 27831 setStatus(""); 27832 setProgress(0); 27833 }, 3e3); 27834 } finally { 27835 setIsExporting(false); 27836 } 27837 }, [isExporting, hasContent, state]); 27838 return /* @__PURE__ */ import_react13.default.createElement("div", { style: styles11.container }
27838, /* @__PURE__ */ import_react13.default.createElement("span", { style: styles11.title }, "Export"), /* @__PURE__ */ import_react13.default.createElement( 27839 "button", 27840 { 27841 style: { 27842 ...styles11.button, 27843 ...styles11.exportButton, 27844 opacity: isExporting || !state.audioInitialized ? 0.6 : 1, 27845 cursor: isExporting ? "wait" : "pointer" 27846 }, 27847 onClick: handleExportWav, 27848 disabled: isExporting || !state.audioInitialized 27849 }, 27850 isExporting ? "Exporting..." : "Export WAV" 27851 ), !hasContent && !isExporting && /* @__PURE__ */ import_react13.default.createElement("span", { style: { ...styles11.status, color: "rgba(255,255,255,0.4)" } }, "Add notes to export"), (isExporting || progress > 0) && /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement("div", { style: styles11.progress }, /* @__PURE__ */ import_react13.default.createElement("div", { style: { ...styles11.progressBar, width: `${progress}%` } })), /* @__PURE__ */ import_react13.default.createElement("span", { style: styles11.status }, status))); 27852} 27853
27854// app/javascript/components/daw/components/RecordingPanel.jsx 27855var import_react14 = __toESM(require_react()); 27856
vendor: 12,223 bytes, lines 27857-28205
27857// node_modules/pitchy/index.js 27858var import_fft = __toESM(require_fft(), 1); 27859var Autocorrelator = class _Autocorrelator { 27860 /** @private @readonly @type {number} */ 27861 _inputLength; 27862 /** @private @type {FFT} */ 27863 _fft; 27864 /** @private @type {(size: number) => T} */ 27865 _bufferSupplier; 27866 /** @private @type {T} */ 27867 _paddedInputBuffer; 27868 /** @private @type {T} */ 27869 _transformBuffer; 27870 /** @private @type {T} */ 27871 _inverseBuffer; 27872 /** 27873 * A helper method to create an {@link Autocorrelator} using 27874 * {@link Float32Array} buffers. 27875 * 27876 * @param inputLength {number} the input array length to support 27877 * @returns {Autocorrelator<Float32Array>} 27878 */ 27879 static forFloat32Array(inputLength) { 27880 return new _Autocorrelator( 27881 inputLength, 27882 (length) => new Float32Array(length) 27883 ); 27884 } 27885 /** 27886 * A helper method to create an {@link Autocorrelator} using 27887 * {@link Float64Array} buffers. 27888 * 27889 * @param inputLength {number} the input array length to support 27890 * @returns {Autocorrelator<Float64Array>} 27891 */ 27892 static forFloat64Array(inputLength) { 27893 return new _Autocorrelator( 27894 inputLength, 27895 (length) => new Float64Array(length) 27896 ); 27897 } 27898 /** 27899 * A helper method to create an {@link Autocorrelator} using `number[]` 27900 * buffers. 27901 * 27902 * @param inputLength {number} the input array length to support 27903 * @returns {Autocorrelator<number[]>} 27904 */ 27905 static forNumberArray(inputLength) { 27906 return new _Autocorrelator(inputLength, (length) => Array(length)); 27907 } 27908 /** 27909 * Constructs a new {@link Autocorrelator} able to handle input arrays of the 27910 * given length. 27911 * 27912 * @param inputLength {number} the input array length to support. This 27913 * `Autocorrelator` will only support operation on arrays of this length. 27914 * @param bufferSupplier {(length: number) => T} the function to use for 27915 * creating buffers, accepting the length of the buffer to create and 27916 * returning a new buffer of that length. The values of the returned buffer 27917 * need not be initialized in any particular way. 27918 */ 27919 constructor(inputLength, bufferSupplier) { 27920 if (inputLength < 1) { 27921 throw new Error(`Input length must be at least one`); 27922 } 27923 this._inputLength = inputLength; 27924 this._fft = new import_fft.default(ceilPow2(2 * inputLength)); 27925 this._bufferSupplier = bufferSupplier; 27926 this._paddedInputBuffer = this._bufferSupplier(this._fft.size); 27927 this._transformBuffer = this._bufferSupplier(2 * this._fft.size); 27928 this._inverseBuffer = this._bufferSupplier(2 * this._fft.size); 27929 } 27930 /** 27931 * Returns the supported input length. 27932 * 27933 * @returns {number} the supported input length 27934 */ 27935 get inputLength() { 27936 return this._inputLength; 27937 } 27938 /** 27939 * Autocorrelates the given input data. 27940 * 27941 * @param input {ArrayLike<number>} the input data to autocorrelate 27942 * @param output {T} the output buffer into which to write the autocorrelated 27943 * data. If not provided, a new buffer will be created. 27944 * @returns {T} `output` 27945 */ 27946 autocorrelate(input, output = this._bufferSupplier(input.length)) { 27947 if (input.length !== this._inputLength) { 27948 throw new Error( 27949 `Input must have length ${this._inputLength} but had length ${input.length}` 27950 ); 27951 } 27952 for (let i = 0; i < input.length; i++) { 27953 this._paddedInputBuffer[i] = input[i]; 27954 } 27955 for (let i = input.length; i < this._paddedInputBuffer.length; i++) { 27956 this._paddedInputBuffer[i] = 0; 27957 } 27958 this._fft.realTransform(this._transformBuffer, this._paddedInputBuffer); 27959 this._fft.completeSpectrum(this._transformBuffer); 27960 const tb = this._transformBuffer; 27961 for (let i = 0; i < tb.length; i += 2) { 27962 tb[i] = tb[i] * tb[i] + tb[i + 1] * tb[i + 1]; 27963 tb[i + 1] = 0; 27964 } 27965 this._fft.inverseTransform(this._inverseBuffer, this._transformBuffer); 27966 for (let i = 0; i < input.length; i++) { 27967 output[i] = this._inverseBuffer[2 * i]; 27968 } 27969 return output; 27970 } 27971}; 27972function getKeyMaximumIndices(input) { 27973 const keyIndices = []; 27974 let lookingForMaximum = false; 27975 let max = -Infinity; 27976 let maxIndex = -1; 27977 for (let i = 1; i < input.length - 1; i++) { 27978 if (input[i - 1] <= 0 && input[i] > 0) { 27979 lookingForMaximum = true; 27980 maxIndex = i; 27981 max = input[i]; 27982 } else if (input[i - 1] > 0 && input[i] <= 0) { 27983 lookingForMaximum = false; 27984 if (maxIndex !== -1) { 27985 keyIndices.push(maxIndex); 27986 } 27987 } else if (lookingForMaximum && input[i] > max) { 27988 max = input[i]; 27989 maxIndex = i; 27990 } 27991 } 27992 return keyIndices; 27993} 27994function refineResultIndex(index, data) { 27995 const [x0, x1, x2] = [index - 1, index, index + 1]; 27996 const [y0, y1, y2] = [data[x0], data[x1], data[x2]]; 27997 const a = y0 / 2 - y1 + y2 / 2; 27998 const b = -(y0 / 2) * (x1 + x2) + y1 * (x0 + x2) - y2 / 2 * (x0 + x1); 27999 const c = y0 * x1 * x2 / 2 - y1 * x0 * x2 + y2 * x0 * x1 / 2; 28000 const xMax = -b / (2 * a); 28001 const yMax = a * xMax * xMax + b * xMax + c; 28002 return [xMax, yMax]; 28003} 28004var PitchDetector = class _PitchDetector { 28005 /** @private @type {Autocorrelator<T>} */ 28006 _autocorrelator; 28007 /** @private @type {T} */ 28008 _nsdfBuffer; 28009 /** @private @type {number} */ 28010 _clarityThreshold = 0.9; 28011 /** @private @type {number} */ 28012 _minVolumeAbsolute = 0; 28013 /** @private @type {number} */ 28014 _maxInputAmplitude = 1; 28015 /** 28016 * A helper method to create an {@link PitchDetector} using {@link Float32Array} buffers. 28017 * 28018 * @param inputLength {number} the input array length to support 28019 * @returns {PitchDetector<Float32Array>} 28020 */ 28021 static forFloat32Array(inputLength) { 28022 return new _PitchDetector(inputLength, (length) => new Float32Array(length)); 28023 } 28024 /** 28025 * A helper method to create an {@link PitchDetector} using {@link Float64Array} buffers. 28026 * 28027 * @param inputLength {number} the input array length to support 28028 * @returns {PitchDetector<Float64Array>} 28029 */ 28030 static forFloat64Array(inputLength) { 28031 return new _PitchDetector(inputLength, (length) => new Float64Array(length)); 28032 } 28033 /** 28034 * A helper method to create an {@link PitchDetector} using `number[]` buffers. 28035 * 28036 * @param inputLength {number} the input array length to support 28037 * @returns {PitchDetector<number[]>} 28038 */ 28039 static forNumberArray(inputLength) { 28040 return new _PitchDetector(inputLength, (length) => Array(length)); 28041 } 28042 /** 28043 * Constructs a new {@link PitchDetector} able to handle input arrays of the 28044 * given length. 28045 * 28046 * @param inputLength {number} the input array length to support. This 28047 * `PitchDetector` will only support operation on arrays of this length. 28048 * @param bufferSupplier {(inputLength: number) => T} the function to use for 28049 * creating buffers, accepting the length of the buffer to create and 28050 * returning a new buffer of that length. The values of the returned buffer 28051 * need not be initialized in any particular way. 28052 */ 28053 constructor(inputLength, bufferSupplier) { 28054 this._autocorrelator = new Autocorrelator(inputLength, bufferSupplier); 28055 this._nsdfBuffer = bufferSupplier(inputLength); 28056 } 28057 /** 28058 * Returns the supported input length. 28059 * 28060 * @returns {number} the supported input length 28061 */ 28062 get inputLength() { 28063 return this._autocorrelator.inputLength; 28064 } 28065 /** 28066 * Sets the clarity threshold used when identifying the correct pitch (the constant 28067 * `k` from the MPM paper). The value must be between 0 (exclusive) and 1 28068 * (inclusive), with the most suitable range being between 0.8 and 1. 28069 * 28070 * @param threshold {number} the clarity threshold 28071 */ 28072 set clarityThreshold(threshold) { 28073 if (!Number.isFinite(threshold) || threshold <= 0 || threshold > 1) { 28074 throw new Error("clarityThreshold must be a number in the range (0, 1]"); 28075 } 28076 this._clarityThreshold = threshold; 28077 } 28078 /** 28079 * Sets the minimum detectable volume, as an absolute number between 0 and 28080 * `maxInputAmplitude`, inclusive, to consider in a sample when detecting the 28081 * pitch. If a sample fails to meet this minimum volume, `findPitch` will 28082 * return a clarity of 0. 28083 * 28084 * Volume is calculated as the RMS (root mean square) of the input samples. 28085 * 28086 * @param volume {number} the minimum volume as an absolute amplitude value 28087 */ 28088 set minVolumeAbsolute(volume) { 28089 if (!Number.isFinite(volume) || volume < 0 || volume > this._maxInputAmplitude) { 28090 throw new Error( 28091 `minVolumeAbsolute must be a number in the range [0, ${this._maxInputAmplitude}]` 28092 ); 28093 } 28094 this._minVolumeAbsolute = volume; 28095 } 28096 /** 28097 * Sets the minimum volume using a decibel measurement. Must be less than or 28098 * equal to 0: 0 indicates the loudest possible sound (see 28099 * `maxInputAmplitude`), -10 is a sound with a tenth of the volume of the 28100 * loudest possible sound, etc. 28101 * 28102 * Volume is calculated as the RMS (root mean square) of the input samples. 28103 * 28104 * @param db {number} the minimum volume in decibels, with 0 being the loudest 28105 * sound 28106 */ 28107 set minVolumeDecibels(db) { 28108 if (!Number.isFinite(db) || db > 0) { 28109 throw new Error("minVolumeDecibels must be a number <= 0"); 28110 } 28111 this._minVolumeAbsolute = this._maxInputAmplitude * 10 ** (db / 10); 28112 } 28113 /** 28114 * Sets the maximum amplitude of an input reading. Must be greater than 0. 28115 * 28116 * @param amplitude {number} the maximum amplitude (absolute value) of an input reading 28117 */ 28118 set maxInputAmplitude(amplitude) { 28119 if (!Number.isFinite(amplitude) || amplitude <= 0) { 28120 throw new Error("maxInputAmplitude must be a number > 0"); 28121 } 28122 this._maxInputAmplitude = amplitude; 28123 } 28124 /** 28125 * Returns the pitch detected using McLeod Pitch Method (MPM) along with a 28126 * measure of its clarity. 28127 * 28128 * The clarity is a value between 0 and 1 (potentially inclusive) that 28129 * represents how "clear" the pitch was. A clarity value of 1 indicates that 28130 * the pitch was very distinct, while lower clarity values indicate less 28131 * definite pitches. 28132 * 28133 * @param input {ArrayLike<number>} the time-domain input data 28134 * @param sampleRate {number} the sample rate at which the input data was 28135 * collected 28136 * @returns {[number, number]} the detected pitch, in Hz, followed by the 28137 * clarity. If a pitch cannot be determined from the input, such as if the 28138 * volume is too low (see `minVolumeAbsolute` and `minVolumeDecibels`), this 28139 * will be `[0, 0]`. 28140 */ 28141 findPitch(input, sampleRate) { 28142 if (this._belowMinimumVolume(input)) return [0, 0]; 28143 this._nsdf(input); 28144 const keyMaximumIndices = getKeyMaximumIndices(this._nsdfBuffer); 28145 if (keyMaximumIndices.length === 0) { 28146 return [0, 0]; 28147 } 28148 const nMax = Math.max(...keyMaximumIndices.map((i) => this._nsdfBuffer[i])); 28149 const resultIndex = keyMaximumIndices.find( 28150 (i) => this._nsdfBuffer[i] >= this._clarityThreshold * nMax 28151 ); 28152 const [refinedResultIndex, clarity] = refineResultIndex( 28153 // @ts-expect-error resultIndex is guaranteed to be defined 28154 resultIndex, 28155 this._nsdfBuffer 28156 ); 28157 return [sampleRate / refinedResultIndex, Math.min(clarity, 1)]; 28158 } 28159 /** 28160 * Returns whether the input audio data is below the minimum volume allowed by 28161 * the pitch detector. 28162 * 28163 * @private 28164 * @param input {ArrayLike<number>} 28165 * @returns {boolean} 28166 */ 28167 _belowMinimumVolume(input) { 28168 if (this._minVolumeAbsolute === 0) return false; 28169 let squareSum = 0; 28170 for (let i = 0; i < input.length; i++) { 28171 squareSum += input[i] ** 2; 28172 } 28173 return Math.sqrt(squareSum / input.length) < this._minVolumeAbsolute; 28174 } 28175 /** 28176 * Computes the NSDF of the input and stores it in the internal buffer. This 28177 * is equation (9) in the McLeod pitch method paper. 28178 * 28179 * @private 28180 * @param input {ArrayLike<number>} 28181 */ 28182 _nsdf(input) { 28183 this._autocorrelator.autocorrelate(input, this._nsdfBuffer); 28184 let m = 2 * this._nsdfBuffer[0]; 28185 let i; 28186 for (i = 0; i < this._nsdfBuffer.length && m > 0; i++) { 28187 this._nsdfBuffer[i] = 2 * this._nsdfBuffer[i] / m; 28188 m -= input[i] ** 2 + input[input.length - i - 1] ** 2; 28189 } 28190 for (; i < this._nsdfBuffer.length; i++) { 28191 this._nsdfBuffer[i] = 0; 28192 } 28193 } 28194}; 28195function ceilPow2(v) { 28196 v--; 28197 v |= v >> 1; 28198 v |= v >> 2; 28199 v |= v >> 4; 28200 v |= v >> 8; 28201 v |= v >> 16; 28202 v++; 28203 return v; 28204} 28205
28206// app/javascript/components/daw/components/RecordingPanel.jsx 28207var styles12 = { 28208 container: { 28209 display: "flex", 28210 flexDirection: "column", 28211 gap: "0.75rem", 28212 padding: "1rem", 28213 background: "rgba(255,255,255,0.03)", 28214 border: "1px solid rgba(255,255,255,0.08)", 28215 borderRadius: "0.5rem" 28216 }, 28217 header: { 28218 display: "flex", 28219 justifyContent: "space-between", 28220 alignItems: "center" 28221 }, 28222 title: { 28223 fontSize: "0.875rem", 28224 color: "rgba(255,255,255,0.6)", 28225 textTransform: "uppercase", 28226 letterSpacing: "0.05em", 28227 fontWeight: 500 28228 }, 28229 waveformContainer: { 28230 height: "80px", 28231 background: "rgba(0,0,0,0.3)", 28232 borderRadius: "0.375rem", 28233 position: "relative", 28234 overflow: "hidden" 28235 }, 28236 waveformCanvas: { 28237 width: "100%", 28238 height: "100%" 28239 }, 28240 pitchDisplay: { 28241 position: "absolute", 28242 top: "8px", 28243 right: "8px", 28244 padding: "4px 8px", 28245 background: "rgba(0,0,0,0.6)", 28246 borderRadius: "4px", 28247 fontSize: "0.8rem", 28248 fontFamily: "monospace", 28249 color: "var(--accent-color, #10b981)" 28250 }, 28251 controls: { 28252 display: "flex", 28253 gap: "0.75rem", 28254 alignItems: "center" 28255 }, 28256 recordButton: { 28257 width: "48px", 28258 height: "48px", 28259 borderRadius: "50%", 28260 border: "2px solid rgba(239, 68, 68, 0.5)", 28261 background: "rgba(239, 68, 68, 0.2)", 28262 cursor: "pointer", 28263 display: "flex", 28264 alignItems: "center", 28265 justifyContent: "center", 28266 transition: "all 0.2s", 28267 flexShrink: 0 28268 }, 28269 recordButtonActive: { 28270 background: "rgba(239, 68, 68, 0.6)", 28271 boxShadow: "0 0 20px rgba(239, 68, 68, 0.4)" 28272 }, 28273 recordIcon: { 28274 width: "20px", 28275 height: "20px", 28276 borderRadius: "50%", 28277 background: "#ef4444" 28278 }, 28279 stopIcon: { 28280 width: "18px", 28281 height: "18px", 28282 background: "#ef4444", 28283 borderRadius: "3px" 28284 }, 28285 controlGroup: { 28286 display: "flex", 28287 flexDirection: "column", 28288 gap: "0.25rem", 28289 flex: 1 28290 }, 28291 label: { 28292 fontSize: "0.7rem", 28293 color: "rgba(255,255,255,0.5)", 28294 textTransform: "uppercase" 28295 }, 28296 toggleButton: { 28297 padding: "0.5rem 1rem", 28298 background: "rgba(255,255,255,0.06)", 28299 border: "1px solid rgba(255,255,255,0.1)", 28300 borderRadius: "0.375rem", 28301 color: "rgba(255,255,255,0.8)", 28302 fontSize: "0.8rem", 28303 cursor: "pointer", 28304 transition: "all 0.2s" 28305 }, 28306 toggleActive: { 28307 background: "rgba(16, 185, 129, 0.2)", 28308 borderColor: "rgba(16, 185, 129, 0.4)", 28309 color: "#10b981" 28310 }, 28311 status: { 28312 fontSize: "0.8rem", 28313 color: "rgba(255,255,255,0.6)", 28314 textAlign: "center" 28315 }, 28316 audioPlayer: { 28317 width: "100%", 28318 height: "36px" 28319 }, 28320 processButton: { 28321 padding: "0.5rem 1rem", 28322 background: "linear-gradient(45deg, #10b981, #059669)", 28323 border: "none", 28324 borderRadius: "0.375rem", 28325 color: "white", 28326 fontSize: "0.8rem", 28327 fontWeight: 500, 28328 cursor: "pointer", 28329 transition: "all 0.2s" 28330 } 28331}; 28332var NOTE_NAMES2 = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]; 28333function frequencyToNote(freq) { 28334 if (freq <= 0) return { note: "-", octave: 0, cents: 0 }; 28335 const midiNote = 12 * Math.log2(freq / 440) + 69; 28336 const roundedNote = Math.round(midiNote); 28337 const cents = Math.round((midiNote - roundedNote) * 100); 28338 const noteName = NOTE_NAMES2[roundedNote % 12]; 28339 const octave = Math.floor(roundedNote / 12) - 1; 28340 return { note: noteName, octave, cents, midi: roundedNote }; 28341} 28342function nearestNoteFrequency(freq) { 28343 const midiNote = Math.round(12 * Math.log2(freq / 440) + 69); 28344 return 440 * Math.pow(2, (midiNote - 69) / 12); 28345} 28346function RecordingPanel() { 28347 const { actions } = useDAW(); 28348 const [isRecording, setIsRecording] = (0, import_react14.useState)(false); 28349 const [hasRecording, setHasRecording] = (0, import_react14.useState)(false); 28350 const [audioUrl, setAudioUrl] = (0, import_react14.useState)(null); 28351 const [processedUrl, setProcessedUrl] = (0, import_react14.useState)(null); 28352 const [duration, setDuration] = (0, import_react14.useState)(0); 28353 const [error, setError] = (0, import_react14.useState)(null); 28354 const [autotuneEnabled, setAutotuneEnabled] = (0, import_react14.useState)(true); 28355 const [currentPitch, setCurrentPitch] = (0, import_react14.useState)(null); 28356 const [isProcessing, setIsProcessing] = (0, import_react14.useState)(false); 28357 const [addedToTrack, setAddedToTrack] = (0, import_react14.useState)(false); 28358 const mediaRecorderRef = (0, import_react14.useRef)(null); 28359 const chunksRef = (0, import_react14.useRef)([]); 28360 const streamRef = (0, import_react14.useRef)(null); 28361 const analyserRef = (0, import_react14.useRef)(null); 28362 const canvasRef = (0, import_react14.useRef)(null); 28363 const animationRef = (0, import_react14.useRef)(null); 28364 const startTimeRef = (0, import_react14.useRef)(null); 28365 const audioContextRef = (0, import_react14.useRef)(null); 28366 const pitchDetectorRef = (0, import_react14.useRef)(null); 28367 const rawAudioBufferRef = (0, import_react14.useRef)(null); 28368 const drawWaveform = (0, import_react14.useCallback)(() => { 28369 if (!analyserRef.current || !canvasRef.current) return; 28370 const canvas = canvasRef.current; 28371 const ctx = canvas.getContext("2d"); 28372 const analyser = analyserRef.current; 28373 const bufferLength = analyser.fftSize; 28374 const dataArray = new Float32Array(bufferLength); 28375 const draw = () => { 28376 if (!isRecording) return; 28377 animationRef.current = requestAnimationFrame(draw); 28378 analyser.getFloatTimeDomainData(dataArray); 28379 if (pitchDetectorRef.current) { 28380 const [pitch, clarity] = pitchDetectorRef.current.findPitch( 28381 dataArray, 28382 audioContextRef.current.sampleRate 28383 ); 28384 if (clarity > 0.9 && pitch > 60 && pitch < 2e3) { 28385 const noteInfo = frequencyToNote(pitch); 28386 setCurrentPitch(noteInfo); 28387 } 28388 } 28389 ctx.fillStyle = "rgba(0, 0, 0, 0.3)"; 28390 ctx.fillRect(0, 0, canvas.width, canvas.height); 28391 ctx.lineWidth = 2; 28392 ctx.strokeStyle = "#ef4444"; 28393 ctx.beginPath(); 28394 const sliceWidth = canvas.width / bufferLength; 28395 let x = 0; 28396 for (let i = 0; i < bufferLength; i++) { 28397 const v = dataArray[i]; 28398 const y = (v + 1) * canvas.height / 2; 28399 if (i === 0) { 28400 ctx.moveTo(x, y); 28401 } else { 28402 ctx.lineTo(x, y); 28403 }
28404 x += sliceWidth; 28405 } 28406 ctx.stroke(); 28407 if (startTimeRef.current) { 28408 setDuration(Math.floor((Date.now() - startTimeRef.current) / 1e3)); 28409 } 28410 }; 28411 draw(); 28412 }, [isRecording]); 28413 const startRecording = (0, import_react14.useCallback)(async () => { 28414 try { 28415 setError(null); 28416 setCurrentPitch(null); 28417 chunksRef.current = []; 28418 setProcessedUrl(null); 28419 setAddedToTrack(false); 28420 const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); 28421 streamRef.current = stream; 28422 audioContextRef.current = new AudioContext(); 28423 const source = audioContextRef.current.createMediaStreamSource(stream); 28424 analyserRef.current = audioContextRef.current.createAnalyser(); 28425 analyserRef.current.fftSize = 2048; 28426 source.connect(analyserRef.current); 28427 pitchDetectorRef.current = PitchDetector.forFloat32Array(analyserRef.current.fftSize); 28428 const mediaRecorder = new MediaRecorder(stream); 28429 mediaRecorderRef.current = mediaRecorder; 28430 mediaRecorder.ondataavailable = (e) => { 28431 if (e.data.size > 0) { 28432 chunksRef.current.push(e.data); 28433 } 28434 }; 28435 mediaRecorder.onstop = async () => { 28436 const blob = new Blob(chunksRef.current, { type: "audio/webm" }); 28437 const url = URL.createObjectURL(blob); 28438 setAudioUrl(url); 28439 setHasRecording(true); 28440 const arrayBuffer = await blob.arrayBuffer(); 28441 const audioContext = new AudioContext(); 28442 rawAudioBufferRef.current = await audioContext.decodeAudioData(arrayBuffer); 28443 }; 28444 mediaRecorder.start(); 28445 startTimeRef.current = Date.now(); 28446 setIsRecording(true); 28447 setDuration(0); 28448 if (canvasRef.current) { 28449 const canvas = canvasRef.current; 28450 canvas.width = canvas.offsetWidth * 2; 28451 canvas.height = canvas.offsetHeight * 2; 28452 canvas.getContext("2d").scale(2, 2); 28453 } 28454 } catch (err) { 28455 setError("Microphone access denied"); 28456 console.error("Recording error:", err); 28457 } 28458 }, []); 28459 const stopRecording = (0, import_react14.useCallback)(() => { 28460 if (mediaRecorderRef.current && isRecording) { 28461 mediaRecorderRef.current.stop(); 28462 setIsRecording(false); 28463 setCurrentPitch(null); 28464 if (streamRef.current) { 28465 streamRef.current.getTracks().forEach((track) => track.stop()); 28466 } 28467 if (animationRef.current) { 28468 cancelAnimationFrame(animationRef.current); 28469 } 28470 if (audioContextRef.current) { 28471 audioContextRef.current.close(); 28472 } 28473 } 28474 }, [isRecording]); 28475 const applyAutotune = (0, import_react14.useCallback)(async () => { 28476 if (!rawAudioBufferRef.current) return; 28477 setIsProcessing(true); 28478 try { 28479 const inputBuffer = rawAudioBufferRef.current; 28480 const sampleRate = inputBuffer.sampleRate; 28481 const channelData = inputBuffer.getChannelData(0); 28482 const outputData = new Float32Array(channelData.length); 28483 const windowSize = 2048; 28484 const hopSize = 256; 28485 const detector = PitchDetector.forFloat32Array(windowSize); 28486 const hannWindow = new Float32Array(windowSize); 28487 for (let i = 0; i < windowSize; i++) { 28488 hannWindow[i] = 0.5 * (1 - Math.cos(2 * Math.PI * i / windowSize)); 28489 } 28490 const accumulator = new Float32Array(channelData.length); 28491 const windowSum = new Float32Array(channelData.length); 28492 for (let i = 0; i < channelData.length - windowSize; i += hopSize) { 28493 const window3 = channelData.slice(i, i + windowSize); 28494 const [pitch, clarity] = detector.findPitch(window3, sampleRate); 28495 let processedWindow = new Float32Array(windowSize); 28496 if (clarity > 0.85 && pitch > 80 && pitch < 1e3) { 28497 const targetPitch = nearestNoteFrequency(pitch); 28498 const shiftRatio = targetPitch / pitch; 28499 for (let j = 0; j < windowSize; j++) { 28500 const srcPos = j / shiftRatio; 28501 const srcIndex = Math.floor(srcPos); 28502 const frac = srcPos - srcIndex; 28503 if (srcIndex + 1 < windowSize) { 28504 processedWindow[j] = window3[srcIndex] * (1 - frac) + window3[srcIndex + 1] * frac; 28505 } else if (srcIndex < windowSize) { 28506 processedWindow[j] = window3[srcIndex]; 28507 } 28508 } 28509 for (let j = 0; j < windowSize; j++) { 28510 processedWindow[j] *= hannWindow[j]; 28511 } 28512 } else { 28513 for (let j = 0; j < windowSize; j++) { 28514 processedWindow[j] = window3[j] * hannWindow[j]; 28515 } 28516 } 28517 for (let j = 0; j < windowSize && i + j < accumulator.length; j++) { 28518 accumulator[i + j] += processedWindow[j]; 28519 windowSum[i + j] += hannWindow[j]; 28520 } 28521 } 28522 for (let i = 0; i < outputData.length; i++) { 28523 if (windowSum[i] > 1e-3) { 28524 outputData[i] = accumulator[i] / windowSum[i]; 28525 } else { 28526 outputData[i] = channelData[i]; 28527 } 28528 } 28529 const offlineContext = new OfflineAudioContext(1, outputData.length, sampleRate); 28530 const processedBuffer = offlineContext.createBuffer(1, outputData.length, sampleRate); 28531 processedBuffer.getChannelData(0).set(outputData); 28532 const wavBlob = audioBufferToWav2(processedBuffer); 28533 const url = URL.createObjectURL(wavBlob); 28534 setProcessedUrl(url); 28535 } catch (err) { 28536 console.error("Autotune processing error:", err); 28537 setError("Processing failed"); 28538 } finally { 28539 setIsProcessing(false); 28540 } 28541 }, []); 28542 const addToTrack = (0, import_react14.useCallback)(() => { 28543 if (!rawAudioBufferRef.current) return; 28544 const urlToUse = processedUrl || audioUrl; 28545 const audioData = { 28546 url: urlToUse, 28547 buffer: rawAudioBufferRef.current, 28548 duration: rawAudioBufferRef.current.duration 28549 }; 28550 const trackName = processedUrl ? "Recording (Tuned)" : "Recording"; 28551 actions.addAudioTrack(trackName, audioData); 28552 setAddedToTrack(true); 28553 }, [processedUrl, audioUrl, actions]); 28554 function audioBufferToWav2(buffer) { 28555 const numChannels = buffer.numberOfChannels; 28556 const sampleRate = buffer.sampleRate; 28557 const bytesPerSample = 2; 28558 const blockAlign = numChannels * bytesPerSample; 28559 const dataSize = buffer.length * blockAlign; 28560 const wavBuffer = new ArrayBuffer(44 + dataSize); 28561 const view = new DataView(wavBuffer); 28562 writeString2(view, 0, "RIFF"); 28563 view.setUint32(4, 36 + dataSize, true); 28564 writeString2(view, 8, "WAVE"); 28565 writeString2(view, 12, "fmt "); 28566 view.setUint32(16, 16, true); 28567 view.setUint16(20, 1, true); 28568 view.setUint16(22, numChannels, true); 28569 view.setUint32(24, sampleRate, true); 28570 view.setUint32(28, sampleRate * blockAlign, true); 28571 view.setUint16(32, blockAlign, true); 28572 view.setUint16(34, 16, true); 28573 writeString2(view, 36, "data"); 28574 view.setUint32(40, dataSize, true); 28575 const channels = []; 28576 for (let i = 0; i < numChannels; i++) { 28577 channels.push(buffer.getChannelData(i)); 28578 } 28579 let pos = 44; 28580 for (let i = 0; i < buffer.length; i++) { 28581 for (let ch = 0; ch < numChannels; ch++) { 28582 const sample = Math.max(-1, Math.min(1, channels[ch][i])); 28583 view.setInt16(pos, sample < 0 ? sample * 32768 : sample * 32767, true); 28584 pos += 2; 28585 } 28586 } 28587 return new Blob([wavBuffer], { type: "audio/wav" }); 28588 } 28589 function writeString2(view, offset, string) { 28590 for (let i = 0; i < string.length; i++) { 28591 view.setUint8(offset + i, string.charCodeAt(i)); 28592 } 28593 } 28594 (0, import_react14.useEffect)(() => { 28595 if (isRecording) { 28596 drawWaveform(); 28597 } 28598 return () => { 28599 if (animationRef.current) { 28600 cancelAnimationFrame(animationRef.current); 28601 } 28602 }; 28603 }, [isRecording, drawWaveform]); 28604 (0, import_react14.useEffect)(() => { 28605 return () => { 28606 if (audioUrl) URL.revokeObjectURL(audioUrl); 28607 if (processedUrl) URL.revokeObjectURL(processedUrl); 28608 if (streamRef.current) {
28609 streamRef.current.getTracks().forEach((track) => track.stop()); 28610 } 28611 if (audioContextRef.current && audioContextRef.current.state !== "closed") { 28612 audioContextRef.current.close(); 28613 } 28614 }; 28615 }, []); 28616 const formatDuration = (seconds) => { 28617 const mins = Math.floor(seconds / 60); 28618 const secs = seconds % 60; 28619 return `${mins}:${secs.toString().padStart(2, "0")}`; 28620 }; 28621 return /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.container }, /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.header }, /* @__PURE__ */ import_react14.default.createElement("span", { style: styles12.title }, "Recording"), /* @__PURE__ */ import_react14.default.createElement( 28622 "button", 28623 { 28624 style: { 28625 ...styles12.toggleButton, 28626 ...autotuneEnabled ? styles12.toggleActive : {} 28627 }, 28628 onClick: () => setAutotuneEnabled(!autotuneEnabled) 28629 }, 28630 "Autotune ", 28631 autotuneEnabled ? "ON" : "OFF" 28632 )), /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.waveformContainer }, /* @__PURE__ */ import_react14.default.createElement("canvas", { ref: canvasRef, style: styles12.waveformCanvas }), currentPitch && isRecording && /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.pitchDisplay }, currentPitch.note, currentPitch.octave, /* @__PURE__ */ import_react14.default.createElement("span", { style: { fontSize: "0.6rem", marginLeft: "4px", opacity: 0.7 } }, currentPitch.cents > 0 ? "+" : "", currentPitch.cents, "\xA2"))), /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.controls }, /* @__PURE__ */ import_react14.default.createElement( 28633 "button", 28634 { 28635 style: { 28636 ...styles12.recordButton, 28637 ...isRecording ? styles12.recordButtonActive : {} 28638 }, 28639 onClick: isRecording ? stopRecording : startRecording, 28640 title: isRecording ? "Stop Recording" : "Start Recording" 28641 },
28642 isRecording ? /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.stopIcon }) : /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.recordIcon }) 28643 ), /* @__PURE__ */ import_react14.default.createElement("div", { style: styles12.controlGroup }, /* @__PURE__ */ import_react14.default.createElement("span", { style: styles12.status }, error ? /* @__PURE__ */ import_react14.default.createElement("span", { style: { color: "#ef4444" } }, error) : isRecording ? `Recording: ${formatDuration(duration)}` : hasRecording ? `Recorded: ${formatDuration(duration)}` : "Click to record")), hasRecording && autotuneEnabled && !processedUrl && /* @__PURE__ */ import_react14.default.createElement( 28644 "button", 28645 { 28646 style: { 28647 ...styles12.processButton, 28648 opacity: isProcessing ? 0.6 : 1 28649 }, 28650 onClick: applyAutotune, 28651 disabled: isProcessing 28652 }, 28653 isProcessing ? "Processing..." : "Apply Autotune" 28654 )), hasRecording && /* @__PURE__ */ import_react14.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" } }, audioUrl && /* @__PURE__ */ import_react14.default.createElement("div", null, /* @__PURE__ */ import_react14.default.createElement("span", { style: { fontSize: "0.7rem", color: "rgba(255,255,255,0.5)" } }, "Original:"), /* @__PURE__ */ import_react14.default.createElement("audio", { controls: true, src: audioUrl, style: styles12.audioPlayer })), processedUrl && /* @__PURE__ */ import_react14.default.createElement("div", null, /* @__PURE__ */ import_react14.default.createElement("span", { style: { fontSize: "0.7rem", color: "#10b981" } }, "Autotuned:"), /* @__PURE__ */ import_react14.default.createElement("audio", { controls: true, src: processedUrl, style: styles12.audioPlayer })), /* @__PURE__ */ import_react14.default.createElement( 28655 "button", 28656 { 28657 style: { 28658 ...styles12.processButton, 28659 opacity: addedToTrack ? 0.6 : 1, 28660 background: addedToTrack ? "rgba(255,255,255,0.1)" : "linear-gradient(45deg, #3b82f6, #2563eb)" 28661 }, 28662 onClick: addToTrack, 28663 disabled: addedToTrack 28664 }, 28665 addedToTrack ? "Added to Track" : "Add to Track" 28666 ))); 28667} 28668
28669// app/javascript/components/daw/components/MIDIPanel.jsx 28670var import_react16 = __toESM(require_react()); 28671
28672// app/javascript/components/daw/hooks/useMIDI.js 28673var import_react15 = __toESM(require_react()); 28674function useMIDI(onNoteOn, onNoteOff, onCC) { 28675 const [midiAccess, setMidiAccess] = (0, import_react15.useState)(null); 28676 const [midiInputs, setMidiInputs] = (0, import_react15.useState)([]); 28677 const [selectedInput, setSelectedInput] = (0, import_react15.useState)(null); 28678 const [isSupported2, setIsSupported] = (0, import_react15.useState)(false); 28679 const [error, setError] = (0, import_react15.useState)(null); 28680 const handlersRef = (0, import_react15.useRef)({ onNoteOn, onNoteOff, onCC }); 28681 (0, import_react15.useEffect)(() => { 28682 handlersRef.current = { onNoteOn, onNoteOff, onCC }; 28683 }, [onNoteOn, onNoteOff, onCC]); 28684 (0, import_react15.useEffect)(() => { 28685 if (!navigator.requestMIDIAccess) { 28686 setIsSupported(false); 28687 setError("Web MIDI API not supported in this browser"); 28688 return; 28689 } 28690 setIsSupported(true); 28691 navigator.requestMIDIAccess().then((access) => { 28692 setMidiAccess(access); 28693 updateInputs(access); 28694 access.onstatechange = () => { 28695 updateInputs(access); 28696 }; 28697 }).catch((err) => { 28698 setError(`MIDI access denied: ${err.message}`); 28699 }); 28700 }, []); 28701 const updateInputs = (0, import_react15.useCallback)((access) => { 28702 const inputs = []; 28703 access.inputs.forEach((input) => { 28704 inputs.push({ 28705 id: input.id, 28706 name: input.name || "Unknown Device", 28707 manufacturer: input.manufacturer, 28708 state: input.state 28709 }); 28710 }); 28711 setMidiInputs(inputs); 28712 if (inputs.length > 0 && !selectedInput) { 28713 setSelectedInput(inputs[0].id); 28714 } 28715 }, [selectedInput]); 28716 const handleMIDIMessage = (0, import_react15.useCallback)((event) => { 28717 const [status, data1, data2] = event.data; 28718 const channel = status & 15; 28719 const messageType = status & 240; 28720 switch (messageType) { 28721 case 144: 28722 if (data2 > 0) { 28723 handlersRef.current.onNoteOn?.(data1, data2, channel); 28724 } else { 28725 handlersRef.current.onNoteOff?.(data1, channel); 28726 } 28727 break; 28728 case 128: 28729 handlersRef.current.onNoteOff?.(data1, channel); 28730 break; 28731 case 176: 28732 handlersRef.current.onCC?.(data1, data2, channel); 28733 break; 28734 default: 28735 break; 28736 } 28737 }, []); 28738 (0, import_react15.useEffect)(() => { 28739 if (!midiAccess || !selectedInput) return; 28740 const input = midiAccess.inputs.get(selectedInput); 28741 if (!input) return; 28742 input.onmidimessage = handleMIDIMessage; 28743 return () => { 28744 input.onmidimessage = null; 28745 }; 28746 }, [midiAccess, selectedInput, handleMIDIMessage]); 28747 const selectInput = (0, import_react15.useCallback)((inputId) => { 28748 setSelectedInput(inputId); 28749 }, []); 28750 return { 28751 isSupported: isSupported2, 28752 error, 28753 midiInputs, 28754 selectedInput, 28755 selectInput 28756 }; 28757} 28758
28759// app/javascript/components/daw/components/MIDIPanel.jsx 28760var styles13 = { 28761 container: { 28762 display: "flex", 28763 flexDirection: "column", 28764 gap: "0.5rem" 28765 }, 28766 title: { 28767 fontSize: "0.75rem", 28768 color: "rgba(255,255,255,0.5)", 28769 textTransform: "uppercase", 28770 letterSpacing: "0.05em" 28771 }, 28772 select: { 28773 padding: "0.375rem 0.5rem", 28774 background: "rgba(255,255,255,0.05)", 28775 border: "1px solid rgba(255,255,255,0.1)", 28776 borderRadius: "0.25rem", 28777 color: "white", 28778 fontSize: "0.7rem" 28779 }, 28780 status: { 28781 fontSize: "0.65rem", 28782 color: "rgba(255,255,255,0.4)" 28783 }, 28784 noSupport: { 28785 fontSize: "0.7rem", 28786 color: "rgba(255,255,255,0.4)", 28787 fontStyle: "italic" 28788 }, 28789 indicator: { 28790 display: "inline-block", 28791 width: "8px", 28792 height: "8px", 28793 borderRadius: "50%", 28794 marginRight: "0.5rem" 28795 }, 28796 connected: { 28797 background: "#10b981", 28798 boxShadow: "0 0 6px #10b981" 28799 }, 28800 disconnected: { 28801 background: "rgba(255,255,255,0.2)" 28802 } 28803}; 28804function MIDIPanel({ onNoteOn, onNoteOff }) { 28805 const { isSupported: isSupported2, error, midiInputs, selectedInput, selectInput } = useMIDI( 28806 onNoteOn, 28807 onNoteOff, 28808 null 28809 // We don't need CC for now 28810 ); 28811 if (!isSupported2) { 28812 return /* @__PURE__ */ import_react16.default.createElement("div", { style: styles13.container }, /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.title }, "MIDI Input"), /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.noSupport }, "Web MIDI not supported in this browser")); 28813 } 28814 if (error) { 28815 return /* @__PURE__ */ import_react16.default.createElement("div", { style: styles13.container }, /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.title }, "MIDI Input"), /* @__PURE__ */ import_react16.default.createElement("span", { style: { ...styles13.noSupport, color: "#ef4444" } }, error)); 28816 } 28817 const selectedDevice = midiInputs.find((d) => d.id === selectedInput); 28818 return /* @__PURE__ */ import_react16.default.createElement("div", { style: styles13.container }, /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.title }, "MIDI Input"), midiInputs.length === 0 ? /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.noSupport }, "No MIDI devices detected") : /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, /* @__PURE__ */ import_react16.default.createElement( 28819 "select", 28820 { 28821 value: selectedInput || "", 28822 onChange: (e) => selectInput(e.target.value), 28823 style: styles13.select 28824 }, 28825 /* @__PURE__ */ import_react16.default.createElement("option", { value: "" }, "Select MIDI device..."), 28826 midiInputs.map((input) => /* @__PURE__ */ import_react16.default.createElement("option", { key: input.id, value: input.id }, input.name)) 28827 ), selectedDevice && /* @__PURE__ */ import_react16.default.createElement("span", { style: styles13.status }, /* @__PURE__ */ import_react16.default.createElement( 28828 "span", 28829 { 28830 style: { 28831 ...styles13.indicator, 28832 ...selectedDevice.state === "connected" ? styles13.connected : styles13.disconnected 28833 } 28834 } 28835 ), selectedDevice.state === "connected" ? "Connected" : "Disconnected"))); 28836} 28837
28838// app/javascript/components/daw/DAW.jsx 28839var styles14 = { 28840 container: { 28841 background: "rgba(255,255,255,0.03)", 28842 border: "1px solid rgba(255,255,255,0.08)", 28843 borderRadius: "0.5rem", 28844 overflow: "hidden" 28845 }, 28846 initOverlay: { 28847 position: "absolute", 28848 inset: 0, 28849 display: "flex", 28850 alignItems: "center", 28851 justifyContent: "center", 28852 background: "rgba(0,0,0,0.8)", 28853 zIndex: 50 28854 }, 28855 initButton: { 28856 padding: "1rem 2rem", 28857 fontSize: "1.25rem", 28858 fontWeight: 600, 28859 background: "linear-gradient(45deg, #10b981, #059669)", 28860 border: "none", 28861 borderRadius: "0.5rem", 28862 color: "white", 28863 cursor: "pointer", 28864 transition: "transform 0.2s, box-shadow 0.2s" 28865 }, 28866 section: { 28867 borderBottom: "1px solid rgba(255,255,255,0.08)" 28868 }, 28869 visualizerSection: { 28870 padding: "1rem", 28871 borderBottom: "1px solid rgba(255,255,255,0.08)", 28872 background: "rgba(0,0,0,0.2)" 28873 }, 28874 mainGrid: { 28875 display: "grid", 28876 gridTemplateColumns: "180px 1fr 360px", 28877 gap: "1px", 28878 background: "rgba(255,255,255,0.05)" 28879 }, 28880 panel: { 28881 background: "rgba(0,0,0,0.3)", 28882 padding: "1rem" 28883 }, 28884 bottomSection: { 28885 display: "flex", 28886 gap: "1px", 28887 background: "rgba(255,255,255,0.05)" 28888 }, 28889 bottomPanel: { 28890 background: "rgba(0,0,0,0.3)", 28891 padding: "1rem", 28892 flex: 1, 28893 display: "flex", 28894 gap: "1rem", 28895 flexWrap: "wrap", 28896 alignItems: "flex-start" 28897 } 28898}; 28899function DAWContent() { 28900 const { state, actions, getSelectedTrack } = useDAW(); 28901 const audioEngineRef = (0, import_react17.useRef)(null); 28902 const sequenceRef = (0, import_react17.useRef)(null); 28903 const initAudio = (0, import_react17.useCallback)(async () => { 28904 const engine = getAudioEngine(); 28905 const success = await engine.init(); 28906 if (success) { 28907 audioEngineRef.current = engine; 28908 actions.setAudioInitialized(true); 28909 state.tracks.forEach((track) => { 28910 if (track.type === "synth") { 28911 engine.createSynth(track.id, track.instrument, track.effects); 28912 } else if (track.type === "drums") { 28913 engine.createDrumSampler(track.id, track.effects); 28914 } else if (track.type === "pluck") { 28915 engine.createPluckSynth(track.id, track.instrument, track.effects); 28916 } else if (track.type === "fm") { 28917 engine.createFMSynth(track.id, track.instrument, track.effects); 28918 } else if (track.type === "am") { 28919 engine.createAMSynth(track.id, track.instrument, track.effects); 28920 } else if (track.type === "audio" && track.audioData?.buffer) { 28921 engine.createAudioPlayer(track.id, track.audioData.buffer, track.effects); 28922 } 28923 engine.setTrackVolume(track.id, track.volume); 28924 engine.setTrackPan(track.id, track.pan); 28925 engine.setTrackMute(track.id, track.muted); 28926 }); 28927 } 28928 }, [actions, state.tracks]); 28929 (0, import_react17.useEffect)(() => { 28930 if (audioEngineRef.current) { 28931 audioEngineRef.current.setBPM(state.bpm); 28932 } 28933 }, [state.bpm]); 28934 (0, import_react17.useEffect)(() => { 28935 if (audioEngineRef.current) { 28936 audioEngineRef.current.setLoop(state.isLooping, state.loopStart, state.loopEnd); 28937 audioEngineRef.current.setLoopPoints(state.loopStart, state.loopEnd, state.stepsPerMeasure); 28938 } 28939 }, [state.isLooping, state.loopStart, state.loopEnd, state.stepsPerMeasure]); 28940 (0, import_react17.useEffect)(() => { 28941 if (audioEngineRef.current) { 28942 audioEngineRef.current.setMasterVolume(state.masterVolume); 28943 } 28944 }, [state.masterVolume]); 28945 const ensureInstrumentsReady = (0, import_react17.useCallback)((engine, tracks) => { 28946 const validTrackIds = tracks.map((t) => t.id); 28947 engine.disposeOrphanedInstruments(validTrackIds); 28948 tracks.forEach((track) => { 28949 if (!engine.hasInstrument(track.id)) { 28950 if (track.type === "synth") { 28951 engine.createSynth(track.id, track.instrument, track.effects); 28952 } else if (track.type === "drums") { 28953 engine.createDrumSampler(track.id, track.effects); 28954 } else if (track.type === "pluck") { 28955 engine.createPluckSynth(track.id, track.instrument, track.effects); 28956 } else if (track.type === "fm") { 28957 engine.createFMSynth(track.id, track.instrument, track.effects); 28958 } else if (track.type === "am") { 28959 engine.createAMSynth(track.id, track.instrument, track.effects); 28960 } else if (track.type === "audio" && track.audioData?.buffer) { 28961 engine.createAudioPlayer(track.id, track.audioData.buffer, track.effects); 28962 } 28963 engine.setTrackVolume(track.id, track.volume); 28964 engine.setTrackPan(track.id, track.pan); 28965 engine.setTrackMute(track.id, track.muted); 28966 } 28967 }); 28968 }, []); 28969 (0, import_react17.useEffect)(() => { 28970 if (!audioEngineRef.current || !state.audioInitialized) return; 28971 const engine = audioEngineRef.current; 28972 if (state.isPlaying) { 28973 ensureInstrumentsReady(engine, state.tracks);
28974 sequenceRef.current = engine.scheduleSequence( 28975 state.tracks, 28976 state.totalSteps, 28977 state.stepsPerMeasure, 28978 (step) => actions.setCurrentStep(step) 28979 ); 28980 engine.play(); 28981 } else { 28982 engine.pause(); 28983 } 28984 }, [state.isPlaying, state.audioInitialized, ensureInstrumentsReady]); 28985 (0, import_react17.useEffect)(() => { 28986 if (!audioEngineRef.current || !state.isPlaying) return; 28987 const engine = audioEngineRef.current; 28988 ensureInstrumentsReady(engine, state.tracks); 28989 sequenceRef.current = engine.scheduleSequence( 28990 state.tracks, 28991 state.totalSteps, 28992 state.stepsPerMeasure, 28993 (step) => actions.setCurrentStep(step) 28994 ); 28995 }, [state.tracks, state.totalSteps, state.stepsPerMeasure, ensureInstrumentsReady]); 28996 (0, import_react17.useEffect)(() => { 28997 if (!audioEngineRef.current || !state.audioInitialized) return; 28998 if (!state.isPlaying) { 28999 ensureInstrumentsReady(audioEngineRef.current, state.tracks); 29000 } 29001 }, [state.tracks, state.audioInitialized, state.isPlaying, ensureInstrumentsReady]); 29002 (0, import_react17.useEffect)(() => { 29003 return () => { 29004 if (audioEngineRef.current) { 29005 audioEngineRef.current.dispose(); 29006 } 29007 }; 29008 }, []); 29009 (0, import_react17.useEffect)(() => { 29010 const handleKeyDown = (e) => { 29011 if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") return; 29012 switch (e.code) { 29013 case "Space": 29014 e.preventDefault(); 29015 actions.setPlaying(!state.isPlaying); 29016 break; 29017 case "Enter": 29018 e.preventDefault(); 29019 if (audioEngineRef.current) { 29020 audioEngineRef.current.stop(); 29021 actions.setPlaying(false); 29022 actions.setCurrentStep(0); 29023 } 29024 break; 29025 default: 29026 break; 29027 } 29028 }; 29029 window.addEventListener("keydown", handleKeyDown); 29030 return () => window.removeEventListener("keydown", handleKeyDown); 29031 }, [state.isPlaying, actions]); 29032 const handleMIDINoteOn = (0, import_react17.useCallback)((note, velocity) => { 29033 const track = getSelectedTrack(); 29034 if (!track || !audioEngineRef.current) return; 29035 if (track.type === "synth" || track.type === "pluck" || track.type === "fm" || track.type === "am") { 29036 audioEngineRef.current.triggerNote(track.id, note, "8n", "+0", velocity / 127); 29037 } else if (track.type === "drums") { 29038 const drumTypes = ["kick", "snare", "hihat", "clap"]; 29039 const drumIndex = note % 4; 29040 audioEngineRef.current.triggerDrum(track.id, drumTypes[drumIndex], "+0", velocity / 127); 29041 } 29042 }, [getSelectedTrack]); 29043 const handleMIDINoteOff = (0, import_react17.useCallback)(() => { 29044 }, []); 29045 const selectedTrack = getSelectedTrack(); 29046 return /* @__PURE__ */ import_react17.default.createElement("div", { className: "daw-scrollbar", style: { ...styles14.container, position: "relative" } }
29046, !state.audioInitialized && /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.initOverlay }, /* @__PURE__ */ import_react17.default.createElement( 29047 "button", 29048 { 29049 style: styles14.initButton, 29050 onClick: initAudio, 29051 onMouseOver: (e) => { 29052 e.currentTarget.style.transform = "scale(1.05)"; 29053 e.currentTarget.style.boxShadow = "0 4px 20px rgba(16, 185, 129, 0.4)"; 29054 }, 29055 onMouseOut: (e) => { 29056 e.currentTarget.style.transform = "scale(1)"; 29057 e.currentTarget.style.boxShadow = "none"; 29058 } 29059 }, 29060 "Click to Start Audio" 29061 )), /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.visualizerSection }, /* @__PURE__ */ import_react17.default.createElement(VisualizerPanel, { audioEngine: audioEngineRef.current, large: true })), /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.section }, /* @__PURE__ */ import_react17.default.createElement(TransportControls, null)), /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.mainGrid }, /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.panel }, /* @__PURE__ */ import_react17.default.createElement(TrackList, { audioEngine: audioEngineRef.current })), /* @__PURE__ */ import_react17.default.createElement("div", { style: { ...styles14.panel, padding: 0, overflow: "hidden", display: "flex", flexDirection: "column" } }, /* @__PURE__ */ import_react17.default.createElement("div", { style: { flex: 1, overflow: "auto" } }, /* @__PURE__ */ import_react17.default.createElement(PianoRoll, { track: selectedTrack, audioEngine: audioEngineRef.current }))), /* @__PURE__ */ import_react17.default.createElement("div", { style: { ...styles14.panel, overflow: "auto", maxHeight: "500px", minWidth: 0, padding: "0.75rem" } }, /* @__PURE__ */ import_react17.default.createElement( 29062 InstrumentPanel, 29063 { 29064 track: selectedTrack, 29065 audioEngine: audioEngineRef.current 29066 } 29067 ), /* @__PURE__ */ import_react17.default.createElement( 29068 EffectsPanel, 29069 { 29070 track: selectedTrack, 29071 audioEngine: audioEngineRef.current 29072 } 29073 ))), /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.bottomSection }, /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.bottomPanel }, /* @__PURE__ */ import_react17.default.createElement(PatternHelpers, { track: selectedTrack }
29073), /* @__PURE__ */ import_react17.default.createElement(MixerPanel, { audioEngine: audioEngineRef.current })), /* @__PURE__ */ import_react17.default.createElement("div", { style: styles14.bottomPanel }, /* @__PURE__ */ import_react17.default.createElement(MIDIPanel, { onNoteOn: handleMIDINoteOn, onNoteOff: handleMIDINoteOff }), /* @__PURE__ */ import_react17.default.createElement(ProjectPanel, null), /* @__PURE__ */ import_react17.default.createElement(ExportPanel, null))), /* @__PURE__ */ import_react17.default.createElement("div", { style: { ...styles14.panel, borderTop: "1px solid rgba(255,255,255,0.08)" } }, /* @__PURE__ */ import_react17.default.createElement(RecordingPanel, null))); 29074} 29075function DAW() { 29076 return /* @__PURE__ */ import_react17.default.createElement(DAWProvider, null, /* @__PURE__ */ import_react17.default.createElement(DAWContent, null)); 29077} 29078export { 29079 DAW as default 29080}; 29081/*! Bundled license information: 29082 29083tone/build/esm/core/Tone.js: 29084 (** 29085 * Tone.js 29086 * @author Yotam Mann 29087 * @license http://opensource.org/licenses/MIT MIT License 29088 * @copyright 2014-2024 Yotam Mann 29089 *) 29090*/ 29091//# sourceMappingURL=/assets/chunk-PMM2NWUE.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.