Monday, June 21, 2010

On Parsing and Licenses

So I spent this weekend rewriting the VexTab parser. The original version, though it served its purpose as a quick prototype for the language, was severely limited due to it being built primarily out of regular expressions.

The new parser uses a recursive-descent algorithm, and fully supports the original grammar. Adding new syntactic elements to the language is now simple, as is adding support for more complex grammars.

Some new features I added to the language are support for slides, hammer-ons, pull-offs, and tapping. Here's a blues lick written in VexTab:

Blues Lick in VexTab

Some readers have asked me about durations and how to specify rhythms in VexTab. Although the VexFlow core has full support for durations and timing, I still need a good way to represent them in the language. I'm open to ideas here if you have any.

Enter TabDiv

I also spent this weekend working on the release of the first VexFlow-based product: TabDiv. TabDiv lets you easily embed guitar tablature into your website or blog.

After you've included the TabDiv .js and .css files in your HTML document (or blog template), you can add tabs by simply creating DIV elements and setting the class to vex-tabdiv.

You can get TabDiv here: http://vexflow.com/tabdiv/index.html.

Why not Open-Source?

I'm no stranger to open-source. I've been writing, maintaining, and contributing to open-source software for over a decade.

Although I hope to eventually open-source all the VexFlow source code, I'm going to hold off on it until I figure out where I want to take this product. I've invested a lot of time and effort into making VexFlow a fast high-quality renderer, and I'd like to find a way to cater to both a commercial-audience, and the open-source community.

So, how does one find and maintain this delicate balance? Do I completely open-source it? Should I keep it closed and charge for it? Dual-license maybe?

