Skip to main content

Part

Struct Part 

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

A part’s lines and the stage they are written in: music21’s MuseDataPart.

Implementations§

Source§

impl Part

Source

pub fn with_stage(lines: Vec<String>, stage: Stage) -> Self

A part of lines already read, in stage: music21’s MuseDataPart(src, stage) for a source it keeps as it is.

Source

pub fn stage_of(lines: &[String]) -> Stage

music21’s _determineStage: stage 2 where any line is an attribute record.

Source

pub fn scrubbed(lines: &[String]) -> Result<Vec<String>>

music21’s _scrubStage1: the lines without the blank ones they open with.

§Errors

Lines of one or none.

Source

pub fn lines(&self) -> &[String]

The part’s lines, a stage-1 part’s leading blank lines dropped.

Source

pub fn stage(&self) -> Stage

The stage the part is written in.

Source

pub fn digits_after(line: &str, tag: &str) -> String

music21’s _getDigitsFollowingTag: the digits after a tag, spaces passed over, - and / kept, anything else ending it.

use music21::musedata::Part;

assert_eq!(Part::digits_after("$ K:-3   Q:4   T:3/4   C:22", "T:"), "3/4");
Source

pub fn letters_after( line: &str, tag: &str, spaces: Spaces, case: Case, ) -> String

music21’s _getAlphasFollowingTag: the letters and commas after a tag, spaces passed over or kept, anything else ending it; with Case::Lowered line and tag are lowered first.

use music21::musedata::{Case, Part, Spaces};

let line = "Group memberships: sound, score";
let read = Part::letters_after(line, "Group memberships:", Spaces::Dropped, Case::Lowered);
assert_eq!(read, "sound,score");
Source

pub fn source(&self) -> Option<String>

music21’s getSource: where the encoding was taken from.

Source

pub fn group_memberships(&self) -> Vec<String>

music21’s getGroupMemberships: the groups the part belongs to.

Source

pub fn group_total(&self, membership: &str) -> Result<Option<IntegerType>>

music21’s getGroupMembershipsTotal: how many parts the group has.

§Errors

A count that is no number.

Source

pub fn group_number(&self, membership: &str) -> Result<Option<String>>

music21’s getGroupMembershipNumber: the part’s place in the group, as written. music21 hands stage 1’s back as text, stage 2’s as a number.

§Errors

A stage-1 header too short.

Source

pub fn work_number(&self) -> Option<String>

music21’s getWorkNumber: the opus number, as written.

Source

pub fn movement_number(&self) -> Option<String>

music21’s getMovementNumber, as written.

Source

pub fn work_title(&self) -> Option<String>

music21’s getWorkTitle: for stage 1, the catalogue number.

Source

pub fn movement_title(&self) -> Option<String>

music21’s getMovementTitle; none for stage 1.

Source

pub fn part_name(&self) -> Option<String>

music21’s getPartName; none for stage 1.

Source

pub fn attributes(&self) -> Result<String>

music21’s _getAttributesRecord: the first line opening with $, or stage 1’s two attribute lines joined.

§Errors

A part with no attribute record.

Source

pub fn key_parameters(&self) -> Result<IntegerType>

music21’s getKeyParameters: the signature’s sharps, flats below nought.

§Errors

A key that is no number.

Source

pub fn key_signature(&self) -> Result<KeySignature>

music21’s getKeySignature.

§Errors

As Part::key_parameters.

Source

pub fn time_signature(&self) -> Result<TimeSignature>

music21’s getTimeSignatureObject.

§Errors

As Part::time_signature_parameters.

Source

pub fn time_signature_parameters(&self) -> Result<String>

music21’s getTimeSignatureParameters: the meter as 3/4, a meter of 1/1 or over nought as 4/4.

§Errors

A meter that is not two numbers.

Source

pub fn staff_count(&self) -> Result<IntegerType>

music21’s _getNumberOfStaves: S:, one where unwritten.

§Errors

A count that is no number.

Source

pub fn clef_parameters(&self) -> Result<Vec<String>>

music21’s _getClefParameters: C:, or each staff’s Cn:, as written; stage 1’s ninth attribute field.

§Errors

A part with no attribute record.

Source

pub fn clef_for(&self, voice: usize) -> Result<Option<Clef>>

music21’s getClefObject: the clef of staff voice, counted from one; none for stage 1.

§Errors

No clef for the staff, or a code music21 does not know.

Source

pub fn directive(&self) -> Result<Option<String>>

music21’s getDirective: D:, usually a tempo word.

§Errors

A part with no attribute record.

Source

pub fn transposition(&self) -> Result<Option<Interval>>

music21’s getTranspositionIntervalObject: the interval a transposing part is written at.

§Errors

A transposition with no interval.

Source

pub fn transposition_parameters(&self) -> Result<Option<IntegerType>>

music21’s _getTranspositionParameters: X:, in base 40.

§Errors

A transposition that is no number.

Source

pub fn divisions(&self) -> Result<FloatType>

Divisions of a quarter note: Q:, or in stage 1 the divisions of a bar over the bar’s length in quarters.

Source

pub fn measure_bounds(&self) -> Result<Vec<(usize, usize)>>

_getMeasureBoundaryIndices: the lines of each measure, from its first up to the one after its last.

Trait Implementations§

Source§

impl Clone for Part

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 Part

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Part

§

impl Freeze for Part

§

impl Move for Part

§

impl RefUnwindSafe for Part

§

impl Send for Part

§

impl Sync for Part

§

impl Unpin for Part

§

impl UnsafeUnpin for Part

§

impl UnwindSafe for Part

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.