PageSourceSearch

https://strudel.cc/_astro/index.DA1heBth.js

js strudel.cc collected 2026-10-02 04:11:05 UTC 4,599 bytes, 105 lines download raw bytes

1import{_ as O}from"./preload-helper.CLcXU_4U.js";import{c as y,l as d,F as h}from"./index.k2Romlaj.js";import{a as C}from"./spectrum.DmSH5sgu.js";import"./index.D9XA5SFw.js";const q=`<CsoundSynthesizer>
2<CsInstruments>
3
4sr=48000
5ksmps=64
6nchnls=2
70dbfs=1
8
9</CsInstruments>
10</CsoundSynthesizer>`,$=`; returns value of given key in given "string map"
11; keymap("freq", "note/c3/freq/220/gain/0.5")
12; yields "220"
13opcode keymap, S, SS
14  Skey, Smap xin
15  idelimiter = strindex(Smap, strcat(Skey, "/"))
16  ifrom = idelimiter + strlen(Skey) + 1
17  Svalue = strsub(Smap, ifrom, strlen(Smap))
18  Svalue = strsub(Svalue, 0, strindex(Svalue, "/"))
19  xout Svalue
20endop
21
22; TODO add incredibly dope synths
23instr organ
24    iduration = p3
25    ifreq = p4
26    igain = p5
27    ioct = octcps(ifreq)
28
29    asig = vco2(igain, ifreq, 12, .5) ; my edit
30    kpwm = oscili(.1, 5)
31    asig = vco2(igain, ifreq, 4, .5 + kpwm)
32    asig += vco2(igain/4, ifreq * 2)
33
34    ; filter
35    ; idepth = 2
36    ; acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) ; filter envelope
37    ; asig = zdf_2pole(asig, cpsoct(ioct + acut), 0.5)
38
39    ; amp envelope
40    iattack = .001
41    irelease = .05
42    asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0)
43
44    out(asig, asig)
45
46endin
47
48instr triangle
49  iduration = p3
50  ifreq = p4
51  igain = p5
52  ioct = octcps(ifreq)
53  
54  asig = vco2(igain, ifreq, 12, .5)
55  
56  ; amp envelope
57  iattack = .001
58  irelease = .05
59  asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0)
60  
61  out(asig, asig)
62endin
63
64instr pad
65    iduration = p3
66    ifreq = p4
67    igain = p5
68    ioct = octcps(ifreq)
69
70    asig = vco2(igain, ifreq, 0)
71
72    ; amp envelope
73    iattack = .5
74    irelease = .1
75    asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0)
76    
77    idepth = 2
78    acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0)
79    asig = zdf_2pole(asig, 1000, 2)
80
81    out(asig, asig)
82endin
83
84
85gisine	ftgen	0, 0, 4096, 10, 1
86
87instr bow
88    kpres = 2
89    krat = 0.16
90    kvibf = 6.12723
91    
92    kvib  linseg 0, 0.5, 0, 1, 1, p3-0.5, 1	
93    kvamp = kvib * 0.01
94    asig  wgbow .7, p4, kpres, krat, kvibf, kvamp, gisine
95    asig = asig*p5
96    outs asig, asig
97endin
98
99
100instr Meta
101    Smap = strget(p6)
102    Sinstrument = keymap("s", Smap)
103    schedule(Sinstrument, 0, p3, p4, p5)
104    ; TODO find a way to pipe Sinstrument through effects
105endin`;let u,e;async function k(n=""){await g(),n&&(n=`${n}`,await e?.evalCode(n))}const D=k,I=k,L=y("csound",(n,i)=>(n=n||"triangle",g(),i.onTrigger((t,s,f,m)=>{if(!e){d("[csound] not loaded yet","warning");return}t.ensureObjectValue();let{gain:o=.8}=t.value;o*=.2;const r=Math.round(h(t)),p=Object.entries({...t.value,freq:r}).flat().join("/"),c=m-s,a=`i ${[`"${n}"`,c,t.duration+0,r,o,`"${p}"`].join(" ")}`;e.inputMessage(a)})));function x(n,i){const[t]=i;if(n==="message"&&(["[commit: HEAD]"].includes(t)||t.startsWith("--Csound version")||t.startsWith("libsndfile")||t.startsWith("sr =")||t.startsWith("0dBFS")||t.startsWith("audio buffered")||t.startsWith("writing")||t.startsWith("SECTION 1:")))return;let s="info";t.startsWith("error:")&&(s="error"),d(`[csound] ${t||""}`,s)}async function W(){if(window.__csound__)return d("[load] Using external Csound","warning"),e=window.__csound__,e;{const{Csound:n}=await O(async()=>{const{Csound:i}=await import("./csound.-DfvzaX-.js");return{Csound:i}},[]);return e=await n({audioContext:C()}),e.removeAllListeners("message"),["message"].forEach(i=>e.on(i,(...t)=>x(i,t))),await e.setOption("-m0d"),await e.setOption("--sample-accurate"),await e.setOption("-odac"),await e.compileCsdText(q),await e.compileOrc($),await e.start(),e}}async function g(){return u=u||W(),u}let l={};async function F(n){if(await g(),typeof n!="string")throw new Error("loadOrc: expected url string");if(n.startsWith("github:")){const[i,t]=n.split("github:");n=`https://raw.githubusercontent.com/${t}`}l[n]||(l[n]=fetch(n).then(i=>i.text()).then(i=>e.compileOrc(i))),await l[n]}const P=y("csoundm",(n,i)=>{let t=n;return typeof n=="string"&&(t=`"${n}"`),g(),i.onTrigger((s,f,m,o)=>{if(!e){d("[csound] not loaded yet","warning");return}if(typeof s.value!="object")throw new Error("csound only support objects as hap values");const r=o-f,p=s.duration.valueOf()+0,c=h(s);let{gain:v=1,velocity:a=.9}=s.value;a=v*a;const S=(Math.log(c/261.62558)/Math.log(2)+8)*12-36,_=127*a,b=Object.entries({...s.value,frequency:c}).flat().join("/"),w=`i ${t} ${r} ${p} ${S} ${_} "${b}"`;console.log("[csoundm]:",w),e.inputMessage(w)})});export{L as csound,P as csoundm,k as loadCSound,I as loadCsound,F as loadOrc,D as loadcsound};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.