diff --git a/java/.project b/java/.project index 0d5afed93..38d32a1a1 100644 --- a/java/.project +++ b/java/.project @@ -16,12 +16,12 @@ - 1616413840733 + 1710347678049 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/java/data/Squidward's Tiki Land Psy-Trance Remix.mp3 b/java/data/Squidward's Tiki Land Psy-Trance Remix.mp3 new file mode 100644 index 000000000..eaab33df0 Binary files /dev/null and b/java/data/Squidward's Tiki Land Psy-Trance Remix.mp3 differ diff --git a/java/data/song.mp3 b/java/data/song.mp3 new file mode 100644 index 000000000..c1ad90f3e Binary files /dev/null and b/java/data/song.mp3 differ diff --git a/java/src/c123456/BryansVisual.java b/java/src/c123456/BryansVisual.java index e69de29bb..1fa06045e 100644 --- a/java/src/c123456/BryansVisual.java +++ b/java/src/c123456/BryansVisual.java @@ -0,0 +1,9 @@ +//hello + +//ur mum +//hello im iria + +//hi im moon + +//amberr +//hi im moon again \ No newline at end of file diff --git a/java/src/c21404706/wissamVisual.java b/java/src/c21404706/wissamVisual.java new file mode 100644 index 000000000..3407a9dee --- /dev/null +++ b/java/src/c21404706/wissamVisual.java @@ -0,0 +1,162 @@ + +package c21404706; + +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import processing.*; +import processing.core.PApplet; +import processing.core.PImage; +import ie.tudublin.*; +import processing.core.*; +import java.util.ArrayList; + +public class wissamVisual extends PApplet { + Minim minim; + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + + int mode = 0; + + float[] lerpedBuffer; + 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, P3D); + size(1024, 600, P3D); + // fullScreen(P3D, SPAN); + } + + public void setup() { + minim = new Minim(this); + // Uncomment this to use the microphone + // ai = minim.getLineIn(Minim.MONO, width, 44100, 16); + // ab = ai.mix; + ap = minim.loadFile("Squidward's Tiki Land Psy-Trance Remix.mp3", 1024); + ap.play(); + ab = ap.mix; + colorMode(HSB); + + y = height / 2; + smoothedY = y; + + lerpedBuffer = new float[width]; + } + + float off = 0; + + public void visiual() { + + for (int i = 0; i < ab.size(); i++) { + float cx = width / 2; + lerpedBuffer[i] = lerp(lerpedBuffer[i], ab.get(i), 0.1f); + float hue = map(i, 0, ab.size(), 0, 256); + float s = lerpedBuffer[i] * cx * 2; + + // from left side to right + stroke(hue, 255, 255); + line(0, i, s, i); + // from right side to left + line(width, i, width - s, i); + // from top to bottom + line(i, 0, i, s); + // from bottom to top + line(i, height, i, height - s); + } + + int gridSize = 40; + + for (int x = gridSize; x <= width - gridSize; x += gridSize) { + for (int y = gridSize; y <= height - gridSize; y += gridSize) { + noStroke(); + fill(255); + rect(x-1, y-1, 3, 3); + stroke(255, 100); + line(x, y, width/2, height/2); + } + } + + int num = 60; + float mx[] = new float[num]; + float my[] = new float[num]; + + // Cycle through the array, using a different entry on each frame. + // Using modulo (%) like this is faster than moving all the values over. + int which = frameCount % num; + mx[which] = mouseX; + my[which] = mouseY; + + for (int i = 0; i < num; i++) { + // which+1 is the smallest (the oldest in the array) + int index = (which+1 + i) % num; + ellipse(mx[index], my[index], i, i); + } + + int x; + int y; + float outsideRadius = 150; + float insideRadius = 100; + + int numPoints = (int) map((float) mouseX, 0, (float) width, 6, 60); + float angle = 0; + float angleStep = 180.0f/num; + + beginShape(TRIANGLE_STRIP); + for (int i = 0; i <= numPoints; i++) { + float px = mouseX + cos(radians(angle)) * outsideRadius; + float py = mouseY + sin(radians(angle)) * outsideRadius; + angle += angleStep; + vertex(px, py); + px = mouseX + cos(radians(angle)) * insideRadius; + py = mouseY + sin(radians(angle)) * insideRadius; + vertex(px, py); + angle += angleStep; + } + endShape(); + + } + + + public void draw() { + background(180); + float halfH = height / 2; + 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.05f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + float cx = width / 2; + float cy = height / 2; + + + //calling outline for visiual + visiual(); + } + +} \ No newline at end of file diff --git a/java/src/c22305863/IriaVisual2.java b/java/src/c22305863/IriaVisual2.java new file mode 100644 index 000000000..057538c9a --- /dev/null +++ b/java/src/c22305863/IriaVisual2.java @@ -0,0 +1,135 @@ +package c22305863; + +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import processing.core.PApplet; + +public class IriaVisual2 extends PApplet { + + Minim minim; + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + + int mode = 0; + + float[] lerpedBuffer; + 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, P3D); + // fullScreen(P3D, SPAN); + size(1024, 1000); + } + + public void setup() { + minim = new Minim(this); + // Uncomment this to use the microphone + // ai = minim.getLineIn(Minim.MONO, width, 44100, 16); + // ab = ai.mix; + ap = minim.loadFile("song.mp3", 1024); + ap.play(); + ab = ap.mix; + colorMode(HSB); + + y = height / 2; + smoothedY = y; + + lerpedBuffer = new float[width]; + } + + float off = 0; + + public void draw() { + // background(0); + float halfH = height / 2; + 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.05f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + float cx = width / 2; + float cy = height / 2; + + switch (mode) { + case 0: + background(0); + + break; + case 1: { + background(0); + + break; + } + case 2: { + background(0); + break; + } + + case 3: { + background(0); + // Code goes here + + stroke(165, 180, 360); + noFill(); + strokeWeight(2); + circle(cy * 1f, cy, average * cy * 5); + break; + } + case 4: { + background(0); + // Code goes here + stroke(165, 180, 360); + noFill(); + rectMode(CENTER); + rect(cx, cy, average * width * 2, average * width * 2); + break; + } + case 5: { + background(0); + // Code goes here + for (int i = 0; i < ab.size(); i++) { + + float hue = map(i, 0, ab.size(), 0, 256); + float s = lerpedBuffer[i] * cx; + stroke(hue, 255, 300); + noFill(); + line(cy * s, i * s, s, ab.get(i) + s * 100); + line(cx, cy, cx + cos(TWO_PI / ab.size() * i) * s, cy + sin(TWO_PI / ab.size() * i) * s); + + } + + break; + + } + + } + + } +} diff --git a/java/src/c22305863/iriaVisual.java b/java/src/c22305863/iriaVisual.java new file mode 100644 index 000000000..fcdc735b9 --- /dev/null +++ b/java/src/c22305863/iriaVisual.java @@ -0,0 +1,155 @@ +package c22305863; + +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import processing.core.PApplet; +import ie.tudublin.*; + +public class iriaVisual extends PApplet { + + Minim minim; + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + + int mode = 0; + + float[] lerpedBuffer; + float y = 0; // vertical position + float ySpeed = 2; + 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, 600, P3D); + // fullScreen(P3D, SPAN); + // size(1024,700); + } + + public void setup() { + minim = new Minim(this); + ap = minim.loadFile("Squidward's Tiki Land Psy-Trance Remix.mp3", 1024); + ap.play(); + ab = ap.mix; + colorMode(HSB); + + y = height / 2; + smoothedY = y; + + lerpedBuffer = new float[width]; + } + + float off = 0; + + public void draw() { + float halfH = height / 2; + float average = 0; + float sum = 0; + off += 1; + // calculate sum and average of the samples + // 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.05f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + float cx = width / 2; + float cy = height / 2; + + background(0); + switch (mode) { + case 1: + colorMode(HSB, 360, 100, 100); // mode HSB + background(199, 100, 100); + + // position of the coconuts + float coconutSpacing = 80; // spacing between coconuts + float coconutSize = 100; + float coconutLeftX = coconutSize / 2 + 50; // left coconut + float coconutRightX1 = width - coconutSize / 2 - 150; // right coconut + float coconutRightX2 = width - coconutSize / 2; // right coconut + float coconutY = y; + + // coconut on the left + // noStroke(); + stroke(360, 100, 15); + fill(360, 100, 36); + ellipse(coconutLeftX, coconutY, coconutSize, coconutSize); + + // coconut on the right + ellipse(coconutRightX2, coconutY + coconutSpacing, coconutSize, coconutSize); + ellipse(coconutRightX1, coconutY - coconutSpacing, coconutSize, coconutSize); + + // position of the small circle inside each coconut + float smallCircleSize = 20; // Size of the small circle + float smallCircleOffsetX = coconutSize / 4; + float smallCircleOffsetY = coconutSize / 4; + // draw small circles inside each coconut + stroke(67, 37, 56); + fill(67, 37, 100); // light reflection color + + ellipse(coconutLeftX + smallCircleOffsetX, coconutY - smallCircleOffsetY, smallCircleSize, + smallCircleSize); + ellipse(coconutRightX2 + smallCircleOffsetX, coconutY + coconutSpacing - smallCircleOffsetY, + smallCircleSize, smallCircleSize); + ellipse(coconutRightX1 + smallCircleOffsetX, coconutY - coconutSpacing - smallCircleOffsetY, + smallCircleSize, smallCircleSize); + + // vertical position + y += ySpeed; + if (y > height) { + y = 0; // reset the coconuts position when it reaches the bottom + } + break; + case 2: { + colorMode(HSB, 360, 100, 100); // mode HSB + background(199, 100, 100); + + // small circle inside leaf + //fill(39, 100, 100); + //stroke(285, 100, 75); + //circle(512, 300, average * cy * 5); + for (int i = 0; i < ab.size(); i++) { + + float hue = map(i, 0, ab.size(), 0, 256); + float s = lerpedBuffer[i] * cx; + stroke(hue, 255, 300); + noFill(); + circle(512, 300, average * cy * 5); + //line(cy * s, i * s, s, ab.get(i) + s * 100); + line(512, 300, cx + cos(TWO_PI / ab.size() * i) * s * 2, cy + sin(TWO_PI / ab.size() * i) * s * 2); + + } + + + + + + break; + } + + default: + break; + } + + } +} diff --git a/java/src/example/MyVisual.java b/java/src/example/MyVisual.java index 8a71fe3f6..eff621a83 100644 --- a/java/src/example/MyVisual.java +++ b/java/src/example/MyVisual.java @@ -6,30 +6,35 @@ public class MyVisual extends Visual { WaveForm wf; AudioBandsVisual abv; + int mode = 0; + public void settings() { - size(1024, 500); + //size(1024, 500); // Use this to make fullscreen // fullScreen(); // Use this to make fullscreen and use P3D for 3D graphics - // fullScreen(P3D, SPAN); + fullScreen(P3D, SPAN); } public void setup() { startMinim(); - + colorMode(HSB); // Call loadAudio to load an audio file to process - // loadAudio("heroplanet.mp3"); + loadAudio("song.mp3"); // Call this instead to read audio from the microphone - startListening(); + // startListening(); wf = new WaveForm(this); abv = new AudioBandsVisual(this); } public void keyPressed() { + if (key >= '0' && key <= '9') { + mode = key - '0'; + } if (key == ' ') { getAudioPlayer().cue(0); getAudioPlayer().play(); @@ -37,19 +42,48 @@ public void keyPressed() { } public void draw() { - background(0); - try { - // Call this if you want to use FFT data - calculateFFT(); - } catch (VisualException e) { - e.printStackTrace(); - } - // Call this is you want to use frequency bands - calculateFrequencyBands(); - // Call this is you want to get the average amplitude - calculateAverageAmplitude(); - wf.render(); - abv.render(); + switch (mode) { + case 0: + background(0); + try { + // Call this if you want to use FFT data + calculateFFT(); + } catch (VisualException e) { + e.printStackTrace(); + } + // Call this is you want to use frequency bands + calculateFrequencyBands(); + + // Call this is you want to get the average amplitude + calculateAverageAmplitude(); + wf.render(); + abv.render(); + break; + case 1: + { + float angle = 0; + background(0); + calculateAverageAmplitude(); + stroke(map(getSmoothedAmplitude(), 0, 1, 0, 255), 255, 255); + strokeWeight(5); + noFill(); + lights(); + pushMatrix(); + + camera(0, 0, 0, 0, 0, -1, 0, 1, 0); + translate(0, 0, -200); + rotateX(angle); + rotateZ(angle); + float boxSize = 50 + (200 * getSmoothedAmplitude()); + box(boxSize); + popMatrix(); + angle += 0.01f; + break; + } + + default: + break; + } } } diff --git a/java/src/ie/tudublin/Main.java b/java/src/ie/tudublin/Main.java index 67e93d892..e52b743ce 100644 --- a/java/src/ie/tudublin/Main.java +++ b/java/src/ie/tudublin/Main.java @@ -1,5 +1,8 @@ package ie.tudublin; +import c22305863.iriaVisual; +import c21404706.wissamVisual; +import c22305863.IriaVisual2; import example.CubeVisual; import example.MyVisual; import example.RotatingAudioBands; @@ -8,7 +11,7 @@ public class Main { public void startUI() { String[] a = { "MAIN" }; - processing.core.PApplet.runSketch(a, new MyVisual()); + processing.core.PApplet.runSketch(a, new wissamVisual()); } public static void main(String[] args) {