Spatial Granular in SuperCollider
The following example uses 16 granular synths in parallel, each being rendered as an individual virtual sound source with azimuth and elevation in the 3rd order Ambisonics domain. This allows the synthesis of spatially distributed sound textures, with the possibility of linking grain properties their spatial position.
A Granular SynthDef
The granular SynthDef creates a monophonic granular stream with individual rate, output bus and grain position. It receives a trigger signal as argument.
A Trigger Synth
The trigger synth creates 16 individual random trigger signals, which are sent to a 16-channel audio bus. The density of all trigger streams can be controlled via an argument.
Read a Wavefile to Buffer
Load a buffer of your choice and plot it for confirmation. Suitable mono wavfiles can be found in the Download Section.
Create 16 Granular Synths
An array of 16 granular Synths creates 16 individual grain streams, which are sent to a 16-channel audio bus. All Synths are kept in a dedicated group to ease the control over the signal flow.
An Encoder SynthDef
A simple encoder SynthDef with dynamic input bus and the control parameters azimuth and elevation.
The Encoder Synths
An array of 16 3rd order decoders is created in a dedicated encoder group. This group is added after the granular group to ensure the correct order of the synths. All 16 encoded signals are sent to a 16-channel audio bus.
The Decoder Synth
A decoder is added after the encoder group and fed with the encoded Ambisonics signal. The binaural output is routed to outputs 0,1 - left and right.
// load binaural IRs for the decoder HOABinaural.loadbinauralIRs(s); ( ~decoder = { Out.ar(0, HOABinaural.ar(3, In.ar(~ambi_BUS.index, 16))); }.play; ) ~decoder.moveAfter(~encoder_GROUP);