pub struct Voice {
pub kind: OscKind,
pub freq: Option<FreqSpec>,
pub sweep: Option<f32>,
pub filter: Option<FilterSpec>,
pub attack: f32,
pub decay: f32,
pub sustain: f32,
pub hold: f32,
pub release: f32,
pub gain: f32,
pub seed: Option<u32>,
}Expand description
One instrument: an oscillator or a noise source, an optional filter,
and an ADSR envelope (attack/decay/sustain/hold/release — see
dsp::Adsr’s doc for why hold stands in for a note-off this score
model never sends). Every field but type and decay has a
drum-machine-flavoured default, so the issue’s own two-voice example
("kick": {"type":"sine","freq":[150,42],"sweep":0.14,"decay":0.38})
needs nothing else.
Fields§
§kind: OscKind§freq: Option<FreqSpec>Required for every type but noise; ignored for noise. Falls
back to 440Hz if omitted on a tonal voice rather than erroring —
consistent with this module’s general posture (see
dsp::BiquadCoeffs::design’s doc) of making an underspecified
voice audible rather than rejecting it.
sweep: Option<f32>Seconds the freq sweep takes to go from its first to its second
value. Ignored unless freq is FreqSpec::Sweep.
filter: Option<FilterSpec>§attack: f32§decay: f32§sustain: f32§hold: f32§release: f32§gain: f32§seed: Option<u32>Seeds this voice’s dsp::Xorshift32 noise source. Two noise
voices with no explicit seed share the same fixed default and so
sound identical to each other — a minor aesthetic simplification
documented here rather than hidden; give each its own seed to
tell them apart.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Voice
impl<'de> Deserialize<'de> for Voice
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Voice
impl JsonSchema for Voice
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for Voice
impl RefUnwindSafe for Voice
impl Send for Voice
impl Sync for Voice
impl Unpin for Voice
impl UnsafeUnpin for Voice
impl UnwindSafe for Voice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more