Kyma Forum
  Tips & Techniques
  !Fader with variable min/max values

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   !Fader with variable min/max values
JackRosete
Member
posted 01 November 2006 08:45         Edit/Delete Message   Reply w/Quote
There seems to be a problem with this script:

(ConstantL * (!Max - !Min) + !Min)

I have used it within the Value field of a SoundToGlobalController. The Constant is a random number generator outputting values between 0 - 1 at rhythmic intervals.

Works fine as long as !Max is greater than !Min. When !Min is greater than !Max, the output should be zero right? Well it still outputs for some reason, as though !Max/!Min had been reversed.

Can anyone explain what's going wrong here/how I can fix this? Basically, I want to constrain the random 0 - 1 numbers within !Max, and !Min parameters, so that when !Max is 0, the GlobalController output is also 0.

Thanks!

IP: Logged

HectorBenard
Member
posted 01 November 2006 10:11         Edit/Delete Message   Reply w/Quote
Hi Jack,

Shouldn't you have an extra set of parentheses?

(ConstantL * ((!Max - !Min) + !Min)).

Otherwise the !Min is added after the multiplication with the ConstantL. Is that what you want?

H

IP: Logged

SSC
Administrator
posted 01 November 2006 10:36         Edit/Delete Message   Reply w/Quote
(ConstantL * (!Max - !Min) + !Min)

If Min > Max, then you will be multiplying ConstantL by a negative number (not zero). Take an example case:
ConstantL = 1
Max = 0.5
Min = 1
would give you:
1 * (0.5 - 1) + 1 = 0.5

"I want to constrain the random 0 - 1 numbers within !Max, and !Min parameters, so that when !Max is 0, the GlobalController output is also 0."

You could try multiplying the random number by the minimum of the two clipped to the range of (0,1):
ConstantL * (!Max vmin: !Min) clipTo01

Or if you still want the smaller value to be used as an offset:
ConstantL * (!Max vmin: !Min) clipTo01 + (!Max vmin: !Min)

Or take the absolute value of the difference for your range and add the minimum of the two as your offset. That would always scale by the DIFFERENCE between Max and Min no matter which was larger:

ConstantL * (!Max - !Min) abs + (!Max vmin: !Min) clipTo01



IP: Logged

JackRosete
Member
posted 01 November 2006 10:53         Edit/Delete Message   Reply w/Quote

KymaShuffler.kym

 
I tried that, but then the output seems to ignore the !Min value altogether! Very odd.

I will attach my Sound which is finished apart from this issue. The script is within the 'GrainAmp' SoundToGlobalController.

It is a Sound that emulates (and expands upon) Metasynth's 'Shuffler'. I will post it into the Tweaky as soon as this problem is solved. It works best with sustained pad samples (and vocals for wacky granulation).

Thanks!

IP: Logged

JackRosete
Member
posted 01 November 2006 10:55         Edit/Delete Message   Reply w/Quote
Sorry SSC, I didn't see your reply! I will try out those options now. Thanks

IP: Logged

HectorBenard
Member
posted 01 November 2006 11:09         Edit/Delete Message   Reply w/Quote
Oh yeah, actually that expression only cancells out the !Min as it is subtracted and then added back. Sorry about that! But now we know how to do it from SSC's post. Look forward to trying out your sound!

H


IP: Logged

JackRosete
Member
posted 01 November 2006 11:49         Edit/Delete Message   Reply w/Quote
I think I didn't explain the behavior I was looking for very well! Sorry...

Your suggestions came close, but none of them was exactly what I had in mind. However! Your maths example really clarified the original code for me (and where it was 'going wrong') and so I came up with this new code, which seems to be working!

(!Max gt: !Min)

true: (Constant L * (!Max - !Min) + !Min)

false: (!Max)

As soon as !Max falls below !Min, !Max's value is used. I also came up with another alternative:

(!Max gt: !Min)

true: (Constant L * (!Max - !Min) + !Min)

false: (Constant L * !Max)

Which works as above, but when !Max falls below !Min, the random numbers are scaled by !Max, so in effect !Max remains the maximum value and 0 becomes the new minimum value.

Thanks!

[This message has been edited by JackRosete (edited 01 November 2006).]

[This message has been edited by JackRosete (edited 01 November 2006).]

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c