Populating a MidiPlayer with event data received over OSC
-
I'm new to HISE, and seeking some tips for getting this particular bit of functionality working:
Receiving an array of event data over OSC, for use in populating a MidiPlayer with note and cc messages, and sending the events out of the MIDI out when used as a MIDI FX plugin in Logic.
I have the OSC receive part working, using the GlobalRoutingManager within an onInit callback of the Interface.
Where or how might one populate a MidiPlayer with events? I haven't found any code examples of this yet.
And also, how might one pass the OSC data received in that Interface callback, over to where it can be used to populate the MidiPlayer?
Best,
Thom -
@phatamoto you 'll need to show us how far you got - so a snippet.
-
I haven't yet gotten anywhere beyond receiving the data over OSC.
I'm unclear on where one needs to populate the MidiPlayer, does it need to happen with a callback locally-specific to the MidiPlayer, or can the MidiPlayer be accessed from with the same Interface onInit callback where the OSC is being received?I've been through some of the documentation and several videos, but still a bit unclear as to how to approach this.
My hope is to get this first bit working as a jumpstart into HISE, something immediately useful to my external music-making workflow, then progressively add features as I learn more and more about HISE and the range of possibilities it offers.
Here's the OSC-receive code. It can receive arrays or single values, and for now just prints the value(s):
const var rm = Engine.getGlobalRoutingManager(); inline function print(value) { Console.print(value); } inline function printOSC(id, value) { // if received token is an array (if it has a defined length) if (typeof value.length == "number") { for (i = 0; i < value.length; i++) { Console.print(value[i]); } } else { Console.print(value); } } inline function processOSC_phraseA(id, value) { print("phraseA: "); printOSC(id, value); } inline function printError(msg) { Console.print(msg); } rm.connectToOSC({"Domain": "/HISE", "SourcePort": 6400}, printError); rm.addOSCCallback("/phraseA", processOSC_phraseA);
-
@phatamoto - so yes you can reference a MIDIPlayer basically anywhere in your code.
Look at the MIDI Player API here;
https://docs.hise.audio/scripting/scripting-api/midiplayer/index.html
Once you have collected your "note data" then you just need to add a sequence to the MIDIPlayer, this will give you a good set of pointers on how to do this:
https://docs.hise.audio/tutorials/recipes/event-processing/create-midi-sequence.html
-
Thank you, this is very helpful!