v0.5.28 with JS component for processing Midi

Discussions related to Testing VisualSwift
Post Reply
Site Admin
Posts: 39
Joined: Sat Nov 30, 2019 2:17 pm

v0.5.28 with JS component for processing Midi

Post by jorge » Sat Aug 22, 2020 4:15 pm

TestFlight v0.5.28 for iPadOS

v0.5.28 for MacOS



The example schematic shown above processes Midi events generating Major or Minor chords depending on the chosen entry in a custom StringSelector component.

The new JS component has a schematic inside that can be used for editing the inputs/outputs and types. The actual events that arrive at the JS component's inputs don't flow inside as in other components but are processed by event handlers inside the javascript code.

At the moment there are two event handlers supported: midiIn and stringIn.

The input parameters passed to the midiIn handler are:

1) i: an int representing the index of the input where this event arrived
2) time: a double representing the sample precise timestamp of the event
3) cmd: the Midi Command
4) note: the Midi Note
5) vel: the Midi Velocity

"self" represents the JS component where this snippet of javascript lives.

Inside the javascript code you have access to the outputs of the JS component, for example to create a variable with a reference to the first output of the component you could run "let output = self.outputs[0];"

Once you have a reference to an output you can send events out, for example to send the received Midi event out you'd run "self.outputs[0].midiOut(time,cmd,note,vel);" inside the midiIn handler.

In this example, notes are sent out according to a selected type of chord and time is added to the second and third notes to create an arpeggio effect.

You also have a stringIn handler for processing a string event. The stringIn handler also has a time parameter ( all events in VisualSwift are timestamped ) and also an "s" parameter which contains the payload of the event ( note that the parameters can have any name, it's only the order that is important ).

In this example the string event comes from a StringSelector that has 3 options: bypass, major and minor.

The StringSelector component is fully customizable:

Here's the full JavaScript code used, it should be understandable now:

Note that there is an init handler for initializing variables.
Note also that inside the string event handler a note is sent as an audiable feedback when the chord type is changed just before updating the current type of chord stored inside the JavaScript code.

Post Reply