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

FM for a graphical position gives strange results #1

Closed
jamshark70 opened this issue Feb 20, 2020 · 2 comments
Closed

FM for a graphical position gives strange results #1

jamshark70 opened this issue Feb 20, 2020 · 2 comments

Comments

@jamshark70
Copy link

jamshark70 commented Feb 20, 2020

Not sure if this is the right place for it...

I was just trying a frequency-modulation expression as a position, and it seems like the values go out of range somewhere.

In audio, frequency modulation works exactly as you would expect.

sin ((sin(220) + 1) * 220) * 0.2 >> centre;

// sounds basically the same as SuperCollider
a = { SinOsc.ar((SinOsc.ar(220) + 1) * 220, 0, 0.2).dup }.play;

OK, let's translate that to graphics:

-- no FM, this is OK
circle [sin(0.05) * 0.5, sin(0.06) * 0.5] 0.25 >> rgb;

But:

-- huh?
circle [sin(sin(0.01) * 0.02 + 0.03) * 0.5, sin(0.06) * 0.5] 0.25 >> rgb;
circle [sin(0.05) * 0.5, sin(0.06) * 0.5] 0.25 >> green;

sin(0.01) * 0.02 + 0.03 should range between 0.03 +- 0.02 = 0.01 to 0.05, but the white circle quite obviously moves much faster than the green one at times. That would be explained only if the calculation is being done incorrectly. But the calculation seems to be correct for audio. I'm mystified.

Forcing order of operations with extra brackets doesn't help: sin(sin(0.01) * 0.02 + 0.03) and sin((sin(0.01) * 0.02) + 0.03) appear to behave identically.

@dktr0
Copy link
Owner

dktr0 commented Feb 20, 2020

I think this may be because the oscillators in the WebGL implementation of Punctual are stateless (just functions of their argument and time) while those in the Web Audio API are stateful (output depends on arguments, time, and preceding state/output of the oscillator). It's an interesting case - I'm not sure the behaviour is "incorrect" just different although I can see how it could be counter-intuitive. A different approach to modulation might be needed/possible to coexist with the generally stateless aspect of things in WebGL, but I'm not sure what that would look like.

@jamshark70
Copy link
Author

Ok, I see... I'll close the issue, then.

I was looking for more "interesting" (less obviously cyclical) modulation shapes. On the graphics side, we might be stuck with additive approaches for now, if the oscillators' phases in WebGL aren't accumulative.

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

2 participants