gd_score¶
Exact musical time, spelled pitches and a flat score shared by readers and engravers. No file access, font policy or engraving geometry belongs in this crate.
Structs
- pub struct gd_score::Duration¶
-
Written duration and exact scaling. The default is an undotted quarter.
Fields
- pub dots: u8¶
-
Augmentation dots, at most eight.
Implementations
- impl Duration
Trait Implementations
- pub struct gd_score::Error¶
-
A structured diagnostic. Adapters place its span in a retained source file.
Fields
Implementations
- impl Error
-
- pub fn new(kind: ErrorKind, message: impl Into<String>) -> Self¶
-
Copies an explanation into an unplaced error; performs no input processing.
- pub fn at(mut self, span: Span) -> Self¶
-
Attaches a source range, consuming and returning the diagnostic.
- pub fn or_at(mut self, span: Span) -> Self¶
-
Attaches a fallback source range only when this diagnostic is still unplaced.
- pub fn hint(mut self, hint: impl Into<String>) -> Self¶
-
Adds a corrective action, consuming and returning the diagnostic.
- pub fn warning(mut self) -> Self¶
-
Marks a diagnostic as recoverable, consuming and returning it.
Trait Implementations
- impl fmt::Display for Error
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- impl std::error::Error for Error
- pub struct gd_score::FileId(pub u32)¶
-
An index into a reader’s retained source files.
Implementations
- impl FileId
-
- pub const NONE: Self = Self(u32::MAX)¶
-
Unplaced source sentinel; file zero is the root input file.
Trait Implementations
- pub struct gd_score::Span¶
-
A half-open byte range in a source file. The default is an unplaced diagnostic.
Fields
- pub start: usize¶
-
First byte, inclusive.
- pub end: usize¶
-
Last byte, exclusive.
Implementations
- pub struct gd_score::Key¶
-
Tonic and mode, independent of the current octave.
Fields
Implementations
- pub struct gd_score::Pitch¶
-
A spelled pitch; c is octave 0, c” (middle C) is octave 1.
Fields
- pub octave: i8¶
-
Count of written octave marks.
Implementations
- impl Pitch
-
- pub fn diatonic(self) -> i16¶
-
Returns the diatonic index without discarding spelling.
- pub fn chromatic(self) -> i16¶
-
Returns semitones relative to c in octave 0.
- pub fn transpose(self, from: Self, to: Self) -> Result<Self, Error>¶
-
Transposes by a spelled interval; fails for an unsupported accidental or octave.
- pub struct gd_score::Ratio¶
-
A reduced exact rational with a strictly positive denominator.
Implementations
- impl Ratio
-
- pub const ZERO: Self = Self { num: 0, den: 1 }¶
-
Exact zero.
- pub const ONE: Self = Self { num: 1, den: 1 }¶
-
Exact one.
- pub fn new(num: i64, den: i64) -> Result<Self, Error>¶
-
Reduces a fraction. Fails for a zero denominator or an unrepresentable result.
- pub fn numerator(self) -> i64¶
-
Returns the reduced numerator.
- pub fn denominator(self) -> i64¶
-
Returns the positive reduced denominator.
- pub fn to_f64(self) -> f64¶
-
Converts to a finite floating approximation for geometry, not musical time.
- pub fn checked_add(self, rhs: Self) -> Result<Self, Error>¶
-
Adds two rationals, failing when the reduced result does not fit.
- pub fn checked_sub(self, rhs: Self) -> Result<Self, Error>¶
-
Subtracts two rationals, failing when the reduced result does not fit.
- pub fn checked_mul(self, rhs: Self) -> Result<Self, Error>¶
-
Multiplies two rationals, failing when the reduced result does not fit.
- pub fn checked_div(self, rhs: Self) -> Result<Self, Error>¶
-
Divides two rationals, failing for zero or an unrepresentable reduced result.
- pub fn checked_neg(self) -> Result<Self, Error>¶
-
Negates the value, failing only for the smallest integer numerator.
- pub fn is_integer(self) -> bool¶
-
Returns whether this value is a whole integer, without converting to floating point.
Trait Implementations
- impl fmt::Display for Ratio
-
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
- impl Ord for Ratio
-
- fn cmp(&self, rhs: &Self) -> Ordering
- pub struct gd_score::StaffId(pub u32)¶
-
A staff index in a score.
- pub struct gd_score::VoiceId(pub u32)¶
-
A voice index in a score.
- pub struct gd_score::EventId(pub u32)¶
-
An event index in a score.
- pub struct gd_score::Moment¶
-
Exact whole-note time, with grace events ordered before their main note.
Fields
- pub struct gd_score::NoteRef¶
-
A particular head of a chord event, not merely the event as a whole.
Fields
- pub note: u8¶
-
Index of the head within its chord.
- pub struct gd_score::Score¶
-
A complete notation model, independent of input syntax and drawing geometry.
Fields
- pub groups: Vec<StaffGroup>¶
-
Braced or bracketed contiguous groups.
- pub struct gd_score::Staff¶
-
One staff of standard notation or tablature.
Fields
- pub struct gd_score::Voice¶
-
One of at most four independent rhythmic sequences on a staff.
Fields
- pub struct gd_score::StaffGroup¶
-
A connected group of contiguous staves.
Fields
Implementations
- impl StaffGroup
- pub struct gd_score::Event¶
-
One timed event with its original location.
Fields
- pub voice_style: Option<VoiceStyle>¶
-
Local voice policy; None inherits the owning voice’s default direction.
- pub column_shift: Option<u8>¶
-
Explicit note-column shift level, as LilyPond’s
horizontal-shift; None uses the voice policy’s level fromVoiceStyle::column_shift.
- pub marks: Vec<Annotation>¶
-
Marks attached to this event.
- pub struct gd_score::Chord¶
-
Simultaneous noteheads with one written duration.
Fields
- pub direction: Option<Direction>¶
-
Explicit stem direction, including neutral; None uses the local voice policy.
- pub auto_beam: bool¶
-
Whether automatic beaming applies at this event.
- pub grace_slash: bool¶
-
Whether grace stems are slashed.
- pub struct gd_score::Note¶
-
A spelled pitch and accidental-display requests.
Fields
- pub forced: bool¶
-
Print an accidental even when implied by state.
- pub cautionary: bool¶
-
Put the accidental in parentheses.
- pub string: Option<u8>¶
-
Tablature string that plays the note, 1 for the highest; None lets tablature choose, as
crate::tab_positionsdescribes.
- pub struct gd_score::Meter¶
-
A common meter shared by every staff.
Fields
- pub numerator: u16¶
-
Number of denominator units per bar.
- pub denominator: u16¶
-
Power-of-two unit denominator.
- pub beats: Vec<u16>¶
-
Optional explicit beaming groups, whose sum is the numerator.
- pub style: MeterStyle¶
-
How the time signature is drawn.
Trait Implementations
- pub struct gd_score::Spanner¶
-
A bounded interval such as a slur or tuplet.
Fields
- pub kind: SpannerKind¶
-
Meaning and drawing policy.
- pub struct gd_score::Annotation¶
-
A text or symbol attached to a rhythmic event.
Fields
- pub kind: AnnotationKind¶
-
Meaning of the mark.
- pub struct gd_score::LyricLine¶
-
One verse below a voice.
Fields
- pub struct gd_score::Syllable¶
-
One lyric syllable with a possible hyphen or extender.
Fields
- pub hyphen: bool¶
-
Join to the next syllable with a hyphen.
- pub struct gd_score::Measure¶
-
One measure, including pickups and a final incomplete measure.
Fields
- pub number: u32¶
-
Printed measure number; a pickup is zero.
- pub struct gd_score::TabPosition¶
-
Where a note is played on a fretted instrument.
Fields
- pub string: u8¶
-
String number, 1 for the highest string.
- pub fret: u8¶
-
Fret number, 0 for the open string.
Enums
- pub enum gd_score::Base¶
-
A written duration before augmentation dots and proportional scaling.
Variants
- Breve¶
-
Two whole notes.
- Whole¶
-
One whole note.
- Half¶
-
Half a whole note.
- Quarter¶
-
A quarter note, the initial inherited duration.
- Eighth¶
-
An eighth note.
- Sixteenth¶
-
A sixteenth note.
- ThirtySecond¶
-
A thirty-second note.
- SixtyFourth¶
-
A sixty-fourth note.
- HundredTwentyEighth¶
-
A hundred-and-twenty-eighth note.
Implementations
- pub enum gd_score::ErrorKind¶
-
Stable problem categories shared by readers and engravers.
Variants
- Syntax¶
-
Malformed LilyPond notation.
- Empty¶
-
No note, rest or spacer exists.
- UnknownCommand¶
-
A command is not known to the profile.
- Unsupported¶
-
A known construct is outside the implemented profile.
- Pitch¶
-
A pitch or accidental is invalid.
- Duration¶
-
A duration is invalid.
- BarCheck¶
-
A written bar check is misplaced.
- Lyrics¶
-
Lyrics could not all be attached.
- Include¶
-
An include was refused or could not be read.
- ReadLimit¶
-
The reader exceeded a declared bound.
- TimeOverflow¶
-
An exact time does not fit the rational representation.
- Score¶
-
A programmatically constructed score violates an invariant.
- Overfull¶
-
A single measure exceeds the line width.
- Font¶
-
A required font or glyph is unavailable.
- EngraveLimit¶
-
Engraving exceeded a declared bound.
Implementations
- pub enum gd_score::Severity¶
-
Whether processing can continue after a diagnostic.
Variants
- Error¶
-
The input cannot be rendered faithfully.
- Warning¶
-
The drawing remains usable.
- pub enum gd_score::ColumnAlign¶
-
Horizontal alignment within a vertical markup column.
Variants
- Left¶
-
Left-aligned lines (
\column,\left-column).
- Center¶
-
Centered lines (
\center-column).
- Right¶
-
Right-aligned lines (
\right-column).
- pub enum gd_score::Enclosure¶
-
A decorative frame or rule drawn around a markup expression.
Variants
- Box¶
-
Rectangular frame (
\box,\rounded-box).
- Circle¶
-
Circular or oval frame (
\circle).
- Underline¶
-
Baseline rule (
\underline).
- pub enum gd_score::Markup¶
-
Rich formatted text and musical symbols independent of LilyPond syntax.
Variants
- Line(Vec<Self>)¶
-
Horizontal sequence separated by word spaces (
\line,{ ... }).
- Concat(Vec<Self>)¶
-
Horizontal sequence with no separating spaces (
\concat).
- Column(ColumnAlign, Vec<Self>)¶
-
Vertical stack of lines (
\column,\center-column,\right-column).
- Style(StyleChange, Box<Self>)¶
-
A change to the enclosing text style (
\bold,\italic,\upright, …).
- Scaled { scale_percent: u16, shift_percent: i16, body: Box<Self> }¶
-
Relative size percentage and vertical baseline shift in hundredths of an em.
- scale_percent: u16¶
-
Font size percentage relative to the enclosing markup (
100is unchanged).
- shift_percent: i16¶
-
Upward baseline shift in hundredths of the enclosing font size.
- Space { horizontal: i16, vertical: i16 }¶
-
Explicit horizontal and vertical offset in hundredths of a staff space.
- horizontal: i16¶
-
Horizontal advance in hundredths of a staff space.
- vertical: i16¶
-
Vertical advance in hundredths of a staff space.
Implementations
- pub enum gd_score::MarkupRole¶
-
Semantic role for a structured markup annotation on an event.
Variants
- Script¶
-
Performance text script (
^\markup,_\markup,\markup).
- Tempo¶
-
Tempo indication (
\tempo \markup ...).
- Rehearsal¶
-
Rehearsal or structural mark (
\mark \markup ...).
- pub enum gd_score::StyleChange¶
-
How a markup command changes the enclosing style; changes nest, as in LilyPond.
Variants
- Bold¶
-
\bold: adds weight.
- Italic¶
-
\italic: adds slant.
- Upright¶
-
\upright: removes slant and keeps weight.
- Medium¶
-
\medium: removes weight and keeps slant.
- Normal¶
-
\normal-text: removes both.
Implementations
- impl StyleChange
- pub enum gd_score::Alter¶
-
A chromatic alteration of a written step; quarter tones are outside the profile.
Variants
- DoubleFlat¶
-
Two semitones below the natural step.
- Flat¶
-
One semitone below the natural step.
- Natural¶
-
The natural step.
- Sharp¶
-
One semitone above the natural step.
- DoubleSharp¶
-
Two semitones above the natural step.
Implementations
- pub enum gd_score::Mode¶
-
A diatonic key mode, represented as a rotation of the major scale.
Variants
- Major¶
-
Ionian.
- Dorian¶
-
Dorian.
- Phrygian¶
-
Phrygian.
- Lydian¶
-
Lydian.
- Mixolydian¶
-
Mixolydian.
- Minor¶
-
Aeolian.
- Locrian¶
-
Locrian.
Implementations
- pub enum gd_score::Step¶
-
A diatonic step, in ascending order from C.
Variants
- C¶
-
Do.
- D¶
-
Re.
- E¶
-
Mi.
- F¶
-
Fa.
- G¶
-
Sol.
- A¶
-
La.
- B¶
-
Ti.
Implementations
- impl Step
-
- pub const ALL: [Self; 7]¶
-
Every step in diatonic order.
- pub fn index(self) -> i16¶
-
Returns this step’s index from C, in 0..7.
- pub fn semitones(self) -> i16¶
-
Returns the natural semitone distance above C.
- pub fn from_index(index: i16) -> Self¶
-
Wraps an arbitrary diatonic index to its step, including negative indices.
- pub enum gd_score::StaffKind¶
-
What a staff’s lines stand for.
Variants
- Standard¶
-
Five lines of standard notation.
- Tablature¶
-
Six lines of guitar tablature in
crate::GUITAR_TUNING, with fret numbers.
- pub enum gd_score::Direction¶
-
A direction, with an automatic house-style default.
Variants
- Auto¶
-
Choose by staff position.
- Up¶
-
Above the staff, or upward stems.
- Down¶
-
Below the staff, or downward stems.
- pub enum gd_score::VoiceStyle¶
-
A local polyphonic policy, independent of the owning voice’s identity.
Variants
- Single¶
-
Choose stems by staff position, without an inner-voice shift.
- One¶
-
First voice: upward stems and the outer note column.
- Two¶
-
Second voice: downward stems and the outer note column.
- Three¶
-
Third voice: upward stems, shifting right when columns conflict.
- Four¶
-
Fourth voice: downward stems, shifting left when columns conflict.
Implementations
- impl VoiceStyle
-
- pub fn direction(self) -> Direction¶
-
Returns the stem and annotation side selected by this local policy.
- pub fn column_shift(self) -> u8¶
-
Returns the note-column shift level of this policy: one for the inner voices three and four, zero otherwise. Among columns with one stem direction, a higher level stands further from the stem side’s outer column.
- pub enum gd_score::GroupKind¶
-
Visual grouping policy for staves.
Variants
- Brace¶
-
PianoStaff and GrandStaff.
- Bracket¶
-
StaffGroup, with connected bar lines.
- Choir¶
-
ChoirStaff, with separate staff bar lines.
- pub enum gd_score::EventKind¶
-
A rhythmic event or a notation change.
Variants
- ChordName(Markup, Duration)¶
-
A chord-name symbol at this moment, as formatted markup such as a root, a quality and a raised extension.
Implementations
- pub enum gd_score::Clef¶
-
A clef and optional octave displacement.
Variants
- Treble¶
-
G clef on the second line.
- Bass¶
-
F clef on the fourth line.
- Alto¶
-
C clef on the middle line.
- Tenor¶
-
C clef on the fourth line.
- Soprano¶
-
C clef on the first line.
- TrebleEight¶
-
G clef sounding an octave lower.
- BassEight¶
-
F clef sounding an octave lower.
Implementations
- pub enum gd_score::MeterStyle¶
-
How a time signature is drawn.
Variants
- Symbol¶
-
LilyPond’s default: 4/4 as the common-time C, 2/2 as the cut-time C and every other meter as numbers.
- Numbers¶
-
Every meter as numbers, as
\numericTimeSignatureasks.
- pub enum gd_score::BarStyle¶
-
A visible bar-line shape.
Variants
- Single¶
-
Ordinary thin bar.
- Double¶
-
Two thin bars.
- Final¶
-
Thin then thick.
- Initial¶
-
Thick then thin.
- RepeatStart¶
-
Opening repeat.
- RepeatEnd¶
-
Closing repeat.
- RepeatBoth¶
-
Closing and opening repeat.
- pub enum gd_score::BreakRule¶
-
A line-break instruction at a bar boundary.
Variants
- Force¶
-
End the current system.
- Forbid¶
-
Keep the adjacent measures in one system.
- pub enum gd_score::SpannerKind¶
-
An interval’s musical meaning.
Variants
- Tie¶
-
Connect two notes of exactly equal spelled pitch.
- Slur¶
-
Legato slur.
- PhrasingSlur¶
-
Phrasing slur.
- Beam¶
-
Explicit beam group.
- Tuplet(u64, u64)¶
-
Ratio displayed above a tuplet.
- Crescendo¶
-
Increasing volume.
- Decrescendo¶
-
Decreasing volume.
- pub enum gd_score::AnnotationKind¶
-
An articulation, dynamic, script or global mark.
Variants
- Breath¶
-
A breathing sign after the note (
\breathe).
- Fingering(u8)¶
-
A finger number in 1..=5.
- Markup(Markup, MarkupRole)¶
-
Rich formatted markup with its semantic role.
- pub enum gd_score::TextStyle¶
-
A text face chosen from the project’s font policy.
Variants
- Regular¶
-
Regular text.
- Bold¶
-
Bold text.
- Italic¶
-
Italic text.
- BoldItalic¶
-
Bold italic text, falling back to bold, then italic, when no such face exists.
- pub enum gd_score::Anchor¶
-
A lyric attachment to a specific note or an independently timed lyric.
Variants
Functions
- pub fn gd_score::check_score(score: &Score) -> Result<(), Error>¶
-
Borrows a score and checks reader-independent invariants. Visits events and references once, with logarithmic measure lookups for meter changes. Returns the first invalid reference, duration, ordering, pitch, meter or interval.
- pub fn gd_score::tab_positions(notes: &[Note]) -> Result<Vec<TabPosition>, Error>¶
-
Places the notes of one chord on the strings of
GUITAR_TUNING, returning one position per note in note order.As LilyPond does by default, a note with a string number keeps that string, and each other note, highest first, takes the highest free string on which its fret lies between 0 and
MAX_FRET. Fails when a string number is outside 1 to 6, when two notes share a string, or when a note has no free string that can play it.
Constants
- pub const gd_score::MAX_STAFF_VOICES: usize = 64¶
-
The most voice records one staff may hold. At most four of them may sound at once; finished voices stay as records so lyrics can still find them by name.
- pub const gd_score::GUITAR_TUNING: [Pitch; 6]¶
-
The open strings of a six-string guitar in standard tuning, string 1 (the highest) first: E4, B3, G3, D3, A2 and E2.
- pub const gd_score::MAX_FRET: u8 = 24¶
-
The highest fret a tablature number may name.