Skip to main content

DataInstance

Struct DataInstance 

Source
pub struct DataInstance { /* private fields */ }
Expand description

A piece prepared for feature extraction, with each representation of it worked out once: music21’s DataInstance and the StreamForms it keeps.

Implementations§

Source§

impl DataInstance

Source

pub fn new(stream: &Stream) -> Result<Self>

Prepares a piece: its ties stripped, and each part of a score and each voice anywhere in it prepared on its own.

§Errors

A tie the piece cannot be stripped of.

Source

pub fn prepared(&self) -> &Stream

The piece with its ties stripped.

Source

pub fn parts(&self) -> &[DataInstance]

Each part of a score prepared on its own, then each voice: music21’s data['parts'].

Source

pub fn parts_count(&self) -> usize

How many parts a score has: music21’s partsCount, nought for a stream that is not a score.

Source

pub fn pitches(&self) -> &[Pitch]

Every pitch of the piece’s notes, chords and chord symbols: music21’s Stream.pitches.

Source

pub fn midi_pitch_histogram(&self) -> &[(IntegerType, usize)]

How often each MIDI note number sounds, in the order each is first met: music21’s midiPitchHistogram, a Counter.

Source

pub fn pitch_class_histogram(&self) -> &[usize; 12]

How often each pitch class sounds: music21’s pitchClassHistogram.

Source

pub fn midi_interval_histogram(&self) -> &[usize]

How often each melodic interval, in semitones either way, comes between neighbouring notes of each part, chords and rests passed over: music21’s midiIntervalHistogram, 128 bins.

Source

pub fn contour_list(&self) -> &[IntegerType] ⓘ

Every melodic step of each part in semitones, rising steps positive, a chord read as its highest note: music21’s contourList.

Source

pub fn metronome_mark_boundaries( &self, ) -> Result<Vec<(FloatType, FloatType, MetronomeMark)>>

The stretches of the piece each tempo holds, start, end and the mark sounding there: Stream::metronome_mark_boundaries of the piece as this instance prepared it.

§Errors

As Stream::metronome_mark_boundaries.

Source

pub fn seconds_map(&self) -> Result<&[Seconds]>

When each note, chord and chord symbol of the piece sounds, in seconds, in the order the piece holds them: the notes of music21’s secondsMap, read over the piece flattened, where music21’s own secondsMap reads only what a stream holds directly. The features that read it want every note of the piece.

§Errors

A tempo that says no number, or as DataInstance::metronome_mark_boundaries.

Source

pub fn parts_sounding(&self) -> Result<&[usize]>

How many parts sound in each chord of the piece chordified, in order: music21’s chordify(addPartIdAsGroup=True), read as the number of part ids on each chord’s pitches. A piece that is not a score is not chordified, and its own chords carry no part ids, so each counts nought.

§Errors

A score that cannot be chordified.

Source

pub fn chordified_chords(&self) -> Result<&[Chord]>

The chords of the piece chordified with every pitch kept: music21’s chordify.flat.getElementsByClass(Chord). A piece that is not a score is not chordified, so these are its own chords and chord symbols, a symbol that sounds nothing an empty chord.

§Errors

A score that cannot be chordified.

Source

pub fn quarter_length_histogram(&self) -> &[(FloatType, usize)]

How often each length in quarters comes among the piece’s notes, in the order each is first met: music21’s flat.notes.quarterLengthHistogram, a Counter.

Source

pub fn analyzed_key(&self) -> Option<&[KeyEstimate]>

The keys the piece is likely in, best first, by Aarden and Essen’s weights: music21’s flat.analyzedKey, the key and its alternateInterpretations. Nothing for a piece with no pitched notes.

Trait Implementations§

Source§

impl Debug for DataInstance

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.