66
edits
Line 156: | Line 156: | ||
void movieEvent(Movie m) { | void movieEvent(Movie m) { | ||
m.read(); | m.read(); | ||
Line 168: | Line 168: | ||
} | } | ||
} | |||
---- | |||
=== ''Sound Processing - Interactive'' === | |||
import ddf.minim.*; | |||
Minim minim; | |||
int n = 8; | |||
int idx; | |||
AudioPlayer[] players = new AudioPlayer[n]; | |||
int[][] locations = { | |||
{307, 234, 10}, //1 | |||
{425, 222, 10}, //2 | |||
{377, 305, 10}, //3 | |||
{426, 383, 10}, //4 | |||
{552, 224, 10}, //5 | |||
{552, 385, 10}, //6 | |||
{661, 420, 10}, //7 | |||
{560, 310, 10}, //8 | |||
}; | |||
int activeLocation = -1; | |||
PImage img; | |||
void setup() { | |||
size(800, 600); | |||
minim = new Minim(this); | |||
img = loadImage("parkhöhle.jpg"); | |||
for (int i = 0; i < n; i++) { | |||
players[i] = minim.loadFile(“test-" + (i + 1) + ".mp3"); | |||
} | |||
} | |||
void draw() { | |||
image(img, 0, 0); | |||
fill(255, 150); | |||
noStroke(); | |||
activeLocation = -1; | |||
for(int i = 0; i < locations.length; i ++) { | |||
int[] loc = locations[i]; | |||
int x = loc[0]; | |||
int y = loc[1]; | |||
int r = loc[2]; | |||
if(atLocation(x, y, r)) { | |||
activeLocation = i; | |||
ellipse(x, y, 2*r, 2*r); | |||
fill(250, 0); | |||
} | |||
} | |||
} | |||
boolean atLocation(int x, int y, int r) { | |||
return mouseX > (x - r) && mouseX < (x + r) && mouseY > (y - r) && mouseY < (y + r); | |||
} | |||
void mousePressed() { | |||
if(activeLocation != -1) { | |||
for (int i = 0; i < n; i++) { | |||
players[i].pause(); | |||
} | |||
println("Sound number " + (activeLocation + 1)); | |||
players[activeLocation].rewind(); | |||
players[activeLocation].play(); | |||
} | |||
} | |||
void keyPressed() { | |||
for (int i = 0; i < n; i++) { | |||
players[i].pause(); | |||
} | |||
int i = (key - '1'); | |||
if (i >= 0 && i < n) { | |||
println("Sound number " + (i + 1)); | |||
players[i].rewind(); | |||
players[i].play(); | |||
} | |||
} | |||
void keyPressed() { | |||
println(pmouseX, pmouseY); | |||
} | } |
edits