HISE icon indicating copy to clipboard operation
HISE copied to clipboard

NRPN

Open nicvlav opened this issue 2 years ago • 2 comments

My first attempt at implementating NRPN into HISE

INFO:

I am working on a project that primarily uses NRPNs to control anything I want the user to customize. I realized that I would need to use the OnControll scripting callback with a switch case of the CC number for numnbers 98,99,38, and 06. I felt like it would be too cluttered to do it in scripting so I tried my hand at introducing NRPN parsing to the source code of HISE.

The immediate red flag in this code would be changing the allignment of the HiseEvent calss to 32 as I added a few parameters and functions in that class whcih increased the class size. I think that creating a child HiseEvent class may solve the issue but I haven't gotten around to tried that. I can see how the change in allignment would be detrimental to the speed and memory usage of HISE. The new variables added to the class are parameterNumber and NRPNValue with their appropriate setters and getters. Again I realize this definitely messes with the compactness of the original allignment of the class but its what I have right now.

I looking at the JUCE modules and found a lot of their NRPN handling methods but I ended up just using a switch case in the MidiProcessorChain::renderNextHiseEventBuffer function in MidiProcessor.cpp. The NRPN messages stay in the buffer like normal until they are processed by the scripting processor, when they are only processed as a single event with a parameterNumber and NRPN Value. I also added a new scripting callback call onNRPNController.

I added a single method into JUCE's MidiMessage class to detect if a MidiMessage is an NRPN message (isNRPNController()) which is intented to be used with isController which would first determine if its a CC Controller message.

I am posting this here in hopes that someone can find a much more efficient way to parse NRPNs or helping to actually utilize the JUCE NRPN parsing methods. The event allignment change is the biggest issue in my opinion.


Scripting Callback handing of NRPN:

  1. NRPN Message is received by HISE
  2. If onNRPNController callback is not empty it executes onNRPNController callback script
  3. onNRPNController callback has access to: Message.getParameterNumber(), Message.getNRPNValue() along with all other methods onController has access to besides Message.getControllerNumber(), Message.getControllerValue()

nicvlav avatar Oct 26 '21 23:10 nicvlav

scripting callback with a switch case of the CC number for numnbers 98,99,38, and 06

What's the problem with this approach other than "clutter"?

davidhealey avatar Oct 27 '21 00:10 davidhealey

That is a fair question. I thought it may be faster to parse through midi in the source code as opposed to the scripting. Since midi consists of such small messages it probably doesn't impact performance drastically. Clutter was a strong secondary reason for me since the project used a fair amount of NRPN messages.

nicvlav avatar Feb 15 '22 22:02 nicvlav