Using gate~ causes strange signal output with scale~
Hi,
I have the following example patch, which gates between two changing audio signals.
It's supposed to output 0. to 15. on the left and the same on the right. However, on the right hand side (2nd inlet of gate~), when the phasor reaches then end, it show 30.24. I'm not sure why?
Is there any way to smooth out this jump? or am I going about this the completely wrong way?
Is there a better way to scale~ audio signals, since scale~ is only available since a few versions ago?
Thx
Scale~ takes two input and two output parameters to determine the mapping between inputs, but then continues to map inputs to outputs even if the exceed the input range. It does NOT constrain inputs to the given range.
So if you give [scale~ 0. 5. 0. 100], an input of 6 would output 120.
Your second scale object takes inputs from 127 to 64 and scales them 0 to 15, so 127 = 0 and 64 = 15...if you continue this pattern, when you reach 0, your output scaling is approximately 30, as your output shows.
Yes, make sense. I'm wondering is there a way to constrain inputs to a given range?
You may want to look at clip~ and pong~, depending on your needs.
Also, to be thorough, your patch doesn't use selector~...it uses gate~. But that's not causing the issue!
The problem with pong is that it finishes on the highest value instead of the lower, ie 15, instead of 0. It's the same with clip. . (it's basically the same as 30.24, it's just choosing the highest number it can, when it should be the lowest number).
I'm really surprised this isn't easier in Max :/
Sorry yes gate is used instead of selector, but it's the same result with either. Can't seem to resolve this issue...
Hello Centre Ville, you are mixing two different things: logic related to message passing and signal processing in MSP. You have to keep in mind, that always (=at every time instant) every signal connection has a value. If you "close" [gate~]'s output, it doesn't mean there is no signal. There is a signal with value 0 (zero), hence this strange "30.24" output.
for scaling ranges you can also use + - * / instead of readymade externals, then you know what exactly happens and why.
however, what you looking for can be archieved by scale~ followed by clip~.
btw: note that the non-MSP scale, map, zmap objects will also act like scale~ - if you want to clip, you have to do that in addition.
And just for fun: two approaches: