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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Bandlimited waveforms synopsis. (click this to go back to the index)<br />

References : Joe Wright<br />

Linked file : waveforms.txt (this linked file is included below)<br />

Notes :<br />

(see linkfile)<br />

Comments<br />

from : dflatccrmadotstanforddotedu<br />

comment : The abs(sin) method from the Lane CMJ paper is not bandlimited! It's basically just a crappy method for BLIT.<br />

You f<strong>org</strong>ot to mention Eli Brandt's minBLEP method. It's the best! You just have to know how to properly generate a nice minblep table... (slightly<br />

dilated, see Stilson and Smith BLIT paper, at the end regarding table implementation issues)<br />

Linked files<br />

From: "Joe Wright" <br />

To: <br />

Subject: Re: waveform discussions<br />

Date: Tue, 19 Oct 1999 14:45:56 +0100<br />

After help from this group and reading various literature I have finished my<br />

waveform engine. As requested, I am now going to share some of the things<br />

are have learnt from a practical viewpoint.<br />

Problem:<br />

The waveforms of interest are sawtooth, square and triangle.<br />

The waveforms must be bandlimited (i.e. fitting under Nyquist). This<br />

precludes simple generation of the waveforms. For example, the<br />

analogue/continuous formular (which has infinite harmonics):<br />

s(t) = (t*f0) mod 1 (t=time, f0=frequency of note)<br />

procudues aliasing that cannot be filtered out when converted to the<br />

digital/discrete form:<br />

s(n) = (f0*n*Ts) mod 1 (n=sample, Ts equals 1/sampling rate)<br />

The other condition of this problem is that the waveforms are generatable in<br />

real-time. Additionally, bonuses are given for solutions which allow<br />

pulse-width modulation and triangle asymmetry.<br />

The generation of these waves is non-triaval and below is discussed three<br />

techniques to solve the problem - wavetables, approximation through<br />

processing of |sinewave| and BLIT integration. BLIT integration is<br />

discussed in depth.<br />

Wavetables:<br />

You can generate a wavetable for the waveform by summing sine waves up to<br />

the Nyquist frequency. For example, the sawtooth waveform can be generated<br />

by:<br />

s(n) = Sum[k=1,n] (1/k *sin(2PI*f0*k*Ts)) where f0*n < Ts/2<br />

The wavetable can then be played back, pitched up or down subject that<br />

pitched f*n < Ts/2. Anything lower will not alias but it may lack some<br />

higher harmonics if pitched too low.<br />

To cover these situations, use multiple wavetables describing different<br />

frequency ranges within which it is fine to pitch up or down.<br />

You may need to compromise between number of wavetables and accuracy because<br />

of memory considerations (especially if over-sampling). This means some<br />

wavetables will have to cover larger ranges than they should. As long as<br />

the range is too far in the lower direction rather than higher, you will not<br />

alias (you will just miss some higher harmonics).<br />

With wavetables you can add a sawtooth to an inverted sawtooth offset in<br />

time, to produce a pulse/square wave. Vary the offset to vary the pulse<br />

width. Asymmetry of triangle waves is not possible (as far as I know)<br />

though.

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

Saved successfully!

Ooh no, something went wrong!