pfh's blog

home | blog



~ 1% inspiration, 99% perseveration ~


31 December 2009, 6:50 UTCLazy
71dbb30659a53f3d98dc7b9348db8ba7.mp3

Started by choosing the rhythm this time.

[permalink]


27 December 2009, 22:48 UTC(melodic] clojure

Lisp! An elegant language from a more civilized age. Yet there has always been the matter of having to count brackets, the difficulty of seeing which bracket goes with which.

Users of Lisp and its children cope with this in various ways:

This final method is effective, but still requires counting back the brackets at the end of a function. Text editors help with this, but would it not be nice if you did not need the text editor's help to understand your code?

Suppose we add a tiny bit of syntactic sugar that lets us express a list

(a b c)

as

(a b] c

with the final element of the list after the closing bracket.

I tried this in Clojure, and found the result pleasing. Consider quicksort (from Rosetta Code).

(defn qsort [L]
  (if (empty? L) 
      '()
      (let [[pivot & L2] L]
           (lazy-cat (qsort (filter (fn [y] (< y pivot)) L2))
                     (list pivot)
                     (qsort (filter (fn [y] (>= y pivot)) L2))))))

See how it drifts right. See the final )))))). See how the simpler case is handled first in the if, putting the meat at the end. Now let's apply sugar:

(defn qsort [L]]
(if (empty?] L '()]
(let[ [pivot & L2] L
    ]]
(lazy-cat (qsort] (filter (fn[y]] (< y pivot)] L2
          (list] pivot
          (qsort] (filter (fn[y]] (>= y pivot)] L2)

Note how the function is revealed to be a series of qualifications -- this is qsort, what to do in the base case, some variable definitions -- to a final statement of how to decompose sorting into two smaller sorting problems. Within each line, you can also see similar transformation into series of qualifications. No more )))))), the structure can be seen at a glance.

The let here is a little ugly, it would be nicer to be able to write:

(let variable-name value]

and simply use multiple let statements for multiple assignments.

You'll also note I left the comparisons unsugared. I feel the order of parameters would ideally be reversed for numerical operators. For example, (< pivot] y. Or for an average (/ (count] values] (sum] values. The denominator is usually less meaty than the numerator.


Another example, the Mandelbrot Set task from Rosetta Code:

(ns mandelbrot
  (:refer-clojure :exclude [+ * <])
  (:use (clojure.contrib complex-numbers)
        (clojure.contrib.generic [arithmetic :only [+ *]]
                                 [comparison :only [<]]
                                 [math-functions :only [abs]])))

(defn mandelbrot? [c]]
(loop [ iters 1
        z c
      ]]
(if (< 20] iters  
    true]
(if (< 2] (abs] z
    false]
(recur (inc] iters] (+ c] (* z] z

(defn mandelbrot []]
(apply str]
(interpose \newline]
(for [y (range 1 -1 -0.05)]]
(apply str]
(for [x (range -2 0.5 0.0315)]]
(if (mandelbrot?] (complex x y)
    "#"] 
" "

(println] (mandelbrot)


Download

Here is the patch to Clojure:

Here is a Clojure jar with the patch applied (compiled from git repository as at 19 December 2009):

If you have installed Java, you can use it with:

java -cp melodic-clojure.jar clojure.main

Why Melodic Clojure?

My initial application for this notation was writing musical melodies. For example, this is the music for the Buffens:

F ((G] A] (A] Bb 
A ((G] A] (F] G 
F ((G] A] (A] Bb 
A ((F] G] (G] F

c (d] (c] Bb
A ((G] A] (Bb] c
c (d] (c] Bb
A ((F] G] (G] F

After desugaring, the brackets indicate the division of time before each note. Before desugaring, the brackets indicate the emphasis pattern, the prosody. The deeper bracketed notes are given reduced emphasis.


--> See Metrical Phonology. For Melodic Clojure perhaps follow these rules:

[permalink]


13 November 2009, 0:44 UTCMariology

I've been reading Harvey Cox recently, in particular "The Seduction of the Spirit", which contrasts the use of religion to maintain the status quo against religion as a tool of liberation.

I had an ah-ha! moment with his comments on mariology. Worship of the Virgin Mary, and belief in the Assumption, is to him a much more obvious invention than the rest of the Christian story. Nevertheless, Mary is a potent element of South American liberation theology. He could sense the same kind of power from it that he did in other forms of worship, despite thinking it pretty idiotic considered as a true story.

I think you could take Cox's attitude to religion, remove all the counterfactual elements from it, i.e. the God bits, and still retain its core: what he calls "interiority", by which I think he means an inner symbolic life and story, and collective interiority in which there are shared symbols and stories. He's big on images and stories.

We have the same experiences, feel the same feelings. You call it holy. We interpret it differently.

We could make up stories and images, and build a community around them. We could decompose the human condition into independent components, and make visual icons for each component. An iconography.

Of course this goes on all the time already.


Why didn't Humanism take off? Well take a look at their anemic idol. Who could love this guy? This is not the product of a healthy culture.

[permalink]


6 October 2009, 0:13 UTCI made a music

866dc6ee9dee76283e33a1f3923768e5.mp3


