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§
Provided Methods§
sourcefn alter_pitch_by(&self, delta: Ratio) -> NoteAtConcertPitch
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.