api.engraving Score

Class representing a score. We can get the current score by calling the api.engraving.curScore

Members

scoreName: String

Name of the score, without path leading to it and extension.

(readonly) title: String

Title of score, as taken from the score properties workTitle

(readonly) composer: String

Composer of the score, as taken from the score properties

(readonly) lyricist: String

Lyricist of score, as taken from the score properties.

(readonly) duration: Number

Duration of score in seconds

(readonly) mscoreVersion: String

MuseScore version the score has been last saved with (includes autosave)

(readonly) mscoreRevision: String

MuseScore revision the score has been last saved with (includes autosave)

(readonly) style: engraving.Style

Style settings for this score.

(readonly) keysig: Number

Key signature at the start of the score, in number of accidentals, negative for flats, positive for sharps

(readonly) npages: Number

Number of pages

(readonly) pages: Array.<engraving.Page>

List of pages in this score.

Since
  • 4.6

pageNumberOffset: Number

Page numbering offset. The user-visible number of the given page is defined as

page.pagenumber + 1 + score.pageNumberOffset

(readonly) parts: Array.<engraving.Part>

The list of parts

(readonly) nstaves: Number

Number of staves

(readonly) staves: Array.<engraving.Staff>

List of staves in this score.

(readonly) ntracks: Number

Number of tracks

(readonly) systems: Array.<engraving.System>

List of systems in this score.

Since
  • 4.6

(readonly) spanners: Array.<engraving.Spanner>

List of spanners (hairpins, slurs, etc.) in this score.

Since
  • 4.7

(readonly) hasHarmonies: Boolean

Whether score has harmonies (chord symbols)

(readonly) harmonyCount: Number

Number of harmony items (chord symbols) in the score

(readonly) hasLyrics: Boolean

Whether score has lyrics

(readonly) lyricCount: Number

Number of lyrics items (syllables) in the score

(readonly) lyrics: Array.<engraving.Lyrics>

List of lyrics in this score.

Since
  • 4.7

(readonly) nmeasures: Number

Number of measures

(readonly) firstMeasure: engraving.Measure

First measure of the score

(readonly) firstMeasureMM: engraving.Measure

First multimeasure rest measure of the score

(readonly) lastMeasure: engraving.Measure

Last measure of the score

(readonly) lastMeasureMM: engraving.Measure

Last multimeasure rest measure of the score

See
  • engraving.Measure.prevMeasureMM

(readonly) lastSegment: engraving.Segment

Last score segment

layoutMode: Number

The current layout mode, a PluginAPI::LayoutMode value.

Since
  • 4.6

showVerticalFrames: Boolean

Whether vertical frames are visible in the current layout mode.

Since
  • 4.6

showInvisible: Boolean

Whether invisible elements are shown in the score.

Since
  • 4.6

showUnprintable: Boolean

Whether formatting elements are displayed in the score.

Since
  • 4.6

showFrames: Boolean

Whether frames are displayed in the score.

Since
  • 4.6

showPageborders: Boolean

Whether page borders are displayed in the score.

Since
  • 4.6

showSoundFlags: Boolean

Whether sound flags are displayed in the score.

Since
  • 4.6

markIrregularMeasures: Boolean

Whether corrupted measures are marked in the score.

Since
  • 4.6

showInstrumentNames: Boolean

Whether instrument names are displayed

Since
  • 4.6

(readonly) selection: engraving.Selection

Current selections for the score.

(readonly) excerpts: Array.<engraving.Excerpt>

List of the excerpts (linked parts)

Methods

metaTag(tag) → {String}

Get the value of a meta tag by name

Parameters:
tagString

Tag

Returns:

Tag value

Type: 
String

setMetaTag(tag, value)

Set a value of a meta tag by name

Parameters:
tagString

Tag

valueString

Value

appendPart(instrumentId)

Appends a part with the instrument defined by instrumentId to this score.

Parameters:
instrumentIdString

ID of the instrument to be added, as listed in instruments.xml

appendPartByMusicXmlId(instrumentMusicXmlId)

Appends a part with the instrument defined by the given MusicXML ID to this score.

Parameters:
instrumentMusicXmlIdString

MusicXML Sound ID of the instrument to be added.

addRemoveSystemLocks(interval, lock)

Add or remove system locks to the current selection.

Parameters:
intervalNumber

Specifies after how many measures locks should be added.

lockboolean

If true, adds locks, else removes them.

Since
  • 4.6

makeIntoSystem(first, last)

Create a (locked) system from two engraving.Measure objects.

Parameters:
firstengraving.Measure

The first Measure in the system.

lastengraving.Measure

The last Measure in the system.

Since
  • 4.6

extractLyrics() → {String}

Extracts all lyrics in the score and returns them in a single string.

Returns:

lyrics string

Type: 
String

appendMeasures(n)

Appends a number of measures to this score.

Parameters:
nNumber

number of measures

tick2measure(tick)

The measure at a given tick in the score.

Parameters:
tickengraving.Fraction

Tick to search for the measure

Since
  • 4.6

firstSegment(segmentType) → {engraving.Segment}

The first segment of a given type in the score. Before MuseScore 4.6, the type could not be specified.

Parameters:
segmentTypeNumber

If not specified, defaults to all types.

Returns:

Segment object

Type: 
engraving.Segment

findSegmentAtTick(types, tick) → {engraving.Segment}

Looks for a segment of a given type at a given tick. Does not create a segment or modify the score.

Parameters:
typesNumber

Determines the types of segments to look for.

tickengraving.Fraction

Determines where to look for the segment

Since
  • 4.6
Returns:

Segment object

Type: 
engraving.Segment

addText(type, text)

Add the text

Parameters:
typeString

Type of text

textString

Value of text

doLayout(startTick, endTick)

Force the score to layout itself. The score is laid out automatically at the end of a command, however this method can be called to layout mid-command. Layout the whole score with:

curScore.doLayout(fraction(0, 1), fraction(-1, 1))
Parameters:
startTickengraving.Fraction

Fraction from which to start the layout

endTickengraving.Fraction

Fraction at which to end the layout

Since
  • 4.6

Cursor* newCursor() → {Cursor}

Creates and returns a cursor to be used to navigate in the score

Returns:

cursor

Type: 
Cursor

startCmd(qActionName)

For MuseScore 4 and for "dock" type plugins: to be used before score modifications to make them undoable, and to avoid corruptions or crashes. Starts an undoable command. Must be accompanied by a corresponding endCmd() call.

Parameters:
qActionNameString

Optional action name that appears in Undo/Redo menus, palettes, and lists.

endCmd(rollback)

For MuseScore 4 and for "dock" type plugins: to be used after score modifications to make them undoable, and to avoid corruptions or crashes. Ends an undoable command.

Parameters:
rollbackBoolean

If true, reverts all the changes made since the last startCmd() invocation.

showElementInScore(item, staffIdx)

Put an item in the user's view.

Parameters:
itemengraving.EngravingItem

The item to put into view.

staffIdxNumber

If provided, the specific staff to put into view.

Since
  • 4.6

createPlayEvents()

Create PlayEvents for all notes based on ornamentation. You need to call this if you are manipulating PlayEvent's so that all ornamentations are populated into Note's PlayEvent lists.

Deprecated
  • PlayEvents don't have a playback effect in MuseScore 4.