Categories
Blog

Channel downmixing in MPlayer

Recently I have been playing with downmixing in MPlayer.ร‚ย  When I bought new speakers, I decided to go with stereo instead of surround since I mostly listen to music. As anyone using mplayer or any “derived” players such as vlc have discovered, there is a incredible annoying problem that the voices of the actors are very low, actually in general the sound is very low. It appears that when mixing to two speakers, the center channels is put very low in the mix. The same could be said about the subwoofer although it’s naturally not as easily recognized.

A quick google revealed that MPlayer has several tricks (audio filters) that might potentially work: volume, volnorm, pan, hrtf. I quickly discarded volume and volnorm since I don’t want to just boost the sound, I want it to distribute the channels properly. hrtf seemed like a good simple choice, since pan looked very complex. Sadly in the middle of Harry Potter I had to turn it off because it was making lots of clipping of the sound. So I was left with pan. It took a while to get a good default, but a bit of googling around revealed one with a decent default. I first just tried turning sub + center up to one but in one or the other movie introduced the dreaded clipping. So I had to keep it down a bit while still retaining decent boost of center and sub. After an afternoon of testing I came to the following “magic” formula:

-channels 6 -af pan=2:0.4:0:0:0.4:0.2:0:0:0.2:0.3:0.3:0.1:0.1

Please do note that one needs to add a -channels 6 in order for mplayer to decode all 6 channels so that it can mix it down to two. One can read more about the pan filter here.

Categories
Blog

How far have we come?

Things like these makes me wonder, with all the advances in computer science how far have we really come?

  • 40 years after the invention of relational databases we are still manually defining indexes
  • 40 years after the invention of Unix, the scheduler in Android (= Linux) still does a terrible job at scheduling the tasks that really depend on it (games and audio)
Categories
Blog

+1 Ubuntu

I was flaming Ubuntu in an earlier post for their lack of quality in their releases, so I thought it would be fair to give them credit when it is due. They have a project called One Hundred Paper Cuts where they try to fix low hanging fruit, easy bugs but annoying bugs. Bugs that when stacked together really can make you go from loving a piece of software to hating it. When I look through the blog post for their round 6,ร‚ย I really like what they are fixing.

We need more of this in software. It’s so easy, and has become so accepted, to ship a half-baked product and just slap a beta sign on it nowadays. Release early, release often is great, but there is also a time for making fixing all the small annoying bugs. If they plan on fixing this bug, then this is a step in the right direction.

Categories
Blog

Running Chrome in Ubuntu

Getting Chrome running in Ubuntu is now pretty easy, simple add the following line to /etc/apt/sources.list:

deb http://dl.google.com/linux/deb/ stable main

Then you can install Chrome using the package manager and it will keep itself updated. Sadly the browser is quite alpha (no flash, random errors, no tabs saving on exit) but they update it every week and it runs insanely fast compared to firefox.

Categories
Blog

Making hibernate work after harddrive upgrade

I recently upgraded the harddrive in my trusty old IBM T60. I mirrored the hd using a little dd magic and everything worked fine, including the IBM rescue partition. The only thing that wasn’t working anymore was hibernation in Ubuntu. This was because it relied on wierd UUIDs instead of actual device names. Fixing it was pretty easy, once you know what the problem is. First step is to fix up /etc/fstab so that the swap partition has the right UUID. You can get the UUID of a device using something like:

sudo vol_id -u /dev/sda4

Next step is to fix up the location of the resume partition. Open /etc/initramfs-tools/conf.d/resume and change the UUID to the same as you just put into fstab. Then run:

sudo update-initramfs -u

And you should be running again ๐Ÿ™‚

Categories
Blog

Generators and decorators in Python

Was reading through some old blog posts today and found an interesting talk about Coroutines and Concurrency. The talk is pretty long but presents some nice ideas about how to split a problem up and making it more modular using yielding. It seems like python has extended this a little so that you can actually use generators to consume messages also. What I found particular interesting though in the talk, was when he briefly showed a decorator. Decorators are really powerful and seems to bring about the best of lisps macro extensability to Python without loosing the excellent syntax ๐Ÿ™‚ I googled a bit and found the following list of patterns that you can do with decorators.

