OSC listener for Midi Events, filtering by Note Number, retrieving Velocity

Hi,

I need to create an script in order to translate velocities to certain values.
So I'm getting started with the advanced syntax, and as I'm not the King of Javascript, I have a question.
I'm able to retrieve the velocity of all the incoming MIDI Note Messages by

OSC{ /note }

That will output the velocity of the incoming message for any note value
But I wanted to narrow down this listening process to a certain Note , and knowing that the syntax is as follows.

OSC{address, default, usePreArgs}

and the incoming messages I get are of the form

(DEBUG, OSC) In: { address: `/note/', args: [ 1 , 2 , 4 ] } From: midi:somedevice

I want to be able to filter by the note number so the Second value in the array of args , in the previous example was 2 , but it can be any value . And return the third value of the array of args.

Any suggestions on how to do this?

Thank you!

Ok, I've just understood it . As per documentation

usePreArgs (optional): by default, osc listeners inherit the widget's preArgs (these must be matched for the osc messages to be processed). Set to false bypass them.

Meaning by default is already listening to my veloity events if the Preargs of the widget are setted as

        "preArgs": [
          Midichannel,
          NoteNumber
        ],

The default value will be the value to start with before any listening event take place (or any MIDI In event in my case)

So lets keep on rocking!!

1 Like