timed-audio-buffer-source-node-audio-worklet 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  export const createScheduleAudioBufferSourceNode = (convertToContextFrame) => (audioWorkletNode, context, createAudioBufferSourceNode, timingObject) => {
2
- const audioBuffer = new AudioBuffer({ length: 2, sampleRate: context.sampleRate });
2
+ const audioBuffer = new AudioBuffer({ length: 3, sampleRate: context.sampleRate });
3
3
  const audioBufferSourceNode = createAudioBufferSourceNode(context);
4
- const { position, timestamp } = timingObject.query();
5
- audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp)]), 0);
4
+ const { position, timestamp, velocity } = timingObject.query();
5
+ audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp), velocity]), 0);
6
6
  audioBufferSourceNode.buffer = audioBuffer;
7
7
  const promise = new Promise((resolve) => audioBufferSourceNode.addEventListener('ended', () => resolve(), { once: true }));
8
8
  audioBufferSourceNode.connect(audioWorkletNode);
@@ -1 +1 @@
1
- {"version":3,"file":"schedule-audio-buffer-source-node.js","sourceRoot":"","sources":["../../../src/factories/schedule-audio-buffer-source-node.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,mCAAmC,GAC5C,CAAC,qBAAqE,EAAE,EAAE,CAC1E,CACI,gBAAqF,EACrF,OAAU,EACV,2BAE+D,EAC/D,YAA2B,EACd,EAAE;IACf,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACnF,MAAM,qBAAqB,GAAG,2BAA2B,CAAM,OAAO,CAAC,CAAC;IACxE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAErD,WAAW,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,CA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../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EAEtB,4BAA4B,EAC5B,QAAQ,EACR,4BAA4B,EAE5B,kCAAkC,EAClC,cAAc,EACjB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAE,2CAA2C,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qDAAqD,EAAE,iDAAiD,EAAE,MAAM,SAAS,CAAC;AAOnI,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAI9B,eAAO,MAAM,+CAA+C,gCAAuC,MAAM,KAAK,QAAQ,IAAI,CAAC,kBAQ1H,CAAC;AAKF,wBAAgB,gDAAgD,CAAC,CAAC,SAAS,QAAQ,GAAG,cAAc,EAChG,2BAA2B,EAAE,CAAC,SAAS,QAAQ,GAAG,4BAA4B,GAAG,kCAAkC,EACnH,OAAO,EAAE,CAAC,EACV,2BAA2B,EAAE,CAAC,SAAS,QAAQ,GACzC,CAAC,OAAO,EAAE,QAAQ,KAAK,sBAAsB,CAAC,QAAQ,CAAC,GACvD,CAAC,OAAO,EAAE,cAAc,KAAK,4BAA4B,EAC/D,OAAO,GAAE,OAAO,CAAC,qDAAqD,CAAC,CAAC,CAAC,CAAM,GAChF,CAAC,SAAS,QAAQ,GAAG,2CAA2C,CAAC,CAAC,CAAC,GAAG,iDAAiD,CA+DzH"}
@@ -28,7 +28,7 @@ export function createTimedAudioBufferSourceNodeAudioWorkletNode(audioWorkletNod
28
28
  throw new TypeError('The AudioBuffer must have the same sampleRate as the AudioContext.');
29
29
  }
30
30
  let { timingObject = null } = options;
31
- const { position = 0, timestamp = 0 } = (_a = timingObject === null || timingObject === void 0 ? void 0 : timingObject.query()) !== null && _a !== void 0 ? _a : {};
31
+ const { position = 0, timestamp = 0, velocity = 0 } = (_a = timingObject === null || timingObject === void 0 ? void 0 : timingObject.query()) !== null && _a !== void 0 ? _a : {};
32
32
  const audioWorkletNode = new audioWorkletNodeConstructor(context, 'timed-audio-buffer-source-node-audio-worklet-processor', {
33
33
  numberOfInputs: 1,
34
34
  numberOfOutputs: 1,
@@ -38,7 +38,8 @@ export function createTimedAudioBufferSourceNodeAudioWorkletNode(audioWorkletNod
38
38
  ? Array.from({ length: buffer.numberOfChannels }, (_, channel) => buffer.getChannelData(channel))
39
39
  : null,
40
40
  position,
41
- timestamp: convertToContextFrame(context, timestamp)
41
+ timestamp: convertToContextFrame(context, timestamp),
42
+ velocity
42
43
  }
43
44
  });
44
45
  let removeListener = null;
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mCAAmC,EAAE,MAAM,+CAA+C,CAAC;AACpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAGvF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;GAGG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,uCAAuC,EAAE,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,+CAA+C,GAAG,KAAK,EAAE,qBAAqD,EAAE,EAAE;IAC3H,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,CAAC;QACD,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;YAAS,CAAC;QACP,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,2BAA2B,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC/E,MAAM,uBAAuB,GAAG,6BAA6B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AAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBACjG,CAAC,CAAC,IAAI;YACd,QAAQ;YACR,SAAS,EAAE,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC;YACpD,QAAQ;SACX;KACJ,CACJ,CAAC;IAEF,IAAI,cAAc,GAAwB,IAAI,CAAC;IAE/C,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE;QACtC,IAAI,EAAE;YACF,GAAG;gBACC,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;YACnG,CAAC;SACJ;QACD,YAAY,EAAE;YACV,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY;YACvB,GAAG,EAAE,CAAC,KAAqE,EAAE,EAAE;gBAC3E,cAAc,aAAd,cAAc,uBAAd,cAAc,EAAI,CAAC;gBAEnB,cAAc,GAAG,IAAI,CAAC;gBAEtB,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACjB,YAAY,GAAG,KAAK,CAAC;gBACzB,CAAC;qBAAM,CAAC;oBACJ,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAC;gBAC9E,CAAC;YACL,CAAC;SACJ;KACJ,CAAC,CAAC;IAEH,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QACxB,cAAc,GAAG,uBAAuB,CAAC,gBAAgB,EAAE,OAAO,EAAE,2BAA2B,EAAE,YAAY,CAAC,CAAC;IACnH,CAAC;IAED,OAAuD,gBAAgB,CAAC;AAC5E,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const worklet = "(()=>{\"use strict\";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:r,outputChannelCount:o,processorOptions:n}=e;var s;const i=\"object\"==typeof n&&null!==n&&\"buffer\"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error(\"The buffer needs to be either null or an array with where each element is a Float32Array.\");if(1!==t)throw new Error(\"The numberOfInputs must be 1.\");if(1!==r)throw new Error(\"The numberOfOutputs must be 1.\");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===o||1!==o.length||u!==o[0])throw new Error(\"The outputChannelCount must match the number of channels of the buffer.\");const f=\"object\"==typeof n&&null!==n&&\"position\"in n?n.position:0;if(\"number\"!=typeof f)throw new Error('The position needs to be of type \"number\".');const h=\"object\"==typeof n&&null!==n&&\"timestamp\"in n?n.timestamp:0;if(\"number\"!=typeof h)throw new Error('The timestamp needs to be of type \"number\".');super(),this._buffer=i,this._position=f,this._timestamp=h}process(e,t){let[r]=e,[o]=t;if(r.length>0){const[e]=r;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],r=o[t];for(let t=0;t<128;t+=1){const o=this._position+currentFrame-this._timestamp+t;o>=0&&o<e.length&&(r[t]=e[o])}}}return!0}}e.parameterDescriptors=[],registerProcessor(\"timed-audio-buffer-source-node-audio-worklet-processor\",e)})();";
1
+ export declare const worklet = "(()=>{\"use strict\";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:o,outputChannelCount:r,processorOptions:n}=e;var s;const i=\"object\"==typeof n&&null!==n&&\"buffer\"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error(\"The buffer needs to be either null or an array with where each element is a Float32Array.\");if(1!==t)throw new Error(\"The numberOfInputs must be 1.\");if(1!==o)throw new Error(\"The numberOfOutputs must be 1.\");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===r||1!==r.length||u!==r[0])throw new Error(\"The outputChannelCount must match the number of channels of the buffer.\");const l=\"object\"==typeof n&&null!==n&&\"position\"in n?n.position:0;if(\"number\"!=typeof l)throw new Error('The position needs to be of type \"number\".');const h=\"object\"==typeof n&&null!==n&&\"timestamp\"in n?n.timestamp:0;if(\"number\"!=typeof h)throw new Error('The timestamp needs to be of type \"number\".');const f=\"object\"==typeof n&&null!==n&&\"velocity\"in n?n.velocity:0;if(![0,1].includes(f))throw new Error(\"The velocity needs to be either 0 or 1.\");super(),this._buffer=i,this._position=l,this._timestamp=h,this._velocity=f}process(e,t){let[o]=e,[r]=t;if((null==o?void 0:o.length)>0){const[e]=o;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]),this._velocity=Math.round(e[2]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],o=r[t];for(let t=0;t<128;t+=1){const r=this._position+(currentFrame-this._timestamp+t)*this._velocity;r>=0&&r<e.length&&(o[t]=e[r])}}}return!0}}e.parameterDescriptors=[],registerProcessor(\"timed-audio-buffer-source-node-audio-worklet-processor\",e)})();";
2
2
  //# sourceMappingURL=worklet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worklet.d.ts","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,yiDAAygD,CAAC"}
1
+ {"version":3,"file":"worklet.d.ts","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,qxDAA+uD,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // This is the minified and stringified code of the timed-audio-buffer-source-node-audio-worklet-processor package.
2
- export const worklet = `(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:r,outputChannelCount:o,processorOptions:n}=e;var s;const i="object"==typeof n&&null!==n&&"buffer"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error("The buffer needs to be either null or an array with where each element is a Float32Array.");if(1!==t)throw new Error("The numberOfInputs must be 1.");if(1!==r)throw new Error("The numberOfOutputs must be 1.");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===o||1!==o.length||u!==o[0])throw new Error("The outputChannelCount must match the number of channels of the buffer.");const f="object"==typeof n&&null!==n&&"position"in n?n.position:0;if("number"!=typeof f)throw new Error('The position needs to be of type "number".');const h="object"==typeof n&&null!==n&&"timestamp"in n?n.timestamp:0;if("number"!=typeof h)throw new Error('The timestamp needs to be of type "number".');super(),this._buffer=i,this._position=f,this._timestamp=h}process(e,t){let[r]=e,[o]=t;if(r.length>0){const[e]=r;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],r=o[t];for(let t=0;t<128;t+=1){const o=this._position+currentFrame-this._timestamp+t;o>=0&&o<e.length&&(r[t]=e[o])}}}return!0}}e.parameterDescriptors=[],registerProcessor("timed-audio-buffer-source-node-audio-worklet-processor",e)})();`; // tslint:disable-line:max-line-length
2
+ export const worklet = `(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:o,outputChannelCount:r,processorOptions:n}=e;var s;const i="object"==typeof n&&null!==n&&"buffer"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error("The buffer needs to be either null or an array with where each element is a Float32Array.");if(1!==t)throw new Error("The numberOfInputs must be 1.");if(1!==o)throw new Error("The numberOfOutputs must be 1.");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===r||1!==r.length||u!==r[0])throw new Error("The outputChannelCount must match the number of channels of the buffer.");const l="object"==typeof n&&null!==n&&"position"in n?n.position:0;if("number"!=typeof l)throw new Error('The position needs to be of type "number".');const h="object"==typeof n&&null!==n&&"timestamp"in n?n.timestamp:0;if("number"!=typeof h)throw new Error('The timestamp needs to be of type "number".');const f="object"==typeof n&&null!==n&&"velocity"in n?n.velocity:0;if(![0,1].includes(f))throw new Error("The velocity needs to be either 0 or 1.");super(),this._buffer=i,this._position=l,this._timestamp=h,this._velocity=f}process(e,t){let[o]=e,[r]=t;if((null==o?void 0:o.length)>0){const[e]=o;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]),this._velocity=Math.round(e[2]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],o=r[t];for(let t=0;t<128;t+=1){const r=this._position+(currentFrame-this._timestamp+t)*this._velocity;r>=0&&r<e.length&&(o[t]=e[r])}}}return!0}}e.parameterDescriptors=[],registerProcessor("timed-audio-buffer-source-node-audio-worklet-processor",e)})();`; // tslint:disable-line:max-line-length
3
3
  //# sourceMappingURL=worklet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worklet.js","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,MAAM,CAAC,MAAM,OAAO,GAAG,sgDAAsgD,CAAC,CAAC,sCAAsC"}
1
+ {"version":3,"file":"worklet.js","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AAAA,mHAAmH;AACnH,MAAM,CAAC,MAAM,OAAO,GAAG,4uDAA4uD,CAAC,CAAC,sCAAsC"}
@@ -20,14 +20,15 @@
20
20
  var createScheduleAudioBufferSourceNode = function createScheduleAudioBufferSourceNode(convertToContextFrame) {
21
21
  return function (audioWorkletNode, context, createAudioBufferSourceNode, timingObject) {
22
22
  var audioBuffer = new AudioBuffer({
23
- length: 2,
23
+ length: 3,
24
24
  sampleRate: context.sampleRate
25
25
  });
26
26
  var audioBufferSourceNode = createAudioBufferSourceNode(context);
27
27
  var _timingObject$query = timingObject.query(),
28
28
  position = _timingObject$query.position,
29
- timestamp = _timingObject$query.timestamp;
30
- audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp)]), 0);
29
+ timestamp = _timingObject$query.timestamp,
30
+ velocity = _timingObject$query.velocity;
31
+ audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp), velocity]), 0);
31
32
  audioBufferSourceNode.buffer = audioBuffer;
