Electronic Music II: Programming and Electronics for Art & Music

Music G6602
Thursday 3-5pm, Room 320H Prentis Hall
Spring 2013
hello.
Professor: Douglas Repetto [douglas at music columbia edu]
TA: Natacha Diels [ndd2117 at columbia edu]
hello.
Our Motto: "Why and how."
hello.
syllabus | schedule

Some Simple Algorithms


Star-shaped imitation game

Sit in a circle with an odd number of people. Each person looks at the person N people to their right. N is chosen so that a complete star is formed by a virtual line drawn from each looker to each lookee. The rule: Do only what the person you're looking at does; otherwise, do nothing.


Human oscillators

Flip flops: two states -- hand up/hand down
* a: do what b does; b: do what a does
* a: do what b does; b: do the opposite of a
* try other rule sets: 3 person triangle, big ring, long line, spoke & wheel, etc

Squeeze and yelp circle: sit in a circle holding hands. When someone squeezes your hand you yelp and pass the squeeze on via your other hand. Someone seed the circle...

Lap sit circle: stand in a circle. Everyone sits, slowly, on the lap of the person behind them.


Quick Hummus *

Traditional hummus involves soaking and boiling dried garbanzo beans for hours. This great recipe gives you the same great taste without all of the time and effort.

* 4-6 cloves garlic
* 2 cans garbanzo beans -- drained and liquid reserved
* 4-6 T. sesame paste or smooth peanut butter
* 2 handfuls fresh parsley or cilantro leaves
* Juice of 2 lemons
* 2 pinches ground black pepper
* 2 pinches salt
* 2/3 c. extra virgin olive oil

Chop the garlic finely in a food processor. Add the beans and 1/2 of the reserved liquid and process finely or to desired consistency. Add the sesame paste or peanut butter, parsley or cilantro, lemon juice, black pepper and salt. Process the mixture until it forms a paste. Drizzle in the olive oil and process until it reaches the consistency of mayonnaise.

* Yields: 8 servings
* Preparation Time: about 10 minutes


Sine Wave Generator

y = sin(x)
(what's a unit circle?)


Tooth Brushing Algorithm*

    Brushing your teeth
        1) Go to bathroom
        2) Find toothpaste and toothbrush
        3) Turn water on
        4) Wet toothbrush head
        5) Turn water off
        6) Place toothpaste onto brush
        7) Turn water on
        8) Wet toothbrush with toothpaste
        9) Turn water off
        10) Begin to brush each tooth in your mouth for two minutes
        11) Rinse mouth
        12) Rinse toothbrush
        13) Return toothbrush and toothpaste to storage place
        14) Exit bathroom

    Assumptions:
        * Water is turned on
        * Have a toothbrush and toothpaste
        * If the bathroom is available
        * Motivation is there to brush your teeth
        * Time to brush teeth?
        * What if you drop your toothbrush in the toilet on accident?

    Pseudocode:
        Go to bathroom
            IF available THEN
                Sequence 1: FUNCTION = proceed with brush teeth
            ELSE not available  THEN
                Sequence 2: idle until available
        FUNCTION:
            IF toothbrush and toothpaste are present THEN
                Sequence 1: place toothpaste onto toothbrush, brush teeth
            ELSE not available THEN
                Sequence 2: leave bathroom

        Clean toothbrush
        Leave Bathroom
    


Mensuration Canon *

The Four Voice Canons are orchestrations of one idea. Each is a mensuration canon, in which successive voices enter later and move proportionately faster. Consequently, the density and rhythmic complexity increases from beginning to end. Each voice is a list of all the possible permutations of 4 or 5 elements. This list of permutations, generated by the computer, is ordered by a simple algorithm from elementary group theory: the next element in the list must be as close as possible to the previous by a 2-transposition, meaning that two items from each permutation are interchanged to form the next element in the list. For example, for four elements ABCD, a possible ordering might be: ABCD, ACBD, DCBA, and so on. Each piece in the set is a four voice canon of the same list of permutations, but the values are applied to different musical parameters.


