I am having problems with NRPN messages being sent to fast to a synth. I need to slow this process down so I was hoping to put a 2ms pause between each line of code. @Balint suggested to accomplish thos “the basics of it would be a timer start on the triggering event that puts the value of the triggering element in a FIFO buffer that has it’s own retrigger until empty.” I have no idea where to start with this. The synth is expecting 6 seperate lines of code(4 xCC’s and 2 resets). I have figured out the messages that need to be sent but I can’t figure how to pause in between lines for a brief period of time. Any help would be appreciated
.
hi!
This is something I came up with. This is an iteration over the defined nrpn_cc_arr
with the help of timer event re-triggers.
Setup Event:
-- Iterator variable used by the Timer event, needs to be initialised
self.c = 0
Button Event:
-- Start the timer on button press
if self:button_state() > 0 then
timer_start(self:element_index(), 1)
end
Timer Event:
-- I have added your MIDI values to an array from the discord, only the param1 and param2 parts
nrpn_cc_arr = {{99, 1}, {98, 108}, {6, 0}, {38, 0}, {101, 127}, {100, 127}}
-- Increment variable every time timer get's hit
self.c = self.c + 1
-- Your channel for the MIDI messages, could be typed directly in midi_send() as well.
local ch = 0
-- This is a trick to use less characters, we reassign a value to a new local variable
local _ = nrpn_cc_arr[self.c]
-- Send the MIDI data when this timer runs
midi_send(ch, 176, _[1], _[2])
-- Restart this very same timer with 100 frame delay, make it higher or less depending on your requirement
timer_start(self:element_index(), 100)
-- The array nrpn_cc_arr has 6 elements. Once we are ready iterating over it to send out the full delayed MIDI message, reset the self.c variable to 0 and stop the timer
if self.c == 6 then
self.c = 0
timer_stop(self:element_index())
end
Kristof,
thank you so much for the reply! Currently, I have this set up on an encoder that switches between 3 NRPN values. when I press the encoder it switches between serperate values. The idea of this encoder is to select global tempo values and then when pressed, the values become triplet versions of the times.
Anyhow would this be easily adaptable to be used on an encoder? Currently it seems to be set up as a button press to cycle through,
Thanks
-Ben
I have couple questions, so I can understand better what to do .
So you have 3 states, 3*6 midi messages, similar to the messages I put in the nrpn_cc_arr? You change between the 3 states with the rotation of the encoder and on the encoder button press you send them out?
My primary question is whether you want to trigger sending the data on button press or on encoder rotation. If the encoder rotation is only for data selection, I think I can easily alter this code snippet for you.
If you could let me know the specific param1, param2 values to send out (those triplets you write?), that might be helpful too.
Definitely encoder rotation. The button press is not that important as I have figured that part out. Basicallly I had the encoder set up to spit out values 1,3,6(normal tempos)Then the button was set up for toggle. With a press, the encoder could select values 2,5,7(triplets). This is all on NRPN 236
To keep everything simple, here is another NRPN that I send. Encoder max is set to 2. Val selects values 0,1,2.
midi_send(ch, 176, 99, 1)
midi_send(ch, 176, 98, 109)
midi_send(ch, 176, 6, 0)
midi_send(ch, 176, 38, val)
midi_send(ch, 176, 101, 127)
midi_send(ch, 176, 100, 127)