Work on documentation
This commit is contained in:
126
docs/engine_samples.md
Normal file
126
docs/engine_samples.md
Normal file
@@ -0,0 +1,126 @@
|
||||
# Samples
|
||||
|
||||
The `sample` source plays audio files from disk with pitch tracking.
|
||||
|
||||
## Loading Samples
|
||||
|
||||
There are two ways to load samples:
|
||||
|
||||
* **From the app:** Navigate to the Engine view and find the Samples section. Press `A` to open a file browser, then select a folder containing your samples. Press `D` to remove the last added path.
|
||||
|
||||
* **From the command line:** Use the `-s` flag when launching Cagire:
|
||||
|
||||
```
|
||||
cagire -s ~/samples -s ~/more-samples
|
||||
```
|
||||
|
||||
The engine scans these directories and builds a registry of available samples. Samples load in the background without blocking audio. Supported file formats are `.wav`, `.mp3`, `.ogg`, `.flac` and `.aiff`.
|
||||
|
||||
## Folder Organization
|
||||
|
||||
```
|
||||
samples/
|
||||
├── kick.wav → "kick"
|
||||
├── snare.wav → "snare"
|
||||
└── hats/
|
||||
├── closed.wav → "hats" n 0
|
||||
├── open.wav → "hats" n 1
|
||||
└── pedal.wav → "hats" n 2
|
||||
```
|
||||
|
||||
Folders at the root of your directory are used as the name of a sample bank. Folders create sample banks where each file gets an index. Files are sorted alphabetically and assigned indices starting from `0`.
|
||||
|
||||
## Playing Samples
|
||||
|
||||
```forth
|
||||
kick sound . ( play kick sample )
|
||||
hats sound 2 n . ( play third hat sample )
|
||||
snare sound 0.5 speed . ( play snare at half speed )
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `n` | 0+ | Sample index within a folder (wraps around) |
|
||||
| `begin` | 0-1 | Playback start position |
|
||||
| `end` | 0-1 | Playback end position |
|
||||
| `speed` | any | Playback speed multiplier |
|
||||
| `freq` | Hz | Base frequency for pitch tracking |
|
||||
| `fit` | seconds | Stretch/compress sample to fit duration |
|
||||
| `cut` | 0+ | Choke group |
|
||||
|
||||
## Slicing with Begin/End
|
||||
|
||||
The `begin` and `end` parameters define what portion of the sample plays. Values are normalized from 0 (start) to 1 (end).
|
||||
|
||||
```forth
|
||||
kick sound 0.25 begin 0.75 end . ( play middle half )
|
||||
kick sound 0.5 begin . ( play second half )
|
||||
kick sound 0.5 end . ( play first half )
|
||||
```
|
||||
|
||||
If begin is greater than end, they swap automatically.
|
||||
|
||||
## Speed and Pitch
|
||||
|
||||
The `speed` parameter affects both tempo and pitch. A speed of 2 plays twice as fast and an octave higher.
|
||||
|
||||
```forth
|
||||
snare sound 2 speed . ( double speed, octave up )
|
||||
snare sound 0.5 speed . ( half speed, octave down )
|
||||
snare sound -1 speed . ( play in reverse )
|
||||
```
|
||||
|
||||
For pitched playback, use `freq` or note names. The sample's base frequency defaults to middle C (261.626 Hz).
|
||||
|
||||
```forth
|
||||
kick sound 440 freq . ( play at A4 )
|
||||
kick sound c4 . ( play at C4 )
|
||||
```
|
||||
|
||||
Negative speed will reverse the sample and play it backwards.
|
||||
|
||||
```forth
|
||||
crow sound -1 speed . ( play backwards at nominal speed )
|
||||
crow sound -4 speed . ( play backwards, 4 times faster )
|
||||
```
|
||||
|
||||
## Fitting to Duration
|
||||
|
||||
The `fit` parameter stretches or compresses a sample to match a target duration in seconds. This adjusts speed automatically.
|
||||
|
||||
```forth
|
||||
kick sound 0.25 fit . ( fit kick into quarter second )
|
||||
snare sound beat fit . ( fit snare to one beat )
|
||||
```
|
||||
|
||||
## Choke Groups
|
||||
|
||||
The `cut` parameter assigns a sample to a choke group. When a new sample with the same cut value plays, it kills any currently playing samples in that group.
|
||||
|
||||
```forth
|
||||
hihat_closed sound 1 cut . ( choke group 1 )
|
||||
hihat_open sound 1 cut . ( kills closed hat, starts open )
|
||||
```
|
||||
|
||||
This is essential for realistic hi-hat behavior where open and closed hats shouldn't overlap.
|
||||
|
||||
## Bank Variations
|
||||
|
||||
Add `_suffix` to sample names to create variations that share the same base name.
|
||||
|
||||
```
|
||||
samples/
|
||||
├── kick.wav
|
||||
├── kick_hard.wav
|
||||
├── kick_soft.wav
|
||||
```
|
||||
|
||||
Select variations with the `bank` parameter:
|
||||
|
||||
```forth
|
||||
kick sound . ( plays kick.wav )
|
||||
kick sound hard bank . ( plays kick_hard.wav )
|
||||
kick sound soft bank . ( plays kick_soft.wav )
|
||||
```
|
||||
@@ -38,18 +38,86 @@ Smaller buffers mean lower latency but higher CPU load. Larger buffers are safer
|
||||
|
||||
Start with 512. Lower it if you need tighter timing. Raise it if you hear glitches.
|
||||
|
||||
### Samples
|
||||
## Samples
|
||||
|
||||
The engine indexes audio files from your sample directories. Add directories with `A`, remove with `D`. The sample count shows how many files are indexed. You can load as many sample banks as you want, they are not really loaded into memory but _lazily loaded_. They are loaded on demand when you play a sample. Samples are referenced by filename without extension:
|
||||
The engine indexes audio files from your sample directories. Add directories with `A`, remove with `D`. The sample count shows how many files are indexed.
|
||||
|
||||
### Supported Formats
|
||||
|
||||
- WAV (.wav)
|
||||
- MP3 (.mp3)
|
||||
- OGG Vorbis (.ogg)
|
||||
- FLAC (.flac)
|
||||
- AIFF (.aiff, .aif)
|
||||
- AAC (.aac)
|
||||
- M4A (.m4a)
|
||||
|
||||
### Lazy Loading
|
||||
|
||||
Samples are not loaded into memory at startup. They are decoded on demand when first played. This means you can have thousands of samples indexed without using much RAM until you actually use them.
|
||||
|
||||
### Folder Organization
|
||||
|
||||
The scanner looks at top-level files and one level of subdirectories:
|
||||
|
||||
```
|
||||
samples/
|
||||
├── kick.wav -> "kick"
|
||||
├── snare.wav -> "snare"
|
||||
├── hats/
|
||||
│ ├── closed.wav -> "hats" n 0
|
||||
│ ├── open.wav -> "hats" n 1
|
||||
│ └── pedal.wav -> "hats" n 2
|
||||
└── breaks/
|
||||
├── amen.wav -> "breaks" n 0
|
||||
└── think.wav -> "breaks" n 1
|
||||
```
|
||||
|
||||
Top-level files are named by their filename (without extension). Files inside folders are sorted alphabetically and numbered starting from 0.
|
||||
|
||||
### Playing Samples
|
||||
|
||||
Reference samples by name:
|
||||
|
||||
```forth
|
||||
kick s . ;; plays kick.wav, kick.mp3, etc.
|
||||
kick s . ;; play kick.wav
|
||||
snare s 0.5 gain . ;; play snare at half volume
|
||||
```
|
||||
|
||||
For samples in folders, use `n` to select which one:
|
||||
|
||||
```forth
|
||||
hats s 0 n . ;; play hats/closed.wav (index 0)
|
||||
hats s 1 n . ;; play hats/open.wav (index 1)
|
||||
hats s 2 n . ;; play hats/pedal.wav (index 2)
|
||||
```
|
||||
|
||||
The index wraps around. If you have 3 samples and request `5 n`, you get index 2 (because 5 % 3 = 2).
|
||||
|
||||
### Sample Variations with Bank
|
||||
|
||||
The `bank` parameter lets you organize variations:
|
||||
|
||||
```
|
||||
samples/
|
||||
├── kick.wav -> default
|
||||
├── kick_a.wav -> bank "a"
|
||||
├── kick_b.wav -> bank "b"
|
||||
└── kick_hard.wav -> bank "hard"
|
||||
```
|
||||
|
||||
```forth
|
||||
kick s . ;; plays kick.wav
|
||||
kick s a bank . ;; plays kick_a.wav
|
||||
kick s hard bank . ;; plays kick_hard.wav
|
||||
```
|
||||
|
||||
If the banked version does not exist, it falls back to the default.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
* **No sound**: Check output device selection.
|
||||
* Try the test sound (`t`) on Engine page).
|
||||
* Try the test sound (`t`) on Engine page).
|
||||
|
||||
* **Glitches/crackling**: Increase buffer size, restart the Engine.
|
||||
|
||||
|
||||
92
docs/engine_sources.md
Normal file
92
docs/engine_sources.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Sources
|
||||
|
||||
The audio engine provides a variety of sound sources. Use the `sound` word (or `s` for short) to select one.
|
||||
|
||||
## Basic Oscillators
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| `sine` | Pure sinusoid, smooth and mellow |
|
||||
| `tri` | Triangle wave, warmer than sine, naturally band-limited |
|
||||
| `saw` | Bright sawtooth with anti-aliasing, rich in harmonics |
|
||||
| `zaw` | Raw sawtooth without anti-aliasing, lo-fi character |
|
||||
| `pulse`, `square` | Variable-width pulse wave with anti-aliasing |
|
||||
| `pulze`, `zquare` | Raw pulse without anti-aliasing, 8-bit feel |
|
||||
|
||||
`pulse` and `pulze` respond to the `pw` parameter (0.0-1.0) for pulse width. At 0.5 you get a square wave.
|
||||
|
||||
### Phase Shaping
|
||||
|
||||
All oscillators support phase shaping for timbral variation:
|
||||
|
||||
| Parameter | Range | Effect |
|
||||
|-----------|-------|--------|
|
||||
| `size` | 0-256 | Phase quantization (lo-fi, chiptune). |
|
||||
| `mult` | 0.25-16 | Phase multiplier (harmonic overtones). |
|
||||
| `warp` | -1 to 1 | Power curve asymmetry. |
|
||||
| `mirror` | 0-1 | Phase reflection point. |
|
||||
|
||||
These are super useful to get the most out of your oscillators.
|
||||
|
||||
### Sub Oscillator
|
||||
|
||||
Add a sub oscillator layer to any basic oscillator:
|
||||
|
||||
| Parameter | Range | Effect |
|
||||
|-----------|-------|--------|
|
||||
| `sub` | 0-1 | Mix level |
|
||||
| `suboct` | 1-3 | Octaves below main. |
|
||||
| `subwave` | tri/sine/square | Sub waveform. |
|
||||
|
||||
## Noise
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| `white` | Equal energy across all frequencies, bright and hissy. |
|
||||
| `pink` | -3dB/octave rolloff, equal energy per octave, natural. |
|
||||
| `brown` | -6dB/octave rolloff, deep rumbling, random walk. |
|
||||
|
||||
Noise sources ignore pitch. Use filters to shape the spectrum.
|
||||
|
||||
## Live Input
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| `live`, `livein`, `mic` | Live audio input from microphone or line-in |
|
||||
|
||||
All filter and effect parameters apply to the input signal.
|
||||
|
||||
## Plaits Engines
|
||||
|
||||
The Plaits engines come from Mutable Instruments and provide a range of synthesis methods. Beware, these sources can be quite CPU hungry. All share three control parameters (`0.0`-`1.0`):
|
||||
|
||||
| Parameter | Controls |
|
||||
|-----------|----------|
|
||||
| `harmonics` | Harmonic content, structure, detuning. |
|
||||
| `timbre` | Brightness, tonal color. |
|
||||
| `morph` | Smooth transitions between variations. |
|
||||
|
||||
### Pitched
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| `modal` | Struck/plucked resonant bodies (strings, plates, tubes). |
|
||||
| `va`, `analog` | Virtual analog with waveform sync and crossfading. |
|
||||
| `ws`, `waveshape` | Waveshaper and wavefolder. |
|
||||
| `fm2` | Two-operator FM synthesis with feedback. |
|
||||
| `grain` | Granular formant oscillator (vowel-like). |
|
||||
| `additive` | Harmonic additive synthesis. |
|
||||
| `wavetable` | Built-in Plaits wavetables (four 8x8 banks). |
|
||||
| `chord` | Four-note chord generator. |
|
||||
| `swarm` | Granular cloud of enveloped sawtooths. |
|
||||
| `pnoise` | Clocked noise through multimode filter. |
|
||||
|
||||
### Percussion
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| `kick`, `bass` | 808-style bass drum. |
|
||||
| `snare` | Analog snare drum with tone/noise balance. |
|
||||
| `hihat`, `hat` | Metallic 808-style hi-hat. |
|
||||
|
||||
Percussions are super hard to use correctly, because you need to tweak their envelope correctly.
|
||||
87
docs/engine_wavetable.md
Normal file
87
docs/engine_wavetable.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# Wavetables
|
||||
|
||||
Any sample can be played as a wavetable. When you use the `scan` parameter, the sample automatically becomes a pitched oscillator that can morph between cycles.
|
||||
|
||||
## What is a Wavetable?
|
||||
|
||||
A wavetable is a series of single-cycle waveforms stored end-to-end in an audio file. Each cycle is a complete waveform that starts and ends at zero crossing, allowing it to loop seamlessly at any pitch.
|
||||
|
||||
```
|
||||
Sample: [cycle 0][cycle 1][cycle 2][cycle 3]
|
||||
↑ ↑
|
||||
scan 0 scan 1
|
||||
```
|
||||
|
||||
The oscillator reads through one cycle at audio rate (determining pitch), while `scan` selects which cycle to play. Values between cycles crossfade smoothly, creating timbral morphing.
|
||||
|
||||
## Basic Usage
|
||||
|
||||
Just add `scan` to any sample and it becomes a wavetable:
|
||||
|
||||
```forth
|
||||
pad 0 scan . ( play pad as wavetable, first cycle )
|
||||
pad 0.5 scan . ( blend to middle cycles )
|
||||
pad 440 freq 0 scan . ( play at A4 )
|
||||
```
|
||||
|
||||
Without `scan`, the sample plays normally. With `scan`, it becomes a looping wavetable oscillator.
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `scan` | 0-1 | Position in wavetable (0 = first cycle, 1 = last) |
|
||||
| `wtlen` | samples | Cycle length in samples (0 = entire sample) |
|
||||
| `scanlfo` | Hz | LFO rate for scan modulation |
|
||||
| `scandepth` | 0-1 | LFO modulation depth |
|
||||
| `scanshape` | shape | LFO waveform |
|
||||
|
||||
## Cycle Length
|
||||
|
||||
The `wtlen` parameter tells the engine how many samples make up one cycle. This must match how the wavetable was created, otherwise you'll hear the wrong pitch or glitchy artifacts.
|
||||
|
||||
```forth
|
||||
pad 0 scan 2048 wtlen . ( Serum-style 2048-sample cycles )
|
||||
pad 0 scan 1024 wtlen . ( 1024-sample cycles )
|
||||
```
|
||||
|
||||
Common cycle lengths are powers of two: 256, 512, 1024, 2048. Serum uses 2048 samples per cycle. The number of cycles in a wavetable is the total sample length divided by `wtlen`. If `wtlen` is 0 (default), the entire sample is treated as one cycle. The sample still loops as a pitched oscillator, but `scan` has no morphing effect since there's only one cycle.
|
||||
|
||||
## Scanning
|
||||
|
||||
The `scan` parameter selects which cycle to play:
|
||||
|
||||
```forth
|
||||
pad 0 scan . ( first cycle only )
|
||||
pad 0.5 scan . ( blend between middle cycles )
|
||||
pad 1 scan . ( last cycle only )
|
||||
```
|
||||
|
||||
## LFO Modulation
|
||||
|
||||
Automate the scan position with a built-in LFO:
|
||||
|
||||
```forth
|
||||
pad 0 scan 2 scanlfo 0.3 scandepth . ( 2 Hz modulation, 30% depth )
|
||||
```
|
||||
|
||||
Available LFO shapes:
|
||||
|
||||
| Shape | Description |
|
||||
|-------|-------------|
|
||||
| `sine` | Smooth oscillation (default) |
|
||||
| `tri` | Triangle wave |
|
||||
| `saw` | Sawtooth, ramps up |
|
||||
| `square` | Alternates between extremes |
|
||||
| `sh` | Sample and hold, random steps |
|
||||
|
||||
## Creating Wavetables
|
||||
|
||||
A proper wavetable file:
|
||||
|
||||
- Contains multiple single-cycle waveforms of identical length
|
||||
- Each cycle starts and ends at zero crossing for seamless looping
|
||||
- Uses power-of-two cycle lengths (256, 512, 1024, 2048)
|
||||
- Has cycles that morph smoothly from one to the next
|
||||
|
||||
You can find wavetable packs online or create your own in tools like Serum, WaveEdit, or Audacity (using zero-crossing snap). Single-cycle waveforms also work. With `wtlen` set to 0, a single-cycle sample becomes a basic pitched oscillator.
|
||||
Reference in New Issue
Block a user