0
0

Hi,

I’m just trying to build a sinus generator with fmod, but I got some trouble with that. I took the userstream code from the samples directory and changed the streamcallback to some constant frequency. I just added constant values to t1 and t2:
[code:2dygvb9b]
t1 += 0.05f;
t2 += 0.05f;
[/code:2dygvb9b]
With a sample rate of 44100Hz I get constant ~175Hz from the sound card. But after about 15 seconds this frequency changes to ~178Hz.
I’m using the produced signal to control a step motor, so this inaccuracy is really really bad… :-(
Any idea, what’s going wrong?
It’s a Linux system with OSS as sound system.

thx,
fallen

  • You must to post comments
0
0

Hi,

do you mean something like this?
[code:1mr97vi9]
pi = 3.14159......;
t1 = (t1 + 0.05f) % (2*pi);
[/code:1mr97vi9]
But don’t you think, that I would get some numerical errors due to the inaccuracy in pi?
Unfortunately I cannot test this now, because I have no oscilloscope available. But I will do so next week.

thx,
fallen

  • You must to post comments
0
0

Yes, but you knew what was meant, didn’t you? An if clause would have been an extra line and I am such a lazy person… 😉
But thanks, I’m going to try this out on monday.

  • You must to post comments
0
0

Works fine, thank you!

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.