Multimode Pad Array?
Multimode Pad Array?
So . . . there's this little gem here by AB, the three-state-button:
https://forum.liine.net/viewtopic.php?f ... 263&p=5197
. . . and I was wondering how to code this up as an array?
i.e. A row of (say) four pads, where each pad steps through its own mde / state changes without affecting the other pads in the array.
I thought this would be simple, but I cannot brain!
https://forum.liine.net/viewtopic.php?f ... 263&p=5197
. . . and I was wondering how to code this up as an array?
i.e. A row of (say) four pads, where each pad steps through its own mde / state changes without affecting the other pads in the array.
I thought this would be simple, but I cannot brain!
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Multimode Pad Array?
conceptually - a 2 dimensional array -- 4x3
I'd start by changing the count() script from id += 1 to id[firstof(x)] += 1
inside process(), I'd continue the change to id with id[firstof(x)] %= MAX; and stateColors[id] becomes stateColors[id[firstof(x)]], etc for the rest
I'd most likely assign id[firstof(x)] to a local variable, just to save typing.
(this is off the top of my head looking at the raw jzlib - no Lemur editor in sight here to test it)
Note that this would be a "I'm using it and know not to press 2 buttons at once" thing. If you're releasing it to someone else, you just might want to play it safe and decl i; and do a for (i=0; i < 4; i++) { } loop around all uses of id instead of using firstof(x). This approach would brute force the updates across all 4 pads even if a user pressed all 4 at once.
I'd start by changing the count() script from id += 1 to id[firstof(x)] += 1
inside process(), I'd continue the change to id with id[firstof(x)] %= MAX; and stateColors[id] becomes stateColors[id[firstof(x)]], etc for the rest
I'd most likely assign id[firstof(x)] to a local variable, just to save typing.
(this is off the top of my head looking at the raw jzlib - no Lemur editor in sight here to test it)
Note that this would be a "I'm using it and know not to press 2 buttons at once" thing. If you're releasing it to someone else, you just might want to play it safe and decl i; and do a for (i=0; i < 4; i++) { } loop around all uses of id instead of using firstof(x). This approach would brute force the updates across all 4 pads even if a user pressed all 4 at once.
Re: Multimode Pad Array?
Thanks fella.
Yeah, I'll need it to be robust enough to accept simultaneous input from the pads so a looping structure was always gonna be needed, and I figured it would boil down to firstof(x) etc - it's just I was using a completely different example template / jzlib to work from when dealing with the pads array that involved use of nonnull . . . and it totally threw me.
I'll give this a shot, see if my brain has returned from its temporary sabbatical in dev null!
Yeah, I'll need it to be robust enough to accept simultaneous input from the pads so a looping structure was always gonna be needed, and I figured it would boil down to firstof(x) etc - it's just I was using a completely different example template / jzlib to work from when dealing with the pads array that involved use of nonnull . . . and it totally threw me.
I'll give this a shot, see if my brain has returned from its temporary sabbatical in dev null!
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Multimode Pad Array?
To handle multiple pad presses, firstof(x) isn't good. You have to be boring/unclever and do id += 1 inside the for() loop then later on in process() similar slogging: id %= MAX; and the setattributes() inside the for loop. The side effect is that you're (re)setting the color for pads that haven't changed to their same value.Joe Soap wrote:Thanks fella.
Yeah, I'll need it to be robust enough to accept simultaneous input from the pads so a looping structure was always gonna be needed, and I figured it would boil down to firstof(x) etc - it's just I was using a completely different example template / jzlib to work from when dealing with the pads array that involved use of nonnull . . . and it totally threw me.
I'll give this a shot, see if my brain has returned from its temporary sabbatical in dev null!
Re: Multimode Pad Array?
Ahhh - resetting the colour on pads not pressed / not same value would be a problem, negating the whole purpose in fact.
It's not that I particularly want it to handle simultaneous presses - it's instead the case that I want each pad in the array to only effect itself and not its neighbours, a natural consequence of which would be that simultaneous presses were handled robustly?
So . . . I think I need a separate array / variable to track state for each pad[i] at the very least? The idea being I can manipulate colour according to the individual state of the array element - which I can already do, just not moderated via any 'state' flag.
Anyway, you've set me on the right road i think, cheers.
It's not that I particularly want it to handle simultaneous presses - it's instead the case that I want each pad in the array to only effect itself and not its neighbours, a natural consequence of which would be that simultaneous presses were handled robustly?
So . . . I think I need a separate array / variable to track state for each pad[i] at the very least? The idea being I can manipulate colour according to the individual state of the array element - which I can already do, just not moderated via any 'state' flag.
Anyway, you've set me on the right road i think, cheers.
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: Multimode Pad Array?
It won't reset the colors, it will set it to whatever the current x value is, I think. Have to play with it, like you said.
Re: Multimode Pad Array?
Heh, yeah. played with it and I've got it working about as far as all that - with the upshot that it does indeed reset the state on new presses . . . and also for unpressed pads. But that's okay, I can probably (hopefully!) sort that.
Total brain failure on my part, having not looked at Lemur for the duration of the World Cup. Thanks for the kickstart.
That . . . was a lot of football.
Total brain failure on my part, having not looked at Lemur for the duration of the World Cup. Thanks for the kickstart.
That . . . was a lot of football.
Re: Multimode Pad Array?
Hi There,
@Joe , that example in particular is not ready to work with arrays, and as oldgearguy mentioned it uses firstof(x) which is not ideal if you click several pads simultaneously, check attachment for an example with arrays.
Hope that helps.
Cheers
@Joe , that example in particular is not ready to work with arrays, and as oldgearguy mentioned it uses firstof(x) which is not ideal if you click several pads simultaneously, check attachment for an example with arrays.
Hope that helps.
Cheers
Last edited by lABl on 17 Jul 2014 09:56, edited 1 time in total.
Re: Multimode Pad Array?
Yup - I had a semi-working version using a loop and nonnull but it had problems resetting itself, among other niggles . . . but this is perfect.
Exactly what I asked for, thanks a bunch Antonio!
Now to see if I can (AB)use (:D) it beyond stock config!
Exactly what I asked for, thanks a bunch Antonio!
Now to see if I can (AB)use (:D) it beyond stock config!
Re: Multimode Pad Array?
Cool, glad that helps Joe!
Ya, initialization is a bit tricky sometimes in lemur.
In reponse to how to (AB)use of this gem, it's easy though, only two steps are required:
1- Sets the num of states in statesNum variable, you asked for 3 states button, so type 3 there, padValues will return an array where each element will rotate its value 0..1..2
2- On changecolors() script, fill "myColors" array with the colors you want for each state, it's easy!
Cheers man, hope that helps.
btw- redownload the module, I've updated it to works with 3 states by default.
Ya, initialization is a bit tricky sometimes in lemur.
In reponse to how to (AB)use of this gem, it's easy though, only two steps are required:
1- Sets the num of states in statesNum variable, you asked for 3 states button, so type 3 there, padValues will return an array where each element will rotate its value 0..1..2
2- On changecolors() script, fill "myColors" array with the colors you want for each state, it's easy!
Cheers man, hope that helps.
btw- redownload the module, I've updated it to works with 3 states by default.
- Attachments
-
- AB Rotate Pads Color.jzlib
- (3.56 KiB) Downloaded 78 times