Δευτέρα, Νοεμβρίου 22, 2004

Piano secrets I

This title is a bit misleading. I do not intend to share the ultimate secret to piano playing because such a secret does not exist. However, I do know some minor facts regarding the physical act of playing the piano that may be of potential interest to some of you.

Touch, strength, sound volume and quality

You may wonder how some famous pianists achieve a wonderful clean, majestic sound quality even in loud volumes, without a trace of harshness. This is very mysterious at first because it seems that the only variable that dominates the impact of the hammer on the string is the speed with which a key is pressed. How can the quality of the sound depend on a single variable that, obviously, mostly influences sound volume? The answer lies in the fact that the keyboard is not a "mathematical model" but a real solid mechanical system and a rapid acceleration can induce a temporary elastic deformation of the lever that bears the hammer. Therefore the hammer-lever-axis system carries energy in two ways, as kinetic energy of the hammer movement and as dynamic energy of lever deformation. The dynamic energy of the system induces an oscillation of the hammer relative to the axis (think of a ruler or a long strip of metal being bent and then suddenly released). Now, the tricky part is that this oscillation is not related to the native frequency of the string and upon impact causes the string to oscillate in its native frequency (clean sound) plus the oscillation frequency of the hammer mechanism (not harmonic, "dirty" sound).

In practical terms this means that if the key is accelerated rapidly then the hammer-lever system is deformed and the sound is "aggressive" and "hard" because of the extra transient non-native frequencies of the string upon impact. If the key is accelerated smoothly, but with a similar final velocity, the sound is equally loud but smoother. This is very intuitive, but hard to achieve in practice: if you hit a key with a rigid hand you force the hammer to accelerate suddenly. A hand in tension causes aggressive sound. A relaxed hand causes smooth sound. Doing this requires tremendous amounts of practice because great playing speed (succession of keypresses) and great energy transfer (speed of hammer on string) is very hard to do with a relaxed hand.

The piano itself can aid or hinder the pianist in his effort for clean sound. High end pianos like Steinway or Bechstein have a comfortable mellow sound without using a very heavy action mechanism. Still, in a high end piano the difference between an amateur and talented professional is even more pronounced. This is good, because it clearly reveals bad piano technique. Most people have trouble realising that their sound is "harsh" and "stressful" when playing on low quality pianos.

Medical knowledge tip: relaxing a muscle requires energy consumption. In a cellular level this happens because when a muscle contracts some proteins move to a "tense" state which can only be reverted with further energy consumpion, but at a much lower cost than contracting the muscle. A tired muscle is unable to relax quickly and this is easily seen in electromyography. Conclusion: when you are tense you get easily tired and when you get tired, you get even more tense. This applies especially to very quick succesive muscle contractions, like the ones in piano playing. Try to relax.


Κυριακή, Νοεμβρίου 21, 2004

Core dump

You are propably wondering what "core dump" means. This is a term used in the old "unix"-type systems to denote a special file, called "core", that was written immediately before a forceful abnormal termination of a program. That file would contain the memory (core) contents of the program before its termination, thereby providing a snapshot of what the program was doing when it crashed.

In many modern unix systems core dumps are by default disabled because end-users have no use for them. A bash shell provides the "ulimit" builtin command that reports the default core file limit. Usually it is set to 0, meaning that core is not dumped when programs fail. You can enable this by setting it to a value large enough to contain the memory contents of your program. Don't forget to periodically check your filesystems for leftover "core" files, possibly with a command like "find / -name core".

The meaningful use of a core file requires a debugger like gdb than can match an executable and its core and produce a human-readable view of the the program's internal state at the time of failure. This is called "post-mortem analysis". Many modern systems try to do that, including Windows XP, by encouraging the user to submit similar "core dumps" or "crash information" to the developers.

In my case, "core dump" is the act of writing out my thoughts in a free form, guided by an occasional inspiration. I strive to print my thoughts and the questions that I face, just like a snapshot of my mind. (possibly also meant for debugging) Some other people also have weblogs called "core dump" so this was not a unique choice. Still, it is quite accurate.


