Archive for the ‘misc’ Category

Metaphors of javadoc

Friday, December 11th, 2009

Conceptual metaphor theory holds that our understanding of the world is largely structured by metaphor.   This presumably includes our understanding of computer programs, which is the basis of Metaphors we Program By: Space, Action and Society in Java, a paper by Alan Blackwell. The paper shows analyses of documentation for some standard Java libraries, looking for the metaphors that structure human understanding of the library components and their interactions. I’ve taken the liberty of extracting the metaphors related in the paper but if you’re interested you should go and read the whole thing, it’s a good one. I feel I could meditate on this list for some time, and I’d love to see comparisons with the metaphors used in the documentation of other languages.

  • Components are agents of action in a causal universe.
  • Programs operate in historical time.
  • Program state can be measured in quantitative terms.
  • Components are members of a society.
  • Components own and trade data.
  • Components are subject to legal constraints.
  • Method calls are speech acts.
  • Components have communicative intent.
  • A component has beliefs and intentions.
  • Components observe and seek information in the execution environment.
  • Components are subject to moral and aesthetic judgment.
  • Programs operate in a spatial world with containment and extent.
  • Execution is a journey in some landscape.
  • Program logic is a physical structure, with material properties and subject to decay.
  • Data is a substance that flows and is stored.
  • Technical relationships are violent encounters.
  • Programs can author texts.
  • Programs can construct displays.
  • Data is a genetic, metabolizing lifeform with body parts.
  • Software tasks and behaviour are delegated by automaticity.
  • Software exists in a cultural/historical context.
  • Software components are social proxies for their authors.

I’ve written about Alan Blackwell’s research before.

Then this morning I saw this tweet:

<laputean> “hello world” programm is the ‘perfect’ starting point of fastidious and wrong epistemological assumptions that one carries for all life

