Hi!<br><br>That was a good question, I think sorting where to use "modular synth style" signal flow and where to us "plain code" is a important part of ChucKing. Many things can be done both ways but if you do it the "wrong" way you'll end up with ugly code and high cpu costs.
<br><br>If there is still a need to round to a multiple of some number in a "5.trunc(2);" style it could be done using something like this;<br><br>fun float trunc(float input, float multiple)<br> {<br> return (input - input%multiple);
<br> }<br><br><br>which will always round down. If we really need the closest value we can use something like;<br><br><br>fun float trunc(float input, float multiple)<br>
{<br>
if ( input%multiple < ( .5 * multiple) ) return (input - input%multiple);<br> else return (input - input%multiple + multiple);<br>
}<br>
<br><br>This would be overkill if we just want a series of tones that hits every multiple of 400Hz (in that case we'd be much better off with simply generating that series directly like Ge said) but it's still a valid question in itself.
<br><br>Hope that helps.<br>Kas.<br>