To compress or not? (Music)

I enjoy listening to music, as I'm sure most of you do. The whole idea of copying music to lossy compressed formats (mp3 and the like) never appealed to me, even though I spend quite a few hours in front of a computer. The reasons, briefly, are that I usually use my decent--nothing particularly fancy--stereo equipment and I can't stand the noise of the computer. The reasons why most people love mp3 are also quite clear, namely good-enough-quality, little hard disk space, "coolness" and most importantly massive ripping/downloading/sharing communities.

Recently I bought a nice set of surround (5.1) computer speakers made by Creative (Creative T5400) to use with my Audigy 2 ZS audio card. I was never satisfied with the quality of the onboard audio which, in most cases, is simply not comparable to add-on cards. Spending 60-70 $/euros on an add-on card can really make a difference, in my opinion. Especially USB versions are quite practical and are also isolated from the electrical noise and interference inside the box. I also took some steps to reduce the noise from my computing environment--a topic large enough to become an article in itself, if you are interested.

To cut a long story short, I decided that I could start listening to music from the pc while working. My network bandwidth is very low and I never got involved in this "sharing"-mania that leads other people to collect massive amounts of music. Besides, I enjoy the process of actually buying a CD from a store, looking at the covers, chatting with the salesmen and pondering my various choices. I only rip my own cd collection, a necessary step to prevent several of my favorite CDs from deteriorating over time. I also "recorded" some of my LPs for everyday listening.

I have considered various formats, I even performed my own blind listening tests with my friends. I started with a minimum acceptable of rate ~200 kbps vbr stereo. In this rate, Vorbis was the clear winner over lame. I used lame --alt-preset extreme and an oggenc -q setting that produced the approximate same bitrate. I consider lame to be an excellent choice for those that are tied to mp3 devices (mobile, car audio etc) but I wish vorbis would be more popular. Sadly it seems that the good-enough philosophy has prevailed to such an extent that most people are not willing to consider a free, open-source, superior alternative over mp3 (for those perplexed by the lame and vorbis terms, allow me to explain: vorbis is an open-source variable bit rate audio codec that has been available for a while, files are commonly called ".ogg" but .ogg is the container format, just like .avi is a container format for DivX video, lame, on the other hand, is a popular mp3 compression "engine" that is also open-source and free. You should consider lame if you are using mp3 compression). If you are using the Windows environment you can propably find the OggDS codec for vorbis audio or try the extremely powerful CDex program for ripping.

While I was considering ogg or mp3, each with its own advantages, I encountered the flac codec. Flac is lossless, it preserves all the information in the original file. Now, arguably, most people are unable to hear differences between a CD and a 320kbps mp3 file but for pedantic listeners like me there is a huge bonus in knowing that the compressed file is mathematically (i.e. bit for bit) equivalent to the original. This is especially important for archival purposes and other uses like home recordings or LP-to-digital recordings. Flac can achieve nice compression ratios (approximately 500 kbps for classical music and less than 800 kbps for most modern music) and is playable, unlike other archival formats like zip. The cost of hard disk space is so low these days that there is little purpose in using low-bitrate formats for your CD collection. In 40 Gbytes I managed to fit over 100 CDs and I can use DVD-R for thematic collections (4.7 GB disc = ~12 CDs). Most importantly, unlike lossy compression formats, flac can easily be converted to vorbis/mp3/aac or whatever you prefer in the future, for your portable device or other uses. Recompressing mp3 or vorbis files or any other lossy format is a very bad idea for several technical reasons. I have made a linux shell script (I could post this if anyone is interested) that descends directories recursively and builds medium bit-rate mp3s for my portable device from the "flac archive".

If you are planning to move your CD collection to another media (PC, notebook, DVD-R) you should consider lossless formats (of which flac is just one--albeit my favorite).