[music-dsp] Re: Waveshaping
earlevel at earlevel.com
Fri Oct 5 16:04:57 EDT 2007
Linear interpolation is only a good choice if you're fairly
oversampled to start with (that is, you don't have a lot of high
frequency components. When upsampling by a factor of 4 or more, it's
usually better to do it in multiple steps--you can use some tricks to
gain a large advantage in efficiency. (You could even upsample with a
high quality interpolator, then go to linear interpolation to go
higher if you want and it meets your criteria.)
As for the bandpass--it's more efficient to filter what you can at
lower rates, so it would be best to block the DC first, then
upsample, and put the effort into low-pass filters.
As for "if you're working at 96 kHz or higher I'd say forget about
aliasing"--you need to oversample by more than that for distortion
algorithms (192 kHz is not enough either)--even if you source signal
is heavily bandlimited (say, a guitar, even with the highs reduced).
On Oct 5, 2007, at 12:44 AM, Aaron Oxford wrote:
> 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
> 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 Oxford - aaron+hardwarehookups .com .au
> Director, Innovative Computer Solutions (Aust) Pty. Ltd.
> 49 Maitland Rd, Mayfield, NSW 2304 Australia
> Developer, SourceForge project VioLet Composer
More information about the music-dsp