A javascript library for displaying notes on a musical staff.
Inspired by the
nslider
in MaxMSP.
Try the live demo.
- show notes on a musical staff
- touch on staff to update the note
- change clef (treble, alto, tenor, bass, grand)
- change accidental sharp or flat
import staff.js library
<!-- import CSS -->
<link rel="stylesheet" href="css/staff.css" />
<!-- import JavaScript -->
<script src="js/JZZ.js"></script>
<script src="js/JZZ.input.Kbd.js"></script>
<script src="js/staff.js"></script>
add this HTML
<div id="myStaff"></div>
now you can use the library to create a staff
// these are the options
var options = {
id: "myStaff",
clef: "treble",
accidental: "flat",
color: "#FF0000",
scroll: false,
}
// create a new staff
var myStaff = new Staff(options)
change the clef
myStaff.setClef('bass');
get the clef
myStaff.getClef();
// bass
Set the current note
myStaff.setNote(88);
Get current note
myStaff.getNote('myStaff');
// 68
change the accidental
myStaff.setAccidental('sharp');
To display multiple notes, setNote()
with an array.
myStaff.setNote([45,55,62]);
set the color
myStaff.setColor('#FF0000');
get the color
myStaff.getColor();
// #FF0000
- support for multiple staffs
- refactor ledger line code
- create a
addNote()
function - add way to make note color different from staff color
- add key signatures
- add microtonal notation
- add way to change note stems
- add way to show note name in notehead
- add way to show a scale
Any contributions you make are greatly appreciated. Any bugs and change requests are to be reported on the issues tab. If you don't like coding, you can contribute by becoming a sponsor.
Please write to [email protected] or visit instrument.bible.