Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation modification #338

Open
DougALug opened this issue Jan 8, 2022 · 0 comments
Open

Documentation modification #338

DougALug opened this issue Jan 8, 2022 · 0 comments

Comments

@DougALug
Copy link

DougALug commented Jan 8, 2022

In the core.misc documentation

you put the following code:

double t = soloud.getStreamTime(h); // get time
if (t == hammertime) hammer();

Even if you match frames this will likely fail. As you describe in the paragraph below it, you can't use '==' to compare floating-point values.

Maybe adding this macro will help

// Check to see if pos is within xtol of xval        
#define _m_Is_Around( pos, xval, xtol )  \
      ( ( ( (pos) >= ( (xval) - (xtol) ) ) && ( (pos) <= ( (xval) + (xtol) ) ) ) ? 1 : 0 )

So now you could say:

double delta_Tolerance = 0.02; // 20ms (a 50hz frametime)
double t = soloud.getStreamTime(h); // get time
if ( _m_Is_Around( t, hammertime,  delta_Tolerance ) ) hammer();

Just a thought... I love the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant