import { Beam } from './beam'; import { BoundingBox } from './boundingbox'; import { ElementStyle } from './element'; import { EngravingProfile } from './engravingprofile'; import { ModifierContextState } from './modifiercontext'; import { Note, NoteStruct } from './note'; import { NoteHead } from './notehead'; import { Stave } from './stave'; import { Stem, StemOptions } from './stem'; import { StemmableNote } from './stemmablenote'; export interface StaveNoteHeadBounds { yTop: number; yBottom: number; displacedX?: number; nonDisplacedX?: number; highestLine: number; lowestLine: number; highestDisplacedLine?: number; lowestDisplacedLine?: number; highestNonDisplacedLine: number; lowestNonDisplacedLine: number; } export interface StaveNoteFormatSettings { line: number; maxLine: number; minLine: number; isrest: boolean; stemDirection?: number; stemMax: number; stemMin: number; voiceShift: number; isDisplaced: boolean; note: StaveNote; } /** A head's pitch and marks travel together when the chord or its extracted part is rebuilt. */ export interface ChordHeadSpec { key: string; fingering?: { finger: string; position: 'above' | 'below' | 'left' | 'right'; }; /** Always print the written sign. A cautionary also encloses it in parentheses. */ accidental?: 'force' | 'cautionary'; } export interface StaveNoteStruct extends NoteStruct { /** Written pitches with individual marks, as an alternative to keys. */ heads?: readonly ChordHeadSpec[]; /** Print the complete white mensural sign for a pitched maxima, longa or brevis. */ whiteMensural?: boolean; /** Fixed rest position in key-line coordinates. On a five-line stave, 1 is the bottom line. */ restLine?: number; /** Override the music glyph family for this note, its heads and its flag. */ musicFont?: string; engraving?: EngravingProfile; /** `Stem.UP` or `Stem.DOWN`. */ stemDirection?: number; autoStem?: boolean; strokePx?: number; octaveShift?: number; clef?: string; } export declare class StaveNote extends StemmableNote { static DEBUG: boolean; static get CATEGORY(): string; static get LEDGER_LINE_OFFSET(): number; static get minNoteheadPadding(): number; /** Format notes inside a ModifierContext. */ static format(notes: StaveNote[], state: ModifierContextState): boolean; static postFormat(notes: Note[]): boolean; minLine: number; maxLine: number; /** The historical sign takes precedence over modern heads when the note is rebuilt. */ private readonly mensuralSign?; protected readonly clef: string; protected readonly octaveShift?: number; /** Preserve the previous line so releasing an explicit position restores automatic placement. */ private lineBeforeRestPin?; protected displaced: boolean; protected dotShiftY: number; protected useDefaultHeadX: boolean; private extraHeadColumns; protected ledgerLineStyle: ElementStyle; private _noteHeads; private sortedKeyProps; readonly engraving?: EngravingProfile; constructor(noteStruct: StaveNoteStruct); reset(): this; setBeam(beam: Beam): this; private fourShapeTonic?; /** Apply the movable major four-shape convention to the passage before formatting. */ static applyFourShape(tonic: string, notes: readonly StaveNote[]): void; /** Choose each owned head again on a stem reversal. Explicit per-pitch head overrides take precedence. */ private fourShapeHead; buildStem(): this; buildNoteHeads(): NoteHead[]; autoStem(): void; calculateOptimalStemDirection(): number; calculateKeyProps(): void; /** Absolute ink of each head after formatting, independent of previous draws. */ getHeadInk(): BoundingBox[]; /** Absolute flag ink; beamed notes and rests have no flag. */ getFlagInk(): BoundingBox | undefined; /** Resolve the rendered stem before its parent writes the drawing coordinates. */ getStemSegment(): ReturnType | undefined; getBoundingBox(includeModifiers?: boolean): BoundingBox; getLineNumber(isTopNote?: boolean): number; /** * @returns true if this note is a type of rest. Rests don't have pitches, but take up space in the score. */ isRest(): boolean; isChord(): boolean; hasStem(): boolean; hasFlag(): boolean; /** Use explicit font metadata first, then the bundled anchors for Bravura rhythm slashes. */ private stemAnchor; getStemX(): number; getYForTopText(textLine: number): number; getYForBottomText(textLine: number): number; setStave(stave: Stave): this; isDisplaced(): boolean; setNoteDisplaced(displaced: boolean): this; getTieRightX(): number; getTieLeftX(): number; getLineForRest(): number; getModifierStartXY(position: number, index: number, options?: { forceFlagRight?: boolean; }): { x: number; y: number; }; setStyle(style: ElementStyle): this; setStemStyle(style: ElementStyle): this; getStemStyle(): ElementStyle | undefined; setLedgerLineStyle(style: ElementStyle): void; getLedgerLineStyle(): ElementStyle; setFlagStyle(style: ElementStyle): void; getFlagStyle(): ElementStyle | undefined; /** Get the glyph width. */ getGlyphWidth(): number; setKeyStyle(index: number, style: ElementStyle): this; /** The explicit key line, or undefined when rest placement is automatic. */ get restLine(): number | undefined; /** Pin this rest to a line. Passing undefined releases it for automatic placement. */ setRestLine(line: number | undefined): this; setKeyLine(index: number, line: number): this; getKeyLine(index: number): number; getVoiceShiftWidth(): number; calcNoteDisplacements(): void; preFormat(): void; /** * @typedef {Object} noteHeadBounds * @property {number} yTop the highest notehead bound * @property {number} yBottom the lowest notehead bound * @property {number|Null} displacedX the starting x for displaced noteheads * @property {number|Null} nonDisplacedX the starting x for non-displaced noteheads * @property {number} highestLine the highest notehead line in traditional music line * numbering (bottom line = 1, top line = 5) * @property {number} lowestLine the lowest notehead line * @property {number|false} highestDisplacedLine the highest staff line number * for a displaced notehead * @property {number|false} lowestDisplacedLine * @property {number} highestNonDisplacedLine * @property {number} lowestNonDisplacedLine */ /** * Get Y bounds for the stem, adjusted for SMuFL stem anchor offsets defined in * Tables.noteHeadStemYOffsets. This ensures stems attach at the correct point * on the notehead (e.g. the arm tip of an X notehead) rather than the center. */ protected getStemYBounds(): { yTop: number; yBottom: number; }; /** * Get the staff line and y value for the highest & lowest noteheads * @returns {noteHeadBounds} */ getNoteHeadBounds(layoutX?: boolean): StaveNoteHeadBounds; getNoteHeadBeginX(): number; getNoteHeadEndX(): number; get noteHeads(): NoteHead[]; /** Shared ledger segments after formatting, in renderer pixels. */ getLedgerLines(): { x: number; y: number; width: number; }[]; drawLedgerLines(): void; drawModifiers(noteheadParam: NoteHead): void; shouldDrawFlag(): boolean; /** Share flag coordinates between measurement and drawing. */ private getFlagPosition; drawFlag(): void; drawNoteHeads(): void; drawStem(stemOptions?: StemOptions): void; /** * Override stemmablenote stem extension to adjust for distance from middle line. */ getStemExtension(): number; draw(): void; }