A neat reminder that the ways in which we perceive the workings of computer `agents’ and source code is very much within a particular social context.

The iPhone and toilet paper freedom

Wednesday, November 11th, 2009

Geoffg is playing a lawyer in declaring his interpretation of the GPL as the truth, lambasting the Free Software Foundation for not updating some old articles, accusing them of spreading FUD and declaring the iphone as a missed marketing opportunity.

He makes the mistake however of reading the GPLv2 as a definition of freedom, rather than an implementation of it. As this fine person pointed out last year, it’s no good being able to change software if you can’t run it. This is the freedom to change software and use it as toilet paper.

Fine, maybe you can run GPLv2 software on your iphone, but you can’t exercise all the freedoms which the FSF campaign for. According to them, GPLv2 software in closed DRM is exploiting a loophole which GPLv3 was in part written to close.

I can see it’s difficult for people to reconcile their love for free software and their love for Apple products, but maybe it’s best to be mindful of the fact that you’ve bought a computer that you can’t run software on without the permission of a large corporation.

There’s a lot of weirdness in the computer music community around this. RJDJ is a port of the free PureData language to the iphone. Many of those involved are free software developers, but have to give up all their rights to RJDJ, a venture capital funded company. RJDJ in turn license the code back to them under the GPLv3. This means they are free to change and run the code under open operating systems, but not on the iphone. This is weird, using the GPLv3 as a firewall to protect commercial interests on a closed platform, while exploiting the work of a free software community.

Just to clarify; I’m not saying that people shouldn’t run open source software on the iphone, particularly when a permissive license like MIT or BSD is involved. I’m just objecting to ignorance of the FSFs definition of software freedom, which I happen to subscribe to and which is incompatible with the iPhone. I find the RJDJ case weird, but while I know of at least some cognitive dissonance in the RJDJ team, I don’t know that any of the authors are otherwise unhappy with the situation.

UPDATE: Michael from RJDJ contacted me to point out something I got wrong. RJDJ don’t release their whole iphone port of PureData, just part of it — rjlib. This is indeed released under a GPLv3 though; if you want to contribute towards rjlib, you have to transfer your rights to RJDJ or fork the code.

BTW they are also releasing a rather nice looking cross-platform gui-less version of PureData under the LGPLGPLv3 and LGPLv3 called zengarden.

Hackpact documentation (week 2)

Tuesday, September 8th, 2009

Following on from week 1 of my hackpact hacks, here’s

hackpact8

I had this feeling that a nice visualisation of polyrhythmic structure would be to plot patterns in a spiral. I finally got it to work, and here’s the first few results, rendered with cairo in Haskell:

{red blue orange purple, yellow brown pink}
spiral1
[red blue orange purple, yellow brown pink]
spiral2
{orange tomato, blue ~ purple ~ ~}
spiral3
{orange yellow, blue green ~}
spiral4

Where colours co-occur, they’re mixed, thanks to the lovely Haskell Colour library.

I was surprised by the rhythmic gestalt these give. In retrospect I realise that Mick Grierson would not be surprised at all by this, and neither would John Whitney. Now I’m a spiral lover too.

I’ll release the code along with the rest of my pattern library next week.

hackpact9

Played around with spiral rendering, but came to conclusion that the spiral mapping itself was beautiful and not the patterns I’m trying to visualise, because just about anything you put into it looks good.  Although you can see the pattern length in the spiral, if you mix different pattern lengths into a polyrhythm, it’s very difficult to perceive more than one pattern length, one comes across more strongly than the others.  Perhaps a peano weave would be better, but I think I’ve gone far enough with this, back to music tomorrow.

beautyinthemapbluetree

hackpact10

My lack of headphones bit me so I couldn’t make music tonight.  Instead I played with context free art, which I’ve been meaning to do for years.  No great masterpieces, but healthy, grammatically constrained fun.

output

round.cfdg

hackpact11

Ok back to music finally.  I’m going to try to add a function to my pattern library before making a quick screencast of the first time I use it to make music patterns.  This time I made a ‘breakbeat’ function, which takes a pattern of integers and uses it to trigger playback positions in another pattern.  I also found a bug which breaks things at the end.  I could add exception handling so these bugs wouldn’t break everying, but hey, it’s good to livecode on the edge.

hackpact12

Added a couple of things:

  • stuff to my ghci interface so I can plug one active pattern into the composition of another.
  • an ‘onsets’ function that turns a pattern into a pattern of bools, true for the first beat of a phrase.

Used these things together to apply functions to effects that are responsive to the sound sample pattern. It takes me a while to work out how to do it, and the end result isn’t particularly musical. I’ll be playing around with this some more, but in the spirit of showing the first time I use a function to make sound, here’s the screencast.

(or it will be once the vimeo flash conversion finishes)

hackpact13

Implemented and played around with bpm patterns. Also implemented simple ‘tween’ pattern for linearly tweening between two values over a given period.

Screencast of first uses here and
here

Like yesterday’s, not particularly musical…

hackpact14

Did some good live coding practice for Sunday’s gig in Plymouth with Dave. We didn’t record anything though. Instead for hackpact I made a swirly processing patch while thinking about pattern visualisation.

Knowledge futures

Friday, September 4th, 2009

I’m very happy to be putting together the evening programme for knowledge futures on October 16th at Goldsmiths. Excitingly, my superheroes Leafcutter John, Finn Peters and Yee-King and Spacedog UK (Sarah Angliss + co) have agreed to play. I’m going to play too as part of slub.

Details are coming together over here. Buy your ticket early!

Hackpact

Sunday, August 30th, 2009

In the tradition of daily live coding practice a few people have formed a hack pact to make something new every day in September.  I’ve got a London Haskell User Group talk coming up on September 17th and a livecoding gig at the planetarium in Plymouth on 21st September, so my daily hack will be focussed on getting my Haskell stuff in order and practicing with it.  I’ll document my progress on this blog.

In other news, a couple of film crews attended the last pubcode, and the bbc feature has appeared on their website.  Features excellent livecoded algorithmic dancing from Yee-King and Click Nilson.

UPDATE: Hackpacters are congregating here.

Questions of creativity

Tuesday, July 21st, 2009
Computational Creativity seminar attendees

Computational Creativity seminar

I attended the start of the Dagstuhl seminar on computational creativity last week, although sadly had to leave after the first day due to family illness (which very sadly is still ongoing).  Anyway here is the position statement I prepared for the seminar, which attempts to answer some fundamental questions around creativity.  I regret I had to leave before getting feedback on these thoughts from the group at Dagstuhl, so any comments here are very much appreciated!

What does creativity produce?

A concept is `a mental representation of a class of things’ (Murphy 2002, p.5), and concepts are the primary output of a creative process. In other words, creativity is the process in which a creative agent recognises a new kind of thing, or modifies their understanding of a kind of thing, changing their view of the world in some valuable way. The visible output of a creative process may be a single thing, but it is the novelty and value of the concept behind the thing that shows creativity. The creative outcome is in the mind, not in a physical object.

Where are concepts represented?

A conventional view is that conceptual representation, and indeed cognition in general is functionally separated from perception. Theories of embodied cognition however take the view that concepts are inherently perceptual; that concepts arise from recurrent states in sensory-motor systems, which in turn form the building blocks of higher level abstract thought. If we creatively generate new concepts, then we are literally altering our perception of the world and of ourselves.

How are concepts represented?

How a concept is represented in human cognition is an open question, for example one view is that a concept is represented by a single best example or prototype, and another being that a concept is represented by a large number of memories, or exemplars. Theories of embodied cognition such as perceptual symbol systems proposed by Barsalou (2009) and conceptual spaces proposed by Gärdenfors (2000) take the prototype view. For example according to Barsalou (2009) concepts are based on incomplete, distorted and often vague summaries of prior perceptual states. Barsalou attributes the unpopularity of embodied cognition to the lack of understanding of this fragmentary and partly subconscious nature of perception. Gärdenfors (2000) also takes a prototype view, but in addition proposes that concepts are inherently geometric, where conceptual properties are convex regions within the quality dimensions of conceptual domains. He goes on to base a system of cognitive semantics on this geometric view, grounded in spatial metaphor as mappings between geometric domains.

What is creative search?

Creativity is described by Boden (1990) and formalised by Wiggins (2006b,a) as a search in a space. Three sets of rules are employed in this search; rules defining traversal of the space, evaluation of the concepts found in the space, and the space itself. However, a creative search is more than a reactive process of traversal and evaluation. Creativity also requires introspection, self-modification and for boundaries to be broken. In other words, the rule sets described above need to be examined and challenged by the agent following them. In the terms of Gärdenfors (2000), the search space is a concept, and the search is for concept instances.[1] For example in a creative search for music within a genre, the genre would be the concept and a piece of music conforming to a genre would be a concept instance.

Artists often speak of self-imposed constraints as providing creatively fertile ground. In terms of a creative search such constraints form the boundary of a space. It is possible for a search to traverse beyond that boundary, thus finding invalid concepts. If invalid yet (according to evaluation rules) valued concepts are found, then the space should be enlarged to include the concept. An invalid concept which is not valued indicates that our traversal strategy is flawed and should be modified to avoid such concepts in the future. A single traversal operation may result in both valid and invalid concepts being found, indicating both the traversal rules and the definition of the space should be modified. Returning to our musical example, we can think of a creative piece of music that has altered the boundaries of a music genre, or defined a whole new genre. Indeed music which does not break boundaries to any degree could be considered uncreative.

It is important to recognise that changes in conceptual structures first happen in an individual, which in the case of music would be the composer or improviser. Another individual’s conceptual structures may be modified to accord with a composer’s new concept by listening to the new concept instance, although success is only likely if the individual already shares the music cultural norms of the composer.

Embodied creative search

Wiggins (2006b,a) formalises creative search in order to provide a comparative framework, and so is agnostic to views of representation. However by taking the view of embodied cognition summarised here, we may define embodied creative search, where sensory-motor faculties are used to navigate a geometric space, in direct metaphor to a search through a physical space. In this view, creative computation requires concepts to be represented in a manner at least sympathetic with the way humans perceive, act and introspect. More detail on this position in the context of musical creativity is given by Forth et al. (2008). Further, an approach to symbolic description of musical sounds informed by human perception termed vocable synthesis is provided by McLean and Wiggins (2009). Both papers are available for download on the Dagstuhl seminar website alongside this position statement.

Footnotes

[1] The terms used by Gärdenfors (2000) diverge from those used by Wiggins (2006b,a). Wiggins uses the term conceptual space in the place of Gärdenfors’ concept, and concept in the place of concept instance. The meaning is however the same, particularly when the recursive heirarchy of Wiggins’ theory is taken into account.

Bibliography

Barsalou, L. W. (2009).
Simulation, situated conceptualization, and prediction.
Philosophical Transactions of the Royal Society B: Biological Sciences, 364(1521):1281-1289.

Boden, M. (1990).
The Creative Mind.
Abacus.

Forth, J., McLean, A., and Wiggins, G. (2008).
Musical creativity on the conceptual level.
In IJWCC 2008.

Gärdenfors, P. (2000).
Conceptual Spaces: The Geometry of Thought.
The MIT Press.

McLean, A. and Wiggins, G. (2009).
Words, movement and timbre.
In Proceedings of NIME.

Murphy, G. L. (2002).
The Big Book of Concepts (Bradford Books).
The MIT Press.

Wiggins, G. A. (2006a).
A preliminary framework for description, analysis and comparison of creative systems.
Journal of Knowledge Based Systems.

Wiggins, G. A. (2006b).
Searching for computational creativity.
New Generation Computing, 24(3):209-222.

Patterns of movement in live languages

Sunday, July 19th, 2009

I’ve had a paper accepted for the 25th CHArt conference on the subject of live coding, here’s the synopsis.

Programmers do their work by writing and modifying software in text form.  That is, a piece of software is a structure made from words. These structures are generally too big to comprehend in their entirety, so programmers instead focus on small detail and overall plans; looking up for parts to combine and simplify and looking down for places to build.  But this is not architecture, these structures are more like machines than static buildings.  A programmer’s work is set in motion by a program interpreter, with information flowing in and around processing units before being directed outward in response.

Usually a programmer will build their work off-line, stepping back to start it up, watch it work and decide upon the next edit.  Live coding programmers however work on their software while it runs, much like modifying a running machine.  Because the software is built from words, this is done by editing it as text, adding new routines or changing the nature of an existing one.  Such a change affects the output immediately, allowing fast creative feedback.

Where a written novel exists to describe human activity, written software exists to simulate it.  Therefore the live coder can take the role of an artist, constructing simulators in order to generate patterns of movement, either as music, video animation or both.  This can be done in front of a live audience, so that the process of building software becomes the process of improvising music or video in performance art.

In this way programmers are finally taking to the stage, introspecting and encoding their musical thoughts before an audience.  A tradition of live coding has quickly formed where computer screens are projected, making the programmer’s reactions to their work visible.  Questions of authorship disappear; the performance is live, the programmer improvising through the medium of written language.

Live coders allow us to look upon the interplay between language and performance art with renewed interest.  In this paper the current activity of live coders will be reviewed, to try to understand where this relatively new practice is taking us.

Patterns in Haskell

Wednesday, June 17th, 2009

I’ve been trying to make music with Haskell for a little while now.  One thing about Haskell is that its strict typing forces you to think a lot about how you represent things.

I wanted to support two things in my musical pattern representation, firstly polyphony (more than one sound being triggered at the same time) and secondly recursive structure. In the west we often think of rhythm in quite `flat’ terms – a 2d pattern like this:

fruity

Of course that’s a pretty useful techno interface, allows for polyphony, and could be represented in haskell using a straightforward list of lists.  However this 2D structure is only really suitable for making music with fixed timed signatures, most notably 4/4.

Time: you're doing it completely wrong

Time: you're doing it completely wrong

Enter Bernard Bel (pictured right).  His BP2 software represents music in a manner inspired by Indian classical music.  His 2001 paper Rationalising musical time has all the details and is a great read, formalising a quite beautiful way of thinking about time. As part of that it defines an elegant pattern syntax that allows patterns to be embedded inside patterns of differing time signatures.

Here’s my first attempt at representing analogous structures in Haskell.  Straightforwardly, a musical event is either a sound (represented by some string) or some silence:

data Event = Sound String
           | Silence

A musical structure is either an event, a cycle of structures, or a polymetry of structures:

data Structure = Atom Event
               | Cycle [Structure]
               | Polymetry [Structure]

A cycle allows us to sequence structures one after another, and a polymetry allows us to represent several structures occuring over the same period of time.  If the structures within a Polymetry have different durations, then they are ’stretched’ until they are the same length (equal to the lowest common multiple of their lengths). I’ve written something in parsec that parses Bel’s notation into the Structure datatype.

The problem with the above representation is that it gets unwieldy with complex rhythmic structures.  The whole point of generative music is being able to make very long patterns out of much shorter rulesets.  However with this representation, to find the 10,000th event you’d have to calculate the 9,999 events preceeding it.  This becomes a particular problem when modifying these structures as part of a live coded musical improvisation.

So I instead came up with this representation:

data Pattern a = Pattern {at :: Int -> [a], period :: Int}
type SoundPattern = Pattern String

Instead of explicitly representing a recursive structure, I’m now hiding everything inside a function mapping from integers to a list.  You pass the function the current position in the pattern (e.g. the current ‘beat’, and get back the list of events at that position.  For certain operations you still need to know the period (length) of the repeating pattern, so that’s in the datatype constructor too.

What kind of operations can I do to these patterns?  Here’s one that simply shifts events backwards in time:

(<~) :: Pattern a -> Int -> Pattern a
(<~) p steps = Pattern (\n -> at p (n + steps)) (period p)

And in the other direction:

(~>) :: Pattern a -> Int -> Pattern a
(~>) p n = (<~) p (-n)

Here’s a higher order one that applies an operation conditional on the time value (while preserving the period of the original):

when :: (Int -> Bool) -> (Pattern a -> Pattern a) -> Pattern a -> Pattern a
when pred f p = Pattern l (period p)
where l n = at (if (pred n) then (f p) else p)  n

Making this possible …

when (\n -> n `mod` 8 > 3) (<~ 2) p

… which shifts the pattern back in time two steps, but only affects every other group of 4 steps.

This is probably fairly humdrum stuff, but quite fascinating to me as someone relatively new to both haskell and functional programming. Being able to pile functions on top of functions in this way lets me compose complex patterns out of simple parts, and I only ever have to deal with the simple parts in memory, not the complex patterns. Great! Thanks to the parameterisation of the Pattern datatype, I can also use patterns for different aspects of a rhythm, my recent screencasts [1,2] showing concurrent patterning of samples, vowel formant filtering, sample playback speed and a comb filter.

I’ve also been looking at making the Pattern a Monad (my first ever monad instance, woo!):

instance Monad Pattern where
    return x = loop $ [x]
    (Pattern l len) >>= f = Pattern l' (lcm len len')
        where l' n = at (combine $ map f (l n)) n
              (Pattern _ len') = f undefined

Where ‘combine’ is another function not shown that which merges patterns together. The problem I’m having with this is that functions of type a -> Pattern a for use with >>= can’t do that much, not being able to consider any pattern context, and not being able to return a different period depending on the input (otherwise that ‘undefined’ value would bite). This is about the most useful thing I can come up with, which ‘masks’ events every other time measure:

mask :: (a -> Pattern a)
 mask x = Pattern (\n -> if n `mod` 2 == 0
                         then [x]
                         else []
                   ) 2

Maybe I should be thinking of what I could do with more general functions of type (a -> Pattern b) instead. I guess I’m just getting a better handle on what monads are really for…

Monads aside I guess my Pattern representation would really become unstuck with patterns that have a lot of interdependencies. For example if every event depended on the event preceding it then you’d have to recalculate the whole pattern all the time. Hmm.

Well that was quite an extended haskell wibble. If by some strange chance you’ve read this far I’d love to hear your thoughts and especially advice!

More hackery

Thursday, June 4th, 2009

Another screencast:

Trying a lower bpm than normal. Also I’m starting to add more higher order rhythm functions to increase live coding potential… “(~> n)” shifts the pattern one beat to the right, (<~ n) to the left, and "when" allows such ops to be applied selectively depending on function over the beat number. I feel a monad coming on.

Someone on twitter wondered whether the last one was faked, I’ll take that as a compliment! As Kassen pointed out, that one was mainly just a sequencer. A polyrhythmic sequencer, with sequences for parameter values as well as samples but a sequencer nonetheless. My aim is to try to stay as simple as possible but I’m currently looking for ways of transforming sequences through live coding. This is a step towards that.

Thanks for all the source code requests, I will release the code eventually and announce it here, but might take a while… Sorry.

I might do an opendork showing this stuff at dorkbotlondon tonight. Might not be time though as we’ve got a lot of classy presentations to get though.

(UK) Stop the racists tomorrow

Wednesday, June 3rd, 2009

If you are in the UK and have a vote, please use it. The BNP are racists, who want all “non-indigenous” (i.e., non-white) people to leave the country. If there is a low voter turn out, they have a good chance of getting their first MEP, which means much more money for their cause and stronger links with other fascist parties in europe. That would be a disaster.

Before the current BNP leader, Nick Griffin, took charge, the BNP were openly racist. He has been working hard to clear up their image and the language they use, but that is all that has changed. He remains a racist, holocaust-denying homophobe who believes that no black or asian person could ever be described as british. Griffin considers the BNP to be “a strong, disciplined organisation with the ability to back up its slogan ‘Defend Rights for Whites’ with well-directed boots and fists. When the crunch comes power is the product of force and will, not of rational debate.”

See wikipedia articles on the BNP and Nick Griffin, and the hope not hate website including this leaflet for more info.

But most of all — please vote, for any party but the BNP! If you’re unsure who to vote for, euprofiler.eu does a good job of matching your opinions to party manifestos.