Ariel’s 11th Lab

This is a lab about Kinect. It uses its camera and sensor to capture people’s gesture and get a general outline of a person’s arms and legs.

This a photo of Kinect.

webwxgetmsgimg (1)

Connecting Kinect with Windows PC didn’t take a long time. But it takes time to download the developer software and library. Then Tiffany and me started to play with Kinect.

At first it couldn’t recognize us because the distance was too short.

IMAG0232

This is a picture of William and Michael who sat in front us. You may see that it has some difficulty in recognizing people who sits still.

Thanks Tiffany for performing the dance.

An experience with kinect

Kinect is a motion sensing input device. It enables users to control and interact with their computers without the need for a game controller.

This is a picture of Kinect downloaded from the Internet.
50e15e63253123f2a470355674bf4ca0

As it doesn’t work for Mac, I watched my partner,Ariel, to operate it.
It seems that we need to download Kinect SDK 1.8 and Processing SimpleOpen NI library to make it work.

Here is a video

Lab 11: Li Chang’s work with images, video, and / or audio in Processing

This lab teaches us how to make and play images, audios and videos in Processing.
Below is the code of my project:

void setup() {

size(540,540);
img = loadImage(“pario.png”);
noCursor();
}

void draw() {
background(250);
image(img,mouseX,mouseY,30,30);
if(mousePressed){
pushMatrix();
scale(2.0);
translate(mouseX,mouseY);
image(img,-200,-200,100,100);
popMatrix();
}
}

Ada’s Lab 11

In the lab 11, I used minim library and controlP5 library to make a piano. You can listen to the music when you press the play button. Then, you can try it yourself with key a s d f g h j on the keyboard.

屏幕快照 2014-11-26 下午12.13.31

屏幕快照 2014-11-26 下午12.13.10

HERE IS THE CODE

import ddf.minim.*;
import controlP5.*;
ControlP5 cp5;

Minim minim;
AudioPlayer player;
AudioOutput out;
PImage piano;

void setup(){
size(640, 100);
minim = new Minim(this);
piano = loadImage(“piano.jpg”);
player = minim.loadFile(“star.mp3”);
image(piano, 0, 0, 640, 100);

out = minim.getLineOut();
out.setTempo(100);

cp5 = new ControlP5(this);
cp5.addButton(“play”)
.setPosition(width-80, 10);

}

void draw(){
}

void play() {
player.play();
}

void keyPressed(){
if (key == ‘a’) {
out.playNote(0, 1, “C3”);
}else if(key == ‘s’){
out.playNote(0, 1, “D3”);
}else if(key == ‘d’){
out.playNote(0, 1, “E3”);
}else if (key == ‘f’){
out.playNote(0, 1, “F3”);
}else if (key == ‘g’){
out.playNote(0, 1, “G3”);
}else if (key == ‘h’){
out.playNote(0, 1, “A3”);
}else if (key == ‘j’){
out.playNote(0, 1, “B3”);
}
}

Jialin’s lab using class

I just found I forgot this lab… This was supposed to be a parking game, you use wasd to control the car and put it into the parking lot without touching the white line, however I’ve not written the judgement of winning so it’s basically just moving the car around… Here’s the code!

Car car1;
PImage background;

void setup() {
size(800, 600);
car1 = new Car();
background = loadImage(“park.jpg”);
}

void draw() {
background(255);
image(background, 0, 0);
car1.display();
car1.drive();

}

void keyPressed(){
if(key == ‘w’){
car1.up();
} else if (key == ‘s’){
car1.back();
}
if(key == ‘a’){
car1.left();
}
if(key == ‘d’){
car1.right();
}
}
void keyReleased(){
if(key == ‘w’){
car1.stopup();
} else if(key == ‘s’){
car1.stopBack();
}
if(key == ‘a’){
car1.stopleft();
}
if(key == ‘d’){
car1.stopRight();
}
}

class Car {
PImage img;
float xpos;
float ypos;
float xspeed;
boolean carUp = false;
boolean carBack = false;
boolean carLeft = false;
boolean carRight = false;

Car() {
img = loadImage(“car.jpg”);
xpos = width/2;
ypos = height/2;
xspeed = 1;
}

void display() {
image(img, xpos, ypos);
}
void up(){
carUp = true;
}
void back(){
carBack = true;
}
void left(){
carLeft = true;
}
void right(){
carRight = true;
}
void stopBack(){
carBack = false;
}
void stopup(){
carUp = false;
}
void stopleft(){
carLeft = false;
}
void stopRight(){
carRight = false;
}
void drive() {
if (carUp) {
ypos –;
}
if(carBack){
ypos ++;
}
if(carRight){
xpos ++;
}
if(carLeft){
xpos –;
}
}
}

Richard experimenting with Microsoft Kinect

Today I experimented with Microsoft Kinect. It was a success fortunately.

So in order to make it work, I had to download Kinect SDK 1.8 and Processing SimpleOpen NI library. I chose one of the examples from the library – “user” to see how it works.

So this is what a Kinect looks like.

IMG_0036

This is the “user” example.

IMG_0047

I decided to add a bit more flavor into this project by combining Minim with the existing code. Basically what I did is add the following code.

2

1

This is a video of me dancing to the music. Enjoy.

Jialin’s Lab 11

My mind was kind of occupied by my final so I was not very creative in class today.. Since I’ve used minim to play audio in my midterm, I decide to make some sound with it this time 🙂 It’s really easy code by the way.

import ddf.minim.*;
import ddf.minim.ugens.*;
PImage img1;
int clickCounter = 0;