Categories
Blog

Streaming media between two linux boxes

I was wondering why it wasn’t possible to playback a movie over a ssh connection using remote X11 forwarding and mplayer. It seems that the latency is simply just too high. I’m not exactly sure if it’s a ssh or a X problem. This was on a wireless link, which might be part of the problem. While researching the problem I found this pretty cool patch for openssh that should give better transfer speeds. It’s in gentoo as the hpn use flag (even a patch for openssh 5.2). Sadly it did not seem to solve the problem. The movie was still very laggy. Then I tried adding a -C to add compression. This help a bit, but it was still painfully slow and uses quite a bit more cpu on the server side. Also the sounds will come out on the server end, so this might not work very well if you’re not in the same machine as the server ๐Ÿ™‚

Back to the drawing board it seems… I found this excellent post on how to stream movies from a server to a Nokia 800 tablet with size conversion done on the fly at the server end. This script is pretty clever and truly UNIX style. It uses netcat to pipe the data from the server to the client, and just sticks a ffmpeg in front to scale the movie first. What is perfect about this solution is that it uses very little cpu (very good for small devices like the Nokia tablets) and it streams the sound to the client. The only downside seems to be that the data is not encrypted. But of course there are ways around that too if you really care.

On the client (mine is 192.168.0.2) do this:

nc -l -p 5000 | mplayer –

And on the server side to this:

cat /movies/nice-movie.avi | nc 192.168.0.2 5000

Categories
Blog

Ginger cookies

My lovely girlfriend Milda made ginger cookies again today ๐Ÿ™‚ The last batch of cookies went so fast that this time she made 3 plates full of goodies. The recipe needs the following ingredients:

100g butter
100g sugar, recommended brown
150g honey
1 egg
400g flour
a bit of salt
1 tee spoon of baking soda
2 tee spoons of blended ginger
1 tee spoon of cinnamon
1 tee spoon of hot wine spices
2 table spoons of sour cream

Put together as:

Mix well butter and sugar.
Peel off ginger and blend it together with an egg. Put it together with butter and sugar.
Mix baking soda with sour cream and put to the bowl for pastry (there should be butter, sugar, egg and ginger by now :)).
Add honey and spices and mix all the ingredients well.
Add flour to make pastry of a consistence for cookies. Put it in the fridge for half an hour.

Flatten the pastry, and form the cookies (I do that by cutting it to squares with a pizza knife :)). Heat the oven up to 180 degrees and bake the cookies for 10 รขโ‚ฌโ€œ 15 minutes. Velbekomme.

OMG so many cookies!

Categories
Blog

DRM

Now if only they would sell their music in flac instead of mp3 ๐Ÿ™‚

Categories
Blog

Bridging the gap between web applications and desktop applications

Google gears has been touted as the answer to offline web applications, but so far very few sites have adopted it. Maybe its because exactly what makes web applications great is the fact that you can communicate with people in real time, or maybe its because adopting a non-trivial web site to work with gears is a very significant task, or maybe its because gears was never bundled with a browser by default (until now).

One area where it really makes sense is for email. Google of course realized this, but it took them a complete phone stack before they actually did it ๐Ÿ™‚ The only other thing that I use geagle for wordpress, but that’s only speeding it up. So contrary to the gmail integration it doesn’t allow you to read, modify and post while offline.

Even with the ubiquity of fast wireless 3G connections coupled with netbooks, the offline support is a welcome change to gmail and only adds to the already long list of reasons for using gmail. It still amazes me that google was able to deliver a new email client at a time when at least I thought the webmail race was over. It really just goes to show that building rock-solid products is still king. Not just time to marked. And that is really good news for the ones of us that still care about that ๐Ÿ™‚