Latest post

Twinkle twinkle little star is a short musical piece I composed and recorded last evening.

This piece consists of 56 measures. It is 1 minute 52 seconds long. The music is composed of four tracks. This is my second attempt at recording music with multiple tracks. The last such attempt was more than two years ago when I composed and recorded 'A few notes'.

The links to the audio files, sheet music, etc. are provided below. The files reside in my website. In case, my website is down, the YouTube link provided below should still work.

The four tracks in this piece are:

  1. Grand piano
  2. Slow strings
  3. Xenon pad
  4. Music box

This arrangement is based on the popular melody of the nursery rhyme called Twinkle, twinkle, little star. The melody is played with the treble notes of the piano. I wrote the bass notes for the piano and the strings, and the high notes for the pad and the music box to fill the music with emotions of love and happiness. I recorded this after about two hours of practice.

Random post

I spent the last evening experimenting with sound and colours.

Listen to this audio first. If you are unable to play the audio in the browser, use the download link below it to download and play it on your system.

You will hear two pairs of tones separated by 2 seconds of silence. Each tone is 2 seconds long. The first tone has a frequency of 100 Hz. I won't tell you the frequency of the second tone right now. But you should notice that it is a little greater than the frequency of the first tone. You'll need good earphones to listen to this. Most laptop speakers can not play these low frequency tones well.

The third tone after the silence has a frequency of 400 Hz and you'll have to wait a little to know the frequency of the fourth tone.

Now, try to answer this question. Is the difference in frequencies in the first pair of tones equal to that of the second pair of tones? If you feel they don't sound equal, which difference sounds greater?

I hope you find the first change in frequency greater than the second one because that's how a normal human brain is supposed to perceive these differences in frequencies. If you do, you might be surprised to know the frequencies of the second and the fourth tone. The frequency of the second tone is 110 Hz and that of the fourth tone is 410 Hz. Yes, there is a difference of 10 Hz in both cases. Why then does the first difference sound greater than the second one? In fact, the first difference would sound roughly four times greater than the second difference. Why?

We sense pitch in a logarithmic fashion. Let me explain what this means. Let us consider a strange company which pays you one gold coin for every 2 days you work. Your income is directly proportional to the number of days you work. The number of gold coins is always half the number of days you work. You earn the gold coins in a linear fashion. The graph looks like this:

Now consider another company which pays one gold coin if you work for 4 days, two gold coins if you work for 16 days, 3 gold coins if you work for 64 days and so on. In other words, you earn n gold coins if you work for 22n days where n is a positive integer. The graph looks like this:
Note that the graph is no longer a straight line. That's why, in this case, the income is not said to grow linearly with the number of days of work. But note that the number of gold coins earned is half that of the exponent to which 2 is raised to equal the number of days. So, if we plot a graph of the gold coins earned versus these exponents, we should get a graph similar to the one we got for the first case. Have a look:
Note that the x axis is log2(number of days of work). log2(n) is the exponent to which 2 has been raised to equal n. So, we see that in this case, the number of gold coins earned is directly proportional to the logarithm of the number of days of work. Hence, the income here is said to be in a logarithmic fashion.

Similarly, the perception of pitch is directly proportional to the logarithm of the frequency of the sound.

There is another interesting thing to note in the second example. You earn one gold coin for 4 days of work. After 4 days, to earn an extra gold coin, 12 extra days of work is needed. The number of extra days required to earn an extra gold coin is 3 times the number of days of work done so far. This pattern holds throughout the graph. For example, after earning three gold coins with 64 days of work, 192 extra days of work is required to earn the fourth gold coin. This pattern holds true if you want to analyze how much extra effort is required to increase your income by 2 gold coins or any number of gold coins you want to consider. Try it.

So, at any point, to earn a certain number of gold coins, the number of extra days of work required is directly proportional to the number of days spent in work so far.

Our perception of pitch of sound is similar to the number of gold coins earned in the second case. The change in frequency (frequency of the second tone - frequency of the first tone) required to cause a certain perceived change in pitch is directly proportional to the frequency of the sound one is hearing. So, At 400 Hz, we need a change of 40 Hz to create the same effect as a change of 10 Hz at 100 Hz. The following audio demonstrates this. The fourth tone in this audio has a frequency of 440 Hz.

Let us see why such a relation between perceived change in frequency, actual frequency and actual change in frequency implies that our perception of pitch is logarithmic.

Let dp be the perceived change in frequency. Let df be the actual change in frequency. Let f be the frequency at which the change occurs. As per the discussion above,

dp ∝ df / f ⇒ dp = k · df / f, where k is a constant

Let us integrate both sides of the equation.

dp = k · df / f ⇒ p = k · ln f + c, where c is a constant

So, here we can see that the perceived pitch is directly proportional to the logarithm of the actual frequency. Now if we represent the first actual frequency as f1st, the second one as f2nd and the corresponding perceived changes in pitch as p1st and p2nd, the perceived change in pitch is:

Δp = p2nd - p1st = (k · ln f2nd + c) - (k · ln f1st + c) = k · ln f2nd - k · ln f1st = k · ln (f2nd/f1st)

So, when you hear a change of 10 Hz at 100 Hz, you perceive a change in pitch of k · ln(110/100) = 0.095k. However, when you hear the same change in frequency at 400 Hz, you perceive a change in pitch of only k · ln(410/400) = 0.024k.

I tried to do a similar experiment with colours: http://susam.in/downloads/files/weber-fechner/color.html. Just like the sound experiment, here the intensity of blue increases from 20 to 40 in the first change and 200 to 220 in the second change. However, I don't think the perceived change in brightness in the first instance appears to be greater than that of the second one. I find both the changes to be almost equal. So, does Weber-Fechner law not work here? The Wikipedia article on Weber-Fechner law mentions that the eye senses brightness approximately logarithmically. Is there a flaw in my experiment?

For a moment, I thought that perhaps, the intensity of blue I am specifying in the RGB code is not directly proportional to the brightness of the color. But the formula GIMP uses to calculate the grayscale brightness from a color image implies that the brightness is directly proportional to the intensity of blue we specify in the RGB code. Or is it that the intensity we specify in the RGB code is already directly proportional to the logarithm of the brightness?

A related post: Listening to superimposed waves.