First time here? Check out the FAQ!
x

How do I get the size of a changeable array at runtime? (EventVariable array confusion)

0 votes
442 views

I'm using a HotValue (!Scale) to select one of several arrays, which are different sizes. I then want to index into the selected array using another, normalised, HotValue (!note1) in the range of 0 - 1.

So I want to know the size of the selected array. I tried this:

but I get the error "HotVariables cannot perform the operation size."

(this is a smaller simplified version of my real Sound to make this easier to read. I'm trying to do something similar to this but with variable sized arrays.)


Update:

I tried using an EventVariable array because you can get the size of those at runtime.

But I can't seem to get values into and out of the EventVariable array at all. I'm staring at this and it's really got me foxed. I can't see what I've done wrong.

I've tried this in the Value field of a SoundToGlobalController:

and it doesn't work at all. I set the !Index fader to go from 0 to 3 and all I get on the !Output event is 0. Also I only get a fader for !Index. I get no faders in the VCS for !Index1, !Index2, !Val1 or !Val2.

I've tried it with literals instead of HotValues and I get the same result, 0 all the time. (Except if I go past the end of the array and try an index of 4 or 5. Then I get weird fractions 3.147... and 4.59186 )

 

Here's the Sound itself.

 

 

 

 

asked Aug 31, 2018 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,840 points)
edited Aug 31, 2018 by alan-jackson

1 Answer

0 votes

RT*M!

The secion on Arrays of Arrays on Page 250 of Kyma X Revealed was particularly helpful. I had the wrong idea about how you access two dimensional arrays. I've got it working now.

For the trivial example above, here's a version that works:

Here's an example that's more interesting and uses the "size" of the varying arrays so the HotValue faders are all scaled up appropriately from the 0 - 1 range.

This goes in the Value field of the SoundToGlobalController:

 

| scales selectableScales |

scales := #(
    #(0 12)
    #(0 7 12)
    #(0 3 7 12 15)
    #(0 3 5 10 12 17)
).

selectableScales := scales collect: [:scale|
    (!NoteSel * scale size) of: scale
].

(!ScaleSel * selectableScales size) of: selectableScales

 

This example lets you select a scale and then select notes from that scale.

answered Sep 1, 2018 by alan-jackson (Virtuoso) (15,840 points)
I'm still completely confused about how to use the EventVariable array.
...