Granular synthesis
A popular cool synthesis technique that can use sampling to produce a wide variety of rich and complex sounds. A phasor is used to trigger grains on the negative edge.
granulate is the main synthesis routine that takes as "granulator" function like simplegrains or chorusgrains.
Synth.granulate — Functiongranulate(samples, dur :: Real, overlap :: Real, speed :: Real, graintime,
player = phasor(1.0 * speed / (dur * (1.0 - overlap)))
; samplingrate=48000.0f0)
granulate(samples::Vector{Float32}, granulator, speed::Signal, graintime::Signal, player::Signal; samplingrate=48000.0f0)Granular synthesis - simple version.
The granulator is a function of time that returns a vector of grains. Two built-in granulators are available – simplegrains and chorusgrains. The player is expected to be a phasor which will trigger grains on the negative edge.
Example
snd = read_rawaudio("/tmp/somefile.raw")
stop = play(0.5 * granulate(snd,
chorusgrains(rng,0.0,3,4.0),
konst(0.5),
line(0.0, 10.0, 3.2),
phasor(20.0)),
10.0)Synth.simplegrains — Functionsimplegrains(dur :: Real, overlap :: Real, speedfactor :: Real)Result is a function(time) which when called will produce a vector of a single grain. This kind of a function is what we call a "granulator" (see granulate).
Synth.chorusgrains — Functionchorusgrains(rng, delayspread=0.0, N=1, spread=5.0f0)Result is a function(time) which when called will produce a vector of N grains spread in time. Since the chorus spread has some randomness to it, you need to pass an RNG. This kind of function is called a "granulator" (see granulate).
Synth.Granulation — TypeRepresents a granulation of a sample array.
The grain durations, overlaps and playback speed can be varied with time as signals. Additionally, the grainplayphasor is expected to be a phasor that will trigger a new grain voice upon its negative edge.
Synth.Grain — TypeAn internal structure used to keep track of a single granular "voice".
rtis the time within the grain. 0.0 is the start of the grain.gtis the grain start time within the larger sample array.duris the grain duration in secondsoverlapis also a duration in seconds. The total duration of the grain is dependent on both dur and overlap.