32
33
  var promise = new Promise(function (resolve) {
33
34
  return audioBufferSourceNode.addEventListener('ended', function () {
@@ -72,7 +73,7 @@
72
73
  };
73
74
 
74
75
  // This is the minified and stringified code of the timed-audio-buffer-source-node-audio-worklet-processor package.
75
- var worklet = "(()=>{var e={31:function(e,t,r){!function(e,t,r,o,n,u,s,p){\"use strict\";function i(e){var t=f();return function(){var r,o=s(e);if(t){var n=s(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return u(this,r)}}function f(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var l=function(u){n(p,u);var s=i(p);function p(e){var o,n,u=e.numberOfInputs,i=e.numberOfOutputs,f=e.outputChannelCount,l=e.processorOptions;r(this,p);var a=\"object\"===t(l)&&null!==l&&\"buffer\"in l?l.buffer:null;if(!(null===a||Array.isArray(a)&&a.every((function(e){return e instanceof Float32Array}))))throw new Error(\"The buffer needs to be either null or an array with where each element is a Float32Array.\");if(1!==u)throw new Error(\"The numberOfInputs must be 1.\");if(1!==i)throw new Error(\"The numberOfOutputs must be 1.\");var c=null!==(n=null==a?void 0:a.length)&&void 0!==n?n:1;if(void 0===f||1!==f.length||c!==f[0])throw new Error(\"The outputChannelCount must match the number of channels of the buffer.\");var x=\"object\"===t(l)&&null!==l&&\"position\"in l?l.position:0;if(\"number\"!=typeof x)throw new Error('The position needs to be of type \"number\".');var d=\"object\"===t(l)&&null!==l&&\"timestamp\"in l?l.timestamp:0;if(\"number\"!=typeof d)throw new Error('The timestamp needs to be of type \"number\".');return(o=s.call(this))._buffer=a,o._position=x,o._timestamp=d,o}return o(p,[{key:\"process\",value:function(t,r){var o=e(t,1)[0],n=e(r,1)[0];if(o.length>0){var u=e(o,1)[0];u.length>1&&(this._position=Math.round(u[0]),this._timestamp=Math.round(u[1]))}if(null!==this._buffer)for(var s=this._buffer.length,p=0;p<s;p+=1)for(var i=this._buffer[p],f=n[p],l=0;l<128;l+=1){var a=this._position+currentFrame-this._timestamp+l;a>=0&&a<i.length&&(f[l]=i[a])}return!0}}]),p}(p(AudioWorkletProcessor));l.parameterDescriptors=[],registerProcessor(\"timed-audio-buffer-source-node-audio-worklet-processor\",l)}(r(424),r(698),r(690),r(728),r(655),r(993),r(808),r(496))},897:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o},e.exports.__esModule=!0,e.exports.default=e.exports},372:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},115:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e},e.exports.__esModule=!0,e.exports.default=e.exports},690:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},e.exports.__esModule=!0,e.exports.default=e.exports},515:(e,t,r)=>{var o=r(15),n=r(617);function u(t,r,s){return n()?(e.exports=u=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=u=function(e,t,r){var n=[null];n.push.apply(n,t);var u=new(Function.bind.apply(e,n));return r&&o(u,r.prototype),u},e.exports.__esModule=!0,e.exports.default=e.exports),u.apply(null,arguments)}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports},728:(e,t,r)=>{var o=r(62);function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,\"value\"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,\"prototype\",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},808:e=>{function t(r){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},655:(e,t,r)=>{var o=r(15);e.exports=function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,\"prototype\",{writable:!1}),t&&o(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},35:e=>{e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf(\"[native code]\")}catch(t){return\"function\"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},617:e=>{e.exports=function(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports},872:e=>{e.exports=function(e,t){var r=null==e?null:\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(null!=r){var o,n,u,s,p=[],i=!0,f=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;i=!1}else for(;!(i=(o=u.call(r)).done)&&(p.push(o.value),p.length!==t);i=!0);}catch(e){f=!0,n=e}finally{try{if(!i&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw n}}return p}},e.exports.__esModule=!0,e.exports.default=e.exports},218:e=>{e.exports=function(){throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")},e.exports.__esModule=!0,e.exports.default=e.exports},993:(e,t,r)=>{var o=r(698).default,n=r(115);e.exports=function(e,t){if(t&&(\"object\"===o(t)||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},15:e=>{function t(r,o){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},424:(e,t,r)=>{var o=r(372),n=r(872),u=r(116),s=r(218);e.exports=function(e,t){return o(e)||n(e,t)||u(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},36:(e,t,r)=>{var o=r(698).default;e.exports=function(e,t){if(\"object\"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||\"default\");if(\"object\"!=o(n))return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},62:(e,t,r)=>{var o=r(698).default,n=r(36);e.exports=function(e){var t=n(e,\"string\");return\"symbol\"==o(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(r){return e.exports=t=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},116:(e,t,r)=>{var o=r(897);e.exports=function(e,t){if(e){if(\"string\"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===r&&e.constructor&&(r=e.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(e):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},496:(e,t,r)=>{var o=r(808),n=r(15),u=r(35),s=r(515);function p(t){var r=\"function\"==typeof Map?new Map:void 0;return e.exports=p=function(e){if(null===e||!u(e))return e;if(\"function\"!=typeof e)throw new TypeError(\"Super expression must either be null or a function\");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,p(t)}e.exports=p,e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,r),u.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{\"use strict\";r(31)})()})();"; // tslint:disable-line:max-line-length
76
+ var worklet = "(()=>{var e={31:function(e,t,r){!function(e,t,r,o,n,u,s,i){\"use strict\";function p(e){var t=l();return function(){var r,o=s(e);if(t){var n=s(this).constructor;r=Reflect.construct(o,arguments,n)}else r=o.apply(this,arguments);return u(this,r)}}function l(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var f=function(u){n(i,u);var s=p(i);function i(e){var o,n,u=e.numberOfInputs,p=e.numberOfOutputs,l=e.outputChannelCount,f=e.processorOptions;r(this,i);var a=\"object\"===t(f)&&null!==f&&\"buffer\"in f?f.buffer:null;if(!(null===a||Array.isArray(a)&&a.every((function(e){return e instanceof Float32Array}))))throw new Error(\"The buffer needs to be either null or an array with where each element is a Float32Array.\");if(1!==u)throw new Error(\"The numberOfInputs must be 1.\");if(1!==p)throw new Error(\"The numberOfOutputs must be 1.\");var c=null!==(n=null==a?void 0:a.length)&&void 0!==n?n:1;if(void 0===l||1!==l.length||c!==l[0])throw new Error(\"The outputChannelCount must match the number of channels of the buffer.\");var x=\"object\"===t(f)&&null!==f&&\"position\"in f?f.position:0;if(\"number\"!=typeof x)throw new Error('The position needs to be of type \"number\".');var d=\"object\"===t(f)&&null!==f&&\"timestamp\"in f?f.timestamp:0;if(\"number\"!=typeof d)throw new Error('The timestamp needs to be of type \"number\".');var y=\"object\"===t(f)&&null!==f&&\"velocity\"in f?f.velocity:0;if(![0,1].includes(y))throw new Error(\"The velocity needs to be either 0 or 1.\");return(o=s.call(this))._buffer=a,o._position=x,o._timestamp=d,o._velocity=y,o}return o(i,[{key:\"process\",value:function(t,r){var o=e(t,1)[0],n=e(r,1)[0];if((null==o?void 0:o.length)>0){var u=e(o,1)[0];u.length>1&&(this._position=Math.round(u[0]),this._timestamp=Math.round(u[1]),this._velocity=Math.round(u[2]))}if(null!==this._buffer)for(var s=this._buffer.length,i=0;i<s;i+=1)for(var p=this._buffer[i],l=n[i],f=0;f<128;f+=1){var a=this._position+(currentFrame-this._timestamp+f)*this._velocity;a>=0&&a<p.length&&(l[f]=p[a])}return!0}}]),i}(i(AudioWorkletProcessor));f.parameterDescriptors=[],registerProcessor(\"timed-audio-buffer-source-node-audio-worklet-processor\",f)}(r(424),r(698),r(690),r(728),r(655),r(993),r(808),r(496))},897:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o},e.exports.__esModule=!0,e.exports.default=e.exports},372:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},115:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e},e.exports.__esModule=!0,e.exports.default=e.exports},690:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},e.exports.__esModule=!0,e.exports.default=e.exports},515:(e,t,r)=>{var o=r(15),n=r(617);function u(t,r,s){return n()?(e.exports=u=Reflect.construct.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=u=function(e,t,r){var n=[null];n.push.apply(n,t);var u=new(Function.bind.apply(e,n));return r&&o(u,r.prototype),u},e.exports.__esModule=!0,e.exports.default=e.exports),u.apply(null,arguments)}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports},728:(e,t,r)=>{var o=r(62);function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,\"value\"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,\"prototype\",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},808:e=>{function t(r){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},655:(e,t,r)=>{var o=r(15);e.exports=function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,\"prototype\",{writable:!1}),t&&o(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},35:e=>{e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf(\"[native code]\")}catch(t){return\"function\"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},617:e=>{e.exports=function(){if(\"undefined\"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(\"function\"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports},872:e=>{e.exports=function(e,t){var r=null==e?null:\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(null!=r){var o,n,u,s,i=[],p=!0,l=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;p=!1}else for(;!(p=(o=u.call(r)).done)&&(i.push(o.value),i.length!==t);p=!0);}catch(e){l=!0,n=e}finally{try{if(!p&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return i}},e.exports.__esModule=!0,e.exports.default=e.exports},218:e=>{e.exports=function(){throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")},e.exports.__esModule=!0,e.exports.default=e.exports},993:(e,t,r)=>{var o=r(698).default,n=r(115);e.exports=function(e,t){if(t&&(\"object\"===o(t)||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},15:e=>{function t(r,o){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},424:(e,t,r)=>{var o=r(372),n=r(872),u=r(116),s=r(218);e.exports=function(e,t){return o(e)||n(e,t)||u(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},36:(e,t,r)=>{var o=r(698).default;e.exports=function(e,t){if(\"object\"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||\"default\");if(\"object\"!=o(n))return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},62:(e,t,r)=>{var o=r(698).default,n=r(36);e.exports=function(e){var t=n(e,\"string\");return\"symbol\"==o(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(r){return e.exports=t=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},116:(e,t,r)=>{var o=r(897);e.exports=function(e,t){if(e){if(\"string\"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return\"Object\"===r&&e.constructor&&(r=e.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(e):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},496:(e,t,r)=>{var o=r(808),n=r(15),u=r(35),s=r(515);function i(t){var r=\"function\"==typeof Map?new Map:void 0;return e.exports=i=function(e){if(null===e||!u(e))return e;if(\"function\"!=typeof e)throw new TypeError(\"Super expression must either be null or a function\");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,i(t)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var u=t[o]={exports:{}};return e[o].call(u.exports,u,u.exports,r),u.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{\"use strict\";r(31)})()})();"; // tslint:disable-line:max-line-length
76
77
 
77
78
  var blob = new Blob([worklet], {
78
79
  type: 'application/javascript; charset=utf-8'
@@ -117,7 +118,9 @@
117
118
  _ref2$position = _ref2.position,
118
119
  position = _ref2$position === void 0 ? 0 : _ref2$position,
119
120
  _ref2$timestamp = _ref2.timestamp,
120
- timestamp = _ref2$timestamp === void 0 ? 0 : _ref2$timestamp;
121
+ timestamp = _ref2$timestamp === void 0 ? 0 : _ref2$timestamp,
122
+ _ref2$velocity = _ref2.velocity,
123
+ velocity = _ref2$velocity === void 0 ? 0 : _ref2$velocity;
121
124
  var audioWorkletNode = new audioWorkletNodeConstructor(context, 'timed-audio-buffer-source-node-audio-worklet-processor', {
122
125
  numberOfInputs: 1,
123
126
  numberOfOutputs: 1,
@@ -129,7 +132,8 @@
129
132
  return buffer.getChannelData(channel);
130
133
  }) : null,
131
134
  position: position,
132
- timestamp: convertToContextFrame(context, timestamp)
135
+ timestamp: convertToContextFrame(context, timestamp),
136
+ velocity: velocity
133
137
  }
134
138
  });
135
139
  var removeListener = null;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@babel/runtime": "^7.23.6",
13
13
  "standardized-audio-context": "^25.3.60",
14
- "timed-audio-buffer-source-node-audio-worklet-processor": "^2.0.0",
14
+ "timed-audio-buffer-source-node-audio-worklet-processor": "^2.1.0",
15
15
  "timing-object": "^3.1.70",
16
16
  "tslib": "^2.6.2"
17
17
  },
@@ -86,5 +86,5 @@
86
86
  "test": "grunt lint && grunt test"
87
87
  },
88
88
  "types": "build/es2019/module.d.ts",
89
- "version": "2.0.0"
89
+ "version": "2.1.0"
90
90
  }
@@ -19,11 +19,11 @@ export const createScheduleAudioBufferSourceNode =
19
19
  : (context: TNativeContext) => TNativeAudioBufferSourceNode,
20
20
  timingObject: ITimingObject
21
21
  ): Promise<void> => {
22
- const audioBuffer = new AudioBuffer({ length: 2, sampleRate: context.sampleRate });
22
+ const audioBuffer = new AudioBuffer({ length: 3, sampleRate: context.sampleRate });
23
23
  const audioBufferSourceNode = createAudioBufferSourceNode(<any>context);
24
- const { position, timestamp } = timingObject.query();
24
+ const { position, timestamp, velocity } = timingObject.query();
25
25
 
26
- audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp)]), 0);
26
+ audioBuffer.copyToChannel(new Float32Array([position, convertToContextFrame(context, timestamp), velocity]), 0);
27
27
 