and another:

2b33fa22c066361ebf85b540f94ba5d0.mp3

This one is for a procession, with the throwing of flower petals, people in masks cavorting and turning as they proceed, wearing little bells, straw statues on wheels. That manner of thing.

[permalink]


28 September 2009, 22:29 UTCExperiment in music visualization
In equal temperament, factors of 2, 3, and 5 can be approximated by 12, 19, and 28 semitones respectively.

We can approximately factorize a note n (given in semitones) with:

12a + 19b + 28c = n

Where a, b, and c are integers. This is a "Diophantine" equation. It has multiple solutions, representing multiple possible factorizations. These solutions turn out to form a two-dimensional grid in the three-dimensional (a,b,c) space.

We can change our parametrization of this space so that one dimension is normal to the grid, and two of the dimensions are co-planar to the grid and wrap onto themselves.

We can do this, but is it a worthwhile exercise?

Consider the tune (selected entirely at random) Buffens from Arbeau's Orchesography. The top line is Arbeau's melody, the bottom line is a counterpoint of my own invention.

Buffens MP3 / Newer version / Newer version, slower


Let's visualize this in the three dimensions (one of unlimited extent, and two wrapped on themselves). Green is Arbeau's melody, blue is my counterpoint.

I've named the first dimension "Melody", since it's a straightforward mapping of the semitone value. You can see Arbeau's smooth melody line. The inspiration for this is The Music Animation Machine.

The second dimension I name "Progression", since this is what you can see in it. Roughly speaking, it has to do with movement by perfect fifths (factors of 3). Upward motion creates a pleasurable tension, and downward motion is conclusive.

The third dimension I name "Tonality", since the notes of the diatonic scale are tightly clustered in this dimension. Roughly speaking, it has to do with movement by major thirds (factors of 5). If key changes were present in a piece, they would be seen in this dimension.


