17.01.2013 Views

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

musicdsp.org source code archive - WSInf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Arbitary shaped band-limited waveform generation (using oversampling and low-pass filtering) (click this to go back to<br />

the index)<br />

References : Posted by remage[AT]kac[DOT]poliod[DOT]hu<br />

Code :<br />

Arbitary shaped band-limited waveform generation<br />

(using oversampling and low-pass filtering)<br />

There are many articles about band-limited waveform synthesis techniques, that provide correct and fast<br />

methods for generating classic analogue waveforms, such as saw, pulse, and triangle wave. However, generating<br />

arbitary shaped band-limited waveforms, such as the "sawsin" shape (found in this <strong>source</strong>-<strong>code</strong> <strong>archive</strong>), seems<br />

to be quite hard using these techniques.<br />

My analogue waveforms are generated in a _very_ high sampling rate (actually it's 1.4112 GHz for 44.1 kHz<br />

waveforms, using 32x oversampling). Using this sample-rate, the amplitude of the aliasing harmonics are<br />

negligible (the base analogue waveforms has exponentially decreasing harmonics amplitudes).<br />

Using a 511-tap windowed sync FIR filter (with Blackman-Harris window, and 12 kHz cutoff frequency) the<br />

harmonics above 20 kHz are killed, the higher harmonics (that cause the sharp overshoot at step response) are<br />

dampened.<br />

The filtered signal downsampled to 44.1 kHz contains the audible (non-aliased) harmonics only.<br />

This waveform synthesis is performed for wavetables of 4096, 2048, 1024, ... 8, 4, 2 samples. The real-time<br />

signal is interpolated from these waveform-tables, using Hermite-(cubic-)interpolation for the waveforms, and<br />

linear interpolation between the two wavetables near the required note.<br />

This procedure is quite time-consuming, but the whole waveform (or, in my implementation, the whole waveformset)<br />

can be precalculated (or saved at first launch of the synth) and reloaded at synth initialization.<br />

I don't know if this is a theoretically correct solution, but the waveforms sound good (no audible aliasing).<br />

Please let me know if I'm wrong...<br />

Comments<br />

from : Alex@smartelectronix.com<br />

comment : Why can't you use fft/ifft<br />

to synthesis directly wavetables of 2048,1024,..?<br />

It'd be not so<br />

"time consuming" comparing to FIR filtering.<br />

Further cubic interpolation still might give you audible<br />

distortion in some cases.<br />

--Alex.<br />

from : remage@kac.poliod.hu<br />

comment : What should I use instead of cubic interpolation? (I had already some aliasing problems with cubic interpolation, but that can be solved by<br />

oversampling 4x the realtime signal generation)<br />

Is this theory of generating waves from wavetables of 4096, 2084, ... 8, 4, 2 samples wrong?<br />

from : Alex[AT]smartelectronix.com<br />

comment : I think tablesize should not vary<br />

depending on tone (4096,2048...)<br />

and you'd better stay with the same table size for all notes (for example 4096, 4096...).<br />

To avoid interpolation noise<br />

(it's NOT caused by aliasing)<br />

try to increase wavetable size<br />

and be sure that waveform spectrum has<br />

steep roll off<br />

(don't f<strong>org</strong>et Gibbs phenomena as well).<br />

from : balazs[DOT]szoradi[At]essnet[DOT]se<br />

comment : you say that the higher harmonics (that cause the sharp overshoot at step response) are dampened.<br />

How ? Or is it a result of the filtering ?<br />

from : remage@makacs.poliod.hu<br />

comment : Yes. The FIR-filter cutoff is set to 12 kHz, so it dampens the audible frequencies too. This way the frequncies above 20 kHz are about -90<br />

dB (don't remember exactly, but killing all harmonics above 20 kHz was the main reason to set the cutoff to 12 kHz).<br />

Anyway, as Alex suggested, FFT/IFFT seems to be a better solution to this problem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!