pub struct PitchClassMask(/* private fields */);Expand description
A bitmask over the twelve pitch classes, with bit n set when pitch class n
is present.
The low twelve bits represent pitch classes C through B.
§Examples
use sim_lib_pitch_core::PitchClass;
use sim_lib_pitch_set::PitchClassMask;
let triad = PitchClassMask::from_pitch_classes(&[PitchClass::C, PitchClass::E, PitchClass::G]);
assert_eq!(triad.count_bits(), 3);Implementations§
Source§impl PitchClassMask
impl PitchClassMask
Sourcepub fn gap_form(self) -> GapForm
pub fn gap_form(self) -> GapForm
Return adjacent cyclic gaps for this set’s pitch classes.
PitchClassMask has set identity, so duplicate pitch classes are already
collapsed and zero gaps are absent. Use gap_form_from_pitch_classes
when caller-owned multiplicity must be preserved.
Sourcepub fn interval_form(self) -> IntervalForm
pub fn interval_form(self) -> IntervalForm
Return directed pairwise intervals between all pitch classes in the set.
Source§impl PitchClassMask
impl PitchClassMask
Sourcepub fn new(bits: u16) -> Result<Self, PitchSetError>
pub fn new(bits: u16) -> Result<Self, PitchSetError>
Builds a pitch-class mask, rejecting any bits outside the low twelve.
Sourcepub fn from_pitch_classes(pitch_classes: &[PitchClass]) -> Self
pub fn from_pitch_classes(pitch_classes: &[PitchClass]) -> Self
Builds a mask from a slice of pitch classes; duplicates collapse to one bit.
Sourcepub fn pitch_classes(self) -> Vec<PitchClass>
pub fn pitch_classes(self) -> Vec<PitchClass>
Returns the set pitch classes in ascending order.
Sourcepub fn rotate(self, semitones: i32) -> Self
pub fn rotate(self, semitones: i32) -> Self
Returns this mask transposed by semitones, wrapping within the octave.
Sourcepub fn invert(self, axis: PitchClass) -> Self
pub fn invert(self, axis: PitchClass) -> Self
Returns this mask inverted about axis.
Sourcepub fn invert_tni(self, index: u8) -> Self
pub fn invert_tni(self, index: u8) -> Self
Returns the conventional set-theory inversion TnI, where each pitch
class p maps to index - p (mod 12).
Unlike PitchClassMask::invert, this accepts every integer inversion
index, including odd indices whose geometric axis lies between pitch
classes.
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
Returns the rotation of this mask with the smallest numeric value, a transposition-invariant normal form.
Sourcepub fn normal_order(self) -> Vec<PitchClass>
pub fn normal_order(self) -> Vec<PitchClass>
Returns the conventional normal order for this set.
The result preserves cardinality and is transposed so the first pitch
class is C. Use PitchClassMask::normalize when the older numeric mask
identity is required instead.
Sourcepub fn classify(self, equivalence: SetEquivalence) -> SetClass
pub fn classify(self, equivalence: SetEquivalence) -> SetClass
Classifies this mask using the requested conventional equivalence policy.
Sourcepub fn is_subset_of(self, other: Self) -> bool
pub fn is_subset_of(self, other: Self) -> bool
Returns true when every pitch class in self is also in other.
Sourcepub fn is_superset_of(self, other: Self) -> bool
pub fn is_superset_of(self, other: Self) -> bool
Returns true when every pitch class in other is also in self.
Sourcepub fn complement(self) -> Self
pub fn complement(self) -> Self
Returns the complement of this set in the twelve pitch-class universe.
Sourcepub fn intersection(self, other: Self) -> Self
pub fn intersection(self, other: Self) -> Self
Returns the pitch classes shared by this set and other.
Sourcepub fn difference(self, other: Self) -> Self
pub fn difference(self, other: Self) -> Self
Returns the pitch classes in this set but not in other.
Sourcepub fn symmetric_difference(self, other: Self) -> Self
pub fn symmetric_difference(self, other: Self) -> Self
Returns the pitch classes belonging to exactly one of the two sets.
Sourcepub fn is_disjoint_from(self, other: Self) -> bool
pub fn is_disjoint_from(self, other: Self) -> bool
Returns true when this set and other share no pitch classes.
Sourcepub fn transpositional_symmetries(self) -> Vec<u8> ⓘ
pub fn transpositional_symmetries(self) -> Vec<u8> ⓘ
Returns transpositions that map this set onto itself.
Sourcepub fn inversional_symmetries(self) -> Vec<PitchClass>
pub fn inversional_symmetries(self) -> Vec<PitchClass>
Returns inversion axes that map this set onto itself.
Sourcepub fn roots(self) -> Vec<PitchClass>
pub fn roots(self) -> Vec<PitchClass>
Returns likely tonal roots, derived from third-stack interpretations.
Returns true when both masks have the same interval vector but distinct
transposition-inversion prime forms.
Sourcepub fn count_bits(self) -> u32
pub fn count_bits(self) -> u32
Returns the number of pitch classes in the set (the population count).
Sourcepub fn interval_vector(self) -> IntervalVector
pub fn interval_vector(self) -> IntervalVector
Returns the IntervalVector tallying interval classes among the set’s
pitch classes.
Trait Implementations§
Source§impl Clone for PitchClassMask
impl Clone for PitchClassMask
Source§fn clone(&self) -> PitchClassMask
fn clone(&self) -> PitchClassMask
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more