First time here? Check out the FAQ!

How do you access the final item in an array using a fader?

0 votes

I've used a ModalFilter where I have a !Model fader that selects between different sets of mode frequencies.

I'm using "of:" and an array of frequencies to do that. Here's a simplified version with just two models.

Using "of:" to access an array is zero-based. So if the !Model fader is 0 we should get the first element of the four arrays, eg. (1, 2, 3, 4). Which indeed we do.

If the !Model fader is 1, we should get the second set, (1, 3.997, 9.469, 15.566), shouldn't we? But I don't.

If I edit the !Model fader's range to go from 0 to 1.01, then I do get the second set, but when the fader is exactly 1.0 I still get the first set. If I edit the code and change all occurrances of "!Model" to "1" I get the second set.

What am I doing wrong? It's as if when the fader says it's 1.0 it's really a bit less.

Here's the set up of the fader:

asked Aug 29, 2018 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,740 points)
If you set the Grid to 1, does that fix it?
Setting the Grid to 1 does allow the fader to select the second set in this example.

That won't work in my full version as I'm interpolating between "models" so I don't want the fader to be stepped using Grid.
For interpolation, you should use into: rather than of:. For example:
!Model into: #({0 @ 2} {1 @ 3.997})
That will interpolate between 2 and 3.997 based on the value of !Model.

Please log in or register to answer this question.