Array within a collect array.

0 votes
275 views
I'm using a 1 to: 8 collect to generate an array of signals for NEL Osc send, where each signal becomes an argument for an osc message (with 8 arguments).

I neee to find a way to get an array within the array but it's not working as I hope.

the following message works;

{(1 to: 8 collect: [:i | (GKeyDown left eq: 0) true: 0.3 false: (i - 1 eq: !SampCounter)]}

This works as I want and my 8 messages/arguments are all 0.3 when !GKeyDownLeft is not pressed and when it is pressed the 8 messages/arguments are 1 only when !SampCounter is 1, which allows me to have the osc messages light up my Monome Grid lights one by one in sync with SampCounter counting.

i now want to add to this so that the first led is always dimly lit in the 'false portion' but not the others (The dimly lit keys are indicating the key has a function when pressed). I can add a + to all 8 messages/arguments but not just one. E.g in the 'false' portion the following message makes all 8 keys dimly lit all the time whilst one is brightly lit in time with !SampCounter counting also.

((i - 1 eq: !SampCounter) + 0.25)

I was hoping to use:
 

{(1 to: 8) collect: [:i | (GKeyDown left eq: 0) true: 0.3 false: { (i - 1 of: #(0.25 0 0 0 0 0 0 0)) +  (i - 1 eq: !SampCounter)}]}
 

But this tells me that i isn't declared (in the second curlies). What's the best way round this?

ps. I'm typing this away from Kyma and on phone so apologies for any typos.
asked Aug 31, 2020 in Capytalk & Smalltalk by ghood (Master) (3,060 points)

1 Answer

0 votes
Answering my own questions again (sorry, sure i'd tried this but now seems to be working just fine so clearly not!).

The answer was:

{(1 to: 8) collect: [:i | !GKeyDownRight true: 0.3 false: (i eq: !SampRowCounter) + ((i - 1) of: #(0.25 0 0 0 0 0 0 0))]}

 

(no second set of curlies)
answered Sep 1, 2020 by ghood (Master) (3,060 points)
...