pub struct ThirdStackSignature {
pub root: PitchClass,
pub steps: Vec<ThirdStep>,
pub guard: bool,
}Expand description
A chord described as a root pitch class plus an ordered stack of third ThirdSteps.
This tertian encoding captures triads, sevenths, and extended chords as a sequence of stacked thirds, with run-length limits that reject implausible stacks.
Fields§
§root: PitchClassThe pitch class at the bottom of the stack.
steps: Vec<ThirdStep>The ordered thirds stacked above the root.
guard: boolA guard bit reserved by the bit encoding to mark the end of the step run.
Implementations§
Source§impl ThirdStackSignature
impl ThirdStackSignature
Sourcepub fn validate(&self) -> Result<(), PitchSetError>
pub fn validate(&self) -> Result<(), PitchSetError>
Validates the step run, rejecting four consecutive minor thirds or three consecutive major thirds.
Sourcepub fn encode(&self) -> Result<u32, PitchSetError>
pub fn encode(&self) -> Result<u32, PitchSetError>
Encodes this signature into a compact u32, validating it first.
Sourcepub fn decode(encoded: u32) -> Result<Self, PitchSetError>
pub fn decode(encoded: u32) -> Result<Self, PitchSetError>
Decodes a u32 produced by ThirdStackSignature::encode back into a
validated signature.
Sourcepub fn family_tag(&self) -> char
pub fn family_tag(&self) -> char
Returns a single-character family tag classifying the stack by its count of major thirds.
Sourcepub fn to_mask(&self) -> PitchClassMask
pub fn to_mask(&self) -> PitchClassMask
Realizes the stacked thirds into the PitchClassMask of the chord’s
pitch classes.
Trait Implementations§
Source§impl Clone for ThirdStackSignature
impl Clone for ThirdStackSignature
Source§fn clone(&self) -> ThirdStackSignature
fn clone(&self) -> ThirdStackSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ThirdStackSignature
impl Debug for ThirdStackSignature
impl Eq for ThirdStackSignature
Source§impl Hash for ThirdStackSignature
impl Hash for ThirdStackSignature
Source§impl PartialEq for ThirdStackSignature
impl PartialEq for ThirdStackSignature
Source§fn eq(&self, other: &ThirdStackSignature) -> bool
fn eq(&self, other: &ThirdStackSignature) -> bool
self and other values to be equal, and is used by ==.