Math tricks to round floats
Date | 2017-07-30 10:34 |
From | Hlöðver Sigurðsson |
Subject | Math tricks to round floats |
Hey list, I'm trying out the new Ableton Link opcodes and I'm having problem rounding the metro phase values, so that I can fire events on specific times.
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
On ksmps=10 then for example, I never get 1.0000 rather 0.99509 0.99512 0.99514 1.00077 1.00092 1.00098 and for 0.25 0.02310 0.02312 0.02314 0.02990 0.02996 0.03003 I guess I need to round it to the lowest resolution, so that every number is divivdeable by 1/64. Tried someting like k_trigger, gk_beat, k_phase, k_time link_metro gi_peer, 4 kphase = int(k_phase) + frac(k_phase) Where I multiplied the frac, roudned it and divided again. But I'm just not "getting" this. Also another challenge here is that an increase in ksmps quickly increases the chances of missing timestamps, wouldn't it make more sense to give the values of link_metro an audio-rate, or recommend setksmps=1? |
Date | 2017-07-30 12:34 |
From | Michael Gogins |
Subject | Re: Math tricks to round floats |
Thanks for the information. I'll look into this and maybe make some changes. Regards, Mike On Jul 30, 2017 5:34 AM, "Hlöðver Sigurðsson" <hlolli@gmail.com> wrote:
|
Date | 2017-07-30 12:48 |
From | Hlöðver Sigurðsson |
Subject | Re: Math tricks to round floats |
Nice, thinking about this more, I think if one is cleaver with this tool, it would be possible to achieve relieable network triggering. Using phaseor and greater than operator for triggering, within csound just make sure the event isn't fired twice. In that case, audio rate isn't so important, but lower ksmps would just make it more accurate but never cause a miss. 2017-07-30 13:34 GMT+02:00 Michael Gogins <michael.gogins@gmail.com>:
|
Date | 2017-07-30 15:03 |
From | Steven Yi |
Subject | Re: Math tricks to round floats |
Rather than search for an exact number you might try using a modulus and check the crossover by checking whether the current value is less than the previous value. On Sun, Jul 30, 2017, 6:48 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-07-30 15:23 |
From | Hlöðver Sigurðsson |
Subject | Re: Math tricks to round floats |
Yes, I think the crossover is the solution here. Different way to approach this than I'm used to from the past. And add some lock so make sure that an event isn't sent on every k-rate after the crossover returnes true. 2017-07-30 16:03 GMT+02:00 Steven Yi <stevenyi@gmail.com>:
|
Date | 2017-07-30 15:43 |
From | Tarmo Johannes |
Subject | Re: Math tricks to round floats |
trigger opcode perhsps would be the easiest? Tarmo 30.07.2017 17:23 kirjutas kuupäeval "Hlöðver Sigurðsson" <hlolli@gmail.com>:
|