Sunday, June 17, 2012

Library

Reasons for using library to structure program:

(1) share common functionality
(2) convenient upgrade rather than replacing multiple executables
(3) separate of interface and implementation
(4) improve start up time and memory footprint by loading what is needed
(5) dynamically replaceable
(6) different version for different platform

Calls to library have a higher overhead than normal call because:
(1) library call may be implemented using a table of jump addresses
(2) library and its data is usually placed into new TLB entries. Calls to library could trigger TLB misses
(3) lazy load overhead during run time
(4) use of position-independent code (address reference relative to current executing location) to allow sharing but also increase code length.

Process and Thread

An application comprises instructions and data.  Before a program runs, it consists of instruction and initialized data sections on the disk.

A process contains instruction, data and states.  State is a set of value held in the registers, address of current instruction, values held in memory and flags.  State is private to the process itself unless it is explicitly set up to share.  In memory, a process contains the text, initialized data, uninitialized data, heap, stack, library and linrary data.

A thread has some state but basically just the regiesters and the stack.  Each thread has its own stack.

Sunday, June 3, 2012

Type of classical music

The most common type of classical music played by an orchestra are symphony and concerto. A symphony involved a hundred of players but not all of them playing at the same time. The tune is passed around from group to group and occasionally is played by full together. A symphony composes of 3 or 4 pieces of tune with short silence in between.

A concerto include a soloist playing with the orchestra. Bach and composer of his time usually group 6 short pieces of music into a suite. Suite typically starts off with a prelude (before-play) follow by dances which merely means they have the distinctive rhythm of certain dances.

Sonata are pieces written for 1 or 2 instruments and contain 3 or 4 movements. A piano sonata is written for piano. A violin or cello sonota has piano accompaniment.

String quartet is written for 2 violin. 1 viola and 1 cello. String trio takes away the 2nd violin. String quintet is a string quartet with an additional cello or viola. Piano quintet adds a piano to the string quartet.

Fugue is a piece with lots of counterpoints.

Cantata is a choir with orchestra and sometime with a solo singer. Chamber music is written for about 10 musicians performing in a room. Lieder (German word for song) is a singer with piano accompaniment.

Classical music is identified by number preceded by K and BWV which representing different catelogues.  Opus means piece of works of a composer published in chronological sequence.  The piece of music usually is of high quality to get published.

Modes

Sometime before 300 B.C., Greek uses different system of tones and semitones to divide the octave up and named them to people or neigbouring areas.  The Christian Church develop a method of singing called Gregorian Chant at 750 onward which uses 7 scale patterns with random Greek names.

There are 7 modes:

Ionian - WWHWWWH - major key

Dorian - WHWWWHW - mostly used in Celtic music and American folk songs originated from Irish melodies.  It gives a melancholy and soulful as the last note does not sound so resolved, like a question unanswered

Phrygian - HWWWHWW - middle east like tune.  Brighter and less melancholy than minor key.  Interval pattern is similar to Aeolian.

Lydian - WWWHWWH - with most of the intervals similar to Ionian mode except the third and forth position.  Bright as major key but with uncommon interval

Moxilydian - WWHWWHW - similarly close to Ionian mode.  Good for counterpoint to Ionian melody

Aeolian - WHWWHWW - natural minor.  If Dorian is melancholy, Aeolian mean despair.

Locrian - HWWHWWW - uncommon

The basic feel of Dorian is very close to minor which is not surprising as the different between Dorian and D minor is only 1 note (B to Bb).

Lydian and Moxilydian sound close to major key as there is only 1 note difference in semitone.  They sound slightly less definite and unambiguous.

Dorian and Phrygian sound close to minor key.  Locrian is the odd ball and not commonly used.

Identifying keys

C major and A minor use the same set of notes.  How do the ears know which key is playing.  The answer is on the emphasis.  If  C, E and G is the favourite, particularly using C as the end of the phrase, the music will have a major key feel.

Alternatively, if A, C and E is the favourites and ending with A frequently, the music will have a minor feel.

Modulation

The most common type of modulation is to change to the key which has 1 note different.  For example, from C major to G major:

C, D, E, F, G, A, B to G, A, B, C, D, E, F#

We subconsciously sense the change of the team leader (tonic) from C to G.  Althernatively we could change from C major to F major which contains all notes from C except B falls to Bb.  The emotional impact usualy lasts for a short duration (10 of seconds).

Composer usually modulate a phrase to key with many different notes to inject more interest.  For example from C major to E major.  Changing the key a semitone above or below brightens up the music.  This is known as truck driver's modulation.

Changing from a major key to minor key add further interest to the mood.  Modulate too frequent may confuse the audience while too little makes the music bland and predictable.

Sharp and Flat in Keys

Even though the same note can be called sharp or flat (e.g Eb = D#), the key to name notes is to avoid using the same letter twice.  For example, the following uses D and A twice.

A major: A, B, Db, D, E, Gb, Ab, A

The practices is to use each letter only once and use either # or b for all notes in the key

E major: E, F#, G#, A, B, C#, D#, E
Bb major: Bb, C, D, Eb, F, G, A, Bb
B major: B, C#, D#, E, F#, G#, A#, B

Saturday, June 2, 2012

Notes in chord

When a note is produced from a musical instrument (e.g. pull a string), it was a combination of the base frequency and its multples.  For example, the note A will contain the base frequency 110Hz and its multiples like 220Hz, 330 Hz etc.  The combimation depends on the position the string is pulled.  If the string is pulled in the middle, the frequency combination will be 110, 220, 440 (i.e. multiple factor of 1, 2, 4, 8... etc).  If the string is pull at the third position, the frequency combination will be 110, 330, 660 etc).

A chord is a contains minimum 3 notes.  The dorminant (5th note) is 1.5 times frequency of the tonic.  The third node is 1.25 times frequency of the tonic. When these 3 notes are played together, there are many common frequency and thus the output sound very harmonic.  For example, A has frequency of 110Hz.  E, the dorminant note has frequency of 165Hz.  They have a common frequency of 330Hz and thus they sound harmonic together.

For a minor chord, the third note is changed to have a relative frequency of 1.2 which has less strongly links to the other 2 notes.