mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-23 21:47:16 -04:00
Updates
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1 @@
|
||||
var x=Object.defineProperty,A=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var f=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))T.call(t,r)&&f(e,r,t[r]);if(k)for(var r of k(t))b.call(t,r)&&f(e,r,t[r]);return e},w=(e,t)=>A(e,C(t));var u=(e,t,r)=>(f(e,typeof t!="symbol"?t+"":t,r),r);import{S as N,E as q,C as O}from"./index.49fc83a2.js";const M=e=>"("+e+")();",R=e=>URL.createObjectURL(new Blob([M(e)],{type:"text/javascript"})),S=e=>new Worker(R(e));class V{constructor(t,r,n=this.interval){u(this,"worker");u(this,"audioContext");u(this,"interval",.2);u(this,"lastEnd",0);this.audioContext=t,this.interval=n,this.worker=S(()=>{let i,o=null;const s=()=>{o&&(clearInterval(o),o=null)},a=()=>{if(s(),!i)throw new Error("no interval set! call worker.postMessage({interval}) before starting.");o=setInterval(()=>postMessage("tick"),i*1e3)};self.onmessage=function(l){l.data=="start"?a():l.data.interval?(i=l.data.interval,o&&a()):l.data=="stop"&&s()}}),this.worker.postMessage({interval:n}),this.worker.onmessage=i=>{if(i.data==="tick"){const o=this.lastEnd||this.audioContext.currentTime,s=this.audioContext.currentTime+this.interval;this.lastEnd=s,r(o,s)}}}start(){console.log("start..."),this.audioContext.resume(),this.worker.postMessage("start")}stop(){console.log("stop..."),this.worker.postMessage("stop")}}class W{constructor({audioContext:t,interval:r=.2,onEvent:n}){u(this,"worker");u(this,"pattern");this.worker=new V(t,(i,o)=>{this.pattern.query(new N(new q(i,o))).forEach(s=>{!s.part.begin.equals(s.whole.begin)||(n?n==null||n(s):console.warn("unplayable event: no audio node nor onEvent callback",s))})},r)}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.worker.start()}stop(){this.worker.stop()}setPattern(t){this.pattern=t}}const{Pattern:c,getFrequency:_,patternify2:F}=O;let d;const p=()=>(d||(d=new AudioContext),d),g=.2,E=(e,t,r,n,i,o,s)=>{const a=p().createGain();return a.gain.setValueAtTime(0,o),a.gain.linearRampToValueAtTime(i,o+e),a.gain.linearRampToValueAtTime(r*i,o+e+t),a.gain.setValueAtTime(r*i,s),a.gain.linearRampToValueAtTime(0,s+n),a};c.prototype.withAudioNode=function(e){return this._withHap(t=>t.setContext(w(h({},t.context),{createAudioNode:(r,n)=>{var i,o;return e(r,n,(o=(i=t.context).createAudioNode)==null?void 0:o.call(i,r,t))}})))};c.prototype._wave=function(e){return this.withAudioNode((t,r)=>{const n=p().createOscillator();n.type=e;const i=_(r);n.frequency.value=i;const o=t!=null?t:r.whole.begin.valueOf()+g,s=o+r.duration.valueOf();return n.start(o),n.stop(s),n})};c.prototype.adsr=function(e=.01,t=.05,r=1,n=.01){return this.withAudioNode((i,o,s)=>{var v;const a=((v=o.context)==null?void 0:v.velocity)||1,l=i!=null?i:o.whole.begin.valueOf()+g,m=l+o.duration.valueOf()+g,y=E(e,t,r,n,a,l,m);return s==null||s.connect(y),y})};c.prototype._filter=function(e="lowpass",t=1e3){return this.withAudioNode((r,n,i)=>{const o=p().createBiquadFilter();return o.type=e,o.frequency.value=t,i==null||i.connect(o),o})};c.prototype.filter=function(e,t){return F(c.prototype._filter)(reify(e),reify(t),this)};c.prototype.out=function(){const e=p().createGain();return e.gain.value=.1,e.connect(p().destination),this.withAudioNode((t,r,n)=>{n||console.warn("out: no source! call .osc() first"),n==null||n.connect(e)})._withHap(t=>{const r=(n,i)=>{var o,s;return(s=(o=i.context)==null?void 0:o.createAudioNode)==null?void 0:s.call(o,n,i)};return t.setContext(w(h({},t.context),{onTrigger:r}))})};c.prototype.define("wave",(e,t)=>t.wave(e),{patternified:!0});export{V as ClockWorker,W as Scheduler,p as getAudioContext};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
import{W as a,D as b}from"./index.db2658eb.js";export{a as WebMidi,b as enableWebMidi};
|
||||
@@ -0,0 +1 @@
|
||||
import{T as d}from"./index.db2658eb.js";import{T as A,o as T,a as k,u as E,d as N,f as O,g as I,t as j,k as q,l as x,m as B,b as D,c as F,n as _,q as v,r as C,j as z,h as H,p as S,e as U,s as G,i as J,v as K}from"./index.db2658eb.js";const f=()=>{document.getElementById("header").style="display:none"};function u(s){window.strudelAnimation&&cancelAnimationFrame(window.strudelAnimation);const a=e=>{const o=d.getTransport().seconds;s(e,o),window.strudelAnimation=requestAnimationFrame(a)};requestAnimationFrame(a)}const g=function(s,a={}){const e=document.getElementById("code"),o="background-image:url("+s+");background-size:contain;";e.style=o;const{className:c}=e,i=(t,n)=>{({style:()=>e.style=o+";"+n,className:()=>e.className=n+" "+c})[t]()},r=Object.entries(a).filter(([t,n])=>typeof n=="function");Object.entries(a).filter(([t,n])=>typeof n=="string").forEach(([t,n])=>i(t,n)),r.length!==0&&u((t,n)=>r.forEach(([l,m])=>{i(l,m(n))}))},h=()=>{const s=document.getElementById("code");s&&(s.style="",s.className="grow relative")};export{A as Tone,T as adsr,k as amsynth,g as backgroundImage,E as cleanupDraw,h as cleanupUi,N as duosynth,O as fmsynth,I as getDefaultSynth,j as getDrawContext,f as hideHeader,q as highpass,x as lowpass,B as membrane,D as metal,F as monosynth,_ as noise,v as osc,C as out,z as piano,H as players,S as pluck,U as polysynth,G as sampler,J as synth,K as vol};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
import{T as d}from"./index.49fc83a2.js";import{T as A,o as T,a as k,u as E,d as N,f as O,g as I,t as j,k as q,l as x,m as B,b as D,c as F,n as _,q as v,r as C,j as z,h as H,p as S,e as U,s as G,i as J,v as K}from"./index.49fc83a2.js";const f=()=>{document.getElementById("header").style="display:none"};function u(s){window.strudelAnimation&&cancelAnimationFrame(window.strudelAnimation);const a=e=>{const o=d.getTransport().seconds;s(e,o),window.strudelAnimation=requestAnimationFrame(a)};requestAnimationFrame(a)}const g=function(s,a={}){const e=document.getElementById("code"),o="background-image:url("+s+");background-size:contain;";e.style=o;const{className:c}=e,i=(t,n)=>{({style:()=>e.style=o+";"+n,className:()=>e.className=n+" "+c})[t]()},r=Object.entries(a).filter(([t,n])=>typeof n=="function");Object.entries(a).filter(([t,n])=>typeof n=="string").forEach(([t,n])=>i(t,n)),r.length!==0&&u((t,n)=>r.forEach(([l,m])=>{i(l,m(n))}))},h=()=>{const s=document.getElementById("code");s&&(s.style="",s.className="grow relative")};export{A as Tone,T as adsr,k as amsynth,g as backgroundImage,E as cleanupDraw,h as cleanupUi,N as duosynth,O as fmsynth,I as getDefaultSynth,j as getDrawContext,f as hideHeader,q as highpass,x as lowpass,B as membrane,D as metal,F as monosynth,_ as noise,v as osc,C as out,z as piano,H as players,S as pluck,U as polysynth,G as sampler,J as synth,K as vol};
|
||||
@@ -0,0 +1 @@
|
||||
import{W as a,D as b}from"./index.49fc83a2.js";export{a as WebMidi,b as enableWebMidi};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
var x=Object.defineProperty,k=Object.defineProperties;var m=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var p=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))A.call(t,r)&&p(e,r,t[r]);if(y)for(var r of y(t))C.call(t,r)&&p(e,r,t[r]);return e},d=(e,t)=>k(e,m(t));var u=(e,t,r)=>(p(e,typeof t!="symbol"?t+"":t,r),r);import{S as T,E as b,C as N}from"./index.db2658eb.js";const q=e=>"("+e+")();",O=e=>URL.createObjectURL(new Blob([q(e)],{type:"text/javascript"})),M=e=>new Worker(O(e));class R{constructor(t,r,n=this.interval){u(this,"worker");u(this,"audioContext");u(this,"interval",.2);u(this,"lastEnd",0);this.audioContext=t,this.interval=n,this.worker=M(()=>{let i,o=null;const s=()=>{o&&(clearInterval(o),o=null)},a=()=>{if(s(),!i)throw new Error("no interval set! call worker.postMessage({interval}) before starting.");o=setInterval(()=>postMessage("tick"),i*1e3)};self.onmessage=function(l){l.data=="start"?a():l.data.interval?(i=l.data.interval,o&&a()):l.data=="stop"&&s()}}),this.worker.postMessage({interval:n}),this.worker.onmessage=i=>{if(i.data==="tick"){const o=this.lastEnd||this.audioContext.currentTime,s=this.audioContext.currentTime+this.interval;this.lastEnd=s,r(o,s)}}}start(){console.log("start..."),this.audioContext.resume(),this.worker.postMessage("start")}stop(){console.log("stop..."),this.worker.postMessage("stop")}}class I{constructor({audioContext:t,interval:r=.2,onEvent:n}){u(this,"worker");u(this,"pattern");this.worker=new R(t,(i,o)=>{this.pattern.query(new T(new b(i,o))).forEach(s=>{!s.part.begin.equals(s.whole.begin)||(n?n==null||n(s):console.warn("unplayable event: no audio node nor onEvent callback",s))})},r)}start(){if(!this.pattern)throw new Error("Scheduler: no pattern set! call .setPattern first.");this.worker.start()}stop(){this.worker.stop()}setPattern(t){this.pattern=t}}const{Pattern:c,getFrequency:S,patternify2:V}=N,h=.2,_=(e,t,r,n,i,o,s)=>{const a=getAudioContext().createGain();return a.gain.setValueAtTime(0,o),a.gain.linearRampToValueAtTime(i,o+e),a.gain.linearRampToValueAtTime(r*i,o+e+t),a.gain.setValueAtTime(r*i,s),a.gain.linearRampToValueAtTime(0,s+n),a};c.prototype.withAudioNode=function(e){return this._withHap(t=>t.setContext(d(f({},t.context),{createAudioNode:(r,n)=>{var i,o;return e(r,n,(o=(i=t.context).createAudioNode)==null?void 0:o.call(i,r,t))}})))};c.prototype._wave=function(e){return this.withAudioNode((t,r)=>{const n=getAudioContext().createOscillator();n.type=e;const i=S(r);n.frequency.value=i;const o=t!=null?t:r.whole.begin.valueOf()+h,s=o+r.duration.valueOf();return n.start(o),n.stop(s),n})};c.prototype.adsr=function(e=.01,t=.05,r=1,n=.01){return this.withAudioNode((i,o,s)=>{var g;const a=((g=o.context)==null?void 0:g.velocity)||1,l=i!=null?i:o.whole.begin.valueOf()+h,v=l+o.duration.valueOf()+h,w=_(e,t,r,n,a,l,v);return s==null||s.connect(w),w})};c.prototype._filter=function(e="lowpass",t=1e3){return this.withAudioNode((r,n,i)=>{const o=getAudioContext().createBiquadFilter();return o.type=e,o.frequency.value=t,i==null||i.connect(o),o})};c.prototype.filter=function(e,t){return V(c.prototype._filter)(reify(e),reify(t),this)};c.prototype.out=function(){const e=getAudioContext().createGain();return e.gain.value=.1,e.connect(getAudioContext().destination),this.withAudioNode((t,r,n)=>{n||console.warn("out: no source! call .osc() first"),n==null||n.connect(e)})._withHap(t=>{const r=(n,i)=>{var o,s;return(s=(o=i.context)==null?void 0:o.createAudioNode)==null?void 0:s.call(o,n,i)};return t.setContext(d(f({},t.context),{onTrigger:r}))})};c.prototype.define("wave",(e,t)=>t.wave(e),{patternified:!0});export{R as ClockWorker,I as Scheduler};
|
||||
Reference in New Issue
Block a user