Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

rounding cycle interrogation ?..

DSP related issues, mathematics, processing and techniques

rounding cycle interrogation ?..

Postby Tepeix » Mon Mar 21, 2022 5:16 pm

Just a simple float counters.

Every time it go > 4096 it's get - 4096.

(seams to works well but not if the input value is > 4096... I need to test it more..)

What seams strange is the first cycle with an 0.1 input value will make 0.1 when -4096 occurs.
Then next cycle it become 0.449. then 0.0347. then 0.0244, 0.0142, 0.0039, ... ...

Did you know what cause this strange rounding behavior ?
Is there any use to try to fix this ?

Thanks for any response ;)
Attachments
Float count.fsm
(62.74 KiB) Downloaded 641 times
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: rounding cycle interrogation ?..

Postby Tepeix » Mon Mar 21, 2022 7:25 pm

I try a different approach with this code :
Code: Select all
streamin in;
streamout out;
float index=0;
float max=4096;
movaps xmm0,in;
addps xmm0,index;
movaps xmm1,xmm0;
cmpps xmm1,max,5;
andps xmm1,max;
subps xmm0,xmm1;
movaps index,xmm0;
movaps out,xmm0;

But i get exatly the same result ... ..
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: rounding cycle interrogation ?..

Postby Tepeix » Mon Mar 21, 2022 9:31 pm

Another approach...

This time a float ramp from 0 to 1. That feed a int counter from 0 to 4095..
And finally the added result.
That's a little more stable. But it never go to 0.. Or maybe after a long time ?
The max value change a little. A 0.0005 imprecision for both..

Also if i check the counter.. There's a lot of variation after 0.1. Like it always add something like 0.10001 ?
Attachments
floatcount other way2.fsm
(added comment about the int output)
(98.06 KiB) Downloaded 616 times
Last edited by Tepeix on Mon Mar 21, 2022 10:18 pm, edited 2 times in total.
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: rounding cycle interrogation ?..

Postby Tepeix » Mon Mar 21, 2022 10:11 pm

Finally, this one seams to works with no rounding problems. (at least for 0.1 input !)

The float ramp go from -0.5 to 0.5. > feed the int counter.
Then adding 0.5 to the float. Adding the int. It seams ok for now ;)

(Note that this code and the last one have a blue int output.
If you connect it to a code that treat it as a float it will take cpu and give bad result..)
Attachments
floatcount other way3.fsm
edit (little stage0; forgotten instructions erased)
(98.11 KiB) Downloaded 623 times
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: rounding cycle interrogation ?..

Postby tulamide » Wed Mar 23, 2022 12:59 am

I'm not sure, what goal you try to reach?
float values are imprecise by nature, you can't rely on them. If you want to make sure to get a stable start and end point, you have to use linear interpolation. If you try to get exact steps per sample, you need to use integer numbers (note, integer numbers, not the integer format). In other words steps like +1 or +13, instead of 0.1 or 1.3.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: rounding cycle interrogation ?..

Postby Tepeix » Wed Mar 23, 2022 1:11 pm

Thanks !

I was thinking that float would be imprecise when using very small number but not specially with 0.1.

Not really sure what i try to do.. But the main purpose is an lfo reading mem.
Maybe an osc, but i think it would be impossible to bandlimit it..

Maybe for an lfo i don't need so much precision...
The 4096 choice also could be to much..

But the int think attract me ;) I first try with true int then i read again your message ;)
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: rounding cycle interrogation ?..

Postby Tepeix » Wed Mar 23, 2022 6:33 pm

Héhé, the guy that try to utilize green ticker to blue, then complain about blue float precision ;) :oops:
Tepeix
 
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm


Return to DSP

Who is online

Users browsing this forum: No registered users and 52 guests