Final Project

I have two versions of code. Both that look to me like they absolutely should work. After hours and days of fishing around the Processing site, I am starting to get scared that it isn't going to be able to process my video fast enough. I also can get the window fullscreen, but not the image. I have tried so much I don't know what to do. I can get it to sometimes, with really simple code, play a video one after another, but I can't usually get it to delay until playing the next video for as long as I ask it to.

here are 2 versions of code:
import processing.video.*;
Movie myMovie;
import processing.serial.*;
Serial port;
float getByte = -1;
float oldByte = 0;
float difference = 0;
Movie CP1;
Movie CP2;
Movie CP3;
Movie CP4;
Movie CP5;
Movie CP6;
Movie BangItOut1;
Movie BangItOut2;
Movie BangItOut3;
Movie Where1;
Movie Where2;
Movie Where3;
Movie WhereYou;
Movie Wait;
Movie FuckOff;
Movie IDontKnow;
Movie WasTalking;
Movie WaitStill;


void setup() {
size(screen.width, screen.height);
port = new Serial(this, Serial.list()[0], 9600);
WaitStill = new Movie(this, "WaitStill.mov");
CP1 = new Movie(this, "CP1.mov");
CP2 = new Movie(this, "CP2.mov");
CP3 = new Movie(this, "CP3.mov");
CP4 = new Movie(this, "CP4.mov");
CP5 = new Movie(this, "CP5.mov");
CP6 = new Movie(this, "CP6.mov");
BangItOut1 = new Movie(this, "BangItOut1.mov");
BangItOut2 = new Movie(this, "BangItOut2.mov");
BangItOut3 = new Movie(this, "BangItOut3.mov");
Wait = new Movie(this, "Wait.mov");
FuckOff = new Movie(this, "FuckOff.mov");
IDontKnow = new Movie(this, "WaitStill.mov");
WasTalking = new Movie(this, "WasTalking.mov");
Where1 = new Movie(this, "Where1.mov");
Where2 = new Movie(this, "Where2.mov");
Where3 = new Movie(this, "Where3.mov");
WhereYou new Movie(this, "WhereYou.mov");
}

