csound
The grain opcode in csound defines all of the parameters
required to produce granular synthesis with various constraints.
grain kamp, ipitch, kdens, kampoff, kpitchoff, kgdur, igfn, iwfn,
imgdur, igrnd
amplitude of the each grain, grain pitch, grain density, random
offset range for grain amplitude, offset range for pitch, grain
duration, grain function, grain amplitude envelope, maximum grain
duration, and a flag for randomly reading from different start
points at each grain excitation.
The complete code is below, with large sections commented out
as I tried to get the conditional stuff working to switch
between
grain and window functions in realtime, and Im not sure if it does.
< CsoundSynthesizer>
< CsInstruments>
;Adam Boulanger
;adamb@media.mit.edu
;Midified grain instrument for testing grainsynth interface
garvb init 0
;ctrlinit 1, 10, x, 11, x, 12, x, 13, x
ctrlinit 1, 14, 12, 15, 0
ctrlinit 1, 16, 0, 17, .16, 18, 0, 19, .8, 20, 4000
ctrlinit 1, 21, 0, 22, 0, 23, 5, 24, 0, 25, 1
instr 3
;midi variable assignment block
;iwfna midic7 10, x, x
;iwfnd midic7 11, x, x
;iwfns midic7 12, x, x
;iwfnr midic7 13, x, x
imgdur midic7 19, .01, .8 ;;init = .8
igrnd midic7 22, 0, 1 ;;init = 0
kdens_gross midic7 14, 6, 100 ;;init = 12
kdens_fine midic7 15, -5, 5 ;;init = 0
kampoff_gross midic7 16, 0, 3000 ;;init = 0
kgdur_gross midic7 17, .01, .8 ;;init = .16
kgdur_fine midic7 18, -.007, .007 ;;init = 0
kamp_gross midic7 20, .00001, 6000 ;;init = 4000
kpitchoff_gross midic7 21, -800, 800 ;;init = 0
kpitch_gross midic7 23, 3.00, 13.0 ;;init = 5.0
kpitch_fine midic7 24, -.5, .5 ;;init = 0
ksel_gfn midic7 25, 0, 5
;grain control block::::::::::::::::::::::::::
;;grain function multi-position switch
if (ksel_gfn <= 1.0) kgoto selfn2
if (ksel_gfn <= 2.0) kgoto selfn3
if (ksel_gfn <= 3.0) kgoto selfn4
if (ksel_gfn <= 4.0) kgoto selfn5
if (ksel_gfn <= 5.0) kgoto selfn6
selfn2:
igfn = 5
koutme = 1 ;debug outme to test conditional
goto end_gfn_sel
selfn3:
igfn = 3
koutme = 2
goto end_gfn_sel
selfn4:
koutme = 3
igfn = 4
goto end_gfn_sel
selfn5:
igfn = 5
goto end_gfn_sel
selfn6:
igfn = 6
goto end_gfn_sel
end_gfn_sel:
;outvalue "maxmsp", koutme
iwfn = 1
;imgdur in i midic7 block
;igrnd in i midic7 block
kamp = kamp_gross
kampoff = kampoff_gross
ipitch cpsmidi
kpitchoff = kpitchoff_gross
kdens = kdens_fine + kdens_gross
kgdur = kgdur_gross
kcut = 500
asig grain kamp, ipitch, kdens, kampoff, kpitchoff, kgdur, igfn, iwfn, imgdur,
igrnd
alp butterlp asig, kcut
out alpendin
< /CsInstruments>
< CsScore>
f 1 0 4096 1 "a50.aif" 0 4 1
f 2 0 4096 20 6 ;gauss
f 3 0 4096 20 9 ;sync
f 4 0 4096 20 8 ;rectangle
f 5 0 4096 20 5
f 6 0 4096 20 7
f0 600</CsScore>
< /CsoundSynthesizer>
< MacOptions>
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
WindowBounds: 68 136 671 768
Options: -b128 -A -s -m7 -R
< /MacOptions>
< MacGUI>
ioView background {60108, 65535, 63132}
ioListing {75, 280} {562, 166}
ioGraph {163, 38} {472, 230}
ioSlider {76, 39} {34, 229} 20.000000 2000.000000 559.351990 pitch
< /MacGUI>
|