BGN 2.0 Survey Extended :)

Hey everyone,

We have extended the survey deadline to July 7, 2008 11:59 pm. This gives you more time to respond to the survey (without hurrying up) and get the chance to have a copy of excerpts of the following books: E-business made easy, Jump Start, Go Negosyo and Go Negosyo Celebrity Edition. (See previous post for more details)

Looking forward to your responses and thank you very much!

Also, we shot some videos to entice (hehe!) you to fill up the survey ;) Here’s the link: http://www.youtube.com/watch?v=7K7VsltzdII

Again, thank you so much for your help ;)

Dae Unisa (for the BGN 2.0 Development Team)

I turned 24! ;)

So I am now 24 years old and first of all I would like to say thank you to everyone who greeted me :) That means so much. I know everyone gets to have this day once a year but I am still one of those people who believe that a birthday is a very special day and just the fact that you’re still alive is reason enough to celebrate! ;)

I originally thought of celebrating it on my own – well, i had a few reasons to be a bit sad – but i realized i have more reasons to be happy! :) I have my family and they’re all healthy and happy; I have my boyfriend who’s everything i want and everything i need; I have my friends who are always there for me; so what more can i ask for? :) So I was ‘convinced’ (hehe :P ) to take my brothers out :) So the three of us went out,  had ‘Wham’ burgers, got some Starbucks goodness (yummy!), watched ‘Wanted’, attended a jollibee kiddie party, went to the supermarket and then mass! :) yup it was a long day but a very fun one ;)

So for this year I only have 3 wishes: (1) My family and my man to stay healthy; (2) Finish my thesis; and (3) get a US Visa :) (So please pray for me too!)

Well, thats how my birthday went. Very simple but full of fun ;) and the best thing about it is that i spent it with the people i love – whether in person or online ;)

Brain Gain Network 2.0 Survey Invite with Premium Content Rewards

As promised, I am posting here the link to the BGN 2.0 Survey that we have created :) I hope you guys can find the time to fill it up as it only takes 12.5 mins :P And theres more, if you finish the survey before July 3, you get the chance to have a copy of the e-books (please read the letter below). Also, your responses will be a huge hep to us to come up with a better ‘web movement’ known as Brain Gain Network ;)

Maraming Salamat!

- dae

logo.gif

June 30, 2008

We are currently developing a new Brain Gain Network webservice that will deliver radically improved content, community and professional networking/collaboration tools for your benefit. In Brain Gain Network 2.0, we plan to offer a unique online environment designed to help Filipino professionals and entrepreneurs around the world achieve success in the fiercely competitive global economy. We also envision BGN 2.0 to facilitate philanthropic and socially responsible projects, ventures and exchanges for a healthier, stronger Philippines.

We are inviting you to participate in a survey that will help us know how best to architect this new and improved incarnation of BGN. If you complete and turn in survey responses on or before Thursday, July 3, 2008, that will win you exclusive access to a premium package of substantive e-excerpts from books that have content aligned with BGN 2.0’s charter.

‘E-Business Made Easy’, The PICS’s (Philippine Internet Commerce Society) Internet RoadMap for Filipinos by

Joey Alarilla

‘Jump Start!’, A Technopreneurship Fable

by Dennis Posadas (author of Rice, Bowl and Chips, How Asian Countries are Using the Silicon Valley Model to Develop Technology Startups)

GO Negosyo: Joey Concepcion’s 50 Inspiring Stories of Entrepreneurs by Joey Concepcion III

and

GO Negosyo: Joey Concepcion’s 50 Inspiring Stories of Entrepreneurs (Celebrity Edition) by Joey Concepcion III

The survey is composed of 31 questions and will take approximately 12.5 minutes to finish. We invite you to take a few minutes to complete the survey and help us catalyze the Filipino transnational gain for a better Philippine economy and quality of life.

Please click on the link below to begin:

http://www.questionpro.com/akira/TakeSurvey?id=988736

We look forward to hearing from you very soon!

Many thanks and Best Regards,

The Brain Gain Network 2.0 Team

DSC01389.JPG

Brain Gain Network – Reloaded ;)

I have been working with the Brain Gain Network (www.bgn.org) for 2 years already – and I must say that it opened my eyes to so many opportunities for success and growth for Filipinos everywhere. I get to work with people like Paco Sandejas (Managing Partner of Narra VC), Dickie Gonzales (CEO of Philippine Emerging Startup Open), Bill Luz (Executive Vice President of Ayala Foundation), and the likes. I even met Dado Banatao! I feel blessed because it’s not a chance every 23-year old could get ;)

