[music-dsp] Article: antialiased sine waveform syncing
robert bristow-johnson
rbj at audioimagination.com
Mon Jun 8 13:27:31 EDT 2009
On Jun 8, 2009, at 8:48 AM, george bezerianos wrote:
>
> http://s1gnals.blogspot.com/2008/12/bloo_6897.html
>
...
On Wed, May 6, 2009 at 2:12 PM, Vadim Zavalishin wrote:
>>
>> http://www.native-instruments.de/index.php?id=dsparticles
>>
>> Comments welcome.
>>
hi Vadim and George.
i took a look at both the bloo.pfd and the SineSyncRC.pdf (i could
not extract what i was looking for in the SineSync.pdf).
now in bloo, George is creating a blit, as best as i can tell, and i
am not sure if you're getting a sinusoid out of it, but if you are,
is your BLIT going through some resonant filter or something? i
don't see where the sin(wt) is coming out of it.
in SineSyncRC, Vadim is using a quite long polynomial of |x| to
approximate a sine function over a period (and i presume he's driving
that with a sawtooth function coming out of a phase-accumulator that
defines the phase of the waveform).
are my understandings reasonably correct?
about Vadim's method, that's fine and good, but i think you're
throwing *much* more polynomial at it to get an acceptable
synthesized sine wave. the sine function is fully analytic (not the
Hilbert transform meaning of "analytic"). it is continuous and has
continuous derivatives, no matter how deep you go. that lends itself
to very good polynomial approximation, *particularly* for the 1/2
cycle before the sin() bends around back (and +/- pi/2).
i would suggest aiming to approximate
sin( pi/2 * x ) for -1 <= x <= +1
sin(x) is a completely odd-symmetry, so any decent polynomial
approximation would be odd-symmetry (and odd-order). if you factor
out the x, and express as
sin( pi/2 * x ) = x * p(x^2)
you are left with a simple polynomial that is made into an even-
symmetry polynomial when x^2 is the argument.
p(x^2) = sin(pi/2*x)/(pi/2*x) * pi/2 = pi/2 * sinc(x/2) -1
<= x <= +1
or
p(x) = pi/2 * sinc( sqrt(x)/2 ) for 0 <= x <= +1
unlike George, i (and nearly all my EE textbooks) define the sinc(x)
function to have the pi in it:
sinc(x) = sin(pi*x)/(pi*x)
that is the polynomial that you want coefficients for (after
determining the order necessary). you might be surprized to see how
good of a fit you get for merely a 2nd or 3rd-order approximation to
the sinc(sqrt(x)/2) function. don't use Taylor series, but try to be
more optimal in getting the coefficients. least-squares would be
good, in this case, but the Remes Exchange algorithm would work also.
oh, the other thing is that you need to turn your sawtooth phase
function into a triangle since the sin(x) function is being fit for
only 1/2 period. if your saw goes from -1 to +1, then
tri(x) = 2*|saw(x)| - 1
that absolute value operation is the only one you'll need.
everything else is just plug-and-chug into the polynomial.
--
r b-j rbj at audioimagination.com
"Imagination is more important than knowledge."
More information about the music-dsp
mailing list