Rounding the output value while the slider is being moved
Rounding the output value while the slider is being moved
- Subject: Rounding the output value while the slider is being moved
- From: Artemiy Pavlov <email@hidden>
- Date: Fri, 29 Sep 2006 16:40:14 +0300
Hey all!
I am trying to figure out how I can round the value the slider
returns while it is being moved. My slider is set to continuously
send the data while it's moving, it sends data to the Audio Unit
plugin and also to a text box near it. While the slider is moving and
is not being relesed, the Audio Unit parameter also changes
continuously. Here's the code that does the job:
- (IBAction)iaParam1Changed:(id)sender {
float floatValue = [sender floatValue];
NSAssert( AUParameterSet(mParameterListener, sender, ¶meter[0],
(Float32)floatValue, 0) == noErr,
@"[SinevibesTransformerView iaParam1Changed:]
AUParameterSet()");
if (sender == uiParam1Slider) {
[uiParam1TextField setFloatValue:floatValue];
} else {
[uiParam1Slider setFloatValue:floatValue];
}
}
Now, for some parameters, I would like to simultaneously round the
value to the first or second decimal after the point, as seeing a
number with 4 or 5 decimals after the dot makes no visual sense. So I
changed the second line to:
float floatValue = round ([sender floatValue] * 10.0f) / 10.0f;
As the slider is being moved, parameter changes smoothly for the
Audio Unit, e.g. 3.5 instead of 2.54121, but the text box shows
3.50000 or 3.49999 until the slider gets released - then it shows
3.5. How can I eliminate this issue which looks connected to
calculation precision?
Any suggestions would be very welcome!
Artemiy.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden