Granulation of sound stored in a table.
in RTcmix/insts/jg
GRANULATE(outsk, INSK, dur, AMP, INPUTTABLE, inchans, INTABLECHAN, INSTART, INEND, WRAPAROUND, TRAVERSERATE, GRAINENV, GRAINHOP, INTIMEJITTER, OUTTIMEJITTER, MINDUR, MAXDUR, MINAMP, MAXAMP, PITCH[, TRANSPTABLE, PITCHJITTER, seed, MINPAN, MAXPAN, INTERPTYPE])
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 | input start time | seconds | yes | no | will be constrained to window, p5-p6 |
p2 | total duration | seconds | no | no | |
p3 | amplitude multiplier | relative multiplier of input sound | yes | no | |
p4 | input sound table | reference to pfield table-handle | yes | no | |
p5 | number of channels in sample table | - | no | no | |
p6 | input channel of sample table | seconds | yes | no | |
p7 | input window start time | seconds | yes | no | |
p8 | input window end time | seconds | yes | no | |
p9 | wraparound | 1: yes 0: no | yes | no | usually use 1 |
p10 | traversal rate | speed multiplier, 1.0 == normal, -1.0 == backwards | yes | no | |
p11 | grain envelope table | reference to pfield table-handle | yes | no | |
p12 | grain hop time | seconds, time between successive grains | yes | no | |
p13 | grain input time jitter | seconds | yes | no | |
p14 | grain output time jitter | seconds | yes | no | |
p15 | grain duration minimum | seconds | yes | no | |
p16 | grain duration maximum | seconds | yes | no | |
p17 | grain amplitude multiplier minimum | relative multiplier of p3 | yes | no | |
p18 | grain amplitude multiplier maximum | relative multiplier of p3 | yes | no | |
p19 | grain transposition | in linear octaves, relative to 0 | yes | no | default: no transposition |
p20 | grain transposition collection | reference to pfield table-handle, oct.pc | yes | yes | default: no transpositions applied |
p21 | grain transposition jitter | linear octaves or oct.pc (if p20 used) | yes | yes | default: no transposition jitter |
p22 | random seed | integer | no | yes | default: system clock |
p23 | grain pan minimum | 0-1 stereo; 0.5 is middle | yes | yes | default 0.0 |
p24 | grain pan maximum | 0-1 stereo; 0.5 is middle | yes | yes | default 0.0 |
p25 | interpolation type | 0: 2nd-order interpolation, 1: 3rd-order interpolation | yes | yes | default: 0 |
Parameters labled as Dynamic can receive dynamic updates from a table or real-time control source.
Author: John Gibson, 1/29/05
GRANULATE is differs from other signal-processing instruments in RTcmix in that it operates upon an input table (see maketable(“soundfile”, …) scorefile command for one possible way to load this table) instead of granulating an input stream or an existing soundfile. This gives it some flexibility and speed that other granulators may lack, although the sound needs to be loaded into memory (the table) first.
p1 (“INSK”) will be constrained to window, the bounds set by p7 and p8. NOTE: Unlike other instruments, this applies to a table, not to an input sound file.
The p4 parameter (“INPUTTABLE”) is a pfield-handle set to a table containing the entirety of an input sound to be granualted. This is set by using the maketable(“soundfile”, …) scorefile command.
The “INSTART” (p7) and “INEND” (p8) parameters refer to the portion of the input sound table read by the granulator. When the granulator reaches the end of the window, it wraps around to the beginning, unless p9 (“WRAPAROUND”) is false (0). In that case, please note that any data coming from time-varying tables may not span the entire table; processing will stop.
It’s best to arrange for the window start to be a little after the sound table start, and for the window end to be a little before the table end.
p10 (“TRAVERSERATE”) sets the speed for reading through the input sound. Here are some sample values:
0 no movement
1 move forward at normal rate
2.5 move forward at a rate that is 2.5 times normal
-1 move backward at normal rate
The following parameters determine the character of individual grains.
GRANULATE can produce either stereo or mono output.
very basic:
rtsetparams(44100, 2, 512)
load("GRANULATE")
dur = 60
amp = ampdb(-12)
env = maketable("curve", 1000, 0,0,1, 2,1,0, 7,1,-1, 10,0)
fname = "mysound.wav"
intab = maketable("soundfile", "nonorm", 0, fname)
filedur = 1.578957
numchans = 1
inchan = 0
inskip = 0.45
winstart = 0.1
winend = filedur - 0.1
wrap = 1
travrate = 0.01
envtab = maketable("window", 1000, "hanning")
injitter = 0.0
outjitter = 0.001
hoptime = 0.006
mindur = hoptime * 22
maxdur = mindur
minamp = maxamp = 1.0
transp = -0.07
transpcoll = 0
transpjitter = 0.0
seed = 1
minpan = 0.3
maxpan = 0.7
GRANULATE(0, inskip, dur, amp * env, intab, numchans, inchan, winstart, winend,
wrap, travrate, envtab, hoptime, injitter, outjitter, mindur, maxdur,
minamp, maxamp, transp, transpcoll, transpjitter, seed, 0, 0)
seed += 1
GRANULATE(0, inskip, dur, amp * env, intab, numchans, inchan, winstart, winend,
wrap, travrate, envtab, hoptime, injitter, outjitter, mindur, maxdur,
minamp, maxamp, transp, transpcoll, transpjitter, seed, 1, 1)
slightly more advanced:
rtsetparams(44100, 2, 512)
load("GRANULATE")
dur = 360
amp = ampdb(-12)
fname = "mysound.wav"
intab = maketable("soundfile", "nonorm", 0, fname)
filedur = 1.578957
numchans = 1
inchan = 0
inskip = 0.45
winstart = 0.01
winend = filedur - 0.01
wrap = 1
travrate = makeconnection("mouse", "x", min=-2, max=2, dflt=0, lag=30, "rate")
envtab = maketable("window", 1000, "hanning")
injitter = 0.0
outjitter = 0.001
hoptime = 0.006
mindur = hoptime * 18
maxdur = mindur
minamp = maxamp = 1.0
transp = makeconnection("mouse", "y", min=-1, max=1, dflt=0, lag=20,
"transp", "oct")
transpcoll = 0
transpjitter = 0.0
seed = 1
minpan = 0.2
maxpan = 0.8
GRANULATE(0, inskip, dur, amp, intab, numchans, inchan, winstart, winend,
wrap, travrate, envtab, hoptime, injitter, outjitter, mindur, maxdur,
minamp, maxamp, transp, transpcoll, transpjitter, seed, 0, 0)
seed += 1
GRANULATE(0, inskip, dur, amp, intab, numchans, inchan, winstart, winend,
wrap, travrate, envtab, hoptime, injitter, outjitter, mindur, maxdur,
minamp, maxamp, transp, transpcoll, transpjitter, seed, 1, 1)