66
edits
| Line 318: | Line 318: | ||
| [https://vimeo.com/161019179 Part 1 - Interactive Club Map] | [https://vimeo.com/161019179 Part 1 - Interactive Club Map] | ||
| Code: | |||
| <source lang="java"> | |||
| import ddf.minim.*; | |||
| import ddf.minim.analysis.*; | |||
| import ddf.minim.effects.*; | |||
| import ddf.minim.signals.*; | |||
| import ddf.minim.spi.*; | |||
| import ddf.minim.ugens.*; | |||
| import camera3D.*; | |||
| import camera3D.generators.*; | |||
| import camera3D.generators.util.*; | |||
| Minim minim; | |||
| PImage img; | |||
| PImage img1; | |||
| PFont font; | |||
| PFont font1; | |||
| int n = 19;  | |||
| int idx; | |||
| AudioPlayer song; | |||
| BeatDetect beat; | |||
| AudioPlayer[] players = new AudioPlayer[n]; | |||
| float eRadius; | |||
| int[][] locations = { | |||
|  {545, 276, 10}, //1 Humboldthain | |||
|  {782, 470, 10}, //2 Berghain | |||
|  {734, 480, 10}, //3 Tresor | |||
|  {735, 509, 10}, //4 RitterButzke | |||
|  {891, 669, 10}, //5 Grießmühle | |||
|  {945, 589, 10}, //6 WildeRenate | |||
|  {568, 270, 10}, //7 Brunnen70 | |||
|  {673, 278, 10}, //8 AlteKantine | |||
|  {422, 370, 10}, //9 Metaxabay | |||
|  {139, 394, 10}, //10 MiSalsa | |||
|  {93, 437, 10}, //11 Goldelse | |||
|  {574, 508, 10}, //12 Werk9 | |||
|  {645, 343, 10}, //13 Sophienclub | |||
|  {573, 532, 10}, //14 Gretchen | |||
|  {261, 496, 10}, //15 Quasimodo | |||
|  {203, 456, 10}, //16 A-Trane | |||
|  {746, 440, 10}, //17 GoldenGate | |||
|  {526, 373, 10}, //18 BarTausend | |||
|  {707, 397, 10}, //19 HouseOfWeekend | |||
|  }; | |||
| int activeLocation = -1;  | |||
| void setup() { | |||
| minim = new Minim(this);  | |||
| size(1000, 750); | |||
| img = loadImage("map2.jpg"); | |||
| img.resize(1000, 750); | |||
| img1 = loadImage("map1.png"); | |||
| img1.resize(631, 92); | |||
| font = loadFont("DejaVuSansCondensed-Bold-60.vlw"); | |||
| font1 = loadFont("DejaVuSans-ExtraLight-20.vlw"); | |||
| for (int i = 0; i < n; i++) { | |||
| players[i] = minim.loadFile("club-" + (i + 1) + ".mp3"); | |||
| } | |||
| beat = new BeatDetect(); | |||
| rectMode(CORNER); | |||
| eRadius = 10; | |||
| } | |||
| void draw() { | |||
| background(img); | |||
| image(img1, 209, 100);   | |||
| fill(255); | |||
| textFont(font, 60); | |||
| text("THE SOUND OF BERLIN", 50, 65); | |||
| fill(0, 24, 50, 70); | |||
| textFont(font, 60); | |||
| text("THE SOUND OF BERLIN", 50, 70, -10); | |||
| fill(255); | |||
| textFont(font1, 20); | |||
| text("find the stars and hear the sound of your favorite clubs", 190, 95);  | |||
| println(pmouseX, pmouseY); | |||
|  activeLocation = -1;  | |||
|  for(int i = 0; i < locations.length; i ++) { | |||
|    int[] loc = locations[i]; | |||
|    int x1 = loc[0]; | |||
|    int y1 = loc[1]; | |||
|    int r  = loc[2]; | |||
| if(atLocation(x1, y1, r)) { | |||
| activeLocation = i; | |||
|  star(x1, y1, 5, 10, 5);  | |||
|  fill(255); | |||
|  noStroke(); | |||
| players[i].play(); | |||
|  } | |||
| else { | |||
|  players[i].pause();   | |||
|   }   | |||
|  } | |||
| } | |||
| void star(float x, float y, float radius1, float radius2, int npoints) { | |||
|   float angle = TWO_PI / npoints; | |||
|   float halfAngle = angle/2.0; | |||
|   beginShape(); | |||
|   for (float a = 0; a < TWO_PI; a += angle) { | |||
|     float sx = x + cos(a) * radius2; | |||
|     float sy = y + sin(a) * radius2; | |||
|     vertex(sx, sy); | |||
|     sx = x + cos(a+halfAngle) * radius1; | |||
|     sy = y + sin(a+halfAngle) * radius1; | |||
|     vertex(sx, sy); | |||
|   } | |||
|   endShape(CLOSE);  | |||
| } | |||
| 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(); | |||
|  } | |||
| } | |||
| </source> | |||
edits