Introduction

Mis à jour il y a 4 ans

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



Plugins allow you to extend MuseScore beyond its built-in features using JavaScript. MuseScore provides a minimal API with access to a subset of MuseScore-specific objects and the Qt API .

Existing plugins can be found in the plugin directory . To discuss plugin development, announce your own plugin, or discuss the plugin API, you can join the dedicated forum .

JavaScript

MuseScore plugins are written in the language JavaScript 1.5 (ECMA-262) using the QtScript engine. If you are familiar with JavaScript from web development you are in good shape, but its important to note that web browsers add specific extensions like DOM and some other functions that are not available to MuseScore plugins.

Resources

  • JavaScript 1.5 Guide - A thorough overview of the language.
  • API documentation for the standard functions and objects - This documents some functions available only in JavaScript 1.6, which MuseScore does not support; they are marked as such.
  • Quick reference - a provided list of objects and functions.
    • Qt bindings

      Qt is the C++ GUI toolkit and library used by MuseScore. Using the Qt Script Generator , MuseScore provides JavaScript bindings to most of the Qt API. This allows you to create widgets and windows, use advanced XML parsing methods, browse the web, open a TCP port and much more.

      Currently there is no reference of the Qt methods accessible through Javascript in MuseScore. Basically, the majority of the objects and functions from QtCore, QtGui, QtUiTools, QtNetwork and QtXml modules should be available. The C documentation and tutorials can also be used. Usually when developing a MuseScore Plugin, you can refer to the Qt Project C++ documentation. However, differences between the nature of C++ and JavaScript mean that the JavaScript docs may differ slightly. This might happen when:

      • C++ features are being used that JavaScript doesn't support.
        • templates
        • Function overriding. If you see a set of functions in the Qt C++ docs with the same name, but different argument types then function overloading is being used and the Qt Script Generator might have chosen to support only one of them (generally the most complete function). Note that the Qt bindings should support different functions with the same name if they vary in the number of arguments.
        • Classes that are redundant with built-in JavaScript types. Just use the JavaScript types instead. Examples include:
          • QList, use Array instead
          • QString, use String instead
          • QVariant, use Object instead

        Access MuseScore objects

        If you are writing a MuseScore plugin, there is a good chance you mainly want to manipulate and query MuseScore objects. Some objects are available to the plugin framework. The latest API is documented in other pages of this handbook. The README.scripts (1.1 version) is also available.

        Debugging

        MuseScore is bundled with a plugin debugger. You can activate it from the Help menu. The plugin debugger enables step-by-step debugging and displays "print" results in the Debug output tab. It also includes a "command line" or Console tab where you can evaluate one line of Javascript code at a time.

        If you want to test a snippet of Javascript code, you can install the Plugin Console plugin.

        Legal

        If you use the Qt Bindings, it seems you are legally obligated to release your script under the GPL v2 or v3 license, under the terms of Qt 4.6's Open Source licensing .

        This documentation is based on the Amarok Scripting How to . Amarok is using the same technology to provide scripting of the music player