Music Sheet Viewer WordPress plugin

« Music Sheet Viewer » plugin allows you to display and play, one or more music sheets written in MEI, MusicXML, ABC … in a WordPress page.

The code is entered directly using the shortcode tag [pn_msv] … and that’s all!!

You do not need to escape HTML entities or anything. Just post your code as-is, even if the code is an XML dialect. The plugin will handle the rest.

The score is resized automatically so as to fit to the available content, you can specify the music font in which the score will be rendered and you can get the music code from a file if you don’t want to write the code inline.

You can play the score and there’s even an option to highlight the notes as they are played!

With this plugin, never ever upload a music sheet image to your website that is not zoomable and requires a new upload every time a single note must be changed!!!

At last it’s fully responsive!

Example : This same page uses the « Music Sheet Viewer » plugin.

The following PAE code :


[pn_msv]
@clef:G-2
@keysig:xFCGD
@timesig:3/8
@data:'6B/{8B+(6B''E'B})({AFD})/{6.E3G},8B-/({6'EGF})({FAG})({GEB})/4F6-
[/pn_msv]

displays as :

MusicSheetViewerPlugin 2.2

Installation

The plugin can be installed from : Music Sheet Viewer on WordPress plugins directory

Implementation

The music sheet rendering is powered by the Verovio JavaScript toolkit.

The score can be played thanks to an enhancement of the MIDI Player.

Supported formats

« Music Sheet Viewer » supports code written in :

Supported inputs

The input can be entered either inline inside [pn_msv] and [/pn_msv] shortcode, or for big scores, using the file parameter.

Content displayed

This plugin is not intented for displaying a full score with many pages, but either the first page of a multi-pages score, or music incipts.

Score layout

The score fits automatically to the content in which it’s placed without any specific indication.
If what is displayed is too small to fit to the allowed content it’s possible to justify the rendering, using the layout="justified" parameter.

Shortcode parameters

format

Format of the music sheet code when passed inline. Has no effect if file parameter is used.

Possible values :

  • mei (MEI)
  • xml (MusicXML)
  • abc (ABC)
  • or pae (RISM format)

Default format is pae as it’s compact and convenient for displaying music sheet fragments.

Note that « Music Sheet Viewer » doesn’t check that the code is written in the language passed to format parameter. If they don’t match, the result is unpredictable.

file

If the code isn’t specified inline, allows to indicate either :

  • a local file previously uploaded on your website
  • In this case, file parameter must start with a ‘/’ and is assumed to be found under your website’s root.

    Example :

    
    [pn_msv file="/wp-content/uploads/2017/05/DoSerrure.mei"/]
    
  • a remote file
  • Specify the complete URL of the file.

    Example :

    
    [pn_msv format="mei" file="https://www.verovio.org/examples/downloads/Chopin_Etude_op.10_no.9.mei"/]
    

    Warning: Note that remote files can only be accessed on sites enabling Cross-Origin Requests (CORS) (see https://enable-cors.org/)

font

Renders the score with the corresponding SMuFL font. The following fonts are available :

  • Leipzig
  • Bravura
  • Gootville
  • Petaluma

By default, Leipzig is used.

A specific font value (« roll ») allows the music fragment to be displayed in a loop, in all available fonts. The font is changed every 2 seconds and the animation lasts 2 minutes. It can allow choosing at preview time which font is best for your score, or just to show it for demonstrating the capabilities of digital scores.

play

Plays the score with a MIDI piano synthesis.
The following options are possible:

  • player
  • Plays the score thanks to the mini-player.

  • auto
  • Plays the score automatically at page load.

  • highlight
  • Same as « player » but the notes are highlighted as they are played.

    Example:

    
    [pn_msv play="highlight"]
    X:1
    T:La Vie En Rose
    M:C|2
    L:1/4
    K:C
    c3B|AGEc|B3A|GECB|A3G|EB,CB|A4|G2z2|]
    [/pn_msv]
    MusicSheetViewerPlugin 2.2

  • autohigh
  • Same as auto but the notes are highlighted as they are played.

layout

By default the score fits automatically to the content in which it’s placed.

layout="justified" allows to maximize the space used to display a score line too small to fit to the allowed content.
To keep for this specific situation as this option will display every music sheet on a single line.

This is the only possible layout value so far.

Example :
Without justification :


[pn_msv]
@clef:G-2
@keysig:xF
@timesig:3/8
@data:=25//$xFCG @c 2-4.-'8E/{6AGFE}{8A''C}'B''4D{6C'B}/{''DC'BA}{''8EA}
[/pn_msv]
MusicSheetViewerPlugin 2.2

With justification:


[pn_msv layout="justified" font="Gootville"]
@clef:G-2
@keysig:xF
@timesig:3/8
@data:=25//$xFCG @c 2-4.-'8E/{6AGFE}{8A''C}'B''4D{6C'B}/{''DC'BA}{''8EA}
[/pn_msv]
MusicSheetViewerPlugin 2.2

id

Allows you to assign an id to the underlying generated HTML element.
That allows you styling it with a CSS element selector.

class

Allows you to assign a class to the underlying generated HTML element.
That allows you styling it with a CSS class selector.

NB : CSS styles on a specific page can be added by means of the Per page add to head plugin

Error messages

Error messages can raise at preview time (e.g font parameter with an unknown value), letting you fix the code prior to publishing.
Or they can raise later, for example if the content of a score file previously uploaded is changed and produces a loading error : In this case the error might only be visible in the browser’s console in development mode.

Troubleshooting

From WordPress 5.0 it is strongly recommended to switch to the Classical editor if you intend to write pn_msv shortcodes with inline MusicXML or MEI code.
Indeed Gutenberg, even under the Code editor, swallows some tags like <body> which is a licit MEI tag.

Known limitations

  • No nested shortcodes are allowed within MEI or XML formats.
  • The font=« roll » is not compatible with « play » options. It’s either one or the other.
  • If several shortcodes in the same page have the font=« roll » option, the behaviour is unpredictable
  • Specific fonts are not compatible with play=« highlight » or « autohigh » options. In that case the font — if any — is forced to Leipzig
  • If several shortcodes in the same page have the font=« auto » or « autohigh » options, the behaviour is unpredictable
  • If a score with font=« roll » is currently displaying and another score is played, the roll effect is stopped
  • When a score is played, it is played to the end even if it exceeds the length of what is displayed.

Gallery

Gallery of examples using Music Sheet Viewer plugin

Les commentaires sont fermés.