# Gatestep

> Step gate: sixteen steps, each with its own level, chop the sound in time with the host (or the Tempo control). Each step opens for its duty then closes; Shape softens the edges from a hard chop to a smooth pulse; Swing delays every other step; Depth sets how far the closed gate goes down. Length shortens the pattern. Rate: 0 = 1/8, 1 = 1/16, 2 = 1/32, 3 = 1/16T.

- Engine id: `org.sournd.performance.gatestep`
- Category: Performance
- Licence: free: a closed library, free to use in your plugins, downloaded with no account or email
- Download (no account or email): https://sournd.com/download/free/macos (macOS universal), https://sournd.com/download/free/linux (Linux x86_64 and aarch64) or https://sournd.com/download/free/windows (Windows x64). One archive with every free engine: static library, C headers, README.
- Version: 1.0.0
- Latency: 0 samples
- Tail: 0 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/gatestep.mp3 (a drum loop, default settings)

## Parameters

The id is the C ABI parameter id and the JUCE parameter id (as a decimal string).

| Id | Key | Name | Min | Max | Default | Unit | Taper |
|---|---|---|---|---|---|---|---|
| 0 | `step_1` | Step 1 | 0 | 100 | 100 | % | linear |
| 1 | `step_2` | Step 2 | 0 | 100 | 100 | % | linear |
| 2 | `step_3` | Step 3 | 0 | 100 | 100 | % | linear |
| 3 | `step_4` | Step 4 | 0 | 100 | 100 | % | linear |
| 4 | `step_5` | Step 5 | 0 | 100 | 100 | % | linear |
| 5 | `step_6` | Step 6 | 0 | 100 | 100 | % | linear |
| 6 | `step_7` | Step 7 | 0 | 100 | 100 | % | linear |
| 7 | `step_8` | Step 8 | 0 | 100 | 100 | % | linear |
| 8 | `step_9` | Step 9 | 0 | 100 | 100 | % | linear |
| 9 | `step_10` | Step 10 | 0 | 100 | 100 | % | linear |
| 10 | `step_11` | Step 11 | 0 | 100 | 100 | % | linear |
| 11 | `step_12` | Step 12 | 0 | 100 | 100 | % | linear |
| 12 | `step_13` | Step 13 | 0 | 100 | 100 | % | linear |
| 13 | `step_14` | Step 14 | 0 | 100 | 100 | % | linear |
| 14 | `step_15` | Step 15 | 0 | 100 | 100 | % | linear |
| 15 | `step_16` | Step 16 | 0 | 100 | 100 | % | linear |
| 16 | `rate` | Rate | 0 | 3 | 1 | - | linear |
| 17 | `length` | Length | 1 | 16 | 16 | steps | linear |
| 18 | `depth` | Depth | 0 | 100 | 100 | % | linear |
| 19 | `duty` | Duty | 5 | 100 | 50 | % | linear |
| 20 | `shape` | Shape | 0 | 100 | 15 | % | linear |
| 21 | `swing` | Swing | 0 | 50 | 0 | % | linear |
| 22 | `tempo` | Tempo | 40 | 300 | 120 | bpm | linear |
| 23 | `mix` | Mix | 0 | 100 | 100 | % | linear |

## Use it in JUCE

CMake ([quick start](/docs/juce/index.md)):

```cmake
juce_add_module(path/to/sournd_engine)
target_include_directories(MyPlugin PRIVATE path/to/include)
target_link_libraries(MyPlugin PRIVATE sournd_engine path/to/libsournd_cabi.a)
```

C++:

```cpp
#include <sournd_engine/sournd_engine.h>

sournd::SourndEngine engine { "org.sournd.performance.gatestep" };
juce::AudioProcessorValueTreeState parameters { *this, nullptr, "Parameters",
    sournd::SourndEngineParameters::createLayout (engine) };
sournd::SourndEngineParameters bridge { engine, parameters };

// prepareToPlay
engine.prepare ({ sampleRate, (juce::uint32) maximumBlock, 2 });
bridge.prepare (sampleRate);
setLatencySamples ((int) engine.latency());

// processBlock
bridge.apply ((uint32_t) buffer.getNumSamples());
juce::dsp::AudioBlock<float> block { buffer };
engine.process (juce::dsp::ProcessContextReplacing<float> { block });

// get/setStateInformation: hold getCallbackLock() around saveState / loadState,
// so state work never overlaps processBlock (full example: /docs/juce/)
```

Plain C:

```c
sournd_engine *e = NULL;
if (sournd_engine_create("org.sournd.performance.gatestep", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 100); /* Step 1 */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design: a bar-locked step clock with pairwise swing, per-step target level for the open part of each step's duty cycle, a one-pole gain follower whose time grows with the shape control and the step length, and a depth blend toward unity.

## Ask your AI

Paste this into your coding assistant:

```text
Add the sournd engine org.sournd.performance.gatestep to my JUCE plugin. Follow https://sournd.com/docs/juce/index.md
and the engine reference at https://sournd.com/engines/gatestep/index.md. Expose every parameter through APVTS.
```