For so many months, our team (Paco, JJ, Rhea and I) have been conceptualizing on how we want the next version of the BGN website would be – admittedly the current website is not very user-friendly (as most of our users have commented). But aside from that, we still need to know what the users think, because we want the users to be part of this whole process from beginning to end ;) And with that said, we are creating a survey that aims to gather information from more BGN users to help us improve the website – in terms of UI, content, services, etc. I’ll post the link here as soon as it’s ready and available :) I hope you take 10 minutes to respond to the survey ;)

I am very excited for this project – as we are getting very serious about it, and just like Rhea described it, we’re “intense” right now ;) There are so many things we want to get done – i cant reveal the details yet ;) And it wont be ‘yet-another-social-network’ :)

I tell you, its going to be great! :D

Will post more soon ;)

MELP algorithm finished! :)

This is a way-delayed update but still worth saying… :) Finally… the MELP code that I have been working on is finished (almost two weeks ago)! ;) Yay!!! Its just amazing when your hardwork translates to an output – in my case a working code! :)

Now, its time for more integration so I can finish my Real-time WLP Speech Coder. 

I’ll post more soon :)

dae

arccos and arctan approximation

For my thesis, I am implementing the 2.4 kbps MELP algorithm in assembly. One subroutine in that algorithm is the conversion of LPC coefficients to their LSF counterparts. In my implementation, I used Chebyshev polynomials, proposed by Peter Kabal and Ravi Prakash Ramachandran. Part of this method is to compute for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, thus giving the radian frequencies.

I was looking for a closed-form equation or an algorithm that computes for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details but I wasn’t able to find one in the internet… (maybe its just me being not very good at finding stuff I need in the internet). But anyways, I realized that Matlab has a documentation on all its functions and acos is one of those functions. Here’s a bit of what is in the Matlab’s documentation on the function acos (click on Help button or type doc acos):

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

And I thought, good, cos I already have a code for log approximation. And then I saw the imaginary part in the log, and I honestly don’t know how to compute for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. But having Matlab to my rescue, here’s what I got:

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

The input to the acos function was any number Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. I let Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details and Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details and then I used these values in the computation of Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. Good thing was that Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details which zeros out the first log term and all I had to worry about was the atan2 function. Basically, atan2 computes for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. And thank goodness, there is a closed-form approximation for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. For any value w, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is computed using the equation below:

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more detailsError: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more detailsError: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details.

If Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. These equations were taken from the ADSP User Manual, Chapter 4 on Function Approximation. Lastly, using the tangent’s odd symmetric property, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details.

After knowing all these equations, I now have a working Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details approximation in assembly! ;)

Math Plugin for Wordpress :)

After doing registration stuff (yes I’m still enrolling this summer and I have to say I’m excited to be a student again – I’ll be taking engineering entrepreneurship), I approved some comments on my blog and I decided to give the math plugin that Philip suggested (see Comments) a go :) I thought it would be useful since I plan to blog more about my thesis and stuff related to it :)

And as usual, I went through the same sysad nightmares. But boy am I proud of myself (hehe yabang!) cos check my previous entry (yes, hello math plugin!) Well, just for future reference ( I actually checked my previous blog entry on setting up this blog to get through) I will list down here the things I did to setup this math plugin ;)

1. I downloaded the files from this link. It’s a zip file so I still had to unzip it. (And I used windows to do that – hehe cheat!)

2. I remember that I had to copy this folder to some folder in the wordpress directory but I wasn’t sure which folder. And then I thought there must be some plugins directory somewhere. And I thought right! :) I had to check my previous blog entry to know where exactly in the server (I’m using Philip’s server) is the wordpress folder. Based on my blog entry it was in /var/dae. But I guess Philip moved things a bit and my wordpress folder landed in /var/sites/dae. It took me minutes to find that :) So I had to copy the entire wpmathpub folder in the plugins (under wp-content) directory. (At first I only copied the files in wpmathpub to plugins and it didn’t work – I tried checking the wpmathpub.php file and I kinda figured that I need to copy all the files with the main folder and not just the files…)

3. And I thought, its sorted… but no. I tried using the sample code provided in this website but nothing was happening. Apparently, I had to activate the new plugin (its in the Plugins section – upper right side). Now, its activated, it should be working already, right?

4. Well, wrong again. I was getting an error message saying that there was no permission for writing on a certain directory. I think what the code does is it converts the given equations into images and those images are stored in the img directory (in /wpmathpub/phpmathpublisher). And since its about permission, I checked my previous blog entry again and there was a thing on changing ownership of the files or directories. So I typed chown -R www-data:www-data /var/sites/dae. And I ran this command while I was in the plugins directory.

And after all these, the math plugin is already up and running ;) I converted all the equations in the previous blog entry and I had help from this site that provides a list of useful/common instructions to write math equations.

Antilog Approximation on ADSP-21065L

It took me some time to look for a site that could help me implement a program that does antilog approximation Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, where Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is any integer and Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is any real number. I was searching for “antilog approximation” but I didn’t get anything helpful (at least at the time I was searching), except for one Google forum site.

Based on that site, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details can be approximated by the following equation:

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

where Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details < Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

(exact when x=0 and x=1)

It should be noted though that the exponent can only be any real number Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details and the base is always 2. Now, there are two questions that arise:

1. What if the base is not 2?

2. What if the exponent is outside the range?

This blog entry answers the two questions and presents a way of implementing an antilog approximation Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, where Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is any integer and Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is any real number, in the ADSP-21065L platform.

Base is not 2

Any expression Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details can be expressed in terms of Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details as Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details à this means the base is now 2 but the exponent becomes Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, – very easy eh? ;) This brings me to the second question, what if the exponent is outside the range [0,1].

Exponent x outside the range Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

Remember that any real number x can be divided into two parts: its integral component, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, and fractional component, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. Thus, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. The fractional component fits in the range [0,1], therefore Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more detailscan be approximated using the equation shown above. But how about the integral part, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details? It can be computed using continuous multiplication. However, 3 cases exist: (1) Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more detailsis positive; (2) Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is 0; and (3)Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is negative. Of course if Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. If Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is positive, continuous multiplication (multiply 2 by itself Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details) will do the trick. If Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more detailsis negative, multiply 2 by itself Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details times and then compute for the reciprocal of the product. This method is ok if Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is a small number. But what if the exponent is in tens or maybe a hundred? Then this method is already inefficient. Add the division that is needed if Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is negative. (ADSP doesnt have a built-in division instruction, and so a subroutine has been developed for that). Good thing is, there’s a more efficient way of computing for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details and that is discussed next.

Implementation on ADSP-21065L

The antilog approximation is implemented by first multiplying the exponent Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details with Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details whatever the base Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is. The value of Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is stored in memory. The next step involves extracting the integral and fractional components, Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details and Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details, of the new exponent. Let’s say the new exponent is saved in f0. To extract the integral component, a flooring function is needed. However, no built-in floor function is available, instead fix or trunc commands can be used. The difference between fix and trunc is that fix rounds the number while trunc simply truncates the number. Example:

f0 = 4.7;

r1 = fix f0; à (r1 will have a value of 5)

r1 = trunc f0; à (r1 will have a value of 4)

f0 = -3.3;

r1 = fix f0; à (r1 will have a value of -3)

r1 = trunc f0; à (r1 will have a value of -3)

Whatever the value of r1 is, it should be compared to f0, because the floor of f0 should always be less than f0. If it’s not less than f0, subtract 1 then that is the integral part (save this to r1 still). And then the fractional part can be implemented by subtracting the integral part from the original exponent. However, take note that you should be subtracting (adding or multiplying) both fixed-point operands of both floating-point operands – cant be one fixed point and one floating point. The next lines of code show how the integral and fractional exponents can be extracted (the original exponent is in f0, integral component in f2, fractional component in f3):

r1 = trunc f0; // extracting the integral part (x1)

f2 = float r1;

f15 = 1.0;

comp(f2,f0);

if gt f2 = f2 – f15; // if f2 > f0, subtract 1 from f2 (f2 should always be less than f0, since f2 is the whole part)

f3 = f1 – f2; // extracting the fractional part (x2)

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is approximated using the equation above. (the one from the Google site). It is important to save the coefficients given in that equation in memory. Then use a loop that accesses these coefficients and updates the value of the exponent Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. (You can email me if you have inquiries on how this could be implemented – would be happy to help!)

But the most interesting bit for me was the implementation of Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. Like I mentioned above, there are three cases for Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details if Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details will be implemented using successive multiplication… And then it hit me, that I don’t have to do successive multiplications. It is only ok to do that if the exponent is less than 10. More than that, the algorithm becomes inefficient. So, what’s the solution, then?

Take note that a 32-bit floating point representation has the MSB as the sign bit, bits (31-24) as exponent (8 bits), and the last 24 bits as mantissa. It represents any floating-point number as

Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details

