11/03/2005

What's the deal!

Today I'm going to post a number of different topics and waffle in a puzzled, bemused, and typically unreadable stream of consciousness writing style, about all of them. Enjoy! And, keep on spankin'!

threads

While attempting to decide whether or not to use the threaded or non-threaded version of Apache 2 I got totally sidetracked by the issue of writing threaded programs themselves. This is an arcane art and frankly I don't understand it. The idea seems to be that you have a program that has N copies of itself and... uh... no, I don't get it at all. How is it different from forked processes?

I tried to make a sieve of Eratosthenes in Perl. Well, it's sort of there already on the perlthrtut man page, I just rewrote it and tried to understand what was going on at each point. But I blatantly don't. The way this works is that for each known prime you have a thread that filters out all the numbers divisible by that prime. If not, you pass it on to the next thread.

My program and the program in perlthrtut takes a list of consecutive numbers and filters all the primes out of them until you stop feeding it numbers. I wanted to create N threads at the start of the program and feed consecutive numbers into the first one until the last one told me it was full, but it didn't work. All that happened was the first thread kept passing numbers into the queue for the second thread. It never yielded control to any of the sub-threads. I don't know. Maybe I'm totally missing the point of threads.

Fraunhofer has a lot to answer for

I don't get MP3 bitrates and whatnot. Check this out. Let's record a sample and encode it. Let the sample rate be 48kHz, that's the maximum my soundcard will handle. Let's then pipe it into lame and spit out an mp3. This is what radioshow does every week when I record the drum and bass show to disc. For reference here's the command:

sox -t ossdsp -r48000 -wsc2 /dev/dsp -t raw - | lame -rxts48 - OUTPUT.mp3

LAME defaults to 128kbit. That is, 128,000 bits per second. What does that even mean? Let's look at the output of mpg123. If I play the MP3 I've just recorded, it reports "384 BPF" which means 384 bytes per frame. That is, 3072 bits per frame. What's a frame? I don't know, but mpg123 seems to indicate a 2 hour radio show is 300,000 frames. So, one second is 300000/(2*3600) ie 125/3 frames. Therefore we have 3072 * 125/3 = 128000 bits per second. Okay, the numbers add up! Hooray!

But wait! How come, when I record at 44.1kHz like on a CD I get 418BPF? Obviously it's in inverse proportion; 48000*384 is roughly 44100*418. How does it turn 48kHz into 128kbit? Once again, I don't know what the fuck.

Where's my damn compose key got to

The compose key is a concept unfamiliar to most computer users aka "Windows faggots" as it never seemed to progress beyond Unix. This is relatively surprising since it is very intuitive to generate accented characters by "overtyping" letters with punctuation symbols. For example, é is an e with a ' over it (well it is if your font puts a slant on an apostrophe. That's how directioned quotes are done it TeX, who am I to argue) Or ç looks like a c with a comma on it, ö looks like an o with a " on it, etc. The point is you can work all these things out easily and generate them in your documents by pressing Compose e ' without having to refer to a character map or whatever.

I used to enjoy the use of the compose key. But here's the problem. Since upgrading software, the damn thing has disappeared off my keymap! Seriously, where has it gone? I tried to work out how to get it back but I don't know what the hell's going on with X's keymapping system (you know, xmodmap and all that shit) It took me a fair amount of digging to even find that the compose key is referred to as the "Multi_Key"! I don't know what the fuck. And don't even get me started on UTF-8!

What's this button do?

It's red nose day today. Hasn't that got really shit? I remember the first one and being enormously annoyed at not being able to stay up to watch it. And the second one, similarly. All the kids would be talking about it. But I'm standing there excluded because I don't know what the fuck. But anyway now it's just shit. I mean you get about 15 minutes of comedy and 45 minutes of "PLEASE GIVE US ALL YOUR MONEY" per hour. It's dull. The last good red nose day was in 1997 when we got a half day of school and it was non-uniform too. Yes I was in my final year of A-levels in 1997 and still had to wear a uniform. This is why I now loathe suits.