A Canvas based Music Notation system for the web
This project is maintained by mauritslamers
Presto is a Canvas based music notation system for the web. It only requires an HTML5 compliant browser.
Please try out the Demo and let me know what you think!
The purpose of Presto is to have an as readable as possible notation system for the web which excels at excerpts and which is able to display the notation of the given music nearly instantaneous.
It takes the LilyPond notation system as main example, trying to come as close as possible to its elegance, but trying to never sacrifice speed in the process. Presto will therefore never be a complete notation system, but of course tries to come as close as possible.
It uses the Lilypond Emmentaler font as a webfont for the best possible graphical result.
As Presto is very much in active development, this document contains elements which are intended to be supported at some point but in the API description below is indicated whether a feature is implemented.
Presto in the current state doesn't do a lot for you, except printing the notation and try to make that look (sort of) right. It will simply print whatever you give it, but it doesn't in any way make sure that your notation is right. This means (among other things):
There are two ways in which you can enter music:
You'll need to create a HTML page, where you add presto.js as a script, as well as presto.css. You can take one of the html pages in this repository as an example. You'll then need to add a canvas element and give it an id. Before you can notate anything, you will have to create a HTML page with a canvas element in it. This canvas element needs to have a unique id.
You then add another script tag, in which you need to define the music and tell Presto where to put the result. A very simple example (assuming the id of the canvas elements is 'canvas'):
var score = {
staffs: [
{
clef: "treble",
key: "c major",
time: "4/4"
notes: [
{
{ name: "c", length: 4, octave: 1 }
}
]
}
]
}
var p = Presto.Score.from('canvas');
window.setTimeout(function () {
p.parse(score);
p.notate();
p.render();
}, 200);
NOTE: you will have to call the notate() and render() functions using a time out, because the browser only starts loading the font after it is referred to the first time. When you'd get all kinds of squares instead of notation, you'll need to refresh, or re-render.
Presto borrows quite a few concepts from Lilypond, the main one being the context layering. The main context is the score context, which has a property called staffs, which is an array of staff contexts.
Properties:
Properties to be supported in the future
Every staff contains a propery called notes, which is an array with notation elements. (rename?) The array contains a set of object literals, which can be:
A note is an object which can have the following properties:
As you can see the dots are not part of the length property, but stored in a separate property called dots. So, if you need a quarter note with two dots, you set the length to 4 and dots to 2.
You can make chords by creating an array with note objects. If you want to have multiple voices, you need to set the stem directions yourselves.
To be supported:
A rest is an object which can have the following properties:
To be supported:
To be supported:
A barline is an object with only a name property, where the name is one of:
The system renders the musical notation in three phases: