Delta modulation experiment

When I first learned about Delta modulation I realized it has a lot of potential for low-digital-bandwidth voice communication. With a single bit data-frame audio communication will be quite easy. This is one among my old experiments. I simulated a delta-modulation-demodulation system with various quantization steps and figured out it’s frequency response.

I did set the sampling rate to 4 times (as suggested by a communication book) the Nyquist Rate. That is 2 x 20kHz x 4.

The surface plot is the correlation co-efficient at those particular quantization steps and input sinusoidal frequency.

Here is the response,

I found out that it’s quite good for voice communication, upto 8kHz it will perform pretty well. The red region suggests good communication will occur upto 8kHz at small quantization steps. The the quality of the communication will gradually fall.

Next I will put a audio file through delta modulation.

The MATLAB code with the Delta modulation simulation model (.rar file) is here at

Moving average filter experiment

This is one of my old experiments I did when I started to learn about digital signal processing. I was intrigued by the simplicity of a moving average filter and did an experiment on frequency response of a moving average filter vs. number of averaging elements.

I found out that is has somewhat a cosine frequency response, and does have excellent low pass characteristics, although have some little curves on higher frequencies.

Here is the response vs. number of averaging elements. I plotted the surface with Number of Averaging Elements/Sampling rate. That way it’s easier to realize the duration of averaging.

Here is the MATLAB program that generates this surface plot,

I also put a sound files through my moving average filter. I don’t exactly remember the number-of-averaging-elements I used but the low pass characters was very impressive. You can use Windows Media Player Bar spectrum analyzer visualization to visualize that, or you can use a good pair of headphones/ speakers to see the difference.

Here is the real sound file and

Here is the filtered sound file

Low pass filtering experiment…

I was trying to explore the realms of filtering, but didn’t a get a neat way to get into it. Then one day, I thought about this eased sloshy movement that I always wanted to achieve when I used to make AVS visualisations in Winamp. If you don’t know about AVS, check it up. It’s one of the coolest Music Visualization System, and with a pretty steep learning curve. I learned to use that when I was 16 years old. Was a co-ordinate geometry buff at that time. There are some of my AVSes at deviantArt. If you have WinAmp with AVS, you can check them out.

It suddenly came to me that low pass filtering might just be able to produce an easing effect. And that was it. Processing came handy and I implemented a moving average filter where the dot co-ordinates are simply low-passed mouse co-ordinates.

Helped me visualizing filtering.

The processing code.

P.S. Processing is a nice neat programming language based on Java that can be used as a graphical programming language. If you haven’t already did it, do check it out.

Discrete Fourier Transforms

Some of my classmates freak out on this subject Digital Signal Processing. I think it’s rather FUN!

Let me get you to a very simple and elegant topic that you may need to study under DSP, it’s called DFT.

The definition of Discrete Fourier Transform,

X_k =\sum_{n=0}^{N-1}x_n e^{-j k n / N}

Now, if you are trained then you can easily find similarity between this relationship with Z-transform. It’s simple z on unit circle, i.e z=e^{j\omega}.

In more general terms, it means if x_n is a sequence of a sampled signal then the frequency spectrum of this signal is X_k. Neat little formula where j=\sqrt{-1}=i. Now, this N is the sampling rate and k is the angular frequency in radians/second. If you are doing manual calculations you can simply consider N as a arbitrary number and multiply the frequency axis with the ratio <real sampling rate>/<your N>.

When I first encountered this definition I thought it is so damn simple to get the phase and amplitude spectrum. All you need to do is find the amplitude and the argument of the numbers in X_k and you get the amplitude and phase spectra respectively.

Now there is another neat tool that can make out your and computers’ life even easier. Well, the MATRIX. Not the movie! 😉

With a little brainstorming you can figure is out too, we are summing up over n and calculating the function with multiple values of k. GET IT?

This matrix form is also known as Vandermonde matrix,

Where w = e^{- j/ N}, and you get can simply put the sequence as the column matrix [x], use this relationship below,

[X] = [W][x]

and get X_k as the [X].

And suppose you want to make some (linear) filter, what will you do? Don’t bother with that word linear, it’s related to linear systems. You can simply multiply X_k with H_k, where h_n is the impulse response of that filter, or rather the transfer function in disguise. You can use the same DFT technique to get H_k from h_n.

Let’s write that as,

F_k = X_k \cdot H_k

And viola! You do a Inverse DFT and get the time sequence, FILTERED!

And the easiest way to do a IDFT? MATRIX again…

[f_n] = [W]^{-1} [F_k]

Here f_n is the filtered sequence. But you wanna know the coolest part? You don’t need to do all the calculations to figure out [W]^{-1}. With a little mathematics, it can be proved that, [W]^{-1} = \frac{1}{N} [W]^{*}. Isn’t that easy? 🙂

What I figured out from other texts and articles, people have been using Fourier Transforms for sequences which are not time-sequences. Well, then what do I call the spectra? I don’t know. Think it out yourself. 🙂

And another thing, there is another thing call DTFT which is similar to DFT, but you can put any frequency resolution you want. With a little time and thought, you can modify DFT techniques into DTFT. Have at it, if’s FUN!

P.S. I could not get neat relationship between w and w^{*}, if I get it, I would post it.