And since the number that I need to represent is a power of 2, I can just set all the mantissa bits to 0, and whatever the value of Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details is, subtract 127 from that and then store this number to bits 31-24 of the register. And then that register can be read as a floating point number and the value is already Error: http://www.daejavu.com/wp-content/plugins/wpmathpub/phpmathpublisher/img/ must have write access Read the official wpmathpub plugin FAQ for more details. Very simple, eh? The next lines of code show how this (very interesting method, at least for me hehe :D ) was implemented:

r2 = fix f2; // r2 is the integral part in the exponent
r4 = 127; // the exponent in a 32-bit floating point representation needs to be subtracted by 127 first to get the actual value of the exponent
r4 = r2+r4;
r4 = lshift r4 by 23;
// f4 is the floating point version ;)

The beauty of this implementation is that it only includes 4 lines of assembly code and it covers all cases! ;)

Pochi’s Graduation Day! :)

My youngest brother, Pochi, graduated from high school today! :) and i am very happy for him… after all those sleepless nights studying for an exam, and all those morning arguing with my mom (well, its more of my mom just trying to wake him up)… its now all over (atleast high school is over!)

I cant wait for him to get to college. He wants to take Hotel and Restaurant Management and im sure that he’ll succeed in that (and he’ll also make a very goo chef soon ;) )…

Congratulations Pochi and ate (with mama, tatay and kuya) is very very proud of you! I love you so much no matter how many times we argue! ;) Enjoy your summer break and 2 months from now, college student ka na! yay! :D

The pictures are in my multiply site. Click here.

On reading/writing binary files using Matlab

I spent most of my time yesterday trying to debug this problem I had with reading and writing binary files using Matlab. For my thesis, I have a copy of the C program that simulates the 2.4 kbps MELP Proposed Federal Standard speech coder from Texas Instruments, Inc. This code can output either compressed speech (output of the decoder) or the bit stream (output of the encoder). I needed to access the bit stream as I had to simulate an AWGN (Additive White Gaussian Noise) Channel and BPSK (Binary Phase Shift Keying) Modulation/Demodulation.

Using Matlab I used the command,

dos([pwd '\melp\melp -a -i ' lb_filename ' -o ' lb_bitstream], ‘-echo’);

to execute the melp code’s analysis (or encoding) stage only, where the filenames of the input and the bit stream are stored in lb_filename and lb_bitstream, respectively. This part was easy, after one click, then I already have my bit stream… It was also easy to read the bits, the command fread does that, but how to write the bits back was where I encountered a problem.

I executed the following lines of code to read my bits in the binary file lb_bitstream.

fid = fopen(lb_bitstream, ‘rb’);
bits_int16 = fread(fid,
‘uint16′);
fclose(fid);

The lines meant that the bits will be read in groups of 16 and will represent a 16-bit unsigned integer. I had to bring these values into their binary counterparts using the dec2bin command. However, dec2bin provides the output in char format, and they needed to be converted back to numerical format using str2num command. Here I have my bits (in 1’s and 0’s) and then I was already able to simulate the AWGN channel and the BPSK modulation/demodulation.

The output of the BPSK demodulator was still, of course, in 1s and 0s. I tried writing these bits to the file directly using fwrite(fid,bits,’uint16’) but as soon as I used this new bit stream as my input to the melp decoder, all I got was noise! I was thinking that the fwrite command would, on its own, group the bits by 16 since one of the parameters in the fwrite command was the format which in this case was uint16. But no…

So… I had to form these bits into groups of 16 again then convert it to its decimal counterpart before executing the fwrite command. The tricky part was the bin2dec command only accepts char or string as inputs. I solved this problem using the following lines of code and when I fed the new lb_bitstream to the melp decoder, I got what I wanted! ;) Yay! :D

% convert the bits to uint16 for writing to file
BPSK_demod = reshape(BPSK_demod, 16,length(BPSK_demod)/16);

temp_bpsk = num2str(BPSK_demod’);

temp_bpsk = temp_bpsk(:,1:3:end);

BPSK_demod = bin2dec(temp_bpsk);

fid = fopen(lb_bitstream, ‘wb’);
fwrite(fid, BPSK_demod,
‘uint16′);
fclose(fid);

To encode the bits using the melp decoder code (from Texas Instruments), the following code was executed:

dos([pwd '\melp\melp -s -i ' lb_bitstream ' -o ' lb_outfile], ‘-echo’);


And since the melp coder file contains data in int16 format (-32768 to +32767), it has to be converted and scaled back to ±1 using the following lines of code:

fid = fopen(lb_outfile, ‘r’);
lowerband_output = fread(fid,
‘int16′);
fclose(fid);

lb_synth= lowerband_output/32768;

So there you go! ;) I won the battle with the bits and got the output that I wanted! :)



?>