(8.D.2.5) Granular Synthesis Module
About This Guide
This Application Note explains the use of the Granular Synthesis modules Audio Weaver Application.
What is Granular Synthesis used for?
Granular Synthesis or Granulation is a flexible method for creating animated sonic textures. Sounds produced by granular synthesis have an organic quality sometimes reminiscent of sounds heard in nature: the sound of a babbling brook, or leaves rustling in a tree. Forms of granular processing involving sampled sound may be used to create time stretching, time freezing, time smearing, pitch shifting and pitch smearing effects. Perceptual continua for granular sounds include gritty / smooth and dense / sparse. The metaphor of “sonic clouds” has been used to describe sounds generated using Granular Synthesis. By varying synthesis parameters over time, gestures evocative of accumulation / dispersal, and condensation / evaporation may be created.
How Does Granular Synthesis Work?
The output of a Granular Synthesizer or Granulator is a mixture of many individual grains of sound. The sonic quality of a granular texture is a result of the distribution of grains in time and of the parameters selected for the synthesis of each grain. Typically, grains are quite short in duration and are often distributed densely in time so that the resultant sound is perceived as a fused texture. Algorithmic means are usually employed to determine when grains occur in time and to select their synthesis parameters, which often include duration, amplitude, panning, pitch, and envelope shape.
A Stochastic Granular Synthesizer uses random number generators to determine grain onset times and synthesis parameters. Usually, the probability functions of these random number generators constitute the parameters of the Granulator as a whole and are often varied over time.
Figure 1. Making a grain
A Granulator generates individual grains by applying an amplitude envelope to a source such as a synthetic or sampled waveform. One criterion that has been used to classify different types of Granular Synthesis is the method used to generate the source for each grain.
According to this classification scheme, types of Granular Synthesis include:
Delay Line Granular Synthesis, which uses a delay line to store samples from a real-time input stream. Each grain reads sound from the delay line with a potentially different delay time and playback rate. This form of Granular Synthesis is appropriate for ‘effects’ processing of real-time input.
Stored Sample Granular Synthesis, which generates each grain by reading sample values from a wavetable. It can be used to process pre-generated or sampled sounds.
Both Delay Line and Stored Sample Granular Synthesizers require information such as a wavetable or delay line to be shared between all grains. They also use interpolated sample lookup whose complexity is dependent on the desired interpolation quality and the efficiency of the interpolation implementation. Maintenance of the delay line and implementation of variable rate delay taps for each grain results in Delay Line Granulation having greater implementation complexity than the other types of Granular Synthesis described here.
Various algorithms for grain amplitude envelope generation and grain onset sequencing may be employed interchangeably in the implementation of the two types of Granular Synthesis. The following envelope algorithms can each be implemented with similar efficiency: Parabolic, Trapezoidal, and Raised Cosine Bell. Another common but possibly less efficient method of generating grain amplitude envelopes is the use of a lookup table containing the envelope function. Selection of a particular envelope algorithm is often based on the level of flexibility desired in specifying the envelope’s attack, sustain and decay characteristics. In some applications such as analysis/resynthesis the spectral characteristics of the grain envelope may determine which algorithm is chosen.
Granular Synthesizers can also be classified in terms of the method used to distribute grains in time:
Asynchronous Granular Synthesis distributes grains in time according to a stochastic function that is traditionally specified in terms of grain density: the number of grains per unit time.
Pitch Synchronous Granular Synthesis sequences grains at regular intervals in time to create periodic or pitched sounds.
For real-time operation, where it is necessary to schedule grains in time-sequential order, a useful concept is interonset time: the time between the onset of successive grains. When implementing Asynchronous Granular Synthesis, it is possible to generate interonset times as a function of grain density. In Pitch Synchronous Granular Synthesis, the interonset time is directly related to the period of the resultant sound.
Common Terms
Grain Length
Figure 2. Grain Length
Grains are typically between 10 and 100 msec in length.
In order to be heard as a pitched event, the minimum length is 13 msec for high frequencies and 45 msec for low frequencies.
Lengths greater than 50 msec create the impression of separate sound events.
Grain Period or interonset time
Figure 3. Grain Period
Grain period is typically randomized in order to avoiding any periodicity. Because grain duration and grain period are varied independently, the period may occasionally be shorter than the duration causing consecutive grains to overlap and produce a smoother texture.
Sample Offset or Play Position
Figure 4. Sample offset
Start point of the grain, located within the sample (aka “Position”)
Grain Pitch
Grains can also be up- or down-sampled to change their pitch.
Time Stretching or Compressing
Grains can be extracted from sound file every N samples to reconstruct the original signal (N depends on windowing function).
Figure 5. Crossfading
If grains are created every N+M samples and used to reconstruct the original every N samples, then time is compressed by a factor of (N/(N+M)) while retaining the original pitch.
Figure 6. Time compression
If grains are extracted every N-M samples and used to reconstruct the original every N samples, then time is stretched by a factor of (N/(N-M)) while retaining the original pitch.
Figure 7. Time Stretching
Granular Pitch Shifting
If grains are extracted from sound file with a pitch shift factor of P, stretching the grain window to P*N and reconstructing every N samples will allow for pitch shift without change of duration.
Figure 8. Granular pitch shifting
Granular Synthesis Modules
Three different variations can be found in the Sound Design/Granular Synthesis folder of the Module Browser.
Figure 9. Location in Module Browser
GranularSynthesisDelay: Uses a delay line to store samples from a real-time input stream.
Figure 10. GranularSynthesisDelay module
GranularSynthesisWaveRAM: Stored Sample Granular Synthesis, which generates each grain by reading sample values from a wavetable.
Figure 11. GranularSynthesisWaveRAM module
GranularSynthesisWaveFFS: Similar to the GranularSynthesisWaveRAM module except it extracts wave samples from an AWE Flash File System container.
Module variables (run time)
Common to all modules:
Grain Size | Sets the length of each grain, denoted in milliseconds |
Grain Density | Sets the number of grain samples per second |
PlayDir | Playback direction 0=Forward 1=Backward 2=Auto (derived from fRatio input pin) |
Gain | The peak level of the window |
Smoothing Time | Time constant of the pitch smoothing process |
Module arguments (build time)
Common to all modules:
Max Grain Size | Max grain size in milliseconds |
Max Density | Max density in grains per sec |
Window Type | Selects the windowing function from these options: If using a custom window, you can load it into Array:window_coeffs. |
Window Length | Defines the length of the window in samples |
panModPin | Does the module display a pan mod pin? |
GranularSynthesisWaveFFS only:
Mute Module | dotted string specifier in subsystem.module format of a mute smoothed module to mute before making changes to parameters |
Unmute Module | dotted string specifier in subsystem.module format of a mute smoothed module to unmute after making changes to parameters |
GranularSynthesisWave (RAM & FFS):
Block Size | Number of samples in each output block |
Sample Rate | Sampling rate in Hz of the source (wave) file |
Normalized Playback Rate | Defines the playback rate of 1.0 |
Max Playback Rate | Maximum scaled playback rate |
File Name | Name of the file name including file ending (.wav) |
For Delay Granular Synthesis only:
Max Delay Time | Maximum delay time in msec |
Mem Heap | Heap in which to allocate delay buffer memory. |
Example Layouts
Scanning sections of a voice WAV file
Note: Place the WAV file into your AWE Server’s folder, e.g. C:\DSP Concepts\AWE Designer 8.D.1.2 Pro\Bin\win32-vc142-rel.
Depending on the source material, granular synthesis can impart a “robotic” quality on voices. The “filePos” control is moved while the layout is running in order to scan through the file section by section. Also experiment with the grain size and grain density controls.
Figure 12. Wave file scanning
Tempo Changes using the Granular Synthesis Delay
Note: Place the WAV files into your AWE Server’s folder, e.g. C:\DSP Concepts\AWE Designer 8.D.1.2 Pro\Bin\win32-vc142-rel.
This layout contains two looping WAV files going into separate Granular Delay lines. One of the WAV files is a drum loop while the other one is a synthesizer melody. They are both about 22.5 seconds long at a 24 kHz sampling rate. By default they are synchronized already.
Figure 13. Rhythmic audio source files
The granulation parameters are set to give a continuous sound. By using a triangle wave to change the delay position (delayPos), time compression and expansion without pitch shifting can be accomplished. This results in an apparent increase of the tempo. This can’t be sustained forever though, as you will eventually run out of delay buffer to scan through. So, half of the triangle’s cycle results in a tempo increase, while the other half results in a tempo decrease.
Figure 14. Wave Scanning Example layout
WAV loop player details
Figure 15. Wave Loop Player
The WAV loop player consists of a WAV file source, which outputs a fract32 to a typeConversion to float. The FIRInterp module converts the sample from 24 kHz to 48 kHz sampling rate. The DeInterleave separates the left and right channels which are added together to create a mono signal that goes on to the Granular Delay.
Tempo Shifter
The apparent shift in tempo is created by slowly changing the start point of grain playback using a slow triangle WAV LFO (Low Frequency Oscillator) that goes between 0 and 1, corresponding to the full length of the delay.
Figure 16. Tempo Shifting LFO
When the value of delayPos is increasing, you will hear the tempo decrease because more space is being put between successive grains. When the value of delayPos is decreasing, you will hear the tempo increase.
Figure 17. Part of the triangle LFO cycle
Pitch Control
While this layout allows you to change the apparent tempo of a sample without changing its pitch, a separate control for pitch is also available.
Figure 18. Pitch control
Dual Panner
Figure 19. Panner LFO
PeriodFuncGen2 is outputting a triangle wave that nominally goes from –1.0 to 1.0. The first ScaleOffset shifts this to 0.0 to 1.0, while the second ScaleOffset inverts that to 1.0 to 0.0, so that the two granular delay lines pan opposite each other. The rate and width of the panning can be adjusted using PeriodicFuncGen2’s inspector.
Figure 20. Panner LFO controls
Bypass
Each Granular Delay module has a bypass multiplexor so you can compare its output easily to the original WAV file. Unselect the “index” in the Multiplexor’s inspector to enable bypass.
Figure 21. Bypass multiplexor
Visualizing the granulation process
Note: Place the DC.WAV file in your AWE Server folder, e.g. C:\DSP Concepts\AWE Designer 8.D.1.2 Pro\Bin\win32-vc142-rel
By using a WAV file that just includes a fixed level, you can see the grain envelopes at the module’s output. Open the layout file, then open Sink2 and GranularSynthesisWaveRAM1’s inspector. Change the Grain Size, Grain Density, and gain to observe the grain shape and distribution. The pitch and filePos controls do not have any effect.
Changing grain size
With a small grain size, the grains do not overlap and you see the full window shape. As the grain size increases, so does overlap and the level goes up. Depending on the window type used, other interesting overlap effects can be seen.
Changing grain size using Blackman-Harris window
The Blackman-Harris window fills in and then goes up smoothly.
Changing grain size using Rectangular window
The Rect(angular) window, on the other hand, does not overlap smoothly and goes up by a series of jumps. Note the use of the gain control to set the maximum amplitude of a grain envelope including overlap effects.
Changing grain density
Changing grain density using Blackman-Harris window
Changing grain density using Rect window
Changing gain
The gain scales each grain so that you can avoid overloading when the grains start to overlap. It does not change the shape of the grain envelope, only its level.
Changing the gain
Selecting a different window type
This can only be done in Design mode. Access the windowType on the Arguments tab.
Arguments
Windows Type options
References
1. Ross Bencina , “Implementing Real-Time Granular Synthesis”, 2001.
2. Curtis Roads, “Automated Granular Synthesis of Sound,” Computer Music Journal
3. http://docs.propellerheads.se/reason10/images/Grain.32.1.2.png
4. https://lcav.gitbook.io/dsp-labs/granular-synthesis/effect_description
5. http://www.granularsynthesis.com/hthesis/sync.html
6. https://cmtext.indiana.edu/synthesis/chapter4_granular.php
7. https://joshstovall.com/writing/granular-synthesis/
8. https://ears2.dmu.ac.uk/courses/generated-sounds/lessons/granular-synthesis