Trait tune::note::PitchedNote

source ·
pub trait PitchedNote: Pitched {
    // Required method
    fn note(&self) -> Note;

    // Provided method
    fn alter_pitch_by(&self, delta: Ratio) -> NoteAtConcertPitch { ... }
}
Expand description

Trait for objects that provide Pitch and Note information.

A Note has a unique pitch defined by the 440 Hz standard tuning. For a note to sound at a different Pitch the type alias NoteAtConcertPitch is used.

Required Methods§

source

fn note(&self) -> Note

Retrieves the Note part of self.

use tune::note::PitchedNote;

let c4 = NoteLetter::C.in_octave(4);
assert_eq!(c4.note(), c4);

let c4_altered = c4.at_pitch(Pitch::from_hz(256.0));
assert_eq!(c4_altered.note(), c4);

Provided Methods§

source

fn alter_pitch_by(&self, delta: Ratio) -> NoteAtConcertPitch

Returns a new PitchedNote with the same Note part but a Pitch altered by delta.

Examples
use tune::note::PitchedNote;
use tune::pitch::Pitched;

let a4 = NoteLetter::A.in_octave(4);
let a4_altered = a4.alter_pitch_by(Ratio::from_float(1.01));
assert_eq!(a4_altered.note(), a4);
assert_approx_eq!(a4_altered.pitch().as_hz(), 444.4);

Object Safety§

This trait is not object safe.

Implementors§