midiout sending data too fast?
Posted: 21 Apr 2012 02:40
I've set up a container with knobs and sliders to control dynamics parameters on my DM1000. They send the sysex data nicely, and control the various console parameters smoothly. If I operate the controls on the console, my knobs and whatnot move on screen to reflect the updated values. So now, I'd like to be able to select the channel I want to edit and have the controls update to the current console settings. Seems simple enough. Send a sysex request for the data (the Yamaha protocol doesn't have a request all sub-parameters for compression that's documented, so I've set up a loop to run 7 times stepping through an array of the parameter values.)
The above code is called from the channel select switches, immediately after sys_channel is set based on firstof(x) being the selected channel. The remainder are globally defined variables specific to the console to generate a complete sysex string, which works great - except...
Problem: I have to press the channel select several times to get all the variables to populate. I suspect that either the data is being sent to the console faster than it can handle, or the responses are coming in faster than Lemur can handle, though I don't know how to sort out which, and frankly don't care. I've searched high and low for something the equivalent of "wait 20;", "sleep 20;", or something simple that would let me just make the dang loop pause for 20 milliseconds or something before running the next iteration to give the whole thing time to send and receive the data.
Attempted solution 1: I looked at several templates in the user library, and tried variations on the "if (time - prevtime < 20)..." syntax, but can't find one that works for a basic loop. Continue on non-match increments the count, which skips a variable. Return skips all but the first iteration. I don't think I want an onFrame script, since I only want it to send the data when I select a new channel. I've been using a Manual script, since that makes the most sense to me. Do this function only when called by the channel select strip.
Attempted solution 2: I added an additional "for(t=0; t<500; t++) {}" before the end of the first loop, and tried a variety of values for the t<500 section. At t<500, it works most of the time, but not always. I still have to press the button 3 times to make absolutely certain.
Attempted solution 3: I tried to integrate the sending and processing into one script so that it would send the threshold request, set the value; send the attack request, set the value; etc... this turned into a horrible mess of code that I gave up on, but if that's the best way to go, I'll revisit it.
Any guidance graciously appreciated. I haven't done any coding since that introductory course in high school, and the rust is taking quite awhile to shake off. The absence of such seemingly simple commands as wait or sleep only adds to the consternation despite my excitement at the opportunities Lemur seems to offer!
Thanks in advance,
CS
Code: Select all
decl i;
for(i=0; i<7; i++) {
midiout(0,{sysexSOX,sysexhdr_req,dynamics.sys_comp_hdr,dynamics.sys_comp_params[i],sys_channel,sysexEOF});
}
Problem: I have to press the channel select several times to get all the variables to populate. I suspect that either the data is being sent to the console faster than it can handle, or the responses are coming in faster than Lemur can handle, though I don't know how to sort out which, and frankly don't care. I've searched high and low for something the equivalent of "wait 20;", "sleep 20;", or something simple that would let me just make the dang loop pause for 20 milliseconds or something before running the next iteration to give the whole thing time to send and receive the data.
Attempted solution 1: I looked at several templates in the user library, and tried variations on the "if (time - prevtime < 20)..." syntax, but can't find one that works for a basic loop. Continue on non-match increments the count, which skips a variable. Return skips all but the first iteration. I don't think I want an onFrame script, since I only want it to send the data when I select a new channel. I've been using a Manual script, since that makes the most sense to me. Do this function only when called by the channel select strip.
Attempted solution 2: I added an additional "for(t=0; t<500; t++) {}" before the end of the first loop, and tried a variety of values for the t<500 section. At t<500, it works most of the time, but not always. I still have to press the button 3 times to make absolutely certain.
Attempted solution 3: I tried to integrate the sending and processing into one script so that it would send the threshold request, set the value; send the attack request, set the value; etc... this turned into a horrible mess of code that I gave up on, but if that's the best way to go, I'll revisit it.
Any guidance graciously appreciated. I haven't done any coding since that introductory course in high school, and the rust is taking quite awhile to shake off. The absence of such seemingly simple commands as wait or sleep only adds to the consternation despite my excitement at the opportunities Lemur seems to offer!
Thanks in advance,
CS