web-music-score - v6.4.0-pre.9
    Preparing search index...

    Class DocumentBuilder

    Document builder class.

    // Example
    let doc = new Score.DocumentBuilder()
    .addScoreConfiguration({ type: "staff", clef: "G", isOctavewDown: true })
    .setMeasuresPerRow(4)
    .addMeasure()
    .addNote(1, "C3", "4n")
    .addChord(1, ["C3", "E3", "G3"], "4n").addAnnotation("chordLabel", "C")
    .addRest(1, "4n")
    // etc.
    .getDEocument();
    Index

    Constructors

    Methods

    • Add annotation with label text to current measure.

      Parameters

      Returns DocumentBuilder

      • This document builder instance.
    • Add any annotation kind to current measure.

      Parameters

      • kind: string

        Annotation kind (e.g. "pp").

      • Optionaloptions: AnnotationOptions

        Annotation options.

      Returns DocumentBuilder

      • This document builder instance.
    • Catch all overload for deprecated stuff. Wil be removed in future release.

      // Deprecated:
      addAnnotation(group: AnnotationGroup, kind: string, options?: AnnotationOptions): DocumentBuilder;
      // Use instead:
      addAnnotation(kind: string, { group: AnnotationGroup }): DocumentBuilder;

      // Deprecated:
      addAnnotation("ending", ...endingPassages: number[]): DocumentBuilder;
      // Use instead:
      addAnnotation("ending", { endingPassages: number | number[] }): DocumentBuilder;

      // Deprecated:
      addAnnotation("endRepeat", repeatCount?: number): DocumentBuilder;
      // Use instead:
      addAnnotation("endRepeat", { repeatCount: number }): DocumentBuilder;

      Parameters

      Returns DocumentBuilder

      Use AnnotationOptions instead for extra args. Will be removed in future release.

    • Add annotation with label text to current measure.

      Parameters

      Returns DocumentBuilder

      • This document builder instance.
    • Add any annotation kind to current measure.

      Parameters

      • staffTargets: StaffTargets

        Single or multiple staff/tab/group identifiers.

      • kind: string

        Annotation kind (e.g. "pp").

      • Optionaloptions: AnnotationOptions

        Annotation options.

      Returns DocumentBuilder

      • This document builder instance.
    • Catch all overload for deprecated stuff. Wil be removed in future release.

      // Deprecated:
      addAnnotation(staffTargets, group: AnnotationGroup, kind: string, options?: AnnotationOptions): DocumentBuilder;
      // Use instead:
      addAnnotation(staffTargets, kind: string, { group: AnnotationGroup }): DocumentBuilder;

      // Deprecated:
      addAnnotation(staffTargets, "ending", ...endingPassages: number[]): DocumentBuilder;
      // Use instead:
      addAnnotation(staffTargets, "ending", { endingPassages: number | number[] }): DocumentBuilder;

      // Deprecated:
      addAnnotation(staffTargets, "endRepeat", repeatCount?: number): DocumentBuilder;
      // Use instead:
      addAnnotation(staffTargets, "endRepeat", { repeatCount: number }): DocumentBuilder;

      Parameters

      Returns DocumentBuilder

      Use AnnotationOptions instead for extra args. Will be removed in future release.

    • Add extension line to previously added annotation or label element.

          // Example
      addExtension(ext => ext.notes("1n", 2)) // length is 2 whole notes
      addExtension(ext => ext.measures(3).hide()) // length is 3 measures, hidden
      addExtension(ext => ext.measures(1).notes("8n")) // length is 1 measure + 1 eigth note
      addExtension(ext => ext.infinity()) // length is as long as possible

      Parameters

      • OptionalextensionBuilder: (ext: ExtensionBuilder) => void

        Extension builder function used to build exstension.

      Returns DocumentBuilder

      • This document builder instance.
    • Add fermata to current measure.

      Parameters

      • fermata: FermataValue = Types.Fermata.AtNote

        Fermata position: "atNote" (default) or "atMeasureEnd".

      Returns DocumentBuilder

      • This document builder instance.

      addFermata() is deprecated. Will be removed in future release. Use addAnnotation() instead.

    • Add fermata to current measure.

      Parameters

      • staffTargets: StaffTargets

        Single or multiple staff/tab/group identifiers.

      • fermata: FermataValue = Types.Fermata.AtNote

        Fermata position: "atNote" (default) or "atMeasureEnd".

      Returns DocumentBuilder

      • This document builder instance.

      addFermataTo() is deprecated. Will be removed in future release. Use addAnnotation() instead.

    • Add label text to column of last added note/chord/rest in current measure.

      Parameters

      • label: LabelValue

        T.Label type: "chord" or "note".

      • text: string

        label text.

      Returns DocumentBuilder

      • This document builder instance.

      addLabel() is deprecated. Will be removed in future release. Use addAnnotation() instead.

    • Add label text to column of last added note/chord/rest in current measure to given staff/tab/group.

      Parameters

      • staffTargets: StaffTargets

        Single or multiple staff/tab/group identifiers.

      • label: LabelValue

        T.Label type "chord" or "note".

      • text: string

        label text.

      Returns DocumentBuilder

      • This document builder instance.

      addLabelTo() is deprecated. Will be removed in future release. Use addAnnotation() instead.

    • Add notes of given scale in ascending order.

      Parameters

      • scale: Scale

        Scale.

      • bottomNote: string

        Scale starts from note >= bottom note.

      • numOctaves: number

        Number of octaves to add.

      Returns DocumentBuilder

      • This document builder instance.
    • Add staff group.

      Parameters

      • groupName: string

        Name of staff group.

      • staffsTabsAndGroups: string | number | (string | number)[]

        Single or multiple staff/tab/group identifiers. Single value or array.

      • verticalPosition: VerticalPositionValue = Types.VerticalPosition.Auto

        Vertical position, are elements added above, below or both.

      Returns DocumentBuilder

      • This document builder instance.
    • Usage:

      addTuplet(0, Theory.Tuplet.Triplet, notes => {
      notes.addNote("G3", Theory.NoteLength.Eighth);
      notes.addNote("B3", Theory.NoteLength.Eighth);
      notes.addNote("D4", Theory.NoteLength.Eighth);
      });

      Parameters

      • voiceId: VoiceId

        Voice id to add tuplet to.

      • tupletRatio: TupletRatio & TupletOptions

        You can also use Theory.Tuplet presets (e.g. Theory.Tuplet.Triplet).

      • tupletBuilder: (notes: TupletBuilder) => void

        Tuplet builder function to build tuplet.

      Returns DocumentBuilder

      • This document builder instance.
    • Fill current measure with rests.

      Parameters

      • ...voiceId: VoiceId[]

        Voice id to add rests to. Single value, array or all if omitted.

      Returns DocumentBuilder

      • This document builder instance.
    • Get music document after finished building.

      Returns MDocument

      • Music document.
    • Add and repeat builder section.

      Parameters

      • times: number

        Repeat count.

      • repeatCreator: (builder: DocumentBuilder) => void

        Repeat creator function.

      Returns DocumentBuilder

      • This document builder instance.
    • Usage examples:

      // throw (default)
      builder.setErrorHandler((e) => { throw e; });
      // log
      builder.setErrorHandler((e) => { console.error("Doc build failed:", e); });
      // log and throw
      builder.setErrorHandler((e) => { console.error("Doc build failed:", e); throw e; });
      // Silent
      builder.setErrorHandler((e) => { });
      

      Parameters

      • fn: (e: unknown) => void

        Error handler function.

      Returns DocumentBuilder

    • Set header texts.

      Parameters

      • Optionaltitle: string

        Title of this docmument/musical piece.

      • Optionalcomposer: string

        Composer of this document/musical piece.

      • Optionalarranger: string

        Arranger of this document/musical piece.

      Returns DocumentBuilder

      • This document builder instance.
    • Set key signature for current measure and forward.

      Parameters

      • tonic: string

        Tonic note (e.g. "C").

      • scaleType: ScaleTypeValue

        Scale type (e.g. string "Major" or ScaleType.Major).

      Returns DocumentBuilder

      • This document builder instance.
    • Set key signature for current measure and forward.

      Parameters

      Returns DocumentBuilder

      • This document builder instance.
    • Set key signature for current measure and forward.

      Parameters

      • keySignature: string

        Key signature string (e.g. "C Major").

      Returns DocumentBuilder

      • This document builder instance.
    • Set key signature for current measure and forward.

      Parameters

      • scale: Scale

        Scale object instance.

      Returns DocumentBuilder

      • This document builder instance.
    • Automatically limit number of measures per score row.

      Parameters

      • measuresPerRow: number

        Number of measures per row. Must be integer >=1 or Infinity.

      Returns DocumentBuilder

      • This document builder instance.
    • Set common or cut time signature for current measure and forward.

      Parameters

      • timeSignature: "C" | "C|"

        "C" or "C|".

      Returns DocumentBuilder

      • This document builder instance.
    • Set time signature for current measure and forward.

      Parameters

      Returns DocumentBuilder

      • This document builder instance.
    • Set time signature for current measure and forward.

      Parameters

      Returns DocumentBuilder

      • This document builder instance.
    • Set time signature for current measure and forward.

      Parameters

      • beatCount: number

        Beat count of time signature (e.g. 3 in "3/4").

      • beatSize: number

        Beat size of time signature (e.g. 4 in "3/4").

      • OptionalbeamGrouping: BeamGroupingValue

        Beam grouping (e.g. "3-2" for time signature "5/8").

      Returns DocumentBuilder

      • This document builder instance.