SPB Git

Repository Public

README.md 3.1 KB 62 lines markdown

1<!--2ORIX Sonata3File: Documentation/acoustics/README.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Acoustics of the Sonata instruments89Every engine in `crates/sonata-instruments` is described here: the equations it implements,10what it approximates, and where the approximation stops being valid. **None of these engines is11an exact physical simulation.** They are physically informed signal models chosen for stable,12in-tune, real-time behaviour.1314| Model | File | Method | Self-oscillating? |15|---|---|---|---|16| `plucked_string`, `bass` (electric) | [strings.md](strings.md) | Extended Karplus-Strong waveguide | passive loop |17| `bowed_string` | [strings.md](strings.md) | Two-segment waveguide + friction curve | yes |18| `piano` | [piano.md](piano.md) | Modal sum of stiff-string partials | no (struck) |19| `clarinet` | [winds.md](winds.md) | Waveguide bore + reed table | yes |20| `flute` | [winds.md](winds.md) | Forced jet into a waveguide tube | **no, excitation prescribed** |21| `brass` | [winds.md](winds.md) | Forced lip valve into a waveguide tube | **no, excitation prescribed** |22| `modal_percussion`, `kick`, `snare`, `hihat` | [percussion.md](percussion.md) | Modal sums, swept sine, filtered noise | no |23| `organ`, `synth`, `fm`, `bass` (synth), `voice`, `patch` | [synthesis.md](synthesis.md) | Additive, subtractive, FM, formant, graph | n/a |2425## Conventions2627* Sample rate `fs`, fundamental `f0`, period in samples `P = fs / f0`, `w0 = 2 pi f0 / fs`.28* "T60" is the time for a 60 dB decay. A per-sample gain `g` gives `T60 = -6.908 / (fs ln g)`.29* Levels: one note at velocity 1 on the default preset peaks between -24 and -3 dBFS30  (test `every_preset_sounds_is_finite_and_below_full_scale`); every preset stays below 0 dBFS.3132## Measured tuning (48 kHz, default presets, vibrato and detuning off)3334Measured by `cargo test -p sonata-instruments --test engines -- --nocapture` (lines `TUNING`),35at the bottom, middle and top of each range. Tolerances enforced by the tests are in parentheses.3637| Model | Low | Middle | High | Tolerance |38|---|---|---|---|---|39| piano (fundamental, spectral peak) | +0.00 | -0.00 | -0.00 | 2 cents |40| plucked_string | +0.01 | +0.03 | +0.02 | 3 |41| bowed_string | -0.07 | -0.03 | -3.59 | 6 |42| flute | +0.00 | +0.00 | -0.00 | 2 |43| clarinet | +0.23 | +1.03 | +0.84 | 4 |44| brass | -0.01 | +0.00 | -0.00 | 2 |45| organ (8' only) | -0.04 | -0.00 | -0.01 | 2 |46| bass | +0.00 | +0.00 | +0.01 | 3 |47| synth, fm, voice | within 0.13 | | | 2 |48| modal_percussion (fundamental) | -0.00 | -0.00 | -0.00 | 2 |4950At 44.1, 96 and 192 kHz the tests allow twice these tolerances; `examples/calibrate.rs` prints51the full tables. The bowed string is the only engine with a measured correction table52(`TUNING` in `bowed.rs`): its friction loop plays up to 12 cents sharp above MIDI 88 without it.5354## Reproducing5556```bash57cargo test -p sonata-instruments                      # all behaviour tests58cargo run --release -p sonata-instruments --example audition   # WAV files in build/audition/59cargo run --release -p sonata-instruments --example calibrate  # tuning tables60cargo run --release -p sonata-instruments --example bench 16   # cost per engine61```62
Files main
Menu

Theme