<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Curve and lattice</title>
	<atom:link href="http://beausievers.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://beausievers.com/blog</link>
	<description>Sound, cognition and difficult music</description>
	<lastBuildDate>Tue, 09 Feb 2010 03:44:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Center Core Never More</title>
		<link>http://beausievers.com/blog/index.php/2010/02/08/center-core-never-more/</link>
		<comments>http://beausievers.com/blog/index.php/2010/02/08/center-core-never-more/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 03:44:56 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=36</guid>
		<description><![CDATA[I tweeted this a while back: a really strange, excellent music video made on an Amiga 500 in the early 90s by YouTube user JimW925.

]]></description>
			<content:encoded><![CDATA[<p>I tweeted this a while back: a really strange, excellent music video made on an Amiga 500 in the early 90s by <a href="http://www.youtube.com/user/JimW925">YouTube user JimW925.</a></p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/rXUb4gdgpbI&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/rXUb4gdgpbI&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2010/02/08/center-core-never-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby PCSet</title>
		<link>http://beausievers.com/blog/index.php/2009/11/28/ruby-pcset/</link>
		<comments>http://beausievers.com/blog/index.php/2009/11/28/ruby-pcset/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 01:06:07 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=30</guid>
		<description><![CDATA[This is a very brief update, but I&#8217;ve just released Ruby PCSet, a Ruby class for pitch-class set operations as open source software. Documentation and examples to come real soon now. Examples are now in the README.
]]></description>
			<content:encoded><![CDATA[<p>This is a very brief update, but I&#8217;ve just released <a href="http://github.com/avianism/Ruby-PCSet/">Ruby PCSet, a Ruby class for pitch-class set operations</a> as open source software. <del datetime="2009-12-01T13:11:46+00:00">Documentation and examples to come real soon now.</del> Examples are now in the README.</p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2009/11/28/ruby-pcset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing tutorial: interfaces</title>
		<link>http://beausievers.com/blog/index.php/2009/07/10/processing-tutorial-interfaces/</link>
		<comments>http://beausievers.com/blog/index.php/2009/07/10/processing-tutorial-interfaces/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 00:19:27 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=29</guid>
		<description><![CDATA[Earlier this week I wrote a tutorial about inheritance and abstract classes in Processing/Java. I mentioned there were several tools we could use to share functionality between classes; the first tool was the abstract class, the second tool is the interface.
First, let&#8217;s do a quick review of abstract classes. An abstract class differs from a [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week I wrote a tutorial about inheritance and abstract classes in Processing/Java. I mentioned there were several tools we could use to share functionality between classes; the first tool was the abstract class, the second tool is the <em>interface</em>.</p>
<p>First, let&#8217;s do a quick review of abstract classes. An <em>abstract</em> class differs from a <em>concrete</em> class in that it can never be directly instantiated. A concrete class must <em>extend</em> the abstract class, and that concrete class may be instantiated. All concrete classes extending an abstract class <em>inherit</em> functionality from a single abstract class—multiple inheritance, or inheritance from more than one class at the same time, is not allowed. Abstract classes may contain both concrete methods and abstract method signatures. Concrete fields and methods are inherited by subclasses. Abstract method signatures define a contract which subclasses must fulfill. For example, if your abstract class contains the code <code>abstract void move();</code> then all subclasses must define their own <code>void move()</code> method.</p>
<p>Interfaces are a way of defining this kind of contract, but without specifying any functionality along the way. An object which <em>implements</em> an interface is committing to respond in a predictable way to a set of methods. For example, this is how you might specify an interface for objects that can move, and an object that implements this interface:</p>
<p>	
<code class="codeblock">interface Moves {
  void move(int dx, int dy);
}

class Creature implements Moves {
  int x, y;
	
  Creature(int initX, int initY) {
    x = initX; y = initY;
  }
	
  void move(int dx, int dy) {
    x += dx; y += dy;
  }
}
</code>
</p>
<p>Note that when declaring a method signature in an interface (as opposed to an abstract class), it is not necessary to prepend <code>abstract</code>, as Processing/Java will figure out what we&#8217;re up to and make the method abstract implicitly.</p>
<p>But why use interfaces at all? Why not just use an abstract class, call it <code>MovingThing</code>, and have <code>Creature</code> extend <code>MovingThing</code>? Because while classes can only extend one superclass, they may implement any number of interfaces. For example:</p>
<p>
<code class="codeblock">interface Moves {
  void move(int dx, int dy);
}

interface ChangesColor {
  void changeColor(int newColor);
}

class Creature implements Moves, ChangesColor {
  int x, y, c;
	
  Creature(int initX, int initY) {
    x = initX; y = initY;
  }
	
  void move(int dx, int dy) {
    x += dx; y += dy;
  }
  
  void changeColor(int newColor) {
    c = newColor;
  }
}
</code>
</p>
<p>This is a way to get something a little like multiple inheritance in Processing/Java. Objects implementing these interfaces may not all do the same thing, as they each have the right to their own implementation, but at least we can be sure that they&#8217;ll do <em>something</em> when called forth to serve.</p>
<p>An object of any class which implements a given interface guarantees it will implement the methods described in that interface. Because we can be sure that an object of a class which implements an interface will have a specific set of features, Processing/Java allows us to typecast objects to the directly to the interface type. For example, say we&#8217;re writing a space shooter game, and we have an <code>ArrayList</code> called <code>listOfSpaceStuff</code> which keeps track of all of our moving objects on the screen. The list will hold objects of types <code>Asteroid</code>, <code>OurHero</code>, and <code>BadGuy</code>. As long as <code>Asteroid</code>, <code>OurHero</code>, and <code>BadGuy</code> all implement the interface <code>Moves</code>, we can do the following:</p>
<p>
<code class="codeblock">for(int i = 0; i < listOfSpaceStuff.size(); i++) {
  Moves movingObject = (Moves)listOfSpaceStuff.get(i);
  movingObject.move(dx, dy);
}
</code>
</p>
<p>Note that because each of our classes has its own unique implementation of <code>move()</code>, they can all move around the screen in a different way. Also note that we could have created a superclass implementing moves, <code>SpaceThing</code>, made <code>Asteroid</code>, <code>OurHero</code>, and <code>BadGuy</code> subclasses of <code>SpaceThing</code>, and then cast the objects coming out of the list to <code>SpaceThing</code>.</p>
<p>Before the final example, a warning about interfaces. Because interfaces only contain abstract method signatures, they pass along the burden of definition to implementing classes. While changing an abstract class can painlessly enhance the functionality of all its subclasses, changing an interface will more likely break your program, because all of the classes which implement that interface will need to be modified so they fulfill the requirements of the new contract. It pays to do some thinking up-front about how your interfaces are going to work, and whether or not the functionality they describe is likely to change, before using them extensively. (The flip side of this is, of course, that using abstract classes can cause brittle code of an entirely different sort. Interested readers might look to <a href="http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html"><em>Why extends is evil</em> at JavaWorld</a> for some discussion.)</p>
<p>Here&#8217;s an example which uses class inheritance as well as interface inheritance, and typecasts objects to interfaces. Notice that <code>Wall</code> and <code>Chameleon</code> both implement the interface <code>ChangesColor</code>, but in dramatically different ways.</p>
<p>
<div id="interfaces_container">

<!--[if !IE]> -->
	<object classid="java:interfaces.class" 
			type="application/x-java-applet"
			archive="/processing/interfaces/interfaces.jar"
			width="400" height="300"
			standby="Loading Processing software..." >
			
		<param name="archive" value="/processing/interfaces/interfaces.jar" />
	
		<param name="mayscript" value="true" />
		<param name="scriptable" value="true" />
	
		<param name="image" value="/processing/interfaces/loading.gif" />
		<param name="boxmessage" value="Loading Processing software..." />
		<param name="boxbgcolor" value="#FFFFFF" />
	
		<param name="test_string" value="outer" />
<!--<![endif]-->
	
	<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
			codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
			width="400" height="300"
			standby="Loading Processing software..."  >
			
		<param name="code" value="/processing/interfaces/interfaces" />
		<param name="archive" value="/processing/interfaces/interfaces.jar" />
		
		<param name="mayscript" value="true" />
		<param name="scriptable" value="true" />
		
		<param name="image" value="/processing/interfaces/loading.gif" />
		<param name="boxmessage" value="Loading Processing software..." />
		<param name="boxbgcolor" value="#FFFFFF" />
		
		<param name="test_string" value="inner" />
		
		<p>
			<strong>
				This browser does not have a Java Plug-in.
				<br />
				<a href="http://java.sun.com/products/plugin/downloads/index.html" title="Download Java Plug-in">
					Get the latest Java Plug-in here.
				</a>
			</strong>
		</p>
	
	</object>
	
<!--[if !IE]> -->
	</object>
<!--<![endif]-->

</div>

<p>
Source code: <a href="/processing/interfaces/interfaces.pde">interfaces</a> 
</p>

<code class="codeblock">
Wall wally = new Wall(50, 150, 0x88000000);
Creature bob = new Creature(150, 150);
Chameleon sally = new Chameleon(250, 150, #FFFFFF);

ArrayList drawList = new ArrayList();
ArrayList colorList = new ArrayList();
ArrayList moveList = new ArrayList();

void setup() 
{
  size(400,300);
  frameRate(30);
  
  drawList.add(wally);
  drawList.add(bob);
  drawList.add(sally);
  
  colorList.add(wally);
  colorList.add(sally);
  
  moveList.add(bob);
  moveList.add(sally);
}

void draw() 
{
  background(222);
  for(int i = 0; i < drawList.size(); i++) {
    Drawable drawableObject = (Drawable)drawList.get(i);
    drawableObject.draw();
  }
  
  for(int i = 0; i < colorList.size(); i++) {
    ChangesColor colorableObject = (ChangesColor)colorList.get(i);
    colorableObject.changeColor(color(random(255), random(255), random(255)));
  }
  
  for(int i = 0; i < moveList.size(); i++) {
    Moves moveableObject = (Moves)moveList.get(i);
    moveableObject.move(int(random(-2,2)), int(random(-2,2)));
  }
}

interface Drawable {
  void draw();
}

interface Moves {
  void move(int dx, int dy);
}

interface ChangesColor {
  void changeColor(int newColor);
}

class Creature implements Drawable, Moves {
  int x, y;
  
  Creature(int initX, int initY) {
    x = initX; y = initY;
  }
  
  void move(int dx, int dy) {
    x += dx; y += dy;
  }
  
  void draw() {
    fill(200);
    ellipse(x, y, 25, 40);
  }
}

class Wall implements Drawable, ChangesColor {
  int x, y, c;
  
  Wall(int initX, int initY, int initColor) {
    x = initX; y = initY;
    c = initColor;
  }
  
  void draw() {
    fill(c);
    rect(x, y, 20, 100);
  }
  
  void changeColor(int newColor) {
    c = newColor;
  }
}

class Chameleon extends Creature implements ChangesColor {
  int c, target;
  float progress;
  
  Chameleon(int initX, int initY, int initColor) {
    super(initX, initY);
    c = initColor;
    target = initColor;
    progress = 1;
  }
  
  void changeColor(int newColor) {
    if(progress >= 1) {
      c = target;
      target = newColor;
      progress = 0;
    }
  }
  
  void draw() {
    fill(lerpColor(c, target, progress));
    ellipse(x, y, 30, 10);
    ellipse(x, y, 10, 30);
    if(progress < 1) {
      progress += 0.05;
    }
  }
}
</code>

</p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2009/07/10/processing-tutorial-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing tutorial: inheritance and abstract classes</title>
		<link>http://beausievers.com/blog/index.php/2009/07/08/processing-tutorial-inheritance-and-abstract-classes/</link>
		<comments>http://beausievers.com/blog/index.php/2009/07/08/processing-tutorial-inheritance-and-abstract-classes/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 16:23:30 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=28</guid>
		<description><![CDATA[Recently I&#8217;ve been using Processing for a number of graphics programming projects. There are a lot of web tutorials covering concepts like inheritance, interfaces, inner classes, polymorphism, and so on from a Java perspective, but very few bridge the gap between Java and Processing, and fewer still offer working Processing demonstrations. Further, a great number [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been using <a href="http://www.processing.org/">Processing</a> for a number of graphics programming projects. There are a lot of web tutorials covering concepts like inheritance, interfaces, inner classes, polymorphism, and so on from a Java perspective, but very few bridge the gap between Java and Processing, and fewer still offer working Processing demonstrations. Further, a great number of Processing tutorials and demos seem to focus on specific animation techniques and not on writing solid, maintable code following best practices. I&#8217;m writing a series of tutorials for the advanced beginner or intermediate level Processing user interested in taking their programming skill to the next level.</p>
<p>Prerequisite to understanding this tutorial is having a decent sense of object-oriented programming, specifically how to define and use classes. <a href="http://processing.org/learning/objects/">This tutorial at the Processing website</a> is a good start.</p>
<p>Here&#8217;s a common problem for Processing programmers. We have a bunch of objects, lets call them creatures, which are similar in some fundamental ways, but have differences which are not simply superficial. All of the creatures have a shared vocabulary of properties and methods: they all have a width and a height, and they all can be drawn to the screen. However, each creature has one or two actions which are unique. For example, one type of creature might search the screen for food to eat, another might change colors when clicked, and a third might be capable of spontaneous asexual reproduction.</p>
<p>The breadth of difference in functionality might initially suggest coding each creature as a different class, like this:</p>
<p>
<code class="codeblock">class Monkey {
  int w, h;
	
  Monkey(initWidth, initHeight) {
    [...]
  }
	
  void draw() {
    [...]
  }
	
  void lookForFood() {
    [...]
  }
}

class Chameleon {
  int w, h;
	
  Chameleon(initWidth, initHeight) {
    [...]
  }
	
  void draw() {
    [...]
  }
	
  void changeColors() {
    [...]
  }
}

class Amoeba {
  int w, h;
	
  Amoeba(initWidth, initHeight) {
    [...]
  }
	
  void draw() {
    [...]
  }
	
  void reproduceAsexually() {
    [...]
  }
}
</code>
</p>
<p>This is bad for two reasons. First, as Good Programmers, it offends our sensibilities by violating a cardinal rule of our craft: <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">Don&#8217;t Repeat Yourself</a>. We are specifying the properties of width and height as well as the constructor and <code>draw()</code> functions three times with no structural variation, so this is two times too many. Second, we&#8217;d like to keep track of all our creatures in one big <code>ArrayList</code>. While we&#8217;re free to add <code>Monkeys</code>, <code>Chameleons</code>, and <code>Amoebae</code> to an <code>ArrayList</code>, things go wrong when we try to take them out. Processing and Java will require us to cast the object we are getting from the list to a specific type. For example, we might want to do something like this:</p>
<p>
<code class="codeblock">for(int i = 0; i < creatureList.size(); i++) {
  currentCreature = (Monkey) creatureList.get(i);
  currentCreature.draw();
}
</code>
</p>
<p>But what if the current creature is not, in fact, a <code>Monkey</code>, but instead an <code>Amoeba</code>? Then we&#8217;ll get a type error. We could keep separate lists of <code>Monkeys</code>, <code>Chameleons</code>, and <code>Amoebae</code>—but then we&#8217;d be repeating ourselves. And what if we later wanted to add <code>GiantSloths</code> or <code>Tardigrades</code>? Our code would be difficult to modify and maintain. Fortunately, we have a few tools which can help us out. The tool we&#8217;ll talk about today is the abstract class, which allows use of something called inheritance.</p>
<p>We can specify an abstract class, called Creature, which defines the properties and methods common to every object deigning to call itself creature. We can then implement subclasses of Creature (e.g. <code>Monkey</code>, <code>Chameleon</code>, and <code>Amoeba</code>) which have additional functionality of their own.</p>
<p>
<code class="codeblock">abstract class Creature {
  int w, h;
	
  Creature(int initWidth, int initHeight) {
    w = initWidth; h = initHeight;
  }
	
  abstract void draw();
}

class Monkey extends Creature {
  Monkey(int initWidth, int initHeight) {
    super(initWidth, initHeight);
  }
	
  void draw() {
    [Draw a monkey.]
  }
}

class Chameleon extends Creature {
  Chameleon(int initWidth, int initHeight) {
    super(initWidth, initHeight);
  }
	
  void draw() {
    [Draw a chameleon.]
  }
}
</code>
</p>
<p>An abstract class is like a partially filled-in template for subclasses. Members of an abstract class can never be directly instantiated (that is, created directly). Given the code above, for example, it would make no sense to write something like <code>Creature aCreature = new Creature(2,3);</code>. Instances of classes like <code>Monkey</code> and <code>Chameleon</code> can be <code>Creatures</code>, but there&#8217;s no such thing as an object which is just a <code>Creature</code> and nothing else. Every subclass of <code>Creature</code> inherits its methods and variables. In this case, that means that <code>Monkeys</code> and <code>Chameleons</code> have integers for storing their width and height.</p>
<p>Abstract classes also make demands of their subclasses. The code <code>abstract void draw();</code> means that every subclass of <code>Creature</code> is required to implement a function of type void called <code>draw()</code>. If a subclass didn&#8217;t implement this <code>draw()</code> function, we&#8217;d get an error. This set of requirements is like a contract that each subclass must honor. I&#8217;m going to expand on this notion of contractual obligation in the next tutorial, which will include a section on another tool we could use for this purpose: interfaces.</p>
<p>Additionally, something funny is happening in those subclass constructors. Subclasses are allowed to call the constructor function of their superclass, in this case <code>Creature()</code>, by using the method <code>super()</code>. The <code>Monkey()</code> and <code>Chameleon()</code> constructors just pass along the initial width and height values to the superclass constructor which handles the value assignment. If a subclass has additional variables not common to the superclass, those should also be initialized in the constructor. For example, <code>Chameleons</code> might want to store their current color in a variable, and begin life with a color passed to the constructor. We&#8217;d modify the <code>Chameleon</code> subclass as follows:</p>
<p>
<code class="codeblock">class Chameleon extends Creature {
  int c;

  Chameleon(int initWidth, int initHeight, int initColor) {
    super(initWidth, initHeight);
    c = initColor;
  }
	
  void draw() {
    [Draw a chameleon.]
  }
}
</code>
</p>
<p>Now we can populate an <code>ArrayList</code> with <code>Monkeys</code> and <code>Chameleons</code>, then iterate through that list, casting each item to the type <code>Creature</code>. Because the <code>Creature</code> superclass requires all its subclasses implement the <code>draw()</code> method, we can safely call this method on any <code>Creature</code> we get from the <code>ArrayList</code>. Here&#8217;s how that looks:</p>
<p>
<code class="codeblock">ArrayList creatureList = new ArrayList();

Monkey hanuman = new Monkey(4,8);
Chameleon lizzy = new Chameleon(7,3);

creatureList.add(hanuman);
creatureList.add(lizzy);

for(int i = 0; i < creatureList.size(); i++) {
  currentCreature = (Creature) creatureList.get(i);
  currentCreature.draw();
}
</code>
</p>
<p>Mighty convenient. Now if we add additional variables or methods to the <code>creature</code> class, all of its subclasses inherit that functionality while preserving their unique features. Below is a complete working demonstration of these principles in action, using Ellipsoids and Rectithings, creatures which are much easier to draw than apes and lizards.</p>
<p>Click on the sketch to give it focus, then press the spacebar to move all the creatures to the center of the screen.</p>
<p>
<div id="abstractClasses_container">

<!--[if !IE]> -->
	<object classid="java:abstractClasses.class" 
			type="application/x-java-applet"
			archive="/processing/abstractClasses/abstractClasses.jar"
			width="400" height="300"
			standby="Loading Processing software..." >
			
		<param name="archive" value="/processing/abstractClasses/abstractClasses.jar" />
	
		<param name="mayscript" value="true" />
		<param name="scriptable" value="true" />
	
		<param name="image" value="/processing/abstractClasses/loading.gif" />
		<param name="boxmessage" value="Loading Processing software..." />
		<param name="boxbgcolor" value="#FFFFFF" />
	
		<param name="test_string" value="outer" />
<!--<![endif]-->
	
	<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
			codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
			width="400" height="300"
			standby="Loading Processing software..."  >
			
		<param name="code" value="/processing/abstractClasses/abstractClasses" />
		<param name="archive" value="/processing/abstractClasses/abstractClasses.jar" />
		
		<param name="mayscript" value="true" />
		<param name="scriptable" value="true" />
		
		<param name="image" value="/processing/abstractClasses/loading.gif" />
		<param name="boxmessage" value="Loading Processing software..." />
		<param name="boxbgcolor" value="#FFFFFF" />
		
		<param name="test_string" value="inner" />
		
		<p>
			<strong>
				This browser does not have a Java Plug-in.
				<br />
				<a href="http://java.sun.com/products/plugin/downloads/index.html" title="Download Java Plug-in">
					Get the latest Java Plug-in here.
				</a>
			</strong>
		</p>
	
	</object>
	
<!--[if !IE]> -->
	</object>
<!--<![endif]-->

</div>

<p>
Source code: <a href="/processing/abstractClasses/abstractClasses.pde">abstractClasses</a> 
</p>

<code class="codeblock">
// Create three creatures.
Ellipsoid jane = new Ellipsoid(100, 50, 300, 150);
Rectithing alan = new Rectithing(40, 15, 100, 50);
Ellipsoid bob = new Ellipsoid(10, 70, 150, 200);

// Create our ArrayList for creature storage.
ArrayList creatureList = new ArrayList();

void setup() 
{
  size(400,300);
  frameRate(30);

  // Add our creatures to the list.
  creatureList.add(jane);
  creatureList.add(alan);
  creatureList.add(bob);
}

void draw()
{
  background(222);

  // Iterate through the list of creatures, telling each one to draw
  // and move.
  for(int i = 0; i < creatureList.size(); i++) {
    Creature currentCreature = (Creature) creatureList.get(i);
    currentCreature.draw();
    currentCreature.move();
  }
}

// When the spacebar is pressed, iterate through the creatureList
// and move every creature to the center.
void keyReleased() {
  if(key == ' ') {
    for(int i = 0; i < creatureList.size(); i++) {
      Creature currentCreature = (Creature) creatureList.get(i);
      currentCreature.moveToCenter();
    }
  }
}

abstract class Creature {
  // Every subclass will inherit these variables.
  int w, h, x, y;

  Creature(int initWidth, int initHeight, int initX, int initY) {
    w = initWidth; h = initHeight; 
    x = initX; y = initY;
  }

  // Every sublcass will inherit this method.
  void moveToCenter() {
    x = int(width * 0.5);
    y = int(height * 0.5);
  }

  // Every subclass is required to implement these methods on their own.
  abstract void draw();
  abstract void move();
}

class Ellipsoid extends Creature {
  // Ellipsoids have a changing color.
  int c;

  Ellipsoid(int initWidth, int initHeight, int initX, int initY) {
    // Call the superclass constructor on initialization.
    super(initWidth, initHeight, initX, initY);
    c = int(random(255));
  }

  void draw() {
    fill(c);
    ellipse(x,y,w,h);
  }

  void move() {
    x += int(random(-2,2));
    y += int(random(-2,2));
    w += int(random(-3,3));
    h += int(random(-3,3));
    c += int(random(-10,10));
  }
}

class Rectithing extends Creature {
  Rectithing(int initWidth, int initHeight, int initX, int initY) {
    super(initWidth, initHeight, initX, initY);
  }

  void draw() {
    fill(127);
    rect(x,y,w,h);
  }

  void move() {
    x += int(random(-3, 3));
    y += int(random(-3, 3));
  }
}
</code>
</p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2009/07/08/processing-tutorial-inheritance-and-abstract-classes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Laptop vs. Table Saw</title>
		<link>http://beausievers.com/blog/index.php/2009/06/20/laptop-vs-table-saw/</link>
		<comments>http://beausievers.com/blog/index.php/2009/06/20/laptop-vs-table-saw/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 00:18:22 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=27</guid>
		<description><![CDATA[My good friend Jack Perkins sent me this video of Leif Shackleford cutting up his laptop with a table saw. With what sounds like live electronic processing. Scenes need a shake-up like this every once in a while; it&#8217;s far too easy to get complacent crawling around on the floor tapping on your collection of [...]]]></description>
			<content:encoded><![CDATA[<p>My good friend <a href="http://aceface.bandcamp.com/">Jack Perkins</a> sent me this video of <a href="http://www.structuredloud.com/">Leif Shackleford</a> cutting up his laptop with a table saw. With what sounds like live electronic processing. Scenes need a shake-up like this every once in a while; it&#8217;s far too easy to get complacent crawling around on the floor tapping on your collection of Boss digital distortion pedals from the 90s or whatever. Bring the noise, brother Leif!</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/E49XZJoQYlg&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/E49XZJoQYlg&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2009/06/20/laptop-vs-table-saw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick links</title>
		<link>http://beausievers.com/blog/index.php/2009/04/11/short-post/</link>
		<comments>http://beausievers.com/blog/index.php/2009/04/11/short-post/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 17:19:27 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Cognitive science and philosophy]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=26</guid>
		<description><![CDATA[This blog has been on hiatus while I work on my Masters thesis. I&#8217;m still working on it, but I&#8217;m going to try to get in here and at least link to interesting content once in a while.
Here&#8217;s a transcription of an excellent talk by Benjamin H. Bratton at Postopolis LA. Though it doesn&#8217;t take [...]]]></description>
			<content:encoded><![CDATA[<p>This blog has been on hiatus while I work on my Masters thesis. I&#8217;m still working on it, but I&#8217;m going to try to get in here and at least link to interesting content once in a while.</p>
<p>Here&#8217;s <a href="http://www.cityofsound.com/blog/2009/04/benjamin-h-brattton-postopolis-la.html">a transcription of an excellent talk by Benjamin H. Bratton at Postopolis LA.</a> Though it doesn&#8217;t take music or cognitive science as its primary subject, it identifies some cultural currents important to the social and political positions of both fields.</p>
<p>And here&#8217;s <a href="http://www.sciencenews.org/view/generic/id/41906/title/Feelings%2C_universal_musical_feelings">coverage of some interesting but deeply problematic research regarding the universality of musical emotion.</a> The researchers had subjects who claim never to have heard Western music classify the emotionality of songs by pointing at pictures of faces expressing one of three emotions: happiness, sadness, and fear. I have not yet read the paper, but the media coverage is characteristically enthusiastic and uncritical, using such misleading and awful headlines as <a href="http://sciencenow.sciencemag.org/cgi/content/full/2009/319/1"><em>Feel-Good Music Feels Good Around the World</em></a> and <a href="http://www.sciencedaily.com/releases/2009/03/090319132909.htm"><em>Language Of Music Really Is Universal, Study Finds.</em></a></p>
<p><strong>Update:</strong> <a href="http://scienceblogs.com/cognitivedaily/2009/04/even_isolated_cultures_underst.php">Decent coverage of the Mafa music study at Cognitive Daily.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2009/04/11/short-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Cutty Wren</title>
		<link>http://beausievers.com/blog/index.php/2008/09/21/the-cutty-wren/</link>
		<comments>http://beausievers.com/blog/index.php/2008/09/21/the-cutty-wren/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 18:29:47 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=25</guid>
		<description><![CDATA[Looking for videos of John Butcher on YouTube, I found a performance by Phil Minton and Veryan Weston of an old English folk song called The Cutty Wren. The film is by Helen Petts, who has a bunch of fantastic videos of improvised music on her YouTube channel. Minton&#8217;s use of fairly extreme extended vocal [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for videos of John Butcher on YouTube, I found <a href="http://www.youtube.com/watch?v=7i7zdS7MHp8">a performance by Phil Minton and Veryan Weston of an old English folk song called The Cutty Wren</a>. The film is by <a href="http://www.youtube.com/helentonic">Helen Petts</a>, who has a bunch of fantastic videos of improvised music on her YouTube channel. Minton&#8217;s use of fairly extreme extended vocal technique casts this ancient traditional in an entirely new light. As a good friend said, &#8220;You cannot buy that kind of pain.&#8221;</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/7i7zdS7MHp8&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/7i7zdS7MHp8&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>The song&#8217;s provenance is unclear. In <a href="http://www.mustrad.org.uk/articles/tse1.htm">The Singing Englishman</a>, A.L. Lloyd dates it to <a href="http://en.wikipedia.org/wiki/Peasants'_Revolt">the peasants&#8217; revolt of 1381</a>. The despair caused by plague and oppression from the upper classes gave the folk songs of the era a rather dark vibe. The wren may be a symbol for the barony or the king or the police, i.e. not a small bird but a person of significant means—which would explain why it&#8217;s so difficult to kill, carry, cook, slice, and distribute.</p>
<p>Also possible is a Celtic mythical/religious interpretation, with the wren as a symbolic human sacrifice, cooked in the cauldron of Kerridwen. According to <a href="http://mysongbook.de/msb/songs/c/cutywren.html">this page</a>, the cauldron of Kerridwen was &#8220;the source of immortality and divine wisdom&#8221;, and the wren represents the Celtic god Bran, &#8220;an oracular hero, a being who linked the outer world with the Underworld&#8221;.</p>
<p>The way these two interpretations rub up against each other is fascinating. It seems like the song originally had a ritual, religious function, but was transformed into political commentary after the plague and the poll tax. Minton&#8217;s modern, surreal, expressionist solo brings the song into our current political/economic context, turning it into a commentary on globalization, seemingly endless war, widespread voter suppression, the near-nationalization of AIG, the $700,000,000,000 bailout budget, and other economic policies weighted in favor of the super-rich. In this climate, the sacrifice of the cutty wren brings a bit of a tear to my eye.</p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2008/09/21/the-cutty-wren/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Library of musical excerpts for emotion study</title>
		<link>http://beausievers.com/blog/index.php/2008/09/10/library-of-musical-excerpts-for-emotion-study/</link>
		<comments>http://beausievers.com/blog/index.php/2008/09/10/library-of-musical-excerpts-for-emotion-study/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 22:47:27 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Cognitive science and philosophy]]></category>
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=24</guid>
		<description><![CDATA[Sandrine Viellard and company at the Isabelle Peretz Research Laboratory recently published an interesting paper entitled Happy, sad, scary and peaceful musical excerpts for research on emotions. The primary goal of the work described in this paper is the creation of a standard set of musical stimuli for music-emotion research, something like Paul Ekman&#8217;s famous [...]]]></description>
			<content:encoded><![CDATA[<p>Sandrine Viellard and company at the <a href="http://www.brams.umontreal.ca/plab/">Isabelle Peretz Research Laboratory</a> recently published an interesting paper entitled <a href="http://www.brams.umontreal.ca/plab/publications/article/96">Happy, sad, scary and peaceful musical excerpts for research on emotions</a>. The primary goal of the work described in this paper is the creation of a standard set of musical stimuli for music-emotion research, something like <a href="http://www.paulekman.com/researchproducts.php">Paul Ekman&#8217;s famous collection of photographs of facial expressions</a>. Unlike Ekman, Viellard et al. aren&#8217;t demonstrating any kind of universality. In fact, they limited themselves to the genre of Western film music performed on a piano, and they see the primary structural determinants of &#8220;tension&#8221; in the music as whether or not it is in a major or minor mode and whether or not there is any chromaticism, so the cultural boundaries are fairly constrained indeed.</p>
<p>Simulation theories of emotional understanding posit the recognition of emotion necessarily involves some kind of internal simulation of that emotion. However, these internal simulations don&#8217;t necessarily have the same phenomenology as <em>feeling</em> (you can&#8217;t see it, but right here I am making a hand gesture to buttress my point!) elicited in a more direct way. The musical examples from Viellard&#8217;s library are a good example; they are (deliberately, rightly) cliché, boring, stripped of their expressive qualities. For the most part, I find myself <em>recognizing</em> the emotion I believe the music attempts to convey (with some exceptions, but as a composer I&#8217;m not an ideal candidate for this sort of thing), but <em>experiencing</em> nothing like emotion at all. Provisionally, I think this is a good thing. Music which elicits emotion rather than referencing it is slippery, different for different people, dependent upon context, maybe impossible to isolate and bottle. It&#8217;s nice to have a collection of musical examples which have been empirically assessed as accurately <em>conveying</em> a basic set of emotions, evocative sterility notwithstanding.</p>
<p>One fact which leaves me a little unsettled, mostly because these clips don&#8217;t cause me to experience any emotion, is that subjects performed <em>better</em> on the emotion identification task when they were told to focus on emotional experience instead of recognition:</p>
<p><cite>&#8220;A significant effect of Instruction [i.e. the instruction to focus on experience versus recognition], F(1,37)=4.97; p=.032; h=.118, was observed, with a higher rating for the intended emotion in the experience condition (from .82 to .91 across emotional categories) than in the recognition condition (from .76 to .84 across emotional categories).&#8221;</cite></p>
<p>I find that result very strange.</p>
<p>Another issue, somewhat less troubling, but still a bit problematic: A forced choice paradigm was used for categorization of the stimuli. For each stimulus, subjects were told to apply as many of the labels &#8220;happy&#8221;, &#8220;sad&#8221;, &#8220;scary&#8221;, and &#8220;peaceful&#8221; as they wanted, and the best label of those four was determined. Each of the stimuli were composed with one of those labels in mind, and so the intention of the composer was validated by the categorization task, but in a pretty weak way. What if, for example, an additional label had been allowed: &#8220;angry&#8221;? Would the categorization task then have clustered the stimuli into five groups, despite the compositional intention of conveying one of four emotions? It&#8217;d be nice to see a freer labeling procedure, it would make the library much more powerful.</p>
<p>References:</p>
<ul>
<li><a href="http://www.brams.umontreal.ca/plab/publications/article/96">Vieillard, S., Peretz, I., Gosselin, N., Khalfa, S., Gagnon, L. &#038; Bouchard, B. (2008) Happy, sad, scary and peaceful musical excerpts for research on emotions. Cognition and Emotion, Vol. 22, Issue 4. 720-752.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2008/09/10/library-of-musical-excerpts-for-emotion-study/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Military neuroscience report</title>
		<link>http://beausievers.com/blog/index.php/2008/08/19/military-neuroscience-report/</link>
		<comments>http://beausievers.com/blog/index.php/2008/08/19/military-neuroscience-report/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 19:21:58 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Cognitive science and philosophy]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=23</guid>
		<description><![CDATA[Just read the free executive summary of a report entitled &#8220;Emerging Cognitive Neuroscience and Related Technologies&#8221; prepared by the National Research Council for the Department of Defense. Mostly predictable, but a couple of things stuck out. First is the burgeoning military interest in &#8220;culture studies&#8221;. It&#8217;s a relief to see, even in this roundabout way, [...]]]></description>
			<content:encoded><![CDATA[<p>Just read the free executive summary of a report entitled <a href="http://www.nap.edu/catalog.php?record_id=12177">&#8220;Emerging Cognitive Neuroscience and Related Technologies&#8221;</a> prepared by the National Research Council for the Department of Defense. Mostly predictable, but a couple of things stuck out. First is the burgeoning military interest in &#8220;culture studies&#8221;. It&#8217;s a relief to see, even in this roundabout way, the US military&#8217;s failure to communicate across cultures acknowledged or addressed. I hope the motive for cross-cultural research isn&#8217;t merely tactical, but strategic, foundational and systematic. If the military sees understanding of cross-cultural unversality and difference as simply means to the end of, say, more effective mind-reading, that would miss the point. A glimmer of light: <cite>&#8220;Conventional social science models based primarily on Western ideas may be challenged by invisible biases.&#8221;</cite></p>
<p>Second, the report seems pretty naïve about AI. It jumps from a paragraph about expert systems directly to speculation about &#8220;an intelligent machine that uses the Internet to train itself&#8221;. The internet, of course, is &#8220;by far the closest we have come to a total database of knowledge&#8221;. Whoa there, guys.</p>
<p>More coverage at <a href="http://blog.wired.com/wiredscience/2008/08/uncle-sam-wants.html">Wired</a> and <a href="http://www.metafilter.com/74225/Hearts-and-Minds">MetaFilter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2008/08/19/military-neuroscience-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open access music articles</title>
		<link>http://beausievers.com/blog/index.php/2008/08/13/open-access-music-articles/</link>
		<comments>http://beausievers.com/blog/index.php/2008/08/13/open-access-music-articles/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 23:55:20 +0000</pubDate>
		<dc:creator>beau</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://beausievers.com/blog/?p=22</guid>
		<description><![CDATA[I wanted to write about Lachenmann, but none of the articles I&#8217;ve been reading are available freely on the internet. That huge bummer led me to search for open-access, peer-reviewed music writing on the web. I found some neat stuff.

&#8220;What I Call a Sound&#8221;: Anthony Braxton’s Synaesthetic Ideal and Notations for Improvisers, by Graham Lock
Form-Building [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to write about Lachenmann, but none of the articles I&#8217;ve been reading are available freely on the internet. That huge bummer led me to search for open-access, peer-reviewed music writing on the web. I found some neat stuff.</p>
<ul>
<li><a href="http://quasar.lib.uoguelph.ca/index.php/csieci/article/view/462">&#8220;What I Call a Sound&#8221;: Anthony Braxton’s Synaesthetic Ideal and Notations for Improvisers</a>, by Graham Lock</li>
<li><a href="http://www.musicandmeaning.net/issues/showArticle.php?artID=4.3">Form-Building Transformations: An Approach to the Aural Analysis of Emergent Musical Forms</a>, by Lasse Thoresen, who is really interesting and deserves more attention than this single link. Maybe after the term ends.</li>
<li><a href="http://www.echo.ucla.edu/volume1-issue1/cizmic/cizmic-interview.html">Composing the Pacific: Interviews with Lou Harrison</a>, by Maria Cizmic.</li>
<li><a href="http://www.echo.ucla.edu/Volume5-Issue2/chapman/chapman1.html">Hermeneutics of Suspicion: Paranoia and the Technological Sublime in Drum and Bass Music</a>, by Dale Chapman. Takes as its starting points the soundtrack to the film <em>π</em> and <a href="http://www.youtube.com/watch?v=ggeu5vhbueo">Photek&#8217;s Two Swords Technique</a>, both of which are classics dear to my heart. I learned to play Two Swords Technique on drum set with Steve Wilkes at Berklee, this makes me want to bust it out and start practicing.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://beausievers.com/blog/index.php/2008/08/13/open-access-music-articles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
