Responsive abcjs

I have been experimenting with having abcjs be responsive. Here’s my first attempt: the sheet music will change size when the area for it changes:

Try changing the browser width and see how the image reacts.

Generating MIDI with abcjs

It’s been a while since I worked on the MIDI part of abcjs, and it shows! When Greg first developed it, he put in a widget that would use QuickTime. Pretty clever at the time. But that doesn’t work anywhere any more, so I removed it. I have some plans for generating MIDI right on the web page, but that will have to wait until the next version.

For this version I concentrated on making the MIDI generation better.

I refactored the generation to use three passes: 1) identify the parts of the abcjs object that affect sound and put them in chronological order, 2) Turn those conceptual events into specific events, 3) generate MIDI. That made it much easier to add features: all of the “artistic” stuff is in the second step.

The two main features I added were guitar chord generation and grace notes. Both of those required some artistic license.

I tried to find a rule of thumb for how long a grace note is, but there really isn’t one. It depends on the style of music whether the grace note is before the beat or on the beat. The length of a grace note is variable. It is unclear whether it should be a fraction of a beat or a fixed amount of time, independent of the tempo. I just picked something that seemed to work for me.

For guitar chords, in general I wanted to do a boom-chick pattern, but that depended on where the chords were specified in time. This can be vague and differs for different meters. So if boom-chick didn’t work, I played the full chord on the beat. If a chord appears between beats, I pulled it back to the previous beat. This seems to have worked passably for the sample tunes I tried. It’s just that the specification is not very exact, so there’s no way of telling for some of the border cases.

In any case, the result was surprisingly good on some tunes! There is room for improvement and there are many decorations, MIDI commands, and rhythm designations to support to keep me busy for the next version.

And, when it comes down to it, MIDI is never going to sound “good”. The purpose of MIDI is as a proof-reader of the music you create. It’s just hard to stop refining it once I get going.

Money Lost:

Sheet Music in WordPress!

I created a WordPress plugin called “ABC Notation” that makes it easy to put sheet music in your blog. It uses the abcjs JavaScript library developed by Greg Dyke and me. Here’s an example of how it works:

The above music was created with this shortcode:

[.abcjs engraver="{ staffwidth:550 }"]
X: 36
T:Money Lost
C:Paul Rosen
S:Copyright 2007, Paul Rosen
Ade|:"Dm"(f2d)e gf|"A7"e2^c4|"Gm"B>>^c BA BG|"A"A3Ade|"Dm"(f2d)e gf|
"A7"e2^c4|"Gm"A>>B "A7"AG FE|1"Dm"D3Ade:|2"Dm"D3DEF||:"Gm"(G2D)E FG|
"Dm"A2F4|"Gm"B>>c "A7"BA BG|"Dm"A3 DEF|"Gm"(G2D)EFG|"Dm"A2F4|
"A7;(Edim)"E>>Fx "(A7)"ED^C2|1"Dm"D3DEF:|2"Dm"D6||