From 98f4d4de8b6e835eb33195a2796991870415dd33 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 13 Aug 2022 16:28:31 +0200 Subject: [PATCH] remove cps-sketch build --- .../cps-sketch/assets/index.8e4690f7.js | 21 ------------------- packages/webaudio/cps-sketch/index.html | 15 ------------- 2 files changed, 36 deletions(-) delete mode 100644 packages/webaudio/cps-sketch/assets/index.8e4690f7.js delete mode 100644 packages/webaudio/cps-sketch/index.html diff --git a/packages/webaudio/cps-sketch/assets/index.8e4690f7.js b/packages/webaudio/cps-sketch/assets/index.8e4690f7.js deleted file mode 100644 index 38dd5b0a..00000000 --- a/packages/webaudio/cps-sketch/assets/index.8e4690f7.js +++ /dev/null @@ -1,21 +0,0 @@ -var E=Object.defineProperty,V=Object.defineProperties;var R=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var L=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))J.call(t,n)&&L(e,n,t[n]);if(I)for(var n of I(t))D.call(t,n)&&L(e,n,t[n]);return e},C=(e,t)=>V(e,R(t));var M=(e,t,n)=>(L(e,typeof t!="symbol"?t+"":t,n),n);const p=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerpolicy&&(i.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?i.credentials="include":r.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}};p();function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default: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(e,t){(function(n){var o=2e3,r={s:1,n:0,d:1};function i(a,c){if(isNaN(a=parseInt(a,10)))throw y.InvalidParameter;return a*c}function s(a,c){if(c===0)throw y.DivisionByZero;var f=Object.create(y.prototype);f.s=a<0?-1:1,a=a<0?-a:a;var l=_(a,c);return f.n=a/l,f.d=c/l,f}function u(a){for(var c={},f=a,l=2,b=4;b<=f;){for(;f%l===0;)f/=l,c[l]=(c[l]||0)+1;b+=1+2*l++}return f!==a?f>1&&(c[f]=(c[f]||0)+1):c[a]=(c[a]||0)+1,c}var h=function(a,c){var f=0,l=1,b=1,P=0,k=0,F=0,j=1,T=1,w=0,g=1,A=1,B=1,q=1e7,W;if(a!=null)if(c!==void 0){if(f=a,l=c,b=f*l,f%1!==0||l%1!==0)throw y.NonIntegerParameter}else switch(typeof a){case"object":{if("d"in a&&"n"in a)f=a.n,l=a.d,"s"in a&&(f*=a.s);else if(0 in a)f=a[0],1 in a&&(l=a[1]);else throw y.InvalidParameter;b=f*l;break}case"number":{if(a<0&&(b=a,a=-a),a%1===0)f=a;else if(a>0){for(a>=1&&(T=Math.pow(10,Math.floor(1+Math.log(a)/Math.LN10)),a/=T);g<=q&&B<=q;)if(W=(w+A)/(g+B),a===W){g+B<=q?(f=w+A,l=g+B):B>g?(f=A,l=B):(f=w,l=g);break}else a>W?(w+=A,g+=B):(A+=w,B+=g),g>q?(f=A,l=B):(f=w,l=g);f*=T}else(isNaN(a)||isNaN(c))&&(l=f=NaN);break}case"string":{if(g=a.match(/\d+|./g),g===null)throw y.InvalidParameter;if(g[w]==="-"?(b=-1,w++):g[w]==="+"&&w++,g.length===w+1?k=i(g[w++],b):g[w+1]==="."||g[w]==="."?(g[w]!=="."&&(P=i(g[w++],b)),w++,(w+1===g.length||g[w+1]==="("&&g[w+3]===")"||g[w+1]==="'"&&g[w+3]==="'")&&(k=i(g[w],b),j=Math.pow(10,g[w].length),w++),(g[w]==="("&&g[w+2]===")"||g[w]==="'"&&g[w+2]==="'")&&(F=i(g[w+1],b),T=Math.pow(10,g[w+1].length)-1,w+=3)):g[w+1]==="/"||g[w+1]===":"?(k=i(g[w],b),j=i(g[w+2],1),w+=3):g[w+3]==="/"&&g[w+1]===" "&&(P=i(g[w],b),k=i(g[w+2],b),j=i(g[w+4],1),w+=5),g.length<=w){l=j*T,b=f=F+l*P+T*k;break}}default:throw y.InvalidParameter}if(l===0)throw y.DivisionByZero;r.s=b<0?-1:1,r.n=Math.abs(f),r.d=Math.abs(l)};function m(a,c,f){for(var l=1;c>0;a=a*a%f,c>>=1)c&1&&(l=l*a%f);return l}function d(a,c){for(;c%2===0;c/=2);for(;c%5===0;c/=5);if(c===1)return 0;for(var f=10%c,l=1;f!==1;l++)if(f=f*10%c,l>o)return 0;return l}function v(a,c,f){for(var l=1,b=m(10,f,c),P=0;P<300;P++){if(l===b)return P;l=l*10%c,b=b*10%c}return 0}function _(a,c){if(!a)return c;if(!c)return a;for(;;){if(a%=c,!a)return c;if(c%=a,!c)return a}}function y(a,c){if(h(a,c),this instanceof y)a=_(r.d,r.n),this.s=r.s,this.n=r.n/a,this.d=r.d/a;else return s(r.s*r.n,r.d)}y.DivisionByZero=new Error("Division by Zero"),y.InvalidParameter=new Error("Invalid argument"),y.NonIntegerParameter=new Error("Parameters must be integer"),y.prototype={s:1,n:0,d:1,abs:function(){return s(this.n,this.d)},neg:function(){return s(-this.s*this.n,this.d)},add:function(a,c){return h(a,c),s(this.s*this.n*r.d+r.s*this.d*r.n,this.d*r.d)},sub:function(a,c){return h(a,c),s(this.s*this.n*r.d-r.s*this.d*r.n,this.d*r.d)},mul:function(a,c){return h(a,c),s(this.s*r.s*this.n*r.n,this.d*r.d)},div:function(a,c){return h(a,c),s(this.s*r.s*this.n*r.d,this.d*r.n)},clone:function(){return s(this.s*this.n,this.d)},mod:function(a,c){if(isNaN(this.n)||isNaN(this.d))return new y(NaN);if(a===void 0)return s(this.s*this.n%this.d,1);if(h(a,c),r.n===0&&this.d===0)throw y.DivisionByZero;return s(this.s*(r.d*this.n)%(r.n*this.d),r.d*this.d)},gcd:function(a,c){return h(a,c),s(_(r.n,this.n)*_(r.d,this.d),r.d*this.d)},lcm:function(a,c){return h(a,c),r.n===0&&this.n===0?s(0,1):s(r.n*this.n,_(r.n,this.n)*_(r.d,this.d))},ceil:function(a){return a=Math.pow(10,a||0),isNaN(this.n)||isNaN(this.d)?new y(NaN):s(Math.ceil(a*this.s*this.n/this.d),a)},floor:function(a){return a=Math.pow(10,a||0),isNaN(this.n)||isNaN(this.d)?new y(NaN):s(Math.floor(a*this.s*this.n/this.d),a)},round:function(a){return a=Math.pow(10,a||0),isNaN(this.n)||isNaN(this.d)?new y(NaN):s(Math.round(a*this.s*this.n/this.d),a)},inverse:function(){return s(this.s*this.d,this.n)},pow:function(a,c){if(h(a,c),r.d===1)return r.s<0?s(Math.pow(this.s*this.d,r.n),Math.pow(this.n,r.n)):s(Math.pow(this.s*this.n,r.n),Math.pow(this.d,r.n));if(this.s<0)return null;var f=u(this.n),l=u(this.d),b=1,P=1;for(var k in f)if(k!=="1"){if(k==="0"){b=0;break}if(f[k]*=r.n,f[k]%r.d===0)f[k]/=r.d;else return null;b*=Math.pow(k,f[k])}for(var k in l)if(k!=="1"){if(l[k]*=r.n,l[k]%r.d===0)l[k]/=r.d;else return null;P*=Math.pow(k,l[k])}return r.s<0?s(P,b):s(b,P)},equals:function(a,c){return h(a,c),this.s*this.n*r.d===r.s*r.n*this.d},compare:function(a,c){h(a,c);var f=this.s*this.n*r.d-r.s*r.n*this.d;return(0=0;P--)b=b.inverse().add(f[P]);if(b.sub(c).abs().valueOf()0&&(f+=c,f+=" ",l%=b),f+=l,f+="/",f+=b),f},toLatex:function(a){var c,f="",l=this.n,b=this.d;return this.s<0&&(f+="-"),b===1?f+=l:(a&&(c=Math.floor(l/b))>0&&(f+=c,l%=b),f+="\\frac{",f+=l,f+="}{",f+=b,f+="}"),f},toContinued:function(){var a,c=this.n,f=this.d,l=[];if(isNaN(c)||isNaN(f))return l;do l.push(Math.floor(c/f)),a=c%f,c=f,f=a;while(c!==1);return l},toString:function(a){var c=this.n,f=this.d;if(isNaN(c)||isNaN(f))return"NaN";a=a||15;var l=d(c,f),b=v(c,f,l),P=this.s<0?"-":"";if(P+=c/f|0,c%=f,c*=10,c&&(P+="."),l){for(var k=b;k--;)P+=c/f|0,c%=f,c*=10;P+="(";for(var k=l;k--;)P+=c/f|0,c%=f,c*=10;P+=")"}else for(var k=a;c&&k--;)P+=c/f|0,c%=f,c*=10;return P}},Object.defineProperty(y,"__esModule",{value:!0}),y.default=y,y.Fraction=y,e.exports=y})()})(fraction$1);var Fraction=getDefaultExportFromCjs(fraction$1.exports);Fraction.prototype.sam=function(){return this.floor()};Fraction.prototype.nextSam=function(){return this.sam().add(1)};Fraction.prototype.wholeCycle=function(){return new TimeSpan(this.sam(),this.nextSam())};Fraction.prototype.cyclePos=function(){return this.sub(this.sam())};Fraction.prototype.lt=function(e){return this.compare(e)<0};Fraction.prototype.gt=function(e){return this.compare(e)>0};Fraction.prototype.lte=function(e){return this.compare(e)<=0};Fraction.prototype.gte=function(e){return this.compare(e)>=0};Fraction.prototype.eq=function(e){return this.compare(e)==0};Fraction.prototype.max=function(e){return this.gt(e)?this:e};Fraction.prototype.min=function(e){return this.lt(e)?this:e};Fraction.prototype.show=function(){return this.s*this.n+"/"+this.d};Fraction.prototype.or=function(e){return this.eq(0)?e:this};const fraction=e=>(typeof e=="number"&&(e=String(e)),Fraction(e)),gcd=(...e)=>e.reduce((t,n)=>t.gcd(n),fraction(1));fraction._original=Fraction;class TimeSpan{constructor(t,n){this.begin=fraction(t),this.end=fraction(n)}get spanCycles(){const t=[];var n=this.begin;const o=this.end,r=o.sam();for(;o.gt(n);){if(n.sam().equals(r)){t.push(new TimeSpan(n,this.end));break}const i=n.nextSam();t.push(new TimeSpan(n,i)),n=i}return t}get duration(){return this.end.sub(this.begin)}cycleArc(){const t=this.begin.cyclePos(),n=t.add(this.duration);return new TimeSpan(t,n)}withTime(t){return new TimeSpan(t(this.begin),t(this.end))}withEnd(t){return new TimeSpan(this.begin,t(this.end))}withCycle(t){const n=this.begin.sam(),o=n.add(t(this.begin.sub(n))),r=n.add(t(this.end.sub(n)));return new TimeSpan(o,r)}intersection(t){const n=this.begin.max(t.begin),o=this.end.min(t.end);if(!n.gt(o)&&!(n.equals(o)&&(n.equals(this.end)&&this.begin.lt(this.end)||n.equals(t.end)&&t.begin.lt(t.end))))return new TimeSpan(n,o)}intersection_e(t){const n=this.intersection(t);if(n==null)throw"TimeSpans do not intersect";return n}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,n,o,r={},i=!1){this.whole=t,this.part=n,this.value=o,this.context=r,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 n=this.whole?t(this.whole):void 0;return new Hap(n,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 n=this.value,[o,r]=n(t);return[o,new Hap(this.whole,this.part,r,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 n=this;return C(S(S({},n.context),t.context),{locations:(n.context.locations||[]).concat(t.context.locations||[])})}setContext(t){return new Hap(this.whole,this.part,this.value,t)}}class State{constructor(t,n={}){this.span=t,this.controls=n}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=e=>/^[a-gA-G][#b]*[0-9]$/.test(e),tokenizeNote=e=>{var r;if(typeof e!="string")return[];const[t,n="",o]=((r=e.match(/^([a-gA-G])([#bs]*)([0-9])?$/))==null?void 0:r.slice(1))||[];return t?[t,n,o?Number(o):void 0]:[]},toMidi=e=>{const[t,n,o]=tokenizeNote(e);if(!t)throw new Error('not a note: "'+e+'"');const r={c:0,d:2,e:4,f:5,g:7,a:9,b:11}[t.toLowerCase()],i=(n==null?void 0:n.split("").reduce((s,u)=>s+{"#":1,b:-1,s:1}[u],0))||0;return(Number(o)+1)*12+r+i},fromMidi=e=>Math.pow(2,(e-69)/12)*440,getFreq=e=>fromMidi(typeof e=="number"?e:toMidi(e)),midi2note=e=>{const t=Math.floor(e/12)-1;return["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"][e%12]+t},mod=(e,t)=>(e%t+t)%t,getPlayableNoteValue=e=>{let{value:t,context:n}=e;if(typeof t=="number"&&n.type!=="frequency")t=fromMidi(e.value);else if(typeof t!="string"||!isNote(t))throw new Error("not a note: "+JSON.stringify(t));return t},getFrequency=e=>{let{value:t,context:n}=e;if(typeof t=="object"&&t.freq)return t.freq;if(typeof t=="number"&&n.type!=="frequency")t=fromMidi(e.value);else if(typeof t=="string"&&isNote(t))t=fromMidi(toMidi(e.value));else if(typeof t!="number")throw new Error("not a note or frequency:"+t);return t},rotate=(e,t)=>e.slice(t).concat(e.slice(0,t)),pipe=(...e)=>e.reduce((t,n)=>(...o)=>t(n(...o)),t=>t),compose=(...e)=>pipe(...e.reverse()),removeUndefineds=e=>e.filter(t=>t!=null),flatten=e=>[].concat(...e),id=e=>e,constant=(e,t)=>e,listRange=(e,t)=>Array.from({length:t-e+1},(n,o)=>o+e);function curry(e,t){const n=function o(...r){if(r.length>=e.length)return e.apply(this,r);{const i=function(...s){return o.apply(this,r.concat(s))};return t&&t(i,r),i}};return t&&t(n,[]),n}function unionWithObj(e,t,n){const o=Object.keys(e).filter(r=>Object.keys(t).includes(r));return Object.assign({},e,t,Object.fromEntries(o.map(r=>[r,n(e[r],t[r])])))}curry((e,t)=>e*t);curry((e,t)=>t.map(e));function drawLine(e,t=60){let n=0,o=fraction(0),r=[""],i="";for(;r[0].lengthd.hasOnset()).map(d=>d.duration),h=gcd(...u),m=h.inverse();r=r.map(d=>d+"|"),i+="|";for(let d=0;dc.whole.begin.lte(v)&&c.whole.end.gte(_)),a=y.length-r.length;a>0&&(r=r.concat(Array(a).fill(i))),r=r.map((c,f)=>{const l=y[f];if(l){const P=l.whole.begin.eq(v)?""+l.value:"-";return c+P}return c+"."}),i+=".",o=o.add(h)}n++}return r.join(` -`)}class Pattern$1{constructor(t){M(this,"_Pattern",!0);this.query=t}queryArc(t,n){return this.query(new State(new TimeSpan(t,n)))}_splitQueries(){const t=this,n=o=>flatten(o.span.spanCycles.map(r=>t.query(o.setSpan(r))));return new Pattern$1(n)}withQuerySpan(t){return new Pattern$1(n=>this.query(n.withSpan(t)))}withQueryTime(t){return new Pattern$1(n=>this.query(n.withSpan(o=>o.withTime(t))))}withHapSpan(t){return new Pattern$1(n=>this.query(n).map(o=>o.withSpan(t)))}withHapTime(t){return this.withHapSpan(n=>n.withTime(t))}_withHaps(t){return new Pattern$1(n=>t(this.query(n)))}_withHap(t){return this._withHaps(n=>n.map(t))}_setContext(t){return this._withHap(n=>n.setContext(t))}_withContext(t){return this._withHap(n=>n.setContext(t(n.context)))}_stripContext(){return this._withHap(t=>t.setContext({}))}withLocation(t,n){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:n[0],column:n[1],offset:n[2]}};return this._withContext(r=>{const i=(r.locations||[]).concat([o]);return C(S({},r),{locations:i})})}withMiniLocation(t,n){const o={start:{line:t[0],column:t[1],offset:t[2]},end:{line:n[0],column:n[1],offset:n[2]}};return this._withContext(r=>{let i=r.locations||[];return i=i.map(({start:s,end:u})=>{const h=s.line===1?o.start.column:0;return{start:C(S({},s),{line:s.line-1+(o.start.line-1)+1,column:s.column-1+h}),end:C(S({},u),{line:u.line-1+(o.start.line-1)+1,column:u.column-1+h})}}),C(S({},r),{locations:i})})}withValue(t){return new Pattern$1(n=>this.query(n).map(o=>o.withValue(t)))}fmap(t){return this.withValue(t)}_filterHaps(t){return new Pattern$1(n=>this.query(n).filter(t))}_filterValues(t){return new Pattern$1(n=>this.query(n).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,n){const o=this,r=function(i){const s=o.query(i),u=n.query(i),h=function(m,d){const v=m.part.intersection(d.part);if(v!=null)return new Hap(t(m.whole,d.whole),v,m.value(d.value),d.combineContext(m))};return flatten(s.map(m=>removeUndefineds(u.map(d=>h(m,d)))))};return new Pattern$1(r)}appBoth(t){const n=function(o,r){if(!(o==null||r==null))return o.intersection_e(r)};return this._appWhole(n,t)}appLeft(t){const n=this,o=function(r){const i=[];for(const s of n.query(r)){const u=t.query(r.setSpan(s.wholeOrPart()));for(const h of u){const m=s.whole,d=s.part.intersection(h.part);if(d){const v=s.value(h.value),_=h.combineContext(s),y=new Hap(m,d,v,_);i.push(y)}}}return i};return new Pattern$1(o)}appRight(t){const n=this,o=function(r){const i=[];for(const s of t.query(r)){const u=n.query(r.setSpan(s.wholeOrPart()));for(const h of u){const m=s.whole,d=h.part.intersection(s.part);if(d){const v=h.value(s.value),_=s.combineContext(h),y=new Hap(m,d,v,_);i.push(y)}}}return i};return new Pattern$1(o)}firstCycle(t=!1){var n=this;return t||(n=n._stripContext()),n.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((n,o)=>n.part.begin.sub(o.part.begin).or(n.part.end.sub(o.part.end)).or(n.whole.begin.sub(o.whole.begin).or(n.whole.end.sub(o.whole.end)))))}_opIn(t,n){return this.fmap(n).appLeft(reify$1(t))}_opOut(t,n){return this.fmap(n).appRight(reify$1(t))}_opMix(t,n){return this.fmap(n).appBoth(reify$1(t))}_opSqueeze(t,n){const o=reify$1(t);return this.fmap(r=>o.fmap(i=>n(r)(i)))._squeezeJoin()}_opSqueezeOut(t,n){const o=this;return reify$1(t).fmap(i=>o.fmap(s=>n(s)(i)))._squeezeJoin()}_opTrig(t,n){return reify$1(t).fmap(r=>this.fmap(i=>n(i)(r)))._trigJoin()}_opTrigzero(t,n){return reify$1(t).fmap(r=>this.fmap(i=>n(i)(r)))._TrigzeroJoin()}_asNumber(t=!1,n=!1){return this._withHap(o=>{const r=Number(o.value);if(!isNaN(r))return o.withValue(()=>r);const i={e:Math.E,pi:Math.PI}[o.value];if(typeof i!="undefined")return o.withValue(()=>i);if(isNote(o.value))return new Hap(o.whole,o.part,toMidi(o.value),C(S({},o.context),{type:"midi"}));if(!t){if(n)return o;throw new Error('cannot parse as number: "'+o.value+'"')}})}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,n){return this.mul(n-t).add(t)}rangex(t,n){return this.range(Math.log(t),Math.log(n)).fmap(Math.exp)}range2(t,n){return this._fromBipolar().range(t,n)}_bindWhole(t,n){const o=this,r=function(i){const s=function(h,m){return new Hap(t(h.whole,m.whole),m.part,m.value,Object.assign({},h.context,m.context,{locations:(h.context.locations||[]).concat(m.context.locations||[])}))},u=function(h){return n(h.value).query(i.setSpan(h.part)).map(m=>s(h,m))};return flatten(o.query(i).map(h=>u(h)))};return new Pattern$1(r)}bind(t){const n=function(o,r){if(!(o==null||r==null))return o.intersection_e(r)};return this._bindWhole(n,t)}join(){return this.bind(id)}outerBind(t){return this._bindWhole((n,o)=>n,t)}outerJoin(){return this.outerBind(id)}innerBind(t){return this._bindWhole((n,o)=>o,t)}innerJoin(){return this.innerBind(id)}_trigJoin(t=!1){const n=this;return new Pattern$1(o=>n.discreteOnly().query(o).map(r=>r.value.late(t?r.whole.begin:r.whole.begin.cyclePos()).query(o).map(i=>new Hap(i.whole?i.whole.intersection(r.whole):void 0,i.part.intersection(r.part),i.value).setContext(r.combineContext(i))).filter(i=>i.part)).flat())}_TrigzeroJoin(){return this._trigJoin(!0)}_squeezeJoin(){const t=this;function n(o){const r=t.discreteOnly().query(o);function i(u){const m=u.value._compressSpan(u.wholeOrPart().cycleArc()).query(o.setSpan(u.part));function d(v,_){let y;if(_.whole&&v.whole&&(y=_.whole.intersection(v.whole),!y))return;const a=_.part.intersection(v.part);if(!a)return;const c=_.combineContext(v);return new Hap(y,a,_.value,c)}return m.map(v=>d(u,v))}return flatten(r.map(i)).filter(u=>u)}return new Pattern$1(n)}_squeezeBind(t){return this.fmap(t)._squeezeJoin()}_apply(t){return t(this)}layer(...t){return stack(...t.map(n=>n(this)))}_patternify(t){const n=this;return function(...r){return r=r.map(s=>isPattern(s)?s.fmap(u=>u.value||u):s),sequence(...r).fmap(s=>t.call(n,s)).innerJoin()}}_fastGap(t){const n=function(r){const i=r.begin.sam(),s=i.add(r.begin.sub(i).mul(t).min(1)),u=i.add(r.end.sub(i).mul(t).min(1));return new TimeSpan(s,u)},o=function(r){const i=r.begin.sam(),s=i.add(r.begin.sub(i).div(t).min(1)),u=i.add(r.end.sub(i).div(t).min(1));return new TimeSpan(s,u)};return this.withQuerySpan(n).withHapSpan(o)._splitQueries()}_compress(t,n){return t.gt(n)||t.gt(1)||n.gt(1)||t.lt(0)||n.lt(0)?silence:this._fastGap(fraction(1).div(n.sub(t)))._late(t)}_compressSpan(t){return this._compress(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,n){return n(this._slow(t))._fast(t)}_outside(t,n){return n(this._fast(t))._slow(t)}_ply(t){return this.fmap(n=>pure(n)._fast(t))._squeezeJoin()}_chop(t){const o=Array.from({length:t},(i,s)=>s).map(i=>({begin:i/t,end:(i+1)/t})),r=function(i){return sequence(o.map(s=>Object.assign({},i,s)))};return this._squeezeBind(r)}_striate(t){const o=Array.from({length:t},(i,s)=>s).map(i=>({begin:i/t,end:(i+1)/t})),r=slowcat(...o);return this.set(r)._fast(t)}_cpm(t){return this._fast(t/60)}_early(t){return t=fraction(t),this.withQueryTime(n=>n.add(t)).withHapTime(n=>n.sub(t))}_late(t){return t=fraction(t),this._early(fraction(0).sub(t))}_zoom(t,n){n=fraction(n),t=fraction(t);const o=n.sub(t);return this.withQuerySpan(r=>r.withCycle(i=>i.mul(o).add(t))).withHapSpan(r=>r.withCycle(i=>i.sub(t).div(o)))._splitQueries()}_zoomArc(t){return this.zoom(t.begin,t.end)}_linger(t){return t==0?silence:t<0?this._zoom(t.add(1),1)._slow(t):this._zoom(0,t)._slow(t)}_color(t){return this._withContext(n=>C(S({},n),{color:t}))}log(){return this._withHap(t=>{var n;return t.setContext(C(S({},t.context),{logs:(((n=t.context)==null?void 0:n.logs)||[]).concat([t.show()])}))})}drawLine(){return console.log(drawLine(this)),this}_segment(t){return this.struct(pure(!0)._fast(t))}invert(){return this.fmap(t=>!t)}inv(){return this.invert()}when(t,n){const o=t._filterValues(id),r=t._filterValues(u=>!u),i=o.fmap(u=>h=>h).appRight(n(this)),s=r.fmap(u=>h=>h).appRight(this);return stack(i,s)}off(t,n){return stack(this,n(this.late(t)))}every(t,n){const o=this,r=Array(t-1).fill(o);return r.unshift(n(o)),slowcatPrime(...r)}brak(){return this.when(slowcat(!1,!0),t=>fastcat(t,silence)._late(.25))}rev(){const t=this,n=function(o){const r=o.span,i=r.begin.sam(),s=r.begin.nextSam(),u=function(m){const d=m.withTime(_=>i.add(s.sub(_))),v=d.begin;return d.begin=d.end,d.end=v,d};return t.query(o.setSpan(u(r))).map(m=>m.withSpan(u))};return new Pattern$1(n)._splitQueries()}palindrome(){return this.every(2,rev)}juxBy(t,n){t/=2;const o=function(s,u,h){return u in s?s[u]:h},r=this.withValue(s=>Object.assign({},s,{pan:o(s,"pan",.5)-t})),i=this.withValue(s=>Object.assign({},s,{pan:o(s,"pan",.5)+t}));return stack(r,n(i))}_jux(t){return this.juxBy(1,t)}stack(...t){return stack(this,...t)}sequence(...t){return sequence(this,...t)}seq(...t){return sequence(this,...t)}cat(...t){return cat(this,...t)}fastcat(...t){return fastcat(this,...t)}slowcat(...t){return slowcat(this,...t)}superimpose(...t){return this.stack(...t.map(n=>n(this)))}stutWith(t,n,o){return stack(...listRange(0,t-1).map(r=>o(this.late(fraction(n).mul(r)),r)))}stut(t,n,o){return this.stutWith(t,o,(r,i)=>r.velocity(Math.pow(n,i)))}_echoWith(t,n,o){return stack(...listRange(0,t-1).map(r=>o(this.late(fraction(n).mul(r)),r)))}_echo(t,n,o){return this._echoWith(t,n,(r,i)=>r.velocity(Math.pow(o,i)))}iter(t,n=!1){return slowcat(...listRange(0,t-1).map(o=>n?this.late(o/t):this.early(o/t)))}iterBack(t){return this.iter(t,!0)}_chunk(t,n,o=!1){const r=Array(t-1).fill(!1);r.unshift(!0);const i=sequence(...r).iter(t,o);return this.when(i,n)}_chunkBack(t,n){return this._chunk(t,n,!0)}_bypass(t){return t=Boolean(parseInt(t)),t?silence:this}hush(){return silence}_duration(t){return this.withHapSpan(n=>new TimeSpan(n.begin,n.begin.add(t)))}_legato(t){return this.withHapSpan(n=>new TimeSpan(n.begin,n.begin.add(n.end.sub(n.begin).mul(t))))}_velocity(t){return this._withContext(n=>C(S({},n),{velocity:(n.velocity||1)*t}))}_loopAt(t,n=1){return this.speed(1/t*n).unit("c").slow(t)}onTrigger(t){return this._withHap(n=>n.setContext(C(S({},n.context),{onTrigger:t})))}log(t=id){return this._withHap(n=>n.setContext(C(S({},n.context),{onTrigger:(...o)=>{n.context.onTrigger&&n.context.onTrigger(...o),console.log(t(...o))}})))}logValues(t=id){return this.log((n,o)=>t(o.value))}}function _composeOp(e,t,n){function o(r){return r instanceof Object&&!(r instanceof Function)}return o(e)||o(t)?(o(e)||(e={value:e}),o(t)||(t={value:t}),unionWithObj(e,t,n)):n(e,t)}(function(){const e=o=>o._asNumber(),n={set:[(o,r)=>r],keep:[(o,r)=>o],keepif:[(o,r)=>r?o:void 0],add:[(o,r)=>o+r,o=>o._asNumber(!1,!0)],sub:[(o,r)=>o-r,e],mul:[(o,r)=>o*r,e],div:[(o,r)=>o/r,e],mod:[mod,e],pow:[Math.pow,e],_and:[(o,r)=>o&r,e],_or:[(o,r)=>o|r,e],_xor:[(o,r)=>o^r,e],_lshift:[(o,r)=>o<o>>r,e],lt:[(o,r)=>oo>r],lte:[(o,r)=>o<=r],gte:[(o,r)=>o>=r],eq:[(o,r)=>o==r],eqt:[(o,r)=>o===r],ne:[(o,r)=>o!=r],net:[(o,r)=>o!==r],and:[(o,r)=>o&&r],or:[(o,r)=>o||r],func:[(o,r)=>r(o)]};for(const[o,[r,i]]of Object.entries(n))for(const s of["In","Out","Mix","Squeeze","SqueezeOut","Trig","Trigzero"])Pattern$1.prototype[o+s]=function(...u){var h=this;u=sequence(u),i&&(h=i(h),u=i(u));var m=h["_op"+s](u,d=>v=>_composeOp(d,v,r));return o==="keepif"&&(m=m._removeUndefineds()),m},s==="Squeeze"&&(Pattern$1.prototype[o+"SqueezeIn"]=Pattern$1.prototype[o+s]),s==="In"?Pattern$1.prototype[o]=Pattern$1.prototype[o+s]:o==="set"&&(Pattern$1.prototype[s.toLowerCase()]=Pattern$1.prototype[o+s]);Pattern$1.prototype.struct=Pattern$1.prototype.keepifOut,Pattern$1.prototype.structAll=Pattern$1.prototype.keepOut,Pattern$1.prototype.mask=Pattern$1.prototype.keepifIn,Pattern$1.prototype.maskAll=Pattern$1.prototype.keepIn,Pattern$1.prototype.reset=Pattern$1.prototype.keepifTrig,Pattern$1.prototype.resetAll=Pattern$1.prototype.keepTrig,Pattern$1.prototype.restart=Pattern$1.prototype.keepifTrigzero,Pattern$1.prototype.restartAll=Pattern$1.prototype.keepTrigzero})();Pattern$1.prototype.patternified=["apply","chop","color","cpm","duration","early","fast","jux","late","legato","linger","ply","segment","striate","slow","velocity"];Pattern$1.prototype.factories={pure,stack,slowcat,fastcat,cat,timeCat,sequence,seq,polymeter,pm,polyrhythm,pr};const silence=new Pattern$1(e=>[]);function pure(e){function t(n){return n.span.spanCycles.map(o=>new Hap(fraction(o.begin).wholeCycle(),o,e))}return new Pattern$1(t)}function isPattern(e){const t=e instanceof Pattern$1||e._Pattern;return!e instanceof Pattern$1&&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$1(e){return isPattern(e)?e:pure(e)}function stack(...e){e=e.map(n=>Array.isArray(n)?sequence(...n):reify$1(n));const t=n=>flatten(e.map(o=>o.query(n)));return new Pattern$1(t)}function slowcat(...e){e=e.map(n=>Array.isArray(n)?sequence(...n):reify$1(n));const t=function(n){const o=n.span,r=mod(o.begin.sam(),e.length),i=e[r];if(!i)return[];const s=o.begin.floor().sub(o.begin.div(e.length).floor());return i.withHapTime(u=>u.add(s)).query(n.setSpan(o.withTime(u=>u.sub(s))))};return new Pattern$1(t)._splitQueries()}function slowcatPrime(...e){e=e.map(reify$1);const t=function(n){const o=Math.floor(n.span.begin)%e.length,r=e[o];return(r==null?void 0:r.query(n))||[]};return new Pattern$1(t)._splitQueries()}function fastcat(...e){return slowcat(...e)._fast(e.length)}function cat(...e){return slowcat(...e)}function timeCat(...e){const t=e.map(r=>r[0]).reduce((r,i)=>r.add(i),fraction(0));let n=fraction(0);const o=[];for(const[r,i]of e){const s=n.add(r);o.push(reify$1(i)._compress(n.div(t),s.div(t))),n=s}return stack(...o)}function sequence(...e){return fastcat(...e)}function seq(...e){return fastcat(...e)}function _sequenceCount(e){return Array.isArray(e)?e.length==0?[silence,0]:e.length==1?_sequenceCount(e[0]):[fastcat(...e.map(t=>_sequenceCount(t)[0])),e.length]:[reify$1(e),1]}function polymeterSteps(e,...t){const n=t.map(r=>_sequenceCount(r));if(n.length==0)return silence;e==0&&(e=n[0][1]);const o=[];for(const r of n)r[1]==0&&next,e==r[1]?o.push(r[0]):o.push(r[0]._fast(fraction(e).div(fraction(r[1]))));return stack(...o)}function polymeter(...e){return polymeterSteps(0,...e)}function pm(...e){polymeter(...e)}function polyrhythm(...e){const t=e.map(n=>sequence(n));return t.length==0?silence:stack(...t)}function pr(e){polyrhythm(e)}const add=curry((e,t)=>t.add(e)),chop=curry((e,t)=>t.chop(e)),chunk=curry((e,t)=>t.chunk(e)),chunkBack=curry((e,t)=>t.chunkBack(e)),div=curry((e,t)=>t.div(e)),early=curry((e,t)=>t.early(e)),echo=curry((e,t,n,o)=>o.echo(e,t,n)),every=curry((e,t,n)=>n.every(e,t)),fast=curry((e,t)=>t.fast(e)),inv=e=>e.inv(),invert=e=>e.invert(),iter=curry((e,t)=>t.iter(e)),iterBack=curry((e,t)=>t.iter(e)),jux=curry((e,t)=>t.jux(e)),juxBy=curry((e,t,n)=>n.juxBy(e,t)),late=curry((e,t)=>t.late(e)),linger=curry((e,t)=>t.linger(e)),mask=curry((e,t)=>t.mask(e)),mul=curry((e,t)=>t.mul(e)),off=curry((e,t,n)=>n.off(e,t)),ply=curry((e,t)=>t.ply(e)),range=curry((e,t,n)=>n.range(e,t)),range2=curry((e,t,n)=>n.range2(e,t)),rev=e=>e.rev(),slow=curry((e,t)=>t.slow(e)),struct=curry((e,t)=>t.struct(e)),sub=curry((e,t)=>t.sub(e)),superimpose=curry((e,t)=>t.superimpose(...e)),set=curry((e,t)=>t.set(e)),when=curry((e,t,n)=>n.when(e,t));Pattern$1.prototype.composable={fast,slow,early,late,superimpose};function makeComposable(e){return Object.entries(Pattern$1.prototype.composable).forEach(([t,n])=>{e[t]=(...o)=>{const r=compose(e,n(...o));return makeComposable(r)}}),e}const patternify2=e=>(t,n,o)=>t.fmap(r=>i=>e.call(o,r,i)).appLeft(n).innerJoin(),patternify3=e=>(t,n,o,r)=>t.fmap(i=>s=>u=>e.call(r,i,s,u)).appLeft(n).appLeft(o).innerJoin(),patternify4=e=>(t,n,o,r,i)=>t.fmap(s=>u=>h=>m=>e.call(i,s,u,h,m)).appLeft(n).appLeft(o).appLeft(r).innerJoin();Pattern$1.prototype.echo=function(...e){return e=e.map(reify$1),patternify3(Pattern$1.prototype._echo)(...e,this)};Pattern$1.prototype.echoWith=function(...e){return e=e.map(reify$1),patternify3(Pattern$1.prototype._echoWith)(...e,this)};Pattern$1.prototype.chunk=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._chunk)(...e,this)};Pattern$1.prototype.chunkBack=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._chunkBack)(...e,this)};Pattern$1.prototype.loopAt=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._loopAt)(...e,this)};Pattern$1.prototype.zoom=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._zoom)(...e,this)};Pattern$1.prototype.compress=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._compress)(...e,this)};Pattern$1.prototype.outside=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._outside)(...e,this)};Pattern$1.prototype.inside=function(...e){return e=e.map(reify$1),patternify2(Pattern$1.prototype._inside)(...e,this)};Pattern$1.prototype.bootstrap=function(){const e=Object.fromEntries(Object.entries(Pattern$1.prototype.composable).map(([t,n])=>(Pattern$1.prototype[t]&&(Pattern$1.prototype[t]=makeComposable(Pattern$1.prototype[t])),[t,curry(n,makeComposable)])));return this.patternified.forEach(t=>{Pattern$1.prototype[t]=function(...n){return this._patternify(Pattern$1.prototype["_"+t])(...n)}}),e};Pattern$1.prototype.define=(e,t,n={})=>{n.composable&&(Pattern$1.prototype.composable[e]=t),n.patternified&&(Pattern$1.prototype.patternified=Pattern$1.prototype.patternified.concat([e])),Pattern$1.prototype.bootstrap()};Pattern$1.prototype.define("hush",e=>e.hush(),{patternified:!1,composable:!0});Pattern$1.prototype.define("bypass",e=>e.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","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","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=(e,...t)=>sequence(...t).withValue(n=>({[e]:n})),_setter=(e,t)=>function(...n){return n.length?this.set(e(...n)):this.fmap(o=>({[t]:o}))};generic_params.forEach(([e,t,n])=>{controls[t]=(...o)=>_name(t,...o),Pattern$1.prototype[t]=_setter(controls[t],t)});controls.createParam=e=>{const t=(...n)=>_name(e,...n);return Pattern$1.prototype[e]=_setter(t,e),(...n)=>_name(e,...n)};controls.createParams=(...e)=>e.reduce((t,n)=>Object.assign(t,{[n]:createParam(n)}),{});function bjorklund(e,t){for(var n=[],o=[],r=[t],i=e-t,s=0,u=function(h){if(h==-1)n.push(0);else if(h==-2)n.push(1);else{for(var m=0;m1;)o.push(Math.floor(i/r[s])),r.push(i%r[s]),i=r[s],s++;return o.push(i),u(s),n.reverse()}var bjork=function(e,t){return e>t?bjorklund(e,t):bjorklund(t,e)};const euclid=(e,t,n=0)=>{const o=bjork(t,e);return n?rotate(o,-n):o};Pattern$1.prototype.euclid=function(e,t,n=0){return this.struct(euclid(e,t,n))};Pattern$1.prototype.euclidLegato=function(e,t,n=0){const o=euclid(e,t,n),r=o.indexOf(1),i=rotate(o,r).join("").split("1").slice(1).map(s=>[s.length+1,!0]);return this.struct(timeCat(...i)).late(fraction(r).div(t))};function steady(e){return new Pattern$1(t=>[new Hap(void 0,t.span,e)])}const signal=e=>{const t=n=>[new Hap(void 0,n.span,e(n.span.midpoint()))];return new Pattern$1(t)},isaw=signal(e=>1-e%1),isaw2=isaw._toBipolar(),saw=signal(e=>e%1),saw2=saw._toBipolar(),sine2=signal(e=>Math.sin(Math.PI*2*e)),sine=sine2._fromBipolar(),cosine=sine._early(fraction(1).div(4)),cosine2=sine2._early(fraction(1).div(4)),square=signal(e=>Math.floor(e*2%2)),square2=square._toBipolar(),tri=fastcat(isaw,saw),tri2=fastcat(isaw2,saw2),time=signal(id),xorwise=e=>{const t=e<<13^e,n=t>>17^t;return n<<5^n},_frac=e=>e-Math.trunc(e),timeToIntSeed=e=>xorwise(Math.trunc(_frac(e/300)*536870912)),intSeedToRand=e=>e%536870912/536870912,timeToRand=e=>Math.abs(intSeedToRand(timeToIntSeed(e))),rand=signal(timeToRand),rand2=rand._toBipolar(),_brandBy=e=>rand.fmap(t=>treify$1(e).fmap(_brandBy).innerJoin(),brand=_brandBy(.5),_irand=e=>rand.fmap(t=>Math.trunc(t*e)),irand=e=>reify$1(e).fmap(_irand).innerJoin(),__chooseWith=(e,t)=>(t=t.map(reify$1),t.length==0?silence:e.range(0,t.length).fmap(n=>t[Math.floor(n)])),chooseWith=(e,t)=>__chooseWith(e,t).outerJoin(),chooseInWith=(e,t)=>__chooseWith(e,t).innerJoin(),choose=(...e)=>chooseWith(rand,e);Pattern$1.prototype.choose=function(...e){return chooseWith(this,e)};Pattern$1.prototype.choose2=function(...e){return chooseWith(this._fromBipolar(),e)};const chooseCycles=(...e)=>chooseInWith(rand.segment(1),e),randcat=chooseCycles,_wchooseWith=function(e,...t){const n=t.map(u=>reify$1(u[0])),o=[];let r=0;for(const u of t)r+=u[1],o.push(r);const i=r,s=function(u){const h=u*i;return n[o.findIndex(m=>m>h,o)]};return e.fmap(s)},wchooseWith=(...e)=>_wchooseWith(...e).outerJoin(),wchoose=(...e)=>wchooseWith(rand,...e),wchooseCycles=(...e)=>_wchooseWith(rand,...e).innerJoin(),perlinWith=e=>{const t=e.fmap(Math.floor),n=e.fmap(i=>Math.floor(i)+1),o=i=>6*i**5-15*i**4+10*i**3,r=i=>s=>u=>s+o(i)*(u-s);return e.sub(t).fmap(r).appBoth(t.fmap(timeToRand)).appBoth(n.fmap(timeToRand))},perlin=perlinWith(time);Pattern$1.prototype._degradeByWith=function(e,t){return this.fmap(n=>o=>n).appLeft(e._filterValues(n=>n>t))};Pattern$1.prototype._degradeBy=function(e){return this._degradeByWith(rand,e)};Pattern$1.prototype.degrade=function(){return this._degradeBy(.5)};Pattern$1.prototype._undegradeBy=function(e){return this._degradeByWith(rand.fmap(t=>1-t),e)};Pattern$1.prototype.undegrade=function(){return this._undegradeBy(.5)};Pattern$1.prototype._sometimesBy=function(e,t){return stack(this._degradeBy(e),t(this._undegradeBy(1-e)))};Pattern$1.prototype.sometimesBy=function(e,t){const n=this;return reify$1(e).fmap(o=>n._sometimesBy(o,t)).innerJoin()};Pattern$1.prototype._sometimesByPre=function(e,t){return stack(this._degradeBy(e),t(this).undegradeBy(1-e))};Pattern$1.prototype.sometimesByPre=function(e,t){const n=this;return reify$1(e).fmap(o=>n._sometimesByPre(o,t)).innerJoin()};Pattern$1.prototype.sometimes=function(e){return this._sometimesBy(.5,e)};Pattern$1.prototype.sometimesPre=function(e){return this._sometimesByPre(.5,e)};Pattern$1.prototype._someCyclesBy=function(e,t){return stack(this._degradeByWith(rand._segment(1),e),t(this._degradeByWith(rand.fmap(n=>1-n)._segment(1),1-e)))};Pattern$1.prototype.someCyclesBy=function(e,t){const n=this;return reify$1(e).fmap(o=>n._someCyclesBy(o,t)).innerJoin()};Pattern$1.prototype.someCycles=function(e){return this._someCyclesBy(.5,e)};Pattern$1.prototype.often=function(e){return this.sometimesBy(.75,e)};Pattern$1.prototype.rarely=function(e){return this.sometimesBy(.25,e)};Pattern$1.prototype.almostNever=function(e){return this.sometimesBy(.1,e)};Pattern$1.prototype.almostAlways=function(e){return this.sometimesBy(.9,e)};Pattern$1.prototype.never=function(e){return this};Pattern$1.prototype.always=function(e){return e(this)};Pattern$1.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(e,t,n){synth.cancel();const o=new SpeechSynthesisUtterance(e);o.lang=t,allVoices=synth.getVoices();const r=allVoices.filter(i=>i.lang.includes(t));typeof n=="number"?o.voice=r[n%r.length]:typeof n=="string"&&(o.voice=r.find(i=>i.name===i)),speechSynthesis.speak(o)}Pattern$1.prototype._speak=function(e,t){return this._withHap(n=>{const o=(r,i)=>{speak(i.value,e,t)};return n.setContext(C(S({},n.context),{onTrigger:o}))})};Pattern$1.prototype.speak=function(e,t){return patternify2(Pattern$1.prototype._speak)(reify(e),reify(t),this)};var gist=(route,cache=!0)=>fetch(`https://gist.githubusercontent.com/${route}?cachebust=${cache?"":Date.now()}`).then(e=>e.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;var strudel=Object.freeze(Object.defineProperty({__proto__:null,Fraction:fraction,gist,Hap,Pattern:Pattern$1,silence,pure,isPattern,reify:reify$1,stack,slowcat,slowcatPrime,fastcat,cat,timeCat,sequence,seq,polymeterSteps,polymeter,pm,polyrhythm,pr,add,chop,chunk,chunkBack,div,early,echo,every,fast,inv,invert,iter,iterBack,jux,juxBy,late,linger,mask,mul,off,ply,range,range2,rev,slow,struct,sub,superimpose,set,when,makeComposable,patternify2,patternify3,patternify4,steady,signal,isaw,isaw2,saw,saw2,sine2,sine,cosine,cosine2,square,square2,tri,tri2,time,rand,rand2,_brandBy,brandBy,brand,_irand,irand,__chooseWith,chooseWith,chooseInWith,choose,chooseCycles,randcat,wchoose,wchooseCycles,perlinWith,perlin,State,TimeSpan,isNote,tokenizeNote,toMidi,fromMidi,getFreq,midi2note,mod,getPlayableNoteValue,getFrequency,rotate,pipe,compose,removeUndefineds,flatten,id,constant,listRange,curry},Symbol.toStringTag,{value:"Module"}));const stringifyFunction=e=>"("+e+")();",urlifyFunction=e=>URL.createObjectURL(new Blob([stringifyFunction(e)],{type:"text/javascript"})),createWorker=e=>new Worker(urlifyFunction(e));class ClockWorker{constructor(t,n=this.interval){M(this,"worker");M(this,"interval",.1);M(this,"tick",0);this.interval=n,this.worker=createWorker(()=>{let o,r=null;const i=()=>{r&&(clearInterval(r),r=null)},s=()=>{if(i(),!o)throw new Error("no interval set! call worker.postMessage({interval}) before starting.");postMessage("tick"),r=setInterval(()=>postMessage("tick"),o*1e3)};self.onmessage=function(u){u.data=="start"?s():u.data.interval?(o=u.data.interval,r&&s()):u.data=="stop"&&i()}}),this.worker.postMessage({interval:n}),this.worker.onmessage=o=>{o.data==="tick"&&t(this.tick++,this.interval)}}start(){this.worker.postMessage("start")}stop(){this.worker.postMessage("stop"),this.tick=0}setInterval(t){this.worker.postMessage({interval:t})}}class Scheduler{constructor({audioContext:t,interval:n=.1,onEvent:o,latency:r=.1}){M(this,"worker");M(this,"pattern");M(this,"phase");M(this,"audioContext");M(this,"cps",1);this.audioContext=t,this.worker=new ClockWorker((i,s)=>{const u=this.phase,h=this.phase+s*this.cps;this.phase=h,this.pattern.queryArc(u,h).forEach(d=>{var v,_;if(typeof((v=d.value)==null?void 0:v.cps)=="number"&&this.setCps((_=d.value)==null?void 0:_.cps),!!d.part.begin.equals(d.whole.begin)){if(d.context.onTrigger){const y=(d.whole.begin-u)/this.cps+this.audioContext.currentTime+r;d.context.onTrigger(y,d,this.audioContext.currentTime,this.cps)}o&&(o==null||o(d))}})},n)}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.audioContext.resume(),this.phase=0,this.worker.start()}stop(){this.worker.stop()}setPattern(t){this.pattern=t}setCps(t=1){this.cps=t}}const bufferCache={},loadCache={},loadBuffer=(e,t)=>(loadCache[e]||(loadCache[e]=fetch(e).then(n=>n.arrayBuffer()).then(async n=>{const o=await t.decodeAudioData(n);return bufferCache[e]=o,o})),loadCache[e]),{Pattern}=strudel;let audioContext;const getAudioContext=()=>(audioContext||(audioContext=new AudioContext),audioContext),getFilter=(e,t,n)=>{const o=getAudioContext().createBiquadFilter();return o.type=e,o.frequency.value=t,o.Q.value=n,o},getADSR=(e,t,n,o,r,i,s)=>{const u=getAudioContext().createGain();return u.gain.setValueAtTime(0,i),u.gain.linearRampToValueAtTime(r,i+e),u.gain.linearRampToValueAtTime(n*r,i+e+t),u.gain.setValueAtTime(n*r,s),u.gain.linearRampToValueAtTime(0,s+o),u},getOscillator=({s:e,freq:t,t:n,duration:o,release:r})=>{const i=getAudioContext().createOscillator();return i.type=e||"triangle",i.frequency.value=Number(t),i.start(n),i.stop(n+o+r),i},getSoundfontKey=e=>{var o,r,i,s;if(!globalThis.soundfontList)return!1;if((r=(o=globalThis.soundfontList)==null?void 0:o.instruments)!=null&&r.includes(e))return e;const t=(s=(i=globalThis.soundfontList)==null?void 0:i.instrumentNames)==null?void 0:s.indexOf(e),n=t<10?`00${t}`:t<100?`0${t}`:t;if(t!==-1)return globalThis.soundfontList.instruments.find(u=>u.startsWith(n))},getSampleBufferSource=async(e,t,n)=>{let o=0;n&&(o=toMidi(n)-36);const r=getAudioContext(),i=getLoadedSamples();if(!i)throw new Error("no samples loaded");const s=i==null?void 0:i[e];if(!s)throw new Error("sample not found:",e,"try one of "+Object.keys(i));if(typeof s!="object")throw new Error("wrong format for sample bank:",e);let u;if(Array.isArray(s))u=s[t%s.length];else{if(!n)throw new Error("no note(...) set for sound",e);const v=y=>toMidi(y)-toMidi(n),_=Object.keys(s).filter(y=>!y.startsWith("_")).reduce((y,a,c)=>!y||Math.abs(v(a)){if(!e.includes(":"))return[e,t];let[n,o]=e.split(":");return isNaN(Number(o))?[e,t]:[n,o]};Pattern.prototype.out=function(){return this.onTrigger(async(e,t,n,o)=>{const r=t.duration/o;try{const i=getAudioContext();e=i.currentTime+e-n;let{freq:s,s:u,sf:h,clip:m=0,n:d=0,note:v,gain:_=1,cutoff:y,resonance:a=1,hcutoff:c,hresonance:f=1,bandf:l,bandq:b=1,pan:P,attack:k=.001,decay:F=.05,sustain:j=.5,release:T=.001,speed:w=1,begin:g=0,end:A=1}=t.value;const{velocity:B=1}=t.context;_*=B;const q=[];if(typeof u=="string"&&([u,d]=splitSN(u,d)),typeof v=="string"&&([v,d]=splitSN(v,d)),!u||["sine","square","triangle","sawtooth"].includes(u)){d=v||d,typeof d=="string"&&(d=toMidi(d)),!s&&typeof d=="number"&&(s=fromMidi(d));const x=getOscillator({t:e,s:u,freq:s,duration:r,release:T});q.push(x);const $=i.createGain();$.gain.value=.3,q.push($);const N=getADSR(k,F,j,T,1,e,e+r);q.push(N)}else{if(w===0)return;if(!u){console.warn("no sample specified");return}const x=getSoundfontKey(u);let $;try{x?$=await globalThis.getFontBufferSource(x,v||d,i):$=await getSampleBufferSource(u,d,v)}catch(O){console.warn(O);return}if(i.currentTime>e){console.warn("sample still loading:",u,d);return}if(!$){console.warn("no buffer source");return}$.playbackRate.value=Math.abs(w)*$.playbackRate.value;let N=x||m?r:$.buffer.duration;const z=g*N;if(N=(A-g)*N/Math.abs(w),x||m?$.start(e,z):$.start(e,z,N),q.push($),x||m){const O=i.createGain(),H=.1;O.gain.value=.6,O.gain.setValueAtTime(O.gain.value,e+N),O.gain.linearRampToValueAtTime(0,e+N+H),q.push(O),$.stop(e+N+H)}else $.stop(e+N)}const W=i.createGain();if(W.gain.value=_,q.push(W),y!==void 0&&q.push(getFilter("lowpass",y,a)),c!==void 0&&q.push(getFilter("highpass",c,f)),l!==void 0&&q.push(getFilter("bandpass",l,b)),P!==void 0){const x=i.createStereoPanner();x.pan.value=2*P-1,q.push(x)}q.push(i.destination),q.slice(1).reduce((x,$)=>x.connect($),q[0])}catch(i){console.warn(".out error:",i)}})};document.body.style="margin: 0";Object.assign(window,strudel);const scheduler=new Scheduler({audioContext:getAudioContext(),interval:.1,onEvent:e=>{var t,n;(n=(t=e.context)==null?void 0:t.createAudioNode)==null||n.call(t,e)}});let initialCode=`sequence(1,2).mul(55/2) // frequencies -.mul(slowcat(1,2)) -.mul(slowcat(1,3/2,4/3,5/3).slow(8)) -.fast(3) -.freq() -.velocity(.5) -.s('sawtooth') -.cutoff(800) -.out() -`;try{const e=decodeURIComponent(window.location.href.split("#")[1]);initialCode=atob(e)}catch(e){console.warn("failed to decode",e)}const input=document.getElementById("text");input.value=initialCode;const evaluate=()=>{try{const pattern=eval(input.value);scheduler.setPattern(pattern),window.location.hash="#"+encodeURIComponent(btoa(input.value))}catch(e){console.warn(e)}};evaluate();input.addEventListener("input",()=>evaluate());document.getElementById("start").addEventListener("click",()=>scheduler.start());document.getElementById("stop").addEventListener("click",()=>scheduler.stop());document.getElementById("slower").addEventListener("click",()=>scheduler.setCps(scheduler.cps-.1));document.getElementById("faster").addEventListener("click",()=>scheduler.setCps(scheduler.cps+.1)); diff --git a/packages/webaudio/cps-sketch/index.html b/packages/webaudio/cps-sketch/index.html deleted file mode 100644 index 2c5ca96e..00000000 --- a/packages/webaudio/cps-sketch/index.html +++ /dev/null @@ -1,15 +0,0 @@ - -
-
-
- - -
- -