Guidedog मैनुअल 1.0.0-beta.16
भाषा
इस पृष्ठ पर
Guidedog / दस्तावेज़ 1.0.0-beta.16

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 base: Base

Written notehead and flag duration.

pub dots: u8

Augmentation dots, at most eight.

pub scale: Ratio

Proportional duration, including nested tuplet factors.

Implementations

impl Duration
pub fn time(self) -> Result<Ratio, Error>

Returns exact time in whole notes. Fails for invalid dots, scale or overflow.

Trait Implementations

impl Default for Duration
fn default() -> Self
pub struct gd_score::Error

A structured diagnostic. Adapters place its span in a retained source file.

Fields

pub kind: ErrorKind

Stable classification.

pub severity: Severity

Whether the drawing remains valid.

pub span: Span

Original notation location, or the default when unplaced.

pub message: String

One concrete explanation.

pub hint: String

A corrective action.

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

impl Default for FileId
fn default() -> Self
pub struct gd_score::Span

A half-open byte range in a source file. The default is an unplaced diagnostic.

Fields

pub file: FileId

The source file that owns the range.

pub start: usize

First byte, inclusive.

pub end: usize

Last byte, exclusive.

Implementations

impl Span
pub fn is_unplaced(self) -> bool

Returns whether this span carries no source-file attachment.

pub struct gd_score::Key

Tonic and mode, independent of the current octave.

Fields

pub tonic: Pitch

Spelled tonic; octave has no effect on the signature.

pub mode: Mode

Diatonic mode.

Implementations

impl Key
pub fn alterations(self) -> Result<[Alter; 7], Error>

Returns alterations by step from C. Fails when the key needs triple accidentals.

pub struct gd_score::Pitch

A spelled pitch; c is octave 0, c’ (middle C) is octave 1.

Fields

pub step: Step

Diatonic spelling.

pub alter: Alter

Chromatic alteration.

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 fn transpose_tonic(mut self, mut from: Self, mut to: Self) -> Result<Self, Error>

Transposes an octave-invariant pitch class such as a key tonic or chord symbol root.

pub fn check_range(self) -> Result<(), Error>

Checks the profile’s finite ledger-line range, returning a pitch diagnostic.

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 Default for Ratio
fn default() -> Self
impl fmt::Display for Ratio
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Ord for Ratio
fn cmp(&self, rhs: &Self) -> Ordering
impl PartialOrd for Ratio
fn partial_cmp(&self, rhs: &Self) -> Option<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 main: Ratio

Main musical time.

pub grace: Ratio

Negative grace time before the main moment, or zero.

pub struct gd_score::NoteRef

A particular head of a chord event, not merely the event as a whole.

Fields

pub event: EventId

Chord event.

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 staves: Vec<Staff>

Staves in top-to-bottom order.

pub groups: Vec<StaffGroup>

Braced or bracketed contiguous groups.

pub voices: Vec<Voice>

Voices, each owned by one staff.

pub events: Vec<Event>

Events addressed by stable indices.

pub spanners: Vec<Spanner>

Ties, slurs, hairpins, beams, tuplets and repeat brackets.

pub lyrics: Vec<LyricLine>

Lyric verses attached to notes or exact time.

pub measures: Vec<Measure>

Measure boundaries and effective meter.

pub struct gd_score::Staff

One staff of standard notation or tablature.

Fields

pub kind: StaffKind

Standard notation or tablature.

pub name: String

Full name on the first system.

pub short_name: String

Abbreviation on subsequent systems.

pub name_markup: Option<Markup>

Optional structured markup for the full instrument name.

pub short_name_markup: Option<Markup>

Optional structured markup for the abbreviated instrument name.

pub struct gd_score::Voice

One of at most four independent rhythmic sequences on a staff.

Fields

pub staff: StaffId

Owning staff.

pub name: String

Optional input name, used to attach lyrics.

pub events: Vec<EventId>

Chronologically ordered event identifiers.

pub direction: Direction

Default stem policy for this voice.

pub struct gd_score::StaffGroup

A connected group of contiguous staves.

Fields

pub first: StaffId

First staff, inclusive.

pub last: StaffId

Last staff, inclusive.

pub kind: GroupKind

Brace or bracket.

pub name: String

Full name of the whole group on the first system, beside its brace or bracket.

pub short_name: String

Abbreviation of the group’s name on subsequent systems.

pub name_markup: Option<Markup>

Optional structured markup for the group’s full name.

pub short_name_markup: Option<Markup>

Optional structured markup for the group’s abbreviated name.

Implementations

impl StaffGroup
pub fn new(first: StaffId, last: StaffId, kind: GroupKind) -> Self

A group of kind over first..=last without a name.

pub struct gd_score::Event

One timed event with its original location.

Fields

pub voice: VoiceId

Owning voice.

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 from VoiceStyle::column_shift.