28
28
  audioBufferSourceNode.buffer = audioBuffer;
29
29
 
package/src/module.ts CHANGED
@@ -59,7 +59,7 @@ export function createTimedAudioBufferSourceNodeAudioWorkletNode<T extends TCont
59
59
 
60
60
  let { timingObject = null } = options;
61
61
 
62
- const { position = 0, timestamp = 0 } = timingObject?.query() ?? {};
62
+ const { position = 0, timestamp = 0, velocity = 0 } = timingObject?.query() ?? {};
63
63
  const audioWorkletNode: TAnyAudioWorkletNode = new (<any>audioWorkletNodeConstructor)(
64
64
  context,
65
65
  'timed-audio-buffer-source-node-audio-worklet-processor',
@@ -73,7 +73,8 @@ export function createTimedAudioBufferSourceNodeAudioWorkletNode<T extends TCont
73
73
  ? Array.from({ length: buffer.numberOfChannels }, (_, channel) => buffer.getChannelData(channel))
74
74
  : null,
75
75
  position,
76
- timestamp: convertToContextFrame(context, timestamp)
76
+ timestamp: convertToContextFrame(context, timestamp),
77
+ velocity
77
78
  }
78
79
  }
79
80
  );
@@ -1,2 +1,2 @@
1
1
  // This is the minified and stringified code of the timed-audio-buffer-source-node-audio-worklet-processor package.
