From 168ac608534e67e6ebf95a1f65dc33dc8bb19bbb Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 8 Nov 2022 21:25:21 +0100 Subject: [PATCH] use tune that works without transpiler --- .../dist/assets/index.211bbc68.js | 1 + .../{index.73313bf6.js => index.4cbc0a10.js} | 55 +++++-------------- .../{index.8b8c94a0.js => index.63aa02b5.js} | 2 +- .../dist/assets/index.85aeb624.js | 1 - .../{index.b258159a.js => index.ecddf978.js} | 2 +- .../vite-vanilla-repl/dist/index.html | 2 +- .../core/examples/vite-vanilla-repl/tune.mjs | 10 +++- 7 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 packages/core/examples/vite-vanilla-repl/dist/assets/index.211bbc68.js rename packages/core/examples/vite-vanilla-repl/dist/assets/{index.73313bf6.js => index.4cbc0a10.js} (78%) rename packages/core/examples/vite-vanilla-repl/dist/assets/{index.8b8c94a0.js => index.63aa02b5.js} (99%) delete mode 100644 packages/core/examples/vite-vanilla-repl/dist/assets/index.85aeb624.js rename packages/core/examples/vite-vanilla-repl/dist/assets/{index.b258159a.js => index.ecddf978.js} (82%) diff --git a/packages/core/examples/vite-vanilla-repl/dist/assets/index.211bbc68.js b/packages/core/examples/vite-vanilla-repl/dist/assets/index.211bbc68.js new file mode 100644 index 00000000..c71a2c36 --- /dev/null +++ b/packages/core/examples/vite-vanilla-repl/dist/assets/index.211bbc68.js @@ -0,0 +1 @@ +import{b as s,h as i,m,a as n,c as p,p as t}from"./index.4cbc0a10.js";export{s as SyntaxError,i as h,m as mini,n as minify,p as parse,t as patternifyAST}; diff --git a/packages/core/examples/vite-vanilla-repl/dist/assets/index.73313bf6.js b/packages/core/examples/vite-vanilla-repl/dist/assets/index.4cbc0a10.js similarity index 78% rename from packages/core/examples/vite-vanilla-repl/dist/assets/index.73313bf6.js rename to packages/core/examples/vite-vanilla-repl/dist/assets/index.4cbc0a10.js index b2f208f7..d34a6d2d 100644 --- a/packages/core/examples/vite-vanilla-repl/dist/assets/index.73313bf6.js +++ b/packages/core/examples/vite-vanilla-repl/dist/assets/index.4cbc0a10.js @@ -1,49 +1,24 @@ -var tn=Object.defineProperty;var rn=(r,t,e)=>t in r?tn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var K=(r,t,e)=>(rn(r,typeof t!="symbol"?t+"":t,e),e);const strudel=Object.freeze(Object.defineProperty({__proto__:null,get Fraction(){return fraction},get controls(){return controls},get drawLine(){return drawLine},get gist(){return gist},get Hap(){return Hap},get setStringParser(){return setStringParser},get Pattern(){return Pattern$3},get polyrhythm(){return polyrhythm},get pr(){return pr},get silence(){return silence$1},get pure(){return pure$1},get isPattern(){return isPattern$1},get reify(){return reify$2},get stack(){return stack$1},get slowcat(){return slowcat$1},get slowcatPrime(){return slowcatPrime},get fastcat(){return fastcat},get cat(){return cat},get timeCat(){return timeCat$1},get sequence(){return sequence$1},get seq(){return seq},get polymeterSteps(){return polymeterSteps},get polymeter(){return polymeter},get pm(){return pm},get add(){return add},get chop(){return chop},get chunk(){return chunk},get chunkBack(){return chunkBack},get div(){return div},get early(){return early},get echo(){return echo},get every(){return every},get fast(){return fast},get inv(){return inv},get invert(){return invert},get iter(){return iter},get iterBack(){return iterBack},get jux(){return jux},get juxBy(){return juxBy},get late(){return late},get linger(){return linger},get mask(){return mask},get mul(){return mul},get off(){return off},get ply(){return ply},get range(){return range},get rangex(){return rangex},get range2(){return range2},get rev(){return rev},get slow(){return slow},get struct(){return struct},get sub(){return sub},get superimpose(){return superimpose},get set(){return set},get when(){return when},get makeComposable(){return makeComposable},get patternify2(){return patternify2},get patternify3(){return patternify3},get patternify4(){return patternify4},get steady(){return steady},get signal(){return signal},get isaw(){return isaw},get isaw2(){return isaw2},get saw(){return saw},get saw2(){return saw2},get sine2(){return sine2},get sine(){return sine},get cosine(){return cosine},get cosine2(){return cosine2},get square(){return square},get square2(){return square2},get tri(){return tri},get tri2(){return tri2},get time(){return time},get rand(){return rand},get rand2(){return rand2},get _brandBy(){return _brandBy},get brandBy(){return brandBy},get brand(){return brand},get _irand(){return _irand},get irand(){return irand},get __chooseWith(){return __chooseWith},get chooseWith(){return chooseWith},get chooseInWith(){return chooseInWith},get choose(){return choose},get chooseCycles(){return chooseCycles},get randcat(){return randcat},get wchoose(){return wchoose},get wchooseCycles(){return wchooseCycles},get perlinWith(){return perlinWith},get perlin(){return perlin},get State(){return State},get TimeSpan(){return TimeSpan},get isNote(){return isNote},get tokenizeNote(){return tokenizeNote},get toMidi(){return toMidi},get fromMidi(){return fromMidi},get getFreq(){return getFreq},get midi2note(){return midi2note},get mod(){return mod},get getPlayableNoteValue(){return getPlayableNoteValue},get getFrequency(){return getFrequency},get rotate(){return rotate},get pipe(){return pipe},get compose(){return compose},get removeUndefineds(){return removeUndefineds},get flatten(){return flatten},get id(){return id},get constant(){return constant},get listRange(){return listRange},get curry(){return curry},get parseNumeral(){return parseNumeral},get mapArgs(){return mapArgs},get numeralArgs(){return numeralArgs},get parseFractional(){return parseFractional},get fractionalArgs(){return fractionalArgs},get evalScope(){return evalScope},get evaluate(){return evaluate$1},get repl(){return repl}},Symbol.toStringTag,{value:"Module"}));(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function e(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerpolicy&&(i.referrerPolicy=s.referrerpolicy),s.crossorigin==="use-credentials"?i.credentials="include":s.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=e(s);fetch(s.href,i)}})();const scriptRel="modulepreload",assetsURL=function(r){return"/tidalcycles/strudel/use-acorn/packages/core/examples/vite-vanilla-repl/dist/"+r},seen={},__vitePreload=function(t,e,o){if(!e||e.length===0)return t();const s=document.getElementsByTagName("link");return Promise.all(e.map(i=>{if(i=assetsURL(i),i in seen)return;seen[i]=!0;const l=i.endsWith(".css"),f=l?'[rel="stylesheet"]':"";if(!!o)for(let y=s.length-1;y>=0;y--){const $=s[y];if($.href===i&&(!l||$.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${f}`))return;const w=document.createElement("link");if(w.rel=l?"stylesheet":scriptRel,l||(w.as="script",w.crossOrigin=""),w.href=i,document.head.appendChild(w),l)return new Promise((y,$)=>{w.addEventListener("load",y),w.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t())};var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function getAugmentedNamespace(r){var t=r.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(o){var s=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:function(){return r[o]}})}),e}var fraction$1={exports:{}};/** +var tn=Object.defineProperty;var rn=(r,t,e)=>t in r?tn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var K=(r,t,e)=>(rn(r,typeof t!="symbol"?t+"":t,e),e);const strudel=Object.freeze(Object.defineProperty({__proto__:null,get Fraction(){return fraction},get controls(){return controls},get drawLine(){return drawLine},get gist(){return gist},get Hap(){return Hap},get setStringParser(){return setStringParser},get Pattern(){return Pattern$3},get polyrhythm(){return polyrhythm},get pr(){return pr},get silence(){return silence$1},get pure(){return pure$1},get isPattern(){return isPattern$1},get reify(){return reify$2},get stack(){return stack$1},get slowcat(){return slowcat$1},get slowcatPrime(){return slowcatPrime},get fastcat(){return fastcat},get cat(){return cat},get timeCat(){return timeCat$1},get sequence(){return sequence$1},get seq(){return seq},get polymeterSteps(){return polymeterSteps},get polymeter(){return polymeter},get pm(){return pm},get add(){return add},get chop(){return chop},get chunk(){return chunk},get chunkBack(){return chunkBack},get div(){return div},get early(){return early},get echo(){return echo},get every(){return every},get fast(){return fast},get inv(){return inv},get invert(){return invert},get iter(){return iter},get iterBack(){return iterBack},get jux(){return jux},get juxBy(){return juxBy},get late(){return late},get linger(){return linger},get mask(){return mask},get mul(){return mul},get off(){return off},get ply(){return ply},get range(){return range},get rangex(){return rangex},get range2(){return range2},get rev(){return rev},get slow(){return slow},get struct(){return struct},get sub(){return sub},get superimpose(){return superimpose},get set(){return set},get when(){return when},get makeComposable(){return makeComposable},get patternify2(){return patternify2},get patternify3(){return patternify3},get patternify4(){return patternify4},get steady(){return steady},get signal(){return signal},get isaw(){return isaw},get isaw2(){return isaw2},get saw(){return saw},get saw2(){return saw2},get sine2(){return sine2},get sine(){return sine},get cosine(){return cosine},get cosine2(){return cosine2},get square(){return square},get square2(){return square2},get tri(){return tri},get tri2(){return tri2},get time(){return time},get rand(){return rand},get rand2(){return rand2},get _brandBy(){return _brandBy},get brandBy(){return brandBy},get brand(){return brand},get _irand(){return _irand},get irand(){return irand},get __chooseWith(){return __chooseWith},get chooseWith(){return chooseWith},get chooseInWith(){return chooseInWith},get choose(){return choose},get chooseCycles(){return chooseCycles},get randcat(){return randcat},get wchoose(){return wchoose},get wchooseCycles(){return wchooseCycles},get perlinWith(){return perlinWith},get perlin(){return perlin},get State(){return State},get TimeSpan(){return TimeSpan},get isNote(){return isNote},get tokenizeNote(){return tokenizeNote},get toMidi(){return toMidi},get fromMidi(){return fromMidi},get getFreq(){return getFreq},get midi2note(){return midi2note},get mod(){return mod},get getPlayableNoteValue(){return getPlayableNoteValue},get getFrequency(){return getFrequency},get rotate(){return rotate},get pipe(){return pipe},get compose(){return compose},get removeUndefineds(){return removeUndefineds},get flatten(){return flatten},get id(){return id},get constant(){return constant},get listRange(){return listRange},get curry(){return curry},get parseNumeral(){return parseNumeral},get mapArgs(){return mapArgs},get numeralArgs(){return numeralArgs},get parseFractional(){return parseFractional},get fractionalArgs(){return fractionalArgs},get evalScope(){return evalScope},get evaluate(){return evaluate$1},get repl(){return repl}},Symbol.toStringTag,{value:"Module"}));(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const f of i.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function e(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerpolicy&&(i.referrerPolicy=s.referrerpolicy),s.crossorigin==="use-credentials"?i.credentials="include":s.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=e(s);fetch(s.href,i)}})();const scriptRel="modulepreload",assetsURL=function(r){return"/tidalcycles/strudel/use-acorn/packages/core/examples/vite-vanilla-repl/dist/"+r},seen={},__vitePreload=function(t,e,o){if(!e||e.length===0)return t();const s=document.getElementsByTagName("link");return Promise.all(e.map(i=>{if(i=assetsURL(i),i in seen)return;seen[i]=!0;const f=i.endsWith(".css"),l=f?'[rel="stylesheet"]':"";if(!!o)for(let y=s.length-1;y>=0;y--){const $=s[y];if($.href===i&&(!f||$.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${l}`))return;const w=document.createElement("link");if(w.rel=f?"stylesheet":scriptRel,f||(w.as="script",w.crossOrigin=""),w.href=i,document.head.appendChild(w),f)return new Promise((y,$)=>{w.addEventListener("load",y),w.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t())};var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getDefaultExportFromCjs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function getAugmentedNamespace(r){var t=r.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(o){var s=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(e,o,s.get?s:{enumerable:!0,get:function(){return r[o]}})}),e}var fraction$1={exports:{}};/** * @license Fraction.js v4.2.0 05/03/2022 * https://www.xarg.org/2014/03/rational-numbers-in-javascript/ * * Copyright (c) 2021, Robert Eisele (robert@xarg.org) * Dual licensed under the MIT or GPL Version 2 licenses. - **/(function(r,t){(function(e){var o=2e3,s={s:1,n:0,d:1};function i(p,d){if(isNaN(p=parseInt(p,10)))throw C.InvalidParameter;return p*d}function l(p,d){if(d===0)throw C.DivisionByZero;var m=Object.create(C.prototype);m.s=p<0?-1:1,p=p<0?-p:p;var b=S(p,d);return m.n=p/b,m.d=d/b,m}function f(p){for(var d={},m=p,b=2,I=4;I<=m;){for(;m%b===0;)m/=b,d[b]=(d[b]||0)+1;I+=1+2*b++}return m!==p?m>1&&(d[m]=(d[m]||0)+1):d[p]=(d[p]||0)+1,d}var g=function(p,d){var m=0,b=1,I=1,T=0,G=0,Y=0,E=1,W=1,P=0,B=1,z=1,O=1,Z=1e7,L;if(p!=null)if(d!==void 0){if(m=p,b=d,I=m*b,m%1!==0||b%1!==0)throw C.NonIntegerParameter}else switch(typeof p){case"object":{if("d"in p&&"n"in p)m=p.n,b=p.d,"s"in p&&(m*=p.s);else if(0 in p)m=p[0],1 in p&&(b=p[1]);else throw C.InvalidParameter;I=m*b;break}case"number":{if(p<0&&(I=p,p=-p),p%1===0)m=p;else if(p>0){for(p>=1&&(W=Math.pow(10,Math.floor(1+Math.log(p)/Math.LN10)),p/=W);B<=Z&&O<=Z;)if(L=(P+z)/(B+O),p===L){B+O<=Z?(m=P+z,b=B+O):O>B?(m=z,b=O):(m=P,b=B);break}else p>L?(P+=z,B+=O):(z+=P,O+=B),B>Z?(m=z,b=O):(m=P,b=B);m*=W}else(isNaN(p)||isNaN(d))&&(b=m=NaN);break}case"string":{if(B=p.match(/\d+|./g),B===null)throw C.InvalidParameter;if(B[P]==="-"?(I=-1,P++):B[P]==="+"&&P++,B.length===P+1?G=i(B[P++],I):B[P+1]==="."||B[P]==="."?(B[P]!=="."&&(T=i(B[P++],I)),P++,(P+1===B.length||B[P+1]==="("&&B[P+3]===")"||B[P+1]==="'"&&B[P+3]==="'")&&(G=i(B[P],I),E=Math.pow(10,B[P].length),P++),(B[P]==="("&&B[P+2]===")"||B[P]==="'"&&B[P+2]==="'")&&(Y=i(B[P+1],I),W=Math.pow(10,B[P+1].length)-1,P+=3)):B[P+1]==="/"||B[P+1]===":"?(G=i(B[P],I),E=i(B[P+2],1),P+=3):B[P+3]==="/"&&B[P+1]===" "&&(T=i(B[P],I),G=i(B[P+2],I),E=i(B[P+4],1),P+=5),B.length<=P){b=E*W,I=m=Y+b*T+W*G;break}}default:throw C.InvalidParameter}if(b===0)throw C.DivisionByZero;s.s=I<0?-1:1,s.n=Math.abs(m),s.d=Math.abs(b)};function w(p,d,m){for(var b=1;d>0;p=p*p%m,d>>=1)d&1&&(b=b*p%m);return b}function y(p,d){for(;d%2===0;d/=2);for(;d%5===0;d/=5);if(d===1)return 0;for(var m=10%d,b=1;m!==1;b++)if(m=m*10%d,b>o)return 0;return b}function $(p,d,m){for(var b=1,I=w(10,m,d),T=0;T<300;T++){if(b===I)return T;b=b*10%d,I=I*10%d}return 0}function S(p,d){if(!p)return d;if(!d)return p;for(;;){if(p%=d,!p)return d;if(d%=p,!d)return p}}function C(p,d){if(g(p,d),this instanceof C)p=S(s.d,s.n),this.s=s.s,this.n=s.n/p,this.d=s.d/p;else return l(s.s*s.n,s.d)}C.DivisionByZero=new Error("Division by Zero"),C.InvalidParameter=new Error("Invalid argument"),C.NonIntegerParameter=new Error("Parameters must be integer"),C.prototype={s:1,n:0,d:1,abs:function(){return l(this.n,this.d)},neg:function(){return l(-this.s*this.n,this.d)},add:function(p,d){return g(p,d),l(this.s*this.n*s.d+s.s*this.d*s.n,this.d*s.d)},sub:function(p,d){return g(p,d),l(this.s*this.n*s.d-s.s*this.d*s.n,this.d*s.d)},mul:function(p,d){return g(p,d),l(this.s*s.s*this.n*s.n,this.d*s.d)},div:function(p,d){return g(p,d),l(this.s*s.s*this.n*s.d,this.d*s.n)},clone:function(){return l(this.s*this.n,this.d)},mod:function(p,d){if(isNaN(this.n)||isNaN(this.d))return new C(NaN);if(p===void 0)return l(this.s*this.n%this.d,1);if(g(p,d),s.n===0&&this.d===0)throw C.DivisionByZero;return l(this.s*(s.d*this.n)%(s.n*this.d),s.d*this.d)},gcd:function(p,d){return g(p,d),l(S(s.n,this.n)*S(s.d,this.d),s.d*this.d)},lcm:function(p,d){return g(p,d),s.n===0&&this.n===0?l(0,1):l(s.n*this.n,S(s.n,this.n)*S(s.d,this.d))},ceil:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):l(Math.ceil(p*this.s*this.n/this.d),p)},floor:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):l(Math.floor(p*this.s*this.n/this.d),p)},round:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):l(Math.round(p*this.s*this.n/this.d),p)},inverse:function(){return l(this.s*this.d,this.n)},pow:function(p,d){if(g(p,d),s.d===1)return s.s<0?l(Math.pow(this.s*this.d,s.n),Math.pow(this.n,s.n)):l(Math.pow(this.s*this.n,s.n),Math.pow(this.d,s.n));if(this.s<0)return null;var m=f(this.n),b=f(this.d),I=1,T=1;for(var G in m)if(G!=="1"){if(G==="0"){I=0;break}if(m[G]*=s.n,m[G]%s.d===0)m[G]/=s.d;else return null;I*=Math.pow(G,m[G])}for(var G in b)if(G!=="1"){if(b[G]*=s.n,b[G]%s.d===0)b[G]/=s.d;else return null;T*=Math.pow(G,b[G])}return s.s<0?l(T,I):l(I,T)},equals:function(p,d){return g(p,d),this.s*this.n*s.d===s.s*s.n*this.d},compare:function(p,d){g(p,d);var m=this.s*this.n*s.d-s.s*s.n*this.d;return(0=0;T--)I=I.inverse().add(m[T]);if(I.sub(d).abs().valueOf()0&&(m+=d,m+=" ",b%=I),m+=b,m+="/",m+=I),m},toLatex:function(p){var d,m="",b=this.n,I=this.d;return this.s<0&&(m+="-"),I===1?m+=b:(p&&(d=Math.floor(b/I))>0&&(m+=d,b%=I),m+="\\frac{",m+=b,m+="}{",m+=I,m+="}"),m},toContinued:function(){var p,d=this.n,m=this.d,b=[];if(isNaN(d)||isNaN(m))return b;do b.push(Math.floor(d/m)),p=d%m,d=m,m=p;while(d!==1);return b},toString:function(p){var d=this.n,m=this.d;if(isNaN(d)||isNaN(m))return"NaN";p=p||15;var b=y(d,m),I=$(d,m,b),T=this.s<0?"-":"";if(T+=d/m|0,d%=m,d*=10,d&&(T+="."),b){for(var G=I;G--;)T+=d/m|0,d%=m,d*=10;T+="(";for(var G=b;G--;)T+=d/m|0,d%=m,d*=10;T+=")"}else for(var G=p;d&&G--;)T+=d/m|0,d%=m,d*=10;return T}},Object.defineProperty(C,"__esModule",{value:!0}),C.default=C,C.Fraction=C,r.exports=C})()})(fraction$1);const Fraction$1=getDefaultExportFromCjs(fraction$1.exports);Fraction$1.prototype.sam=function(){return this.floor()};Fraction$1.prototype.nextSam=function(){return this.sam().add(1)};Fraction$1.prototype.wholeCycle=function(){return new TimeSpan(this.sam(),this.nextSam())};Fraction$1.prototype.cyclePos=function(){return this.sub(this.sam())};Fraction$1.prototype.lt=function(r){return this.compare(r)<0};Fraction$1.prototype.gt=function(r){return this.compare(r)>0};Fraction$1.prototype.lte=function(r){return this.compare(r)<=0};Fraction$1.prototype.gte=function(r){return this.compare(r)>=0};Fraction$1.prototype.eq=function(r){return this.compare(r)==0};Fraction$1.prototype.max=function(r){return this.gt(r)?this:r};Fraction$1.prototype.min=function(r){return this.lt(r)?this:r};Fraction$1.prototype.show=function(){return this.s*this.n+"/"+this.d};Fraction$1.prototype.or=function(r){return this.eq(0)?r:this};const fraction=r=>(typeof r=="number"&&(r=String(r)),Fraction$1(r)),gcd=(...r)=>r.reduce((t,e)=>t.gcd(e),fraction(1));fraction._original=Fraction$1;class TimeSpan{constructor(t,e){this.begin=fraction(t),this.end=fraction(e)}get spanCycles(){const t=[];var e=this.begin;const o=this.end,s=o.sam();if(e.equals(o))return[new TimeSpan(e,o)];for(;o.gt(e);){if(e.sam().equals(s)){t.push(new TimeSpan(e,this.end));break}const i=e.nextSam();t.push(new TimeSpan(e,i)),e=i}return t}get duration(){return this.end.sub(this.begin)}cycleArc(){const t=this.begin.cyclePos(),e=t.add(this.duration);return new TimeSpan(t,e)}withTime(t){return new TimeSpan(t(this.begin),t(this.end))}withEnd(t){return new TimeSpan(this.begin,t(this.end))}withCycle(t){const e=this.begin.sam(),o=e.add(t(this.begin.sub(e))),s=e.add(t(this.end.sub(e)));return new TimeSpan(o,s)}intersection(t){const e=this.begin.max(t.begin),o=this.end.min(t.end);if(!e.gt(o)&&!(e.equals(o)&&(e.equals(this.end)&&this.begin.lt(this.end)||e.equals(t.end)&&t.begin.lt(t.end))))return new TimeSpan(e,o)}intersection_e(t){const e=this.intersection(t);if(e==null)throw"TimeSpans do not intersect";return e}midpoint(){return this.begin.add(this.duration.div(fraction(2)))}equals(t){return this.begin.equals(t.begin)&&this.end.equals(t.end)}show(){return this.begin.show()+" -> "+this.end.show()}}class Hap{constructor(t,e,o,s={},i=!1){this.whole=t,this.part=e,this.value=o,this.context=s,this.stateful=i,i&&console.assert(typeof this.value=="function","Stateful values must be functions")}get duration(){return this.whole.end.sub(this.whole.begin)}wholeOrPart(){return this.whole?this.whole:this.part}withSpan(t){const e=this.whole?t(this.whole):void 0;return new Hap(e,t(this.part),this.value,this.context)}withValue(t){return new Hap(this.whole,this.part,t(this.value),this.context)}hasOnset(){return this.whole!=null&&this.whole.begin.equals(this.part.begin)}resolveState(t){if(this.stateful&&this.hasOnset()){console.log("stateful");const e=this.value,[o,s]=e(t);return[o,new Hap(this.whole,this.part,s,this.context,!1)]}return[t,this]}spanEquals(t){return this.whole==null&&t.whole==null||this.whole.equals(t.whole)}equals(t){return this.spanEquals(t)&&this.part.equals(t.part)&&this.value===t.value}show(){return"("+(this.whole==null?"~":this.whole.show())+", "+this.part.show()+", "+this.value+")"}showWhole(){return`${this.whole==null?"~":this.whole.show()}: ${typeof this.value=="object"?JSON.stringify(this.value):this.value}`}combineContext(t){const e=this;return{...e.context,...t.context,locations:(e.context.locations||[]).concat(t.context.locations||[])}}setContext(t){return new Hap(this.whole,this.part,this.value,t)}}class State{constructor(t,e={}){this.span=t,this.controls=e}setSpan(t){return new State(t,this.controls)}withSpan(t){return this.setSpan(t(this.span))}setControls(t){return new State(this.span,t)}}const isNote=r=>/^[a-gA-G][#b]*[0-9]$/.test(r),tokenizeNote=r=>{var s;if(typeof r!="string")return[];const[t,e="",o]=((s=r.match(/^([a-gA-G])([#bs]*)([0-9])?$/))==null?void 0:s.slice(1))||[];return t?[t,e,o?Number(o):void 0]:[]},toMidi=r=>{const[t,e,o]=tokenizeNote(r);if(!t)throw new Error('not a note: "'+r+'"');const s={c:0,d:2,e:4,f:5,g:7,a:9,b:11}[t.toLowerCase()],i=(e==null?void 0:e.split("").reduce((l,f)=>l+{"#":1,b:-1,s:1}[f],0))||0;return(Number(o)+1)*12+s+i},fromMidi=r=>Math.pow(2,(r-69)/12)*440,getFreq=r=>fromMidi(typeof r=="number"?r:toMidi(r)),midi2note=r=>{const t=Math.floor(r/12)-1;return["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"][r%12]+t},mod=(r,t)=>(r%t+t)%t,getPlayableNoteValue=r=>{let{value:t,context:e}=r;if(typeof t=="object"&&!Array.isArray(t)&&(t=t.note||t.n||t.value),typeof t=="number"&&e.type!=="frequency")t=fromMidi(r.value);else if(typeof t=="number"&&e.type==="frequency")t=r.value;else if(typeof t!="string"||!isNote(t))throw new Error("not a note: "+JSON.stringify(t));return t},getFrequency=r=>{let{value:t,context:e}=r;if(typeof t=="object")return t.freq?t.freq:getFreq(t.note||t.n||t.value);if(typeof t=="number"&&e.type!=="frequency")t=fromMidi(r.value);else if(typeof t=="string"&&isNote(t))t=fromMidi(toMidi(r.value));else if(typeof t!="number")throw new Error("not a note or frequency: "+t);return t},rotate=(r,t)=>r.slice(t).concat(r.slice(0,t)),pipe=(...r)=>r.reduce((t,e)=>(...o)=>t(e(...o)),t=>t),compose=(...r)=>pipe(...r.reverse()),removeUndefineds=r=>r.filter(t=>t!=null),flatten=r=>[].concat(...r),id=r=>r,constant=(r,t)=>r,listRange=(r,t)=>Array.from({length:t-r+1},(e,o)=>o+r);function curry(r,t){const e=function o(...s){if(s.length>=r.length)return r.apply(this,s);{const i=function(...l){return o.apply(this,s.concat(l))};return t&&t(i,s),i}};return t&&t(e,[]),e}function parseNumeral(r){const t=Number(r);if(!isNaN(t))return t;if(isNote(r))return toMidi(r);throw new Error(`cannot parse as numeral: "${r}"`)}function mapArgs(r,t){return(...e)=>r(...e.map(t))}function numeralArgs(r){return mapArgs(r,parseNumeral)}function parseFractional(r){const t=Number(r);if(!isNaN(t))return t;const e={pi:Math.PI,w:1,h:.5,q:.25,e:.125,s:.0625,t:1/3,f:.2,x:1/6}[r];if(typeof e<"u")return e;throw new Error(`cannot parse as fractional: "${r}"`)}const fractionalArgs=r=>mapArgs(r,parseFractional);function unionWithObj(r,t,e){const o=Object.keys(r).filter(s=>Object.keys(t).includes(s));return Object.assign({},r,t,Object.fromEntries(o.map(s=>[s,e(r[s],t[s])])))}curry((r,t)=>r*t);curry((r,t)=>t.map(r));function drawLine(r,t=60){let e=0,o=fraction(0),s=[""],i="";for(;s[0].lengthy.hasOnset()).map(y=>y.duration),g=gcd(...f),w=g.inverse();s=s.map(y=>y+"|"),i+="|";for(let y=0;yd.whole.begin.lte($)&&d.whole.end.gte(S)),p=C.length-s.length;p>0&&(s=s.concat(Array(p).fill(i))),s=s.map((d,m)=>{const b=C[m];if(b){const T=b.whole.begin.eq($)?""+b.value:"-";return d+T}return d+"."}),i+=".",o=o.add(g)}e++}return s.join(` -`)}let stringParser;const setStringParser=r=>stringParser=r;class Pattern$3{constructor(t){K(this,"_Pattern",!0);this.query=t}queryArc(t,e){return this.query(new State(new TimeSpan(t,e)))}_splitQueries(){const t=this,e=o=>flatten(o.span.spanCycles.map(s=>t.query(o.setSpan(s))));return new Pattern$3(e)}withQuerySpan(t){return new Pattern$3(e=>this.query(e.withSpan(t)))}withQuerySpanMaybe(t){const e=this;return new Pattern$3(o=>{const s=o.withSpan(t);return s.span?e.query(s):[]})}withQueryTime(t){return new Pattern$3(e=>this.query(e.withSpan(o=>o.withTime(t))))}withHapSpan(t){return new Pattern$3(e=>this.query(e).map(o=>o.withSpan(t)))}withHapTime(t){return this.withHapSpan(e=>e.withTime(t))}_withHaps(t){return new Pattern$3(e=>t(this.query(e)))}_withHap(t){return this._withHaps(e=>e.map(t))}_setContext(t){return this._withHap(e=>e.setContext(t))}_withContext(t){return this._withHap(e=>e.setContext(t(e.context)))}_stripContext(){return this._withHap(t=>t.setContext({}))}withLocation(t,e){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:e[0],column:e[1],offset:e[2]}};return this._withContext(s=>{const i=(s.locations||[]).concat([o]);return{...s,locations:i}})}withMiniLocation(t,e){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:e[0],column:e[1],offset:e[2]}};return this._withContext(s=>{let i=s.locations||[];return i=i.map(({start:l,end:f})=>{const g=l.line===1?o.start.column:0;return{start:{...l,line:l.line-1+(o.start.line-1)+1,column:l.column-1+g},end:{...f,line:f.line-1+(o.start.line-1)+1,column:f.column-1+g}}}),{...s,locations:i}})}withValue(t){return new Pattern$3(e=>this.query(e).map(o=>o.withValue(t)))}fmap(t){return this.withValue(t)}_filterHaps(t){return new Pattern$3(e=>this.query(e).filter(t))}_filterValues(t){return new Pattern$3(e=>this.query(e).filter(o=>t(o.value)))}_removeUndefineds(){return this._filterValues(t=>t!=null)}onsetsOnly(){return this._filterHaps(t=>t.hasOnset())}discreteOnly(){return this._filterHaps(t=>t.whole)}_appWhole(t,e){const o=this,s=function(i){const l=o.query(i),f=e.query(i),g=function(w,y){const $=w.part.intersection(y.part);if($!=null)return new Hap(t(w.whole,y.whole),$,w.value(y.value),y.combineContext(w))};return flatten(l.map(w=>removeUndefineds(f.map(y=>g(w,y)))))};return new Pattern$3(s)}appBoth(t){const e=function(o,s){if(!(o==null||s==null))return o.intersection_e(s)};return this._appWhole(e,t)}appLeft(t){const e=this,o=function(s){const i=[];for(const l of e.query(s)){const f=t.query(s.setSpan(l.wholeOrPart()));for(const g of f){const w=l.whole,y=l.part.intersection(g.part);if(y){const $=l.value(g.value),S=g.combineContext(l),C=new Hap(w,y,$,S);i.push(C)}}}return i};return new Pattern$3(o)}appRight(t){const e=this,o=function(s){const i=[];for(const l of t.query(s)){const f=e.query(s.setSpan(l.wholeOrPart()));for(const g of f){const w=l.whole,y=g.part.intersection(l.part);if(y){const $=g.value(l.value),S=l.combineContext(g),C=new Hap(w,y,$,S);i.push(C)}}}return i};return new Pattern$3(o)}firstCycle(t=!1){var e=this;return t||(e=e._stripContext()),e.query(new State(new TimeSpan(fraction(0),fraction(1))))}get _firstCycleValues(){return this.firstCycle().map(t=>t.value)}get _showFirstCycle(){return this.firstCycle().map(t=>`${t.value}: ${t.whole.begin.toFraction()} - ${t.whole.end.toFraction()}`)}_sortHapsByPart(){return this._withHaps(t=>t.sort((e,o)=>e.part.begin.sub(o.part.begin).or(e.part.end.sub(o.part.end)).or(e.whole.begin.sub(o.whole.begin).or(e.whole.end.sub(o.whole.end)))))}_opIn(t,e){return this.fmap(e).appLeft(reify$2(t))}_opOut(t,e){return this.fmap(e).appRight(reify$2(t))}_opMix(t,e){return this.fmap(e).appBoth(reify$2(t))}_opSqueeze(t,e){const o=reify$2(t);return this.fmap(s=>o.fmap(i=>e(s)(i)))._squeezeJoin()}_opSqueezeOut(t,e){const o=this;return reify$2(t).fmap(i=>o.fmap(l=>e(l)(i)))._squeezeJoin()}_opTrig(t,e){return reify$2(t).fmap(s=>this.fmap(i=>e(i)(s)))._trigJoin()}_opTrigzero(t,e){return reify$2(t).fmap(s=>this.fmap(i=>e(i)(s)))._TrigzeroJoin()}_asNumber(){return this.fmap(parseNumeral)}round(){return this._asNumber().fmap(t=>Math.round(t))}floor(){return this._asNumber().fmap(t=>Math.floor(t))}ceil(){return this._asNumber().fmap(t=>Math.ceil(t))}_toBipolar(){return this.fmap(t=>t*2-1)}_fromBipolar(){return this.fmap(t=>(t+1)/2)}_range(t,e){return this.mul(e-t).add(t)}_rangex(t,e){return this._range(Math.log(t),Math.log(e)).fmap(Math.exp)}_range2(t,e){return this._fromBipolar()._range(t,e)}_bindWhole(t,e){const o=this,s=function(i){const l=function(g,w){return new Hap(t(g.whole,w.whole),w.part,w.value,Object.assign({},g.context,w.context,{locations:(g.context.locations||[]).concat(w.context.locations||[])}))},f=function(g){return e(g.value).query(i.setSpan(g.part)).map(w=>l(g,w))};return flatten(o.query(i).map(g=>f(g)))};return new Pattern$3(s)}bind(t){const e=function(o,s){if(!(o==null||s==null))return o.intersection_e(s)};return this._bindWhole(e,t)}join(){return this.bind(id)}outerBind(t){return this._bindWhole((e,o)=>e,t)}outerJoin(){return this.outerBind(id)}innerBind(t){return this._bindWhole((e,o)=>o,t)}innerJoin(){return this.innerBind(id)}_trigJoin(t=!1){const e=this;return new Pattern$3(o=>e.discreteOnly().query(o).map(s=>s.value.late(t?s.whole.begin:s.whole.begin.cyclePos()).query(o).map(i=>new Hap(i.whole?i.whole.intersection(s.whole):void 0,i.part.intersection(s.part),i.value).setContext(s.combineContext(i))).filter(i=>i.part)).flat())}_TrigzeroJoin(){return this._trigJoin(!0)}_squeezeJoin(){const t=this;function e(o){const s=t.discreteOnly().query(o);function i(f){const w=f.value._focusSpan(f.wholeOrPart()).query(o.setSpan(f.part));function y($,S){let C;if(S.whole&&$.whole&&(C=S.whole.intersection($.whole),!C))return;const p=S.part.intersection($.part);if(!p)return;const d=S.combineContext($);return new Hap(C,p,S.value,d)}return w.map($=>y(f,$))}return flatten(s.map(i)).filter(f=>f)}return new Pattern$3(e)}_squeezeBind(t){return this.fmap(t)._squeezeJoin()}_apply(t){return t(this)}layer(...t){return stack$1(...t.map(e=>e(this)))}_patternify(t){const e=this;return function(...s){return s=s.map(l=>isPattern$1(l)?l.fmap(f=>f.value||f):l),sequence$1(...s).fmap(l=>t.call(e,l)).innerJoin()}}_fastGap(t){const e=function(s){const i=s.begin.sam(),l=s.begin.sub(i).mul(t).min(1),f=s.end.sub(i).mul(t).min(1);if(!(l>=1))return new TimeSpan(i.add(l),i.add(f))},o=function(s){const i=s.part.begin,l=s.part.end,f=i.sam(),g=i.sub(f).div(t).min(1),w=l.sub(f).div(t).min(1),y=new TimeSpan(f.add(g),f.add(w)),$=s.whole?new TimeSpan(y.begin.sub(i.sub(s.whole.begin).div(t)),y.end.add(s.whole.end.sub(l).div(t))):void 0;return new Hap($,y,s.value,s.context)};return this.withQuerySpanMaybe(e)._withHap(o)._splitQueries()}_compress(t,e){return t.gt(e)||t.gt(1)||e.gt(1)||t.lt(0)||e.lt(0)?silence$1:this._fastGap(fraction(1).div(e.sub(t)))._late(t)}_compressSpan(t){return this._compress(t.begin,t.end)}_focus(t,e){return this._fast(fraction(1).div(e.sub(t))).late(t.cyclePos())}_focusSpan(t){return this._focus(t.begin,t.end)}_fast(t){return this.withQueryTime(o=>o.mul(t)).withHapTime(o=>o.div(t))}_slow(t){return this._fast(fraction(1).div(t))}_inside(t,e){return e(this._slow(t))._fast(t)}_outside(t,e){return e(this._fast(t))._slow(t)}_ply(t){return this.fmap(e=>pure$1(e)._fast(t))._squeezeJoin()}_chop(t){const o=Array.from({length:t},(i,l)=>l).map(i=>({begin:i/t,end:(i+1)/t})),s=function(i){return sequence$1(o.map(l=>Object.assign({},i,l)))};return this._squeezeBind(s)}_striate(t){const o=Array.from({length:t},(i,l)=>l).map(i=>({begin:i/t,end:(i+1)/t})),s=slowcat$1(...o);return this.set(s)._fast(t)}_cpm(t){return this._fast(t/60)}_early(t){return t=fraction(t),this.withQueryTime(e=>e.add(t)).withHapTime(e=>e.sub(t))}_late(t){return t=fraction(t),this._early(fraction(0).sub(t))}_zoom(t,e){e=fraction(e),t=fraction(t);const o=e.sub(t);return this.withQuerySpan(s=>s.withCycle(i=>i.mul(o).add(t))).withHapSpan(s=>s.withCycle(i=>i.sub(t).div(o)))._splitQueries()}_zoomArc(t){return this.zoom(t.begin,t.end)}_linger(t){return t==0?silence$1:t<0?this._zoom(t.add(1),1)._slow(t):this._zoom(0,t)._slow(t)}_color(t){return this._withContext(e=>({...e,color:t}))}log(){return this._withHap(t=>{var e;return t.setContext({...t.context,logs:(((e=t.context)==null?void 0:e.logs)||[]).concat([t.show()])})})}drawLine(){return console.log(drawLine(this)),this}_segment(t){return this.struct(pure$1(!0)._fast(t))}invert(){return this.fmap(t=>!t)}inv(){return this.invert()}when(t,e){const o=t._filterValues(id),s=t._filterValues(f=>!f),i=o.fmap(f=>g=>g).appRight(e(this)),l=s.fmap(f=>g=>g).appRight(this);return stack$1(i,l)}off(t,e){return stack$1(this,e(this.late(t)))}every(t,e){const o=this,s=Array(t-1).fill(o);return s.push(e(o)),slowcatPrime(...s)}every(t,e){const o=this,s=Array(t-1).fill(o);return s.unshift(e(o)),slowcatPrime(...s)}each(t,e){const o=this,s=Array(t-1).fill(o);return s.push(e(o)),slowcatPrime(...s)}brak(){return this.when(slowcat$1(!1,!0),t=>fastcat(t,silence$1)._late(.25))}rev(){const t=this,e=function(o){const s=o.span,i=s.begin.sam(),l=s.begin.nextSam(),f=function(w){const y=w.withTime(S=>i.add(l.sub(S))),$=y.begin;return y.begin=y.end,y.end=$,y};return t.query(o.setSpan(f(s))).map(w=>w.withSpan(f))};return new Pattern$3(e)._splitQueries()}palindrome(){return this.every(2,rev)}juxBy(t,e){t/=2;const o=function(l,f,g){return f in l?l[f]:g},s=this.withValue(l=>Object.assign({},l,{pan:o(l,"pan",.5)-t})),i=this.withValue(l=>Object.assign({},l,{pan:o(l,"pan",.5)+t}));return stack$1(s,e(i))}_jux(t){return this.juxBy(1,t)}stack(...t){return stack$1(this,...t)}sequence(...t){return sequence$1(this,...t)}seq(...t){return sequence$1(this,...t)}cat(...t){return cat(this,...t)}fastcat(...t){return fastcat(this,...t)}slowcat(...t){return slowcat$1(this,...t)}superimpose(...t){return this.stack(...t.map(e=>e(this)))}stutWith(t,e,o){return stack$1(...listRange(0,t-1).map(s=>o(this.late(fraction(e).mul(s)),s)))}stut(t,e,o){return this.stutWith(t,o,(s,i)=>s.velocity(Math.pow(e,i)))}_echoWith(t,e,o){return stack$1(...listRange(0,t-1).map(s=>o(this.late(fraction(e).mul(s)),s)))}_echo(t,e,o){return this._echoWith(t,e,(s,i)=>s.velocity(Math.pow(o,i)))}iter(t,e=!1){return slowcat$1(...listRange(0,t-1).map(o=>e?this.late(o/t):this.early(o/t)))}iterBack(t){return this.iter(t,!0)}_chunk(t,e,o=!1){const s=Array(t-1).fill(!1);s.unshift(!0);const i=sequence$1(...s).iter(t,o);return this.when(i,e)}_chunkBack(t,e){return this._chunk(t,e,!0)}_bypass(t){return t=Boolean(parseInt(t)),t?silence$1:this}hush(){return silence$1}_duration(t){return this.withHapSpan(e=>new TimeSpan(e.begin,e.begin.add(t)))}_legato(t){return this.withHapSpan(e=>new TimeSpan(e.begin,e.begin.add(e.end.sub(e.begin).mul(t))))}_velocity(t){return this._withContext(e=>({...e,velocity:(e.velocity||1)*t}))}_loopAt(t,e=1){return this.speed(1/t*e).unit("c").slow(t)}onTrigger(t){return this._withHap(e=>e.setContext({...e.context,onTrigger:t}))}log(t=id){return this._withHap(e=>e.setContext({...e.context,onTrigger:(...o)=>{e.context.onTrigger&&e.context.onTrigger(...o),console.log(t(...o))}}))}logValues(t=id){return this.log((e,o)=>t(o.value))}}function _composeOp(r,t,e){function o(s){return s instanceof Object&&!(s instanceof Function)}return o(r)||o(t)?(o(r)||(r={value:r}),o(t)||(t={value:t}),unionWithObj(r,t,e)):e(r,t)}(function(){const r={set:[(t,e)=>e],keep:[(t,e)=>t],keepif:[(t,e)=>e?t:void 0],add:[numeralArgs((t,e)=>t+e)],sub:[numeralArgs((t,e)=>t-e)],mul:[numeralArgs((t,e)=>t*e)],div:[numeralArgs((t,e)=>t/e)],mod:[numeralArgs(mod)],pow:[numeralArgs(Math.pow)],_and:[numeralArgs((t,e)=>t&e)],_or:[numeralArgs((t,e)=>t|e)],_xor:[numeralArgs((t,e)=>t^e)],_lshift:[numeralArgs((t,e)=>t<t>>e)],lt:[(t,e)=>tt>e],lte:[(t,e)=>t<=e],gte:[(t,e)=>t>=e],eq:[(t,e)=>t==e],eqt:[(t,e)=>t===e],ne:[(t,e)=>t!=e],net:[(t,e)=>t!==e],and:[(t,e)=>t&&e],or:[(t,e)=>t||e],func:[(t,e)=>e(t)]};for(const[t,[e,o]]of Object.entries(r))for(const s of["In","Out","Mix","Squeeze","SqueezeOut","Trig","Trigzero"])Pattern$3.prototype[t+s]=function(...i){var l=this;i=sequence$1(i),o&&(l=o(l),i=o(i));var f;return t==="keepif"?(f=l["_op"+s](i,g=>w=>e(g,w)),f=f._removeUndefineds()):f=l["_op"+s](i,g=>w=>_composeOp(g,w,e)),f},s==="Squeeze"&&(Pattern$3.prototype[t+"SqueezeIn"]=Pattern$3.prototype[t+s]),s==="In"?Pattern$3.prototype[t]=Pattern$3.prototype[t+s]:t==="set"&&(Pattern$3.prototype[s.toLowerCase()]=Pattern$3.prototype[t+s]);Pattern$3.prototype.struct=Pattern$3.prototype.keepifOut,Pattern$3.prototype.structAll=Pattern$3.prototype.keepOut,Pattern$3.prototype.mask=Pattern$3.prototype.keepifIn,Pattern$3.prototype.maskAll=Pattern$3.prototype.keepIn,Pattern$3.prototype.reset=Pattern$3.prototype.keepifTrig,Pattern$3.prototype.resetAll=Pattern$3.prototype.keepTrig,Pattern$3.prototype.restart=Pattern$3.prototype.keepifTrigzero,Pattern$3.prototype.restartAll=Pattern$3.prototype.keepTrigzero})();Pattern$3.prototype.patternified=["apply","chop","color","cpm","duration","early","fast","jux","late","legato","linger","ply","segment","striate","slow","velocity"];const polyrhythm=stack$1,pr=stack$1;Pattern$3.prototype.factories={pure:pure$1,stack:stack$1,slowcat:slowcat$1,fastcat,cat,timeCat:timeCat$1,sequence:sequence$1,seq,polymeter,pm,polyrhythm,pr};const silence$1=new Pattern$3(r=>[]);function pure$1(r){function t(e){return e.span.spanCycles.map(o=>new Hap(fraction(o.begin).wholeCycle(),o,r))}return new Pattern$3(t)}function isPattern$1(r){const t=r instanceof Pattern$3||(r==null?void 0:r._Pattern);return!r instanceof Pattern$3&&console.warn(`Found Pattern that fails "instanceof Pattern" check. + **/(function(r,t){(function(e){var o=2e3,s={s:1,n:0,d:1};function i(p,d){if(isNaN(p=parseInt(p,10)))throw C.InvalidParameter;return p*d}function f(p,d){if(d===0)throw C.DivisionByZero;var m=Object.create(C.prototype);m.s=p<0?-1:1,p=p<0?-p:p;var b=S(p,d);return m.n=p/b,m.d=d/b,m}function l(p){for(var d={},m=p,b=2,I=4;I<=m;){for(;m%b===0;)m/=b,d[b]=(d[b]||0)+1;I+=1+2*b++}return m!==p?m>1&&(d[m]=(d[m]||0)+1):d[p]=(d[p]||0)+1,d}var g=function(p,d){var m=0,b=1,I=1,T=0,G=0,Y=0,D=1,W=1,P=0,B=1,z=1,O=1,Z=1e7,L;if(p!=null)if(d!==void 0){if(m=p,b=d,I=m*b,m%1!==0||b%1!==0)throw C.NonIntegerParameter}else switch(typeof p){case"object":{if("d"in p&&"n"in p)m=p.n,b=p.d,"s"in p&&(m*=p.s);else if(0 in p)m=p[0],1 in p&&(b=p[1]);else throw C.InvalidParameter;I=m*b;break}case"number":{if(p<0&&(I=p,p=-p),p%1===0)m=p;else if(p>0){for(p>=1&&(W=Math.pow(10,Math.floor(1+Math.log(p)/Math.LN10)),p/=W);B<=Z&&O<=Z;)if(L=(P+z)/(B+O),p===L){B+O<=Z?(m=P+z,b=B+O):O>B?(m=z,b=O):(m=P,b=B);break}else p>L?(P+=z,B+=O):(z+=P,O+=B),B>Z?(m=z,b=O):(m=P,b=B);m*=W}else(isNaN(p)||isNaN(d))&&(b=m=NaN);break}case"string":{if(B=p.match(/\d+|./g),B===null)throw C.InvalidParameter;if(B[P]==="-"?(I=-1,P++):B[P]==="+"&&P++,B.length===P+1?G=i(B[P++],I):B[P+1]==="."||B[P]==="."?(B[P]!=="."&&(T=i(B[P++],I)),P++,(P+1===B.length||B[P+1]==="("&&B[P+3]===")"||B[P+1]==="'"&&B[P+3]==="'")&&(G=i(B[P],I),D=Math.pow(10,B[P].length),P++),(B[P]==="("&&B[P+2]===")"||B[P]==="'"&&B[P+2]==="'")&&(Y=i(B[P+1],I),W=Math.pow(10,B[P+1].length)-1,P+=3)):B[P+1]==="/"||B[P+1]===":"?(G=i(B[P],I),D=i(B[P+2],1),P+=3):B[P+3]==="/"&&B[P+1]===" "&&(T=i(B[P],I),G=i(B[P+2],I),D=i(B[P+4],1),P+=5),B.length<=P){b=D*W,I=m=Y+b*T+W*G;break}}default:throw C.InvalidParameter}if(b===0)throw C.DivisionByZero;s.s=I<0?-1:1,s.n=Math.abs(m),s.d=Math.abs(b)};function w(p,d,m){for(var b=1;d>0;p=p*p%m,d>>=1)d&1&&(b=b*p%m);return b}function y(p,d){for(;d%2===0;d/=2);for(;d%5===0;d/=5);if(d===1)return 0;for(var m=10%d,b=1;m!==1;b++)if(m=m*10%d,b>o)return 0;return b}function $(p,d,m){for(var b=1,I=w(10,m,d),T=0;T<300;T++){if(b===I)return T;b=b*10%d,I=I*10%d}return 0}function S(p,d){if(!p)return d;if(!d)return p;for(;;){if(p%=d,!p)return d;if(d%=p,!d)return p}}function C(p,d){if(g(p,d),this instanceof C)p=S(s.d,s.n),this.s=s.s,this.n=s.n/p,this.d=s.d/p;else return f(s.s*s.n,s.d)}C.DivisionByZero=new Error("Division by Zero"),C.InvalidParameter=new Error("Invalid argument"),C.NonIntegerParameter=new Error("Parameters must be integer"),C.prototype={s:1,n:0,d:1,abs:function(){return f(this.n,this.d)},neg:function(){return f(-this.s*this.n,this.d)},add:function(p,d){return g(p,d),f(this.s*this.n*s.d+s.s*this.d*s.n,this.d*s.d)},sub:function(p,d){return g(p,d),f(this.s*this.n*s.d-s.s*this.d*s.n,this.d*s.d)},mul:function(p,d){return g(p,d),f(this.s*s.s*this.n*s.n,this.d*s.d)},div:function(p,d){return g(p,d),f(this.s*s.s*this.n*s.d,this.d*s.n)},clone:function(){return f(this.s*this.n,this.d)},mod:function(p,d){if(isNaN(this.n)||isNaN(this.d))return new C(NaN);if(p===void 0)return f(this.s*this.n%this.d,1);if(g(p,d),s.n===0&&this.d===0)throw C.DivisionByZero;return f(this.s*(s.d*this.n)%(s.n*this.d),s.d*this.d)},gcd:function(p,d){return g(p,d),f(S(s.n,this.n)*S(s.d,this.d),s.d*this.d)},lcm:function(p,d){return g(p,d),s.n===0&&this.n===0?f(0,1):f(s.n*this.n,S(s.n,this.n)*S(s.d,this.d))},ceil:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):f(Math.ceil(p*this.s*this.n/this.d),p)},floor:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):f(Math.floor(p*this.s*this.n/this.d),p)},round:function(p){return p=Math.pow(10,p||0),isNaN(this.n)||isNaN(this.d)?new C(NaN):f(Math.round(p*this.s*this.n/this.d),p)},inverse:function(){return f(this.s*this.d,this.n)},pow:function(p,d){if(g(p,d),s.d===1)return s.s<0?f(Math.pow(this.s*this.d,s.n),Math.pow(this.n,s.n)):f(Math.pow(this.s*this.n,s.n),Math.pow(this.d,s.n));if(this.s<0)return null;var m=l(this.n),b=l(this.d),I=1,T=1;for(var G in m)if(G!=="1"){if(G==="0"){I=0;break}if(m[G]*=s.n,m[G]%s.d===0)m[G]/=s.d;else return null;I*=Math.pow(G,m[G])}for(var G in b)if(G!=="1"){if(b[G]*=s.n,b[G]%s.d===0)b[G]/=s.d;else return null;T*=Math.pow(G,b[G])}return s.s<0?f(T,I):f(I,T)},equals:function(p,d){return g(p,d),this.s*this.n*s.d===s.s*s.n*this.d},compare:function(p,d){g(p,d);var m=this.s*this.n*s.d-s.s*s.n*this.d;return(0=0;T--)I=I.inverse().add(m[T]);if(I.sub(d).abs().valueOf()0&&(m+=d,m+=" ",b%=I),m+=b,m+="/",m+=I),m},toLatex:function(p){var d,m="",b=this.n,I=this.d;return this.s<0&&(m+="-"),I===1?m+=b:(p&&(d=Math.floor(b/I))>0&&(m+=d,b%=I),m+="\\frac{",m+=b,m+="}{",m+=I,m+="}"),m},toContinued:function(){var p,d=this.n,m=this.d,b=[];if(isNaN(d)||isNaN(m))return b;do b.push(Math.floor(d/m)),p=d%m,d=m,m=p;while(d!==1);return b},toString:function(p){var d=this.n,m=this.d;if(isNaN(d)||isNaN(m))return"NaN";p=p||15;var b=y(d,m),I=$(d,m,b),T=this.s<0?"-":"";if(T+=d/m|0,d%=m,d*=10,d&&(T+="."),b){for(var G=I;G--;)T+=d/m|0,d%=m,d*=10;T+="(";for(var G=b;G--;)T+=d/m|0,d%=m,d*=10;T+=")"}else for(var G=p;d&&G--;)T+=d/m|0,d%=m,d*=10;return T}},Object.defineProperty(C,"__esModule",{value:!0}),C.default=C,C.Fraction=C,r.exports=C})()})(fraction$1);const Fraction$1=getDefaultExportFromCjs(fraction$1.exports);Fraction$1.prototype.sam=function(){return this.floor()};Fraction$1.prototype.nextSam=function(){return this.sam().add(1)};Fraction$1.prototype.wholeCycle=function(){return new TimeSpan(this.sam(),this.nextSam())};Fraction$1.prototype.cyclePos=function(){return this.sub(this.sam())};Fraction$1.prototype.lt=function(r){return this.compare(r)<0};Fraction$1.prototype.gt=function(r){return this.compare(r)>0};Fraction$1.prototype.lte=function(r){return this.compare(r)<=0};Fraction$1.prototype.gte=function(r){return this.compare(r)>=0};Fraction$1.prototype.eq=function(r){return this.compare(r)==0};Fraction$1.prototype.max=function(r){return this.gt(r)?this:r};Fraction$1.prototype.min=function(r){return this.lt(r)?this:r};Fraction$1.prototype.show=function(){return this.s*this.n+"/"+this.d};Fraction$1.prototype.or=function(r){return this.eq(0)?r:this};const fraction=r=>(typeof r=="number"&&(r=String(r)),Fraction$1(r)),gcd=(...r)=>r.reduce((t,e)=>t.gcd(e),fraction(1));fraction._original=Fraction$1;class TimeSpan{constructor(t,e){this.begin=fraction(t),this.end=fraction(e)}get spanCycles(){const t=[];var e=this.begin;const o=this.end,s=o.sam();if(e.equals(o))return[new TimeSpan(e,o)];for(;o.gt(e);){if(e.sam().equals(s)){t.push(new TimeSpan(e,this.end));break}const i=e.nextSam();t.push(new TimeSpan(e,i)),e=i}return t}get duration(){return this.end.sub(this.begin)}cycleArc(){const t=this.begin.cyclePos(),e=t.add(this.duration);return new TimeSpan(t,e)}withTime(t){return new TimeSpan(t(this.begin),t(this.end))}withEnd(t){return new TimeSpan(this.begin,t(this.end))}withCycle(t){const e=this.begin.sam(),o=e.add(t(this.begin.sub(e))),s=e.add(t(this.end.sub(e)));return new TimeSpan(o,s)}intersection(t){const e=this.begin.max(t.begin),o=this.end.min(t.end);if(!e.gt(o)&&!(e.equals(o)&&(e.equals(this.end)&&this.begin.lt(this.end)||e.equals(t.end)&&t.begin.lt(t.end))))return new TimeSpan(e,o)}intersection_e(t){const e=this.intersection(t);if(e==null)throw"TimeSpans do not intersect";return e}midpoint(){return this.begin.add(this.duration.div(fraction(2)))}equals(t){return this.begin.equals(t.begin)&&this.end.equals(t.end)}show(){return this.begin.show()+" -> "+this.end.show()}}class Hap{constructor(t,e,o,s={},i=!1){this.whole=t,this.part=e,this.value=o,this.context=s,this.stateful=i,i&&console.assert(typeof this.value=="function","Stateful values must be functions")}get duration(){return this.whole.end.sub(this.whole.begin)}wholeOrPart(){return this.whole?this.whole:this.part}withSpan(t){const e=this.whole?t(this.whole):void 0;return new Hap(e,t(this.part),this.value,this.context)}withValue(t){return new Hap(this.whole,this.part,t(this.value),this.context)}hasOnset(){return this.whole!=null&&this.whole.begin.equals(this.part.begin)}resolveState(t){if(this.stateful&&this.hasOnset()){console.log("stateful");const e=this.value,[o,s]=e(t);return[o,new Hap(this.whole,this.part,s,this.context,!1)]}return[t,this]}spanEquals(t){return this.whole==null&&t.whole==null||this.whole.equals(t.whole)}equals(t){return this.spanEquals(t)&&this.part.equals(t.part)&&this.value===t.value}show(){return"("+(this.whole==null?"~":this.whole.show())+", "+this.part.show()+", "+this.value+")"}showWhole(){return`${this.whole==null?"~":this.whole.show()}: ${typeof this.value=="object"?JSON.stringify(this.value):this.value}`}combineContext(t){const e=this;return{...e.context,...t.context,locations:(e.context.locations||[]).concat(t.context.locations||[])}}setContext(t){return new Hap(this.whole,this.part,this.value,t)}}class State{constructor(t,e={}){this.span=t,this.controls=e}setSpan(t){return new State(t,this.controls)}withSpan(t){return this.setSpan(t(this.span))}setControls(t){return new State(this.span,t)}}const isNote=r=>/^[a-gA-G][#b]*[0-9]$/.test(r),tokenizeNote=r=>{var s;if(typeof r!="string")return[];const[t,e="",o]=((s=r.match(/^([a-gA-G])([#bs]*)([0-9])?$/))==null?void 0:s.slice(1))||[];return t?[t,e,o?Number(o):void 0]:[]},toMidi=r=>{const[t,e,o]=tokenizeNote(r);if(!t)throw new Error('not a note: "'+r+'"');const s={c:0,d:2,e:4,f:5,g:7,a:9,b:11}[t.toLowerCase()],i=(e==null?void 0:e.split("").reduce((f,l)=>f+{"#":1,b:-1,s:1}[l],0))||0;return(Number(o)+1)*12+s+i},fromMidi=r=>Math.pow(2,(r-69)/12)*440,getFreq=r=>fromMidi(typeof r=="number"?r:toMidi(r)),midi2note=r=>{const t=Math.floor(r/12)-1;return["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"][r%12]+t},mod=(r,t)=>(r%t+t)%t,getPlayableNoteValue=r=>{let{value:t,context:e}=r;if(typeof t=="object"&&!Array.isArray(t)&&(t=t.note||t.n||t.value),typeof t=="number"&&e.type!=="frequency")t=fromMidi(r.value);else if(typeof t=="number"&&e.type==="frequency")t=r.value;else if(typeof t!="string"||!isNote(t))throw new Error("not a note: "+JSON.stringify(t));return t},getFrequency=r=>{let{value:t,context:e}=r;if(typeof t=="object")return t.freq?t.freq:getFreq(t.note||t.n||t.value);if(typeof t=="number"&&e.type!=="frequency")t=fromMidi(r.value);else if(typeof t=="string"&&isNote(t))t=fromMidi(toMidi(r.value));else if(typeof t!="number")throw new Error("not a note or frequency: "+t);return t},rotate=(r,t)=>r.slice(t).concat(r.slice(0,t)),pipe=(...r)=>r.reduce((t,e)=>(...o)=>t(e(...o)),t=>t),compose=(...r)=>pipe(...r.reverse()),removeUndefineds=r=>r.filter(t=>t!=null),flatten=r=>[].concat(...r),id=r=>r,constant=(r,t)=>r,listRange=(r,t)=>Array.from({length:t-r+1},(e,o)=>o+r);function curry(r,t){const e=function o(...s){if(s.length>=r.length)return r.apply(this,s);{const i=function(...f){return o.apply(this,s.concat(f))};return t&&t(i,s),i}};return t&&t(e,[]),e}function parseNumeral(r){const t=Number(r);if(!isNaN(t))return t;if(isNote(r))return toMidi(r);throw new Error(`cannot parse as numeral: "${r}"`)}function mapArgs(r,t){return(...e)=>r(...e.map(t))}function numeralArgs(r){return mapArgs(r,parseNumeral)}function parseFractional(r){const t=Number(r);if(!isNaN(t))return t;const e={pi:Math.PI,w:1,h:.5,q:.25,e:.125,s:.0625,t:1/3,f:.2,x:1/6}[r];if(typeof e<"u")return e;throw new Error(`cannot parse as fractional: "${r}"`)}const fractionalArgs=r=>mapArgs(r,parseFractional);function unionWithObj(r,t,e){const o=Object.keys(r).filter(s=>Object.keys(t).includes(s));return Object.assign({},r,t,Object.fromEntries(o.map(s=>[s,e(r[s],t[s])])))}curry((r,t)=>r*t);curry((r,t)=>t.map(r));function drawLine(r,t=60){let e=0,o=fraction(0),s=[""],i="";for(;s[0].lengthy.hasOnset()).map(y=>y.duration),g=gcd(...l),w=g.inverse();s=s.map(y=>y+"|"),i+="|";for(let y=0;yd.whole.begin.lte($)&&d.whole.end.gte(S)),p=C.length-s.length;p>0&&(s=s.concat(Array(p).fill(i))),s=s.map((d,m)=>{const b=C[m];if(b){const T=b.whole.begin.eq($)?""+b.value:"-";return d+T}return d+"."}),i+=".",o=o.add(g)}e++}return s.join(` +`)}let stringParser;const setStringParser=r=>stringParser=r;class Pattern$3{constructor(t){K(this,"_Pattern",!0);this.query=t}queryArc(t,e){return this.query(new State(new TimeSpan(t,e)))}_splitQueries(){const t=this,e=o=>flatten(o.span.spanCycles.map(s=>t.query(o.setSpan(s))));return new Pattern$3(e)}withQuerySpan(t){return new Pattern$3(e=>this.query(e.withSpan(t)))}withQuerySpanMaybe(t){const e=this;return new Pattern$3(o=>{const s=o.withSpan(t);return s.span?e.query(s):[]})}withQueryTime(t){return new Pattern$3(e=>this.query(e.withSpan(o=>o.withTime(t))))}withHapSpan(t){return new Pattern$3(e=>this.query(e).map(o=>o.withSpan(t)))}withHapTime(t){return this.withHapSpan(e=>e.withTime(t))}_withHaps(t){return new Pattern$3(e=>t(this.query(e)))}_withHap(t){return this._withHaps(e=>e.map(t))}_setContext(t){return this._withHap(e=>e.setContext(t))}_withContext(t){return this._withHap(e=>e.setContext(t(e.context)))}_stripContext(){return this._withHap(t=>t.setContext({}))}withLocation(t,e){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:e[0],column:e[1],offset:e[2]}};return this._withContext(s=>{const i=(s.locations||[]).concat([o]);return{...s,locations:i}})}withMiniLocation(t,e){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:e[0],column:e[1],offset:e[2]}};return this._withContext(s=>{let i=s.locations||[];return i=i.map(({start:f,end:l})=>{const g=f.line===1?o.start.column:0;return{start:{...f,line:f.line-1+(o.start.line-1)+1,column:f.column-1+g},end:{...l,line:l.line-1+(o.start.line-1)+1,column:l.column-1+g}}}),{...s,locations:i}})}withValue(t){return new Pattern$3(e=>this.query(e).map(o=>o.withValue(t)))}fmap(t){return this.withValue(t)}_filterHaps(t){return new Pattern$3(e=>this.query(e).filter(t))}_filterValues(t){return new Pattern$3(e=>this.query(e).filter(o=>t(o.value)))}_removeUndefineds(){return this._filterValues(t=>t!=null)}onsetsOnly(){return this._filterHaps(t=>t.hasOnset())}discreteOnly(){return this._filterHaps(t=>t.whole)}_appWhole(t,e){const o=this,s=function(i){const f=o.query(i),l=e.query(i),g=function(w,y){const $=w.part.intersection(y.part);if($!=null)return new Hap(t(w.whole,y.whole),$,w.value(y.value),y.combineContext(w))};return flatten(f.map(w=>removeUndefineds(l.map(y=>g(w,y)))))};return new Pattern$3(s)}appBoth(t){const e=function(o,s){if(!(o==null||s==null))return o.intersection_e(s)};return this._appWhole(e,t)}appLeft(t){const e=this,o=function(s){const i=[];for(const f of e.query(s)){const l=t.query(s.setSpan(f.wholeOrPart()));for(const g of l){const w=f.whole,y=f.part.intersection(g.part);if(y){const $=f.value(g.value),S=g.combineContext(f),C=new Hap(w,y,$,S);i.push(C)}}}return i};return new Pattern$3(o)}appRight(t){const e=this,o=function(s){const i=[];for(const f of t.query(s)){const l=e.query(s.setSpan(f.wholeOrPart()));for(const g of l){const w=f.whole,y=g.part.intersection(f.part);if(y){const $=g.value(f.value),S=f.combineContext(g),C=new Hap(w,y,$,S);i.push(C)}}}return i};return new Pattern$3(o)}firstCycle(t=!1){var e=this;return t||(e=e._stripContext()),e.query(new State(new TimeSpan(fraction(0),fraction(1))))}get _firstCycleValues(){return this.firstCycle().map(t=>t.value)}get _showFirstCycle(){return this.firstCycle().map(t=>`${t.value}: ${t.whole.begin.toFraction()} - ${t.whole.end.toFraction()}`)}_sortHapsByPart(){return this._withHaps(t=>t.sort((e,o)=>e.part.begin.sub(o.part.begin).or(e.part.end.sub(o.part.end)).or(e.whole.begin.sub(o.whole.begin).or(e.whole.end.sub(o.whole.end)))))}_opIn(t,e){return this.fmap(e).appLeft(reify$2(t))}_opOut(t,e){return this.fmap(e).appRight(reify$2(t))}_opMix(t,e){return this.fmap(e).appBoth(reify$2(t))}_opSqueeze(t,e){const o=reify$2(t);return this.fmap(s=>o.fmap(i=>e(s)(i)))._squeezeJoin()}_opSqueezeOut(t,e){const o=this;return reify$2(t).fmap(i=>o.fmap(f=>e(f)(i)))._squeezeJoin()}_opTrig(t,e){return reify$2(t).fmap(s=>this.fmap(i=>e(i)(s)))._trigJoin()}_opTrigzero(t,e){return reify$2(t).fmap(s=>this.fmap(i=>e(i)(s)))._TrigzeroJoin()}_asNumber(){return this.fmap(parseNumeral)}round(){return this._asNumber().fmap(t=>Math.round(t))}floor(){return this._asNumber().fmap(t=>Math.floor(t))}ceil(){return this._asNumber().fmap(t=>Math.ceil(t))}_toBipolar(){return this.fmap(t=>t*2-1)}_fromBipolar(){return this.fmap(t=>(t+1)/2)}_range(t,e){return this.mul(e-t).add(t)}_rangex(t,e){return this._range(Math.log(t),Math.log(e)).fmap(Math.exp)}_range2(t,e){return this._fromBipolar()._range(t,e)}_bindWhole(t,e){const o=this,s=function(i){const f=function(g,w){return new Hap(t(g.whole,w.whole),w.part,w.value,Object.assign({},g.context,w.context,{locations:(g.context.locations||[]).concat(w.context.locations||[])}))},l=function(g){return e(g.value).query(i.setSpan(g.part)).map(w=>f(g,w))};return flatten(o.query(i).map(g=>l(g)))};return new Pattern$3(s)}bind(t){const e=function(o,s){if(!(o==null||s==null))return o.intersection_e(s)};return this._bindWhole(e,t)}join(){return this.bind(id)}outerBind(t){return this._bindWhole((e,o)=>e,t)}outerJoin(){return this.outerBind(id)}innerBind(t){return this._bindWhole((e,o)=>o,t)}innerJoin(){return this.innerBind(id)}_trigJoin(t=!1){const e=this;return new Pattern$3(o=>e.discreteOnly().query(o).map(s=>s.value.late(t?s.whole.begin:s.whole.begin.cyclePos()).query(o).map(i=>new Hap(i.whole?i.whole.intersection(s.whole):void 0,i.part.intersection(s.part),i.value).setContext(s.combineContext(i))).filter(i=>i.part)).flat())}_TrigzeroJoin(){return this._trigJoin(!0)}_squeezeJoin(){const t=this;function e(o){const s=t.discreteOnly().query(o);function i(l){const w=l.value._focusSpan(l.wholeOrPart()).query(o.setSpan(l.part));function y($,S){let C;if(S.whole&&$.whole&&(C=S.whole.intersection($.whole),!C))return;const p=S.part.intersection($.part);if(!p)return;const d=S.combineContext($);return new Hap(C,p,S.value,d)}return w.map($=>y(l,$))}return flatten(s.map(i)).filter(l=>l)}return new Pattern$3(e)}_squeezeBind(t){return this.fmap(t)._squeezeJoin()}_apply(t){return t(this)}layer(...t){return stack$1(...t.map(e=>e(this)))}_patternify(t){const e=this;return function(...s){return s=s.map(f=>isPattern$1(f)?f.fmap(l=>l.value||l):f),sequence$1(...s).fmap(f=>t.call(e,f)).innerJoin()}}_fastGap(t){const e=function(s){const i=s.begin.sam(),f=s.begin.sub(i).mul(t).min(1),l=s.end.sub(i).mul(t).min(1);if(!(f>=1))return new TimeSpan(i.add(f),i.add(l))},o=function(s){const i=s.part.begin,f=s.part.end,l=i.sam(),g=i.sub(l).div(t).min(1),w=f.sub(l).div(t).min(1),y=new TimeSpan(l.add(g),l.add(w)),$=s.whole?new TimeSpan(y.begin.sub(i.sub(s.whole.begin).div(t)),y.end.add(s.whole.end.sub(f).div(t))):void 0;return new Hap($,y,s.value,s.context)};return this.withQuerySpanMaybe(e)._withHap(o)._splitQueries()}_compress(t,e){return t.gt(e)||t.gt(1)||e.gt(1)||t.lt(0)||e.lt(0)?silence$1:this._fastGap(fraction(1).div(e.sub(t)))._late(t)}_compressSpan(t){return this._compress(t.begin,t.end)}_focus(t,e){return this._fast(fraction(1).div(e.sub(t))).late(t.cyclePos())}_focusSpan(t){return this._focus(t.begin,t.end)}_fast(t){return this.withQueryTime(o=>o.mul(t)).withHapTime(o=>o.div(t))}_slow(t){return this._fast(fraction(1).div(t))}_inside(t,e){return e(this._slow(t))._fast(t)}_outside(t,e){return e(this._fast(t))._slow(t)}_ply(t){return this.fmap(e=>pure$1(e)._fast(t))._squeezeJoin()}_chop(t){const o=Array.from({length:t},(i,f)=>f).map(i=>({begin:i/t,end:(i+1)/t})),s=function(i){return sequence$1(o.map(f=>Object.assign({},i,f)))};return this._squeezeBind(s)}_striate(t){const o=Array.from({length:t},(i,f)=>f).map(i=>({begin:i/t,end:(i+1)/t})),s=slowcat$1(...o);return this.set(s)._fast(t)}_cpm(t){return this._fast(t/60)}_early(t){return t=fraction(t),this.withQueryTime(e=>e.add(t)).withHapTime(e=>e.sub(t))}_late(t){return t=fraction(t),this._early(fraction(0).sub(t))}_zoom(t,e){e=fraction(e),t=fraction(t);const o=e.sub(t);return this.withQuerySpan(s=>s.withCycle(i=>i.mul(o).add(t))).withHapSpan(s=>s.withCycle(i=>i.sub(t).div(o)))._splitQueries()}_zoomArc(t){return this.zoom(t.begin,t.end)}_linger(t){return t==0?silence$1:t<0?this._zoom(t.add(1),1)._slow(t):this._zoom(0,t)._slow(t)}_color(t){return this._withContext(e=>({...e,color:t}))}log(){return this._withHap(t=>{var e;return t.setContext({...t.context,logs:(((e=t.context)==null?void 0:e.logs)||[]).concat([t.show()])})})}drawLine(){return console.log(drawLine(this)),this}_segment(t){return this.struct(pure$1(!0)._fast(t))}invert(){return this.fmap(t=>!t)}inv(){return this.invert()}when(t,e){const o=t._filterValues(id),s=t._filterValues(l=>!l),i=o.fmap(l=>g=>g).appRight(e(this)),f=s.fmap(l=>g=>g).appRight(this);return stack$1(i,f)}off(t,e){return stack$1(this,e(this.late(t)))}every(t,e){const o=this,s=Array(t-1).fill(o);return s.push(e(o)),slowcatPrime(...s)}every(t,e){const o=this,s=Array(t-1).fill(o);return s.unshift(e(o)),slowcatPrime(...s)}each(t,e){const o=this,s=Array(t-1).fill(o);return s.push(e(o)),slowcatPrime(...s)}brak(){return this.when(slowcat$1(!1,!0),t=>fastcat(t,silence$1)._late(.25))}rev(){const t=this,e=function(o){const s=o.span,i=s.begin.sam(),f=s.begin.nextSam(),l=function(w){const y=w.withTime(S=>i.add(f.sub(S))),$=y.begin;return y.begin=y.end,y.end=$,y};return t.query(o.setSpan(l(s))).map(w=>w.withSpan(l))};return new Pattern$3(e)._splitQueries()}palindrome(){return this.every(2,rev)}juxBy(t,e){t/=2;const o=function(f,l,g){return l in f?f[l]:g},s=this.withValue(f=>Object.assign({},f,{pan:o(f,"pan",.5)-t})),i=this.withValue(f=>Object.assign({},f,{pan:o(f,"pan",.5)+t}));return stack$1(s,e(i))}_jux(t){return this.juxBy(1,t)}stack(...t){return stack$1(this,...t)}sequence(...t){return sequence$1(this,...t)}seq(...t){return sequence$1(this,...t)}cat(...t){return cat(this,...t)}fastcat(...t){return fastcat(this,...t)}slowcat(...t){return slowcat$1(this,...t)}superimpose(...t){return this.stack(...t.map(e=>e(this)))}stutWith(t,e,o){return stack$1(...listRange(0,t-1).map(s=>o(this.late(fraction(e).mul(s)),s)))}stut(t,e,o){return this.stutWith(t,o,(s,i)=>s.velocity(Math.pow(e,i)))}_echoWith(t,e,o){return stack$1(...listRange(0,t-1).map(s=>o(this.late(fraction(e).mul(s)),s)))}_echo(t,e,o){return this._echoWith(t,e,(s,i)=>s.velocity(Math.pow(o,i)))}iter(t,e=!1){return slowcat$1(...listRange(0,t-1).map(o=>e?this.late(o/t):this.early(o/t)))}iterBack(t){return this.iter(t,!0)}_chunk(t,e,o=!1){const s=Array(t-1).fill(!1);s.unshift(!0);const i=sequence$1(...s).iter(t,o);return this.when(i,e)}_chunkBack(t,e){return this._chunk(t,e,!0)}_bypass(t){return t=Boolean(parseInt(t)),t?silence$1:this}hush(){return silence$1}_duration(t){return this.withHapSpan(e=>new TimeSpan(e.begin,e.begin.add(t)))}_legato(t){return this.withHapSpan(e=>new TimeSpan(e.begin,e.begin.add(e.end.sub(e.begin).mul(t))))}_velocity(t){return this._withContext(e=>({...e,velocity:(e.velocity||1)*t}))}_loopAt(t,e=1){return this.speed(1/t*e).unit("c").slow(t)}onTrigger(t){return this._withHap(e=>e.setContext({...e.context,onTrigger:t}))}log(t=id){return this._withHap(e=>e.setContext({...e.context,onTrigger:(...o)=>{e.context.onTrigger&&e.context.onTrigger(...o),console.log(t(...o))}}))}logValues(t=id){return this.log((e,o)=>t(o.value))}}function _composeOp(r,t,e){function o(s){return s instanceof Object&&!(s instanceof Function)}return o(r)||o(t)?(o(r)||(r={value:r}),o(t)||(t={value:t}),unionWithObj(r,t,e)):e(r,t)}(function(){const r={set:[(t,e)=>e],keep:[(t,e)=>t],keepif:[(t,e)=>e?t:void 0],add:[numeralArgs((t,e)=>t+e)],sub:[numeralArgs((t,e)=>t-e)],mul:[numeralArgs((t,e)=>t*e)],div:[numeralArgs((t,e)=>t/e)],mod:[numeralArgs(mod)],pow:[numeralArgs(Math.pow)],_and:[numeralArgs((t,e)=>t&e)],_or:[numeralArgs((t,e)=>t|e)],_xor:[numeralArgs((t,e)=>t^e)],_lshift:[numeralArgs((t,e)=>t<t>>e)],lt:[(t,e)=>tt>e],lte:[(t,e)=>t<=e],gte:[(t,e)=>t>=e],eq:[(t,e)=>t==e],eqt:[(t,e)=>t===e],ne:[(t,e)=>t!=e],net:[(t,e)=>t!==e],and:[(t,e)=>t&&e],or:[(t,e)=>t||e],func:[(t,e)=>e(t)]};for(const[t,[e,o]]of Object.entries(r))for(const s of["In","Out","Mix","Squeeze","SqueezeOut","Trig","Trigzero"])Pattern$3.prototype[t+s]=function(...i){var f=this;i=sequence$1(i),o&&(f=o(f),i=o(i));var l;return t==="keepif"?(l=f["_op"+s](i,g=>w=>e(g,w)),l=l._removeUndefineds()):l=f["_op"+s](i,g=>w=>_composeOp(g,w,e)),l},s==="Squeeze"&&(Pattern$3.prototype[t+"SqueezeIn"]=Pattern$3.prototype[t+s]),s==="In"?Pattern$3.prototype[t]=Pattern$3.prototype[t+s]:t==="set"&&(Pattern$3.prototype[s.toLowerCase()]=Pattern$3.prototype[t+s]);Pattern$3.prototype.struct=Pattern$3.prototype.keepifOut,Pattern$3.prototype.structAll=Pattern$3.prototype.keepOut,Pattern$3.prototype.mask=Pattern$3.prototype.keepifIn,Pattern$3.prototype.maskAll=Pattern$3.prototype.keepIn,Pattern$3.prototype.reset=Pattern$3.prototype.keepifTrig,Pattern$3.prototype.resetAll=Pattern$3.prototype.keepTrig,Pattern$3.prototype.restart=Pattern$3.prototype.keepifTrigzero,Pattern$3.prototype.restartAll=Pattern$3.prototype.keepTrigzero})();Pattern$3.prototype.patternified=["apply","chop","color","cpm","duration","early","fast","jux","late","legato","linger","ply","segment","striate","slow","velocity"];const polyrhythm=stack$1,pr=stack$1;Pattern$3.prototype.factories={pure:pure$1,stack:stack$1,slowcat:slowcat$1,fastcat,cat,timeCat:timeCat$1,sequence:sequence$1,seq,polymeter,pm,polyrhythm,pr};const silence$1=new Pattern$3(r=>[]);function pure$1(r){function t(e){return e.span.spanCycles.map(o=>new Hap(fraction(o.begin).wholeCycle(),o,r))}return new Pattern$3(t)}function isPattern$1(r){const t=r instanceof Pattern$3||(r==null?void 0:r._Pattern);return!r instanceof Pattern$3&&console.warn(`Found Pattern that fails "instanceof Pattern" check. This may happen if you are using multiple versions of @strudel.cycles/core. - Please check by running "npm ls @strudel.cycles/core".`),t}function reify$2(r){return isPattern$1(r)?r:stringParser&&typeof r=="string"?stringParser(r):pure$1(r)}function stack$1(...r){r=r.map(e=>Array.isArray(e)?sequence$1(...e):reify$2(e));const t=e=>flatten(r.map(o=>o.query(e)));return new Pattern$3(t)}function slowcat$1(...r){r=r.map(e=>Array.isArray(e)?sequence$1(...e):reify$2(e));const t=function(e){const o=e.span,s=mod(o.begin.sam(),r.length),i=r[s];if(!i)return[];const l=o.begin.floor().sub(o.begin.div(r.length).floor());return i.withHapTime(f=>f.add(l)).query(e.setSpan(o.withTime(f=>f.sub(l))))};return new Pattern$3(t)._splitQueries()}function slowcatPrime(...r){r=r.map(reify$2);const t=function(e){const o=Math.floor(e.span.begin)%r.length,s=r[o];return(s==null?void 0:s.query(e))||[]};return new Pattern$3(t)._splitQueries()}function fastcat(...r){return slowcat$1(...r)._fast(r.length)}function cat(...r){return slowcat$1(...r)}function timeCat$1(...r){const t=r.map(s=>s[0]).reduce((s,i)=>s.add(i),fraction(0));let e=fraction(0);const o=[];for(const[s,i]of r){const l=e.add(s);o.push(reify$2(i)._compress(e.div(t),l.div(t))),e=l}return stack$1(...o)}function sequence$1(...r){return fastcat(...r)}function seq(...r){return fastcat(...r)}function _sequenceCount(r){return Array.isArray(r)?r.length==0?[silence$1,0]:r.length==1?_sequenceCount(r[0]):[fastcat(...r.map(t=>_sequenceCount(t)[0])),r.length]:[reify$2(r),1]}function polymeterSteps(r,...t){const e=t.map(s=>_sequenceCount(s));if(e.length==0)return silence$1;r==0&&(r=e[0][1]);const o=[];for(const s of e)s[1]==0&&next,r==s[1]?o.push(s[0]):o.push(s[0]._fast(fraction(r).div(fraction(s[1]))));return stack$1(...o)}function polymeter(...r){return polymeterSteps(0,...r)}function pm(...r){polymeter(...r)}const add=curry((r,t)=>t.add(r)),chop=curry((r,t)=>t.chop(r)),chunk=curry((r,t)=>t.chunk(r)),chunkBack=curry((r,t)=>t.chunkBack(r)),div=curry((r,t)=>t.div(r)),early=curry((r,t)=>t.early(r)),echo=curry((r,t,e,o)=>o.echo(r,t,e)),every=curry((r,t,e)=>e.every(r,t)),fast=curry((r,t)=>t.fast(r)),inv=r=>r.inv(),invert=r=>r.invert(),iter=curry((r,t)=>t.iter(r)),iterBack=curry((r,t)=>t.iter(r)),jux=curry((r,t)=>t.jux(r)),juxBy=curry((r,t,e)=>e.juxBy(r,t)),late=curry((r,t)=>t.late(r)),linger=curry((r,t)=>t.linger(r)),mask=curry((r,t)=>t.mask(r)),mul=curry((r,t)=>t.mul(r)),off=curry((r,t,e)=>e.off(r,t)),ply=curry((r,t)=>t.ply(r)),range=curry((r,t,e)=>e.range(r,t)),rangex=curry((r,t,e)=>e.rangex(r,t)),range2=curry((r,t,e)=>e.range2(r,t)),rev=r=>r.rev(),slow=curry((r,t)=>t.slow(r)),struct=curry((r,t)=>t.struct(r)),sub=curry((r,t)=>t.sub(r)),superimpose=curry((r,t)=>t.superimpose(...r)),set=curry((r,t)=>t.set(r)),when=curry((r,t,e)=>e.when(r,t));Pattern$3.prototype.composable={fast,slow,early,late,superimpose};function makeComposable(r){return Object.entries(Pattern$3.prototype.composable).forEach(([t,e])=>{r[t]=(...o)=>{const s=compose(r,e(...o));return makeComposable(s)}}),r}const patternify2=r=>(t,e,o)=>t.fmap(s=>i=>r.call(o,s,i)).appLeft(e).innerJoin(),patternify3=r=>(t,e,o,s)=>t.fmap(i=>l=>f=>r.call(s,i,l,f)).appLeft(e).appLeft(o).innerJoin(),patternify4=r=>(t,e,o,s,i)=>t.fmap(l=>f=>g=>w=>r.call(i,l,f,g,w)).appLeft(e).appLeft(o).appLeft(s).innerJoin();Pattern$3.prototype.echo=function(...r){return r=r.map(reify$2),patternify3(Pattern$3.prototype._echo)(...r,this)};Pattern$3.prototype.echoWith=function(...r){return r=r.map(reify$2),patternify3(Pattern$3.prototype._echoWith)(...r,this)};Pattern$3.prototype.chunk=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._chunk)(...r,this)};Pattern$3.prototype.chunkBack=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._chunkBack)(...r,this)};Pattern$3.prototype.loopAt=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._loopAt)(...r,this)};Pattern$3.prototype.zoom=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._zoom)(...r,this)};Pattern$3.prototype.compress=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._compress)(...r,this)};Pattern$3.prototype.outside=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._outside)(...r,this)};Pattern$3.prototype.inside=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._inside)(...r,this)};Pattern$3.prototype.range=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._range)(...r,this)};Pattern$3.prototype.rangex=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._rangex)(...r,this)};Pattern$3.prototype.range2=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._range2)(...r,this)};Pattern$3.prototype.bootstrap=function(){const r=Object.fromEntries(Object.entries(Pattern$3.prototype.composable).map(([t,e])=>(Pattern$3.prototype[t]&&(Pattern$3.prototype[t]=makeComposable(Pattern$3.prototype[t])),[t,curry(e,makeComposable)])));return this.patternified.forEach(t=>{Pattern$3.prototype[t]=function(...e){return this._patternify(Pattern$3.prototype["_"+t])(...e)}}),r};Pattern$3.prototype.define=(r,t,e={})=>{e.composable&&(Pattern$3.prototype.composable[r]=t),e.patternified&&(Pattern$3.prototype.patternified=Pattern$3.prototype.patternified.concat([r])),Pattern$3.prototype.bootstrap()};Pattern$3.prototype.define("hush",r=>r.hush(),{patternified:!1,composable:!0});Pattern$3.prototype.define("bypass",r=>r.bypass(on),{patternified:!0,composable:!0});const controls={},generic_params=[["s","s","sound"],["f","n","The note or sample number to choose for a synth or sampleset"],["f","note","The note or pitch to play a sound or synth with"],["f","accelerate","a pattern of numbers that speed up (or slow down) samples while they play."],["f","gain","a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder. For the linear equivalent, see @amp@."],["f","amp","like @gain@, but linear."],["f","attack","a pattern of numbers to specify the attack time (in seconds) of an envelope applied to each sample."],["f","bank","selects sound bank to use"],["f","decay",""],["f","sustain",""],["f","release","a pattern of numbers to specify the release time (in seconds) of an envelope applied to each sample."],["f","hold","a pattern of numbers to specify the hold time (in seconds) of an envelope applied to each sample. Only takes effect if `attack` and `release` are also specified."],["f","bandf","A pattern of numbers from 0 to 1. Sets the center frequency of the band-pass filter."],["f","bandq","a pattern of anumbers from 0 to 1. Sets the q-factor of the band-pass filter."],["f","begin","a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample."],["f","end","the same as `begin`, but cuts the end off samples, shortening them; e.g. `0.75` to cut off the last quarter of each sample."],["f","loop","loops the sample (from `begin` to `end`) the specified number of times."],["f","legato","controls the amount of overlap between two adjacent sounds"],["f","crush","bit crushing, a pattern of numbers from 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction)."],["f","coarse","fake-resampling, a pattern of numbers for lowering the sample rate, i.e. 1 for original 2 for half, 3 for a third and so on."],["i","channel","choose the channel the pattern is sent to in superdirt"],["i","cut","In the style of classic drum-machines, `cut` will stop a playing sample as soon as another samples with in same cutgroup is to be played. An example would be an open hi-hat followed by a closed one, essentially muting the open."],["f","cutoff","a pattern of numbers from 0 to 1. Applies the cutoff frequency of the low-pass filter."],["f","hcutoff","a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter. Also has alias @hpf@"],["f","hresonance","a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter. Has alias @hpq@"],["f","resonance","a pattern of numbers from 0 to 1. Specifies the resonance of the low-pass filter."],["f","djf","DJ filter, below 0.5 is low pass filter, above is high pass filter."],["f","delay","a pattern of numbers from 0 to 1. Sets the level of the delay signal."],["f","delayfeedback","a pattern of numbers from 0 to 1. Sets the amount of delay feedback."],["f","delaytime","a pattern of numbers from 0 to 1. Sets the length of the delay."],["f","lock","A pattern of numbers. Specifies whether delaytime is calculated relative to cps. When set to 1, delaytime is a direct multiple of a cycle."],["f","detune",""],["f","dry","when set to `1` will disable all reverb for this pattern. See `room` and `size` for more information about reverb."],["f","fadeTime","Used when using begin/end or chop/striate and friends, to change the fade out time of the 'grain' envelope."],["f","fadeInTime","As with fadeTime, but controls the fade in time of the grain envelope. Not used if the grain begins at position 0 in the sample."],["f","freq",""],["f","gate",""],["f","leslie",""],["f","lrate",""],["f","lsize",""],["f","degree",""],["f","mtranspose",""],["f","ctranspose",""],["f","harmonic",""],["f","stepsPerOctave",""],["f","octaveR",""],["f","nudge","Nudges events into the future by the specified number of seconds. Negative numbers work up to a point as well (due to internal latency)"],["i","octave",""],["f","offset",""],["i","orbit","a pattern of numbers. An `orbit` is a global parameter context for patterns. Patterns with the same orbit will share hardware output bus offset and global effects, e.g. reverb and delay. The maximum number of orbits is specified in the superdirt startup, numbers higher than maximum will wrap around."],["f","overgain",""],["f","overshape",""],["f","pan","a pattern of numbers between 0 and 1, from left to right (assuming stereo), once round a circle (assuming multichannel)"],["f","panspan","a pattern of numbers between -inf and inf, which controls how much multichannel output is fanned out (negative is backwards ordering)"],["f","pansplay","a pattern of numbers between 0.0 and 1.0, which controls the multichannel spread range (multichannel only)"],["f","panwidth","a pattern of numbers between 0.0 and inf, which controls how much each channel is distributed over neighbours (multichannel only)"],["f","panorient","a pattern of numbers between -1.0 and 1.0, which controls the relative position of the centre pan in a pair of adjacent speakers (multichannel only)"],["f","rate","used in SuperDirt softsynths as a control rate or 'speed'"],["f","slide",""],["f","semitone",""],["f","velocity",""],["f","voice",""],["f","room","a pattern of numbers from 0 to 1. Sets the level of reverb."],["f","size","a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the `room` to be used in reverb."],["f","roomsize","a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the `room` to be used in reverb."],["f","shape","wave shaping distortion, a pattern of numbers from 0 for no distortion up to 1 for loads of distortion."],["f","speed","a pattern of numbers which changes the speed of sample playback, i.e. a cheap way of changing pitch. Negative values will play the sample backwards!"],["s","unit",'used in conjunction with `speed`, accepts values of "r" (rate, default behavior), "c" (cycles), or "s" (seconds). Using `unit "c"` means `speed` will be interpreted in units of cycles, e.g. `speed "1"` means samples will be stretched to fill a cycle. Using `unit "s"` means the playback speed will be adjusted so that the duration is the number of seconds specified by `speed`.'],["f","squiz",""],["f","stutterdepth",""],["f","stuttertime",""],["f","timescale",""],["f","timescalewin",""],["s","vowel","formant filter to make things sound like vowels, a pattern of either `a`, `e`, `i`, `o` or `u`. Use a rest (`~`) for no effect."],["f","waveloss",""],["f","dur",""],["f","expression",""],["f","sustainpedal",""],["f","tremolodepth","Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],["f","tremolorate","Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],["f","phaserdepth","Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],["f","phaserrate","Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],["f","fshift","frequency shifter"],["f","fshiftnote","frequency shifter"],["f","fshiftphase","frequency shifter"],["f","triode","tube distortion"],["f","krush","shape/bass enhancer"],["f","kcutoff",""],["f","octer","octaver effect"],["f","octersub","octaver effect"],["f","octersubsub","octaver effect"],["f","ring","ring modulation"],["f","ringf","ring modulation"],["f","ringdf","ring modulation"],["f","distort","noisy fuzzy distortion"],["f","freeze","Spectral freeze"],["f","xsdelay",""],["f","tsdelay",""],["f","real","Spectral conform"],["f","imag",""],["f","enhance","Spectral enhance"],["f","partials",""],["f","comb","Spectral comb"],["f","smear","Spectral smear"],["f","scram","Spectral scramble"],["f","binshift","Spectral binshift"],["f","hbrick","High pass sort of spectral filter"],["f","lbrick","Low pass sort of spectral filter"],["f","midichan",""],["f","control",""],["f","ccn",""],["f","ccv",""],["f","polyTouch",""],["f","midibend",""],["f","miditouch",""],["f","ctlNum",""],["f","frameRate",""],["f","frames",""],["f","hours",""],["s","midicmd",""],["f","minutes",""],["f","progNum",""],["f","seconds",""],["f","songPtr",""],["f","uid",""],["f","val",""],["f","cps",""],["f","clip",""]],_name=(r,...t)=>sequence$1(...t).withValue(e=>({[r]:e})),_setter=(r,t)=>function(...e){return e.length?this.set(r(...e)):this.fmap(o=>({[t]:o}))};generic_params.forEach(([r,t,e])=>{controls[t]=(...o)=>_name(t,...o),Pattern$3.prototype[t]=_setter(controls[t],t)});controls.createParam=r=>{const t=(...e)=>_name(r,...e);return Pattern$3.prototype[r]=_setter(t,r),(...e)=>_name(r,...e)};controls.createParams=(...r)=>r.reduce((t,e)=>Object.assign(t,{[e]:createParam(e)}),{});function bjorklund(r,t){for(var e=[],o=[],s=[t],i=r-t,l=0,f=function(g){if(g==-1)e.push(0);else if(g==-2)e.push(1);else{for(var w=0;w1;)o.push(Math.floor(i/s[l])),s.push(i%s[l]),i=s[l],l++;return o.push(i),f(l),e.reverse()}var bjork=function(r,t){return r>t?bjorklund(r,t):bjorklund(t,r)};const euclid=(r,t,e=0)=>{const o=bjork(t,r);return e?rotate(o,-e):o};Pattern$3.prototype.euclid=function(r,t,e=0){return this.struct(euclid(r,t,e))};Pattern$3.prototype.euclidLegato=function(r,t,e=0){const o=euclid(r,t,e),s=o.indexOf(1),i=rotate(o,s).join("").split("1").slice(1).map(l=>[l.length+1,!0]);return this.struct(timeCat$1(...i)).late(fraction(s).div(t))};function steady(r){return new Pattern$3(t=>[new Hap(void 0,t.span,r)])}const signal=r=>{const t=e=>[new Hap(void 0,e.span,r(e.span.midpoint()))];return new Pattern$3(t)},isaw=signal(r=>1-r%1),isaw2=isaw._toBipolar(),saw=signal(r=>r%1),saw2=saw._toBipolar(),sine2=signal(r=>Math.sin(Math.PI*2*r)),sine=sine2._fromBipolar(),cosine=sine._early(fraction(1).div(4)),cosine2=sine2._early(fraction(1).div(4)),square=signal(r=>Math.floor(r*2%2)),square2=square._toBipolar(),tri=fastcat(isaw,saw),tri2=fastcat(isaw2,saw2),time=signal(id),xorwise=r=>{const t=r<<13^r,e=t>>17^t;return e<<5^e},_frac=r=>r-Math.trunc(r),timeToIntSeed=r=>xorwise(Math.trunc(_frac(r/300)*536870912)),intSeedToRand=r=>r%536870912/536870912,timeToRand=r=>Math.abs(intSeedToRand(timeToIntSeed(r))),rand=signal(timeToRand),rand2=rand._toBipolar(),_brandBy=r=>rand.fmap(t=>treify$2(r).fmap(_brandBy).innerJoin(),brand=_brandBy(.5),_irand=r=>rand.fmap(t=>Math.trunc(t*r)),irand=r=>reify$2(r).fmap(_irand).innerJoin(),__chooseWith=(r,t)=>(t=t.map(reify$2),t.length==0?silence$1:r.range(0,t.length).fmap(e=>t[Math.floor(e)])),chooseWith=(r,t)=>__chooseWith(r,t).outerJoin(),chooseInWith=(r,t)=>__chooseWith(r,t).innerJoin(),choose=(...r)=>chooseWith(rand,r);Pattern$3.prototype.choose=function(...r){return chooseWith(this,r)};Pattern$3.prototype.choose2=function(...r){return chooseWith(this._fromBipolar(),r)};const chooseCycles=(...r)=>chooseInWith(rand.segment(1),r),randcat=chooseCycles,_wchooseWith=function(r,...t){const e=t.map(f=>reify$2(f[0])),o=[];let s=0;for(const f of t)s+=f[1],o.push(s);const i=s,l=function(f){const g=f*i;return e[o.findIndex(w=>w>g,o)]};return r.fmap(l)},wchooseWith=(...r)=>_wchooseWith(...r).outerJoin(),wchoose=(...r)=>wchooseWith(rand,...r),wchooseCycles=(...r)=>_wchooseWith(rand,...r).innerJoin(),perlinWith=r=>{const t=r.fmap(Math.floor),e=r.fmap(i=>Math.floor(i)+1),o=i=>6*i**5-15*i**4+10*i**3,s=i=>l=>f=>l+o(i)*(f-l);return r.sub(t).fmap(s).appBoth(t.fmap(timeToRand)).appBoth(e.fmap(timeToRand))},perlin=perlinWith(time.fmap(r=>Number(r)));Pattern$3.prototype._degradeByWith=function(r,t){return this.fmap(e=>o=>e).appLeft(r._filterValues(e=>e>t))};Pattern$3.prototype._degradeBy=function(r){return this._degradeByWith(rand,r)};Pattern$3.prototype.degrade=function(){return this._degradeBy(.5)};Pattern$3.prototype._undegradeBy=function(r){return this._degradeByWith(rand.fmap(t=>1-t),r)};Pattern$3.prototype.undegrade=function(){return this._undegradeBy(.5)};Pattern$3.prototype._sometimesBy=function(r,t){return stack$1(this._degradeBy(r),t(this._undegradeBy(1-r)))};Pattern$3.prototype.sometimesBy=function(r,t){const e=this;return reify$2(r).fmap(o=>e._sometimesBy(o,t)).innerJoin()};Pattern$3.prototype._sometimesByPre=function(r,t){return stack$1(this._degradeBy(r),t(this).undegradeBy(1-r))};Pattern$3.prototype.sometimesByPre=function(r,t){const e=this;return reify$2(r).fmap(o=>e._sometimesByPre(o,t)).innerJoin()};Pattern$3.prototype.sometimes=function(r){return this._sometimesBy(.5,r)};Pattern$3.prototype.sometimesPre=function(r){return this._sometimesByPre(.5,r)};Pattern$3.prototype._someCyclesBy=function(r,t){return stack$1(this._degradeByWith(rand._segment(1),r),t(this._degradeByWith(rand.fmap(e=>1-e)._segment(1),1-r)))};Pattern$3.prototype.someCyclesBy=function(r,t){const e=this;return reify$2(r).fmap(o=>e._someCyclesBy(o,t)).innerJoin()};Pattern$3.prototype.someCycles=function(r){return this._someCyclesBy(.5,r)};Pattern$3.prototype.often=function(r){return this.sometimesBy(.75,r)};Pattern$3.prototype.rarely=function(r){return this.sometimesBy(.25,r)};Pattern$3.prototype.almostNever=function(r){return this.sometimesBy(.1,r)};Pattern$3.prototype.almostAlways=function(r){return this.sometimesBy(.9,r)};Pattern$3.prototype.never=function(r){return this};Pattern$3.prototype.always=function(r){return r(this)};Pattern$3.prototype.patternified.push("degradeBy","undegradeBy");let synth;try{synth=window==null?void 0:window.speechSynthesis}catch{console.warn("cannot use window: not in browser?")}let allVoices=synth==null?void 0:synth.getVoices();function speak(r,t,e){synth.cancel();const o=new SpeechSynthesisUtterance(r);o.lang=t,allVoices=synth.getVoices();const s=allVoices.filter(i=>i.lang.includes(t));typeof e=="number"?o.voice=s[e%s.length]:typeof e=="string"&&(o.voice=s.find(i=>i.name===i)),speechSynthesis.speak(o)}Pattern$3.prototype._speak=function(r,t){return this._withHap(e=>{const o=(s,i)=>{speak(i.value,r,t)};return e.setContext({...e.context,onTrigger:o})})};Pattern$3.prototype.speak=function(r,t){return patternify2(Pattern$3.prototype._speak)(reify(r),reify(t),this)};const{isPattern,Pattern:Pattern$2}=strudel;let scoped=!1;const evalScope=async(...r)=>{scoped&&console.warn("evalScope was called more than once."),scoped=!0;const t=await Promise.allSettled(r),e=t.filter(o=>o.status==="fulfilled").map(o=>o.value);t.forEach((o,s)=>{o.status==="rejected"&&console.warn(`evalScope: module with index ${s} could not be loaded:`,o.reason)}),Object.assign(globalThis,...e,Pattern$2.prototype.bootstrap())};function safeEval(r,t={}){const{wrapExpression:e=!0,wrapAsync:o=!0}=t;e&&(r=`{${r}}`),o&&(r=`(async ()=>${r})()`);const s=`"use strict";return (${r})`;return Function(s)()}const evaluate$1=async(r,t)=>{scoped||await evalScope(),t&&(r=t(r));let o=await safeEval(r,{wrapExpression:!!t});if(!isPattern(o)){console.log("evaluated",o);const s=`got "${typeof o}" instead of pattern`;throw new Error(s+(typeof o=="function"?", did you forget to call a function?":"."))}return{mode:"javascript",pattern:o}};function createClock(r,t,e=.05,o=.1,s=.1){let i=0,l=0,f=10**4,g=.01;const w=b=>e=b(e);s=s||o/2;const y=()=>{const b=r(),I=b+o+s;for(l===0&&(l=b+g);l=b&&t(l,e,i),l{y(),$=setInterval(y,o*1e3)},C=()=>clearInterval($);return{setDuration:w,start:S,stop:()=>{i=0,l=0,C()},pause:()=>C(),duration:e,getPhase:()=>l}}class Cyclist{constructor({interval:t,onTrigger:e,onError:o,getTime:s,latency:i=.1}){K(this,"worker");K(this,"pattern");K(this,"started",!1);K(this,"cps",1);K(this,"getTime");K(this,"phase",0);this.getTime=s;const l=f=>Math.round(f*1e3)/1e3;this.clock=createClock(s,(f,g,w)=>{w===0&&(this.origin=f);const y=l(f-this.origin);this.phase=y-i;const $=l(y+g),S=s();try{this.pattern.queryArc(y,$).forEach(p=>{if(p.part.begin.equals(p.whole.begin)){const d=p.whole.begin+this.origin-S+i,m=p.duration*1;e==null||e(p,d,m)}})}catch(C){console.warn("scheduler error",C),o==null||o(C)}},t)}getPhase(){return this.phase}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.clock.start(),this.started=!0}pause(){this.clock.stop(),delete this.origin,this.started=!1}stop(){delete this.origin,this.clock.stop(),this.started=!1}setPattern(t,e=!1){this.pattern=t,e&&!this.started&&this.start()}setCps(t=1){this.cps=t}log(t,e,o){const s=o.filter(i=>i.hasOnset());console.log(`${t.toFixed(4)} - ${e.toFixed(4)} ${Array(s.length).fill("I").join("")}`)}}function repl({interval:r,defaultOutput:t,onSchedulerError:e,onEvalError:o,onEval:s,getTime:i,transpiler:l}){const f=new Cyclist({interval:r,onTrigger:t,onError:e,getTime:i});return{scheduler:f,evaluate:async w=>{if(!w)throw new Error("no code to evaluate");try{const{pattern:y}=await evaluate$1(w,l);f.setPattern(y,!0),s==null||s({pattern:y,code:w})}catch(y){console.warn(`eval error: ${y.message}`),o==null||o(y)}}}}const gist=(route,cache=!0)=>fetch(`https://gist.githubusercontent.com/${route}?cachebust=${cache?"":Date.now()}`).then(r=>r.text()).then(code=>eval(code));console.log("%c // \u{1F300} @strudel.cycles/core loaded \u{1F300}","background-color: black;color:white;padding:4px;border-radius:15px");globalThis._strudelLoaded&&console.warn(`@strudel.cycles/core was loaded more than once... + Please check by running "npm ls @strudel.cycles/core".`),t}function reify$2(r){return isPattern$1(r)?r:stringParser&&typeof r=="string"?stringParser(r):pure$1(r)}function stack$1(...r){r=r.map(e=>Array.isArray(e)?sequence$1(...e):reify$2(e));const t=e=>flatten(r.map(o=>o.query(e)));return new Pattern$3(t)}function slowcat$1(...r){r=r.map(e=>Array.isArray(e)?sequence$1(...e):reify$2(e));const t=function(e){const o=e.span,s=mod(o.begin.sam(),r.length),i=r[s];if(!i)return[];const f=o.begin.floor().sub(o.begin.div(r.length).floor());return i.withHapTime(l=>l.add(f)).query(e.setSpan(o.withTime(l=>l.sub(f))))};return new Pattern$3(t)._splitQueries()}function slowcatPrime(...r){r=r.map(reify$2);const t=function(e){const o=Math.floor(e.span.begin)%r.length,s=r[o];return(s==null?void 0:s.query(e))||[]};return new Pattern$3(t)._splitQueries()}function fastcat(...r){return slowcat$1(...r)._fast(r.length)}function cat(...r){return slowcat$1(...r)}function timeCat$1(...r){const t=r.map(s=>s[0]).reduce((s,i)=>s.add(i),fraction(0));let e=fraction(0);const o=[];for(const[s,i]of r){const f=e.add(s);o.push(reify$2(i)._compress(e.div(t),f.div(t))),e=f}return stack$1(...o)}function sequence$1(...r){return fastcat(...r)}function seq(...r){return fastcat(...r)}function _sequenceCount(r){return Array.isArray(r)?r.length==0?[silence$1,0]:r.length==1?_sequenceCount(r[0]):[fastcat(...r.map(t=>_sequenceCount(t)[0])),r.length]:[reify$2(r),1]}function polymeterSteps(r,...t){const e=t.map(s=>_sequenceCount(s));if(e.length==0)return silence$1;r==0&&(r=e[0][1]);const o=[];for(const s of e)s[1]==0&&next,r==s[1]?o.push(s[0]):o.push(s[0]._fast(fraction(r).div(fraction(s[1]))));return stack$1(...o)}function polymeter(...r){return polymeterSteps(0,...r)}function pm(...r){polymeter(...r)}const add=curry((r,t)=>t.add(r)),chop=curry((r,t)=>t.chop(r)),chunk=curry((r,t)=>t.chunk(r)),chunkBack=curry((r,t)=>t.chunkBack(r)),div=curry((r,t)=>t.div(r)),early=curry((r,t)=>t.early(r)),echo=curry((r,t,e,o)=>o.echo(r,t,e)),every=curry((r,t,e)=>e.every(r,t)),fast=curry((r,t)=>t.fast(r)),inv=r=>r.inv(),invert=r=>r.invert(),iter=curry((r,t)=>t.iter(r)),iterBack=curry((r,t)=>t.iter(r)),jux=curry((r,t)=>t.jux(r)),juxBy=curry((r,t,e)=>e.juxBy(r,t)),late=curry((r,t)=>t.late(r)),linger=curry((r,t)=>t.linger(r)),mask=curry((r,t)=>t.mask(r)),mul=curry((r,t)=>t.mul(r)),off=curry((r,t,e)=>e.off(r,t)),ply=curry((r,t)=>t.ply(r)),range=curry((r,t,e)=>e.range(r,t)),rangex=curry((r,t,e)=>e.rangex(r,t)),range2=curry((r,t,e)=>e.range2(r,t)),rev=r=>r.rev(),slow=curry((r,t)=>t.slow(r)),struct=curry((r,t)=>t.struct(r)),sub=curry((r,t)=>t.sub(r)),superimpose=curry((r,t)=>t.superimpose(...r)),set=curry((r,t)=>t.set(r)),when=curry((r,t,e)=>e.when(r,t));Pattern$3.prototype.composable={fast,slow,early,late,superimpose};function makeComposable(r){return Object.entries(Pattern$3.prototype.composable).forEach(([t,e])=>{r[t]=(...o)=>{const s=compose(r,e(...o));return makeComposable(s)}}),r}const patternify2=r=>(t,e,o)=>t.fmap(s=>i=>r.call(o,s,i)).appLeft(e).innerJoin(),patternify3=r=>(t,e,o,s)=>t.fmap(i=>f=>l=>r.call(s,i,f,l)).appLeft(e).appLeft(o).innerJoin(),patternify4=r=>(t,e,o,s,i)=>t.fmap(f=>l=>g=>w=>r.call(i,f,l,g,w)).appLeft(e).appLeft(o).appLeft(s).innerJoin();Pattern$3.prototype.echo=function(...r){return r=r.map(reify$2),patternify3(Pattern$3.prototype._echo)(...r,this)};Pattern$3.prototype.echoWith=function(...r){return r=r.map(reify$2),patternify3(Pattern$3.prototype._echoWith)(...r,this)};Pattern$3.prototype.chunk=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._chunk)(...r,this)};Pattern$3.prototype.chunkBack=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._chunkBack)(...r,this)};Pattern$3.prototype.loopAt=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._loopAt)(...r,this)};Pattern$3.prototype.zoom=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._zoom)(...r,this)};Pattern$3.prototype.compress=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._compress)(...r,this)};Pattern$3.prototype.outside=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._outside)(...r,this)};Pattern$3.prototype.inside=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._inside)(...r,this)};Pattern$3.prototype.range=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._range)(...r,this)};Pattern$3.prototype.rangex=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._rangex)(...r,this)};Pattern$3.prototype.range2=function(...r){return r=r.map(reify$2),patternify2(Pattern$3.prototype._range2)(...r,this)};Pattern$3.prototype.bootstrap=function(){const r=Object.fromEntries(Object.entries(Pattern$3.prototype.composable).map(([t,e])=>(Pattern$3.prototype[t]&&(Pattern$3.prototype[t]=makeComposable(Pattern$3.prototype[t])),[t,curry(e,makeComposable)])));return this.patternified.forEach(t=>{Pattern$3.prototype[t]=function(...e){return this._patternify(Pattern$3.prototype["_"+t])(...e)}}),r};Pattern$3.prototype.define=(r,t,e={})=>{e.composable&&(Pattern$3.prototype.composable[r]=t),e.patternified&&(Pattern$3.prototype.patternified=Pattern$3.prototype.patternified.concat([r])),Pattern$3.prototype.bootstrap()};Pattern$3.prototype.define("hush",r=>r.hush(),{patternified:!1,composable:!0});Pattern$3.prototype.define("bypass",r=>r.bypass(on),{patternified:!0,composable:!0});const controls={},generic_params=[["s","s","sound"],["f","n","The note or sample number to choose for a synth or sampleset"],["f","note","The note or pitch to play a sound or synth with"],["f","accelerate","a pattern of numbers that speed up (or slow down) samples while they play."],["f","gain","a pattern of numbers that specify volume. Values less than 1 make the sound quieter. Values greater than 1 make the sound louder. For the linear equivalent, see @amp@."],["f","amp","like @gain@, but linear."],["f","attack","a pattern of numbers to specify the attack time (in seconds) of an envelope applied to each sample."],["f","bank","selects sound bank to use"],["f","decay",""],["f","sustain",""],["f","release","a pattern of numbers to specify the release time (in seconds) of an envelope applied to each sample."],["f","hold","a pattern of numbers to specify the hold time (in seconds) of an envelope applied to each sample. Only takes effect if `attack` and `release` are also specified."],["f","bandf","A pattern of numbers from 0 to 1. Sets the center frequency of the band-pass filter."],["f","bandq","a pattern of anumbers from 0 to 1. Sets the q-factor of the band-pass filter."],["f","begin","a pattern of numbers from 0 to 1. Skips the beginning of each sample, e.g. `0.25` to cut off the first quarter from each sample."],["f","end","the same as `begin`, but cuts the end off samples, shortening them; e.g. `0.75` to cut off the last quarter of each sample."],["f","loop","loops the sample (from `begin` to `end`) the specified number of times."],["f","legato","controls the amount of overlap between two adjacent sounds"],["f","crush","bit crushing, a pattern of numbers from 1 (for drastic reduction in bit-depth) to 16 (for barely no reduction)."],["f","coarse","fake-resampling, a pattern of numbers for lowering the sample rate, i.e. 1 for original 2 for half, 3 for a third and so on."],["i","channel","choose the channel the pattern is sent to in superdirt"],["i","cut","In the style of classic drum-machines, `cut` will stop a playing sample as soon as another samples with in same cutgroup is to be played. An example would be an open hi-hat followed by a closed one, essentially muting the open."],["f","cutoff","a pattern of numbers from 0 to 1. Applies the cutoff frequency of the low-pass filter."],["f","hcutoff","a pattern of numbers from 0 to 1. Applies the cutoff frequency of the high-pass filter. Also has alias @hpf@"],["f","hresonance","a pattern of numbers from 0 to 1. Applies the resonance of the high-pass filter. Has alias @hpq@"],["f","resonance","a pattern of numbers from 0 to 1. Specifies the resonance of the low-pass filter."],["f","djf","DJ filter, below 0.5 is low pass filter, above is high pass filter."],["f","delay","a pattern of numbers from 0 to 1. Sets the level of the delay signal."],["f","delayfeedback","a pattern of numbers from 0 to 1. Sets the amount of delay feedback."],["f","delaytime","a pattern of numbers from 0 to 1. Sets the length of the delay."],["f","lock","A pattern of numbers. Specifies whether delaytime is calculated relative to cps. When set to 1, delaytime is a direct multiple of a cycle."],["f","detune",""],["f","dry","when set to `1` will disable all reverb for this pattern. See `room` and `size` for more information about reverb."],["f","fadeTime","Used when using begin/end or chop/striate and friends, to change the fade out time of the 'grain' envelope."],["f","fadeInTime","As with fadeTime, but controls the fade in time of the grain envelope. Not used if the grain begins at position 0 in the sample."],["f","freq",""],["f","gate",""],["f","leslie",""],["f","lrate",""],["f","lsize",""],["f","degree",""],["f","mtranspose",""],["f","ctranspose",""],["f","harmonic",""],["f","stepsPerOctave",""],["f","octaveR",""],["f","nudge","Nudges events into the future by the specified number of seconds. Negative numbers work up to a point as well (due to internal latency)"],["i","octave",""],["f","offset",""],["i","orbit","a pattern of numbers. An `orbit` is a global parameter context for patterns. Patterns with the same orbit will share hardware output bus offset and global effects, e.g. reverb and delay. The maximum number of orbits is specified in the superdirt startup, numbers higher than maximum will wrap around."],["f","overgain",""],["f","overshape",""],["f","pan","a pattern of numbers between 0 and 1, from left to right (assuming stereo), once round a circle (assuming multichannel)"],["f","panspan","a pattern of numbers between -inf and inf, which controls how much multichannel output is fanned out (negative is backwards ordering)"],["f","pansplay","a pattern of numbers between 0.0 and 1.0, which controls the multichannel spread range (multichannel only)"],["f","panwidth","a pattern of numbers between 0.0 and inf, which controls how much each channel is distributed over neighbours (multichannel only)"],["f","panorient","a pattern of numbers between -1.0 and 1.0, which controls the relative position of the centre pan in a pair of adjacent speakers (multichannel only)"],["f","rate","used in SuperDirt softsynths as a control rate or 'speed'"],["f","slide",""],["f","semitone",""],["f","velocity",""],["f","voice",""],["f","room","a pattern of numbers from 0 to 1. Sets the level of reverb."],["f","size","a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the `room` to be used in reverb."],["f","roomsize","a pattern of numbers from 0 to 1. Sets the perceptual size (reverb time) of the `room` to be used in reverb."],["f","shape","wave shaping distortion, a pattern of numbers from 0 for no distortion up to 1 for loads of distortion."],["f","speed","a pattern of numbers which changes the speed of sample playback, i.e. a cheap way of changing pitch. Negative values will play the sample backwards!"],["s","unit",'used in conjunction with `speed`, accepts values of "r" (rate, default behavior), "c" (cycles), or "s" (seconds). Using `unit "c"` means `speed` will be interpreted in units of cycles, e.g. `speed "1"` means samples will be stretched to fill a cycle. Using `unit "s"` means the playback speed will be adjusted so that the duration is the number of seconds specified by `speed`.'],["f","squiz",""],["f","stutterdepth",""],["f","stuttertime",""],["f","timescale",""],["f","timescalewin",""],["s","vowel","formant filter to make things sound like vowels, a pattern of either `a`, `e`, `i`, `o` or `u`. Use a rest (`~`) for no effect."],["f","waveloss",""],["f","dur",""],["f","expression",""],["f","sustainpedal",""],["f","tremolodepth","Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],["f","tremolorate","Tremolo Audio DSP effect | params are 'tremolorate' and 'tremolodepth'"],["f","phaserdepth","Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],["f","phaserrate","Phaser Audio DSP effect | params are 'phaserrate' and 'phaserdepth'"],["f","fshift","frequency shifter"],["f","fshiftnote","frequency shifter"],["f","fshiftphase","frequency shifter"],["f","triode","tube distortion"],["f","krush","shape/bass enhancer"],["f","kcutoff",""],["f","octer","octaver effect"],["f","octersub","octaver effect"],["f","octersubsub","octaver effect"],["f","ring","ring modulation"],["f","ringf","ring modulation"],["f","ringdf","ring modulation"],["f","distort","noisy fuzzy distortion"],["f","freeze","Spectral freeze"],["f","xsdelay",""],["f","tsdelay",""],["f","real","Spectral conform"],["f","imag",""],["f","enhance","Spectral enhance"],["f","partials",""],["f","comb","Spectral comb"],["f","smear","Spectral smear"],["f","scram","Spectral scramble"],["f","binshift","Spectral binshift"],["f","hbrick","High pass sort of spectral filter"],["f","lbrick","Low pass sort of spectral filter"],["f","midichan",""],["f","control",""],["f","ccn",""],["f","ccv",""],["f","polyTouch",""],["f","midibend",""],["f","miditouch",""],["f","ctlNum",""],["f","frameRate",""],["f","frames",""],["f","hours",""],["s","midicmd",""],["f","minutes",""],["f","progNum",""],["f","seconds",""],["f","songPtr",""],["f","uid",""],["f","val",""],["f","cps",""],["f","clip",""]],_name=(r,...t)=>sequence$1(...t).withValue(e=>({[r]:e})),_setter=(r,t)=>function(...e){return e.length?this.set(r(...e)):this.fmap(o=>({[t]:o}))};generic_params.forEach(([r,t,e])=>{controls[t]=(...o)=>_name(t,...o),Pattern$3.prototype[t]=_setter(controls[t],t)});controls.createParam=r=>{const t=(...e)=>_name(r,...e);return Pattern$3.prototype[r]=_setter(t,r),(...e)=>_name(r,...e)};controls.createParams=(...r)=>r.reduce((t,e)=>Object.assign(t,{[e]:createParam(e)}),{});function bjorklund(r,t){for(var e=[],o=[],s=[t],i=r-t,f=0,l=function(g){if(g==-1)e.push(0);else if(g==-2)e.push(1);else{for(var w=0;w1;)o.push(Math.floor(i/s[f])),s.push(i%s[f]),i=s[f],f++;return o.push(i),l(f),e.reverse()}var bjork=function(r,t){return r>t?bjorklund(r,t):bjorklund(t,r)};const euclid=(r,t,e=0)=>{const o=bjork(t,r);return e?rotate(o,-e):o};Pattern$3.prototype.euclid=function(r,t,e=0){return this.struct(euclid(r,t,e))};Pattern$3.prototype.euclidLegato=function(r,t,e=0){const o=euclid(r,t,e),s=o.indexOf(1),i=rotate(o,s).join("").split("1").slice(1).map(f=>[f.length+1,!0]);return this.struct(timeCat$1(...i)).late(fraction(s).div(t))};function steady(r){return new Pattern$3(t=>[new Hap(void 0,t.span,r)])}const signal=r=>{const t=e=>[new Hap(void 0,e.span,r(e.span.midpoint()))];return new Pattern$3(t)},isaw=signal(r=>1-r%1),isaw2=isaw._toBipolar(),saw=signal(r=>r%1),saw2=saw._toBipolar(),sine2=signal(r=>Math.sin(Math.PI*2*r)),sine=sine2._fromBipolar(),cosine=sine._early(fraction(1).div(4)),cosine2=sine2._early(fraction(1).div(4)),square=signal(r=>Math.floor(r*2%2)),square2=square._toBipolar(),tri=fastcat(isaw,saw),tri2=fastcat(isaw2,saw2),time=signal(id),xorwise=r=>{const t=r<<13^r,e=t>>17^t;return e<<5^e},_frac=r=>r-Math.trunc(r),timeToIntSeed=r=>xorwise(Math.trunc(_frac(r/300)*536870912)),intSeedToRand=r=>r%536870912/536870912,timeToRand=r=>Math.abs(intSeedToRand(timeToIntSeed(r))),rand=signal(timeToRand),rand2=rand._toBipolar(),_brandBy=r=>rand.fmap(t=>treify$2(r).fmap(_brandBy).innerJoin(),brand=_brandBy(.5),_irand=r=>rand.fmap(t=>Math.trunc(t*r)),irand=r=>reify$2(r).fmap(_irand).innerJoin(),__chooseWith=(r,t)=>(t=t.map(reify$2),t.length==0?silence$1:r.range(0,t.length).fmap(e=>t[Math.floor(e)])),chooseWith=(r,t)=>__chooseWith(r,t).outerJoin(),chooseInWith=(r,t)=>__chooseWith(r,t).innerJoin(),choose=(...r)=>chooseWith(rand,r);Pattern$3.prototype.choose=function(...r){return chooseWith(this,r)};Pattern$3.prototype.choose2=function(...r){return chooseWith(this._fromBipolar(),r)};const chooseCycles=(...r)=>chooseInWith(rand.segment(1),r),randcat=chooseCycles,_wchooseWith=function(r,...t){const e=t.map(l=>reify$2(l[0])),o=[];let s=0;for(const l of t)s+=l[1],o.push(s);const i=s,f=function(l){const g=l*i;return e[o.findIndex(w=>w>g,o)]};return r.fmap(f)},wchooseWith=(...r)=>_wchooseWith(...r).outerJoin(),wchoose=(...r)=>wchooseWith(rand,...r),wchooseCycles=(...r)=>_wchooseWith(rand,...r).innerJoin(),perlinWith=r=>{const t=r.fmap(Math.floor),e=r.fmap(i=>Math.floor(i)+1),o=i=>6*i**5-15*i**4+10*i**3,s=i=>f=>l=>f+o(i)*(l-f);return r.sub(t).fmap(s).appBoth(t.fmap(timeToRand)).appBoth(e.fmap(timeToRand))},perlin=perlinWith(time.fmap(r=>Number(r)));Pattern$3.prototype._degradeByWith=function(r,t){return this.fmap(e=>o=>e).appLeft(r._filterValues(e=>e>t))};Pattern$3.prototype._degradeBy=function(r){return this._degradeByWith(rand,r)};Pattern$3.prototype.degrade=function(){return this._degradeBy(.5)};Pattern$3.prototype._undegradeBy=function(r){return this._degradeByWith(rand.fmap(t=>1-t),r)};Pattern$3.prototype.undegrade=function(){return this._undegradeBy(.5)};Pattern$3.prototype._sometimesBy=function(r,t){return stack$1(this._degradeBy(r),t(this._undegradeBy(1-r)))};Pattern$3.prototype.sometimesBy=function(r,t){const e=this;return reify$2(r).fmap(o=>e._sometimesBy(o,t)).innerJoin()};Pattern$3.prototype._sometimesByPre=function(r,t){return stack$1(this._degradeBy(r),t(this).undegradeBy(1-r))};Pattern$3.prototype.sometimesByPre=function(r,t){const e=this;return reify$2(r).fmap(o=>e._sometimesByPre(o,t)).innerJoin()};Pattern$3.prototype.sometimes=function(r){return this._sometimesBy(.5,r)};Pattern$3.prototype.sometimesPre=function(r){return this._sometimesByPre(.5,r)};Pattern$3.prototype._someCyclesBy=function(r,t){return stack$1(this._degradeByWith(rand._segment(1),r),t(this._degradeByWith(rand.fmap(e=>1-e)._segment(1),1-r)))};Pattern$3.prototype.someCyclesBy=function(r,t){const e=this;return reify$2(r).fmap(o=>e._someCyclesBy(o,t)).innerJoin()};Pattern$3.prototype.someCycles=function(r){return this._someCyclesBy(.5,r)};Pattern$3.prototype.often=function(r){return this.sometimesBy(.75,r)};Pattern$3.prototype.rarely=function(r){return this.sometimesBy(.25,r)};Pattern$3.prototype.almostNever=function(r){return this.sometimesBy(.1,r)};Pattern$3.prototype.almostAlways=function(r){return this.sometimesBy(.9,r)};Pattern$3.prototype.never=function(r){return this};Pattern$3.prototype.always=function(r){return r(this)};Pattern$3.prototype.patternified.push("degradeBy","undegradeBy");let synth;try{synth=window==null?void 0:window.speechSynthesis}catch{console.warn("cannot use window: not in browser?")}let allVoices=synth==null?void 0:synth.getVoices();function speak(r,t,e){synth.cancel();const o=new SpeechSynthesisUtterance(r);o.lang=t,allVoices=synth.getVoices();const s=allVoices.filter(i=>i.lang.includes(t));typeof e=="number"?o.voice=s[e%s.length]:typeof e=="string"&&(o.voice=s.find(i=>i.name===i)),speechSynthesis.speak(o)}Pattern$3.prototype._speak=function(r,t){return this._withHap(e=>{const o=(s,i)=>{speak(i.value,r,t)};return e.setContext({...e.context,onTrigger:o})})};Pattern$3.prototype.speak=function(r,t){return patternify2(Pattern$3.prototype._speak)(reify(r),reify(t),this)};const{isPattern,Pattern:Pattern$2}=strudel;let scoped=!1;const evalScope=async(...r)=>{scoped&&console.warn("evalScope was called more than once."),scoped=!0;const t=await Promise.allSettled(r),e=t.filter(o=>o.status==="fulfilled").map(o=>o.value);t.forEach((o,s)=>{o.status==="rejected"&&console.warn(`evalScope: module with index ${s} could not be loaded:`,o.reason)}),Object.assign(globalThis,...e,Pattern$2.prototype.bootstrap())};function safeEval(r,t={}){const{wrapExpression:e=!0,wrapAsync:o=!0}=t;e&&(r=`{${r}}`),o&&(r=`(async ()=>${r})()`);const s=`"use strict";return (${r})`;return Function(s)()}const evaluate$1=async(r,t)=>{scoped||await evalScope(),t&&(r=t(r));let o=await safeEval(r,{wrapExpression:!!t});if(!isPattern(o)){console.log("evaluated",o);const s=`got "${typeof o}" instead of pattern`;throw new Error(s+(typeof o=="function"?", did you forget to call a function?":"."))}return{mode:"javascript",pattern:o}};function createClock(r,t,e=.05,o=.1,s=.1){let i=0,f=0,l=10**4,g=.01;const w=b=>e=b(e);s=s||o/2;const y=()=>{const b=r(),I=b+o+s;for(f===0&&(f=b+g);f=b&&t(f,e,i),f{y(),$=setInterval(y,o*1e3)},C=()=>clearInterval($);return{setDuration:w,start:S,stop:()=>{i=0,f=0,C()},pause:()=>C(),duration:e,getPhase:()=>f}}class Cyclist{constructor({interval:t,onTrigger:e,onError:o,getTime:s,latency:i=.1}){K(this,"worker");K(this,"pattern");K(this,"started",!1);K(this,"cps",1);K(this,"getTime");K(this,"phase",0);this.getTime=s;const f=l=>Math.round(l*1e3)/1e3;this.clock=createClock(s,(l,g,w)=>{w===0&&(this.origin=l);const y=f(l-this.origin);this.phase=y-i;const $=f(y+g),S=s();try{this.pattern.queryArc(y,$).forEach(p=>{if(p.part.begin.equals(p.whole.begin)){const d=p.whole.begin+this.origin-S+i,m=p.duration*1;e==null||e(p,d,m)}})}catch(C){console.warn("scheduler error",C),o==null||o(C)}},t)}getPhase(){return this.phase}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.clock.start(),this.started=!0}pause(){this.clock.stop(),delete this.origin,this.started=!1}stop(){delete this.origin,this.clock.stop(),this.started=!1}setPattern(t,e=!1){this.pattern=t,e&&!this.started&&this.start()}setCps(t=1){this.cps=t}log(t,e,o){const s=o.filter(i=>i.hasOnset());console.log(`${t.toFixed(4)} - ${e.toFixed(4)} ${Array(s.length).fill("I").join("")}`)}}function repl({interval:r,defaultOutput:t,onSchedulerError:e,onEvalError:o,onEval:s,getTime:i,transpiler:f}){const l=new Cyclist({interval:r,onTrigger:t,onError:e,getTime:i});return{scheduler:l,evaluate:async w=>{if(!w)throw new Error("no code to evaluate");try{const{pattern:y}=await evaluate$1(w,f);l.setPattern(y,!0),s==null||s({pattern:y,code:w})}catch(y){console.warn(`eval error: ${y.message}`),o==null||o(y)}}}}const gist=(route,cache=!0)=>fetch(`https://gist.githubusercontent.com/${route}?cachebust=${cache?"":Date.now()}`).then(r=>r.text()).then(code=>eval(code));console.log("%c // \u{1F300} @strudel.cycles/core loaded \u{1F300}","background-color: black;color:white;padding:4px;border-radius:15px");globalThis._strudelLoaded&&console.warn(`@strudel.cycles/core was loaded more than once... This might happen when you have multiple versions of strudel installed. -Please check with "npm ls @strudel.cycles/core".`);globalThis._strudelLoaded=!0;function peg$subclass(r,t){function e(){this.constructor=r}e.prototype=t.prototype,r.prototype=new e}function peg$SyntaxError(r,t,e,o){var s=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(s,peg$SyntaxError.prototype),s.expected=t,s.found=e,s.location=o,s.name="SyntaxError",s}peg$subclass(peg$SyntaxError,Error);function peg$padEnd(r,t,e){return e=e||" ",r.length>t?r:(t-=r.length,e+=e.repeat(t),r+e.slice(0,t))}peg$SyntaxError.prototype.format=function(r){var t="Error: "+this.message;if(this.location){var e=null,o;for(o=0;ot?r:(t-=r.length,e+=e.repeat(t),r+e.slice(0,t))}peg$SyntaxError.prototype.format=function(r){var t="Error: "+this.message;if(this.location){var e=null,o;for(o=0;o `+i+` -`+f+` | +`+l+` | `+s.line+" | "+g+` -`+f+" | "+peg$padEnd("",s.column-1," ")+peg$padEnd("",y,"^")}else t+=` - at `+i}return t};peg$SyntaxError.buildMessage=function(r,t){var e={literal:function(w){return'"'+s(w.text)+'"'},class:function(w){var y=w.parts.map(function($){return Array.isArray($)?i($[0])+"-"+i($[1]):i($)});return"["+(w.inverted?"^":"")+y.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(w){return w.description}};function o(w){return w.charCodeAt(0).toString(16).toUpperCase()}function s(w){return w.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+o(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+o(y)})}function i(w){return w.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+o(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+o(y)})}function l(w){return e[w.type](w)}function f(w){var y=w.map(l),$,S;if(y.sort(),y.length>0){for($=1,S=1;$",E="@",W="!",P="(",B=")",z="/",O="*",Z="%",L="?",le="struct",we="target",be="euclid",te="slow",fe="rotL",pe="rotR",he="fast",ve="scale",de="//",$e="cat",F="$",Q="setcps",ge="setbpm",me="hush",M=/^[1-9]/,U=/^[eE]/,ye=/^[0-9]/,J=/^[ \n\r\t]/,ee=/^[0-9a-zA-Z~]/,R=/^[^\n]/,X=He("number"),re=N(".",!1),Pe=ne([["1","9"]],!1,!1),Be=ne(["e","E"],!1,!1),Te=N("-",!1),Ze=N("+",!1),Le=N("0",!1),Je=ne([["0","9"]],!1,!1),Ke=He("whitespace"),Ge=ne([" ",` -`,"\r"," "],!1,!1),Ye=N(",",!1),Qe=N("|",!1),Ue=N('"',!1),et=N("'",!1),tt=ne([["0","9"],["a","z"],["A","Z"],"~"],!1,!1),rt=N("#",!1),nt=N("^",!1),st=N("_",!1),ot=N(":",!1),Re=N("[",!1),je=N("]",!1),it=N("<",!1),at=N(">",!1),ct=N("@",!1),ut=N("!",!1),lt=N("(",!1),ft=N(")",!1),pt=N("/",!1),ht=N("*",!1),dt=N("%",!1),gt=N("?",!1),mt=N("struct",!1),yt=N("target",!1),wt=N("euclid",!1),bt=N("slow",!1),vt=N("rotL",!1),$t=N("rotR",!1),_t=N("fast",!1),Ct=N("scale",!1),At=N("//",!1),Fe=ne([` -`],!0,!1),It=N("cat",!1),Pt=N("$",!1),Bt=N("setcps",!1),St=N("setbpm",!1),xt=N("hush",!1),kt=function(){return parseFloat(ur())},Nt=function(n){return n.join("")},qt=function(n){return n},Tt=function(n){return n.arguments_.alignment="t",n},Gt=function(n){return{weight:n}},Rt=function(n){return{replicate:n}},jt=function(n,c,u){return{operator:{type_:"bjorklund",arguments_:{pulse:n,step:c,rotation:u||0}}}},Ft=function(n){return{operator:{type_:"stretch",arguments_:{amount:n}}}},Mt=function(n){return{operator:{type_:"stretch",arguments_:{amount:"1/"+n}}}},Ht=function(n){return{operator:{type_:"fixed-step",arguments_:{amount:n}}}},Ot=function(n){return{operator:{type_:"degradeBy",arguments_:{amount:n||.5}}}},Wt=function(n,c){return new en(n,c)},Vt=function(n){return new Ne(n,"h")},zt=function(n){return{alignment:"v",list:n}},Xt=function(n){return{alignment:"r",list:n}},Dt=function(n,c){return c&&c.list.length>0?new Ne([n,...c.list],c.alignment):n},Et=function(n){return n},Zt=function(n){return{name:"struct",args:{sequence:n}}},Lt=function(n){return{name:"target",args:{name:n}}},Jt=function(n,c,u){return{name:"bjorklund",args:{pulse:parseInt(n),step:parseInt(c)}}},Kt=function(n){return{name:"stretch",args:{amount:n}}},Yt=function(n){return{name:"shift",args:{amount:"-"+n}}},Qt=function(n){return{name:"shift",args:{amount:n}}},Ut=function(n){return{name:"stretch",args:{amount:"1/"+n}}},er=function(n){return{name:"scale",args:{scale:n.join("")}}},Me=function(n,c){return c},tr=function(n,c){return c.unshift(n),new Ne(c,"t")},rr=function(n){return n},nr=function(n,c){return new Ur(n.name,n.args,c)},sr=function(n){return n},or=function(n){return n},ir=function(n){return new qe("setcps",{value:n})},ar=function(n){return new qe("setcps",{value:n/120/2})},cr=function(){return new qe("hush")},a=0,q=0,_e=[{line:1,column:1}],D=0,Se=[],_=0,Ce;if("startRule"in t){if(!(t.startRule in s))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');i=s[t.startRule]}function ur(){return r.substring(q,a)}function lr(){return xe(q,a)}function N(n,c){return{type:"literal",text:n,ignoreCase:c}}function ne(n,c,u){return{type:"class",parts:n,inverted:c,ignoreCase:u}}function fr(){return{type:"end"}}function He(n){return{type:"other",description:n}}function Oe(n){var c=_e[n],u;if(c)return c;for(u=n-1;!_e[u];)u--;for(c=_e[u],c={line:c.line,column:c.column};uD&&(D=a,Se=[]),Se.push(n))}function hr(n,c,u){return new peg$SyntaxError(peg$SyntaxError.buildMessage(n,c),n,c,u)}function We(){var n;return n=Qr(),n}function H(){var n,c;return _++,n=a,Ve(),c=Ae(),c!==e?(wr(),yr(),q=n,n=kt()):(a=n,n=e),_--,n===e&&_===0&&A(X),n}function dr(){var n;return r.charCodeAt(a)===46?(n=l,a++):(n=e,_===0&&A(re)),n}function gr(){var n;return M.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Pe)),n}function mr(){var n;return U.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Be)),n}function yr(){var n,c,u,v,x;if(n=a,c=mr(),c!==e){if(u=Ve(),u===e&&(u=br()),u===e&&(u=null),v=[],x=se(),x!==e)for(;x!==e;)v.push(x),x=se();else v=e;v!==e?(c=[c,u,v],n=c):(a=n,n=e)}else a=n,n=e;return n}function wr(){var n,c,u,v;if(n=a,c=dr(),c!==e){if(u=[],v=se(),v!==e)for(;v!==e;)u.push(v),v=se();else u=e;u!==e?(c=[c,u],n=c):(a=n,n=e)}else a=n,n=e;return n}function Ae(){var n,c,u,v;if(n=vr(),n===e)if(n=a,c=gr(),c!==e){for(u=[],v=se();v!==e;)u.push(v),v=se();c=[c,u],n=c}else a=n,n=e;return n}function Ve(){var n;return r.charCodeAt(a)===45?(n=f,a++):(n=e,_===0&&A(Te)),n}function br(){var n;return r.charCodeAt(a)===43?(n=g,a++):(n=e,_===0&&A(Ze)),n}function vr(){var n;return r.charCodeAt(a)===48?(n=w,a++):(n=e,_===0&&A(Le)),n}function se(){var n;return ye.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Je)),n}function k(){var n,c;for(_++,n=[],J.test(r.charAt(a))?(c=r.charAt(a),a++):(c=e,_===0&&A(Ge));c!==e;)n.push(c),J.test(r.charAt(a))?(c=r.charAt(a),a++):(c=e,_===0&&A(Ge));return _--,c=e,_===0&&A(Ke),n}function oe(){var n,c,u,v;return n=a,c=k(),r.charCodeAt(a)===44?(u=y,a++):(u=e,_===0&&A(Ye)),u!==e?(v=k(),c=[c,u,v],n=c):(a=n,n=e),n}function ze(){var n,c,u,v;return n=a,c=k(),r.charCodeAt(a)===124?(u=$,a++):(u=e,_===0&&A(Qe)),u!==e?(v=k(),c=[c,u,v],n=c):(a=n,n=e),n}function ie(){var n;return r.charCodeAt(a)===34?(n=S,a++):(n=e,_===0&&A(Ue)),n===e&&(r.charCodeAt(a)===39?(n=C,a++):(n=e,_===0&&A(et))),n}function Ie(){var n;return ee.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(tt)),n===e&&(r.charCodeAt(a)===45?(n=f,a++):(n=e,_===0&&A(Te)),n===e&&(r.charCodeAt(a)===35?(n=p,a++):(n=e,_===0&&A(rt)),n===e&&(r.charCodeAt(a)===46?(n=l,a++):(n=e,_===0&&A(re)),n===e&&(r.charCodeAt(a)===94?(n=d,a++):(n=e,_===0&&A(nt)),n===e&&(r.charCodeAt(a)===95?(n=m,a++):(n=e,_===0&&A(st)),n===e&&(r.charCodeAt(a)===58?(n=b,a++):(n=e,_===0&&A(ot)))))))),n}function Xe(){var n,c,u;if(n=a,k(),c=[],u=Ie(),u!==e)for(;u!==e;)c.push(u),u=Ie();else c=e;return c!==e?(u=k(),q=n,n=Nt(c)):(a=n,n=e),n}function $r(){var n,c,u,v;return n=a,k(),r.charCodeAt(a)===91?(c=I,a++):(c=e,_===0&&A(Re)),c!==e?(k(),u=Ee(),u!==e?(k(),r.charCodeAt(a)===93?(v=T,a++):(v=e,_===0&&A(je)),v!==e?(k(),q=n,n=qt(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function _r(){var n,c,u,v;return n=a,k(),r.charCodeAt(a)===60?(c=G,a++):(c=e,_===0&&A(it)),c!==e?(k(),u=ae(),u!==e?(k(),r.charCodeAt(a)===62?(v=Y,a++):(v=e,_===0&&A(at)),v!==e?(k(),q=n,n=Tt(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Cr(){var n;return n=Xe(),n===e&&(n=$r(),n===e&&(n=_r())),n}function Ar(){var n;return n=Ir(),n===e&&(n=Br(),n===e&&(n=Sr(),n===e&&(n=xr(),n===e&&(n=kr(),n===e&&(n=Pr(),n===e&&(n=Nr())))))),n}function Ir(){var n,c,u;return n=a,r.charCodeAt(a)===64?(c=E,a++):(c=e,_===0&&A(ct)),c!==e?(u=H(),u!==e?(q=n,n=Gt(u)):(a=n,n=e)):(a=n,n=e),n}function Pr(){var n,c,u;return n=a,r.charCodeAt(a)===33?(c=W,a++):(c=e,_===0&&A(ut)),c!==e?(u=H(),u!==e?(q=n,n=Rt(u)):(a=n,n=e)):(a=n,n=e),n}function Br(){var n,c,u,v,x,j,V;return n=a,r.charCodeAt(a)===40?(c=P,a++):(c=e,_===0&&A(lt)),c!==e?(k(),u=H(),u!==e?(k(),v=oe(),v!==e?(k(),x=H(),x!==e?(k(),oe(),k(),j=H(),j===e&&(j=null),k(),r.charCodeAt(a)===41?(V=B,a++):(V=e,_===0&&A(ft)),V!==e?(q=n,n=jt(u,x,j)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Sr(){var n,c,u;return n=a,r.charCodeAt(a)===47?(c=z,a++):(c=e,_===0&&A(pt)),c!==e?(u=H(),u!==e?(q=n,n=Ft(u)):(a=n,n=e)):(a=n,n=e),n}function xr(){var n,c,u;return n=a,r.charCodeAt(a)===42?(c=O,a++):(c=e,_===0&&A(ht)),c!==e?(u=H(),u!==e?(q=n,n=Mt(u)):(a=n,n=e)):(a=n,n=e),n}function kr(){var n,c,u;return n=a,r.charCodeAt(a)===37?(c=Z,a++):(c=e,_===0&&A(dt)),c!==e?(u=H(),u!==e?(q=n,n=Ht(u)):(a=n,n=e)):(a=n,n=e),n}function Nr(){var n,c,u;return n=a,r.charCodeAt(a)===63?(c=L,a++):(c=e,_===0&&A(gt)),c!==e?(u=H(),u===e&&(u=null),q=n,n=Ot(u)):(a=n,n=e),n}function De(){var n,c,u;return n=a,c=Cr(),c!==e?(u=Ar(),u===e&&(u=null),q=n,n=Wt(c,u)):(a=n,n=e),n}function ae(){var n,c,u;if(n=a,c=[],u=De(),u!==e)for(;u!==e;)c.push(u),u=De();else c=e;return c!==e&&(q=n,c=Vt(c)),n=c,n}function qr(){var n,c,u,v,x;if(n=a,c=[],u=a,v=oe(),v!==e?(x=ae(),x!==e?u=x:(a=u,u=e)):(a=u,u=e),u!==e)for(;u!==e;)c.push(u),u=a,v=oe(),v!==e?(x=ae(),x!==e?u=x:(a=u,u=e)):(a=u,u=e);else c=e;return c!==e&&(q=n,c=zt(c)),n=c,n}function Tr(){var n,c,u,v,x;if(n=a,c=[],u=a,v=ze(),v!==e?(x=ae(),x!==e?u=x:(a=u,u=e)):(a=u,u=e),u!==e)for(;u!==e;)c.push(u),u=a,v=ze(),v!==e?(x=ae(),x!==e?u=x:(a=u,u=e)):(a=u,u=e);else c=e;return c!==e&&(q=n,c=Xt(c)),n=c,n}function Ee(){var n,c,u;return n=a,c=ae(),c!==e?(u=qr(),u===e&&(u=Tr()),u===e&&(u=null),q=n,n=Dt(c,u)):(a=n,n=e),n}function Gr(){var n,c,u,v;return n=a,k(),c=ie(),c!==e?(u=Ee(),u!==e?(v=ie(),v!==e?(q=n,n=Et(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Rr(){var n;return n=zr(),n===e&&(n=Hr(),n===e&&(n=Vr(),n===e&&(n=Fr(),n===e&&(n=Mr(),n===e&&(n=jr(),n===e&&(n=Wr(),n===e&&(n=Or()))))))),n}function jr(){var n,c,u;return n=a,r.substr(a,6)===le?(c=le,a+=6):(c=e,_===0&&A(mt)),c!==e?(k(),u=ce(),u!==e?(q=n,n=Zt(u)):(a=n,n=e)):(a=n,n=e),n}function Fr(){var n,c,u,v,x;return n=a,r.substr(a,6)===we?(c=we,a+=6):(c=e,_===0&&A(yt)),c!==e?(k(),u=ie(),u!==e?(v=Xe(),v!==e?(x=ie(),x!==e?(q=n,n=Lt(v)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Mr(){var n,c,u,v;return n=a,r.substr(a,6)===be?(c=be,a+=6):(c=e,_===0&&A(wt)),c!==e?(k(),u=Ae(),u!==e?(k(),v=Ae(),v!==e?(k(),Ae(),q=n,n=Jt(u,v)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Hr(){var n,c,u;return n=a,r.substr(a,4)===te?(c=te,a+=4):(c=e,_===0&&A(bt)),c!==e?(k(),u=H(),u!==e?(q=n,n=Kt(u)):(a=n,n=e)):(a=n,n=e),n}function Or(){var n,c,u;return n=a,r.substr(a,4)===fe?(c=fe,a+=4):(c=e,_===0&&A(vt)),c!==e?(k(),u=H(),u!==e?(q=n,n=Yt(u)):(a=n,n=e)):(a=n,n=e),n}function Wr(){var n,c,u;return n=a,r.substr(a,4)===pe?(c=pe,a+=4):(c=e,_===0&&A($t)),c!==e?(k(),u=H(),u!==e?(q=n,n=Qt(u)):(a=n,n=e)):(a=n,n=e),n}function Vr(){var n,c,u;return n=a,r.substr(a,4)===he?(c=he,a+=4):(c=e,_===0&&A(_t)),c!==e?(k(),u=H(),u!==e?(q=n,n=Ut(u)):(a=n,n=e)):(a=n,n=e),n}function zr(){var n,c,u,v,x;if(n=a,r.substr(a,5)===ve?(c=ve,a+=5):(c=e,_===0&&A(Ct)),c!==e)if(k(),u=ie(),u!==e){if(v=[],x=Ie(),x!==e)for(;x!==e;)v.push(x),x=Ie();else v=e;v!==e?(x=ie(),x!==e?(q=n,n=er(v)):(a=n,n=e)):(a=n,n=e)}else a=n,n=e;else a=n,n=e;return n}function ke(){var n,c,u,v;if(n=a,r.substr(a,2)===de?(c=de,a+=2):(c=e,_===0&&A(At)),c!==e){for(u=[],R.test(r.charAt(a))?(v=r.charAt(a),a++):(v=e,_===0&&A(Fe));v!==e;)u.push(v),R.test(r.charAt(a))?(v=r.charAt(a),a++):(v=e,_===0&&A(Fe));c=[c,u],n=c}else a=n,n=e;return n}function Xr(){var n,c,u,v,x,j,V,ue;if(n=a,r.substr(a,3)===$e?(c=$e,a+=3):(c=e,_===0&&A(It)),c!==e)if(k(),r.charCodeAt(a)===91?(u=I,a++):(u=e,_===0&&A(Re)),u!==e)if(k(),v=ce(),v!==e){for(x=[],j=a,V=oe(),V!==e?(ue=ce(),ue!==e?(q=j,j=Me(v,ue)):(a=j,j=e)):(a=j,j=e);j!==e;)x.push(j),j=a,V=oe(),V!==e?(ue=ce(),ue!==e?(q=j,j=Me(v,ue)):(a=j,j=e)):(a=j,j=e);j=k(),r.charCodeAt(a)===93?(V=T,a++):(V=e,_===0&&A(je)),V!==e?(q=n,n=tr(v,x)):(a=n,n=e)}else a=n,n=e;else a=n,n=e;else a=n,n=e;return n}function Dr(){var n;return n=Xr(),n===e&&(n=Gr()),n}function ce(){var n,c,u,v,x;if(n=a,c=Dr(),c!==e){for(k(),u=[],v=ke();v!==e;)u.push(v),v=ke();q=n,n=rr(c)}else a=n,n=e;return n===e&&(n=a,c=Rr(),c!==e?(k(),r.charCodeAt(a)===36?(u=F,a++):(u=e,_===0&&A(Pt)),u!==e?(v=k(),x=ce(),x!==e?(q=n,n=nr(c,x)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)),n}function Er(){var n,c;return n=a,c=ce(),c!==e&&(q=n,c=sr(c)),n=c,n===e&&(n=ke()),n}function Zr(){var n;return n=Er(),n}function Lr(){var n,c;return n=a,k(),c=Jr(),c===e&&(c=Kr(),c===e&&(c=Yr())),c!==e?(k(),q=n,n=or(c)):(a=n,n=e),n}function Jr(){var n,c,u;return n=a,r.substr(a,6)===Q?(c=Q,a+=6):(c=e,_===0&&A(Bt)),c!==e?(k(),u=H(),u!==e?(q=n,n=ir(u)):(a=n,n=e)):(a=n,n=e),n}function Kr(){var n,c,u;return n=a,r.substr(a,6)===ge?(c=ge,a+=6):(c=e,_===0&&A(St)),c!==e?(k(),u=H(),u!==e?(q=n,n=ar(u)):(a=n,n=e)):(a=n,n=e),n}function Yr(){var n,c;return n=a,r.substr(a,4)===me?(c=me,a+=4):(c=e,_===0&&A(xt)),c!==e&&(q=n,c=cr()),n=c,n}function Qr(){var n;return n=Zr(),n===e&&(n=Lr()),n}var Ne=function(n,c){this.type_="pattern",this.arguments_={alignment:c},this.source_=n},Ur=function(n,c,u){this.type_=n,this.arguments_=c,this.source_=u},en=function(n,c){this.type_="element",this.source_=n,this.options_=c,this.location_=lr()},qe=function(n,c){this.type_="command",this.name_=n,this.options_=c};if(Ce=i(),Ce!==e&&a===r.length)return Ce;throw Ce!==e&&a(t,e)=>{const s=r.source_[e].options_,i=s==null?void 0:s.operator;if(i){switch(i.type_){case"stretch":const f=Fraction(i.arguments_.amount).inverse();return reify$1(t).fast(f);case"bjorklund":return t.euclid(i.arguments_.pulse,i.arguments_.step,i.arguments_.rotation);case"degradeBy":return reify$1(t)._degradeByWith(rand.early(randOffset*_nextSeed()).segment(1),i.arguments_.amount)}console.warn(`operator "${i.type_}" not implemented`)}if(s!=null&&s.weight)return t;const l=Object.keys(s||{}).filter(f=>f!=="operator");return l.length&&console.warn(`option${l.length>1?"s":""} ${l.map(f=>`"${f}"`).join(", ")} not implemented`),t};function resolveReplications(r){r.source_=r.source_.map(t=>{const{replicate:e,...o}=t.options_||{};return e?{...t,options_:{...o,weight:e},source_:{type_:"pattern",arguments_:{alignment:"h"},source_:[{type_:"element",source_:t.source_,location_:t.location_,options_:{operator:{type_:"stretch",arguments_:{amount:Fraction(e).inverse().toString()}}}}]}}:t})}function patternifyAST(r){switch(r.type_){case"pattern":resolveReplications(r);const t=r.source_.map(patternifyAST).map(applyOptions(r)),e=r.arguments_.alignment;if(e==="v")return stack(...t);if(e==="r")return chooseInWith(rand.early(randOffset*_nextSeed()).segment(1),t);const o=r.source_.some(s=>{var i;return!!((i=s.options_)!=null&&i.weight)});if(!o&&e==="t")return slowcat(...t);if(o){const s=timeCat(...r.source_.map((i,l)=>{var f;return[((f=i.options_)==null?void 0:f.weight)||1,t[l]]}));if(e==="t"){const i=r.source_.reduce((l,f)=>{var g;return l+(((g=f.options_)==null?void 0:g.weight)||1)},0);return s._slow(i)}return s}return sequence(...t);case"element":if(r.source_==="~")return silence;if(typeof r.source_!="object"){if(!r.location_)return console.warn("no location for",r),r.source_;const{start:s,end:i}=r.location_,l=isNaN(Number(r.source_))?r.source_:Number(r.source_);return pure(l).withLocation([s.line,s.column,s.offset],[i.line,i.column,i.offset])}return patternifyAST(r.source_);case"stretch":return patternifyAST(r.source_).slow(r.arguments_.amount);default:return console.warn(`node type "${r.type_}" not implemented -> returning silence`),silence}}const mini=(...r)=>{const t=r.map(e=>{const o=peg$parse(`"${e}"`);return patternifyAST(o)});return sequence(...t)},h=r=>{const t=peg$parse(r);return patternifyAST(t)};Pattern$1.prototype.define("mini",mini,{composable:!0});Pattern$1.prototype.define("m",mini,{composable:!0});Pattern$1.prototype.define("h",h,{composable:!0});function minify(r){return typeof r=="string"?mini(r):reify$1(r)}if(typeof DelayNode<"u"){class r extends DelayNode{constructor(e,o,s,i){super(e),o=Math.abs(o),this.delayTime.value=s;const l=e.createGain();l.gain.value=Math.min(Math.abs(i),.995),this.feedback=l.gain;const f=e.createGain();return f.gain.value=o,this.delayGain=f,this.connect(l),this.connect(f),l.connect(this),this.connect=g=>f.connect(g),this}start(e){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,e+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(t,e,o){return new r(this,t,e,o)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(r,t=1){const e=this.sampleRate*r,o=this.createBuffer(t,e,this.sampleRate),s=o.getChannelData(0);for(let i=0;i(t.buffer=this.impulseResponse(e),t.duration=r,t),t.setDuration(r),t});const bufferCache={},loadCache={},getCachedBuffer=r=>bufferCache[r],loadBuffer=(r,t)=>(loadCache[r]||(loadCache[r]=fetch(r).then(e=>e.arrayBuffer()).then(async e=>{const o=await t.decodeAudioData(e);return bufferCache[r]=o,o})),loadCache[r]);function reverseBuffer(r){const t=getAudioContext(),e=t.createBuffer(r.numberOfChannels,r.length,t.sampleRate);for(let o=0;obufferCache[r],githubCache={};let sampleCache={current:void 0};const loadGithubSamples=async(r,t)=>{const e="loadGithubSamples "+r,o=localStorage.getItem(e);if(o&&(console.log("[sampler]: loaded sample list from localstorage",r),githubCache[r]=JSON.parse(o)),githubCache[r])return sampleCache.current=githubCache[r],githubCache[r];console.log("[sampler]: fetching sample list from github",r);try{const[s,i,...l]=r.split("/"),f=`https://api.github.com/repos/${s}/${i}/contents`,g=await fetch(`${f}/${l.join("/")}`).then(w=>w.json());githubCache[r]=(await Promise.all(g.map(async({name:w,path:y})=>({name:w,content:await fetch(`${f}/${y}`).then($=>$.json()).catch($=>{console.error("could not load path",$)})})))).filter(({content:w})=>!!w).reduce((w,{name:y,content:$})=>({...w,[(t==null?void 0:t(y))||y]:$.map(({download_url:S})=>S)}),{})}catch(s){console.error("[sampler]: failed to fetch sample list from github",s);return}return sampleCache.current=githubCache[r],localStorage.setItem(e,JSON.stringify(sampleCache.current)),console.log("[sampler]: loaded samples:",sampleCache.current),githubCache[r]},samples=async(r,t=r._base||"")=>{if(typeof r=="string"){if(r.startsWith("github:")){const[o,s]=r.split("github:");r=`https://raw.githubusercontent.com/${s}/strudel.json`}if(typeof fetch!="function")return;const e=r.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(r).then(o=>o.json()).then(o=>samples(o,t||o._base||e)).catch(o=>{throw console.error(o),new Error(`error loading "${r}"`)})}sampleCache.current={...sampleCache.current,...Object.fromEntries(Object.entries(r).map(([e,o])=>{if(typeof o=="string"&&(o=[o]),typeof o!="object")throw new Error("wrong sample map format for "+e);t=o._base||t;const s=i=>(t+i).replace("github:","https://raw.githubusercontent.com/");return Array.isArray(o)?[e,o.map(s)]:[e,Object.fromEntries(Object.entries(o).map(([i,l])=>[i,(typeof l=="string"?[l]:l).map(s)]))]}))}},resetLoadedSamples=()=>{sampleCache.current=void 0},getLoadedSamples$1=()=>sampleCache.current;var vowelFormant={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class r extends GainNode{constructor(e,o){if(super(e),!vowelFormant[o])throw new Error("vowel: unknown vowel "+o);const{gains:s,qs:i,freqs:l}=vowelFormant[o],f=e.createGain();for(let g=0;g<5;g++){const w=e.createGain();w.gain.value=s[g];const y=e.createBiquadFilter();y.type="bandpass",y.Q.value=i[g],y.frequency.value=l[g],this.connect(y),y.connect(w),w.connect(f)}return f.gain.value=8,this.connect=g=>f.connect(g),this}}AudioContext.prototype.createVowelFilter=function(t){return new r(this,t)}}const workletsUrl="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK",{Pattern}=strudel;let audioContext;const getAudioContext$1=()=>(audioContext||(audioContext=new AudioContext),audioContext);let destination;const getDestination=()=>{const r=getAudioContext$1();return destination||(destination=r.createGain(),destination.connect(r.destination)),destination},panic=()=>{getDestination().gain.linearRampToValueAtTime(0,getAudioContext$1().currentTime+.01),destination=null},getFilter=(r,t,e)=>{const o=getAudioContext$1().createBiquadFilter();return o.type=r,o.frequency.value=t,o.Q.value=e,o},getADSR=(r,t,e,o,s,i,l)=>{const f=getAudioContext$1().createGain();return f.gain.setValueAtTime(0,i),f.gain.linearRampToValueAtTime(s,i+r),f.gain.linearRampToValueAtTime(e*s,i+r+t),f.gain.setValueAtTime(e*s,l),f.gain.linearRampToValueAtTime(0,l+o),f},getOscillator=({s:r,freq:t,t:e,duration:o,release:s})=>{const i=getAudioContext$1().createOscillator();return i.type=r||"triangle",i.frequency.value=Number(t),i.start(e),i.stop(e+o+s),i},getSoundfontKey=r=>{var o,s,i,l;if(!globalThis.soundfontList)return!1;if((s=(o=globalThis.soundfontList)==null?void 0:o.instruments)!=null&&s.includes(r))return r;const t=(l=(i=globalThis.soundfontList)==null?void 0:i.instrumentNames)==null?void 0:l.indexOf(r),e=t<10?`00${t}`:t<100?`0${t}`:t;if(t!==-1)return globalThis.soundfontList.instruments.find(f=>f.startsWith(e))},getSampleBufferSource=async(r,t,e,o)=>{let s=0,i=typeof e=="string"?toMidi(e):e||36;s=i-36;const l=getAudioContext$1(),f=getLoadedSamples();if(!f)throw new Error("no samples loaded");const g=f==null?void 0:f[r];if(!g)throw new Error(`sample not found: "${r}", try one of ${Object.keys(f).map(C=>`"${C}"`).join(", ")}.`);if(typeof g!="object")throw new Error("wrong format for sample bank:",r);let w;if(Array.isArray(g))w=g[t%g.length];else{const C=d=>toMidi(d)-i,p=Object.keys(g).filter(d=>!d.startsWith("_")).reduce((d,m,b)=>!d||Math.abs(C(m)){if(!r.includes(":"))return[r,t];let[e,o]=r.split(":");return isNaN(Number(o))?[r,t]:[e,o]};let workletsLoading;function loadWorklets(){return workletsLoading||(workletsLoading=getAudioContext$1().audioWorklet.addModule(workletsUrl),workletsLoading)}function getWorklet(r,t,e){const o=new AudioWorkletNode(r,t);return Object.entries(e).forEach(([s,i])=>{o.parameters.get(s).value=i}),o}if(typeof window<"u")try{loadWorklets()}catch(r){console.warn("could not load AudioWorklet effects coarse, crush and shape",r)}function gainNode(r){const t=getAudioContext$1().createGain();return t.gain.value=r,t}const cutGroups=[];let delays={};function getDelay(r,t,e,o){if(!delays[r]){const i=getAudioContext$1().createFeedbackDelay(1,t,e);i.start(o),i.connect(getDestination()),delays[r]=i}return delays[r].delayTime.value!==t&&delays[r].delayTime.setValueAtTime(t,o),delays[r].feedback.value!==e&&delays[r].feedback.setValueAtTime(e,o),delays[r]}let reverbs={};function getReverb(r,t=2){if(!reverbs[r]){const o=getAudioContext$1().createReverb(t);o.connect(getDestination()),reverbs[r]=o}return reverbs[r].duration!==t&&(reverbs[r]=reverbs[r].setDuration(t),reverbs[r].duration=t),reverbs[r]}function effectSend(r,t,e){const o=gainNode(e);return r.connect(o),o.connect(t),o}const webaudioOutput=async(r,t,e)=>{var o;try{const s=getAudioContext$1();if(typeof r.value!="object")throw new Error(`hap.value ${r.value} is not supported by webaudio output. Hint: append .note() or .s() to the end`);let i=s.currentTime+t,{freq:l,s:f,bank:g,sf:w,clip:y=0,n:$=0,note:S,gain:C=.8,cutoff:p,resonance:d=1,hcutoff:m,hresonance:b=1,bandf:I,bandq:T=1,coarse:G,crush:Y,shape:E,pan:W,speed:P=1,begin:B=0,end:z=1,vowel:O,delay:Z=0,delayfeedback:L=.5,delaytime:le=.25,unit:we,nudge:be=0,cut:te,loop:fe,orbit:pe=1,room:he,size:ve=2,roomsize:de=ve}=r.value;const{velocity:$e=1}=r.context;C*=$e;const F=[];if(g&&f&&(f=`${g}_${f}`),typeof f=="string"&&([f,$]=splitSN(f,$)),typeof S=="string"&&([S,$]=splitSN(S,$)),!f||["sine","square","triangle","sawtooth"].includes(f)){const{attack:M=.001,decay:U=.05,sustain:ye=.6,release:J=.01}=r.value;$=S||$||36,typeof $=="string"&&($=toMidi($)),!l&&typeof $=="number"&&(l=fromMidi($));const ee=getOscillator({t:i,s:f,freq:l,duration:e,release:J});F.push(ee),F.push(gainNode(.3));const R=getADSR(M,U,ye,J,1,i,i+e);F.push(R)}else{const{attack:M=.001,decay:U=.001,sustain:ye=1,release:J=.001}=r.value;if(P===0)return;if(!f){console.warn("no sample specified");return}const ee=getSoundfontKey(f);let R;try{ee?R=await globalThis.getFontBufferSource(ee,S||$,s):R=await getSampleBufferSource(f,$,S,P)}catch(Be){console.warn(Be);return}if(s.currentTime>i){console.warn("sample still loading:",f,$);return}if(!R){console.warn("no buffer source");return}R.playbackRate.value=Math.abs(P)*R.playbackRate.value,we==="c"&&(R.playbackRate.value=R.playbackRate.value*R.buffer.duration);let X=ee||y?e:R.buffer.duration/R.playbackRate.value;const re=B*X*R.playbackRate.value;X=(z-B)*X,fe&&(R.loop=!0,R.loopStart=re,R.loopEnd=re+X,X=fe*X),i+=be,R.start(i,re),te!==void 0&&((o=cutGroups[te])==null||o.stop(i),cutGroups[te]=R),F.push(R),R.stop(i+X+J);const Pe=getADSR(M,U,ye,J,1,i,i+X);F.push(Pe)}if(F.push(gainNode(C)),p!==void 0&&F.push(getFilter("lowpass",p,d)),m!==void 0&&F.push(getFilter("highpass",m,b)),I!==void 0&&F.push(getFilter("bandpass",I,T)),O!==void 0&&F.push(s.createVowelFilter(O)),G!==void 0&&F.push(getWorklet(s,"coarse-processor",{coarse:G})),Y!==void 0&&F.push(getWorklet(s,"crush-processor",{crush:Y})),E!==void 0&&F.push(getWorklet(s,"shape-processor",{shape:E})),W!==void 0){const M=s.createStereoPanner();M.pan.value=2*W-1,F.push(M)}const Q=gainNode(1);F.push(Q),Q.connect(getDestination());let ge;if(Z>0&&le>0&&L>0){const M=getDelay(pe,le,L,i);ge=effectSend(Q,M,Z)}let me;if(he>0&&de>0){const M=getReverb(pe,de);me=effectSend(Q,M,he)}F.slice(1).reduce((M,U)=>M.connect(U),F[0]),F[0].onended=()=>F.concat([ge,me]).forEach(M=>M==null?void 0:M.disconnect())}catch(s){console.warn(".out error:",s)}},webaudioOutputTrigger=(r,t,e,o)=>webaudioOutput(t,r-e,t.duration/o);Pattern.prototype.out=function(){return this.onTrigger(webaudioOutputTrigger)};const tune=`await samples('github:tidalcycles/Dirt-Samples/master') - -stack( - // amen - n("0 1 2 3 4 5 6 7") - .sometimes(x=>x.ply(2)) - .rarely(x=>x.speed("2 | -2")) - .sometimesBy(.4, x=>x.delay(".5")) - .s("amencutup") - .slow(2) - .room(.5) - , - // bass - sine.add(saw.slow(4)).range(0,7).segment(8) - .superimpose(x=>x.add(.1)) - .scale('G0 minor').note() - .s("sawtooth").decay(.1).sustain(0) - .gain(.4).cutoff(perlin.range(300,3000).slow(8)).resonance(10) - .degradeBy("0 0.1 .5 .1") - .rarely(add(note("12"))) - , - // chord - note("Bb3,D4".superimpose(x=>x.add(.2))) - .s('sawtooth').cutoff(1000).struct("<~@3 [~ x]>") - .decay(.05).sustain(.0).delay(.8).delaytime(.125).room(.8) - , - // alien - s("breath").room(1).shape(.6).chop(16).rev().mask("") - , - n("0 1").s("east").delay(.5).degradeBy(.8).speed(rand.range(.5,1.5)) -).reset("")`,ctx=getAudioContext$1(),input=document.getElementById("text");input.innerHTML=tune;evalScope(controls,__vitePreload(()=>Promise.resolve().then(()=>strudel),void 0),__vitePreload(()=>import("./index.85aeb624.js"),[]),__vitePreload(()=>import("./index.b258159a.js"),[]),__vitePreload(()=>import("./index.8b8c94a0.js"),[]));setStringParser(mini);const{evaluate}=repl({defaultOutput:webaudioOutput,getTime:()=>ctx.currentTime});document.getElementById("start").addEventListener("click",()=>{ctx.resume(),evaluate(input.value)});export{Hap as H,Pattern$3 as P,minify as a,peg$SyntaxError as b,peg$parse as c,panic as d,webaudioOutputTrigger as e,getCachedBuffer as f,getAudioContext$1 as g,h,getLoadedBuffer as i,loadGithubSamples as j,resetLoadedSamples as k,loadBuffer as l,mini as m,getLoadedSamples$1 as n,mod as o,patternifyAST as p,getAugmentedNamespace as q,reverseBuffer as r,samples as s,commonjsGlobal as t,getDefaultExportFromCjs as u,reify$2 as v,webaudioOutput as w,stack$1 as x}; +`+l+" | "+peg$padEnd("",s.column-1," ")+peg$padEnd("",y,"^")}else t+=` + at `+i}return t};peg$SyntaxError.buildMessage=function(r,t){var e={literal:function(w){return'"'+s(w.text)+'"'},class:function(w){var y=w.parts.map(function($){return Array.isArray($)?i($[0])+"-"+i($[1]):i($)});return"["+(w.inverted?"^":"")+y.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(w){return w.description}};function o(w){return w.charCodeAt(0).toString(16).toUpperCase()}function s(w){return w.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+o(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+o(y)})}function i(w){return w.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(y){return"\\x0"+o(y)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(y){return"\\x"+o(y)})}function f(w){return e[w.type](w)}function l(w){var y=w.map(f),$,S;if(y.sort(),y.length>0){for($=1,S=1;$",D="@",W="!",P="(",B=")",z="/",O="*",Z="%",L="?",fe="struct",we="target",be="euclid",te="slow",le="rotL",pe="rotR",he="fast",ve="scale",de="//",$e="cat",F="$",Q="setcps",ge="setbpm",me="hush",M=/^[1-9]/,U=/^[eE]/,ye=/^[0-9]/,J=/^[ \n\r\t]/,ee=/^[0-9a-zA-Z~]/,R=/^[^\n]/,X=He("number"),re=x(".",!1),Pe=ne([["1","9"]],!1,!1),Be=ne(["e","E"],!1,!1),Te=x("-",!1),Ze=x("+",!1),Le=x("0",!1),Je=ne([["0","9"]],!1,!1),Ke=He("whitespace"),Ge=ne([" ",` +`,"\r"," "],!1,!1),Ye=x(",",!1),Qe=x("|",!1),Ue=x('"',!1),et=x("'",!1),tt=ne([["0","9"],["a","z"],["A","Z"],"~"],!1,!1),rt=x("#",!1),nt=x("^",!1),st=x("_",!1),ot=x(":",!1),Re=x("[",!1),je=x("]",!1),it=x("<",!1),at=x(">",!1),ct=x("@",!1),ut=x("!",!1),ft=x("(",!1),lt=x(")",!1),pt=x("/",!1),ht=x("*",!1),dt=x("%",!1),gt=x("?",!1),mt=x("struct",!1),yt=x("target",!1),wt=x("euclid",!1),bt=x("slow",!1),vt=x("rotL",!1),$t=x("rotR",!1),_t=x("fast",!1),Ct=x("scale",!1),At=x("//",!1),Fe=ne([` +`],!0,!1),It=x("cat",!1),Pt=x("$",!1),Bt=x("setcps",!1),St=x("setbpm",!1),kt=x("hush",!1),Nt=function(){return parseFloat(ur())},xt=function(n){return n.join("")},qt=function(n){return n},Tt=function(n){return n.arguments_.alignment="t",n},Gt=function(n){return{weight:n}},Rt=function(n){return{replicate:n}},jt=function(n,c,u){return{operator:{type_:"bjorklund",arguments_:{pulse:n,step:c,rotation:u||0}}}},Ft=function(n){return{operator:{type_:"stretch",arguments_:{amount:n}}}},Mt=function(n){return{operator:{type_:"stretch",arguments_:{amount:"1/"+n}}}},Ht=function(n){return{operator:{type_:"fixed-step",arguments_:{amount:n}}}},Ot=function(n){return{operator:{type_:"degradeBy",arguments_:{amount:n||.5}}}},Wt=function(n,c){return new en(n,c)},Vt=function(n){return new xe(n,"h")},zt=function(n){return{alignment:"v",list:n}},Xt=function(n){return{alignment:"r",list:n}},Et=function(n,c){return c&&c.list.length>0?new xe([n,...c.list],c.alignment):n},Dt=function(n){return n},Zt=function(n){return{name:"struct",args:{sequence:n}}},Lt=function(n){return{name:"target",args:{name:n}}},Jt=function(n,c,u){return{name:"bjorklund",args:{pulse:parseInt(n),step:parseInt(c)}}},Kt=function(n){return{name:"stretch",args:{amount:n}}},Yt=function(n){return{name:"shift",args:{amount:"-"+n}}},Qt=function(n){return{name:"shift",args:{amount:n}}},Ut=function(n){return{name:"stretch",args:{amount:"1/"+n}}},er=function(n){return{name:"scale",args:{scale:n.join("")}}},Me=function(n,c){return c},tr=function(n,c){return c.unshift(n),new xe(c,"t")},rr=function(n){return n},nr=function(n,c){return new Ur(n.name,n.args,c)},sr=function(n){return n},or=function(n){return n},ir=function(n){return new qe("setcps",{value:n})},ar=function(n){return new qe("setcps",{value:n/120/2})},cr=function(){return new qe("hush")},a=0,q=0,_e=[{line:1,column:1}],E=0,Se=[],_=0,Ce;if("startRule"in t){if(!(t.startRule in s))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');i=s[t.startRule]}function ur(){return r.substring(q,a)}function fr(){return ke(q,a)}function x(n,c){return{type:"literal",text:n,ignoreCase:c}}function ne(n,c,u){return{type:"class",parts:n,inverted:c,ignoreCase:u}}function lr(){return{type:"end"}}function He(n){return{type:"other",description:n}}function Oe(n){var c=_e[n],u;if(c)return c;for(u=n-1;!_e[u];)u--;for(c=_e[u],c={line:c.line,column:c.column};uE&&(E=a,Se=[]),Se.push(n))}function hr(n,c,u){return new peg$SyntaxError(peg$SyntaxError.buildMessage(n,c),n,c,u)}function We(){var n;return n=Qr(),n}function H(){var n,c;return _++,n=a,Ve(),c=Ae(),c!==e?(wr(),yr(),q=n,n=Nt()):(a=n,n=e),_--,n===e&&_===0&&A(X),n}function dr(){var n;return r.charCodeAt(a)===46?(n=f,a++):(n=e,_===0&&A(re)),n}function gr(){var n;return M.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Pe)),n}function mr(){var n;return U.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Be)),n}function yr(){var n,c,u,v,k;if(n=a,c=mr(),c!==e){if(u=Ve(),u===e&&(u=br()),u===e&&(u=null),v=[],k=se(),k!==e)for(;k!==e;)v.push(k),k=se();else v=e;v!==e?(c=[c,u,v],n=c):(a=n,n=e)}else a=n,n=e;return n}function wr(){var n,c,u,v;if(n=a,c=dr(),c!==e){if(u=[],v=se(),v!==e)for(;v!==e;)u.push(v),v=se();else u=e;u!==e?(c=[c,u],n=c):(a=n,n=e)}else a=n,n=e;return n}function Ae(){var n,c,u,v;if(n=vr(),n===e)if(n=a,c=gr(),c!==e){for(u=[],v=se();v!==e;)u.push(v),v=se();c=[c,u],n=c}else a=n,n=e;return n}function Ve(){var n;return r.charCodeAt(a)===45?(n=l,a++):(n=e,_===0&&A(Te)),n}function br(){var n;return r.charCodeAt(a)===43?(n=g,a++):(n=e,_===0&&A(Ze)),n}function vr(){var n;return r.charCodeAt(a)===48?(n=w,a++):(n=e,_===0&&A(Le)),n}function se(){var n;return ye.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(Je)),n}function N(){var n,c;for(_++,n=[],J.test(r.charAt(a))?(c=r.charAt(a),a++):(c=e,_===0&&A(Ge));c!==e;)n.push(c),J.test(r.charAt(a))?(c=r.charAt(a),a++):(c=e,_===0&&A(Ge));return _--,c=e,_===0&&A(Ke),n}function oe(){var n,c,u,v;return n=a,c=N(),r.charCodeAt(a)===44?(u=y,a++):(u=e,_===0&&A(Ye)),u!==e?(v=N(),c=[c,u,v],n=c):(a=n,n=e),n}function ze(){var n,c,u,v;return n=a,c=N(),r.charCodeAt(a)===124?(u=$,a++):(u=e,_===0&&A(Qe)),u!==e?(v=N(),c=[c,u,v],n=c):(a=n,n=e),n}function ie(){var n;return r.charCodeAt(a)===34?(n=S,a++):(n=e,_===0&&A(Ue)),n===e&&(r.charCodeAt(a)===39?(n=C,a++):(n=e,_===0&&A(et))),n}function Ie(){var n;return ee.test(r.charAt(a))?(n=r.charAt(a),a++):(n=e,_===0&&A(tt)),n===e&&(r.charCodeAt(a)===45?(n=l,a++):(n=e,_===0&&A(Te)),n===e&&(r.charCodeAt(a)===35?(n=p,a++):(n=e,_===0&&A(rt)),n===e&&(r.charCodeAt(a)===46?(n=f,a++):(n=e,_===0&&A(re)),n===e&&(r.charCodeAt(a)===94?(n=d,a++):(n=e,_===0&&A(nt)),n===e&&(r.charCodeAt(a)===95?(n=m,a++):(n=e,_===0&&A(st)),n===e&&(r.charCodeAt(a)===58?(n=b,a++):(n=e,_===0&&A(ot)))))))),n}function Xe(){var n,c,u;if(n=a,N(),c=[],u=Ie(),u!==e)for(;u!==e;)c.push(u),u=Ie();else c=e;return c!==e?(u=N(),q=n,n=xt(c)):(a=n,n=e),n}function $r(){var n,c,u,v;return n=a,N(),r.charCodeAt(a)===91?(c=I,a++):(c=e,_===0&&A(Re)),c!==e?(N(),u=De(),u!==e?(N(),r.charCodeAt(a)===93?(v=T,a++):(v=e,_===0&&A(je)),v!==e?(N(),q=n,n=qt(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function _r(){var n,c,u,v;return n=a,N(),r.charCodeAt(a)===60?(c=G,a++):(c=e,_===0&&A(it)),c!==e?(N(),u=ae(),u!==e?(N(),r.charCodeAt(a)===62?(v=Y,a++):(v=e,_===0&&A(at)),v!==e?(N(),q=n,n=Tt(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Cr(){var n;return n=Xe(),n===e&&(n=$r(),n===e&&(n=_r())),n}function Ar(){var n;return n=Ir(),n===e&&(n=Br(),n===e&&(n=Sr(),n===e&&(n=kr(),n===e&&(n=Nr(),n===e&&(n=Pr(),n===e&&(n=xr())))))),n}function Ir(){var n,c,u;return n=a,r.charCodeAt(a)===64?(c=D,a++):(c=e,_===0&&A(ct)),c!==e?(u=H(),u!==e?(q=n,n=Gt(u)):(a=n,n=e)):(a=n,n=e),n}function Pr(){var n,c,u;return n=a,r.charCodeAt(a)===33?(c=W,a++):(c=e,_===0&&A(ut)),c!==e?(u=H(),u!==e?(q=n,n=Rt(u)):(a=n,n=e)):(a=n,n=e),n}function Br(){var n,c,u,v,k,j,V;return n=a,r.charCodeAt(a)===40?(c=P,a++):(c=e,_===0&&A(ft)),c!==e?(N(),u=H(),u!==e?(N(),v=oe(),v!==e?(N(),k=H(),k!==e?(N(),oe(),N(),j=H(),j===e&&(j=null),N(),r.charCodeAt(a)===41?(V=B,a++):(V=e,_===0&&A(lt)),V!==e?(q=n,n=jt(u,k,j)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Sr(){var n,c,u;return n=a,r.charCodeAt(a)===47?(c=z,a++):(c=e,_===0&&A(pt)),c!==e?(u=H(),u!==e?(q=n,n=Ft(u)):(a=n,n=e)):(a=n,n=e),n}function kr(){var n,c,u;return n=a,r.charCodeAt(a)===42?(c=O,a++):(c=e,_===0&&A(ht)),c!==e?(u=H(),u!==e?(q=n,n=Mt(u)):(a=n,n=e)):(a=n,n=e),n}function Nr(){var n,c,u;return n=a,r.charCodeAt(a)===37?(c=Z,a++):(c=e,_===0&&A(dt)),c!==e?(u=H(),u!==e?(q=n,n=Ht(u)):(a=n,n=e)):(a=n,n=e),n}function xr(){var n,c,u;return n=a,r.charCodeAt(a)===63?(c=L,a++):(c=e,_===0&&A(gt)),c!==e?(u=H(),u===e&&(u=null),q=n,n=Ot(u)):(a=n,n=e),n}function Ee(){var n,c,u;return n=a,c=Cr(),c!==e?(u=Ar(),u===e&&(u=null),q=n,n=Wt(c,u)):(a=n,n=e),n}function ae(){var n,c,u;if(n=a,c=[],u=Ee(),u!==e)for(;u!==e;)c.push(u),u=Ee();else c=e;return c!==e&&(q=n,c=Vt(c)),n=c,n}function qr(){var n,c,u,v,k;if(n=a,c=[],u=a,v=oe(),v!==e?(k=ae(),k!==e?u=k:(a=u,u=e)):(a=u,u=e),u!==e)for(;u!==e;)c.push(u),u=a,v=oe(),v!==e?(k=ae(),k!==e?u=k:(a=u,u=e)):(a=u,u=e);else c=e;return c!==e&&(q=n,c=zt(c)),n=c,n}function Tr(){var n,c,u,v,k;if(n=a,c=[],u=a,v=ze(),v!==e?(k=ae(),k!==e?u=k:(a=u,u=e)):(a=u,u=e),u!==e)for(;u!==e;)c.push(u),u=a,v=ze(),v!==e?(k=ae(),k!==e?u=k:(a=u,u=e)):(a=u,u=e);else c=e;return c!==e&&(q=n,c=Xt(c)),n=c,n}function De(){var n,c,u;return n=a,c=ae(),c!==e?(u=qr(),u===e&&(u=Tr()),u===e&&(u=null),q=n,n=Et(c,u)):(a=n,n=e),n}function Gr(){var n,c,u,v;return n=a,N(),c=ie(),c!==e?(u=De(),u!==e?(v=ie(),v!==e?(q=n,n=Dt(u)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Rr(){var n;return n=zr(),n===e&&(n=Hr(),n===e&&(n=Vr(),n===e&&(n=Fr(),n===e&&(n=Mr(),n===e&&(n=jr(),n===e&&(n=Wr(),n===e&&(n=Or()))))))),n}function jr(){var n,c,u;return n=a,r.substr(a,6)===fe?(c=fe,a+=6):(c=e,_===0&&A(mt)),c!==e?(N(),u=ce(),u!==e?(q=n,n=Zt(u)):(a=n,n=e)):(a=n,n=e),n}function Fr(){var n,c,u,v,k;return n=a,r.substr(a,6)===we?(c=we,a+=6):(c=e,_===0&&A(yt)),c!==e?(N(),u=ie(),u!==e?(v=Xe(),v!==e?(k=ie(),k!==e?(q=n,n=Lt(v)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Mr(){var n,c,u,v;return n=a,r.substr(a,6)===be?(c=be,a+=6):(c=e,_===0&&A(wt)),c!==e?(N(),u=Ae(),u!==e?(N(),v=Ae(),v!==e?(N(),Ae(),q=n,n=Jt(u,v)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e),n}function Hr(){var n,c,u;return n=a,r.substr(a,4)===te?(c=te,a+=4):(c=e,_===0&&A(bt)),c!==e?(N(),u=H(),u!==e?(q=n,n=Kt(u)):(a=n,n=e)):(a=n,n=e),n}function Or(){var n,c,u;return n=a,r.substr(a,4)===le?(c=le,a+=4):(c=e,_===0&&A(vt)),c!==e?(N(),u=H(),u!==e?(q=n,n=Yt(u)):(a=n,n=e)):(a=n,n=e),n}function Wr(){var n,c,u;return n=a,r.substr(a,4)===pe?(c=pe,a+=4):(c=e,_===0&&A($t)),c!==e?(N(),u=H(),u!==e?(q=n,n=Qt(u)):(a=n,n=e)):(a=n,n=e),n}function Vr(){var n,c,u;return n=a,r.substr(a,4)===he?(c=he,a+=4):(c=e,_===0&&A(_t)),c!==e?(N(),u=H(),u!==e?(q=n,n=Ut(u)):(a=n,n=e)):(a=n,n=e),n}function zr(){var n,c,u,v,k;if(n=a,r.substr(a,5)===ve?(c=ve,a+=5):(c=e,_===0&&A(Ct)),c!==e)if(N(),u=ie(),u!==e){if(v=[],k=Ie(),k!==e)for(;k!==e;)v.push(k),k=Ie();else v=e;v!==e?(k=ie(),k!==e?(q=n,n=er(v)):(a=n,n=e)):(a=n,n=e)}else a=n,n=e;else a=n,n=e;return n}function Ne(){var n,c,u,v;if(n=a,r.substr(a,2)===de?(c=de,a+=2):(c=e,_===0&&A(At)),c!==e){for(u=[],R.test(r.charAt(a))?(v=r.charAt(a),a++):(v=e,_===0&&A(Fe));v!==e;)u.push(v),R.test(r.charAt(a))?(v=r.charAt(a),a++):(v=e,_===0&&A(Fe));c=[c,u],n=c}else a=n,n=e;return n}function Xr(){var n,c,u,v,k,j,V,ue;if(n=a,r.substr(a,3)===$e?(c=$e,a+=3):(c=e,_===0&&A(It)),c!==e)if(N(),r.charCodeAt(a)===91?(u=I,a++):(u=e,_===0&&A(Re)),u!==e)if(N(),v=ce(),v!==e){for(k=[],j=a,V=oe(),V!==e?(ue=ce(),ue!==e?(q=j,j=Me(v,ue)):(a=j,j=e)):(a=j,j=e);j!==e;)k.push(j),j=a,V=oe(),V!==e?(ue=ce(),ue!==e?(q=j,j=Me(v,ue)):(a=j,j=e)):(a=j,j=e);j=N(),r.charCodeAt(a)===93?(V=T,a++):(V=e,_===0&&A(je)),V!==e?(q=n,n=tr(v,k)):(a=n,n=e)}else a=n,n=e;else a=n,n=e;else a=n,n=e;return n}function Er(){var n;return n=Xr(),n===e&&(n=Gr()),n}function ce(){var n,c,u,v,k;if(n=a,c=Er(),c!==e){for(N(),u=[],v=Ne();v!==e;)u.push(v),v=Ne();q=n,n=rr(c)}else a=n,n=e;return n===e&&(n=a,c=Rr(),c!==e?(N(),r.charCodeAt(a)===36?(u=F,a++):(u=e,_===0&&A(Pt)),u!==e?(v=N(),k=ce(),k!==e?(q=n,n=nr(c,k)):(a=n,n=e)):(a=n,n=e)):(a=n,n=e)),n}function Dr(){var n,c;return n=a,c=ce(),c!==e&&(q=n,c=sr(c)),n=c,n===e&&(n=Ne()),n}function Zr(){var n;return n=Dr(),n}function Lr(){var n,c;return n=a,N(),c=Jr(),c===e&&(c=Kr(),c===e&&(c=Yr())),c!==e?(N(),q=n,n=or(c)):(a=n,n=e),n}function Jr(){var n,c,u;return n=a,r.substr(a,6)===Q?(c=Q,a+=6):(c=e,_===0&&A(Bt)),c!==e?(N(),u=H(),u!==e?(q=n,n=ir(u)):(a=n,n=e)):(a=n,n=e),n}function Kr(){var n,c,u;return n=a,r.substr(a,6)===ge?(c=ge,a+=6):(c=e,_===0&&A(St)),c!==e?(N(),u=H(),u!==e?(q=n,n=ar(u)):(a=n,n=e)):(a=n,n=e),n}function Yr(){var n,c;return n=a,r.substr(a,4)===me?(c=me,a+=4):(c=e,_===0&&A(kt)),c!==e&&(q=n,c=cr()),n=c,n}function Qr(){var n;return n=Zr(),n===e&&(n=Lr()),n}var xe=function(n,c){this.type_="pattern",this.arguments_={alignment:c},this.source_=n},Ur=function(n,c,u){this.type_=n,this.arguments_=c,this.source_=u},en=function(n,c){this.type_="element",this.source_=n,this.options_=c,this.location_=fr()},qe=function(n,c){this.type_="command",this.name_=n,this.options_=c};if(Ce=i(),Ce!==e&&a===r.length)return Ce;throw Ce!==e&&a(t,e)=>{const s=r.source_[e].options_,i=s==null?void 0:s.operator;if(i){switch(i.type_){case"stretch":const l=Fraction(i.arguments_.amount).inverse();return reify$1(t).fast(l);case"bjorklund":return t.euclid(i.arguments_.pulse,i.arguments_.step,i.arguments_.rotation);case"degradeBy":return reify$1(t)._degradeByWith(rand.early(randOffset*_nextSeed()).segment(1),i.arguments_.amount)}console.warn(`operator "${i.type_}" not implemented`)}if(s!=null&&s.weight)return t;const f=Object.keys(s||{}).filter(l=>l!=="operator");return f.length&&console.warn(`option${f.length>1?"s":""} ${f.map(l=>`"${l}"`).join(", ")} not implemented`),t};function resolveReplications(r){r.source_=r.source_.map(t=>{const{replicate:e,...o}=t.options_||{};return e?{...t,options_:{...o,weight:e},source_:{type_:"pattern",arguments_:{alignment:"h"},source_:[{type_:"element",source_:t.source_,location_:t.location_,options_:{operator:{type_:"stretch",arguments_:{amount:Fraction(e).inverse().toString()}}}}]}}:t})}function patternifyAST(r){switch(r.type_){case"pattern":resolveReplications(r);const t=r.source_.map(patternifyAST).map(applyOptions(r)),e=r.arguments_.alignment;if(e==="v")return stack(...t);if(e==="r")return chooseInWith(rand.early(randOffset*_nextSeed()).segment(1),t);const o=r.source_.some(s=>{var i;return!!((i=s.options_)!=null&&i.weight)});if(!o&&e==="t")return slowcat(...t);if(o){const s=timeCat(...r.source_.map((i,f)=>{var l;return[((l=i.options_)==null?void 0:l.weight)||1,t[f]]}));if(e==="t"){const i=r.source_.reduce((f,l)=>{var g;return f+(((g=l.options_)==null?void 0:g.weight)||1)},0);return s._slow(i)}return s}return sequence(...t);case"element":if(r.source_==="~")return silence;if(typeof r.source_!="object"){if(!r.location_)return console.warn("no location for",r),r.source_;const{start:s,end:i}=r.location_,f=isNaN(Number(r.source_))?r.source_:Number(r.source_);return pure(f).withLocation([s.line,s.column,s.offset],[i.line,i.column,i.offset])}return patternifyAST(r.source_);case"stretch":return patternifyAST(r.source_).slow(r.arguments_.amount);default:return console.warn(`node type "${r.type_}" not implemented -> returning silence`),silence}}const mini=(...r)=>{const t=r.map(e=>{const o=peg$parse(`"${e}"`);return patternifyAST(o)});return sequence(...t)},h=r=>{const t=peg$parse(r);return patternifyAST(t)};Pattern$1.prototype.define("mini",mini,{composable:!0});Pattern$1.prototype.define("m",mini,{composable:!0});Pattern$1.prototype.define("h",h,{composable:!0});function minify(r){return typeof r=="string"?mini(r):reify$1(r)}if(typeof DelayNode<"u"){class r extends DelayNode{constructor(e,o,s,i){super(e),o=Math.abs(o),this.delayTime.value=s;const f=e.createGain();f.gain.value=Math.min(Math.abs(i),.995),this.feedback=f.gain;const l=e.createGain();return l.gain.value=o,this.delayGain=l,this.connect(f),this.connect(l),f.connect(this),this.connect=g=>l.connect(g),this}start(e){this.delayGain.gain.setValueAtTime(this.delayGain.gain.value,e+this.delayTime.value)}}AudioContext.prototype.createFeedbackDelay=function(t,e,o){return new r(this,t,e,o)}}typeof AudioContext<"u"&&(AudioContext.prototype.impulseResponse=function(r,t=1){const e=this.sampleRate*r,o=this.createBuffer(t,e,this.sampleRate),s=o.getChannelData(0);for(let i=0;i(t.buffer=this.impulseResponse(e),t.duration=r,t),t.setDuration(r),t});const bufferCache={},loadCache={},getCachedBuffer=r=>bufferCache[r],loadBuffer=(r,t)=>(loadCache[r]||(loadCache[r]=fetch(r).then(e=>e.arrayBuffer()).then(async e=>{const o=await t.decodeAudioData(e);return bufferCache[r]=o,o})),loadCache[r]);function reverseBuffer(r){const t=getAudioContext(),e=t.createBuffer(r.numberOfChannels,r.length,t.sampleRate);for(let o=0;obufferCache[r],githubCache={};let sampleCache={current:void 0};const loadGithubSamples=async(r,t)=>{const e="loadGithubSamples "+r,o=localStorage.getItem(e);if(o&&(console.log("[sampler]: loaded sample list from localstorage",r),githubCache[r]=JSON.parse(o)),githubCache[r])return sampleCache.current=githubCache[r],githubCache[r];console.log("[sampler]: fetching sample list from github",r);try{const[s,i,...f]=r.split("/"),l=`https://api.github.com/repos/${s}/${i}/contents`,g=await fetch(`${l}/${f.join("/")}`).then(w=>w.json());githubCache[r]=(await Promise.all(g.map(async({name:w,path:y})=>({name:w,content:await fetch(`${l}/${y}`).then($=>$.json()).catch($=>{console.error("could not load path",$)})})))).filter(({content:w})=>!!w).reduce((w,{name:y,content:$})=>({...w,[(t==null?void 0:t(y))||y]:$.map(({download_url:S})=>S)}),{})}catch(s){console.error("[sampler]: failed to fetch sample list from github",s);return}return sampleCache.current=githubCache[r],localStorage.setItem(e,JSON.stringify(sampleCache.current)),console.log("[sampler]: loaded samples:",sampleCache.current),githubCache[r]},samples=async(r,t=r._base||"")=>{if(typeof r=="string"){if(r.startsWith("github:")){const[o,s]=r.split("github:");r=`https://raw.githubusercontent.com/${s}/strudel.json`}if(typeof fetch!="function")return;const e=r.split("/").slice(0,-1).join("/");return typeof fetch>"u"?void 0:fetch(r).then(o=>o.json()).then(o=>samples(o,t||o._base||e)).catch(o=>{throw console.error(o),new Error(`error loading "${r}"`)})}sampleCache.current={...sampleCache.current,...Object.fromEntries(Object.entries(r).map(([e,o])=>{if(typeof o=="string"&&(o=[o]),typeof o!="object")throw new Error("wrong sample map format for "+e);t=o._base||t;const s=i=>(t+i).replace("github:","https://raw.githubusercontent.com/");return Array.isArray(o)?[e,o.map(s)]:[e,Object.fromEntries(Object.entries(o).map(([i,f])=>[i,(typeof f=="string"?[f]:f).map(s)]))]}))}},resetLoadedSamples=()=>{sampleCache.current=void 0},getLoadedSamples$1=()=>sampleCache.current;var vowelFormant={a:{freqs:[660,1120,2750,3e3,3350],gains:[1,.5012,.0708,.0631,.0126],qs:[80,90,120,130,140]},e:{freqs:[440,1800,2700,3e3,3300],gains:[1,.1995,.1259,.1,.1],qs:[70,80,100,120,120]},i:{freqs:[270,1850,2900,3350,3590],gains:[1,.0631,.0631,.0158,.0158],qs:[40,90,100,120,120]},o:{freqs:[430,820,2700,3e3,3300],gains:[1,.3162,.0501,.0794,.01995],qs:[40,80,100,120,120]},u:{freqs:[370,630,2750,3e3,3400],gains:[1,.1,.0708,.0316,.01995],qs:[40,60,100,120,120]}};if(typeof GainNode<"u"){class r extends GainNode{constructor(e,o){if(super(e),!vowelFormant[o])throw new Error("vowel: unknown vowel "+o);const{gains:s,qs:i,freqs:f}=vowelFormant[o],l=e.createGain();for(let g=0;g<5;g++){const w=e.createGain();w.gain.value=s[g];const y=e.createBiquadFilter();y.type="bandpass",y.Q.value=i[g],y.frequency.value=f[g],this.connect(y),y.connect(w),w.connect(l)}return l.gain.value=8,this.connect=g=>l.connect(g),this}}AudioContext.prototype.createVowelFilter=function(t){return new r(this,t)}}const workletsUrl="data:application/javascript;base64,Ly8gTElDRU5TRSBHTlUgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSB2My4wIHNlZSBodHRwczovL2dpdGh1Yi5jb20vZGt0cjAvV2ViRGlydC9ibG9iL21haW4vTElDRU5TRQovLyBhbGwgdGhlIGNyZWRpdCBnb2VzIHRvIGRrdHIwJ3Mgd2ViZGlydDogaHR0cHM6Ly9naXRodWIuY29tL2RrdHIwL1dlYkRpcnQvYmxvYi81Y2UzZDY5ODM2MmM1NGQ2ZTFiNjhhY2M0N2ViMjk1NWFjNjJjNzkzL2Rpc3QvQXVkaW9Xb3JrbGV0cy5qcwovLyA8MwoKY2xhc3MgQ29hcnNlUHJvY2Vzc29yIGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgZ2V0IHBhcmFtZXRlckRlc2NyaXB0b3JzKCkgewogICAgcmV0dXJuIFt7IG5hbWU6ICdjb2Fyc2UnLCBkZWZhdWx0VmFsdWU6IDEgfV07CiAgfQoKICBjb25zdHJ1Y3RvcigpIHsKICAgIHN1cGVyKCk7CiAgICB0aGlzLm5vdFN0YXJ0ZWQgPSB0cnVlOwogIH0KCiAgcHJvY2VzcyhpbnB1dHMsIG91dHB1dHMsIHBhcmFtZXRlcnMpIHsKICAgIGNvbnN0IGlucHV0ID0gaW5wdXRzWzBdOwogICAgY29uc3Qgb3V0cHV0ID0gb3V0cHV0c1swXTsKICAgIGNvbnN0IGNvYXJzZSA9IHBhcmFtZXRlcnMuY29hcnNlOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBvdXRwdXRbMF1bMF0gPSBpbnB1dFswXVswXTsKICAgICAgZm9yIChsZXQgbiA9IDE7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgIGZvciAobGV0IG8gPSAwOyBvIDwgb3V0cHV0Lmxlbmd0aDsgbysrKSB7CiAgICAgICAgICBvdXRwdXRbb11bbl0gPSBuICUgY29hcnNlID09IDAgPyBpbnB1dFswXVtuXSA6IG91dHB1dFtvXVtuIC0gMV07CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ2NvYXJzZS1wcm9jZXNzb3InLCBDb2Fyc2VQcm9jZXNzb3IpOwoKY2xhc3MgQ3J1c2hQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ2NydXNoJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBjcnVzaCA9IHBhcmFtZXRlcnMuY3J1c2g7CiAgICBjb25zdCBibG9ja1NpemUgPSAxMjg7CiAgICBjb25zdCBoYXNJbnB1dCA9ICEoaW5wdXRbMF0gPT09IHVuZGVmaW5lZCk7CiAgICBpZiAoaGFzSW5wdXQpIHsKICAgICAgdGhpcy5ub3RTdGFydGVkID0gZmFsc2U7CiAgICAgIGlmIChjcnVzaC5sZW5ndGggPT09IDEpIHsKICAgICAgICBjb25zdCB4ID0gTWF0aC5wb3coMiwgY3J1c2hbMF0gLSAxKTsKICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgICBjb25zdCB2YWx1ZSA9IE1hdGgucm91bmQoaW5wdXRbMF1bbl0gKiB4KSAvIHg7CiAgICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgICBvdXRwdXRbb11bbl0gPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCBibG9ja1NpemU7IG4rKykgewogICAgICAgICAgbGV0IHggPSBNYXRoLnBvdygyLCBjcnVzaFtuXSAtIDEpOwogICAgICAgICAgY29uc3QgdmFsdWUgPSBNYXRoLnJvdW5kKGlucHV0WzBdW25dICogeCkgLyB4OwogICAgICAgICAgZm9yIChsZXQgbyA9IDA7IG8gPCBvdXRwdXQubGVuZ3RoOyBvKyspIHsKICAgICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQpyZWdpc3RlclByb2Nlc3NvcignY3J1c2gtcHJvY2Vzc29yJywgQ3J1c2hQcm9jZXNzb3IpOwoKY2xhc3MgU2hhcGVQcm9jZXNzb3IgZXh0ZW5kcyBBdWRpb1dvcmtsZXRQcm9jZXNzb3IgewogIHN0YXRpYyBnZXQgcGFyYW1ldGVyRGVzY3JpcHRvcnMoKSB7CiAgICByZXR1cm4gW3sgbmFtZTogJ3NoYXBlJywgZGVmYXVsdFZhbHVlOiAwIH1dOwogIH0KCiAgY29uc3RydWN0b3IoKSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5ub3RTdGFydGVkID0gdHJ1ZTsKICB9CgogIHByb2Nlc3MoaW5wdXRzLCBvdXRwdXRzLCBwYXJhbWV0ZXJzKSB7CiAgICBjb25zdCBpbnB1dCA9IGlucHV0c1swXTsKICAgIGNvbnN0IG91dHB1dCA9IG91dHB1dHNbMF07CiAgICBjb25zdCBzaGFwZTAgPSBwYXJhbWV0ZXJzLnNoYXBlWzBdOwogICAgY29uc3Qgc2hhcGUxID0gc2hhcGUwIDwgMSA/IHNoYXBlMCA6IDEuMCAtIDRlLTEwOwogICAgY29uc3Qgc2hhcGUgPSAoMi4wICogc2hhcGUxKSAvICgxLjAgLSBzaGFwZTEpOwogICAgY29uc3QgYmxvY2tTaXplID0gMTI4OwogICAgY29uc3QgaGFzSW5wdXQgPSAhKGlucHV0WzBdID09PSB1bmRlZmluZWQpOwogICAgaWYgKGhhc0lucHV0KSB7CiAgICAgIHRoaXMubm90U3RhcnRlZCA9IGZhbHNlOwogICAgICBmb3IgKGxldCBuID0gMDsgbiA8IGJsb2NrU2l6ZTsgbisrKSB7CiAgICAgICAgY29uc3QgdmFsdWUgPSAoKDEgKyBzaGFwZSkgKiBpbnB1dFswXVtuXSkgLyAoMSArIHNoYXBlICogTWF0aC5hYnMoaW5wdXRbMF1bbl0pKTsKICAgICAgICBmb3IgKGxldCBvID0gMDsgbyA8IG91dHB1dC5sZW5ndGg7IG8rKykgewogICAgICAgICAgb3V0cHV0W29dW25dID0gdmFsdWU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5ub3RTdGFydGVkIHx8IGhhc0lucHV0OwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoJ3NoYXBlLXByb2Nlc3NvcicsIFNoYXBlUHJvY2Vzc29yKTsK",{Pattern}=strudel;let audioContext;const getAudioContext$1=()=>(audioContext||(audioContext=new AudioContext),audioContext);let destination;const getDestination=()=>{const r=getAudioContext$1();return destination||(destination=r.createGain(),destination.connect(r.destination)),destination},panic=()=>{getDestination().gain.linearRampToValueAtTime(0,getAudioContext$1().currentTime+.01),destination=null},getFilter=(r,t,e)=>{const o=getAudioContext$1().createBiquadFilter();return o.type=r,o.frequency.value=t,o.Q.value=e,o},getADSR=(r,t,e,o,s,i,f)=>{const l=getAudioContext$1().createGain();return l.gain.setValueAtTime(0,i),l.gain.linearRampToValueAtTime(s,i+r),l.gain.linearRampToValueAtTime(e*s,i+r+t),l.gain.setValueAtTime(e*s,f),l.gain.linearRampToValueAtTime(0,f+o),l},getOscillator=({s:r,freq:t,t:e,duration:o,release:s})=>{const i=getAudioContext$1().createOscillator();return i.type=r||"triangle",i.frequency.value=Number(t),i.start(e),i.stop(e+o+s),i},getSoundfontKey=r=>{var o,s,i,f;if(!globalThis.soundfontList)return!1;if((s=(o=globalThis.soundfontList)==null?void 0:o.instruments)!=null&&s.includes(r))return r;const t=(f=(i=globalThis.soundfontList)==null?void 0:i.instrumentNames)==null?void 0:f.indexOf(r),e=t<10?`00${t}`:t<100?`0${t}`:t;if(t!==-1)return globalThis.soundfontList.instruments.find(l=>l.startsWith(e))},getSampleBufferSource=async(r,t,e,o)=>{let s=0,i=typeof e=="string"?toMidi(e):e||36;s=i-36;const f=getAudioContext$1(),l=getLoadedSamples();if(!l)throw new Error("no samples loaded");const g=l==null?void 0:l[r];if(!g)throw new Error(`sample not found: "${r}", try one of ${Object.keys(l).map(C=>`"${C}"`).join(", ")}.`);if(typeof g!="object")throw new Error("wrong format for sample bank:",r);let w;if(Array.isArray(g))w=g[t%g.length];else{const C=d=>toMidi(d)-i,p=Object.keys(g).filter(d=>!d.startsWith("_")).reduce((d,m,b)=>!d||Math.abs(C(m)){if(!r.includes(":"))return[r,t];let[e,o]=r.split(":");return isNaN(Number(o))?[r,t]:[e,o]};let workletsLoading;function loadWorklets(){return workletsLoading||(workletsLoading=getAudioContext$1().audioWorklet.addModule(workletsUrl),workletsLoading)}function getWorklet(r,t,e){const o=new AudioWorkletNode(r,t);return Object.entries(e).forEach(([s,i])=>{o.parameters.get(s).value=i}),o}if(typeof window<"u")try{loadWorklets()}catch(r){console.warn("could not load AudioWorklet effects coarse, crush and shape",r)}function gainNode(r){const t=getAudioContext$1().createGain();return t.gain.value=r,t}const cutGroups=[];let delays={};function getDelay(r,t,e,o){if(!delays[r]){const i=getAudioContext$1().createFeedbackDelay(1,t,e);i.start(o),i.connect(getDestination()),delays[r]=i}return delays[r].delayTime.value!==t&&delays[r].delayTime.setValueAtTime(t,o),delays[r].feedback.value!==e&&delays[r].feedback.setValueAtTime(e,o),delays[r]}let reverbs={};function getReverb(r,t=2){if(!reverbs[r]){const o=getAudioContext$1().createReverb(t);o.connect(getDestination()),reverbs[r]=o}return reverbs[r].duration!==t&&(reverbs[r]=reverbs[r].setDuration(t),reverbs[r].duration=t),reverbs[r]}function effectSend(r,t,e){const o=gainNode(e);return r.connect(o),o.connect(t),o}const webaudioOutput=async(r,t,e)=>{var o;try{const s=getAudioContext$1();if(typeof r.value!="object")throw new Error(`hap.value ${r.value} is not supported by webaudio output. Hint: append .note() or .s() to the end`);let i=s.currentTime+t,{freq:f,s:l,bank:g,sf:w,clip:y=0,n:$=0,note:S,gain:C=.8,cutoff:p,resonance:d=1,hcutoff:m,hresonance:b=1,bandf:I,bandq:T=1,coarse:G,crush:Y,shape:D,pan:W,speed:P=1,begin:B=0,end:z=1,vowel:O,delay:Z=0,delayfeedback:L=.5,delaytime:fe=.25,unit:we,nudge:be=0,cut:te,loop:le,orbit:pe=1,room:he,size:ve=2,roomsize:de=ve}=r.value;const{velocity:$e=1}=r.context;C*=$e;const F=[];if(g&&l&&(l=`${g}_${l}`),typeof l=="string"&&([l,$]=splitSN(l,$)),typeof S=="string"&&([S,$]=splitSN(S,$)),!l||["sine","square","triangle","sawtooth"].includes(l)){const{attack:M=.001,decay:U=.05,sustain:ye=.6,release:J=.01}=r.value;$=S||$||36,typeof $=="string"&&($=toMidi($)),!f&&typeof $=="number"&&(f=fromMidi($));const ee=getOscillator({t:i,s:l,freq:f,duration:e,release:J});F.push(ee),F.push(gainNode(.3));const R=getADSR(M,U,ye,J,1,i,i+e);F.push(R)}else{const{attack:M=.001,decay:U=.001,sustain:ye=1,release:J=.001}=r.value;if(P===0)return;if(!l){console.warn("no sample specified");return}const ee=getSoundfontKey(l);let R;try{ee?R=await globalThis.getFontBufferSource(ee,S||$,s):R=await getSampleBufferSource(l,$,S,P)}catch(Be){console.warn(Be);return}if(s.currentTime>i){console.warn("sample still loading:",l,$);return}if(!R){console.warn("no buffer source");return}R.playbackRate.value=Math.abs(P)*R.playbackRate.value,we==="c"&&(R.playbackRate.value=R.playbackRate.value*R.buffer.duration);let X=ee||y?e:R.buffer.duration/R.playbackRate.value;const re=B*X*R.playbackRate.value;X=(z-B)*X,le&&(R.loop=!0,R.loopStart=re,R.loopEnd=re+X,X=le*X),i+=be,R.start(i,re),te!==void 0&&((o=cutGroups[te])==null||o.stop(i),cutGroups[te]=R),F.push(R),R.stop(i+X+J);const Pe=getADSR(M,U,ye,J,1,i,i+X);F.push(Pe)}if(F.push(gainNode(C)),p!==void 0&&F.push(getFilter("lowpass",p,d)),m!==void 0&&F.push(getFilter("highpass",m,b)),I!==void 0&&F.push(getFilter("bandpass",I,T)),O!==void 0&&F.push(s.createVowelFilter(O)),G!==void 0&&F.push(getWorklet(s,"coarse-processor",{coarse:G})),Y!==void 0&&F.push(getWorklet(s,"crush-processor",{crush:Y})),D!==void 0&&F.push(getWorklet(s,"shape-processor",{shape:D})),W!==void 0){const M=s.createStereoPanner();M.pan.value=2*W-1,F.push(M)}const Q=gainNode(1);F.push(Q),Q.connect(getDestination());let ge;if(Z>0&&fe>0&&L>0){const M=getDelay(pe,fe,L,i);ge=effectSend(Q,M,Z)}let me;if(he>0&&de>0){const M=getReverb(pe,de);me=effectSend(Q,M,he)}F.slice(1).reduce((M,U)=>M.connect(U),F[0]),F[0].onended=()=>F.concat([ge,me]).forEach(M=>M==null?void 0:M.disconnect())}catch(s){console.warn(".out error:",s)}},webaudioOutputTrigger=(r,t,e,o)=>webaudioOutput(t,r-e,t.duration/o);Pattern.prototype.out=function(){return this.onTrigger(webaudioOutputTrigger)};const tune=`stack( + n("c3 [eb3,g3]") + .delay("<0 .5>") + .delaytime(".16 | .33") + .delayfeedback(".6 | .8") +).sometimes(x=>x.speed("-1"))`,ctx=getAudioContext$1(),input=document.getElementById("text");input.innerHTML=tune;evalScope(controls,__vitePreload(()=>Promise.resolve().then(()=>strudel),void 0),__vitePreload(()=>import("./index.211bbc68.js"),[]),__vitePreload(()=>import("./index.ecddf978.js"),[]),__vitePreload(()=>import("./index.63aa02b5.js"),[]));setStringParser(mini);const{evaluate}=repl({defaultOutput:webaudioOutput,getTime:()=>ctx.currentTime});document.getElementById("start").addEventListener("click",()=>{ctx.resume(),evaluate(input.value)});export{Hap as H,Pattern$3 as P,minify as a,peg$SyntaxError as b,peg$parse as c,panic as d,webaudioOutputTrigger as e,getCachedBuffer as f,getAudioContext$1 as g,h,getLoadedBuffer as i,loadGithubSamples as j,resetLoadedSamples as k,loadBuffer as l,mini as m,getLoadedSamples$1 as n,mod as o,patternifyAST as p,getAugmentedNamespace as q,reverseBuffer as r,samples as s,commonjsGlobal as t,getDefaultExportFromCjs as u,reify$2 as v,webaudioOutput as w,stack$1 as x}; diff --git a/packages/core/examples/vite-vanilla-repl/dist/assets/index.8b8c94a0.js b/packages/core/examples/vite-vanilla-repl/dist/assets/index.63aa02b5.js similarity index 99% rename from packages/core/examples/vite-vanilla-repl/dist/assets/index.8b8c94a0.js rename to packages/core/examples/vite-vanilla-repl/dist/assets/index.63aa02b5.js index 91f92a1d..dfde3ae1 100644 --- a/packages/core/examples/vite-vanilla-repl/dist/assets/index.8b8c94a0.js +++ b/packages/core/examples/vite-vanilla-repl/dist/assets/index.63aa02b5.js @@ -1 +1 @@ -import{P as _,o as Lt,q as Ut,t as Y,u as Xt,v as Kt,H as Qt,x as Yt}from"./index.73313bf6.js";const C=(n,t)=>Array(Math.abs(t)+1).join(n);function g(n,t,e){return function(...o){return console.warn(`${n} is deprecated. Use ${t}.`),e.apply(this,o)}}function z(n){return n!==null&&typeof n=="object"&&typeof n.name=="string"}function q(n){return n!==null&&typeof n=="object"&&typeof n.step=="number"&&typeof n.alt=="number"}const Qn=[0,2,4,-1,1,3,5],Yn=Qn.map(n=>Math.floor(n*7/12));function en(n){const{step:t,alt:e,oct:o,dir:r=1}=n,i=Qn[t]+7*e;if(o===void 0)return[r*i];const a=o-Yn[t]-4*e;return[r*i,r*a]}const Zt=[3,0,4,1,5,2,6];function on(n){const[t,e,o]=n,r=Zt[Jt(t)],i=Math.floor((t+1)/7);if(e===void 0)return{step:r,alt:i,dir:o};const a=e+4*i+Yn[r];return{step:r,alt:i,oct:a,dir:o}}function Jt(n){const t=(n+1)%7;return t<0?7+t:t}const Zn={empty:!0,name:"",pc:"",acc:""},Dn=new Map,vn=n=>"CDEFGAB".charAt(n),E=n=>n<0?C("b",-n):C("#",n),G=n=>n[0]==="b"?-n.length:n.length;function m(n){const t=Dn.get(n);if(t)return t;const e=typeof n=="string"?te(n):q(n)?m(ee(n)):z(n)?m(n.name):Zn;return Dn.set(n,e),e}const Wt=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function rn(n){const t=Wt.exec(n);return[t[1].toUpperCase(),t[2].replace(/x/g,"##"),t[3],t[4]]}function F(n){return m(on(n))}const ne=(n,t)=>(n%t+t)%t,pn=[0,2,4,5,7,9,11];function te(n){const t=rn(n);if(t[0]===""||t[3]!=="")return Zn;const e=t[0],o=t[1],r=t[2],i=(e.charCodeAt(0)+3)%7,a=G(o),s=r.length?+r:void 0,c=en({step:i,alt:a,oct:s}),l=e+o+r,u=e+o,d=(pn[i]+a+120)%12,M=s===void 0?ne(pn[i]+a,12)-12*99:pn[i]+a+12*(s+1),h=M>=0&&M<=127?M:null,A=s===void 0?null:Math.pow(2,(M-69)/12)*440;return{empty:!1,acc:o,alt:a,chroma:d,coord:c,freq:A,height:M,letter:e,midi:h,name:l,oct:s,pc:u,step:i}}function ee(n){const{step:t,alt:e,oct:o}=n,r=vn(t);if(!r)return"";const i=r+E(e);return o||o===0?i+o:i}const yn={empty:!0,name:"",acc:""},oe="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",re="(AA|A|P|M|m|d|dd)([-+]?\\d+)",ie=new RegExp("^"+oe+"|"+re+"$");function $n(n){const t=ie.exec(`${n}`);return t===null?["",""]:t[1]?[t[1],t[2]]:[t[4],t[3]]}const Rn={};function f(n){return typeof n=="string"?Rn[n]||(Rn[n]=ae(n)):q(n)?f(ce(n)):z(n)?f(n.name):yn}const kn=[0,2,4,5,7,9,11],Jn="PMMPPMM";function ae(n){const t=$n(n);if(t[0]==="")return yn;const e=+t[0],o=t[1],r=(Math.abs(e)-1)%7,i=Jn[r];if(i==="M"&&o==="P")return yn;const a=i==="M"?"majorable":"perfectable",s=""+e+o,c=e<0?-1:1,l=e===8||e===-8?e:c*(r+1),u=se(a,o),d=Math.floor((Math.abs(e)-1)/7),M=c*(kn[r]+u+12*d),h=(c*(kn[r]+u)%12+12)%12,A=en({step:r,alt:u,oct:d,dir:c});return{empty:!1,name:s,num:e,q:o,step:r,alt:u,dir:c,type:a,simple:l,semitones:M,chroma:h,coord:A,oct:d}}function B(n,t){const[e,o=0]=n,r=e*7+o*12<0,i=t||r?[-e,-o,-1]:[e,o,1];return f(on(i))}function se(n,t){return t==="M"&&n==="majorable"||t==="P"&&n==="perfectable"?0:t==="m"&&n==="majorable"?-1:/^A+$/.test(t)?t.length:/^d+$/.test(t)?-1*(n==="perfectable"?t.length:t.length+1):0}function ce(n){const{step:t,alt:e,oct:o=0,dir:r}=n;if(!r)return"";const i=t+1+7*o,a=i===0?t+1:i,s=r<0?"-":"",c=Jn[t]==="M"?"majorable":"perfectable";return s+a+me(c,e)}function me(n,t){return t===0?n==="majorable"?"M":"P":t===-1&&n==="majorable"?"m":t>0?C("A",t):C("d",n==="perfectable"?t:t+1)}function P(n,t){const e=m(n),o=f(t);if(e.empty||o.empty)return"";const r=e.coord,i=o.coord,a=r.length===1?[r[0]+i[0]]:[r[0]+i[0],r[1]+i[1]];return F(a).name}function D(n,t){const e=m(n),o=m(t);if(e.empty||o.empty)return"";const r=e.coord,i=o.coord,a=i[0]-r[0],s=r.length===2&&i.length===2?i[1]-r[1]:-Math.floor(a*7/12),c=o.height===e.height&&o.midi!==null&&e.midi!==null&&e.step>o.step;return B([a,s],c).name}const Wn=Object.freeze(Object.defineProperty({__proto__:null,accToAlt:G,altToAcc:E,coordToInterval:B,coordToNote:F,decode:on,deprecate:g,distance:D,encode:en,fillStr:C,interval:f,isNamed:z,isPitch:q,note:m,stepToLetter:vn,tokenizeInterval:$n,tokenizeNote:rn,transpose:P},Symbol.toStringTag,{value:"Module"})),On=(n,t)=>Array(t+1).join(n),ue=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function nt(n){const t=ue.exec(n);return t?[t[1],t[2],t[3]]:["","",""]}function W(n){const[t,e,o]=nt(n);if(e==="")return"";let r=4;for(let a=0;a96?e.toUpperCase()+i+(r+1):e+i+r}function tt(n){const t=m(n);if(t.empty||!t.oct&&t.oct!==0)return"";const{letter:e,acc:o,oct:r}=t,i=o[0]==="b"?o.replace(/b/g,"_"):o.replace(/#/g,"^"),a=r>4?e.toLowerCase():e,s=r===5?"":r>4?On("'",r-5):On(",",4-r);return i+a+s}function le(n,t){return tt(P(W(n),t))}function de(n,t){return D(W(n),W(t))}var Me={abcToScientificNotation:W,scientificToAbcNotation:tt,tokenize:nt,transpose:le,distance:de};function fe(n,t){const e=[];for(;t--;e[t]=t+n);return e}function Pe(n,t){const e=[];for(;t--;e[t]=n-t);return e}function pe(n,t){return nt===0||t)}function et(n){return n.map(e=>m(e)).filter(e=>!e.empty).sort((e,o)=>e.height-o.height).map(e=>e.name)}function ge(n){return et(n).filter((t,e,o)=>e===0||t!==o[e-1])}function be(n,t=Math.random){let e,o,r=n.length;for(;r;)e=Math.floor(t()*r--),o=n[r],n[r]=n[e],n[e]=o;return n}function ot(n){return n.length===0?[[]]:ot(n.slice(1)).reduce((t,e)=>t.concat(n.map((o,r)=>{const i=e.slice();return i.splice(r,0,n[0]),i})),[])}const Ae=Object.freeze(Object.defineProperty({__proto__:null,compact:ye,permutations:ot,range:pe,rotate:he,shuffle:be,sortedNoteNames:et,sortedUniqNoteNames:ge},Symbol.toStringTag,{value:"Module"}));function ve(n,t){const e=[];for(;t--;e[t]=t+n);return e}function $e(n,t){const e=[];for(;t--;e[t]=n-t);return e}function an(n,t){return nt===0||t)}function Ne(n,t=Math.random){let e,o,r=n.length;for(;r;)e=Math.floor(t()*r--),o=n[r],n[r]=n[e],n[e]=o;return n}function rt(n){return n.length===0?[[]]:rt(n.slice(1)).reduce((t,e)=>t.concat(n.map((o,r)=>{const i=e.slice();return i.splice(r,0,n[0]),i})),[])}var Ie={compact:Nn,permutations:rt,range:an,rotate:H,shuffle:Ne};const T={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},In=n=>Number(n).toString(2),Fn=n=>parseInt(n,2),je=/^[01]{12}$/;function it(n){return je.test(n)}const Se=n=>typeof n=="number"&&n>=0&&n<=4095,Te=n=>n&&it(n.chroma),zn={[T.chroma]:T};function p(n){const t=it(n)?n:Se(n)?In(n):Array.isArray(n)?ze(n):Te(n)?n.chroma:T.chroma;return zn[t]=zn[t]||Fe(t)}const Ve=g("Pcset.pcset","Pcset.get",p),_e=n=>p(n).chroma,Ce=n=>p(n).intervals,we=n=>p(n).setNum,xe=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Ee(n){const t=[];for(let e=0;e<12;e++)n.charAt(e)==="1"&&t.push(xe[e]);return t}function De(){return an(2048,4095).map(In)}function jn(n,t=!0){const o=p(n).chroma.split("");return Nn(o.map((r,i)=>{const a=H(i,o);return t&&a[0]==="0"?null:a.join("")}))}function Re(n,t){return p(n).setNum===p(t).setNum}function sn(n){const t=p(n).setNum;return e=>{const o=p(e).setNum;return t&&t!==o&&(o&t)===o}}function cn(n){const t=p(n).setNum;return e=>{const o=p(e).setNum;return t&&t!==o&&(o|t)===o}}function at(n){const t=p(n);return e=>{const o=m(e);return t&&!o.empty&&t.chroma.charAt(o.chroma)==="1"}}function ke(n){const t=at(n);return e=>e.filter(t)}var st={get:p,chroma:_e,num:we,intervals:Ce,chromas:De,isSupersetOf:cn,isSubsetOf:sn,isNoteIncludedIn:at,isEqual:Re,filter:ke,modes:jn,pcset:Ve};function Oe(n){const t=n.split("");return t.map((e,o)=>H(o,t).join(""))}function Fe(n){const t=Fn(n),e=Oe(n).map(Fn).filter(i=>i>=2048).sort()[0],o=In(e),r=Ee(n);return{empty:!1,name:"",setNum:t,chroma:n,normalized:o,intervals:r}}function ze(n){if(n.length===0)return T.chroma;let t;const e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let o=0;on.name).filter(n=>n)}function Le(){return R.map(n=>n.aliases[0]).filter(n=>n)}function Ue(){return Object.keys(j)}function k(){return R.slice()}const Xe=g("ChordType.entries","ChordType.all",k);function Ke(){R=[],j={}}function ct(n,t,e){const o=Ye(n),r={...p(n),name:e||"",quality:o,intervals:n,aliases:t};R.push(r),r.name&&(j[r.name]=r),j[r.setNum]=r,j[r.chroma]=r,r.aliases.forEach(i=>Qe(r,i))}function Qe(n,t){j[t]=n}function Ye(n){const t=e=>n.indexOf(e)!==-1;return t("5A")?"Augmented":t("3M")?"Major":t("5d")?"Diminished":t("3m")?"Minor":"Unknown"}qe.forEach(([n,t,e])=>ct(n.split(" "),e.split(" "),t));R.sort((n,t)=>n.setNum-t.setNum);var mt={names:He,symbols:Le,get:Sn,all:k,add:ct,removeAll:Ke,keys:Ue,entries:Xe,chordType:Be};const Ze=n=>{const t=n.reduce((e,o)=>{const r=m(o).chroma;return r!==void 0&&(e[r]=e[r]||m(o).name),e},{});return e=>t[e]};function Je(n){const t=n.map(o=>m(o).pc).filter(o=>o);return m.length===0?[]:We(t,1).filter(o=>o.weight).sort((o,r)=>r.weight-o.weight).map(o=>o.name)}function We(n,t){const e=n[0],o=m(e).chroma,r=Ze(n),i=jn(n,!1),a=[];return i.forEach((s,c)=>{k().filter(u=>u.chroma===s).forEach(u=>{const d=u.aliases[0],M=r(c);c!==o?a.push({weight:.5*t,name:`${M}${d}/${e}`}):a.push({weight:1*t,name:`${M}${d}`})})}),a}const no=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neopolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5P pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7M pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neopolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 7m","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neopolitan major"],["1P 2M 3m 4P 5P 6m 7m","aeolian","minor"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],to={...T,intervals:[],aliases:[]};let mn=[],S={};function ut(){return mn.map(n=>n.name)}function un(n){return S[n]||to}const eo=g("ScaleDictionary.scaleType","ScaleType.get",un);function L(){return mn.slice()}const oo=g("ScaleDictionary.entries","ScaleType.all",L);function ro(){return Object.keys(S)}function io(){mn=[],S={}}function lt(n,t,e=[]){const o={...p(n),name:t,intervals:n,aliases:e};return mn.push(o),S[o.name]=o,S[o.setNum]=o,S[o.chroma]=o,o.aliases.forEach(r=>ao(o,r)),o}function ao(n,t){S[t]=n}no.forEach(([n,t,...e])=>lt(n.split(" "),t,e));var dt={names:ut,get:un,all:L,add:lt,removeAll:io,keys:ro,entries:oo,scaleType:eo};const gn={empty:!0,name:"",symbol:"",root:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]},so=/^(6|64|7|9|11|13)$/;function ln(n){const[t,e,o,r]=rn(n);return t===""?["",n]:t==="A"&&r==="ug"?["","aug"]:!r&&(o==="4"||o==="5")?[t+e,o]:so.test(o)?[t+e,o+r]:[t+e+o,r]}function U(n){if(n==="")return gn;if(Array.isArray(n)&&n.length===2)return Z(n[1],n[0]);{const[t,e]=ln(n),o=Z(e,t);return o.empty?Z(n):o}}function Z(n,t,e){const o=Sn(n),r=m(t||""),i=m(e||"");if(o.empty||t&&r.empty||e&&i.empty)return gn;const a=D(r.pc,i.pc),s=o.intervals.indexOf(a)+1;if(!i.empty&&!s)return gn;const c=Array.from(o.intervals);for(let M=1;MP(r,M));n=o.aliases.indexOf(n)!==-1?n:o.aliases[0];const u=`${r.empty?"":r.pc}${n}${i.empty||s<=1?"":"/"+i.pc}`,d=`${t?r.pc+" ":""}${o.name}${s>1&&e?" over "+i.pc:""}`;return{...o,name:d,symbol:u,type:o.name,root:i.name,intervals:c,rootDegree:s,tonic:r.name,notes:l}}const co=g("Chord.chord","Chord.get",U);function mo(n,t){const[e,o]=ln(n);return e?P(e,t)+o:n}function uo(n){const t=U(n),e=cn(t.chroma);return L().filter(o=>e(o.chroma)).map(o=>o.name)}function lo(n){const t=U(n),e=cn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>t.tonic+o.aliases[0])}function Mo(n){const t=U(n),e=sn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>t.tonic+o.aliases[0])}var fo={getChord:Z,get:U,detect:Je,chordScales:uo,extended:lo,reduced:Mo,tokenize:ln,transpose:mo,chord:co};const Po=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],dn=[];Po.forEach(([n,t,e])=>$o(n,t,e));const po={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function ho(){return dn.reduce((n,t)=>(t.names.forEach(e=>n.push(e)),n),[])}function yo(){return dn.map(n=>n.shorthand)}const go=/^([^.]+)(\.*)$/;function Tn(n){const[t,e,o]=go.exec(n)||[],r=dn.find(s=>s.shorthand===e||s.names.includes(e));if(!r)return po;const i=No(r.fraction,o.length),a=i[0]/i[1];return{...r,name:n,dots:o,value:a,fraction:i}}const bo=n=>Tn(n).value,Ao=n=>Tn(n).fraction;var vo={names:ho,shorthands:yo,get:Tn,value:bo,fraction:Ao};function $o(n,t,e){dn.push({empty:!1,dots:"",name:"",value:1/n,fraction:n<1?[1/n,1]:[1,n],shorthand:t,names:e})}function No(n,t){const e=Math.pow(2,t);let o=n[0]*e,r=n[1]*e;const i=o;for(let a=0;af(n).name,So=n=>f(n).semitones,To=n=>f(n).q,Vo=n=>f(n).num;function ft(n){const t=f(n);return t.empty?"":t.simple+t.q}function _o(n){const t=f(n);if(t.empty)return"";const e=(7-t.step)%7,o=t.type==="perfectable"?-t.alt:-(t.alt+1);return f({step:e,alt:o,oct:t.oct,dir:t.dir}).name}const Co=[1,2,2,3,3,4,5,5,6,6,7,7],wo="P m M m M P d P m M m M".split(" ");function xo(n){const t=n<0?-1:1,e=Math.abs(n),o=e%12,r=Math.floor(e/12);return t*(Co[o]+7*r)+wo[o]}const Eo=D,Pt=ht((n,t)=>[n[0]+t[0],n[1]+t[1]]),Do=n=>t=>Pt(n,t),Ro=ht((n,t)=>[n[0]-t[0],n[1]-t[1]]);function pt(n,t){const e=Mt(n);if(e.empty)return"";const[o,r,i]=e.coord;return B([o+t,r,i]).name}var bn={names:Io,get:Mt,name:jo,num:Vo,semitones:So,quality:To,fromSemitones:xo,distance:Eo,invert:_o,simplify:ft,add:Pt,addTo:Do,substract:Ro,transposeFifths:pt};function ht(n){return(t,e)=>{const o=f(t).coord,r=f(e).coord;if(o&&r){const i=n(o,r);return B(i).name}}}function yt(n){return+n>=0&&+n<=127}function gt(n){if(yt(n))return+n;const t=m(n);return t.empty?null:t.midi}function ko(n,t=440){return Math.pow(2,(n-69)/12)*t}const Oo=Math.log(2),Fo=Math.log(440);function Vn(n){const t=12*(Math.log(n)-Fo)/Oo+69;return Math.round(t*100)/100}const zo="C C# D D# E F F# G G# A A# B".split(" "),qo="C Db D Eb E F Gb G Ab A Bb B".split(" ");function I(n,t={}){if(isNaN(n)||n===-1/0||n===1/0)return"";n=Math.round(n);const o=(t.sharps===!0?zo:qo)[n%12];if(t.pitchClass)return o;const r=Math.floor(n/12)-1;return o+r}var Go={isMidi:yt,toMidi:gt,midiToFreq:ko,midiToNoteName:I,freqToMidi:Vn};const Bo=["C","D","E","F","G","A","B"],bt=n=>n.name,At=n=>n.map(m).filter(t=>!t.empty);function Ho(n){return n===void 0?Bo.slice():Array.isArray(n)?At(n).map(bt):[]}const y=m,Lo=n=>y(n).name,Uo=n=>y(n).pc,Xo=n=>y(n).acc,Ko=n=>y(n).oct,Qo=n=>y(n).midi,Yo=n=>y(n).freq,Zo=n=>y(n).chroma;function vt(n){return I(n)}function Jo(n){return I(Vn(n))}function Wo(n){return I(Vn(n),{sharps:!0})}function nr(n){return I(n,{sharps:!0})}const _n=P,tr=P,$t=n=>t=>_n(t,n),er=$t,Nt=n=>t=>_n(n,t),or=Nt;function nn(n,t){const e=y(n);if(e.empty)return"";const[o,r]=e.coord;return F(r===void 0?[o+t]:[o+t,r]).name}const rr=nn,Cn=(n,t)=>n.height-t.height,ir=(n,t)=>t.height-n.height;function It(n,t){return t=t||Cn,At(n).sort(t).map(bt)}function jt(n){return It(n,Cn).filter((t,e,o)=>e===0||t!==o[e-1])}const ar=n=>{const t=y(n);return t.empty?"":I(t.midi||t.chroma,{sharps:t.alt>0,pitchClass:t.midi===null})};function St(n,t){const e=y(n);if(e.empty)return"";const o=y(t||I(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(o.empty||o.chroma!==e.chroma)return"";if(e.oct===void 0)return o.pc;const r=e.chroma-e.alt,i=o.chroma-o.alt,a=r>11||i<0?-1:r<0||i>11?1:0,s=e.oct+a;return o.pc+s}var w={names:Ho,get:y,name:Lo,pitchClass:Uo,accidentals:Xo,octave:Ko,midi:Qo,ascending:Cn,descending:ir,sortedNames:It,sortedUniqNames:jt,fromMidi:vt,fromMidiSharps:nr,freq:Yo,fromFreq:Jo,fromFreqSharps:Wo,chroma:Zo,transpose:_n,tr,transposeBy:$t,trBy:er,transposeFrom:Nt,trFrom:or,transposeFifths:nn,trFifths:rr,simplify:ar,enharmonic:St};const Tt={empty:!0,name:"",chordType:""},qn={};function $(n){return typeof n=="string"?qn[n]||(qn[n]=Mr(n)):typeof n=="number"?$(Mn[n]||""):q(n)?mr(n):z(n)?$(n.name):Tt}const sr=g("RomanNumeral.romanNumeral","RomanNumeral.get",$);function cr(n=!0){return(n?Mn:dr).slice()}function mr(n){return $(E(n.alt)+Mn[n.step])}const ur=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function lr(n){return ur.exec(n)||["","","",""]}const Vt="I II III IV V VI VII",Mn=Vt.split(" "),dr=Vt.toLowerCase().split(" ");function Mr(n){const[t,e,o,r]=lr(n);if(!o)return Tt;const i=o.toUpperCase(),a=Mn.indexOf(i),s=G(e),c=1;return{empty:!1,name:t,roman:o,interval:f({step:a,alt:s,dir:c}).name,acc:e,chordType:r,alt:s,step:a,major:o===i,oct:0,dir:c}}var fr={names:cr,get:$,romanNumeral:sr};const b=Object.freeze([]),_t={type:"major",tonic:"",alteration:0,keySignature:""},J={tonic:"",grades:b,intervals:b,scale:b,chords:b,chordsHarmonicFunction:b,chordScales:b},Pr={..._t,...J,type:"major",minorRelative:"",scale:b,secondaryDominants:b,secondaryDominantsMinorRelative:b,substituteDominants:b,substituteDominantsMinorRelative:b},pr={..._t,type:"minor",relativeMajor:"",natural:J,harmonic:J,melodic:J},Gn=(n,t,e="")=>t.map((o,r)=>`${n[r]}${e}${o}`);function fn(n,t,e,o){return r=>{const i=n.map(s=>$(s).interval||""),a=i.map(s=>P(r,s));return{tonic:r,grades:n,intervals:i,scale:a,chords:Gn(a,t),chordsHarmonicFunction:e.slice(),chordScales:Gn(a,o," ")}}}const Ct=(n,t)=>{const e=m(n),o=m(t);return e.empty||o.empty?0:o.coord[0]-e.coord[0]},hr=fn("I II III IV V VI VII".split(" "),"maj7 m7 m7 maj7 7 m7 m7b5".split(" "),"T SD T SD D T D".split(" "),"major,dorian,phrygian,lydian,mixolydian,minor,locrian".split(",")),yr=fn("I II bIII IV V bVI bVII".split(" "),"m7 m7b5 maj7 m7 m7 maj7 7".split(" "),"T SD T SD D SD SD".split(" "),"minor,locrian,major,dorian,phrygian,lydian,mixolydian".split(",")),gr=fn("I II bIII IV V bVI VII".split(" "),"mMaj7 m7b5 +maj7 m7 7 maj7 o7".split(" "),"T SD T SD D SD D".split(" "),"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian".split(",")),br=fn("I II bIII IV V VI VII".split(" "),"m6 m7 +maj7 7 7 m7b5 m7b5".split(" "),"T SD T SD D ".split(" "),"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered".split(","));function Ar(n){const t=m(n).pc;if(!t)return Pr;const e=hr(t),o=Ct("C",t),r=i=>{const a=$(i);return a.empty?"":P(n,a.interval)+a.chordType};return{...e,type:"major",minorRelative:P(t,"-3m"),alteration:o,keySignature:E(o),secondaryDominants:"- VI7 VII7 I7 II7 III7 -".split(" ").map(r),secondaryDominantsMinorRelative:"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -".split(" ").map(r),substituteDominants:"- bIII7 IV7 bV7 bVI7 bVII7 -".split(" ").map(r),substituteDominantsMinorRelative:"- IIIm7 Im7 IIbm7 VIm7 IVm7 -".split(" ").map(r)}}function vr(n){const t=m(n).pc;if(!t)return pr;const e=Ct("C",t)-3;return{type:"minor",tonic:t,relativeMajor:P(t,"3m"),alteration:e,keySignature:E(e),natural:yr(t),harmonic:gr(t),melodic:br(t)}}function $r(n){return typeof n=="number"?nn("C",n):typeof n=="string"&&/^b+|#+$/.test(n)?nn("C",G(n)):null}var Nr={majorKey:Ar,majorTonicFromKeySignature:$r,minorKey:vr};const wn=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],Bn={...T,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},xn=wn.map(Tr),An={};xn.forEach(n=>{An[n.name]=n,n.aliases.forEach(t=>{An[t]=n})});function V(n){return typeof n=="string"?An[n.toLowerCase()]||Bn:n&&n.name?V(n.name):Bn}const Ir=g("Mode.mode","Mode.get",V);function wt(){return xn.slice()}const jr=g("Mode.mode","Mode.all",wt);function Sr(){return xn.map(n=>n.name)}function Tr(n){const[t,e,o,r,i,a,s]=n,c=s?[s]:[],l=Number(e).toString(2);return{empty:!1,intervals:un(r).intervals,modeNum:t,chroma:l,normalized:l,name:r,setNum:e,alt:o,triad:i,seventh:a,aliases:c}}function Vr(n,t){return V(n).intervals.map(e=>P(t,e))}function xt(n){return(t,e)=>{const o=V(t);if(o.empty)return[];const r=H(o.modeNum,n),i=o.intervals.map(a=>P(e,a));return r.map((a,s)=>i[s]+a)}}const _r=xt(wn.map(n=>n[4])),Cr=xt(wn.map(n=>n[5]));function Et(n,t){const e=V(t),o=V(n);return e.empty||o.empty?"":ft(pt("1P",o.alt-e.alt))}function wr(n,t,e){return P(e,Et(n,t))}var xr={get:V,names:Sr,all:wt,distance:Et,relativeTonic:wr,notes:Vr,triads:_r,seventhChords:Cr,entries:jr,mode:Ir};function Er(n,t){return t.map($).map(o=>P(n,f(o))+o.chordType)}function Dr(n,t){return t.map(e=>{const[o,r]=ln(e),i=D(n,o);return $(f(i)).name+r})}var Rr={fromRomanNumerals:Er,toRomanNumerals:Dr};function Dt(n){const t=Nn(n.map(gt));return!n.length||t.length!==n.length?[]:t.reduce((e,o)=>{const r=e[e.length-1];return e.concat(an(r,o).slice(1))},[t[0]])}function kr(n,t){return Dt(n).map(e=>I(e,t))}var Or={numeric:Dt,chromatic:kr};const Fr={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function Rt(n){if(typeof n!="string")return["",""];const t=n.indexOf(" "),e=m(n.substring(0,t));if(e.empty){const r=m(n);return r.empty?["",n]:[r.name,""]}const o=n.substring(e.name.length+1);return[e.name,o.length?o:""]}const zr=ut;function N(n){const t=Array.isArray(n)?n:Rt(n),e=m(t[0]).name,o=un(t[1]);if(o.empty)return Fr;const r=o.name,i=e?o.intervals.map(s=>P(e,s)):[],a=e?e+" "+r:r;return{...o,name:a,type:r,tonic:e,notes:i}}const qr=g("Scale.scale","Scale.get",N);function Gr(n){const t=N(n),e=sn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>o.aliases[0])}function Br(n){const t=N(n),e=cn(t.chroma);return L().filter(o=>e(o.chroma)).map(o=>o.name)}function Hr(n){const t=sn(N(n).chroma);return L().filter(e=>t(e.chroma)).map(e=>e.name)}function kt(n){const t=n.map(r=>m(r).pc).filter(r=>r),e=t[0],o=jt(t);return H(o.indexOf(e),o)}function Lr(n){const t=N(n);if(t.empty)return[];const e=t.tonic?t.notes:t.intervals;return jn(t.chroma).map((o,r)=>{const i=N(o).name;return i?[e[r],i]:["",""]}).filter(o=>o[0])}function Ur(n){const t=Array.isArray(n)?kt(n):N(n).notes,e=t.map(o=>m(o).chroma);return o=>{const r=m(typeof o=="number"?vt(o):o),i=r.height;if(i===void 0)return;const a=i%12,s=e.indexOf(a);if(s!==-1)return St(r.name,t[s])}}function Xr(n){const t=Ur(n);return(e,o)=>{const r=m(e).height,i=m(o).height;return r===void 0||i===void 0?[]:an(r,i).map(t).filter(a=>a)}}var tn={get:N,names:zr,extended:Br,modeNames:Lr,reduced:Hr,scaleChords:Gr,scaleNotes:kt,tokenize:Rt,rangeOf:Xr,scale:qr};const Kr={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},Qr=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function Yr(){return Qr.slice()}const Zr=/^(\d?\d(?:\+\d)*)\/(\d)$/,Hn=new Map;function Jr(n){const t=Hn.get(n);if(t)return t;const e=ni(En(n));return Hn.set(n,e),e}function En(n){if(typeof n=="string"){const[i,a,s]=Zr.exec(n)||[];return En([a,s])}const[t,e]=n,o=+e;if(typeof t=="number")return[t,o];const r=t.split("+").map(i=>+i);return r.length===1?[r[0],o]:[r,o]}var Wr={names:Yr,parse:En,get:Jr};function ni([n,t]){const e=Array.isArray(n)?n.reduce((s,c)=>s+c,0):n,o=t;if(e===0||o===0)return Kr;const r=Array.isArray(n)?`${n.join("+")}/${t}`:`${n}/${t}`,i=Array.isArray(n)?n:[],a=o===4||o===2?"simple":o===8&&e%3===0?"compound":"irregular";return{empty:!1,name:r,type:a,upper:e,lower:o,additive:i}}const ti=Wn,ei=st,oi=mt,ri=dt,ii=Object.freeze(Object.defineProperty({__proto__:null,Array:Ae,Core:Wn,ChordDictionary:oi,PcSet:ei,ScaleDictionary:ri,Tonal:ti,AbcNotation:Me,Chord:fo,ChordType:mt,Collection:Ie,DurationValue:vo,Interval:bn,Key:Nr,Midi:Go,Mode:xr,Note:w,Pcset:st,Progression:Rr,Range:Or,RomanNumeral:fr,Scale:tn,ScaleType:dt,TimeSignature:Wr,accToAlt:G,altToAcc:E,coordToInterval:B,coordToNote:F,decode:on,deprecate:g,distance:D,encode:en,fillStr:C,interval:f,isNamed:z,isPitch:q,note:m,stepToLetter:vn,tokenizeInterval:$n,tokenizeNote:rn,transpose:P},Symbol.toStringTag,{value:"Module"}));function Ot(n,t,e){let[o,r]=tn.tokenize(n),{notes:i}=tn.get(`${o} ${r}`);if(i=i.map(h=>w.get(h).pc),t=Number(t),isNaN(t))throw new Error(`scale offset "${t}" not a number`);const{pc:a,oct:s=3}=w.get(e),c=i.indexOf(a);if(c===-1)throw new Error(`note "${e}" is not in scale "${n}"`);let l=c,u=s,d=a;const M=Math.sign(t);for(;Math.abs(l-c)0&&d[0]==="C"&&(u+=M)}return d+u}_.prototype._transpose=function(n){return this._withHap(t=>{const e=isNaN(Number(n))?String(n):bn.fromSemitones(n);if(typeof t.value=="number"){const o=typeof e=="string"?bn.semitones(e)||0:e;return t.withValue(()=>t.value+o)}return t.withValue(()=>w.simplify(w.transpose(t.value,e)))})};_.prototype._scaleTranspose=function(n){return this._withHap(t=>{if(!t.context.scale)throw new Error("can only use scaleTranspose after .scale");if(typeof t.value!="string")throw new Error("can only use scaleTranspose with notes");return t.withValue(()=>Ot(t.context.scale,Number(n),t.value))})};_.prototype._scale=function(n){return this._withHap(t=>{let e=t.value;const o=Number(e);if(!isNaN(o)){let[r,i]=tn.tokenize(n);const{pc:a,oct:s=3}=w.get(r);e=Ot(a+" "+i,o,a+s)}return t.withValue(()=>e).setContext({...t.context,scale:n})})};_.prototype.define("transpose",(n,t)=>t.transpose(n),{composable:!0,patternified:!0});_.prototype.define("scale",(n,t)=>t.scale(n),{composable:!0,patternified:!0});_.prototype.define("scaleTranspose",(n,t)=>t.scaleTranspose(n),{composable:!0,patternified:!0});var Ft={},hn={},X={};X.__esModule=!0;X.getBestVoicing=void 0;function ai(n){var t=n.chord,e=n.range,o=n.finder,r=n.picker,i=n.lastVoicing,a=o(t,e);return a.length?r(a,i):[]}X.getBestVoicing=ai;var O={};const zt=Ut(ii);var K={};K.__esModule=!0;K.tokenizeChord=void 0;function si(n){var t=(n||"").match(/^([A-G][b#]*)([^\/]*)[\/]?([A-G][b#]*)?$/);return t?t.slice(1):[]}K.tokenizeChord=si;var Ln;function ci(){if(Ln)return O;Ln=1,O.__esModule=!0,O.voicingsInRange=void 0;var n=zt,t=qt(),e=K;function o(r,i,a){i===void 0&&(i=t.lefthand),a===void 0&&(a=["D3","A4"]);var s=(0,e.tokenizeChord)(r),c=s[0],l=s[1];if(!i[l])return[];var u=i[l].map(function(M){return M.split(" ")}),d=n.Range.chromatic(a);return u.reduce(function(M,h){var A=h.map(function(v){return n.Interval.substract(v,h[0])}),Q=n.Note.transpose(c,h[0]),Gt=d.filter(function(v){return n.Note.chroma(v)===n.Note.chroma(Q)}).filter(function(v){return n.Note.midi(n.Note.transpose(v,A[A.length-1]))<=n.Note.midi(a[1])}).map(function(v){return n.Note.enharmonic(v,Q)}),Bt=Gt.map(function(v){return A.map(function(Ht){return n.Note.transpose(v,Ht)})});return M.concat(Bt)},[])}return O.voicingsInRange=o,O}var Un;function qt(){return Un||(Un=1,function(n){var t=Y&&Y.__assign||function(){return t=Object.assign||function(s){for(var c,l=1,u=arguments.length;lui({chord:n,dictionary:di,range:e,picker:li,lastVoicing:t}),x=_;x.prototype.fmapNested=function(n){return new x(t=>this.query(t).map(e=>Kt(n(e)).query(t).map(o=>new Qt(e.whole,e.part,o.value,o.context))).flat())};x.prototype.voicings=function(n){let t;return n!=null&&n.length||(n=["F3","A4"]),this.fmapNested(e=>(t=Mi(e.value,t,n),Yt(...t)._withContext(()=>({locations:e.context.locations||[]}))))};x.prototype._rootNotes=function(n=2){return this.fmap(t=>{const[e,o]=t.match(/^([a-gA-G][b#]?).*$/);return o+n})};x.prototype.define("voicings",(n,t)=>t.voicings(n),{composable:!0});x.prototype.define("rootNotes",(n,t)=>t.rootNotes(n),{composable:!0,patternified:!0}); +import{P as _,o as Lt,q as Ut,t as Y,u as Xt,v as Kt,H as Qt,x as Yt}from"./index.4cbc0a10.js";const C=(n,t)=>Array(Math.abs(t)+1).join(n);function g(n,t,e){return function(...o){return console.warn(`${n} is deprecated. Use ${t}.`),e.apply(this,o)}}function z(n){return n!==null&&typeof n=="object"&&typeof n.name=="string"}function q(n){return n!==null&&typeof n=="object"&&typeof n.step=="number"&&typeof n.alt=="number"}const Qn=[0,2,4,-1,1,3,5],Yn=Qn.map(n=>Math.floor(n*7/12));function en(n){const{step:t,alt:e,oct:o,dir:r=1}=n,i=Qn[t]+7*e;if(o===void 0)return[r*i];const a=o-Yn[t]-4*e;return[r*i,r*a]}const Zt=[3,0,4,1,5,2,6];function on(n){const[t,e,o]=n,r=Zt[Jt(t)],i=Math.floor((t+1)/7);if(e===void 0)return{step:r,alt:i,dir:o};const a=e+4*i+Yn[r];return{step:r,alt:i,oct:a,dir:o}}function Jt(n){const t=(n+1)%7;return t<0?7+t:t}const Zn={empty:!0,name:"",pc:"",acc:""},Dn=new Map,vn=n=>"CDEFGAB".charAt(n),E=n=>n<0?C("b",-n):C("#",n),G=n=>n[0]==="b"?-n.length:n.length;function m(n){const t=Dn.get(n);if(t)return t;const e=typeof n=="string"?te(n):q(n)?m(ee(n)):z(n)?m(n.name):Zn;return Dn.set(n,e),e}const Wt=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function rn(n){const t=Wt.exec(n);return[t[1].toUpperCase(),t[2].replace(/x/g,"##"),t[3],t[4]]}function F(n){return m(on(n))}const ne=(n,t)=>(n%t+t)%t,pn=[0,2,4,5,7,9,11];function te(n){const t=rn(n);if(t[0]===""||t[3]!=="")return Zn;const e=t[0],o=t[1],r=t[2],i=(e.charCodeAt(0)+3)%7,a=G(o),s=r.length?+r:void 0,c=en({step:i,alt:a,oct:s}),l=e+o+r,u=e+o,d=(pn[i]+a+120)%12,M=s===void 0?ne(pn[i]+a,12)-12*99:pn[i]+a+12*(s+1),h=M>=0&&M<=127?M:null,A=s===void 0?null:Math.pow(2,(M-69)/12)*440;return{empty:!1,acc:o,alt:a,chroma:d,coord:c,freq:A,height:M,letter:e,midi:h,name:l,oct:s,pc:u,step:i}}function ee(n){const{step:t,alt:e,oct:o}=n,r=vn(t);if(!r)return"";const i=r+E(e);return o||o===0?i+o:i}const yn={empty:!0,name:"",acc:""},oe="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",re="(AA|A|P|M|m|d|dd)([-+]?\\d+)",ie=new RegExp("^"+oe+"|"+re+"$");function $n(n){const t=ie.exec(`${n}`);return t===null?["",""]:t[1]?[t[1],t[2]]:[t[4],t[3]]}const Rn={};function f(n){return typeof n=="string"?Rn[n]||(Rn[n]=ae(n)):q(n)?f(ce(n)):z(n)?f(n.name):yn}const kn=[0,2,4,5,7,9,11],Jn="PMMPPMM";function ae(n){const t=$n(n);if(t[0]==="")return yn;const e=+t[0],o=t[1],r=(Math.abs(e)-1)%7,i=Jn[r];if(i==="M"&&o==="P")return yn;const a=i==="M"?"majorable":"perfectable",s=""+e+o,c=e<0?-1:1,l=e===8||e===-8?e:c*(r+1),u=se(a,o),d=Math.floor((Math.abs(e)-1)/7),M=c*(kn[r]+u+12*d),h=(c*(kn[r]+u)%12+12)%12,A=en({step:r,alt:u,oct:d,dir:c});return{empty:!1,name:s,num:e,q:o,step:r,alt:u,dir:c,type:a,simple:l,semitones:M,chroma:h,coord:A,oct:d}}function B(n,t){const[e,o=0]=n,r=e*7+o*12<0,i=t||r?[-e,-o,-1]:[e,o,1];return f(on(i))}function se(n,t){return t==="M"&&n==="majorable"||t==="P"&&n==="perfectable"?0:t==="m"&&n==="majorable"?-1:/^A+$/.test(t)?t.length:/^d+$/.test(t)?-1*(n==="perfectable"?t.length:t.length+1):0}function ce(n){const{step:t,alt:e,oct:o=0,dir:r}=n;if(!r)return"";const i=t+1+7*o,a=i===0?t+1:i,s=r<0?"-":"",c=Jn[t]==="M"?"majorable":"perfectable";return s+a+me(c,e)}function me(n,t){return t===0?n==="majorable"?"M":"P":t===-1&&n==="majorable"?"m":t>0?C("A",t):C("d",n==="perfectable"?t:t+1)}function P(n,t){const e=m(n),o=f(t);if(e.empty||o.empty)return"";const r=e.coord,i=o.coord,a=r.length===1?[r[0]+i[0]]:[r[0]+i[0],r[1]+i[1]];return F(a).name}function D(n,t){const e=m(n),o=m(t);if(e.empty||o.empty)return"";const r=e.coord,i=o.coord,a=i[0]-r[0],s=r.length===2&&i.length===2?i[1]-r[1]:-Math.floor(a*7/12),c=o.height===e.height&&o.midi!==null&&e.midi!==null&&e.step>o.step;return B([a,s],c).name}const Wn=Object.freeze(Object.defineProperty({__proto__:null,accToAlt:G,altToAcc:E,coordToInterval:B,coordToNote:F,decode:on,deprecate:g,distance:D,encode:en,fillStr:C,interval:f,isNamed:z,isPitch:q,note:m,stepToLetter:vn,tokenizeInterval:$n,tokenizeNote:rn,transpose:P},Symbol.toStringTag,{value:"Module"})),On=(n,t)=>Array(t+1).join(n),ue=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function nt(n){const t=ue.exec(n);return t?[t[1],t[2],t[3]]:["","",""]}function W(n){const[t,e,o]=nt(n);if(e==="")return"";let r=4;for(let a=0;a96?e.toUpperCase()+i+(r+1):e+i+r}function tt(n){const t=m(n);if(t.empty||!t.oct&&t.oct!==0)return"";const{letter:e,acc:o,oct:r}=t,i=o[0]==="b"?o.replace(/b/g,"_"):o.replace(/#/g,"^"),a=r>4?e.toLowerCase():e,s=r===5?"":r>4?On("'",r-5):On(",",4-r);return i+a+s}function le(n,t){return tt(P(W(n),t))}function de(n,t){return D(W(n),W(t))}var Me={abcToScientificNotation:W,scientificToAbcNotation:tt,tokenize:nt,transpose:le,distance:de};function fe(n,t){const e=[];for(;t--;e[t]=t+n);return e}function Pe(n,t){const e=[];for(;t--;e[t]=n-t);return e}function pe(n,t){return nt===0||t)}function et(n){return n.map(e=>m(e)).filter(e=>!e.empty).sort((e,o)=>e.height-o.height).map(e=>e.name)}function ge(n){return et(n).filter((t,e,o)=>e===0||t!==o[e-1])}function be(n,t=Math.random){let e,o,r=n.length;for(;r;)e=Math.floor(t()*r--),o=n[r],n[r]=n[e],n[e]=o;return n}function ot(n){return n.length===0?[[]]:ot(n.slice(1)).reduce((t,e)=>t.concat(n.map((o,r)=>{const i=e.slice();return i.splice(r,0,n[0]),i})),[])}const Ae=Object.freeze(Object.defineProperty({__proto__:null,compact:ye,permutations:ot,range:pe,rotate:he,shuffle:be,sortedNoteNames:et,sortedUniqNoteNames:ge},Symbol.toStringTag,{value:"Module"}));function ve(n,t){const e=[];for(;t--;e[t]=t+n);return e}function $e(n,t){const e=[];for(;t--;e[t]=n-t);return e}function an(n,t){return nt===0||t)}function Ne(n,t=Math.random){let e,o,r=n.length;for(;r;)e=Math.floor(t()*r--),o=n[r],n[r]=n[e],n[e]=o;return n}function rt(n){return n.length===0?[[]]:rt(n.slice(1)).reduce((t,e)=>t.concat(n.map((o,r)=>{const i=e.slice();return i.splice(r,0,n[0]),i})),[])}var Ie={compact:Nn,permutations:rt,range:an,rotate:H,shuffle:Ne};const T={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},In=n=>Number(n).toString(2),Fn=n=>parseInt(n,2),je=/^[01]{12}$/;function it(n){return je.test(n)}const Se=n=>typeof n=="number"&&n>=0&&n<=4095,Te=n=>n&&it(n.chroma),zn={[T.chroma]:T};function p(n){const t=it(n)?n:Se(n)?In(n):Array.isArray(n)?ze(n):Te(n)?n.chroma:T.chroma;return zn[t]=zn[t]||Fe(t)}const Ve=g("Pcset.pcset","Pcset.get",p),_e=n=>p(n).chroma,Ce=n=>p(n).intervals,we=n=>p(n).setNum,xe=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Ee(n){const t=[];for(let e=0;e<12;e++)n.charAt(e)==="1"&&t.push(xe[e]);return t}function De(){return an(2048,4095).map(In)}function jn(n,t=!0){const o=p(n).chroma.split("");return Nn(o.map((r,i)=>{const a=H(i,o);return t&&a[0]==="0"?null:a.join("")}))}function Re(n,t){return p(n).setNum===p(t).setNum}function sn(n){const t=p(n).setNum;return e=>{const o=p(e).setNum;return t&&t!==o&&(o&t)===o}}function cn(n){const t=p(n).setNum;return e=>{const o=p(e).setNum;return t&&t!==o&&(o|t)===o}}function at(n){const t=p(n);return e=>{const o=m(e);return t&&!o.empty&&t.chroma.charAt(o.chroma)==="1"}}function ke(n){const t=at(n);return e=>e.filter(t)}var st={get:p,chroma:_e,num:we,intervals:Ce,chromas:De,isSupersetOf:cn,isSubsetOf:sn,isNoteIncludedIn:at,isEqual:Re,filter:ke,modes:jn,pcset:Ve};function Oe(n){const t=n.split("");return t.map((e,o)=>H(o,t).join(""))}function Fe(n){const t=Fn(n),e=Oe(n).map(Fn).filter(i=>i>=2048).sort()[0],o=In(e),r=Ee(n);return{empty:!1,name:"",setNum:t,chroma:n,normalized:o,intervals:r}}function ze(n){if(n.length===0)return T.chroma;let t;const e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let o=0;on.name).filter(n=>n)}function Le(){return R.map(n=>n.aliases[0]).filter(n=>n)}function Ue(){return Object.keys(j)}function k(){return R.slice()}const Xe=g("ChordType.entries","ChordType.all",k);function Ke(){R=[],j={}}function ct(n,t,e){const o=Ye(n),r={...p(n),name:e||"",quality:o,intervals:n,aliases:t};R.push(r),r.name&&(j[r.name]=r),j[r.setNum]=r,j[r.chroma]=r,r.aliases.forEach(i=>Qe(r,i))}function Qe(n,t){j[t]=n}function Ye(n){const t=e=>n.indexOf(e)!==-1;return t("5A")?"Augmented":t("3M")?"Major":t("5d")?"Diminished":t("3m")?"Minor":"Unknown"}qe.forEach(([n,t,e])=>ct(n.split(" "),e.split(" "),t));R.sort((n,t)=>n.setNum-t.setNum);var mt={names:He,symbols:Le,get:Sn,all:k,add:ct,removeAll:Ke,keys:Ue,entries:Xe,chordType:Be};const Ze=n=>{const t=n.reduce((e,o)=>{const r=m(o).chroma;return r!==void 0&&(e[r]=e[r]||m(o).name),e},{});return e=>t[e]};function Je(n){const t=n.map(o=>m(o).pc).filter(o=>o);return m.length===0?[]:We(t,1).filter(o=>o.weight).sort((o,r)=>r.weight-o.weight).map(o=>o.name)}function We(n,t){const e=n[0],o=m(e).chroma,r=Ze(n),i=jn(n,!1),a=[];return i.forEach((s,c)=>{k().filter(u=>u.chroma===s).forEach(u=>{const d=u.aliases[0],M=r(c);c!==o?a.push({weight:.5*t,name:`${M}${d}/${e}`}):a.push({weight:1*t,name:`${M}${d}`})})}),a}const no=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neopolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5P pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7M pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neopolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 7m","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neopolitan major"],["1P 2M 3m 4P 5P 6m 7m","aeolian","minor"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],to={...T,intervals:[],aliases:[]};let mn=[],S={};function ut(){return mn.map(n=>n.name)}function un(n){return S[n]||to}const eo=g("ScaleDictionary.scaleType","ScaleType.get",un);function L(){return mn.slice()}const oo=g("ScaleDictionary.entries","ScaleType.all",L);function ro(){return Object.keys(S)}function io(){mn=[],S={}}function lt(n,t,e=[]){const o={...p(n),name:t,intervals:n,aliases:e};return mn.push(o),S[o.name]=o,S[o.setNum]=o,S[o.chroma]=o,o.aliases.forEach(r=>ao(o,r)),o}function ao(n,t){S[t]=n}no.forEach(([n,t,...e])=>lt(n.split(" "),t,e));var dt={names:ut,get:un,all:L,add:lt,removeAll:io,keys:ro,entries:oo,scaleType:eo};const gn={empty:!0,name:"",symbol:"",root:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]},so=/^(6|64|7|9|11|13)$/;function ln(n){const[t,e,o,r]=rn(n);return t===""?["",n]:t==="A"&&r==="ug"?["","aug"]:!r&&(o==="4"||o==="5")?[t+e,o]:so.test(o)?[t+e,o+r]:[t+e+o,r]}function U(n){if(n==="")return gn;if(Array.isArray(n)&&n.length===2)return Z(n[1],n[0]);{const[t,e]=ln(n),o=Z(e,t);return o.empty?Z(n):o}}function Z(n,t,e){const o=Sn(n),r=m(t||""),i=m(e||"");if(o.empty||t&&r.empty||e&&i.empty)return gn;const a=D(r.pc,i.pc),s=o.intervals.indexOf(a)+1;if(!i.empty&&!s)return gn;const c=Array.from(o.intervals);for(let M=1;MP(r,M));n=o.aliases.indexOf(n)!==-1?n:o.aliases[0];const u=`${r.empty?"":r.pc}${n}${i.empty||s<=1?"":"/"+i.pc}`,d=`${t?r.pc+" ":""}${o.name}${s>1&&e?" over "+i.pc:""}`;return{...o,name:d,symbol:u,type:o.name,root:i.name,intervals:c,rootDegree:s,tonic:r.name,notes:l}}const co=g("Chord.chord","Chord.get",U);function mo(n,t){const[e,o]=ln(n);return e?P(e,t)+o:n}function uo(n){const t=U(n),e=cn(t.chroma);return L().filter(o=>e(o.chroma)).map(o=>o.name)}function lo(n){const t=U(n),e=cn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>t.tonic+o.aliases[0])}function Mo(n){const t=U(n),e=sn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>t.tonic+o.aliases[0])}var fo={getChord:Z,get:U,detect:Je,chordScales:uo,extended:lo,reduced:Mo,tokenize:ln,transpose:mo,chord:co};const Po=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],dn=[];Po.forEach(([n,t,e])=>$o(n,t,e));const po={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function ho(){return dn.reduce((n,t)=>(t.names.forEach(e=>n.push(e)),n),[])}function yo(){return dn.map(n=>n.shorthand)}const go=/^([^.]+)(\.*)$/;function Tn(n){const[t,e,o]=go.exec(n)||[],r=dn.find(s=>s.shorthand===e||s.names.includes(e));if(!r)return po;const i=No(r.fraction,o.length),a=i[0]/i[1];return{...r,name:n,dots:o,value:a,fraction:i}}const bo=n=>Tn(n).value,Ao=n=>Tn(n).fraction;var vo={names:ho,shorthands:yo,get:Tn,value:bo,fraction:Ao};function $o(n,t,e){dn.push({empty:!1,dots:"",name:"",value:1/n,fraction:n<1?[1/n,1]:[1,n],shorthand:t,names:e})}function No(n,t){const e=Math.pow(2,t);let o=n[0]*e,r=n[1]*e;const i=o;for(let a=0;af(n).name,So=n=>f(n).semitones,To=n=>f(n).q,Vo=n=>f(n).num;function ft(n){const t=f(n);return t.empty?"":t.simple+t.q}function _o(n){const t=f(n);if(t.empty)return"";const e=(7-t.step)%7,o=t.type==="perfectable"?-t.alt:-(t.alt+1);return f({step:e,alt:o,oct:t.oct,dir:t.dir}).name}const Co=[1,2,2,3,3,4,5,5,6,6,7,7],wo="P m M m M P d P m M m M".split(" ");function xo(n){const t=n<0?-1:1,e=Math.abs(n),o=e%12,r=Math.floor(e/12);return t*(Co[o]+7*r)+wo[o]}const Eo=D,Pt=ht((n,t)=>[n[0]+t[0],n[1]+t[1]]),Do=n=>t=>Pt(n,t),Ro=ht((n,t)=>[n[0]-t[0],n[1]-t[1]]);function pt(n,t){const e=Mt(n);if(e.empty)return"";const[o,r,i]=e.coord;return B([o+t,r,i]).name}var bn={names:Io,get:Mt,name:jo,num:Vo,semitones:So,quality:To,fromSemitones:xo,distance:Eo,invert:_o,simplify:ft,add:Pt,addTo:Do,substract:Ro,transposeFifths:pt};function ht(n){return(t,e)=>{const o=f(t).coord,r=f(e).coord;if(o&&r){const i=n(o,r);return B(i).name}}}function yt(n){return+n>=0&&+n<=127}function gt(n){if(yt(n))return+n;const t=m(n);return t.empty?null:t.midi}function ko(n,t=440){return Math.pow(2,(n-69)/12)*t}const Oo=Math.log(2),Fo=Math.log(440);function Vn(n){const t=12*(Math.log(n)-Fo)/Oo+69;return Math.round(t*100)/100}const zo="C C# D D# E F F# G G# A A# B".split(" "),qo="C Db D Eb E F Gb G Ab A Bb B".split(" ");function I(n,t={}){if(isNaN(n)||n===-1/0||n===1/0)return"";n=Math.round(n);const o=(t.sharps===!0?zo:qo)[n%12];if(t.pitchClass)return o;const r=Math.floor(n/12)-1;return o+r}var Go={isMidi:yt,toMidi:gt,midiToFreq:ko,midiToNoteName:I,freqToMidi:Vn};const Bo=["C","D","E","F","G","A","B"],bt=n=>n.name,At=n=>n.map(m).filter(t=>!t.empty);function Ho(n){return n===void 0?Bo.slice():Array.isArray(n)?At(n).map(bt):[]}const y=m,Lo=n=>y(n).name,Uo=n=>y(n).pc,Xo=n=>y(n).acc,Ko=n=>y(n).oct,Qo=n=>y(n).midi,Yo=n=>y(n).freq,Zo=n=>y(n).chroma;function vt(n){return I(n)}function Jo(n){return I(Vn(n))}function Wo(n){return I(Vn(n),{sharps:!0})}function nr(n){return I(n,{sharps:!0})}const _n=P,tr=P,$t=n=>t=>_n(t,n),er=$t,Nt=n=>t=>_n(n,t),or=Nt;function nn(n,t){const e=y(n);if(e.empty)return"";const[o,r]=e.coord;return F(r===void 0?[o+t]:[o+t,r]).name}const rr=nn,Cn=(n,t)=>n.height-t.height,ir=(n,t)=>t.height-n.height;function It(n,t){return t=t||Cn,At(n).sort(t).map(bt)}function jt(n){return It(n,Cn).filter((t,e,o)=>e===0||t!==o[e-1])}const ar=n=>{const t=y(n);return t.empty?"":I(t.midi||t.chroma,{sharps:t.alt>0,pitchClass:t.midi===null})};function St(n,t){const e=y(n);if(e.empty)return"";const o=y(t||I(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(o.empty||o.chroma!==e.chroma)return"";if(e.oct===void 0)return o.pc;const r=e.chroma-e.alt,i=o.chroma-o.alt,a=r>11||i<0?-1:r<0||i>11?1:0,s=e.oct+a;return o.pc+s}var w={names:Ho,get:y,name:Lo,pitchClass:Uo,accidentals:Xo,octave:Ko,midi:Qo,ascending:Cn,descending:ir,sortedNames:It,sortedUniqNames:jt,fromMidi:vt,fromMidiSharps:nr,freq:Yo,fromFreq:Jo,fromFreqSharps:Wo,chroma:Zo,transpose:_n,tr,transposeBy:$t,trBy:er,transposeFrom:Nt,trFrom:or,transposeFifths:nn,trFifths:rr,simplify:ar,enharmonic:St};const Tt={empty:!0,name:"",chordType:""},qn={};function $(n){return typeof n=="string"?qn[n]||(qn[n]=Mr(n)):typeof n=="number"?$(Mn[n]||""):q(n)?mr(n):z(n)?$(n.name):Tt}const sr=g("RomanNumeral.romanNumeral","RomanNumeral.get",$);function cr(n=!0){return(n?Mn:dr).slice()}function mr(n){return $(E(n.alt)+Mn[n.step])}const ur=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function lr(n){return ur.exec(n)||["","","",""]}const Vt="I II III IV V VI VII",Mn=Vt.split(" "),dr=Vt.toLowerCase().split(" ");function Mr(n){const[t,e,o,r]=lr(n);if(!o)return Tt;const i=o.toUpperCase(),a=Mn.indexOf(i),s=G(e),c=1;return{empty:!1,name:t,roman:o,interval:f({step:a,alt:s,dir:c}).name,acc:e,chordType:r,alt:s,step:a,major:o===i,oct:0,dir:c}}var fr={names:cr,get:$,romanNumeral:sr};const b=Object.freeze([]),_t={type:"major",tonic:"",alteration:0,keySignature:""},J={tonic:"",grades:b,intervals:b,scale:b,chords:b,chordsHarmonicFunction:b,chordScales:b},Pr={..._t,...J,type:"major",minorRelative:"",scale:b,secondaryDominants:b,secondaryDominantsMinorRelative:b,substituteDominants:b,substituteDominantsMinorRelative:b},pr={..._t,type:"minor",relativeMajor:"",natural:J,harmonic:J,melodic:J},Gn=(n,t,e="")=>t.map((o,r)=>`${n[r]}${e}${o}`);function fn(n,t,e,o){return r=>{const i=n.map(s=>$(s).interval||""),a=i.map(s=>P(r,s));return{tonic:r,grades:n,intervals:i,scale:a,chords:Gn(a,t),chordsHarmonicFunction:e.slice(),chordScales:Gn(a,o," ")}}}const Ct=(n,t)=>{const e=m(n),o=m(t);return e.empty||o.empty?0:o.coord[0]-e.coord[0]},hr=fn("I II III IV V VI VII".split(" "),"maj7 m7 m7 maj7 7 m7 m7b5".split(" "),"T SD T SD D T D".split(" "),"major,dorian,phrygian,lydian,mixolydian,minor,locrian".split(",")),yr=fn("I II bIII IV V bVI bVII".split(" "),"m7 m7b5 maj7 m7 m7 maj7 7".split(" "),"T SD T SD D SD SD".split(" "),"minor,locrian,major,dorian,phrygian,lydian,mixolydian".split(",")),gr=fn("I II bIII IV V bVI VII".split(" "),"mMaj7 m7b5 +maj7 m7 7 maj7 o7".split(" "),"T SD T SD D SD D".split(" "),"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian".split(",")),br=fn("I II bIII IV V VI VII".split(" "),"m6 m7 +maj7 7 7 m7b5 m7b5".split(" "),"T SD T SD D ".split(" "),"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered".split(","));function Ar(n){const t=m(n).pc;if(!t)return Pr;const e=hr(t),o=Ct("C",t),r=i=>{const a=$(i);return a.empty?"":P(n,a.interval)+a.chordType};return{...e,type:"major",minorRelative:P(t,"-3m"),alteration:o,keySignature:E(o),secondaryDominants:"- VI7 VII7 I7 II7 III7 -".split(" ").map(r),secondaryDominantsMinorRelative:"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -".split(" ").map(r),substituteDominants:"- bIII7 IV7 bV7 bVI7 bVII7 -".split(" ").map(r),substituteDominantsMinorRelative:"- IIIm7 Im7 IIbm7 VIm7 IVm7 -".split(" ").map(r)}}function vr(n){const t=m(n).pc;if(!t)return pr;const e=Ct("C",t)-3;return{type:"minor",tonic:t,relativeMajor:P(t,"3m"),alteration:e,keySignature:E(e),natural:yr(t),harmonic:gr(t),melodic:br(t)}}function $r(n){return typeof n=="number"?nn("C",n):typeof n=="string"&&/^b+|#+$/.test(n)?nn("C",G(n)):null}var Nr={majorKey:Ar,majorTonicFromKeySignature:$r,minorKey:vr};const wn=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],Bn={...T,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},xn=wn.map(Tr),An={};xn.forEach(n=>{An[n.name]=n,n.aliases.forEach(t=>{An[t]=n})});function V(n){return typeof n=="string"?An[n.toLowerCase()]||Bn:n&&n.name?V(n.name):Bn}const Ir=g("Mode.mode","Mode.get",V);function wt(){return xn.slice()}const jr=g("Mode.mode","Mode.all",wt);function Sr(){return xn.map(n=>n.name)}function Tr(n){const[t,e,o,r,i,a,s]=n,c=s?[s]:[],l=Number(e).toString(2);return{empty:!1,intervals:un(r).intervals,modeNum:t,chroma:l,normalized:l,name:r,setNum:e,alt:o,triad:i,seventh:a,aliases:c}}function Vr(n,t){return V(n).intervals.map(e=>P(t,e))}function xt(n){return(t,e)=>{const o=V(t);if(o.empty)return[];const r=H(o.modeNum,n),i=o.intervals.map(a=>P(e,a));return r.map((a,s)=>i[s]+a)}}const _r=xt(wn.map(n=>n[4])),Cr=xt(wn.map(n=>n[5]));function Et(n,t){const e=V(t),o=V(n);return e.empty||o.empty?"":ft(pt("1P",o.alt-e.alt))}function wr(n,t,e){return P(e,Et(n,t))}var xr={get:V,names:Sr,all:wt,distance:Et,relativeTonic:wr,notes:Vr,triads:_r,seventhChords:Cr,entries:jr,mode:Ir};function Er(n,t){return t.map($).map(o=>P(n,f(o))+o.chordType)}function Dr(n,t){return t.map(e=>{const[o,r]=ln(e),i=D(n,o);return $(f(i)).name+r})}var Rr={fromRomanNumerals:Er,toRomanNumerals:Dr};function Dt(n){const t=Nn(n.map(gt));return!n.length||t.length!==n.length?[]:t.reduce((e,o)=>{const r=e[e.length-1];return e.concat(an(r,o).slice(1))},[t[0]])}function kr(n,t){return Dt(n).map(e=>I(e,t))}var Or={numeric:Dt,chromatic:kr};const Fr={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function Rt(n){if(typeof n!="string")return["",""];const t=n.indexOf(" "),e=m(n.substring(0,t));if(e.empty){const r=m(n);return r.empty?["",n]:[r.name,""]}const o=n.substring(e.name.length+1);return[e.name,o.length?o:""]}const zr=ut;function N(n){const t=Array.isArray(n)?n:Rt(n),e=m(t[0]).name,o=un(t[1]);if(o.empty)return Fr;const r=o.name,i=e?o.intervals.map(s=>P(e,s)):[],a=e?e+" "+r:r;return{...o,name:a,type:r,tonic:e,notes:i}}const qr=g("Scale.scale","Scale.get",N);function Gr(n){const t=N(n),e=sn(t.chroma);return k().filter(o=>e(o.chroma)).map(o=>o.aliases[0])}function Br(n){const t=N(n),e=cn(t.chroma);return L().filter(o=>e(o.chroma)).map(o=>o.name)}function Hr(n){const t=sn(N(n).chroma);return L().filter(e=>t(e.chroma)).map(e=>e.name)}function kt(n){const t=n.map(r=>m(r).pc).filter(r=>r),e=t[0],o=jt(t);return H(o.indexOf(e),o)}function Lr(n){const t=N(n);if(t.empty)return[];const e=t.tonic?t.notes:t.intervals;return jn(t.chroma).map((o,r)=>{const i=N(o).name;return i?[e[r],i]:["",""]}).filter(o=>o[0])}function Ur(n){const t=Array.isArray(n)?kt(n):N(n).notes,e=t.map(o=>m(o).chroma);return o=>{const r=m(typeof o=="number"?vt(o):o),i=r.height;if(i===void 0)return;const a=i%12,s=e.indexOf(a);if(s!==-1)return St(r.name,t[s])}}function Xr(n){const t=Ur(n);return(e,o)=>{const r=m(e).height,i=m(o).height;return r===void 0||i===void 0?[]:an(r,i).map(t).filter(a=>a)}}var tn={get:N,names:zr,extended:Br,modeNames:Lr,reduced:Hr,scaleChords:Gr,scaleNotes:kt,tokenize:Rt,rangeOf:Xr,scale:qr};const Kr={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},Qr=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function Yr(){return Qr.slice()}const Zr=/^(\d?\d(?:\+\d)*)\/(\d)$/,Hn=new Map;function Jr(n){const t=Hn.get(n);if(t)return t;const e=ni(En(n));return Hn.set(n,e),e}function En(n){if(typeof n=="string"){const[i,a,s]=Zr.exec(n)||[];return En([a,s])}const[t,e]=n,o=+e;if(typeof t=="number")return[t,o];const r=t.split("+").map(i=>+i);return r.length===1?[r[0],o]:[r,o]}var Wr={names:Yr,parse:En,get:Jr};function ni([n,t]){const e=Array.isArray(n)?n.reduce((s,c)=>s+c,0):n,o=t;if(e===0||o===0)return Kr;const r=Array.isArray(n)?`${n.join("+")}/${t}`:`${n}/${t}`,i=Array.isArray(n)?n:[],a=o===4||o===2?"simple":o===8&&e%3===0?"compound":"irregular";return{empty:!1,name:r,type:a,upper:e,lower:o,additive:i}}const ti=Wn,ei=st,oi=mt,ri=dt,ii=Object.freeze(Object.defineProperty({__proto__:null,Array:Ae,Core:Wn,ChordDictionary:oi,PcSet:ei,ScaleDictionary:ri,Tonal:ti,AbcNotation:Me,Chord:fo,ChordType:mt,Collection:Ie,DurationValue:vo,Interval:bn,Key:Nr,Midi:Go,Mode:xr,Note:w,Pcset:st,Progression:Rr,Range:Or,RomanNumeral:fr,Scale:tn,ScaleType:dt,TimeSignature:Wr,accToAlt:G,altToAcc:E,coordToInterval:B,coordToNote:F,decode:on,deprecate:g,distance:D,encode:en,fillStr:C,interval:f,isNamed:z,isPitch:q,note:m,stepToLetter:vn,tokenizeInterval:$n,tokenizeNote:rn,transpose:P},Symbol.toStringTag,{value:"Module"}));function Ot(n,t,e){let[o,r]=tn.tokenize(n),{notes:i}=tn.get(`${o} ${r}`);if(i=i.map(h=>w.get(h).pc),t=Number(t),isNaN(t))throw new Error(`scale offset "${t}" not a number`);const{pc:a,oct:s=3}=w.get(e),c=i.indexOf(a);if(c===-1)throw new Error(`note "${e}" is not in scale "${n}"`);let l=c,u=s,d=a;const M=Math.sign(t);for(;Math.abs(l-c)0&&d[0]==="C"&&(u+=M)}return d+u}_.prototype._transpose=function(n){return this._withHap(t=>{const e=isNaN(Number(n))?String(n):bn.fromSemitones(n);if(typeof t.value=="number"){const o=typeof e=="string"?bn.semitones(e)||0:e;return t.withValue(()=>t.value+o)}return t.withValue(()=>w.simplify(w.transpose(t.value,e)))})};_.prototype._scaleTranspose=function(n){return this._withHap(t=>{if(!t.context.scale)throw new Error("can only use scaleTranspose after .scale");if(typeof t.value!="string")throw new Error("can only use scaleTranspose with notes");return t.withValue(()=>Ot(t.context.scale,Number(n),t.value))})};_.prototype._scale=function(n){return this._withHap(t=>{let e=t.value;const o=Number(e);if(!isNaN(o)){let[r,i]=tn.tokenize(n);const{pc:a,oct:s=3}=w.get(r);e=Ot(a+" "+i,o,a+s)}return t.withValue(()=>e).setContext({...t.context,scale:n})})};_.prototype.define("transpose",(n,t)=>t.transpose(n),{composable:!0,patternified:!0});_.prototype.define("scale",(n,t)=>t.scale(n),{composable:!0,patternified:!0});_.prototype.define("scaleTranspose",(n,t)=>t.scaleTranspose(n),{composable:!0,patternified:!0});var Ft={},hn={},X={};X.__esModule=!0;X.getBestVoicing=void 0;function ai(n){var t=n.chord,e=n.range,o=n.finder,r=n.picker,i=n.lastVoicing,a=o(t,e);return a.length?r(a,i):[]}X.getBestVoicing=ai;var O={};const zt=Ut(ii);var K={};K.__esModule=!0;K.tokenizeChord=void 0;function si(n){var t=(n||"").match(/^([A-G][b#]*)([^\/]*)[\/]?([A-G][b#]*)?$/);return t?t.slice(1):[]}K.tokenizeChord=si;var Ln;function ci(){if(Ln)return O;Ln=1,O.__esModule=!0,O.voicingsInRange=void 0;var n=zt,t=qt(),e=K;function o(r,i,a){i===void 0&&(i=t.lefthand),a===void 0&&(a=["D3","A4"]);var s=(0,e.tokenizeChord)(r),c=s[0],l=s[1];if(!i[l])return[];var u=i[l].map(function(M){return M.split(" ")}),d=n.Range.chromatic(a);return u.reduce(function(M,h){var A=h.map(function(v){return n.Interval.substract(v,h[0])}),Q=n.Note.transpose(c,h[0]),Gt=d.filter(function(v){return n.Note.chroma(v)===n.Note.chroma(Q)}).filter(function(v){return n.Note.midi(n.Note.transpose(v,A[A.length-1]))<=n.Note.midi(a[1])}).map(function(v){return n.Note.enharmonic(v,Q)}),Bt=Gt.map(function(v){return A.map(function(Ht){return n.Note.transpose(v,Ht)})});return M.concat(Bt)},[])}return O.voicingsInRange=o,O}var Un;function qt(){return Un||(Un=1,function(n){var t=Y&&Y.__assign||function(){return t=Object.assign||function(s){for(var c,l=1,u=arguments.length;lui({chord:n,dictionary:di,range:e,picker:li,lastVoicing:t}),x=_;x.prototype.fmapNested=function(n){return new x(t=>this.query(t).map(e=>Kt(n(e)).query(t).map(o=>new Qt(e.whole,e.part,o.value,o.context))).flat())};x.prototype.voicings=function(n){let t;return n!=null&&n.length||(n=["F3","A4"]),this.fmapNested(e=>(t=Mi(e.value,t,n),Yt(...t)._withContext(()=>({locations:e.context.locations||[]}))))};x.prototype._rootNotes=function(n=2){return this.fmap(t=>{const[e,o]=t.match(/^([a-gA-G][b#]?).*$/);return o+n})};x.prototype.define("voicings",(n,t)=>t.voicings(n),{composable:!0});x.prototype.define("rootNotes",(n,t)=>t.rootNotes(n),{composable:!0,patternified:!0}); diff --git a/packages/core/examples/vite-vanilla-repl/dist/assets/index.85aeb624.js b/packages/core/examples/vite-vanilla-repl/dist/assets/index.85aeb624.js deleted file mode 100644 index 72bd56c8..00000000 --- a/packages/core/examples/vite-vanilla-repl/dist/assets/index.85aeb624.js +++ /dev/null @@ -1 +0,0 @@ -import{b as s,h as i,m,a as n,c as p,p as t}from"./index.73313bf6.js";export{s as SyntaxError,i as h,m as mini,n as minify,p as parse,t as patternifyAST}; diff --git a/packages/core/examples/vite-vanilla-repl/dist/assets/index.b258159a.js b/packages/core/examples/vite-vanilla-repl/dist/assets/index.ecddf978.js similarity index 82% rename from packages/core/examples/vite-vanilla-repl/dist/assets/index.b258159a.js rename to packages/core/examples/vite-vanilla-repl/dist/assets/index.ecddf978.js index 5856669c..7e53038e 100644 --- a/packages/core/examples/vite-vanilla-repl/dist/assets/index.b258159a.js +++ b/packages/core/examples/vite-vanilla-repl/dist/assets/index.ecddf978.js @@ -1 +1 @@ -import{g as s,f as d,i as t,n as r,l as u,j as o,d as f,k as p,r as g,s as i,w as l,e as m}from"./index.73313bf6.js";export{s as getAudioContext,d as getCachedBuffer,t as getLoadedBuffer,r as getLoadedSamples,u as loadBuffer,o as loadGithubSamples,f as panic,p as resetLoadedSamples,g as reverseBuffer,i as samples,l as webaudioOutput,m as webaudioOutputTrigger}; +import{g as s,f as d,i as t,n as r,l as u,j as o,d as f,k as p,r as g,s as i,w as l,e as m}from"./index.4cbc0a10.js";export{s as getAudioContext,d as getCachedBuffer,t as getLoadedBuffer,r as getLoadedSamples,u as loadBuffer,o as loadGithubSamples,f as panic,p as resetLoadedSamples,g as reverseBuffer,i as samples,l as webaudioOutput,m as webaudioOutputTrigger}; diff --git a/packages/core/examples/vite-vanilla-repl/dist/index.html b/packages/core/examples/vite-vanilla-repl/dist/index.html index 9544e82e..614a6b6c 100644 --- a/packages/core/examples/vite-vanilla-repl/dist/index.html +++ b/packages/core/examples/vite-vanilla-repl/dist/index.html @@ -4,7 +4,7 @@ Vite Vanilla Strudel REPL - +
diff --git a/packages/core/examples/vite-vanilla-repl/tune.mjs b/packages/core/examples/vite-vanilla-repl/tune.mjs index acdc0a62..88e8a7fe 100644 --- a/packages/core/examples/vite-vanilla-repl/tune.mjs +++ b/packages/core/examples/vite-vanilla-repl/tune.mjs @@ -1,4 +1,4 @@ -export default `await samples('github:tidalcycles/Dirt-Samples/master') +/* export default `await samples('github:tidalcycles/Dirt-Samples/master') stack( // amen @@ -29,3 +29,11 @@ stack( , n("0 1").s("east").delay(.5).degradeBy(.8).speed(rand.range(.5,1.5)) ).reset("")`; + */ + +export default `stack( + n("c3 [eb3,g3]") + .delay("<0 .5>") + .delaytime(".16 | .33") + .delayfeedback(".6 | .8") +).sometimes(x=>x.speed("-1"))`;