Javascript SDK

Download the Javascript SDK

The gTar Javascript SDK is in a relatively early state and is still dependent on 3rd party plug ins to allow for Web MIDI since the Web MIDI spec has not been adopted publicly by mainstream browsers. The gTar Javascript SDK is however built around the upcoming Web MIDI specification through the use of Chris Wilson's polyfill:

The polyfill is dependent on a the Jazz-Soft 3rd party plug in at the moment which is also linked on Chris'es github page for the polyfill. This page will continue to be kept up to date as Web MIDI continues to develop as a standard and achieve cross platform adoption. Get involved here!

You can download the 0.1 initial version of the gTar Javascript SDK here: gtar_0_1.js

Getting Started with gTar.js

Getting gTar.js going is quick and straight forward. First of all, make sure that you have the Jazz-Soft 3rd party plug in installed and are including Chris Wilson's Polyfill code since the gTar is built on top of the upcoming Web MIDI specification.

Be sure to include gtar_0_1.js in your code and you're good to go! Setting up the connection to the gTar is as simple as the following snippet of code:

 var gtar = gtarConnect(); 

Now you're ready to send messages to the gTar. This can be done as show in the next litle bit of code.

                                var gtar = gtarConnect(); 
                                gtar.setLEDEx(string, fret, red, green, blue, reserved);

Note that the reserved value must always be zero, as it might be used in the future for different LED lighting modes. The red, green, and blue values can each be values between [0, 3], and will be clamped down if larger. The string and can be between [0, 6] where sending the 0 string will light up the entire respective fret provided, and the fret value can be any value between [0, 16]. Similarily if the fret value sent is 0 the entire respective string will be lit up. If both fret and string are set to zero, this will light up the entire fretboard.

To recieve incoming messages from the gTar a subscriber / notifier design is used. To subscribe to notifications from the gTar the following bit of code can be used along with the corresponding callback:

                                var gtarSubscriberId = gtar.AddSubscriber(GtarAppCallback);
                                function GtarTestAppGtarCallback(msgType, channel, data1, data2) {
                                        // Do stuff

The above callback is a thin layer above the raw MIDI data coming in from the hardware. Over time the SDK and guide will be improved to make a more direct connections between user action and SDK output. In the meanwhile, the incoming data is MIDI compatible and NoteOn / NoteOff messages can be used exactly as would be done with a Midi Keyboard or other controller. There are fret-down/up messages being sent on the control channels, but these will be wrapped in the SDK soon.