## Archive for April, 2007

### The little scientist

Monday, April 30th, 2007

I have told Gennie that I don't mind what Alexander does when he grows up as long as he grows up to be a scientist. I don't mean that that necessarily has to be his job title or that he has to wear a lab coat, just that I hope that he always uses science and the scientific method in whatever he does. I hope he continues to take a keen interest in the world around him, develops theories about the world around him and then does experiments to find out if those theories are true.

I do this in my job (and non-work life) all the time. Actually I suspect everyone does it, but most people probably don't realize that they are actually doing science when they (for example) try another channel when there's static on the TV to find out if it's a problem with the TV (or cable provider) or just a problem with one particuar channel.

Maybe I should have said "I don't mind what my child does for a living as long as he understands what science is and appreciates its value whenever he uses it". But that's less catchy as a T-shirt slogan.

### Robot squirrel

Sunday, April 29th, 2007

When I first arrived at Microsoft I had a few days to settle in before I actually started work. I took the opportunity on one of these days to wander through the campus so I would know where to go on my first day, and to just explore a little. At one point on my walk I noticed a squirrel sitting on top of a fencepost staring it me, its eyes following me as I walked. I wondered (not seriously) if it was a robotic squirrel invented by the research department.

### Musical toy

Saturday, April 28th, 2007

The new and more logical musical stave I proposed yesterday could also form the basis for a fun musical toy. It would consist of a set of bars of various lengths representing various intervals, with the length proportional to the logarithm of the frequency multiplier (so maybe 15cm for an octave, 8.8cm for a fifth, 4.8cm for a major third and so on) and a set of connectors into which one or more of these bars can be plugged.

