Basic Electroacoustics II: Programming and Electronics for Art & Music

Music G6602
Tuesday 3-5pm, Room 313 Prentis Hall
Spring 2010
hello.
Professor: Douglas Repetto [douglas at music columbia edu]
TA: Damon Holzborn [damon at zucasa dot com]
hello.
Our Motto: "Why and how."
hello.
syllabus | schedule

Some Simple Algorithms


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)


Tooth Brushing Algorithm *

1. Walk to the bathroom
2. Open the tube of toothpaste
3. Pick up the toothbrush
4. Run water over the brush (if desired)
5. Squeeze a small blob of toothpaste onto the bristles of the toothbrush
6. Brush all teeth on all sides possible
7. Spit excess saliva and toothpaste into the sink
8. Run some water to wash recently spit stuff down the drain
9. Run approximately 3 ounces into mouth
10. Swish around briefly
11. Spit water into sink
12. Repeat mouth rinsing as desired
13. Rinse toothbrush and sink
14. Close toothpaste tube
15. Hang up toothbrush
16. Turn off water

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 climibing 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 *

Among Surrealist techniques exploiting the mystique of accident was a kind of collective collage of words or images called the cadavre exquis (exquisite corpse). Based on an old parlor game, it was played by several people, each of whom would write a phrase on a sheet of paper, fold the paper to conceal part of it, and pass it on to the next player for his contribution.

The technique got its name from results obtained in initial playing, "Le cadavre exquis boira le vin nouveau" (The exquisite corpse will drink the young wine). Other examples are: "The dormitory of friable little girls puts the odious box right" and "The Senegal oyster will eat the tricolor bread." These poetic fragments were felt to reveal what Nicolas Calas characterized as the "unconscious reality in the personality of the group" resulting from a process of what Ernst called "mental contagion."