Help to test the value of NoteStep.State // noteStep.state()

Post Reply New Topic
RELATED
PRODUCTS

Post

Hi.

I am trying to develop a script for the Launch Control XL, to use it as a Drum sequencer.

I am (ridiculously) stuck because of a test that didn't work.

I created a note observer with :

Code: Select all

cursorClip.addNoteStepObserver(NewNote);
And then, in the function "NewNote", I wrote :

Code: Select all

function NewNote(note) {
println("X: "+note.x()+" Y: "+note.y()+" State: "+note.state());

if (note.state() == 1 ) {  // if the note is on show "Catch"
	println("Catch");
} else {
	println("Not catch");
	}
}
In the console I get :
X: 0 Y: 36 State: NoteOn
As expected, but why (the hell) my "if" return always "Not catch" ?
I try all possible variant I know, like creating a variable like this :

Code: Select all

var noteState = {
	Empty: 0,
	NoteOn: 1,
	NoteSustain: 2,
};
and then do a test like this :

Code: Select all

if ( note.state() == noteState.NoteOn )
But I become the same result : "Not Catch".

It is written in the Bitwig "NoteStep.js" as reference :

Code: Select all

/**
 * @since API version 10
 */
com.bitwig.extension.controller.api.NoteStep.State = {
	Empty: 0,
	NoteOn: 1,
	NoteSustain: 2,
};
I probably do something wrong, but what ?

Post

I find a "dirty" workaround to test the value, it is getting a step that "must" be off :

Code: Select all

var noteOff = cursorClip.getStep(1,0,126);
"noteOff" then will return "Empty" as a noteStep object, and then I can do my test :

Code: Select all

if ( note.state() != noteOff.state() )
because I am "sure" that "noteOff.state()" will return "Empty".

It is "dirty" like I said... but it work. If someone know a cleaner way to do it, it can help.

Post Reply

Return to “Controller Scripting”