pub struct AbcNote {Show 18 fields
pub src: String,
pub line: usize,
pub is_chord: bool,
pub carried_accidental: String,
pub chord_symbols: Vec<String>,
pub in_grace: bool,
pub default_quarter_length: Option<FloatType>,
pub broken_rhythm: Option<(String, Side)>,
pub key: Option<KeySignature>,
pub tuplet: Option<Tuplet>,
pub spanners: Vec<usize>,
pub tie: Option<TieType>,
pub articulations: Vec<String>,
pub accidental_display: Option<bool>,
pub is_rest: bool,
pub pitch_name: Option<String>,
pub quarter_length: FloatType,
pub sub_tokens: Vec<AbcNote>,
}Expand description
A note, a rest, or with is_chord a chord: music21’s ABCNote and
ABCChord. Its context is filled by Handler::process, its pitch and
length by AbcNote::parse.
Fields§
§src: StringThe text it was read from.
line: usizeThe line of the text it starts on; nought where unknown.
is_chord: boolWhether it is a chord.
carried_accidental: StringThe accidental carried from earlier in the measure.
chord_symbols: Vec<String>The chord symbols written over it, quotes kept.
in_grace: boolWhether it is a grace note.
default_quarter_length: Option<FloatType>The default length in force, in quarter notes.
broken_rhythm: Option<(String, Side)>The broken-rhythm mark and the side of it the note stands on.
key: Option<KeySignature>The key in force.
tuplet: Option<Tuplet>The tuplet it is in.
spanners: Vec<usize>The spanners in force, by where they stand among the handler’s.
tie: Option<TieType>The tie it starts, continues or stops.
articulations: Vec<String>music21’s names: staccato, upbow and the rest.
accidental_display: Option<bool>Whether the accidental is shown: nothing where undecided.
is_rest: boolWhether it is a rest.
pitch_name: Option<String>The pitch as music21 names one; nothing for a rest or a chord.
quarter_length: FloatTypeThe length in quarter notes.
sub_tokens: Vec<AbcNote>A chord’s notes, once parsed.
Implementations§
Source§impl AbcNote
impl AbcNote
Sourcepub fn new(src: &str, carried: &str) -> Self
pub fn new(src: &str, carried: &str) -> Self
An unread note of src, carrying the accidental carried.
Sourcepub fn split_chord_symbols(src: &str) -> (Vec<String>, String)
pub fn split_chord_symbols(src: &str) -> (Vec<String>, String)
music21’s _splitChordSymbols: the quoted strings, and what is left
after the last of them.
use music21::abc::step::AbcNote;
let (symbols, rest) = AbcNote::split_chord_symbols("\"D7\"\"D\"d2");
assert_eq!((symbols, rest.as_str()), (vec!["\"D7\"".to_string(), "\"D\"".to_string()], "d2"));Sourcepub fn pitch_name(
&self,
src: &str,
forced_key: Option<&KeySignature>,
) -> Result<(Option<String>, Option<bool>)>
pub fn pitch_name( &self, src: &str, forced_key: Option<&KeySignature>, ) -> Result<(Option<String>, Option<bool>)>
music21’s getPitchName: the pitch as music21 names one, or nothing
for a rest, and whether its accidental is shown. forced_key stands
in for the note’s own key.
use music21::abc::step::AbcNote;
use music21::KeySignature;
let note = AbcNote::new("", "");
assert_eq!(note.pitch_name("_g''", None)?, (Some("G-7".to_string()), Some(true)));
let key = KeySignature::new(3);
assert_eq!(note.pitch_name("c", Some(&key))?, (Some("C#5".to_string()), Some(false)));Sourcepub fn quarter_length_of(
&self,
src: &str,
forced_default: Option<FloatType>,
) -> Result<FloatType>
pub fn quarter_length_of( &self, src: &str, forced_default: Option<FloatType>, ) -> Result<FloatType>
music21’s getQuarterLength: the length src writes, against the
default length (or forced_default), stretched by a broken rhythm.
use music21::abc::step::{AbcNote, Side};
let mut note = AbcNote::new("", "");
note.default_quarter_length = Some(0.5);
assert_eq!(note.quarter_length_of("A3/2", None)?, 0.75);
note.broken_rhythm = Some(("<<".to_string(), Side::Right));
assert_eq!(note.quarter_length_of("A", None)?, 0.875);Sourcepub fn parse(
&mut self,
forced_default: Option<FloatType>,
forced_key: Option<&KeySignature>,
) -> Result<()>
pub fn parse( &mut self, forced_default: Option<FloatType>, forced_key: Option<&KeySignature>, ) -> Result<()>
music21’s ABCNote.parse and ABCChord.parse: the chord symbols,
the pitch and the length, or for a chord its notes and length.
forced_default and forced_key stand in for the note’s own.
Trait Implementations§
impl StructuralPartialEq for AbcNote
Auto Trait Implementations§
impl Forget for AbcNote
impl Freeze for AbcNote
impl Move for AbcNote
impl RefUnwindSafe for AbcNote
impl Send for AbcNote
impl Sync for AbcNote
impl Unpin for AbcNote
impl UnsafeUnpin for AbcNote
impl UnwindSafe for AbcNote
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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