Csound
Image source: Csound

Csound

Csound


Csound Project

.

The Code I wrote

  • you can try copy this
Csound
Filtered
Amplitude-modified
Spectrally-rich unit generators
Granular synthesis of 3 different sound files
 
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーー




-o/Users/TATSUYA/Desktop/Grain.aif

sr = 44100

kr = 4410

ksmps = 10

nchnls = 2

instr 1

  kamp linen ampdb(p4), p3/3, p3, p3*2/2

  kcps line cpspch(p5), p3, cpspch(p6)

  iwave = 3

  kpw line p7, p3, p8

  kcf line p9, p3, p10

  kbw line p11, p3, p12

  ;kbw = p11

;kpw — determines either the pulse width (if iwave is 2) or the saw/ramp character (if iwave is 3) The value of kpw should be greater than 0 and less than 1. A value of 0.5 will generate either a square wave (if iwave is 2) or a triangle wave (if iwave is 3).

;kcf — the center frequency of the filter, or frequency position of the peak response.

;kbw — bandwidth of the filter (the Hz difference between the upper and lower half-power points).

  kxp line p13, p3, p14

  aoriginal vco kamp, kcps, iwave, kpw

  afilter reson aoriginal, kcf, kbw

  asig balance afilter, aoriginal

  ;out asig

  a1, a2 pan2 asig, kxp

  outs a1, a2

endin

instr 2

;grain- iamp ipitch idens kampoff kpitchoff kgdur igfn iwfn imgdur

  iamp = ampdb(p4)

  kpitch line p18, p3, p19

  ;kpitch linen p4, p18, p3, p19

  idens = p5

  kampoff line p6, p3, p7

  kpitchoff linen p4, p8, p3, p9

  kgdur line p10, p3, p11

  igfn = p12

  iwfn = p13

  imgdur = .5

  kcf line p14, p3, p15

  kbw line p16, p3, p17

  kxp line p20, p3, p21

  iwidth = p22

  ispeed = p23

  klfo lfo iwidth, ispeed, p24

;xdens — Density of grains measured in grains per second. If this is constant then the output is synchronous granular synthesis, very similar to fof. If xdens has a random element (like added noise), then the result is more like asynchronous granular synthesis

;kampoff — Maximum amplitude deviation from xamp. This means that the maximum amplitude a grain can have is xamp + kampoff and the minimum is xamp. If kampoff is set to zero then there is no random amplitude for each grain.

;kpitchoff — Maximum pitch deviation from xpitch in Hz. Similar to kampoff.

;kgdur — Grain duration in seconds. The maximum value for this should be declared in imgdur. If kgdur at any point becomes greater than imgdur, it will be truncated to imgdur.

  aorigi grain iamp, kpitch, idens, kampoff, kpitchoff, kgdur, igfn, iwfn, imgdur

  afilter reson aorigi, kcf, kbw

  asig balance afilter, aorigi

;out asig

  a1, a2 pan2 asig, kxp+klfo

  outs a1, a2

endin

f1 0 8192 10 1

f2 0 32768 1 “Attention.aif” 0 0 0

f3 0 131072 1 “JapaneseDrum.aif” 0 0 0

f4 0 262144 1 “TubularBell.aif” 0 0 0

f5 0 1024 20 1

;1 2  3  4   5      6      7 8 9 10 11   12     13 14

i1 0 10 80 8.01 9.01 0 1 0 1   100 1000 0   1

;instr start dur iamp ipitch idens kampoff kpitchoff kgdur igfn iwfn imgdur kcf kbw

;1  2   3   4   5     6  7  8    9    10  11  12 13 14 15 16   17      18    19      20 21 22    22  24

i2 10 15 75 10   .5  0  10 100 10  15  2   1    0  1   100 1000  7.08  9.01  0   1   10    4    3

i2  +   .   75 100 .5  0  10 100 15  20  3   1    0  1   100 1000  8.01  9.01  1   0   100  1    2

i2  .    .   75 100 .5  0  10 100 20  25  4   1    0  1   100 1000  9.04  8.01  0   1   200  2    1

i2  .    .   75 10   .5  0  10 100 25  30  2   1    0  1   100 1000  9.01  8.01  1   0   250  3    4

EndFragment

1 2 3 4 5
Csound