Each of the connectors would have a button on it which, when pressed, makes a sound. One of the connectors has its frequency fixed at (say) 440Hz (or maybe is tunable with a potentiometer) - the frequencies of the other connectors depend on how far away they are from the fixed connector (which in turn depends on which interval bars are plugged in. The connectors are built in such a way that if two bars are plugged in to opposite sides, their ends touch.

The result would be a sort of "build it yourself piano keyboard" which would help children (and adults) learn about musical intervals and tuning systems.

### The mathematics underlying music

Saturday, April 28th, 2007

Did you know that almost all Western music is based on an approximation? 524288 = 531441 to be precise (which is true to an accuracy of about 1.3%). These numbers are quite special:
524288 = 212
531441 = 319
Their ratio is called the Pythagorean comma and is the difference between 12 perfect fifths and 7 octaves. In Western music this ratio is treated identically to 1 (i.e. if you go up a fifth 12 times you'll end up on the note you started with, 7 octaves up). This approximation caused an enormous amount of trouble for early piano tuners.

Making this sort of approximation is quite important otherwise there would be an infinite number of notes (if you keep going up in intervals of fifths and going down in intervals of octaves you never get to exactly where you started).

But if we're using computers instead of more primitive instruments to make music, having an infinite number of possible notes doesn't really matter - the computer can represent them as exactly or approximately as you like, making it possible to do perfect just intonation and use any intervals you like without approximating.

The really interesting thing about thinking about intervals instead of "the 12 notes" is (for me) not so much that the different sounds are possible but that the underlying harmonic structure of the music is made explicit. The musical stave with its lines, spaces, sharps and flats has evolved rather than being designed and as such seems to hide the underlying intervals rather than revealing them. A fifth, for example, can be represented by 2 units, 2 units plus an accidental or 2 and half units plus an accidental depending on the note and key signature. But when the music is played they all sound like the same interval.

A much more logical stave would have time going down the vertical axis and frequency along the horizontal axis. Vertical lines would represent notes of constant pitch and horizontal lines would represent particular intervals. The horizontal scale should be made logarithmic so that a particular interval would be the same length no matter what its absolute pitch is. Intervals would be marked with their ratio to make it clearer what they really mean (though with practice it would probably be possible to read this kind of stave by eye without the interval markings). So if an octave is represented by 30mm, a perfect fifth (marked $\frac{3}{2}$) would be represented by 17.5mm ($\displaystyle 30\frac{\log \frac{3}{2}}{\log 2}$) and a major third ($\frac{5}{4}$) by 9.7mm ($\displaystyle 30\frac{\log \frac{5}{4}}{\log 2}$).

I ought to try drawing various pieces of music like this to see how it looks. It would also be much easier to write music using "weird" intervals like 7/4 and 12/11 using this stave.

### Multiple scrollbars

Thursday, April 26th, 2007

Ever have a window which has so much text in it that the vertical scrollbar moves too coarsely to allow you to find the position you want? Like you have an entire dictionary loaded as a text file and you're trying to find the word "madrigal". You get to "machine" and (after some fiddling with the mouse) manage to move the scroller one pixel down only to find that you have overshot all the way to "magical". Then you have to scroll all the way back up to madrigal or go back to machine and scroll down. Either of which, depending on the size of the dictionary, may take quite some time. Most annoying.

Wouldn't it be good if, for long documents like this, you had two scrollbars side-by-side. These would work like the hour hand and minute hand on a clock. The rightmost one would set the position in the document coarsely and the leftmost one would be for fine-tuning it. Once you had got to the "early Ms" with the rightmost scrollbar you could quickly get to any nearby word with the leftmost one.

For best distribution of precision between the scrollbars, the region of the document corresponding to the entirety of the leftmost scrollbar (X) would be to the entirety of the document as the window would be to X (i.e. the pixel size of the two scrollers would be the same).

The scrollbars would be set up so that moving the scroller of the leftmost scrollbar one pixel scrolled the document by at most one line. If the document is too large, than a new scrollbar is added - particularly long documents might have 3 or even more scrollbars, each with the same virtual document size to virtual window size ratio.

### Lensing editor

Wednesday, April 25th, 2007

One problem I'm always wrestling with while programming is how to see as much as possible of my program on screen at once. I tend to use a very high screen resolution (1600x1200 usually) and a very small font in my text editor (6x8) to see a large quantity of text at once. My coworkers despair that they can never read what's on my screen and say that I must have very good eyesight (I do at short distance - reading road signs while driving is another matter). But even 150 lines is not enough sometimes.

A while ago I had an idea for effectively increasing the number of lines even further. Vertically "compress" the lines that are further away from the cursor, while showing the closer lines at normal size. The further lines wouldn't be legible (unless the document is quite small) but you can see the overall "shape" of the document and easily navigate to different sections. The effect would be kind of like squashing the document vertically so that the whole thing fits on the screen and then looking at part of it with a horizontal bar magnifier centred on the cursor (although it would be a magnifier with an extended cross section so that even lines of text quite far away from the center were magnified a little bit, and there would be no obvious boundary between magnified and non-magnified text). Because of the similarity to a bar magnifier, and by analogy with the concept of a "folding editor" I call this idea the "lensing editor".

Tuesday, April 24th, 2007

Here's an interesting idea I had a while ago. It involves using the microphone in a headset like this, a fixed set of speakers and a high-resolution sound card (like almost any modern sound card) to track the position of the head of the person wearing the headset.

The software works by sending sounds through the speakers and trying to pick them up through the microphone. Once it manages to synchronize the sent pulses with the received pulses it can calculate the exact delay from sending a pulse to receiving it. Part of this delay will be due to the hardware involved or the latencies in the operating system, but these delays should be fixed. The remainder of the time is caused by the finite speed of sound in the medium between the speaker and the microphone. To a fairly good approximation this speed will be constant (about 300m/s) so using the delay one can work out the distance between the microphone and the speaker. Do this for two speakers and you can triangulate the position to a circle in the plane normal to the line between the speakers. Two more speakers and you can determine the position of the user's head quite precisely, up to the resolution limit of the soundcard (most modern soundcards can do 192k samples/second, giving a positioning accuracy of about 1.6mm).

Why would you want to do this? Well, the position of the user's head is a particularly interesting datum because it can be used to move windows around giving a pseudo-3D view. Suppose you have two windows on the screen and one is partially covering another. Normally to see the hidden part of the lower window you have to use the mouse (or worse, the keyboard) to move the upper window or bring the lower window to the foreground. But with a pseudo-3D view each window has a "Z-position" in front of or behind the plane of the monitor. If the user's head moves left then the closer windows move right and the further windows move left, allowing you to "see around" the upper window by moving your head, just as you would do with real objects. I haven't tried it yet, but I think it would be quite effective, and a cheap way to make a user interface much more immersive. I thought of doing this years ago but with an infra-red gadget strapped to the forehead - it only recently occurred to me that this could be done less intrusively with the microphone that many people wear anyway for telephony purposes.

### Play high

Monday, April 23rd, 2007

I think one of the best things about having a big part in a play is the high that you get after a particularly successful performance. I always feel so "on" in that situation - extra confident and witty. For example, after one rehearsal of Cash on Delivery we were trying on the costumes for the first time. One of the other characters was wearing an absolutely hideous dress and I made the old joke "It's very becoming. Though I'm not sure quite what it's becoming..." which seemed quite out of character for me. Maybe I was just starting to feel comfortable in the presence of my fellow cast members or maybe it was a natural high caused by the adrenaline of the situation. Almost like being drunk, but with no hangover in the morning.

### Embedded scroll bars

Sunday, April 15th, 2007

Many usability abominations have been inflicted on us in recent years, but I think one of the worst is embedded scroll bars in web pages. I usually scroll with my mouse wheel so it's especially annoying to be scrolling down and have a frame with a vertical scrollbar scroll under the pointer so that it starts sucking away the scroll events. It's also annoying if you're actually interested in the contents of the frame, since you have to cover up part of the text that you're reading with the pointer in order to be able to scroll the frame. Ban embedded scroll bars now! (Yeah, I know - I should use an open source browser and reprogram it myself to remove constructs that I dislike...)

### The future of language

Saturday, April 14th, 2007

I think that as global communication improves the language barrier will gradually disappear. This is not to say that there won't be different languages (at least for a good long while), just that everyone will be able to understand each other. Probably a few of the more obscure languages will die out, a few others will be kept deliberately alive although their speakers will have fluency in the "mainstream" languages as well. Some words will disappear, others will migrate between languages. Techniques for teaching language will improve so that the remaining languages will be spoken and understood by everyone. Perhaps eventually these languages will become (effectively) a single language that everyone speaks.

Then we'll make contact with aliens and have a language barrier again just as we've forgotten all our techniques for effectively living with it.