nidhi
nidhi (Sanskrit: treasure) — Sample playback engine for AGNOS.
Polyphonic sampler with key/velocity zones, ADSR envelopes, loop modes, time-stretching, SFZ/SF2 import, sample capture, and per-instrument effects.
Features
- Polyphonic engine — configurable voice stealing (Oldest/Quietest/Lowest/None), poly/mono/legato modes
- Key/velocity zones — full MIDI range mapping, round-robin groups, choke groups, velocity curves
- ADSR envelopes — per-voice and per-zone, with smooth release from any level
- Filters — SVF (LP/HP/BP/Notch) via naad, true stereo, with envelope and LFO modulation
- Loop modes — OneShot, Forward, PingPong, Reverse, LoopSustain (release exits loop), crossfade loops
- Expression — per-note pitch bend, pressure/aftertouch, brightness (CC#74), key tracking
- SFZ import — 40+ opcodes, note names,
<control>/<curve>,#include,_onccNCC modulation - SF2 import — RIFF binary parser, preset/zone extraction, PCM16 to f32
- Sample capture — record audio, auto-trim, normalize, onset detection, loop point detection
- Effects — per-instrument chain (reverb, delay, chorus, compressor, limiter) via naad
- WAV loading —
iofeature for file and in-memory WAV loading, plus streaming for large instruments - Time-stretching — WSOLA and OLA algorithms (offline)
- Multi-output — per-zone bus routing
- Built on naad — shares audio synthesis primitives with the AGNOS ecosystem
- no_std compatible — works with
alloc, no standard library required
Quick Start
use *;
let sample = from_mono;
let mut bank = new;
let id = bank.add;
let zone = new.with_key_range.with_root_note;
let mut inst = new;
inst.add_zone;
let mut engine = new;
engine.set_bank;
engine.set_instrument;
engine.note_on;
let = engine.next_sample_stereo;
SFZ Import
use *;
use sfz;
let input = r#"
<control> default_path=samples/
<global> lovel=0 hivel=127
<group> lokey=60 hikey=72
<region> sample=piano_c4.wav pitch_keycenter=60
<region> sample=piano_c5.wav pitch_keycenter=72
"#;
let sfz_file = parse.unwrap;
let = sfz_file.to_instrument;
SF2 Import
use sf2;
let bytes = read.unwrap;
let = parse.unwrap;
Feature Flags
| Feature | Default | Description |
|---|---|---|
std |
Yes | Standard library + naad integration. Disable for no_std + alloc |
io |
No | WAV file loading and streaming via shravan (implies std) |
simd |
No | SIMD-accelerated stereo mixing and interpolation (implies std) |
logging |
No | tracing-subscriber for debug logging |
full |
No | Enables std + io + simd + logging |
Architecture
SamplerEngine
/ | | \
Instrument SampleBank EffectChain SampleRecorder
| |
Zone[] Sample[]
|
LoopMode, filter, LFO, pan, tune, ADSR
|
SfzFile / SF2 (import) TimeStretcher (offline)
Consumers
License
GPL-3.0-only