[Csnd] Math tricks to round floats

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Csnd] Math tricks to round floats

hlolli
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.

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?
Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Math tricks to round floats

Michael Gogins-2
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" <[hidden email]> wrote:
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.

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?
Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Math tricks to round floats

hlolli
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 <[hidden email]>:
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" <[hidden email]> wrote:
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.

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?
Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Math tricks to round floats

Steven Yi

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 <[hidden email]> wrote:
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 <[hidden email]>:
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" <[hidden email]> wrote:
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.

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?
Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Math tricks to round floats

hlolli
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 <[hidden email]>:

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 <[hidden email]> wrote:
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 <[hidden email]>:
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" <[hidden email]> wrote:
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.

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?
Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] Math tricks to round floats

Tarmo Johannes-3
 trigger opcode perhsps would be the easiest?

Tarmo

30.07.2017 17:23 kirjutas kuupäeval "Hlöðver Sigurðsson" <[hidden email]>:
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 <[hidden email]>:

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 <[hidden email]> wrote:
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 <[hidden email]>:
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" <[hidden email]> wrote:
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.

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?
Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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

Csound mailing list [hidden email] 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
Csound mailing list [hidden email] 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
Loading...