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

Unexpected results setting Synth args to large numbers #4853

Closed
markwheeler opened this issue Apr 5, 2020 · 2 comments
Closed

Unexpected results setting Synth args to large numbers #4853

markwheeler opened this issue Apr 5, 2020 · 2 comments

Comments

@markwheeler
Copy link
Contributor

@markwheeler markwheeler commented Apr 5, 2020

Environment

  • SuperCollider version: 3.11.0
  • Operating system: MacOS 10.14.6
  • Other details (Qt version, audio driver, etc.):

Steps to reproduce

(
SynthDef("aSynth", {
	arg myArg;
	((myArg + 10) - 40000000).poll(2, "Difference"); // Expecting 10, seeing 8
}).add;
)
Synth("aSynth", [\myArg, 40000000]);

Expected vs. actual behavior

I'm seeing unexpected results passing large-ish numbers to Synth args – it seems like they aren't correctly set within the Synth.

The code example should be fairly self explanatory. Varying the numbers gives different incorrect results. I feel like I may be missing some kind of restriction or...?

For context, I discovered this while trying to pass frame numbers in to a sample player.

@markwheeler markwheeler added the bug label Apr 5, 2020
@brianlheim
Copy link
Member

@brianlheim brianlheim commented Apr 5, 2020

the server uses 32-bit floats for signals; you are seeing rounding error because you are performing operations on numbers of very different magnitudes. if you swap your order of operations you would get the answer you expect. see also this stackexchange answer or the classic 'what every computer scientist should know about floating point arithmetic'

@brianlheim brianlheim closed this Apr 5, 2020
@brianlheim brianlheim added intended behavior and removed bug labels Apr 5, 2020
@markwheeler
Copy link
Contributor Author

@markwheeler markwheeler commented Apr 5, 2020

Thanks for the quick answer! I have some reading to do :)

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

Successfully merging a pull request may close this issue.

None yet
2 participants