Hello,
I have my PBF4 set up with short press / long press buttons. So for example for button 4 the CC for the short press is 15 and for the long press is 16. Sending MIDI out that way works flawlessly. However, the Processing sketch I am using the controller with will have some of the values associated with the buttons on by default. In order to have this mirrored on the controller, I want to send those values to the controller on startup of the Processing sketch. So I send a MIDI message “127” to the corresponding CCs. It works fine for CC15, but not for CC16. I am assuming this is because of the short press / long press logic I set up. I have it from here and was already discussing this here but thought it would make sense to create a new topic.
Is there some kind of Midi rx script I can use to properly receive these values?
Hi this is because the states are represented in self. variables on each element. So for example button 0 would be cc 15 on press and cc 47 on longpress. It’s not enough to just set the state of the button with an rx message, you would have to modify the correct self. variable (there are two self.p and self.lp for press/longpress) as well.
Could you tell me how to do that? I think that also explains why I was seeing the button light up, but sometimes had to press it twice to turn it off again. I still had a midi rx script that was resetting all the actual values:
How could I change this script to assign them correctly?
if i ~= nil then
led_value(i, 1, param2)
led_color(i, 1, led_default_red(), led_default_green(), led_default_blue())
element[i].p = 0
element[i].lp = 0
end
The problem is my Processing sketch only knows the cc numbers. It doesn’t know about elements, or that there are two cc per element. I essentially need a script that gets an incoming midi message and sets that value to the corresponding CC, not the element or its p or lp.
Yeah, you would have to properly match CCs to LP and P values.
You could do that algorithmically though…
Let’s say that Press CC equals self:element_index()
and Long Press CC equals self:element_index()+32
. In this case you can just reverse that on the MIDIRX event and address the LEDs like that.
Can you please elaborate a bit or provide an example?
Edit:
I think I managed to do it like this. I need a local variables action block, couldn’t just do it in code.
if param1 >= 8 and param1 < 12 then
element[param1].p = param2
led_value(param1, 1, param2)
else
element[param1 - 4].lp = param2
if param2 > 0 then
led_color(param1 - 4, 1, 0, led_default_green(), 0, 0)
else
led_color(param1 - 4, 1, led_default_red(), led_default_green(), led_default_blue())
end
end
Elements 8 - 11 are CC 8 - 11 and CC 12 - 15 for long press CC.