- What note is a minor 3rd above a B?
- What are the scale tones of a Gb Harmonic Minor?
- What relation is the C# note to an A Major scale? (Major 3rd)
- What accidentals should be displayed for the perfect 4th note of a G Major scale?
- etc.
The API is part of VexFlow, and can be used independently of the rendering API. Take a look at music.js in the VexFlow GitHub repository for the complete reference. There's also a handy key management library for building scores in keymanager.js.
I'm currently working on updating the VexFlow Tutorial with a quickstart on the music theory API, but meanwhile, here are some teasers (pulled straight out of the tests).
// What does C note consist of? var parts = music.getNoteParts("c"); equals(parts.root, "c"); equals(parts.accidental, null); // What does C# note consist of? var parts = music.getNoteParts("c#"); equals(parts.root, "c"); equals(parts.accidental, "#"); // What is a flat-5th above C? var value = music.getRelativeNoteValue(music.getNoteValue("c"), music.getIntervalValue("b5")); equals(value, music.getNoteValue("gb"); equals(value, music.getNoteValue("f#"); // What is the C quality of a Db? equals(music.getRelativeNoteName("c", music.getNoteValue("db")), "c#"); // What are the tones of a C major scale? var c_major = music.getScaleTones( music.getNoteValue("c"), Vex.Flow.Music.scales.major); // result: ["c", "d", "e", "f", "g", "a", "b"] // What is the interval between a C and a D? equals(music.getCanonicalIntervalName(music.getIntervalBetween( music.getNoteValue("c"), music.getNoteValue("d"))), "M2");
Smarter Accidentals |
Notice how the accidentals are correctly picked according to the rules of standard notation? Yep, so do I.
We also have lots more tests -- over 750 of them! Try running them on your browser and tell me how long it takes.
That's all folks!
Tests completed in 3834 milliseconds.
ReplyDelete754 tests of 754 passed, 0 failed.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16
My test results:
ReplyDelete------------
Google Chrome 12.0.712.0 dev
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.27 (KHTML, like Gecko) Chrome/12.0.712.0 Safari/534.27
Tests completed in 1866 milliseconds.
754 tests of 754 passed, 0 failed.
------------
Firefox 4.0
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0
Tests completed in 5200 milliseconds.
754 tests of 754 passed, 0 failed.
------------
IE 9
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; .NET4.0C; .NET4.0E; InfoPath.3)
Tests completed in 3388 milliseconds.
218 tests of 248 passed, 30 failed.
------------
Opera 11.01
Opera/9.80 (Windows NT 6.1; U; en) Presto/2.7.62 Version/11.01
Tests completed in 2000 milliseconds.
754 tests of 754 passed, 0 failed.
------------
Nice work on the theory API, especially for smarter accidentals. And the tests were fast:
ReplyDeleteTests completed in 2561 milliseconds.
754 tests of 754 passed, 0 failed.
(Firefox 4, Mac OS X 10.6)
1620 milliseconds
ReplyDeleteMozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16
Running Chrome with WAY too many tabs open.. at least 40+
It's really coming along! We should get together again. I've moved back to the city actually and am living out in Williamsburg.
Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.16 Safari/534.24
ReplyDeleteTests completed in 4093 milliseconds.
754 tests of 754 passed, 0 failed.
This is on an ancient 1.26 GHz P3 machine though.
As a musician and a software engineer, I am very impressed by this work to date. I believe that it could become an important development.
ReplyDeleteCongratulations and keep up the good work.
Awesome work! I'm starting to work on a digital music theory textbook with some interactive features. Can't wait to try some of this stuff!
ReplyDeleteNice. I have some of this set up in a few projects but nothing as complete as this. great example.
ReplyDeleteMozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1
ReplyDeleteTests completed in 1367 milliseconds.
754 tests of 754 passed, 0 failed.
Would like to say that your work is awesome!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
ReplyDeleteTests completed in 1377 milliseconds.
754 tests of 754 passed, 0 failed.
AWESOME lib. Can't wait to put it to use.
Running on 1.6 GHz MacBook Air
ReplyDeleteMozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Tests completed in 4335 milliseconds.
894 tests of 894 passed, 0 failed.
Do you plan any support for MusicXML as input?
ReplyDeleteThank you so much for your work. Love it !!
ReplyDeleteAll Tests on the same Machine (i5 - 2320@3GHz):
I had time differences up to 400ms when actualizing the page. But the results here represent a average overview. Safari seems to be the fastest. Opera the slowest.
*** FIREFOX:
Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0
Tests completed in 4118 milliseconds.
1565 tests of 1565 passed, 0 failed.
*** CHROME:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.91 Safari/537.11
Tests completed in 3383 milliseconds.
1565 tests of 1565 passed, 0 failed.
*** OPERA:
Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.11
Tests completed in 4509 milliseconds.
1565 tests of 1565 passed, 0 failed.
*** IE9:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
Tests completed in 4289 milliseconds.
1565 tests of 1565 passed, 0 failed.
*** SAFARI:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Tests completed in 2836 milliseconds.
1565 tests of 1565 passed, 0 failed.
Sandbox on website is broken - Error shown is : ReferenceError: Vex is not defined
ReplyDeleteTried to download and run locally uing vexflow-master.zip. same error.
What link are you using? (and what browser/OS)?
ReplyDeleteLink: http://www.vexflow.com/docs/sandbox.html
DeleteOS and Browsers: Linux using FireFox and Chrome, same problem in both. The rest of the site works fine.
I finally got my local version working by downloading vextab and copying some files across.
(Same environment as above.)
Is there somewhere better to post bugs like this? Is there a help forum?
It would be good if the sanbox had a clear button.
FYI, this is fixed.
DeleteThanks for the report. I opened issue: https://github.com/0xfe/vexflow/issues/92
ReplyDeleteBest place to report issues is at the GitHub repo: http://github.com/0xfe/vexflow
(Clear button is a good idea -- will add.)
In My Vexflow it would be nice to have a unpublished/published status so that work in progress is not seen by the public.
ReplyDelete