Logo
← Back

October 25, 2026

Step 8: From One LFO to a Modulation System

Turning a useful first oscillator into a flexible architecture for movement across the grain cloud.

In Step 7, Drizel gained its first modulation source: a low-frequency oscillator that can move grain position or pitch. That was enough to make a static cloud evolve, but it also revealed the next design problem. If every new kind of movement needs its own special path through the audio engine, the system will become difficult to extend.

Step 8 is about making modulation a shared language. A source produces a control signal, a route connects that signal to a destination, and the destination applies it within its own range. The LFO remains useful, but it becomes one source among several rather than the whole system.

1. Separate sources from destinations

A modulation source describes how a value changes over time. A destination describes which synth parameter receives that change. They answer different questions, so they should not be built into one another.

SourceCharacterPossible use
LFORepeating and rate-controlledA regular scan or pulse
EnvelopeChanges in response to an eventA shaped rise and fall
Random walkSlow, bounded, seeded driftLess repetitive movement

These sources have different timing and state. An LFO advances its phase continuously. An envelope needs a trigger and a defined shape. A random walk changes its target over time and needs a rule for how far it may wander. The engine should not need to know those details; it should consume modulation values through a common interface.

A shared interface does not mean every source behaves the same. It means the rest of the system can ask each source for its current value without knowing how that value was made.

class ModulationSource
{
public:
    virtual ~ModulationSource() = default;
    virtual float next() noexcept = 0;
    virtual void reset() noexcept = 0;
};

This is an architectural sketch, not a claim that Drizel already has this interface. The actual implementation should choose a representation that fits the audio callback and avoids unnecessary dynamic dispatch or allocation there.

2. Give modulation values clear meanings

A source value is not yet a parameter value. A normalized position is measured between 0 and 1, pitch is measured in semitones, and density is measured in grain starts per second. Treating all three as interchangeable numbers would make routing ambiguous.

Each destination needs a base value, a modulation amount, and a mapping from the source's range into that destination's units. For a bipolar source and a normalized position, that might look like this:

position target = base position
               + source value × amount × position range

safe position = clamp(position target, 0, 1)

For pitch, the same source could instead be scaled in semitones. A small amount might create a gentle drift; a larger one might sweep across a wider interval. The source stays reusable because the route supplies the destination-specific units and range.

Sources can also be unipolar or bipolar. An envelope commonly moves from zero toward one, while the Step 7 LFO moves above and below zero. The route must account for that difference rather than quietly assuming that every source has the same range.

3. Make a route small and explicit

A route can be described with three pieces: which source to read, which destination to affect, and how much influence to apply. With that boundary in place, new sources can be added without rewriting the grain engine for each one.

struct ModulationRoute
{
    ModSourceId source;
    ModDestination destination;
    float amount;
};

This is also the point where multiple routes become possible. One slow LFO could move position while a random walk adds a smaller offset to spread. Their contributions can be combined with the base parameter, then clamped once to the destination range.

target = base
       + route 1 contribution
       + route 2 contribution

safe target = clamp(target, destination minimum, destination maximum)
current value = smooth(current value, safe target)

The order matters. Combining routes before clamping preserves their intended relationship; applying the same smoothing path after the final target keeps the engine's response consistent. Destination-specific limits still decide what is valid.

4. Extend movement across the grain cloud

The Step 7 prototype focuses on position and pitch. The broader modulation design can include density and spread as well:

  • Position changes where newly launched grains read from the source sample.
  • Pitch changes the playback rate chosen for new grains.
  • Density changes how frequently the scheduler launches grains.
  • Spread changes how broadly grains are distributed in the stereo field.

These parameters do not have the same units or perceptual effect. A route should therefore identify its destination and let that destination define its safe range and interpretation. Modulation adds motion; it should not bypass the parameter rules that keep the instrument predictable.

5. Keep the audio path predictable

All of this movement eventually reaches the real-time audio callback. The same constraints from Step 6 and Step 7 still apply: no file access, blocking locks, memory allocation, or unpredictable work in the processing loop.

A source should keep only the state it needs. The LFO needs phase; an envelope needs its current stage and level; a random walk needs its current value and random-generator state. Parameters can be read once per block, while the modulation values and smoothed targets are updated at the cadence required by the engine.

Random movement also needs reproducible rules. A seed makes a random walk repeatable for tests and renders, while bounded steps keep it from wandering beyond its destination's range. Randomness can make a texture less predictable without making the software itself unpredictable.

6. Test the system, not just the waveforms

Testing the LFO's sine and triangle shapes was a useful start. A general system needs tests for the connections between sources and parameters too:

  • Each source stays within its documented output range.
  • An envelope follows its trigger and stage timing rules.
  • Identical random-walk seeds produce identical sequences.
  • A route with zero amount leaves its base value unchanged.
  • Combined routes remain inside the destination's limits.
  • Adding a source does not require source-specific engine branches.

These checks establish correctness, but they do not replace listening. The final modulation amounts and rates need to feel useful across different samples, and callback timing still needs to be measured on the target build.

7. A foundation for what comes next

The Drizel roadmap describes a broader modulation layer: reusable sources, explicit routes, and a shared path for smoothing the values that reach the engine. Step 7 is the first working increment of that layer, not its completion. Envelopes, seeded random walks, and routing to density and spread remain follow-on work.

That distinction is important. A clean design is not the same as a finished feature, and an architecture sketch is not a test result. The next milestone is to implement these pieces, verify them with automated tests, measure their cost in the callback, and listen to how they shape the sound.

Once sources and destinations can evolve independently, the grain cloud gets more than another control. It gets a foundation for motion that can be extended without losing sight of musical intent or real-time reliability.

Video explanation

Command Palette

Search for a command to run...