Ok, so. Let me try to explain the C Major diatonic scale. I'm going to show an extract from the circle of fifths, and another extract below that, so that major thirds are lined up.

       
   (B  F# C#)
... G  D  A  E  B  F# C# ...
... Eb Bb F  C  G  D  A  ...            

        II IV I  V
        ?

-- note the similarity to the Stradella bass system on accordions.

Imagine a line running from D on the first line through D on the second line. Movement along this line is the progression dimension. Movement vertically away from this line is the tonality dimension. So here F# and Bb are furthest from the line, and can be used as a brief departure from the tonality.

Below this I've named some chords. Each chord applies to the block of four notes above it. For example, I has E, B, C and G. Progression likes to move left, descending by fifth. The chord marked II you get some bonus notes to play with, F# or Bb or maybe even C#. Or you can just stick to I-IV-V-I, that is perfectly fine apparently.

Using both notes on a "/" diagonal in a harmony, such as C and B, would stretch the tonality a bit far (unless that's the effect you want). However for a sense of fullness in the tonality you do need notes from both lines, and for a sense of fullness in the progression dimension you want notes from the left and right columns of the block. So in this sense the minor third (eg E-G) is the nicest harmonic interval, in that it gives you fullness in all dimensions without stretching any too far.


This seems to be a workable system within which to refine a composition. Here's something I whipped up with a little tonal excursion.

noodling.mp3

and maybe a little

wobbling.mp3

[permalink]


16 September 2009, 23:12 UTCI want to send a Robot to the Moon that trundles around making Statues out of Moon Rocks
I don't know why.

Yes I do.

Fuck this science shit, lets start making stuff on other planets. Let's start making stuff out of the stuff of other planets.

This feels wrong, doesn't it? Well, that's a messed up feeling. There's no environment on other planets to preserve. They're just dead rocks, and that's a bad thing, they're just dead rocks unless we do something about it.

[permalink]


13 September 2009, 0:13 UTCTed Talk: Temporarily disabling the ability to think about other people's motivations using Transcranial Magnetic Stimulation

This is a start at addressing a weak point in my theory of why people are somewhat good.

See also.

[permalink]


7 September 2009, 8:44 UTCOh Yes I Kan
I have just read a book that made sense of a great many things: Architectural Ornament: Banishment & Return, by Brent C. Brolin. I now know the name of my enemy, and knowing the name of one's enemy is a very good thing.

The name of my enemy is Kant's concept of genius.

Genius, according to Kant, is the ability to create new things. Crucially, this ability can not be described scientifically. No rule can be given that produces the things that genius produces. It can not be learnt.

This is a very comforting idea, and has proven popular. People thought to have this quality of genius are given high social status. It fills a much needed gap in people's minds with the idea that worthwhile artistic or even scientific expression is something that one brings forth from within. This is a gap that might otherwise be filled with skill acquired by study, and by trying things out and mostly failing.

Furthermore, geniuses don't fully understand their own abilities. Pat pat. Don't try to explain your process. We'll love you more if you say it is magic.


My counter-concept is that the key ingredient of "genius" is just to be able to recognize success. To select accurately. Beyond this, it is simply a matter of generate and test. You get better at generating with practice. Anyone with the ability to appreciate good art also has the ability to create it by this method, given sufficient time.

Evolution by natural selection is a good example of this. God is the ultimate Kantian genius, and evolution shows that He is unnecessary. Many people find this discomforting, it at once destroys God and denies their own access to transcendent genius.


If we turn this concept in on itself there is a most wonderful idea to arrive at. It might at first seem that Kant's concept of genius precludes the construction of an intelligent machine. However we can get around this simply by constructing a machine that we can not understand. Genius can beget genius. Thus: the Artificial Neural Network. Computer scientists are easy prey for this. Their time could be better spent getting a haircut and learning some real statistics.

This explains the strange feeling I have had that my experiments in music generation are a little bit monstrous. They are monstrous because I understand them. If I were to use something more mysterious, such as a cellular automaton, neural network, or genetic algorithm, the problem would not arise. You will find a lot of this kind of thing, the results are usually terrible as music.

David Cope's approach to music generation by pastiche is similarly monstrous.


I expect I shall have more to say on this in future.


10/9/09: Jiri notes the "neats vs scruffies" debate in AI. In my experience, scruffy code motivated by neat concepts often beats pure neatness or pure scruff. Scruff gets the wrong answer, and neatness is too slow. Computational efficiency is an issue I haven't addressed above.

[permalink]


3 September 2009, 6:55 UTC"Is this person, in general, a sufficiently helpful sort?"
Julian Sanchez has some very clever stuff to say about free-riding, which is of course relevant to software production.

He writes:

Because an individual act of free-riding may be part of a pattern of behavior that is, on net, both efficient and fair, for certain types of cases it may be that we want to ask, not: "Has this person acted correctly in this case?" but rather "Is this person, in general, a sufficiently helpful sort?"

This reflects my own current position. Contrary to the usual model used in economics, people are somewhat good. We should try to quantify this, develop social institutions that increase the strength of this effect, and engineer situations where it can express itself.

I have in the past favored classical economic solutions. However this is more powerful, I think.

[permalink]


27 August 2009, 3:56 UTCRenaissance dance: 15th century Italian saltarello and quadernaria

This is material for a class on the saltarello and quadernaria for St. Vitus Dance Weekend 2009.

Handout (PDF)

Ferretra (modern composition to fit dance description) - Sheet music (PDF) - part 2 only - slower version - slower version of part 2 only

Voltati in Ca Rosina - slower version

Update 3/8/2009, 15/9/2009: Discussing this with a couple of cluey musicians at the St. Vitus Dance Weekend in Politarchopolis, it emerged that the saltarello rhythm seen in at the start of Tesara may actually be:

* - - * -** * - - * -** * - - * -** * - - * -**

and not

* - * * * - * - * * * - * - * * * - * - * * * -

as given in Smith's book.

My reconstruction of the saltarello step is readily adapted to this. However the link with quadernaria becomes less clear.

In "Joy and Jealousy" this rhythm is used in the music for Tesara. However in other places, such as in la Ingrata, the rhythm seen in Smith's book is used, for music with identical notation in the original manuscripts for music with very similar notation. This requires us to believe, for music corresponding to the same dance step, that the dot represents a punctus divisionis in the sequence semibreve-minim-dot-minim-semibreve and a punctus additionis in the nearly identical semibreve-minim-dot-minim-minim, in Paris, B.N., Ital. 972. The alternative would be to ascribe the difference to scribal error, the final semibreve is off-beat and perhaps feels small.


In Joy and Jealousy's version of sections III and IV of Tesara, the familiar semibreve-minim-dot-minim-semibreve is treated as a scribal error. If you examine other music, you will see that this pattern is far more common than semibreve-minim-dot-minim-minim. On balance I think it is more likely that the former pattern is the scribal error, and prefer to retain my original interpretation.

[permalink]



5 August 2009, 11:14 UTCNew bioinformatics software: nesoni, and updated treemaker key-value store
25 June 2009, 13:52 UTCA nasty story pattern
18 June 2009, 6:57 UTCDo I win a prize?
6 June 2009, 22:38 UTCA key-value data warehouse
5 May 2009, 22:37 UTCTordion and Galliard beat patterns
11 April 2009, 14:04 UTCOld Measures
8 March 2009, 8:34 UTCMusic synthesis by physical modelling: ChucK
21 February 2009, 6:24 UTCQuerying intervals efficiently in SQL + Python revisited
18 February 2009, 6:17 UTCQuerying intervals efficiently in SQL + Python
18 January 2009, 20:50 UTCSketchifier
12 January 2009, 8:51 UTCThis is not a tilt-shift photograph
29 December 2008, 3:53 UTCThe Problem of Good, a Platform Game
21 December 2008, 22:39 UTCThe rise and fall of Christianity in Europe
26 November 2008, 3:37 UTCReligious logic gate
17 November 2008, 9:02 UTCGame theory's influence
4 November 2008, 5:48 UTCKin selection: a worked example
18 September 2008, 22:36 UTCFluff
17 August 2008, 10:11 UTCFurther violence done to time
9 August 2008, 8:20 UTCMythical
24 June 2008, 21:43 UTCMore drum beats

All older entries

Google
Web www.logarithmic.net



[atom feed]  
[æ]