pub struct Tone {
pub partials: Vec<Partial>,
pub envelope: Envelope,
pub duration: Duration,
}Fields§
§partials: Vec<Partial>Sinusoidal components that sum to form the tone.
envelope: EnvelopeAmplitude envelope applied across the tone.
duration: DurationTotal sounding length of the tone.
Implementations§
Source§impl Tone
impl Tone
Sourcepub fn sine(frequency: Frequency, duration: Duration) -> Self
pub fn sine(frequency: Frequency, duration: Duration) -> Self
Builds a pure sine tone at frequency with the default envelope.
Sourcepub fn sawtooth(
frequency: Frequency,
duration: Duration,
partials: usize,
) -> Self
pub fn sawtooth( frequency: Frequency, duration: Duration, partials: usize, ) -> Self
Builds a sawtooth tone from partials harmonics with 1/n amplitudes.
Sourcepub fn square(frequency: Frequency, duration: Duration, partials: usize) -> Self
pub fn square(frequency: Frequency, duration: Duration, partials: usize) -> Self
Builds a square tone from the odd harmonics within partials, with
1/n amplitudes.
Sourcepub fn triangle(
frequency: Frequency,
duration: Duration,
partials: usize,
) -> Self
pub fn triangle( frequency: Frequency, duration: Duration, partials: usize, ) -> Self
Builds a triangle tone from the odd harmonics within partials, with
1/n^2 amplitudes.
Sourcepub fn from_partials(
partials: Vec<Partial>,
envelope: Envelope,
duration: Duration,
) -> Result<Self, SoundCoreError>
pub fn from_partials( partials: Vec<Partial>, envelope: Envelope, duration: Duration, ) -> Result<Self, SoundCoreError>
Builds a tone from explicit partials, rejecting empty partial lists, zero durations, and invalid component values.
Sourcepub fn transpose_cents(self, cents: f64) -> Self
pub fn transpose_cents(self, cents: f64) -> Self
Returns the tone with every partial shifted by cents.
Sourcepub fn amplify(self, gain: f64) -> Self
pub fn amplify(self, gain: f64) -> Self
Returns the tone with every partial amplitude scaled by gain.
Sourcepub fn time_stretch(self, factor: f64) -> Result<Self, SoundCoreError>
pub fn time_stretch(self, factor: f64) -> Result<Self, SoundCoreError>
Returns the tone with its duration and envelope stages scaled by
factor, rejecting non-positive factors.