pub struct Drum {
pub kind: DrumKind,
pub kit: DrumKit,
pub pitch_hz: u16,
pub tone_ms: u32,
pub noise_ms: u32,
pub sweep_cents: u16,
pub sweep_ms: u32,
pub noise_percent: u8,
pub click_percent: u8,
pub seed: u32,
}Expand description
A drum preset with integer, portable controls. Notes transpose pitched components relative to C4; noise filters stay fixed. Envelope times are finite lengths, not exponential time constants. Each trigger resets oscillators, filters and seed. A component shorter than its 1 ms attack (including a one-frame envelope at low sample rates) can be silent. Presets use longer envelopes.
Fields§
§kind: DrumKind§kit: DrumKit§pitch_hz: u16Fundamental/metal-bank base at C4, 20..=20000 Hz, clamped below Nyquist.
tone_ms: u32Tone envelope length, 0..=10000 ms. Zero silences that component.
noise_ms: u32Noise envelope length, 0..=10000 ms. Clap adds 30 ms for its initial bursts.
sweep_cents: u16Initial pitch above the base, 0..=4800 cents, falling linearly in cents.
sweep_ms: u32Time to reach the base pitch, 0..=1000 ms. Zero starts at the base.
noise_percent: u8Noise blend, 0..=100 percent; the tone receives the complementary amount.
click_percent: u8A separate 3 ms filtered-noise transient, 0..=100 percent.
seed: u32Fixed noise seed. Zero maps to one; the chiptune register uses its low 15 bits.