Prevent MIDI Encoder Reset When Switching Between DAW and EN16 Controller

Hello, I want to configure my MIDI controller EN16 in the Grid Editor software so that when I modify a virtual button in my DAW with the mouse, the physical encoder does not start from zero when I take control again.

I can clearly see the value being returned in the midi monitor

tmp

For example, in the screenshot, we can clearly see that when I change the value via my DAW to 4, as soon as I touch the encoder, it immediately returns to its last known value, which is “126” in this example.

I am aware that my English is not perfect and that my explanations might not be very clear. However, I hope you can still assist me.

Thank you!

1 Like

Did you configure the encoder to send relative +/- updates, i.e. mode 1 or 2?
You should also change the midi mapping in the DAW to accept this correctly.

Hello,

Yes I tried.
But it is not a valid option for me, because my DAW Flstudio is not compatible with these modes :frowning:

Does the DAW have a catch-up option? With that, the DAW will only update if the enc reached the actual value, eliminating jumps, but with a dead zone without change. If it doesn’t, you could probably code it in Grid. Store the received value, and in the encoder event compare the encoder value with the received value. Only when the enc value and received value are equal, +/- 1, start sending midi.
Edit: Or maybe simpler, set the enc in relative mode and in the enc event add the enc value to the stored received value and send that value in the midi. You need min/max check.

I recently made a midi script for fl that handles this. It emits tons of errors on Grid Editor, but it does the job. I will try to attach the script when I have time today.

Here’s the code I made that just started working after many frustrations given.
It monitors 16 CCs, starting from CCStart and up to ConsecutiveCCAmount CCs.

Basically you put this in a file named device_<name of your choice>.py and place it in your user setting folder: \Documents\Image-Line\FL Studio\Settings\Hardware\<different name or same name>\.

The Code
#name=Intech Grid EN16

from enum import IntFlag
from fl_classes import FlMidiMsg
import midi
import device

PortNumber = device.getPortNumber()
CCStart = 16
ConsecutiveCCAmount = 16

CCs = []
ControlIDs = []
EventIDs = []

for i in range(0, ConsecutiveCCAmount):
  CCs.append(CCStart + i)
  EventIDs.append(midi.REC_InvalidID)

def OnInit():
  for i in range(0, ConsecutiveCCAmount):
    ControlIDs.append(midi.EncodeRemoteControlID(PortNumber, 0, CCStart + i))

def OnRefresh(flags: IntFlag):
  # check if any linked control in FL is changed
  if flags & midi.HW_Dirty_RemoteLinkValues:
    # then starts cycling through all the registered ControlIDs (ControlID is made for each remote link)
    for i in range (0, ConsecutiveCCAmount):
      # and find EventID for that (looking for the address where the exact remote link change can be found)
      PossibleEventID = device.findEventID(ControlIDs[i])
      # if the new found address is different, update the list of EventIDs
      if PossibleEventID != EventIDs[i]:
        EventIDs[i] = PossibleEventID
      # using the EventIDs, get the value stored in each control in FL
      LinkedValue = device.getLinkedValue(EventIDs[i])
      # if the value is -1.0, the link doesn't exist yet
      if LinkedValue != -1.0:
        # the range of the value is from 0.0 to 1.0, so make it fit to MIDI data2 range that is 0 to 127
        ConvertedValue = int(device.getLinkedValue(EventIDs[i]) * 127)
        # send that converted value, along with corresponding CCs for the changes, to the device.
        device.midiOutMsg(midi.MIDI_CONTROLCHANGE, 0, CCs[i], ConvertedValue)

This code is nowhere near perfect, there could easily be a better way to achieve the task, and I don’t know common Python naming conventions, and when you adjust from your device after receiving changes from the DAW, the knobs on the screen might not move for a moment while the value changes from the device are being accepted.

Hope this works, or if not, that you still get an idea of how to approach this.

update: seemingly not every VST works with this…