Simple granular synthesis.
in RTcmix/insts/jg
GRANSYNTH(outsk, dur, AMP, WAVETABLE, GRAINENV, GRAINHOP, OUTTIMEJITTER, MINDUR, MAXDUR, MINAMP, MAXAMP, PITCH[, TRANSPTABLE, PITCHJITTER, seed, MINPAN, MAXPAN])
CAPITALIZED parameters are pfield-enabled for table or dynamic control (see the maketable or makeconnection scorefile commands). Parameters after the [bracket] are optional and default to 0 unless otherwise noted.
Param Field | Parameter | Units | Dynamic | Optional | Notes |
---|---|---|---|---|---|
p0 | output start time | seconds | no | no | |
p1 | total duration | seconds | no | no | |
p2 | amplitude | absolute, for 16-bit soundfiles: 0-32768 | yes | no | |
p3 | oscillator waveform table | reference to pfield table-handle | yes | no | |
p4 | grain envelope table | - | yes | no | |
p5 | grain hop time | seconds, time between successive grains | yes | no | |
p6 | grain output time jitter | seconds | yes | no | |
p7 | grain duration minimum | seconds | yes | no | |
p8 | grain duration maximum | seconds | yes | no | |
p9 | grain amplitude multiplier minimum | relative multiplier of p2 | yes | no | |
p10 | grain amplitude multiplier maximum | relative multiplier of p2 | yes | no | |
p11 | grain pitch | linear octaves | yes | no | |
p12 | grain transposition collection | reference to pfield table-handle, oct.pc | yes | yes | default: no transpositions applied |
p13 | grain pitch jitter | linear octaves or oct.pc (if p12 used) | yes | yes | default: no pitch jitter applied |
p14 | random seed | integer | no | yes | default: use system clock |
p15 | grain pan minimum | 0-1 stereo; 0.5 is middle | yes | yes | default: 0.0 |
p16 | grain pan maximum | 0-1 stereo; 0.5 is middle | yes | yes | default: 1.0 |
Parameters labled as Dynamic can receive dynamic updates from a table or real-time control source.
Author: John Gibson, 2/8/05
GRANSYNTH is a time-varying granular synthesis instrument, similar to some of Mara Helmuth’s instruments (see SGRANR and STGRANR). This instrument is capable of many interesting and subtle effects.
Parameters that determine the character of individual grains:
GRANSYNTH can produce either stereo or mono output.
very basic:
rtsetparams(44100, 2, 128)
load("GRANSYNTH")
dur = 30
amp = maketable("line", 1000, 0,0, 1,1, 2,0.5, 3,1, 4,0)
wave = maketable("wave", 2000, 1, .5, .3, .2, .1)
granenv = maketable("window", 2000, "hanning")
hoptime = maketable("line", "nonorm", 1000, 0,0.01, 1,0.002, 2,0.05)
hopjitter = 0.0001
mindur = .04
maxdur = .06
minamp = maxamp = 1
pitch = maketable("line", "nonorm", 1000, 0,6, 1,9)
transpcoll = maketable("literal", "nonorm", 0, 0, .02, .03, .05, .07, .10)
pitchjitter = 1
st = 0
GRANSYNTH(st, dur, amp*7000, wave, granenv, hoptime, hopjitter,
mindur, maxdur, minamp, maxamp, pitch, transpcoll, pitchjitter, 14, 0, 0)
st = st+0.14
pitch = pitch+0.002
GRANSYNTH(st, dur, amp*7000, wave, granenv, hoptime, hopjitter,
mindur, maxdur, minamp, maxamp, pitch, transpcoll, pitchjitter, 21, 1, 1)
slightly more advanced:
rtsetparams(44100, 2, 128)
load("GRANSYNTH")
dur = 60
amp = makeconnection("mouse", "y", 50, 70, 10, 60, "amp", "dB")
amp = makeconverter(amp, "ampdb")
wavetab = maketable("wave", 2000, 1, .5, .3, .2, .1)
envtab = maketable("window", 2000, "hanning")
outjitter = 0.0001
density = makeconnection("mouse", "x", 1, 500, 1, 10, "density")
hoptime = 1.0 / density
mindur = .05
maxdur = mindur
minamp = maxamp = 1
pitch = makeconnection("mouse", "y", 6, 8, 6, 10, "pitch", "linoct")
transpcoll = maketable("literal", "nonorm", 0, 0, .02, .03, .05, .07, .10)
pitchjitter = 1
seed = 1
st = 0
GRANSYNTH(st, dur, amp, wavetab, envtab, hoptime, outjitter,
mindur, maxdur, minamp, maxamp, pitch, transpcoll, pitchjitter, seed, 0, 0)
st += 0.01
seed += 1
pitch = pitch + 0.002
GRANSYNTH(st, dur, amp, wavetab, envtab, hoptime, outjitter,
mindur, maxdur, minamp, maxamp, pitch, transpcoll, pitchjitter, seed, 1, 1)