[music-dsp] Re: Waveshaping
Aaron Oxford
aaron at hardwarehookups.com.au
Fri Oct 5 03:44:02 EDT 2007
Hi all,
I am by no means an expert on oversampling, but FWIW I recently
needed to upsample some stuff to between 4x and 16x from 'normal',
and I found that a simple linear interpol upsample followed by a
couple of passes through a bandpass (I wanted to remove DC also)
worked well (and more importantly in my case was easy to write from
first principles in C#).
I didn't need to downsample but I'd imagine the same would work well
in reverse - as someone else already suggested you can do the
bandpass first and then just throw away samples, using the linear
interpolation if you aren't doing a nice easy 'just throw away n-1of
every n samples'-type downsample.
I'm aware that there are far more advanced and accurate techniques,
but again this worked well from first principles without very much effort.
As for the technique you suggested yourself, I'm not sure if you're
applying that equation to create intermediate samples or simply using
that function to effectively create a smoothed waveform as your input
(you're just applying the shaping function in the same step, right?).
Either way, you'll probably find it works, but I've found that that
particular 'filter' function is too severe for working with sound
high in treble (e.g. a hihat sample) at 'normal' sample rates.
Which brings me to my next point. This all depends on the sample rate
you're working with to start with too - if you're working at 96 kHz
or higher I'd say forget about aliasing - since only a discontinuous
or 'extreme' shaping function would introduce aliasing to your
already fairly highly 'oversampled' data (which we will blatantly
assume is nicely bandlimited), and aliasing on the output can be
dealt with by the output stages of whatever it is you're doing.
Again, if you're working at 48 kHz or lower, I think that your
filtering will be a bit too severe for certain sounds, so I'd suggest
something a little less forceful, such as o[x] = f(0.9*i[x] + 0.1*o[x-1]).
One of the smart people on this list might tell you what the low-pass
cutoff and steepness of that transfer function is. :-D
Anything more complex than that and you may as well be working out
the coefficients for a 'proper' filter. Having said that I simply
ripped off some 2p filter psuedo-code from this list's archive. :-)
Hope this is helpful,
Aaron.
---------------------------------------------------------------------------------
Aaron Oxford - aaron+hardwarehookups .com .au
Director, Innovative Computer Solutions (Aust) Pty. Ltd.
49 Maitland Rd, Mayfield, NSW 2304 Australia
http://www.ic-solutions.com.au
Developer, SourceForge project VioLet Composer
http://sourceforge.net/projects/buzz-like
More information about the music-dsp
mailing list