A granular synth package for the scriptable audio pipeline.
For creating dynamic sounds such as: Vehicles, Scrapes, Light-sabers or ambiences.
Features
- Granular Synth, configurable as a ScriptableObject.
- Controls: Rate, Playback Position Range, Pitch Range, Volume Range, Pan Range, Grain Size Range.
- Configurable Grain Shape.
- Stereo Sample Support.
- Live Preview.
- Toggleable Anti-Phasing.
- Range Control script that acts as a macro modulator.
Basic Setup
Create a Granular Generator by right-clicking in the Assets folder and selecting: Audio → Generators → Granular Generator.
Add the audio file you want to granulate to the AudioClip field.
Assign the ScriptableObject to an AudioSource in the scene. Make sure the AudioSource is audible to your AudioListener.
With Live Preview enabled, play the scene to hear the granular synth in action.
Configure the different parameters of the ScriptableObject until you achieve the desired result.
Dynamic Input
Granular synthesis is best suited for dynamic (changing) sounds that are hard to represent with a typical loop such as vehicles, scraping, creaking and dynamic weather or water systems.
To configure dynamic controls you can modulate values by assigning targets in the modulation matrix.
To modulate the inputs: attach the script to an AudioSource with a granulator and call audioSource.SetModulation1(normalizedInput);.
For more specific or advanced modulation, you can send your own modulation messages. Check out the deprecated methods in GranularSynthExtension.cs to get a grasp on how to do this.
To add additional features or write custom messages, see the Unity Documentation on the Scriptable Pipeline.