Paso 7: Programación 2
Import SimpleOpenNI.*;
Import ddf.minim.*;
SimpleOpenNI kinect;
int closestValue;
int closestX;
int closestY;
Mínima mínima;
Reproductor de AudioSnippet;
void setup() {}
tamaño (640, 480);
Kinect = new SimpleOpenNI (this);
kinect.enableDepth();
}
void draw() {}
closestValue = 8000;
Kinect.Update();
int [] depthValues = kinect.depthMap();
para (int y = 0 y < 480; y ++) {}
para (int x = 0; x < 640; x ++) {}
int i = x + y * 640;
int currentDepthValue = depthValues [i];
Si (currentDepthValue > 0 & & currentDepthValue < closestValue) {}
closestValue = currentDepthValue;
closestX = x;
closestY = y;
}
}
}
Image(Kinect.depthImage(), 0, 0);
relleno (255, 0, 0, 155);
Rect (20, 0, 40, 480);
relleno (255, 128, 0, 155);
Rect (100, 0, 40, 480);
relleno (255, 255, 0, 155);
Rect (180, 0, 40, 480);
relleno (0, 255, 0, 155);
Rect (260, 0, 40, 480);
relleno (0, 255, 255, 155);
Rect (340, 0, 40, 480);
relleno (0, 0, 255, 155);
Rect (420 0, 40, 480);
relleno (128, 0, 255, 155);
Rect (500, 0, 40, 480);
relleno (255, 0, 255, 155);
Rect (580, 0, 40, 480);
Fill(155);
elipse (closestX, closestY, 20, 20);
Si (closestX < 60) {}
Si (closestX > 20) {}
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound1.wav");
Player.Play();
}
}
Si (closestX < 140) {}
Si (closestX > 100) {}
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound2.wav");
Player.Play();
}
}
Si (closestX < 220) {}
Si {} (closestX > 180)
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound3.wav");
Player.Play();
}
}
Si (closestX < 300) {}
Si (closestX > 260) {}
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound4.wav");
Player.Play();
}
}
Si {} (closestX < 380)
Si {} (closestX > 340)
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound5.wav");
Player.Play();
}
}
Si {} (closestX < 460)
Si {} (closestX > 420)
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound6.wav");
Player.Play();
}
}
Si {} (closestX < 540)
Si {} (closestX > 500)
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound7.wav");
Player.Play();
}
}
Si {} (closestX < 620)
Si {} (closestX > 580)
mínima = nuevo Minim(this);
jugador = minim.loadSnippet("Sound8.wav");
Player.Play();
}
}
}
void stop() {}
Player.Close();
Minim.STOP();
Super.STOP();
}
Con este programa, puede cambiar los sonidos a cualquier archivo .wav. Ir bajo, "Bosquejo," elegir "Add File" y seleccione los sonidos que desee. Sustituir a uno de los sonidos por ejemplo, ("Sound8.wav") con el nombre del nuevo sonido que desea y el programa reproducirá el sonido descargado bajo ese nombre. Con este programa, que desea probar y mantener los sonidos tan cortos como sea posible. Si los sonidos son más que unos segundos, el programa se congele. Esto se puede solucionar en "Archivo" y luego "preferencias," hasta cierto punto, pero el equipo realmente luchas con clips largos.