Score Object

Atnaujinta prieš 4 years

This documentation applies to plugins for 1.x only!


Documentation for 2.x+ is built into the Plugin Creator of Musescore.

( ⇒ In Musescore press Ctrl+Shift+P, then F1 to bring it up. )


Click here for Documentation for 3.x



Represents a complete score.

A new score can be created with:
var a = new Score();
The new score is appended to MuseScore's list of scores.

The current score can be obtained with:
var b = curScore;

Properties

Name Type Description
composer string name of the composer
duration integer total score duration in seconds (read-only)
fileName string the name of the file without the path, "Untitled" for unsaved scores (read-only). (MuseScore 2.0+ as of r5033 )
fileVersion string the version of the version information (MuseScore 1.2+)
hasHarmonies bool true if a valid chordname is found
hasLyrics bool true if a lyric element is found in the score
keysig integer Key signature at the beginning: -7 (= 7 flats) to 7 (= 7 sharps) or undefined for custom signature
measures integer Number of actual measures (read only)
pageFormat PageFormat Object the format of pages in the score (currently disabled)
pages integer Number of pages (read only)
parts integer Number of parts (read only)
path string the path of the score without the filename, an empty string if the file is not saved (read-only). (MuseScore 2.0+ as of r5033 )
poet string name of the poet/lyricist
staves integer number of staves (read-only)
subtitle string subtitle of the score
title string title of the score
timesig TimeSig Object the time signature of the score (MuseScore 1.1+)
version string the version of MuseScore that the score was last saved with (MuseScore 1.2+)

Methods

appendMeasures(integer n)

Append n measures to the score.

appendPart(string partname)

Append a new part to the score.
partname refers to an instrument name in the file instruments.xml.
The part will be initialized from the named instrument in this file.
If partname is empty, a default part will be appended.

close()

Close score. (MuseScore 1.2+)

endUndo()

End undoable operations.

bool load(string path)

Load the score file located at path. Can be any format supported by MuseScore, the extension is used to find out the type of file.

int metatag(string tag)

Sets metatag tag to tag. (Version 2.0+)

int metatag(string tag, string value)

Sets metatag tag to value. (Version 2.0+)

Part part(int i)

Part object at index i.

bool save(string path, string type)

Write score into file path. The file extension type determines the type of file:
"mscz", "mscx", "xml", "mxl", "mid", "pdf","ps", "png", "svg", "ly", "wav", "flac", "ogg".
Not all types may be available.

bool save(string path, string type, string soundfontPath)

For soundfile output (type being one of "wav", "flac", "ogg"), the soundfont to be used can be specified as an additional parameter. (Not available anymore in MuseScore 2.x as of r5011 ).

bool save(string path, "png", boolean screenshot, boolean transparent, double dpi, boolean grayscale)

When saving into a PNG file, additional parameters can be specified.

setExpandRepeat(bool)

Turns on or off the repetitions of ritornellos.

setStyle(string key, string value)

Set the style element with name key to the given value. Known to work for the given keys:

  • chordDescriptionFile
  • lastSystemFillLimit

startUndo()

Starts undoable operations.