latest....

mouse painting

float weight = .05;
int lastX, lastY;
int aa = 0;

void setup() {
background(255);
size(screen.width,screen.height);
lastX = mouseX;
lastY = mouseY;
smooth();
}

void draw(){
noStroke();
fill(0,10);

if(lastX == mouseX && lastY == mouseY) {
noFill();
stroke(aa,10);
strokeWeight(1);
ellipse(mouseX,mouseY, 20+weight,20+weight);

noStroke();
fill(255,03);
ellipse(mouseX,mouseY, 10+weight,10+weight);
weight = weight+.05;
}

else {
if(mousePressed) {
stroke(aa);
strokeWeight(.5);
line(lastX, lastY,mouseX,mouseY);
weight = .05;
}
}

lastX = mouseX;
lastY = mouseY;

}

Mouse tracking outside of the screen using Processing

This code borrows MouseInfo from JAVA to get coordinates outside of Processing’s display window. It also includes the ability to compile a PDF when you’re done by pressing the UP key in the sketch. Enjoy.

// trackScreen by Colin Owens
// Using JAVA mouseInfo for a bit of hackiness
// Use to your heart's content with attribution
// 2010

import processing.pdf.*;

Point mouse;

float weight = .05;
int lastX, lastY;

int aa = 0;

void setup() {
  background(255);
  size(screen.width,screen.height);
  mouse = MouseInfo.getPointerInfo().getLocation();  

  lastX = mouse.x;
  lastY = mouse.y;
  smooth();
  beginRecord(PDF, "filename.pdf");
  println("I'm running");
}

void draw(){
  mouse = MouseInfo.getPointerInfo().getLocation();  

  noStroke();
  fill(0,10);

  if(lastX == mouse.x && lastY == mouse.y) {
    noFill();
    stroke(aa,10);
    strokeWeight(1);
    ellipse(mouse.x,mouse.y, 20+weight,20+weight);

    noStroke();
    fill(255,03);
    ellipse(mouse.x,mouse.y, 10+weight,10+weight);
    weight = weight+.05;
  }

  else {
    stroke(aa);
    strokeWeight(.5);
    line(lastX, lastY,mouse.x,mouse.y);
    weight = .05;
  }

  lastX = mouse.x;
  lastY = mouse.y;

} 

void keyPressed() {
  if (key == CODED) {
    if (keyCode == UP) {
      endRecord();
      exit();
    }
  }
}

Beautiful

Sometimes I come across something that I want to share:

Nuit Blanche from Spy Films on Vimeo.

There’s a making of video too.

Flash Week two code

// Anything to the right of these two slashes is
// A comment and will not be part of the code.

var xSize:int = 200;

// Add an event listener to the stage and name the function
stage.addEventListener(Event.ENTER_FRAME,onFrameLoop);

// Your function name must match the name after the comma
// in the parenthesis.
function onFrameLoop(evt:Event):void {

// These are all of the things that will happen in
// the function.

// This will rotate the instance of the rectangle
// colin according to mouse X and Y values.
colin.y = mouseY;
colin.x = 800 – mouseX;

// here’s an if statement
if (mouseX > xSize) {
trace(“rotating! ” + mouseX +” ” + colin.y);
//colin.rotation = mouseX;
colin.height = 29;
// here’s another option if that statement hasn’t been met
}
else if(mouseX < xSize) {
trace(“scaling!”);
colin.scaleY = mouseY;
}
// This will scale the instance of the rectangle
// colin according to the mouse X and Y values.
colin.scaleX = mouseY/20;
colin.scaleY = mouseX/20;

}

// Don’t forget to close the function with the
// brace (squiggly bracket) above!!!

Systems Instruction Card

Flash Interactive Animation Class 1

Link to the directory to find the flash class examples.

Link to class syllabus.

Systems day two assignment

Take your inputs and organize them in the following way:

  1. Timetime is elastic and relative, use your best judgement.
  2. Actionwhat were you doing at that time?
  3. Sense–requirement: use iconography
  4. Location–where were you? can you be more specific?
There is no wrong approach. You can choose the primary method you feel expresses your journey best. Use typography and clustering to show meaningful relationships between actions, your inputs the location and time. Whatever you use as the primary viewpoint will dictate how the story will unfold.
Processing–For next Thursday bring a processing sketch that modifies an input file example. Show us how you modified it.

Design Systems spring 2010

Welcome back! You can search these pages for useful code and material from previous systems classes.

Here is our class syllabus in PDF format.

getting volume data in Flash and Processing

Update: Here’s a fabulous explanation on the getSpectrum() class for Flash.

I’ve compiled a list of basic resources for you to play around with before class on Wednesday in case you haven’t found these already. If you’re working with Processing, remember to place your sound file inside of a folder called “data” inside of your sketch’s folder. If you’re using flash, remember that computeSpectrum only deals with two channel audio (for our purposes right now this is OK). I also placed some code at the end of this post that uses beat detect. You will be able to tell the difference between beat detect and Minim’s standard volume.get by the blue flashiness. Enjoy!

Processing with Ess

Showing the level from an FFT with color

Showing a level of volume across frequency using color

Processing with Minim

Getting volume data in time (without an FFT)

Flash

computeSpectrum reading (a variation of the example I used in class) a sound file

ComputeSpectrum Using an external actionScript file

Minim–BeatDetect Example

// Example By Colin Owens
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
BeatDetect beat;
int multiplier = 10;
int count = 0;
int dotSize = 5;
void setup()
{
  size(1024, 768);
  minim = new Minim(this);
  song = minim.loadFile("true.mp3");
  song.play();
  beat = new BeatDetect();
}
void draw()
{
  background(0);
  beat.detect(song.mix);
  for(int i = 0; i < song.bufferSize() - 1; i++)
  {
    noStroke();
    fill(210,180,20);
    smooth();
    ellipse(count*multiplier, height/3 + song.left.get(i)*250, dotSize, dotSize);
    ellipse(count*multiplier, (height/3)*2 + song.right.get(i)*250, dotSize, dotSize);
if ( beat.isOnset() ) {
  fill(20,180,210);
   ellipse(count*multiplier, height/3 + song.left.get(i)*250, dotSize*10, dotSize*10);
    ellipse(count*multiplier, (height/3)*2 + song.right.get(i)*250, dotSize*10, dotSize*10);
}
    count++;
    if (count >= width) {
      count=0;
    }
    if (dotSize <= 0) {
      dotSize=1;
      multiplier = 10;
    }
  }
  if(keyPressed) {
    if (keyCode == LEFT) {
      multiplier = multiplier -1;
      dotSize = dotSize -1;
    }
    if (keyCode == RIGHT) {
      multiplier = multiplier +1;
      dotSize = dotSize +1;
    }
  }
}
void stop()
{
  song.close();
  super.stop();
}

Sound for dynamic media week 3 links


Here are the links to my running playlists on youTube. These are not strict categories per se. Please feel free to email me your suggestions for the video jukebox as well. Enjoy:

Color Music

Music Video

Sound Sculpture

Synaesthetic Video

Visual Music