diff --git a/.DS_Store b/.DS_Store index 52ff9d241..b0a5ac3a2 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/java/bin/.DS_Store b/java/bin/.DS_Store index 5147394f7..06be1777a 100644 Binary files a/java/bin/.DS_Store and b/java/bin/.DS_Store differ diff --git a/java/bin/ie/.DS_Store b/java/bin/ie/.DS_Store new file mode 100644 index 000000000..4c75225e9 Binary files /dev/null and b/java/bin/ie/.DS_Store differ diff --git a/java/src/.DS_Store b/java/src/.DS_Store index eae6d6be4..06be1777a 100644 Binary files a/java/src/.DS_Store and b/java/src/.DS_Store differ diff --git a/java/src/d20125581/sphere.java b/java/src/d20125581/sphere.java new file mode 100644 index 000000000..535c6f0e8 --- /dev/null +++ b/java/src/d20125581/sphere.java @@ -0,0 +1,121 @@ + +package d20125581; + +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import processing.core.PApplet; + +public class sphere extends PApplet { + Minim minim; + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + + int mode = 0; + float y = 0; + float smoothedY = 0; + float smoothedAmplitude = 0; + + public void keyPressed() { + if (key >= '0' && key <= '9') { + mode = key - '0'; + } + if (keyCode == ' ') { + if (ap.isPlaying()) { + ap.pause(); + } else { + ap.rewind(); + ap.play(); + } + } + } + + public void settings() { + size(1024, 1000); + // fullScreen(P3D, SPAN); + } + + public void setup() { + + minim = new Minim(this); + ap = minim.loadFile("java/data/horizon.mp3", 1024); + ap.play(); + ab = ap.mix; + colorMode(HSB); + y = height / 2; + smoothedY = y; + + } + + float off = 0; + float lerpedBuffer[] = new float[1024]; + + public void draw() { + float average = 0; + float sum = 0; + off += 1; + + // Calculate sum and average of the samples + // Also lerp each element of buffer; + for (int i = 0; i < ab.size(); i++) { + sum += abs(ab.get(i)); + lerpedBuffer[i] = lerp(lerpedBuffer[i], ab.get(i), 0.1f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + // Calculate sum and average of the samples + // Also lerp each element of buffer; + for (int i = 0; i < ab.size(); i++) { + sum += abs(ab.get(i)); + lerpedBuffer[i] = lerp(lerpedBuffer[i], ab.get(i), 0.1f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + background(0); + noFill(); + translate(width / 2, height / 2); + + // Draw the sphere + float sphereRadius = 300; + int sphereDetail = 30; + for (float i = 0; i < PI; i += PI / sphereDetail) { + float r1 = sin(i) * sphereRadius; + float r2 = sin(i + PI / sphereDetail) * sphereRadius; + for (float j = 0; j < TWO_PI; j += TWO_PI / sphereDetail) { + float theta = random(0, PI); + float x1 = cos(j) * r1; + float y1 = sin(j) * r1; + float x2 = cos(j) * r2; + float y2 = sin(j) * r2; + float c = (int) ((theta / PI) * 255); + stroke(c, 255, 255); + line(x1, y1, -cos(i) * sphereRadius, x2, y2, -cos(i + PI / sphereDetail) * sphereRadius); + } + } + + // Draw the dots + int numDots = 700; + for (int i = 0; i < numDots; i++) { + float theta1 = random(0, PI); + float theta2 = random(0, TWO_PI); + float x = sin(theta1) * cos(theta2) * sphereRadius; + float y = sin(theta1) * sin(theta2) * sphereRadius; + float z = -cos(theta1) * sphereRadius; + float movement = map(smoothedAmplitude, 0, 1, 0, 100); // map amplitude to movement range + x += random(-movement, movement); + y += random(-movement, movement); + z += random(-movement, movement); + float dotSize = map(smoothedAmplitude, 0, 1, 1, 10); // map amplitude to dot size range + ellipse(x, y, dotSize, dotSize); + int hue = (int) ((theta1 / PI) * 255); + fill(hue, 255, 255); + } + + } +} \ No newline at end of file diff --git a/java/src/d20125581/spiralNodes.java b/java/src/d20125581/spiralNodes.java new file mode 100644 index 000000000..a82cef770 --- /dev/null +++ b/java/src/d20125581/spiralNodes.java @@ -0,0 +1,94 @@ +package d20125581; + +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import processing.core.PApplet; +import processing.core.PVector; +import ddf.minim.analysis.*; + +public class spiralNodes extends PApplet { + Minim m; + AudioPlayer player; + FFT fft; + + Node[] nodes = new Node[1200]; + + class Node { + PVector loc; + PVector velocity = new PVector(random(-2, 2), random(-2, 2)); + float size = 10; + float angle = random(0, TWO_PI); + + Node(float x, float y) { + this.loc = new PVector(x, y); + } + + void run(float freq) { + this.display(); + this.move(freq); + this.bounce(); + } + + void display() { + point(loc.x, loc.y); + } + + void move(float freq) { + float spiralSpeed = freq * 0.1f; + angle += spiralSpeed; + float radius = freq * 0.5f; + loc.x += cos(angle) * radius; + loc.y += sin(angle) * radius; + } + + void bounce() { + if ((this.loc.x > width) || (this.loc.x < 0)) { + velocity.x = velocity.x * -1; + } + if ((this.loc.y > height) || (this.loc.y < 0)) { + velocity.y = velocity.y * -1; + } + } + } + + public void settings() { + size(1024, 1000); + } + + public void setup() { + smooth(); + + for (int i = 0; i < nodes.length; i++) { + nodes[i] = new Node(random(width), random(height)); + } + + m = new Minim(this); + player = m.loadFile("java/data/horizon.mp3", 1024); + fft = new FFT(player.bufferSize(), player.sampleRate()); + player.play(); + + } + + public void draw() { + noStroke(); + noCursor(); + background(40, 40, 80); + fft.forward(player.mix); + + for (int i = 0; i < nodes.length; i++) { + float freq = fft.getFreq((float) (dist(nodes[i].loc.x, nodes[i].loc.y, width / 2, height / 2) * 2.2)); + + strokeWeight(freq / 10); + stroke((1 - nodes[i].loc.y / 800) * 255, (nodes[i].loc.x / 800) * 255, (nodes[i].loc.y / 800) * 255); + for (int j = i + 1; j < nodes.length; j++) { + Node other = nodes[j]; + float dist = nodes[i].loc.dist(other.loc); + if (dist > 0 && dist < 60) { + line(nodes[i].loc.x, nodes[i].loc.y, other.loc.x, other.loc.y); + } + } + stroke(255); + nodes[i].run(freq); + } + } +} diff --git a/java/src/ie/.DS_Store b/java/src/ie/.DS_Store new file mode 100644 index 000000000..4c75225e9 Binary files /dev/null and b/java/src/ie/.DS_Store differ