16 comments:

  1. Awesome!!!

    > So, how does one find and maintain this delicate balance? Do I completely open-source it? Should I keep it closed and charge for it? Dual-license maybe?

    Well... we have an iPhone app that relies on an encrypted datastore. The encryption engine we built out to support our product is called SQLCipher, and we were comfortable open-sourcing that. There we had a clearly defined piece of code we could give back to the open community that would do well to be under peer-review and open to forking. Open-sourcing the engine doesn't necessarily give away our product - making a good application is another story altogether!

    So, I guess it all depends on what you envision your product(s) being.

    FWIW, I think this is really cool; I would love the ability to write blocks of text to draw beautiful staves (and tabs). I still draw music myself sometimes, and I'm loathe to then scan it in or to use something like Finale in the first place. I very much like the idea of a an open text format for this.

    (I'd avoid dual-licensing, the mysql ab licensing always looked kinda whack to us ;-)

    ReplyDelete
  2. Nice nice. I'm missing the Standard Notation which you rendered in the very early releases of "JsNotation". What happened to this staff?

    I'm also proud to present my new nightly build: http://dev.coderline.net/jsgs/
    It now supports midi playback via a hidden Java Applet and displayes the current played measure.

    ReplyDelete
  3. @Billy Thanks for the thoughtful reply. I'll ruminate over this a bit more.

    @Danielku15 The standard notation is still there - I just haven't thought of an elegant way to represent rhythms and timing in the VexTab language.

    ReplyDelete
  4. I'm with @Danielku1: what happened to the Standard notation support? It was really beautiful. Is it still in there?

    On the open source piece, I think that you could open source the main renderer but keep the VexTab parser to yourself. I don't think that this would hinder your ability to sell a "packaged" solution to users without the coding experience necessary to use the more full fledged JavaScript API. This has been done by countless open source projects in order to make a little money, and I think it would be a nice fit for this project as well.

    This is an amazing piece of technology and it could really revolutionize the viewing of sheet music on the web which has up until now been entirely plugin based. An open source solution will allow other people to build on this great work and build even cooler things. That is my vote.

    Again, great work!
    Devon

    ReplyDelete
  5. @Mohit: What do you think about a format like this: Fret/String/Duration, for duration values simply use the numeric representation: 1(Full), 2(Half), 4(Fourth), 8(Eighth),... If this syntax is reserved you could use a pipe Fre/String|Duration

    ReplyDelete
  6. Here a small sample how the definitions could look like.
    # EADGBE
    tuning 40 45 50 55 59 64
    # 3/4
    timesignature 3 4
    # D-minor
    keysignature Dm

    notestave
    tabstave
    notes 5/1/4 3/1/4/ 3/1/4 | (5/1.3/1.3/1)/4

    ReplyDelete
  7. @Danielku15

    Using a single integer for a duration does not work for triplets (or n-tuplets). Ideally we'd use some kind of a rational: e.g.,

    notes 5/2|1/8 6/2|3/8

    ... but that makes it hard to read. Alternatively, I can set the duration separately, and use simple letters for the durations (below q is quarter, and w is whole):

    notes q 5-6-7/5 w 7/4

    or, keep them with the notes:

    notes 5-6-7/5q 7/4w

    Triplets could be tq, tw, th, etc. where the second character is the duration that is being divided. Custom rationals might be specified as rN/D, e.g.

    notes r8/3 5-6-7/5

    Anyhow, thanks for your input. I'll play around with the various options and see if I can come up with something reasonable.

    ReplyDelete
  8. I'd really hope to see an open source version at some point. The problem I see with dual licensed open source projects is with third party modifications. Basically you cannot reintegrate the changes of third party developers into your main version unless they are willing to license them to you for your proprietary version. Which I think can create tension. I hope you'll find a way.

    Jonas

    ReplyDelete
  9. I'm too wondering about the inclusion of the standard notation.

    Is the javascript API now public so that we may write file interpreters and bypass vexflow?

    ReplyDelete
  10. For guitar tab, it's helpful to be able to write lyrics under specific chords or notes. Is there a way to line up lyrics with music?

    Also, thanks again for all your efforts and enthusiasm.

    ReplyDelete
  11. +1 to Blair's comment

    ReplyDelete
  12. @Tails, the API is not yet public... it still needs some work on the interfaces. I'm almost done finishing a builder-pattern interface and will test it with VexTab. When that works out well, I'll push out the API.

    @Blair, Lining up lyrics/chords/rhythm slashes, etc. with the music is dependent on timing/duration support in VexTab. I almost have something working here, and once you can express rhythms for the tab, it'll be easy to have lyrics, etc. line up.

    ReplyDelete
  13. Thanks Mohit. You rock... and you help us all rock.

    ReplyDelete
  14. Oooh, I'm writing some tabs and I have another request... repeats, codas, 1st, 2nd endings..., section notation (verse, chorus, solo...). Some of these are probably fixed with the timing work you're doing.

    ReplyDelete
  15. This is great work - keep it up!

    I'm penning my own rendering library as well, geared strictly toward rhythm. Some thoughts I had on the tuplet problem is to encapsulate it into it's own unit, with an overall duration - e.g. an 8th note triplet in 4/4 has a duration of a quarter note (and so does a tuplet of 5 16ths); a quarter note triplet has an overall duration of two quarters.

    In this scheme every tuplet has: an overall duration, a note type (8th, 16th, etc.), and a note count. Theoretically, you could just specify the overall duration and note count, and then calculate the note type - but that's academic.

    This scheme allows for recursive tuplets, as well - e.g. a quarter note triplet, where the first quarter note is an 8th note triplet.

    I'm not sure how you would notate this into your language, but I've been thinking about tuplets for a while, and I think the structure above is pretty flexible.

    Cheers,
    Steve

    ReplyDelete
  16. I'm not a lawyer so please correct me if I'm wrong. but this is as far as I understand:

    There are a few projects that put their source-code under an open and commercial license:

    See for example extjs/Sencha. They put their code under GPL so it can be used in other open-source projects, while if you want to use it a closed-source project they offer commercial sub-licenses.

    The advantage/issue with GPL is that the license has to stay GPL. So contributors will have to sign a CLA (contributor license agreement) that grants all rights to extjs.

    Other similar projects are jwplayer and flowplayer (both GPL). They show their logo for 1-2 seconds in the free GPL version, you'd be surprised how many of my clients (I'm a web-developer) pay the 100$ to get rid of the logo.

    Afaik GPL code can't be included in iphone due to Apple restrictions so if somebody wants to build an APP for the iphone he'll need a commercial version.

    Other companies have a different business model offering commercial support and opensourcing everything under MIT, BSD or apache license (apache, titaniumapp and afaik former sun microsystems / java) This license doesn't need CLA, (again I'm no lawyer).

    Personally I like the idea of sponsoring new features / donation for features (maybe on kickstarter).

    Other web applications open their source code provide free account with some limitations and offer a pro-account with more features (i.e. more disc space or analytics, see http://soundcloud.com or http://github.com) I think this is an add-free and very honest way.

    Talking about the JsNotation, I guess you could open the source code for other open projects and build on top of that a proprietary plugin that is easy embeddable in a website.

    I am currently writing an open music app and haven't decided yet which to use, GPL or MIT. At a later point I am planing to integrate a Notation score. I'd love to see JsNotation under either GPL or MIT. Alternatively I am thinking of abcjs, which is GPL.

    ReplyDelete