Skip to main content

Hasher

Struct Hasher 

Source
pub struct Hasher {
Show 16 fields pub include_reference: bool, pub hash_pitch: bool, pub hash_midi: bool, pub hash_note_name_octave: bool, pub hash_octave: bool, pub hash_duration: bool, pub round_duration_and_offset: bool, pub hash_offset: bool, pub granularity: u32, pub hash_interval_from_last_note: bool, pub hash_is_accidental: bool, pub hash_is_tied: bool, pub hash_chords_as_notes: bool, pub hash_chords_as_chords: bool, pub hash_normal_order_string: bool, pub hash_prime_form_string: bool,
}
Expand description

What a hasher hashes of each note, rest and chord: music21’s Hasher.

By default a note is its MIDI pitch, its length and its offset, each rounded to a 32nd of a quarter, and a chord is hashed note by note.

Fields§

§include_reference: bool

Whether each hash says what it was made from.

§hash_pitch: bool

Whether a note’s pitch is hashed.

§hash_midi: bool

Whether the pitch is its MIDI number rather than its name.

§hash_note_name_octave: bool

Whether a named pitch leaves out its octave: music21’s hashNoteNameOctave.

§hash_octave: bool

Whether the octave is hashed.

§hash_duration: bool

Whether the length is hashed.

§round_duration_and_offset: bool

Whether lengths and offsets are rounded to granularity.

§hash_offset: bool

Whether the offset in the element’s own measure or voice is hashed.

§granularity: u32

How many parts of a quarter lengths and offsets are rounded to.

§hash_interval_from_last_note: bool

Whether the interval class from the note before in the same part is hashed; a part’s first note has none.

§hash_is_accidental: bool

Whether whether a note is altered is hashed: music21 hashes nothing for it yet, so the value is always nothing.

§hash_is_tied: bool

Whether ties are hashed: music21 does not use it.

§hash_chords_as_notes: bool

Whether a chord is hashed note by note.

§hash_chords_as_chords: bool

Whether a chord is hashed as one.

§hash_normal_order_string: bool

Whether a chord’s normal order is hashed, where chords are hashed as chords.

§hash_prime_form_string: bool

Whether a chord’s prime form is hashed, where chords are hashed as chords.

Implementations§

Source§

impl Hasher

Source

pub fn tuple_list(&self) -> Vec<&'static str>

The names of the values each hash holds, in order: music21’s tupleList.

Source

pub fn hash_stream(&self, stream: &Stream) -> Result<Vec<NoteHash>>

Every note, rest and chord of a stream, hashed in the order music21’s recurse walks them: music21’s hashStream. A chord is hashed note by note, as one, or not at all as the hasher says. Offsets are each element’s own in its measure or voice.

music21 also rounds each element’s own length and offset in the stream as it hashes them; the stream here is left as it is.

§Errors

An interval from the note before that cannot be measured, a chord symbol whose notes cannot be worked out, or octaves asked of chords hashed as chords, which music21 cannot hash.

Trait Implementations§

Source§

impl Clone for Hasher

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Hasher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Hasher

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Hasher

Source§

impl PartialEq for Hasher

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Hasher

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.