Thursday, December 18, 2008

The wonder of OpenMP

It took me about 5 minutes to make an app multithreaded with openMP.

Step 1 : Turn on openMP flag


Step 2 :  Add #pragma omp parallel for to the existing for statement like so
#pragma omp parallel for
for ( int i = 0; i < parlist.count(); i++)
    // Do your code here.
   // Cannot jump out of for loop. No breaks, no returns.
Step 3 : Profit!

Wednesday, December 10, 2008

Some audio madness

I just found the most awesome command line utility for audio processing. EVER! SoX.

I don't think I'll ever need anything other than this and batch files to do transcoding of audio or even batch processing of audio ever again. GUI's are nice and all, but nothing beats command line apps!

Also, another wav editor instead of audacity which people seem to have many complaints about. Wavosaur.

And lastly, for those musicians out there. LMMS. A Digital Audio Workstation app that now finally has windows support. Awesome!

Here is a sample batch file that you can put inside your SoX folder :

FOR %%G IN (%1\*.wav) DO (
    sox %%G "temp.wav" rate -v 8000
    del %%G
    move temp.wav %%G

I would use this for downsampling 44khz audio recordings to 8k for the Wii Remote. i.e. Lit's phone calls. It's destructive since it converts in place, so make sure your audio is under version control!

Wednesday, December 3, 2008

Multithreaded compiling with VC Express or make -j

For posterity: To turn on multicore compiles in VC Express 2008, in the commandline options of the compiler options. Add a /MP

Thursday, June 19, 2008

Youtube and load balancing.

It seems that youtube doesn't like people who load balance. Simply put, the IP that loads the webpage and probably the flash element needs to be the same one getting the video stream from one of their MANY servers.

The way I solved it was to bind certain IP ranges to a single WAN connection.

This seems to have gotten most of them. I may be missing a few or assigned too large a subnet, but at least my videos usually don't say "We're sorry, this video is no longer available" anymore.

Friday, June 13, 2008

A day that will live in infamy 6/13/2008

Today, I have become the very proud owner of a Mitsubishi Lancer Evolution X MR in Graphite Grey Pearl.

It scares me when I drive it... but in a good way. From a stop light, I rest my foot on the gas lightly and the car rolls foward seemingly docile, until you hear that whine. Then it lurches forward at a speed that sends my stomach into my spine. The first time I tried to make a left turn and depressed the gas pedal at what I felt was a reasonable position, I heard the engine come to life and I had to react way faster than I had expected to. Mistake 1, my foot is used to the lag of a torque converter.

It's no walk in the park on the freeway either, while cruising I breathe on the accelerator, and the pull to my intended maximum speed is amazing. If I'm a split-second late off the gas I blow my target speed by 15 mph. It demands every bit of attention from me to drive it with fuel economy in mind and trying to stay under the speed limit.

The range on a full tank shows about 200 miles, hopefully it goes up after the break in period. So not only does the power scare me, the eventual gas bill does too. Thank goodness I live and work in the same city so my daily commute is 10 miles round trip. Once a week or so I head to Alhambra for some deliciousness at Lee Kam Kee.

How does it feel to drive an evo you ask? I feel drunk on power, as I hear the whine of the turbo as it spools up, my heart rate rises in in unison. The car feels poised ready to pounce at any turn I am going to send it's way, and it is ready to chew it up and spit it out. The gadgetry is amazing, the included sound system rivals some home theaters. It's got everything Lexus has to offer, with none of the fancy fake wood trim. Everything feels precise and minimal. In other words, your luxury German marque comfort monger is not going to like it, and will make countless comparisons to the 3 series or the 1 series which I do admit, beats the Evo in a straight line in the 3.0 Twin Turbo V6 models but it's just different animal. One is like a Bagheera, still a wildcat, but he's nice and cuddly on the inside. The other is Shere Khan. The evo taunts me everytime I get in the car. It pleads to me, let me loose, tear it up, thankfully my voice of reason kicks in every time, it's still the break in period.

The geometry of the car seems to be meant for a tall skinny person, and last I checked Mitsubishi is a Japanese company. I'm 5"6' and I feel swallowed in those Recaro' buckets. The A pillar is a huge blind spot when looking for cars coming from the left and right, the rear spoiler blocks half the rear view mirror. The side head bolsters of those recaro's block my view when trying to navigate Los Angeles stop and go traffic, and the door panels feels like they start where my neck does. It makes parking a brand new car rather interesting because I never felt like I had visibility problems in my previous car a Mazda 3. So let's look at a table.

The difference in measurements is miniscule except for the 2.2 inches in width. It feels much wider, but now that I'm looking at the measurements, it must be all perception! So why does it feel hard to maneuver in tight spaces? It didn't dawn on me until I looked at the curb to curb turning circle. Mazda (34.1 feet) , Mitsubishi (38.7). That's 4.8 feet, so all my usual turning points to judge how to get into a parking spot, are different. Alright, alright enough with the Asians can't park jokes. Again it's all a matter of adapting.

On the whole, I couldn't be happier, other than dealing with the initial feeling out period of a new car and becoming comfortable with it. I am now in the club of those who have attained their dream car. It has been a long wait and I'm glad I don't have to wear a suit and drive this to work everyday. Getting in and out of it would probably leave some nasty creases.