Minim minim;
AudioPlayer player;
AudioOutput out;
Oscil wave;

void setup() {
size(449, 112);
minim = new Minim(this);
out = minim.getLineOut();
out.setTempo(80);
out.pauseNotes();
out.playNote(0.0, 7.0, “C3”);
out.resumeNotes();
wave = new Oscil(100, 1, Waves.SINE);
wave.patch(out);
img1 = loadImage(“images.png”);
img1.loadPixels();
}

void mouseMoved() {
/*wave.frequency.setLastValue(map(mouseX, 0, width, 0, 1000));
wave.amplitude.setLastValue(map(mouseY,0,height,0,1)); */
float amp = map(mouseY, 0, height, 1, 0);
wave.setAmplitude(amp);
float freq = map(mouseX, 0, width. 110, 800);
wave.setFrequency(freq);
if (img1.width >0) {
if (mouseX > 320 && mouseY > 210) {
for (int i = 0; i<img1.pixels.length; i++) {
frameRate(30);
if (floor(random(200))==0) {
img1.pixels[i] = color(0);
}
}
} else {
for (int i = 0; i<img1.pixels.length; i++) {
frameRate(20);
if (floor(random(200))==0) {
img1.pixels[i] = color(0);
}
}
}
img1.updatePixels();

image(img1, 0, 0, width, height);
float imgR = red(img1.pixels[mouseY*img1.width+mouseX]);
float imgG = green(img1.pixels[mouseY*img1.width+mouseX]);
float imgB = blue(img1.pixels[mouseY*img1.width+mouseX]);

stroke(255);
fill(imgR, imgG, imgB);
}
}

void draw() {
}

Lab11—by Anny and Lewis

lab11

This our project for today’s lab.

Today’s topic is about image&audio&video.

We combined image and audio together.

In the video, you can see the original picture at the bottom of the screen. What we did it to use mouse to draw a pixel picture of it. When moving the mouse, you can get new pixels and there will be sound of the SINE wave.

PImage img;
int pointillize = 10;

import ddf.minim.*;//import library “minim” see document on the internet
import ddf.minim.ugens.*;
Minim minim;
AudioPlayer player;//you have to input “AudioPlayer”
AudioOutput out;
Oscil wave;

void setup() {
size(460,306);
img = loadImage(“sunflower.jpeg”);
background (0);
smooth();

minim = new Minim (this);

out = minim.getLineOut();

wave = new Oscil(100,1,Waves.SINE);//change the frequency by change 100
wave.patch(out);
}

void mouseMoved() {
int x = int (mouseX);
int y = int (mouseY);
int location = x + y*img.width;

loadPixels();
float r = red(img.pixels[location]);
float g = green(img.pixels[location]);
float b = blue(img.pixels[location]);

fill(r,g,b);
noStroke();
ellipse(x,y,pointillize,pointillize);

wave.frequency.setLastValue(map(mouseX,0,width,0,1000));//value between 0~1000
wave.amplitude.setLastValue(map(mouseY,0,height,0,1));//value between 0~1
}
void draw() {

}

 

Lab 11: Kate and Lilly Use Audio to Make a Music Lamp

Today Kate and I double-dipped. Our final project will include the intersection between light and music. Utilizing the Maki-Maki we programed the Arduino to play different notes in unison with the keyboard. Eventually we will like to create a circuit using the Maki-Maki so that the noise produced will be a direct response to touch.

import org.firmata.*;

import cc.arduino.*;

import processing.serial.*;
import ddf.minim.*;
import ddf.minim.ugens.*;

import cc.arduino.*;

Arduino arduino;

Minim minim;
AudioOutput out;

int octave = 1;

color off = color(4, 79, 111);
color on = color(84, 145, 158);

int red = 0;
int green = 0;
int blue = 0;
int[] values = {
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW
};

void setup() {
size(470, 200);

// Prints out the available serial ports.
println(Arduino.list());

// Modify this line, by changing the “0” to the index of the serial
// port corresponding to your Arduino board (as it appears in the list
// printed by the line above).
arduino = new Arduino(this, Arduino.list()[5], 57600);

// Alternatively, use the name of the serial port corresponding to your
// Arduino (in double-quotes), as in the following line.
//arduino = new Arduino(this, “/dev/tty.usbmodem621”, 57600);

// Set the Arduino digital pins as outputs.
for (int i = 0; i <= 13; i++)
arduino.pinMode(i, Arduino.OUTPUT);

minim = new Minim(this);
out = minim.getLineOut();
out.setTempo( 100 );
}

void draw() {
background(off);
stroke(on);

for (int i = 0; i <= 13; i++) {
if (values[i] == Arduino.HIGH)
fill(on);
else
fill(off);

rect(420 – i * 30, 30, 20, 20);
}
}

void keyPressed() {
if (key == ‘w’ || key == ‘W’) {
red += 10;
arduino.analogWrite(11, red);
out.playNote( 0, 1, “C”+octave );
octave++;
} else if (key == ‘a’ || key == ‘A’) {
green += 10;
arduino.analogWrite(10, green);
out.playNote( 0, 1, “D”+octave );
octave++;
//arduino.digitalWrite(10, Arduino.HIGH);
} else if (key == ‘s’ || key == ‘S’) {
blue += 10;
arduino.analogWrite(9, blue);
out.playNote( 0, 1, “E”+octave );
octave++;
//arduino.digitalWrite(9, Arduino.HIGH);
} else {
red = 0;
green = 0;
blue = 0;
arduino.analogWrite(11, red);
arduino.analogWrite(10, green);
arduino.analogWrite(9, blue);
}
}