74 lines
3.2 KiB
Markdown
74 lines
3.2 KiB
Markdown
# Audio Engine
|
|
|
|
Cagire uses **Doux** as its audio engine ([https://doux.livecoding.fr](https://doux.livecoding.fr)). Doux is a standalone synthesis and sampling engine that receives commands as strings and turns them into sound. Doux is a fixed graph synthesizer, which means that the structure of the sound is defined by a fixed set of nodes and connections, and the parameters of these nodes can be adjusted to create different sounds. Doux is extremely versatile and you are likely to find it useful for a wide range of musical styles and genres.
|
|
|
|
## How Sound is Produced
|
|
|
|
When the sequencer hits an active step, the Forth script is compiled and executed. Each emit operation (`.`) generates a command string that is sent to Doux. The command encodes the sound name and all accumulated parameters. The following example script:
|
|
|
|
```
|
|
"saw" sound c4 note 0.5 gain 2000 lpf .
|
|
```
|
|
|
|
will produce a command string that Doux interprets to _play a saw wave at C4 with gain 0.5 and a 2kHz lowpass filter_.
|
|
|
|
## Sound sources
|
|
|
|
Each sound needs a source. Sources are defined by typing their name followed by the `sound` keyword. Sources are raw waveforms or samples. They are shaped by passing additional parameters that will modify the characteristics of the sound: envelopes, effects, synthesis options, etc. The following example defines a source named `saw` with a frequency of 440 Hz, a gain of 0.5 and some reverb:
|
|
|
|
```
|
|
"saw" source 440 freq 0.5 gain 0.5 verb .
|
|
```
|
|
|
|
The audio engine offers a vast array (~20+) of sources including oscillators, noises, live input, and more.
|
|
|
|
## Settings
|
|
|
|
- **Channels**: Output channel count (1-64)
|
|
- **Buffer Size**: Audio buffer in samples (64-4096). Lower values reduce latency but increase CPU load.
|
|
- **Voices**: Maximum polyphony (1-128, default 32). When the limit is reached, the oldest voice is stolen.
|
|
|
|
Settings are persisted across sessions.
|
|
|
|
## Samples
|
|
|
|
Cagire scans sample directories recursively and indexes all audio files. Add sample paths on the Engine page with **a**, remove with **d**. Use samples in scripts by name:
|
|
|
|
```
|
|
"kick" s .
|
|
"hat" s 0.5 gain .
|
|
```
|
|
|
|
The sample index is shown on the Engine page with the total count.
|
|
|
|
## Visualizers
|
|
|
|
The Engine page displays two real-time visualizers:
|
|
|
|
- **Scope**: Waveform display (64 samples), updated on every audio callback
|
|
- **Spectrum**: 32-band FFT analyzer with logarithmic frequency scaling (20Hz to Nyquist), Hann window, displayed in dB
|
|
|
|
Both can be toggled on or off in the Options page.
|
|
|
|
## Monitoring
|
|
|
|
The Engine page shows live metrics:
|
|
|
|
- **Active voices**: Current polyphony count
|
|
- **Peak voices**: Highest voice count since last reset (press **r** to reset)
|
|
- **CPU load**: Audio thread utilization
|
|
- **Events**: Total emitted and dropped event counts
|
|
|
|
## Tempo Scaling
|
|
|
|
Some parameters are automatically scaled by step duration so they sound consistent across tempos. These include envelope times (attack, decay, release), filter envelopes, pitch envelopes, FM envelopes, glide, and reverb/delay times.
|
|
|
|
## Commands
|
|
|
|
On the Engine page:
|
|
|
|
- **h**: Hush (graceful fade-out of all voices)
|
|
- **p**: Panic (hard stop all voices immediately)
|
|
- **r**: Reset peak voice counter
|
|
- **t**: Test sound (plays a 440Hz sine)
|