Two’s Complement

The Two’s Complement is one of those important things you learn in digital electronics. Simply put in a few steps. For a negative number you would
1. Take its absolute value.
2. Convert it into binary like you would normally do
3. Complement it
4. Add one.
So -5 would be 5. Which is 0101. Which becomes 1010 when you complement it. Which becomes 1011 when you add 1 to it.
For a positive number it’s just the usual.

But whats interesting about this whole thing is that it’s just like an odometer. Assuming it can count to hundred. Go forward, it’s 0 1 2 3 4 … Go back, it’s 0 99 98 97. It’s something a lot of teachers fail to teach. Now it makes sense why this notation is preferred for hardware applications.


Dypsa Algorithm

Dypsa Algorithm is a common algorithm used in speech signal processing using Matlab. Its part of the Voicebox toolbox that’s available online for free. You can download it here!. Download the Zip file or click here to download the zip file anyway. The Zip file contains a whole lot of other Algorithms along with dypsa. Install the toolbox by setting the path to it or if you don’t know how to do that just paste all the codes or dypsa.m file alone(if you are going to use dypsa alone) in the current working directory. That should do the trick

What Dypsa does.

Basically what Dypsa does is, It extracts the Glottal Closure Instants(GCI) and the Glottal Opening Instants(GOI) form the speech signal that you provide it. So you would get two matrices one corresponding to the GCI and one corresponding to the GOI if you run a wav file through dypsa algorithm. These matrices will contain the locations, or the sample numbers, of the places of the glottal closure and opening instants. I will provide you a small piece of code incase you need an example of how to use it.

Glottal Closure and Opening Instants.

So what are these instants. Every time you produce a sound (a voiced sound), your glottis flaps. There is an instant where it is closed and there is an instant where it is open. If you take into account one of these instants, either the closure or the opening instants, you will get an idea of the pitch of the speaker. The distance between two successive samples is the Pitch Period, and the from this you can find out the pitch contour (which I don’t want to confuse you with, here).

How these instants can be related to pitch?, is a good question, which again I do not want to post here in the same blog.


Although Dypsa algorithm can find out the GCI and the GOI of the speech signal. It also gives us some values at the unvoiced portion of the speech too. This particular point about dypsa should be noted. Because for a lot of applications it would be a negative aspect.


clear all;
close all;
[input,Fs] = wavread(‘tapestry’);
[gci, goi] = dypsa(input, Fs);
impulseC(gci) = 1;
impulseO(goi)= 1;
subplot(3,1,1),plot(input((6500:8500),1)),title(‘Voiced Segment of thee Input signal’),axis(‘tight’);
subplot(3,1,2),plot(impulseCT((6500:8500),1),’r’),title(‘Impulse Signal, based on GCI’),axis(‘tight’);
subplot(3,1,3),plot(impulseOT((6500:8500),1),’b’),title(‘Impulse Signal, based on GOI’),axis(‘tight’);

What I’ve done here is that, I’ve read the wave file and stored it in input and ive given it to dypsa which will give me the gci and goi in line 4. Since dypsa only gives the locations of the gci and goi I’ve converted it to impulses so that you can see it when you plot it.

In order to read a wavefile, put the wave file in your working directory.

Doubts are welcome.

Thanks for reading.