pub at: Moment

Exact start time.

pub kind: EventKind

Musical meaning.

pub span: Span

Source location retained for diagnostics.

pub marks: Vec<Annotation>

Marks attached to this event.

pub struct gd_score::Chord

Simultaneous noteheads with one written duration.

Fields

pub notes: Vec<Note>

Heads in input order; relative pitch interpretation uses this order.

pub duration: Duration

Written and sounding duration.

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 pitch: Pitch

Sounding and written pitch.

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_positions describes.

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

impl Default for Meter
fn default() -> Self
pub struct gd_score::Spanner

A bounded interval such as a slur or tuplet.

Fields

pub start: NoteRef

Opening event or note.

pub end: NoteRef

Closing event or note.

pub kind: SpannerKind

Meaning and drawing policy.

pub direction: Direction

Explicit direction when present.

pub span: Span

Original notation for diagnostics.

pub struct gd_score::Annotation

A text or symbol attached to a rhythmic event.

Fields

pub kind: AnnotationKind

Meaning of the mark.

pub direction: Direction

Explicit side, when supplied.

pub struct gd_score::LyricLine

One verse below a voice.

Fields

pub voice: VoiceId

Voice whose staff owns the verse.

pub syllables: Vec<Syllable>

Ordered syllables.

pub struct gd_score::Syllable

One lyric syllable with a possible hyphen or extender.

Fields

pub text: String

Text to shape.

pub anchor: Anchor

First note or exact moment.

pub hyphen: bool

Join to the next syllable with a hyphen.

pub extender: Option<Anchor>

Last note or moment of a melisma extender.

pub span: Span

Source location for diagnostics.

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 start: Ratio

Exact start, inclusive.

pub end: Ratio

Exact end, exclusive.

pub meter: Meter

Effective meter.

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

impl Base
pub fn denominator(self) -> u16

Returns the denominator of a whole-note fraction, or zero for a breve.

pub fn from_denominator(den: u16) -> Result<Self, Error>

Reads a supported duration denominator. Zero denotes a breve; others may fail.

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

impl ErrorKind
pub fn code(self) -> &'static str

Returns the diagnostic’s stable code without allocating.

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

Text(String)

Shaped text string.

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 (100 is unchanged).

shift_percent: i16

Upward baseline shift in hundredths of the enclosing font size.

body: Box<Self>

Scaled child expression.

Framed(Enclosure, Box<Self>)

Frame or underline around an expression.

MusicGlyph(String)

Named SMuFL glyph from the embedded music font.

Dynamic(String)

Inline dynamic string rendered with SMuFL dynamic glyphs.

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

impl Markup
pub fn plain_text(&self) -> String

Extracts a readable plain-text summary for accessibility descriptions and metadata.

pub fn approx_bytes(&self) -> usize

Returns a conservative heap footprint estimate in bytes.

pub fn check(&self, depth: usize) -> Result<(), Error>

Validates depth, scale percentages and dynamic letters.

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 fn apply(self, outer: TextStyle) -> TextStyle

The style that results from applying this change inside outer.

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

impl Alter
pub fn semitones(self) -> i16

Returns the signed semitone offset.

pub fn from_semitones(value: i16) -> Result<Self, Error>

Reads an offset, failing for alterations outside the profile.

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

impl Mode
pub fn index(self) -> usize

Returns the rotation index of the major scale.

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

Chord(Chord)

One or more pitched noteheads.

Rest(Duration)

An ordinary rest.

Skip(Duration)

An invisible rhythmic spacer.

MeasureRest(Duration)

One or more whole-measure rests.

Clef(Clef)

A clef change.

Key(Key)

A key change.

Time(Meter)

A meter change on a measure boundary.

Bar(BarStyle)

A visible bar line.

Break(BreakRule)

A forced or forbidden system break.

ChordName(Markup, Duration)

A chord-name symbol at this moment, as formatted markup such as a root, a quality and a raised extension.

Implementations

impl EventKind
pub fn duration(&self) -> Option<&Duration>

Borrows a rhythmic duration, or returns None for instantaneous notation changes.

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

impl Clef
pub fn middle(self) -> i16

Returns the diatonic pitch on the middle staff line.

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 \numericTimeSignature asks.

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.

Volta(String)

Numbered repeat alternative.

pub enum gd_score::AnnotationKind

An articulation, dynamic, script or global mark.

Variants

Articulation(String)

A named SMuFL articulation.

Breath

A breathing sign after the note (\breathe).

Fingering(u8)

A finger number in 1..=5.

Dynamic(String)

A dynamic such as mf or sfz.

Text(String, TextStyle)

Outlined text, with its simple style.

Tempo(String)

A tempo instruction.

Rehearsal(String)

A rehearsal label.

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

Note(NoteRef)

A note within a chord.

Moment(Moment)

An exact main or grace moment.

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.