2
- export const worklet = `(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:r,outputChannelCount:o,processorOptions:n}=e;var s;const i="object"==typeof n&&null!==n&&"buffer"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error("The buffer needs to be either null or an array with where each element is a Float32Array.");if(1!==t)throw new Error("The numberOfInputs must be 1.");if(1!==r)throw new Error("The numberOfOutputs must be 1.");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===o||1!==o.length||u!==o[0])throw new Error("The outputChannelCount must match the number of channels of the buffer.");const f="object"==typeof n&&null!==n&&"position"in n?n.position:0;if("number"!=typeof f)throw new Error('The position needs to be of type "number".');const h="object"==typeof n&&null!==n&&"timestamp"in n?n.timestamp:0;if("number"!=typeof h)throw new Error('The timestamp needs to be of type "number".');super(),this._buffer=i,this._position=f,this._timestamp=h}process(e,t){let[r]=e,[o]=t;if(r.length>0){const[e]=r;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],r=o[t];for(let t=0;t<128;t+=1){const o=this._position+currentFrame-this._timestamp+t;o>=0&&o<e.length&&(r[t]=e[o])}}}return!0}}e.parameterDescriptors=[],registerProcessor("timed-audio-buffer-source-node-audio-worklet-processor",e)})();`; // tslint:disable-line:max-line-length
2
+ export const worklet = `(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(e){let{numberOfInputs:t,numberOfOutputs:o,outputChannelCount:r,processorOptions:n}=e;var s;const i="object"==typeof n&&null!==n&&"buffer"in n?n.buffer:null;if(!(null===i||Array.isArray(i)&&i.every((e=>e instanceof Float32Array))))throw new Error("The buffer needs to be either null or an array with where each element is a Float32Array.");if(1!==t)throw new Error("The numberOfInputs must be 1.");if(1!==o)throw new Error("The numberOfOutputs must be 1.");const u=null!==(s=null==i?void 0:i.length)&&void 0!==s?s:1;if(void 0===r||1!==r.length||u!==r[0])throw new Error("The outputChannelCount must match the number of channels of the buffer.");const l="object"==typeof n&&null!==n&&"position"in n?n.position:0;if("number"!=typeof l)throw new Error('The position needs to be of type "number".');const h="object"==typeof n&&null!==n&&"timestamp"in n?n.timestamp:0;if("number"!=typeof h)throw new Error('The timestamp needs to be of type "number".');const f="object"==typeof n&&null!==n&&"velocity"in n?n.velocity:0;if(![0,1].includes(f))throw new Error("The velocity needs to be either 0 or 1.");super(),this._buffer=i,this._position=l,this._timestamp=h,this._velocity=f}process(e,t){let[o]=e,[r]=t;if((null==o?void 0:o.length)>0){const[e]=o;e.length>1&&(this._position=Math.round(e[0]),this._timestamp=Math.round(e[1]),this._velocity=Math.round(e[2]))}if(null!==this._buffer){const e=this._buffer.length;for(let t=0;t<e;t+=1){const e=this._buffer[t],o=r[t];for(let t=0;t<128;t+=1){const r=this._position+(currentFrame-this._timestamp+t)*this._velocity;r>=0&&r<e.length&&(o[t]=e[r])}}}return!0}}e.parameterDescriptors=[],registerProcessor("timed-audio-buffer-source-node-audio-worklet-processor",e)})();`; // tslint:disable-line:max-line-length