Controller API Java Parser :: Ala Trappar inspired

Official support for: bitwig.com
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

In my little bit of spare time I got to thinking about this controller API. I use WebStorm for refactoring and code completetion etc, and thought I don't think I could really maintain a bunch of projects without it.

Then I thought about Trappar's great repo he created for creating stubs for library loading in JavaScript IDE. I then thought about the ridiculous amount of time he would need to keep up to date on that API as things are added in the future, doing diffs of javadoc and then actually adding, plus maybe updating descriptions as Bitwig adds more info would just get out of control, so this project is for you Trappar.

I have quite a bit of experience writting compilers and cross compilers, so basically I wrote a Java application that;

- Reads the HTML javadocs of the current release
- Parses all the interface files within the iface package, creates a intermediary model with interface/function signatures and doc comments. (using jsoup HTML parser and DOM).
- From this model it emits actuall Java source code for each interface basically creating .java source files
- Then I use a nother parse to actually parse real java into AST.
- Once we have the AST for everything, comments and all it then uses a visitor pattern to emit the javascript stub files in the api directory.

Here is the output of the NoteInput parse

Code: Select all


function NoteInput() {}

/**
 * Assign polyphonic aftertouch to a specific note expression. By using multiple midi channels multi-dimensional control is possible. When set, the key translation table is also used for polyphonic aftertouch.
 *
 * @param {int} channel - MIDI channel to map [0 .. 15]
 * @param {NoteInput.NoteExpression} expression - the note-expression to map to channel
 * @param {int} pitchRange - range of the pitch mapping in semitones. Ignored for non-pitch expressions. [1..24]
 * @throws com.bitwig.base.control_surface.ControlSurfaceException
 */
NoteInput.prototype.assignPolyphonicAftertouchToExpression = function(channel, expression, pitchRange) {};

/**
 * Send MIDI data directly to the note input. This will bypass both the event filter and translation tables. The MIDI channel of the message will be ignored.
 *
 * @param {int} status -
 * @param {int} data0 -
 * @param {int} data1 -
 * @throws com.bitwig.base.control_surface.ControlSurfaceException
 */
NoteInput.prototype.sendRawMidiEvent = function(status, data0, data1) {};

/**
 * Specify a translation table which defines for each key which key (0-127) should be sent from the NoteInput. This is used for Note-On/Off and polyphonic aftertouch events. Specifying -1 for a key means it will send no event. Useful for providing transposition or scale features through the controller scripts. By default an identity transform table is set.
 *
 * @param {Object[]} table - an array which should be 128 values in length.
 * @throws com.bitwig.base.control_surface.ControlSurfaceException
 */
NoteInput.prototype.setKeyTranslationTable = function(table) {};

/**
 * When true (default) the events defined for this note-input will be consumed but the input and will not be sent to the MIDI callback of the port. Set this to false if you want to use the events defined by the mask both for the NoteInput and your callback function, or if you want to change the behaviour dynamically. This setting is true by default.
 *
 * @throws com.bitwig.base.control_surface.ControlSurfaceException
 */
NoteInput.prototype.setShouldConsumeEvents = function(shouldConsumeEvents) {};

/**
 * Specify a translation table which defines for each input velocity which velocity should be sent from the NoteInput. This is used for Note-On events. Useful for providing velocity curves or fixed velocity mappings. By default an identity transform table is set.
 *
 * @param {Object[]} table - an array which should be 128 values in length.
 * @throws com.bitwig.base.control_surface.ControlSurfaceException
 */
NoteInput.prototype.setVelocityTranslationTable = function(table) {};


As you can see, I just saved Tappar the trouble of adding the new Bitwig 1.0.11 NoteInput.prototype.sendRawMidiEvent() function. :)

I just have the little bit of inheritance to do and its basically ready to start creating these stub files for controller API developers.

@Trappar if you read this, do you want me to use my fork and send pull requests of the new api? Or just create a repo in my github account?

I am going to have a separate repo for the actual Java parser code.

Let me know.

Edited: spelled his name wrong. :) ... Trappar not Tappar haha

Mike
Michael Schmalle
http://www.teotigraphix.com
Surfing on sine waves

Maschine4Bitwig - Studio, MK2, MikroMK2, MK1
http://www.teotigraphix.com/bitwig/maschine

Post

Good stuff - yeah, I also wondered if that could be automated and become maybe part of the API itself?

Thanks!

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Good stuff - yeah, I also wondered if that could be automated and become maybe part of the API itself?
Are you talking about Bitwig doing it? If so, of course, they have the source code! I have just become extremely good at writing language translators. :) My last one was a full ActionScript to JavaScript cross compiler.

I know one thing, I never depend on things I don't have control over. I know that we get javadocs from Bitwig and that I created a program that is only dependent on the javadocs. SO it adds no more work to Bitwig right now other then getting them document more of the API in the docs. :)

So if they did end up writing a simple code generator from their source code java interfaces, it would mean my 2 days of making this was wasted. hehe

Mike
Michael Schmalle
http://www.teotigraphix.com
Surfing on sine waves

Maschine4Bitwig - Studio, MK2, MikroMK2, MK1
http://www.teotigraphix.com/bitwig/maschine

Post

hehehe - yeah, I know what you mean - work from what you have control over ;-)

I was merely thinking aloud - in the long run it would make sense to have it part of the API, in the short run there are more pressing things if we can manage.

But I'll keep it in mind ;-)

Cheers,

Tom

(I dream of better docs too... ;-) )
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

BTW, If Bitwig was interested I could donate the Java parser/renderer code to them that just parsed the interface stubs I know they have in their code base. :)

Also, one other thing to chew on. Its out in left field BUT, if Bitwig put those interfaces in a github account, the community could fork them and make pull requests with docs, obviously Bitwig wouldn't accept changes in the java API.

Having that available could allow all the docs to get written and then I have easy access to the source for it to be generated. We could also see API changes when Bitwig would push the the repo.

Just a weird thought. (I think you can see my distaste for Public API that is not documented) ;-)

Mike
Michael Schmalle
http://www.teotigraphix.com
Surfing on sine waves

Maschine4Bitwig - Studio, MK2, MikroMK2, MK1
http://www.teotigraphix.com/bitwig/maschine

Post

If you want to do pull requests that would definitely save me some time. Until Bitwig gets around to releasing method stubs along with their other scripting resources some manual work will have to be done though to keep up with updates. If you would like I would be happy to just give you permissions to make updates on my repo and you can update to your heart's content :)

Post

TeotiGraphix wrote:BTW, If Bitwig was interested I could donate the Java parser/renderer code to them that just parsed the interface stubs I know they have in their code base. :)

Also, one other thing to chew on. Its out in left field BUT, if Bitwig put those interfaces in a github account, the community could fork them and make pull requests with docs, obviously Bitwig wouldn't accept changes in the java API.

Having that available could allow all the docs to get written and then I have easy access to the source for it to be generated. We could also see API changes when Bitwig would push the the repo.

Just a weird thought. (I think you can see my distaste for Public API that is not documented) ;-)

Mike
Hey Mike, I created a ticket for this and linked here. IMO it is a great idea, and I too dream of better docs... I share that distaste :tu:

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post Reply

Return to “Bitwig”