void draw(){
image(myMovie, 0, 0);
WaitStill.loop();
getByte = port.read();
oldByte = getByte;
delay(40);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference > 200) {
WaitStill.stop();
CP1.play();
delay(9140);}
else {
WaitStill.loop();
exit();}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
CP1.stop();
CP2.play();
delay(2050);}
else {
CP1.stop();
myMovie = new Movie (this, "Where1.mov");
Where1.play();
delay(2050);
getByte = port.read();
if (getByte > 1000){
Where1.stop();
WaitStill.loop();
exit();}

else {
Where1.stop();
CP2.play();
delay (2050);}}
oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
CP2.stop();
CP3.play();
delay(6090);}
else{
CP2.stop();
myMovie = new Movie (this, "Where3.mov");
Where3.play();
delay(327000);
getByte = port.read();
if (getByte > 1000){
Where3.stop();
WaitStill.loop();
exit();}

else{
Where3.stop();
CP3.play();
delay(609000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}}

delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}
else{
myMovie.stop();
myMovie = new Movie (this, "WasTalking.mov");
myMovie.play();
delay(305000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where2.mov");
myMovie.play();
delay(2260);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}
else{
myMovie.stop();
myMovie = new Movie (this, "IDontKnow.mov");
myMovie.play();
delay(320000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
else{
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
myMovie = new Movie (this, "WaitStill.mov");
delay(2000);
}
void movieEvent(Movie m) {
m.read();
}


AND (the only difference is that This one keeps the same variable for all the movies. That makes it super slow I think)
import processing.video.*;
Movie myMovie;
import processing.serial.*;
Serial port;
float getByte = -1;
float oldByte = 0;
float difference = 0;



void setup() {
size(screen.width, screen.height);
port = new Serial(this, Serial.list()[0], 9600);

}

void draw(){
image(myMovie, 0, 0);
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
getByte = port.read();
oldByte = getByte;
delay(40);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference > 200) {
myMovie.stop();
myMovie = new Movie (this, "CP1.mov");
myMovie.play();
delay(914000);}
else {
myMovie.loop();
exit();}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP2.mov");
myMovie.play();
delay(205000);}
else {
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP2.mov");
myMovie.play();
delay (205000);}}
oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP3.mov");
myMovie.play();
delay(609000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where3.mov");
myMovie.play();
delay(327000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else{
myMovie.stop();
myMovie = new Movie(this, "CP3.mov");
delay(609000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP4.mov");
myMovie.play();
delay(708000);}}

oldByte = getByte;
delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}
else{
myMovie.stop();
myMovie = new Movie (this, "Wait.mov");
myMovie.play();
delay(118000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP5.mov");
myMovie.play();
delay(109200);}}

delay(10);
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}
else{
myMovie.stop();
myMovie = new Movie (this, "WasTalking.mov");
myMovie.play();
delay(305000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "CP6.mov");
myMovie.play();
delay(813000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where2.mov");
myMovie.play();
delay(2260);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut1.mov");
myMovie.play();
delay(914000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}
else{
myMovie.stop();
myMovie = new Movie (this, "IDontKnow.mov");
myMovie.play();
delay(320000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut2.mov");
myMovie.play();
delay(115000);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}
else{
myMovie.stop();
myMovie = new Movie (this, "Where1.mov");
myMovie.play();
delay(205000);
getByte = port.read();
if (getByte > 1000){
myMovie.stop();
myMovie = new Movie(this, "WaitStill.mov");
myMovie.loop();
exit();}

else {
myMovie.stop();
myMovie = new Movie (this, "BangItOut3.mov");
myMovie.play();
delay(99100);}}
delay(10);
oldByte = getByte;
getByte = port.read();
difference = sqrt((oldByte - getByte) * (oldByte - getByte));
if (difference < 200) {
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
else{
myMovie.stop();
myMovie = new Movie (this, "FuckOff.mov");
myMovie.play();
delay(213000);}
myMovie = new Movie (this, "WaitStill.mov");
delay(2000);
}
void movieEvent(Movie m) {
m.read();
}

I know that the image/screen setting are not consistent or good in these pieces of code. I have been playing around with those in my sample code and still can't get what I want.

Final Project

My project will emulate the behavior of a socially awkward person in a party/gallery setting. I want it to be placed in the corner of a room. The piece, physically, is a rectangular television (NOT flat screen) sitting on top of a right angle triangular prism/pedestal. When a person walks past it, within the range of 150 cm, the piece begins the interaction by cueing the first video clip. The video is a close shot of a person’s head that begins to tell an anecdote. The story is odd and inappropriate but, I think, very funny. The viewer is either put off and uninterested in the piece/story or stays to listen. If the person is uninterested, as they walk away, the motion sensor detects this and cues the next clip. The next clip begins at twice the volume and is meant to grab the attention of the person who was just standing there again.
The idea is that the piece behaves like a clingy socially awkward person. They are planted in the corner, just wanting to gab, afraid of mingling. When you try and leave the piece, it calls out with more force. It keeps trying to top itself until you stay. When you leave, it waits. Its quiet and deflated until a new person walks by. In an attempt to mask the many quick cuts, I will give the person a twitch that plays during the story. Even if the person stays to listen, the twitch will be incorporated. It is definitely activated every time the motion sensor detects someone walking away and then segways into the next part of the story with a LOUD first few seconds.
The motion sensor will be mounted in a red bowtie placed just under the T.V. at the top of the pedestol.
(please excuse video quality. It's only this bad here)
This is what it is doing when there is no on near it:



Here is a video sequence that is one possible interaction you could have with it:



Here is another:

Technical Talk

A microphone is a device made to capture waves in air, water or hard material and translate them into an electrical signal. The most common method is via a thin membrane producing some proportional electrical signal. Most microphones in use today for audio use electromagnetic generation (dynamic microphones), capacitance change (condenser microphones) or piezoelectric generation to produce the signal from mechanical vibration.


Electret condenser microphones
The name comes from electrostatic and magnet; a static charge is embedded in an electret by alignment of the static charges in the material, much the way a magnet is made by aligning the magnetic domains in a piece of iron. They are used in many applications, from high-quality recording to small sound recording devices and telephones. Though electret microphones were once low-cost and considered low quality, the best ones can now rival capacitor microphones in every respect and can even offer the long-term stability and ultra-flat response needed for a measuring microphone. Unlike other capacitor microphones, they require no polarizing voltage, but normally contain an integrated preamplifier which does require power (often incorrectly called polarizing power or bias). This preamp is frequently phantom powered in sound reinforcement and studio applications. While few electret microphones rival the best DC-polarized units in terms of noise level, this is not due to any inherent limitation of the electret. Rather, mass production techniques needed to produce electrets cheaply don't lend themselves to the precision needed to produce the highest quality microphones.


Dynamic microphones
Dynamic microphones work via electromagnetic induction [Electromagnetic induction is the production of voltage across a conductor situated in a changing magnetic field or a conductor moving through a stationary magnetic field.]They are robust, relatively inexpensive and resistant to moisture, and for this reason they are widely used on-stage by singers. There are two basic types: the moving coil microphone and the ribbon microphone.
The dynamic principle is exactly the same as in a loudspeaker, only reversed. A small movable induction coil, positioned in the magnetic field of a permanent magnet, is attached to the diaphragm. When sound enters through the windscreen of the microphone, the sound wave moves the diaphragm. When the diaphragm vibrates, the coil moves in the magnetic field, producing a varying current in the coil through electromagnetic induction. A single dynamic membrane will not respond linearly to all audio frequencies. Some microphones for this reason utilize multiple membranes for the different parts of the audio spectrum and then combine the resulting signals.


Ribbon microphones
In ribbon microphones a thin, usually corrugated metal ribbon is suspended in a magnetic field. The ribbon is electrically connected to the microphone's output, and its vibration within the magnetic field generates the electrical signal. Ribbon microphones are similar to moving coil microphones in the sense that both produce sound by means of magnetic induction. Basic ribbon microphones detect sound in a bidirectional (also called figure-eight) pattern because the ribbon, which is open to sound both front and back, responds to the pressure gradient rather than the sound pressure.
In common with other classes of dynamic microphone, ribbon microphones don't require phantom power; in fact, this voltage can damage some older ribbon microphones. (There are some new modern ribbon microphone designs which incorporate a preamplifier and therefore do require phantom power, also there are new ribbon materials available that are immune to wind blasts and phantom power.)
Carbon microphones
A carbon microphone, formerly used in telephone handsets, is a capsule containing carbon granules pressed between two metal plates. A voltage is applied across the metal plates, causing a small current to flow through the carbon. One of the plates, the diaphragm, vibrates in sympathy with incident sound waves, applying a varying pressure to the carbon. The changing pressure deforms the granules, causing the contact area between each pair of adjacent granules to change, and this causes the electrical resistance of the mass of granules to change. The changes in resistance cause a corresponding change in the voltage across the two plates, and hence in the current flowing through the microphone, producing the electrical signal. Carbon microphones were once commonly used in telephones; they have extremely low-quality sound reproduction and a very limited frequency response range, but are very robust devices.
Unlike other microphone types, the carbon microphone can also be used as a type of amplifier, using a small amount of sound energy to produce a larger amount of electrical energy.

All taken From Wikipedia

Artist Talk

Bas Jan Ader
was a Dutch born artist who worked with video, photo, and performance/happenings. Though his choice of media relates him to many artists of his time, his work is more universally accessible because of its dealings with laymen’s verbal play. While Donald Judd and Richard Serra are showcasing at the Whitney’s “When Attitude becomes form” exhibition, Ader employed these new forms without making work whose primary concern was the novelty of its execution. There is something egalitarian about his pieces because they play on common phrases or ideas. You do not need to study any history or art in order to appreciate Ader’s work. What you do need is familiarity with the idioms and verbal constructions he plays on. Because of how literally he takes and uses these phrases, Ader’s work is both surprising and fresh. His art is his ability to subvert the expectation of his audience. Ader is able to snap the viewer, if only for a second, out of and away from his/her typical mode of humdrum mundane thought processes. In this way, his project is not unlike Malevich’s though his means are almost opposite. Still, that is not to say that Ader does not push the boundaries of form. He died while working on a piece called “In search of the Miraculous” which was in part comprised of a voyage on a 12-foot sailboat from Cape Cod mass across the Atlantic. What was inspiring about Bas Jan Ader’s work was his ability to produce pieces that were relevant to both high art culture while maintaining their accessibility to low (popular) culture.



Vehicle

I tied six balloons to a piece of foam core. The had glued a fan through the foam core that was connected to the Arduino. The balloons where balanced and weighted so that the vehicle stayed stationary unless there was a lot of wind. The Ir sensor was supposed to read the distance that the balloons where from it. It would then send pulses to the fan to start so that the vehicle would float up a little. when the fan stopped and the vehicle floated down, when it got back to its original height, the fan would start again.


code:
int fanPin = 1;
int analogPin = 3;
int val = 0;
int threshold = 0;

void setup()
{
pinMode(fanPin, OUTPUT);
pinMode(analogPin, INPUT);
pinMode(fanPin, LOW);
delay(20);
int threshold = analogRead(analogPin);


}

void loop()
{
val = analogRead(analogPin);
if (val <= threshold) {
digitalWrite(fanPin, HIGH);
delay(5000);
digitalWrite(fanPin, LOW);
} else {
digitalWrite(fanPin, LOW);
}
}

game

I made a version of Operation that was a fishing game. There was a wire, sort of fishing rod-shaped, connected to the box that held the cups. If the wire touched the water, it would complete the circuit and the led would blink.
Here is the code I got from the Arduino Tutorials page.:
int ledPin = 13; // LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}