Struct redact_composer_musical::PitchClass
source · pub struct PitchClass(pub u8);
Expand description
An octave-independent note.
Tuple Fields§
§0: u8
Implementations§
source§impl PitchClass
impl PitchClass
sourcepub fn values() -> Vec<PitchClass>
pub fn values() -> Vec<PitchClass>
Returns all valid PitchClass
values (0..=11).
sourcepub fn all_in_range<R: RangeBounds<Note>>(range: R) -> Vec<PitchClass>
pub fn all_in_range<R: RangeBounds<Note>>(range: R) -> Vec<PitchClass>
Returns all pitch classes contained in the given note range.
use redact_composer_musical::{Note, NoteName::{C, F}, PitchClass as PC};
assert_eq!(
PC::all_in_range(Note::from((C, 3))..=Note::from((F, 3))),
vec![PC(0), PC(1), PC(2), PC(3), PC(4), PC(5)]
);
assert_eq!(
PC::all_in_range(Note::from((C, 3))..=Note::from((C, 5))),
PC::values()
);
sourcepub fn in_octave(&self, octave: i8) -> Note
pub fn in_octave(&self, octave: i8) -> Note
Returns the Note
with this pitch class in a given octave.
use redact_composer_musical::{Note, NoteName::C, PitchClass};
assert_eq!(PitchClass::from(C).in_octave(4), Note(60));
sourcepub fn above(&self, note: &Note) -> Note
pub fn above(&self, note: &Note) -> Note
Returns the next Note
of this pitch class above the given note. If the given note is already of this pitch
class, the note an octave above is returned.
use redact_composer_musical::{Note, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(G).above(&Note::from((C, 3))), Note::from((G, 3)));
assert_eq!(PitchClass::from(G).above(&Note::from((G, 3))), Note::from((G, 4)));
sourcepub fn at_or_above(&self, note: &Note) -> Note
pub fn at_or_above(&self, note: &Note) -> Note
Returns the next Note
of this pitch class at or above the given note.
use redact_composer_musical::{Note, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(G).at_or_above(&Note::from((C, 3))), Note::from((G, 3)));
assert_eq!(PitchClass::from(G).at_or_above(&Note::from((G, 3))), Note::from((G, 3)));
sourcepub fn below(&self, note: &Note) -> Note
pub fn below(&self, note: &Note) -> Note
Returns the next Note
of this pitch class below the given note. If the given note is already of this pitch
class, the note an octave below is returned.
use redact_composer_musical::{Note, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(G).below(&Note::from((C, 3))), Note::from((G, 2)));
assert_eq!(PitchClass::from(G).below(&Note::from((G, 3))), Note::from((G, 2)));
sourcepub fn at_or_below(&self, note: &Note) -> Note
pub fn at_or_below(&self, note: &Note) -> Note
Returns the next Note
of this pitch class at or below the given note.
use redact_composer_musical::{Note, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(G).at_or_below(&Note::from((C, 3))), Note::from((G, 2)));
assert_eq!(PitchClass::from(G).at_or_below(&Note::from((G, 3))), Note::from((G, 3)));
sourcepub fn interval_to(&self, other: &PitchClass) -> Interval
pub fn interval_to(&self, other: &PitchClass) -> Interval
Returns the simple interval (ascending) from this pitch class to the nearest other
pitch class.
use redact_composer_musical::{Interval, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(C).interval_to(&G.into()), Interval::P5);
sourcepub fn interval_from(&self, other: &PitchClass) -> Interval
pub fn interval_from(&self, other: &PitchClass) -> Interval
Returns the simple interval (ascending) from some other
pitch class to this one.
use redact_composer_musical::{Interval, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(C).interval_from(&G.into()), Interval::P4);
source§impl PitchClass
impl PitchClass
sourcepub fn name_in_key(&self, key: &Key) -> NoteName
pub fn name_in_key(&self, key: &Key) -> NoteName
Returns this pitch class’s name within the context of a Key
. Pitch classes not in the
given key will return some variation of a name equating to the pitch class, but exactly
which is subject to change.
Trait Implementations§
source§impl Add<Interval> for PitchClass
impl Add<Interval> for PitchClass
source§fn add(self, rhs: Interval) -> Self::Output
fn add(self, rhs: Interval) -> Self::Output
Returns the pitch class a given interval above this.
use redact_composer_musical::{Interval as I, NoteName::{C, G}, PitchClass};
assert_eq!(PitchClass::from(C) + I::P5, PitchClass::from(G));
assert_eq!(PitchClass::from(C) + I::Octave, PitchClass::from(C));
§type Output = PitchClass
type Output = PitchClass
+
operator.source§impl AddAssign<Interval> for PitchClass
impl AddAssign<Interval> for PitchClass
source§fn add_assign(&mut self, rhs: Interval)
fn add_assign(&mut self, rhs: Interval)
+=
operation. Read moresource§impl Clone for PitchClass
impl Clone for PitchClass
source§fn clone(&self) -> PitchClass
fn clone(&self) -> PitchClass
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PitchClass
impl Debug for PitchClass
source§impl From<Note> for PitchClass
impl From<Note> for PitchClass
source§impl From<NoteName> for PitchClass
impl From<NoteName> for PitchClass
source§impl From<u8> for PitchClass
impl From<u8> for PitchClass
source§impl Hash for PitchClass
impl Hash for PitchClass
source§impl NoteIterator for PitchClass
impl NoteIterator for PitchClass
source§fn iter_notes_in_range<R: RangeBounds<Note>>(
&self,
note_range: R
) -> NoteIter<R> ⓘ
fn iter_notes_in_range<R: RangeBounds<Note>>( &self, note_range: R ) -> NoteIter<R> ⓘ
NoteIter
) for notes of an interval pattern within the given note range.source§fn notes_in_range<R: RangeBounds<Note>>(&self, note_range: R) -> Vec<Note>
fn notes_in_range<R: RangeBounds<Note>>(&self, note_range: R) -> Vec<Note>
source§impl PartialEq<NoteName> for PitchClass
impl PartialEq<NoteName> for PitchClass
source§impl PartialEq<PitchClass> for Note
impl PartialEq<PitchClass> for Note
source§fn eq(&self, other: &PitchClass) -> bool
fn eq(&self, other: &PitchClass) -> bool
use redact_composer_musical::{Note, NoteName::C, PitchClass};
assert!(Note::from((C, 3)) == PitchClass::from(C));
source§impl PartialEq<PitchClass> for NoteName
impl PartialEq<PitchClass> for NoteName
source§fn eq(&self, pitch_class: &PitchClass) -> bool
fn eq(&self, pitch_class: &PitchClass) -> bool
use redact_composer_musical::{NoteName, PitchClass};
assert!(NoteName::C.eq(&PitchClass(0)));
source§impl PartialEq for PitchClass
impl PartialEq for PitchClass
source§fn eq(&self, other: &PitchClass) -> bool
fn eq(&self, other: &PitchClass) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PitchClassCollection for PitchClass
impl PitchClassCollection for PitchClass
source§fn pitch_classes(&self) -> Vec<PitchClass>
fn pitch_classes(&self) -> Vec<PitchClass>
source§impl Sub<Interval> for PitchClass
impl Sub<Interval> for PitchClass
source§fn sub(self, rhs: Interval) -> Self::Output
fn sub(self, rhs: Interval) -> Self::Output
Returns the pitch class a given interval below this.
use redact_composer_musical::{Interval as I, NoteName::{C, F}, PitchClass};
assert_eq!(PitchClass::from(C) - I::P5, PitchClass::from(F));
assert_eq!(PitchClass::from(C) - I::Octave, PitchClass::from(C));
§type Output = PitchClass
type Output = PitchClass
-
operator.source§impl SubAssign<Interval> for PitchClass
impl SubAssign<Interval> for PitchClass
source§fn sub_assign(&mut self, rhs: Interval)
fn sub_assign(&mut self, rhs: Interval)
-=
operation. Read more