Page 1 of 1

Wave Table Read-primitive bug report

Posted: Sun Feb 15, 2015 5:13 pm
by martinvicanek
Hi devs,

I would like to point out a bug which I came across in the Wave Table Read primitive.

For certain small negatve requencies in the range -1e-5 < f < 0 the output signal will be zero. For other frequencies in the same range, the output will slowly oscillate as it should. (The prim will behave well outside that frequency range, as far as I can tell.)

Now you may argue that for one thing one should use positive frequencies, and besides, for such low frequencies wave tables are not the most efficient approach anyway. However, I happen to have an FM application where the modulated frequency may pass through zero. In that case the bug causes nasty spikes of one or more samples duration in the time domain, resulting in an annoying broadband noise in the frequency domain.

I am attaching a demo schematic. I should say that I am still using FS 3.0.3 (too many bugs in the newer releases :twisted: ). If this particular bug has been fixed meanwhile then please ignore this report.

Re: Wave Table Read-primitive bug report

Posted: Sun Feb 15, 2015 6:53 pm
by MyCo
Looks like there is check for neg. input missing in the wave read code. There are 2 sections in the code that use the freq input directly without checking for negative values. The first one calculates which wave should be used, the result is it uses the same wave ignoring the sign. So the wave for freq = 0.5 is the same as for freq = -0.5.

The second use is for the accumulator which isn't checked for negative values. This causes the internal accumulator to decrement below zero and there is no limit so it goes on and on... That can cause some funny effects, because over time the float value jumps into different rounding schemes causing changes in pitch and eventually complete silence forever.

This needs a fix...

Re: Wave Table Read-primitive bug report

Posted: Sun Feb 15, 2015 10:21 pm
by martinvicanek
Thanks for the detailed analysis. An oscillator should be able to handle both positive and negative frequencies (run backwards). Makes it more flexible anyway.

Re: Wave Table Read-primitive bug report

Posted: Mon Feb 23, 2015 8:18 am
by martinvicanek
The Sawtooth and Triangle oscillator primitives also have this bug. The Sine oscillator primitive, however, modulates through zero without any problem.

Re: Wave Table Read-primitive bug report

Posted: Thu Dec 17, 2015 6:19 pm
by MyCo
This should be fixed in the next version. However you shouldn't modulate the frequency down around 0 as this would cause one half cycle to be silence

Re: Wave Table Read-primitive bug report

Posted: Thu Dec 17, 2015 9:15 pm
by martinvicanek
MyCo wrote:This should be fixed in the next version.
Great! :D
MyCo wrote:However you shouldn't modulate the frequency down around 0 as this would cause one half cycle to be silence
No, why? There would only be silence if the frequency stays at zero for some time. If it keeps in motion, zero crossings of the frequency are perfectly OK. Negative frequencies should be allowed, resulkting in the oscillator running backwards. Check out the attachment for a demo.