Using equation (1) and (2) first find out the initial conditions. To generate a tone of frequency f = 50Hz with sampling frequency fs = 500Hz: Rearranging the above equation and setting x (n) as an impulse sequence the following recursive equation are obtained įor n = 0, y (0) = x (-1) sin (wT)+2y(-1) cos (wT)-y (-2) The above equation can be rewritten in a difference equation form as follows: Thus the above equation is translated to: for x (z)=1) will generate a sine wave of frequency ‘w’ sampled at a rate of T (=1/fs). The impulse response of the above transforms (i.e. The z-transform of a sine wave is given as follows: Generation of a single tone basically implies generating sample of a sine/cosine wave. This is the principle of so called Wavetable synthesis (lookup table method), which has been used with great success in computer music applications. The period or equivalently the fundamental frequency of the generated waveform is controlled either by varying the speed of cycling around the table or by accessing a subset of the table at a fixed speed.
A more efficient approach is to precompute the sample of the waveform, store them in a table in RAM which is usually implemented as a circular buffer and access them from the table whenever needed. In this approach, generating each sample by running the sample-processing algorithm of the filter requires a certain amount of computational overhead.
This type of method is known as “Recursive” method. Then, sending an impulse response d(n) as input will generate the desired waveforms at the output. It is often desired to generate various types of waveforms, such as periodic, square waves, sawtooth signals, sinusoids and so on.Ī filtering approach to generating such waveforms is to design a filter H (z) whose response h (n) is the waveform one wishes to generate.