improve csound bindings:
- better timing - can now pass instrument to .csound(...) - can now write instruments with csound(...)
This commit is contained in:
parent
729e0afdbe
commit
c40078ffc9
4 changed files with 236 additions and 66 deletions
60
packages/csound/csd.mjs
Normal file
60
packages/csound/csd.mjs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
export function csd(code = '') {
|
||||
return `
|
||||
<CsoundSynthesizer>
|
||||
<CsOptions>
|
||||
-o dac --port=10000 --sample-accurate
|
||||
</CsOptions>
|
||||
<CsInstruments>
|
||||
sr=48000
|
||||
ksmps=64
|
||||
nchnls=2
|
||||
0dbfs=1
|
||||
|
||||
instr organ
|
||||
iduration = p3
|
||||
ifreq = p4
|
||||
igain = p5
|
||||
ioct = octcps(ifreq)
|
||||
|
||||
asig = vco2(igain, ifreq, 12, .5) ; my edit
|
||||
kpwm = oscili(.1, 5)
|
||||
asig = vco2(igain, ifreq, 4, .5 + kpwm)
|
||||
asig += vco2(igain/4, ifreq * 2)
|
||||
|
||||
; filter
|
||||
; idepth = 2
|
||||
; acut = transegr:a(0, .005, 0, idepth, .06, -4.2, 0.001, .01, -4.2, 0) ; filter envelope
|
||||
; asig = zdf_2pole(asig, cpsoct(ioct + acut), 0.5)
|
||||
|
||||
; amp envelope
|
||||
iattack = .001
|
||||
irelease = .05
|
||||
asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0)
|
||||
|
||||
out(asig, asig)
|
||||
|
||||
endin
|
||||
|
||||
instr triangle
|
||||
iduration = p3
|
||||
ifreq = p4
|
||||
igain = p5
|
||||
ioct = octcps(ifreq)
|
||||
|
||||
asig = vco2(igain, ifreq, 12, .5)
|
||||
|
||||
; amp envelope
|
||||
iattack = .001
|
||||
irelease = .05
|
||||
asig *= linsegr:a(0, iattack, 1, iduration, 1, irelease, 0)
|
||||
|
||||
out(asig, asig)
|
||||
|
||||
endin
|
||||
|
||||
${code}
|
||||
|
||||
</CsInstruments>
|
||||
</CsoundSynthesizer>
|
||||
`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue