Scripting

From Denemo - Free and Open Music Notation Editor

Jump to: navigation, search
Scripting
Author: Nils Gey
Type: Scripting
Level: Advanced User
Version: 0.8.4
Example



Denemo offers a very powerful Script-API via Guile/Scheme. Denemo itself uses it to create many of its features and commands.

Recording Scripts

You don't have to know scheme to create new scripts. It is possible to record your GUI-actions and save them as a new script/command. Think of it as a Macro. You can also create a script from an existing DenemoDirective using the advanced text edit dialog.

List of Commands

These are the special Denemo scheme-commands. You can copy and paste them to a new line to make them work.

  • (d-CursorLeft)
    • Shifts the Cursor left one position - this is a standard Denemo command under the Cursor menu
  • (d-RefreshDisplay) - this is a special for scheme command.

Misc

From here on only notes:

  • (d-DirectivePut-standalone-override "StepTempo" (logior DENEMO_OVERRIDE_TEMPO DENEMO_OVERRIDE_STEP DENEMO_OVERRIDE_RELATIVE))
    • puts a standalone-object in the staff tagged "StepTempo". Override means if there is already one at the cursor with the same tag then it will be replaced. logior means "now follow the flags", followed indeed by three flags.
  • (d-DirectivePut-standalone-midibytes "StepTempo" "40")
    • The upper line creates a standalone directive tagged "StepTempo" and simultaneously sets its override field, now it we alter other fields of this directive. The 40 is the actual value to be used by the MIDI output routines, in this case the tempo increase. Note that this all applies to the same denemo directive - the one at the cursor with the tag StepTempo so if you use it twice in the same script without moving the cursor the first setting will be overwritten.

So the first line defines the meaning of the midibytes field set in the second one (the effect will be heard when it is played back). If you just use the second one alone it will create a standalone directive with the default meaning for the midibytes field which is that it will send the midibytes out when played back. That is it will send raw midi-data, so it depends on the enviroment - where the cursor is in the score. Means: Don't do it unless you understand what your are doing (e.g. channel changes). As with other scripts, your script should establish the environment that it is in (e.g. by doing (d-StaffUp) repeatedly to get to the topmost staff for MIDI messages that must be output with the first staff).