A Simple Fractal Algorithm *

Take a line
Erase the middle
Bring each of the resulting lines back in and do it again


Hill Climbing *

In hill climbing the basic idea is to always head towards a state which is better than the current one. So, if you are at town A and you can get to town B and town C (and your target is town D) then you should make a move IF town B or C appear nearer to town D than town A does. In steepest ascent hill climbing you will always make your next state the best successor of your current state, and will only make a move if that successor is better than your current state. This can be described as follows:

1. Start with current-state = initial-state.
2. Until current-state = goal-state OR there is no change in current-state do:
1. Get the successors of the current state and use the evaluation function to assign a score to each successor.
2. If one of the successors has a better score than the current-state then set the new current-state to be the successor with the best score.

Note that the algorithm does not attempt to exhaustively try every node and path, so no node list or agenda is maintained - just the current state. If there are loops in the search space then using hill climbing you shouldn't encounter them - you can't keep going up and still get back to where you were before.

Hill climbing terminates when there are no successors of the current state which are better than the current state itself.


A Simple Genetic Algorithm

1. Generate initial population
2. Measure fitness
3. Select a mating pool
4. Mutate each member of the mating pool
5. Pair members of the mating pool and perform crossover to obtain a new generation
6. Return to 2 until some stopping condition is satisfied


Change Ringing *

"The art of change ringing is peculiar to the English, and, like most English peculiarities, unintelligible to the rest of the world. To the musical Belgian, for example, it appears that the proper thing to do with a carefully tuned ring of bells is to play a tune upon it. By the English campanologist ... the proper use of the bells is to work out mathematical permutations and combinations." -- Dorothy L. Sayers, The Nine Tailors

Here is a simple method on 5 bells, Plain Bob Doubles. In the version with all the numbers written in, I've marked the second bell in bold text so you can see the pattern more easily, and in the other one, I've marked the second bell with a *. Except for some practice exercises for learners, ringing a method always starts at rounds, that is, all the bells ringing in order of their number, giving a descending scale of pitch. Observe that for most of the time, it is hunting, that is, simply moving between front and back, one place at a time, and making two blows at each end of its range. When the treble (bell 1, marked with a . ) is leading (i.e. ringing first in the change) the other bells dodge instead of hunting. The treble hunts continuously -- this is described as a treble hunt method. In all methods, the treble does something different from the other bells (there are also some principles, which are not methods, but are similar, in which all bells do the same thing; Stedman's is the best-known principle); either it hunts, or does ``treble bob'', which is more elaborate, or hunts just between places 1 and 4 (``little bob methods'').

Looking at these diagrams of Plain Bob, you can see that if the other bells did not dodge when the treble leads, all the bells would be doing plain hunt, and would come round (i.e. back to rounds) at each lead end, that is, when the treble makes its second blow in the lead.

To ring a longer touch, the conductor will call bobs and singles at the lead ends. When one of these is called, the bells do some variant of dodging, so that the touch will not come round yet.


Simple Pseudo-Random Number Generator *

int rand()
{

random_seed = random_seed * 1103515245 + 12345;
return (unsigned int)(random_seed / 65536) % 32768;
}


A Silly Game

Sit in a circle.
Pick one person to start.
That person says any word.
Moving counter-clockwise around the circle, each person says the first word that comes into their mind in response to the previous word.
Try to move the words around the circle as quickly as possible.
Continue until everyone is hysterical.


Exquisite Corpse *

"Exquisite corpse, also known as exquisite cadaver (from the original French term cadavre exquis) or rotating corpse, is a method by which a collection of words or images is collectively assembled. Each collaborator adds to a composition in sequence, either by following a rule (e.g. "The adjective noun adverb verb the adjective noun") or by being allowed to see the end of what the previous person contributed."