# [music-dsp] Waveshaping

paul Fultz pfultz2 at yahoo.com
Thu Oct 4 15:39:02 EDT 2007

thanks for the information, but what kind of filter do
i use? most filters cause phase shifting and group
delay. butterworth and bessel are too slow of cutoff,
and chebyshev or elliptical cause ripples in the pass
band. also if i use a polynomial waveshaper then i
could filter for each term, right? for example if w(x)
= x + x^2 + x^3, then i use a low pass at one-half of
the nyquist frequency then calculate x^2 and i use a
low pass at one-third of the nyquist frequency then
calculate x^3 but use no filter for the first term x.
also using linear interpolation and a simple 1-pole
lowpass filter produces this formula:
s1 = w(x[n])
s2 = w((x[n] + x[n-1])/2)
a= 1 - e^(-pi)
y[n] = a(s1 + s1) + (a^2)(y[n-1] - s2) + y[n-1]
i think thats right, perhaps there is way to improve
it. thanks,
paul
--- Nigel Redmon <earlevel at earlevel.com> wrote:

> First, the part about not understanding how to do a
> good filter for
> decimation: The basics are simple--you just have to
> understand why,
> and you can make good choices. You have to restrict
> the frequency
> band to under half the new sample rate, then
> decimate. So, if you are
> downsampling by a factor of 2, and you have a source
> that is 96 kHz
> sample rate (giving you 48 kHz upper frequencies),
> you need to run it
> through a low-pass filter set to block everything
> above 24 kHz--then
> just throw away every other sample. (There are
> different kinds of
> filters, and different ways of optimizing,
> especially if the
> downsampling ratio is big enough to warrant
> multirate technique--I'm
> just talking fundamentals here.)
>
> Any frequencies that don't get removed in the
> filtering will reflect
> back into the audio band--just make sure the filter
> is good enough to
> get those reflections low enough in amplitude to
> requirements, which will depend on the strength your
> original audio
> has in that area, the characteristics of the filter,
> and the quality
> required in the end result. For instance, if you
> original audio will be down 40 dB at 24 kHz and
> dropping, you can get
> away with a simpler filter than if it has more
> powerful harmonics in
> that area.
>
> Now, in the rest of your post, you're trying to
> mitigate aliasing in
> the time domain--in a nutshell (looking at aliasing
> in the time
> domain), the position of sharp edges are the thing
> that suffers with
> lower sample rates. That is, you get a
> frequency-dependent ambiguity
> about where the sharp transition lands, when it
> would ideally land
> between samples. For instance, a square wave that's
> an exactly
> multiple of the sample period will sound fine, but
> one that's not
> will have a modulation of the edges that results in
> new frequencies--
> aliasing. (Technically, you could say the one that's
> an exact
> multiple aliases as well, but the aliased
> frequencies all line up on
> harmonics and cancel each other.) So the smoother a
> wave, the less
> aliasing--this should be obvious, because you need
> higher frequencies
> to make sharp edges.
>
> conversion:
>
>
http://www.earlevel.com/Digital%20Audio/RateConversion.html
>
> As noted on that page, make sure you read this first
> to lay the
> ground rules:
>
>
http://www.earlevel.com/Digital%20Audio/Conversion.html
>
>
>
> On Oct 4, 2007, at 8:59 AM, paul Fultz wrote:
> > i was wanting to implement some anti-aliased
> > waveshaping, i first thought about upsampling and
> then
> > downsampling, but i dont fully understand how to
> > implement a good filter for decimation, so i
> thought
> > about creating another way to do it without
> upsampling
> > and i came up with this formula:
> > where w(x) is the transfer function for
> waveshaping
> >
> > (w(x[n]) - w(x[n-1]))/2 + w((x[n] + x[n-1])/2)
> >
> >
> > what do you think? when w(x) = ax then the formula
> > returns a*x[n] but i dont know how well it smooths
> out
> > aliasing maybe some people with better math skills
> > than me can analyze it deeper, or maybe have a
> better
> > formula. i know it doesnt get rid of all the
> aliasing,
> > but maybe its moving in that direction.
> > thanks,
> > paul
>
> --
> dupswapdrop -- the music-dsp mailing list and
> website:
> subscription info, FAQ, source code archive, list
> archive, book reviews, dsp links
> http://music.columbia.edu/cmc/music-dsp
> http://music.columbia.edu/mailman/listinfo/music-dsp
>

____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.