diff --git a/.DS_Store b/.DS_Store index 55c1fcbeb..c003ac12e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 19ba88c75..919a03824 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Music Visualiser Project -Name: - -Student Number: +Student Number and Student Name: Alex Mackey - C22739165 + Aaron Connolly - C22410766 + Sergei Larionov - C22483302 ## Instructions - Fork this repository and use it a starter project for your assignment @@ -11,10 +11,19 @@ Student Number: - There is an example visualiser called MyVisual in the example package - Check out the WaveForm and AudioBandsVisual for examples of how to call the Processing functions from other classes that are not subclasses of PApplet +# IDEAS +0:00 - 0:16 +0:16 - 1:57 +1:57 - 3:04 +3:04 - 4:09 +4:09 - 5:59 + + # Description of the assignment +visuals of Bohemian Rhapsody # Instructions - +merge practice # How it works # What I am most proud of in the assignment diff --git a/java/.DS_Store b/java/.DS_Store index 629e3335c..c08c4803d 100644 Binary files a/java/.DS_Store and b/java/.DS_Store differ diff --git a/java/.project b/java/.project index 0d5afed93..e706f0494 100644 --- a/java/.project +++ b/java/.project @@ -16,12 +16,12 @@ - 1616413840733 + 1710348951264 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/.DS_Store b/java/data/.DS_Store new file mode 100644 index 000000000..730181e4d Binary files /dev/null and b/java/data/.DS_Store differ diff --git a/java/data/QueenBohemianRhapsody.mp3 b/java/data/QueenBohemianRhapsody.mp3 new file mode 100644 index 000000000..615322a8d Binary files /dev/null and b/java/data/QueenBohemianRhapsody.mp3 differ diff --git a/java/data/Section3.mp3 b/java/data/Section3.mp3 new file mode 100644 index 000000000..71f609a6f Binary files /dev/null and b/java/data/Section3.mp3 differ diff --git a/java/data/test.jpg b/java/data/test.jpg new file mode 100644 index 000000000..c126081a4 Binary files /dev/null and b/java/data/test.jpg differ diff --git a/java/src/C22410766/AaronVisual.java b/java/src/C22410766/AaronVisual.java new file mode 100644 index 000000000..3980060a4 --- /dev/null +++ b/java/src/C22410766/AaronVisual.java @@ -0,0 +1,156 @@ +package C22410766; + +import java.util.ArrayList; + +import ie.tudublin.Visual; +import ie.tudublin.VisualException; +import processing.core.PApplet; + + +public class AaronVisual { + Visual visual; + ArrayList particles = new ArrayList<>(); + ArrayList> lineSets = new ArrayList<>(); + + + int len, linesPerBand = 20; + float amplitude, centerX, centerY; + float[] bands; + int radius = 200; + + public AaronVisual(Visual visual) { + this.visual = visual; + visual.startMinim(); + + this.centerX = visual.width / 2; + this.centerY = visual.height / 2; + + + + visual.calculateFrequencyBands(); // Calculate frequency bands + visual.calculateAverageAmplitude(); // Calculate amplitude + this.bands = visual.getSmoothedBands(); // max 667 + this.len = bands.length; + this.amplitude = visual.getSmoothedAmplitude(); // max value is 0.233 + + float[] bandLengthsstart = {radius, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600}; // Example specific lengths for each band + float[] bandLengthsend = {100, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600}; // Example specific lengths for each band + int[] bandColors = {visual.color(255, 255, 125), // Red + visual.color(20, 165, 120), // Orange + visual.color(40, 255, 125), // Yellow + visual.color(100, 255, 125), // Green + visual.color(150, 55, 125), // Blue + visual.color(195, 255, 120), // Indigo + visual.color(218, 230, 128),// Violet + visual.color(225, 230, 125), // Magenta + visual.color(255, 192, 123) // Pink + }; + + for (int i = 0; i < len; i++) { + ArrayList lines = new ArrayList<>(); + for (int j = 0; j < linesPerBand; j++) { + float angle = visual.TWO_PI / linesPerBand * j + visual.TWO_PI / len * i; + float strokeWeight = visual.random(1, 3); + lines.add(new Lines(visual, 0, 0, bandLengthsstart[0], angle, bandLengthsend[i], bandColors[i], strokeWeight)); + } + lineSets.add(lines); + } + + } + + float b = 0; // Angle of rotation + float offset = (float) (visual.PI/24.0); // Angle offset between boxes + int num = 60; + + + + public void draw() { + visual.background(0); + + //float bgHue = visual.map(amplitude, 0, 0.3f, 0, 360); // Use full color wheel + //visual.background(bgHue, 100, 100, 1); // Set background with HSB color mode + + + try { + visual.calculateFFT(); // Perform FFT analysis + } catch (VisualException e) { + e.printStackTrace(); + } + + visual.calculateFrequencyBands(); // Calculate frequency bands + visual.calculateAverageAmplitude(); // Calculate amplitude + bands = visual.getSmoothedBands(); // max 667 + + amplitude = visual.getSmoothedAmplitude(); // max value is 0.233 + float radius = visual.map(amplitude, 0, 0.3f, 200, 400); + + + float hue = visual.map(amplitude, 0.15f, 0.3f, 100, 255); + //visual.strokeWeight(10); + + visual.noFill(); + + visual.lights(); + visual.translate(centerX, centerY); // Center translate to middle of window + float rotateVelocity = visual.map(amplitude, 0.1f, 0.24f, 0.4f, 1.1f) * offset; + + + for (int i = 0; i < num; i++) { + float gray = visual.map(i, 0, num - 1, 0, 255); + visual.pushMatrix(); + //visual.fill(gray); + visual.stroke(hue, 255, 255); + visual.rotateY(b + rotateVelocity * i); // Rotate around Y axis + visual.rotateX(b / 2 + rotateVelocity * i); // Rotate around X axis + visual.ellipse(0, 0, radius, radius); + visual.popMatrix(); + } + + b += 0.01; // Increment angle + if (b > visual.TWO_PI) { // Reset 'b' to avoid overflow + b = 0; + } + // Draw each circle + + + for (int i = particles.size() - 1; i >= 0; i--) { + Particle p = particles.get(i); + p.run(); // Update and display the particle + + if (p.isDead()) { + particles.remove(i); // Remove dead particles + } + } + + // Add new particles based on some condition (e.g., on beats) + int numParticlesToSpawn = (int) (amplitude * 350); // Scale number of particles with amplitude + for (int i = 0; i < numParticlesToSpawn; i++) { + float angle = visual.random(visual.TWO_PI); + float velocityFactor = visual.map(amplitude, 0.1f, 0.24f, 1, 7); // Map the band amplitude to a useful velocity range + particles.add(new Particle(visual, 0, 0, radius/2, angle, velocityFactor)); + } + + + int maxBandIndex = 0; + float maxBandValue = 0; + for (int i = 0; i < len; i++) { + if (bands[i] > maxBandValue) { + maxBandValue = bands[i]; + maxBandIndex = i; + } + } + + + // Draw only the lines of the band with the highest current value + for (int i = 0; i < len; i++) { + for (Lines line : lineSets.get(i)) { + if (i == maxBandIndex) { + line.display(); + } + } + } + + + } + +} diff --git a/java/src/C22410766/Lines.java b/java/src/C22410766/Lines.java new file mode 100644 index 000000000..ddd8993b9 --- /dev/null +++ b/java/src/C22410766/Lines.java @@ -0,0 +1,31 @@ +package C22410766; + +import ie.tudublin.Visual; + +public class Lines { + float x, y, endX, endY; + Visual parent; + float angle, length; + int strokeColor; + float strokeWeight; + + public Lines(Visual parent, float centerX, float centerY, float radius, float angle, float length, int strokeColor, float strokeWeight) { + this.parent = parent; + this.angle = angle; + this.length = length; + this.strokeColor = strokeColor; + this.strokeWeight = strokeWeight; + + this.x = centerX + radius * parent.cos(angle); + this.y = centerY + radius * parent.sin(angle); + this.endX = x + length * parent.cos(angle); + this.endY = y + length * parent.sin(angle); + } + + public void display() { + parent.stroke(strokeColor); + parent.strokeWeight(strokeWeight); + parent.line(x, y, endX, endY); + } +} + diff --git a/java/src/C22410766/Particle.java b/java/src/C22410766/Particle.java new file mode 100644 index 000000000..9ca721255 --- /dev/null +++ b/java/src/C22410766/Particle.java @@ -0,0 +1,45 @@ +package C22410766; + +import processing.core.PApplet; +import ie.tudublin.Visual; + + +public class Particle { + float x, y, vx, vy, life; // Properties for particle position, velocity, and life + Visual parent; // Reference to the Visual class which should be a subclass of PApplet + + // Constructor with correctly named parameters + public Particle(Visual parent, float centerX, float centerY, float radius, float angle, float velocityFactor) { + this.parent = parent; + + // Calculate initial position on the circle edge + this.x = centerX + radius * PApplet.cos(angle); + this.y = centerY + radius * PApplet.sin(angle); + + // Initial velocities, possibly away from the center or tangential + this.vx = PApplet.cos(angle) * velocityFactor; // This could be adjusted + this.vy = PApplet.sin(angle) * velocityFactor; // This could be adjusted + this.life = 255; // Starting life value + } + + public void run() { + update(); + display(); + } + + private void update() { + x += vx; + y += vy; + life -= 2; // Decrease life + } + + private void display() { + parent.stroke(255, life); + parent.strokeWeight(2); + parent.point(x, y); + } + + public boolean isDead() { + return life <= 0; + } +} diff --git a/java/src/C22410766/start.java b/java/src/C22410766/start.java new file mode 100644 index 000000000..04084e162 --- /dev/null +++ b/java/src/C22410766/start.java @@ -0,0 +1,32 @@ +package C22410766; + +import ie.tudublin.Visual; + +public class start { + Visual visual; + + public start(Visual visual) { + this.visual = visual; + + + } + public void draw(){ + visual.background(0); + + float centerX = visual.width / 2; + float centerY = visual.height / 2; + float angle = 0;5 + + angle += 0.01; + + // Set the rotation angle + visual.rotate(angle); + + visual.textSize(50); + visual.text("OOP Visual assignment", centerX-200, centerY); + visual.textSize(30); + visual.text("by Aaron, Alex, Sergei", centerX-200, centerY+50); + + + } +} diff --git a/java/src/C22483302/SergeiAwesomeVisual.java b/java/src/C22483302/SergeiAwesomeVisual.java new file mode 100644 index 000000000..c1636afbe --- /dev/null +++ b/java/src/C22483302/SergeiAwesomeVisual.java @@ -0,0 +1,88 @@ +package C22483302; + +import ie.tudublin.Visual; +import ie.tudublin.VisualException; + +public class SergeiAwesomeVisual{ + + Visual visual; + + public SergeiAwesomeVisual(Visual visual) { + this.visual = visual; + visual.startMinim(); + } + + float b = 0; // angle of rotation + float offset = (float) (visual.PI/24.0); // angle offset between boxes + int num = 60; + +public void draw() { + visual.background(0); + + try { + visual.calculateFFT(); + } catch (VisualException e) { + e.printStackTrace(); + } + + visual.calculateFrequencyBands(); + visual.calculateAverageAmplitude(); + float[] bands = visual.getSmoothedBands(); + float amplitude = visual.getSmoothedAmplitude(); + + float centerX = visual.width / 2; + float centerY = visual.height / 2; + + float rotateSpeed = visual.map(amplitude, 0.1f, 0.5f, 0.02f, 0.2f); + + visual.lights(); + visual.translate(centerX, centerY); + + // adjust overall rotation angle + float orbitAngle = visual.map(amplitude, 0.1f, 0.5f, 0.02f, 0.2f); + b += orbitAngle; + + for (int i = 0; i < num; i++) { + float angle = visual.map(i, 0, num, 0, visual.TWO_PI); + float x = visual.width / 4 * visual.cos(angle); + float y = visual.height / 4 * visual.sin(angle); + + float zOffset = visual.map(bands[i % bands.length], 0, 255, -200, 200); + float shapeSize = visual.map(bands[i % bands.length], 0, 255, 50, 200); + + float hue = visual.map(i, 0, num, 0, 255); + + visual.pushMatrix(); + + // translate and rotate the entire group + visual.translate(x, y, zOffset); + visual.rotateX(b + angle * rotateSpeed); + visual.rotateY(b + angle * rotateSpeed); + + // varying stroke color based on position + visual.stroke(hue, 255, 255); + + // draw different shapes based on amplitude + if (i % 3 == 0) { + visual.box(shapeSize); // draw box + } else if (i % 3 == 1) { + visual.sphere(shapeSize / 2); // draw sphere + } else { + // draw cylinder + int segments = 20; + float radius = shapeSize / 2; + float segmentHeight = shapeSize / segments; + for (int j = 0; j < segments; j++) { + visual.ellipse(0, 0, radius * 2, radius * 2); + visual.translate(0, 0, segmentHeight); + } + } + + visual.popMatrix(); + } + + if (b > visual.TWO_PI) { + b = 0; + } + } +} diff --git a/java/src/C22483302/SergeiAwesomeVisual2.java b/java/src/C22483302/SergeiAwesomeVisual2.java new file mode 100644 index 000000000..96f7aa8fe --- /dev/null +++ b/java/src/C22483302/SergeiAwesomeVisual2.java @@ -0,0 +1,157 @@ +package C22483302; + +import ie.tudublin.Visual; +import ie.tudublin.VisualException; + +public class SergeiAwesomeVisual2 { + + Visual visual; + float amplitude; + + // center coordinates and size of the pyramid base + float baseSize = 200; + + // angle variables for triangle pyramid positions + float angle1 = 0; + float angle2 = Visual.TWO_PI / 3; + float angle3 = 2 * Visual.TWO_PI / 3; + + // eye variables + float eyeSize = 50; + float eyeX; + float eyeY; + + public SergeiAwesomeVisual2(Visual visual) { + this.visual = visual; + visual.startMinim(); + } + + public void draw() { + visual.background(0); + + try { + visual.calculateFFT(); + visual.calculateFrequencyBands(); + visual.calculateAverageAmplitude(); + } catch (VisualException e) { + e.printStackTrace(); + } + + amplitude = visual.getSmoothedAmplitude(); + + // update the angles based on amplitude to create rotation effect + float rotateSpeed = visual.map(amplitude, 0, 1, 0.01f, 0.1f); + angle1 += rotateSpeed; + angle2 += rotateSpeed; + angle3 += rotateSpeed; + + // center of screen + float centerX = visual.width / 2; + float centerY = visual.height / 2; + + // define vertices of pyramid base + float baseY = centerY + baseSize / 2; // Base of the pyramid is centered horizontally + float apexY = centerY - baseSize / 2; // Apex of the pyramid is above the base + + float x0 = centerX; + float y0 = apexY; + float z0 = 0; + + float x1 = centerX + baseSize * visual.cos(angle1); + float y1 = baseY; + float z1 = -baseSize; // base vertex 1 + + float x2 = centerX + baseSize * visual.cos(angle2); + float y2 = baseY; + float z2 = -baseSize; // base vertex 2 + + float x3 = centerX + baseSize * visual.cos(angle3); + float y3 = baseY; + float z3 = -baseSize; // base vertex 3 + + // eye position above pyramid + eyeX = visual.width / 2; + eyeY = centerY - baseSize / 2 - eyeSize; + + float[] bands = visual.getSmoothedBands(); + + float hueWavyLandscape = visual.map(amplitude, 0.15f, 0.3f, 100, 255); + + visual.stroke(100); + visual.strokeWeight(3); + + // draw triangular faces of the pyramid + drawTriangle(x0, y0, z0, x1, y1, z1, x2, y2, z2); // Triangle 1 + drawTriangle(x0, y0, z0, x2, y2, z2, x3, y3, z3); // Triangle 2 + drawTriangle(x0, y0, z0, x3, y3, z3, x1, y1, z1); // Triangle 3 + drawTriangle(x1, y1, z1, x2, y2, z2, x3, y3, z3); // Base triangle + + visual.stroke(hueWavyLandscape, 255, 255); + + drawWavyLandscape(); + + visual.stroke(150); + drawEye(); + } + + private void drawWavyLandscape() { + float stepSize = 10; + float waveHeight = 500; + + // loop through horizontal sections of the screen + for (float x = 0; x < visual.width; x += stepSize) { + visual.beginShape(Visual.TRIANGLE_STRIP); + + float startY = visual.height * 0.7f; + float endY = visual.height + waveHeight; + + for (float y = startY; y <= endY; y += stepSize) { + // calculate yOffset based on amplitude + float amplitudeMapped = visual.map(amplitude, 0, 1, 0, 1); + float noiseValue = visual.noise(x * 0.01f, y * 0.01f); + float yOffset = visual.map(noiseValue, 0, 1, -waveHeight, waveHeight); + yOffset *= amplitudeMapped; // scale wave height based on amplitude + + float clippedY = visual.constrain(y + yOffset, 0, visual.height + waveHeight); + + visual.vertex(x, clippedY); + visual.vertex(x + stepSize, clippedY); + } + + visual.endShape(); + } + } + + private void drawEye() { + + // draw eye + visual.ellipseMode(Visual.CENTER); + visual.ellipse(eyeX, eyeY, eyeSize, eyeSize); + + // calculate pupil size based on amplitude + float basePupilSize = eyeSize * 0.6f; // Base size of the pupil + float amplitudeMapped = visual.map(amplitude, 0, 1, 0.5f, 2.0f); // Map amplitude to range for pupil size + float pupilSize = basePupilSize * amplitudeMapped; // Scaled pupil size based on amplitude + + // calculate pupil position based on mouse cursor + float pupilX = eyeX + visual.map(visual.mouseX, 0, visual.width, -pupilSize * 0.25f, pupilSize * 0.25f); + float pupilY = eyeY + visual.map(visual.mouseY, 0, visual.height, -pupilSize * 0.25f, pupilSize * 0.25f); + + // draw pupil + visual.ellipse(pupilX, pupilY, pupilSize, pupilSize); + } + + + + private void drawTriangle(float x1, float y1, float z1, + float x2, float y2, float z2, + float x3, float y3, float z3) + { + // draw a triangle with specified vertices + visual.beginShape(); + visual.vertex(x1, y1, z1); + visual.vertex(x2, y2, z2); + visual.vertex(x3, y3, z3); + visual.endShape(Visual.CLOSE); // close the triangle + } +} diff --git a/java/src/C22739165/Alex.java b/java/src/C22739165/Alex.java new file mode 100644 index 000000000..51a1c6cf5 --- /dev/null +++ b/java/src/C22739165/Alex.java @@ -0,0 +1,56 @@ +package C22739165; + +import ie.tudublin.Visual; +import ie.tudublin.VisualException; + +import java.util.ArrayList; + +public class Alex { + Visual visual; + ArrayList boxSets; // List of BoxSet objects + RotatingCircles rotatingCircles; + + + public Alex(Visual visual) { + this.visual = visual; + boxSets = new ArrayList(); + + // Create BoxSet instances in a diamond shape + // Top + boxSets.add(new BoxSet(visual, visual.width / 2, visual.height / 4, 10)); + // Right + boxSets.add(new BoxSet(visual, 3 * visual.width / 4, visual.height / 2, 10)); + // Bottom + boxSets.add(new BoxSet(visual, visual.width / 2, 3 * visual.height / 4, 10)); + // Left + boxSets.add(new BoxSet(visual, visual.width / 4, visual.height / 2, 10)); + + //circles + rotatingCircles = new RotatingCircles(visual, 10); + } + + public void draw() { + visual.background(0); // Set the background to black + float intensity = visual.getSmoothedAmplitude(); + visual.background(10 + intensity * 245); // Background changes with amplitude + try { + visual.calculateFFT(); // Perform FFT analysis + } catch (VisualException e) { + e.printStackTrace(); + } + visual.calculateFrequencyBands(); + visual.calculateAverageAmplitude(); + float[] bands = visual.getSmoothedBands(); + float amplitude = visual.getSmoothedAmplitude(); + + // Update and draw each BoxSet with both amplitude and frequency bands + for (BoxSet boxSet : boxSets) { + boxSet.update(amplitude, bands); // Update with the current amplitude and frequency bands + boxSet.draw(); // Draw the box set + } + + rotatingCircles.update(visual.getSmoothedBands()); + rotatingCircles.draw(); // This will overlay the rotating circles on top of the boxes + } +} + diff --git a/java/src/C22739165/BoxClass.java b/java/src/C22739165/BoxClass.java new file mode 100644 index 000000000..efdba874b --- /dev/null +++ b/java/src/C22739165/BoxClass.java @@ -0,0 +1,59 @@ +package C22739165; + +import ie.tudublin.Visual; +import processing.core.PApplet; + +class BoxSet { + Visual visual; + float x, y; // Position + int numBoxes; + float angle = 0; + float amplitude; + float colorR, colorG, colorB; + + BoxSet(Visual visual, float x, float y, int numBoxes) { + this.visual = visual; + this.x = x; + this.y = y; + this.numBoxes = numBoxes; + } + + public void update(float amplitude, float[] bands) { + this.amplitude = amplitude; + if (bands.length >= 3) { + // Implementing gradient based on the band values + colorR = PApplet.map(bands[0], 0, 1, 200, 255); + colorG = PApplet.map(bands[1], 0, 1, 200, 255); + colorB = PApplet.map(bands[2], 0, 1, 200, 255); + } + } + + + public void draw() { + visual.pushMatrix(); + visual.translate(x, y); + + // Ensure the rotation is continuous + angle = (angle + 0.05f) % PApplet.TWO_PI; // Smooth incremental rotation + visual.rotateY(angle); + visual.rotateX(angle / 2); + + for (int i = 0; i < numBoxes; i++) { + visual.pushMatrix(); + float spacing = PApplet.TWO_PI / numBoxes; + float currentAngle = spacing * i; + + visual.stroke(colorR, colorG, colorB); + visual.fill(colorR, colorG, colorB, 150); // Keep the opacity subtle + + visual.rotateY(currentAngle); + visual.rotateX(currentAngle / 2); + // Dynamically increase the size based on the amplitude + float boxSize = 50 + (300 * amplitude); // Base size + scaled with amplitude + visual.translate(50, 0, 0); // Position adjustment for design consistency + visual.box(boxSize); + visual.popMatrix(); + } + visual.popMatrix(); + } +} diff --git a/java/src/C22739165/RotatingCircles.java b/java/src/C22739165/RotatingCircles.java new file mode 100644 index 000000000..4ef1d55c3 --- /dev/null +++ b/java/src/C22739165/RotatingCircles.java @@ -0,0 +1,46 @@ +package C22739165; + +import ie.tudublin.Visual; +import processing.core.PApplet; + +class RotatingCircles { + Visual visual; + float a = 0; // Rotation control + float numCircles; + float[] bands; + + RotatingCircles(Visual visual, int numCircles) { + this.visual = visual; + this.numCircles = numCircles; + this.bands = new float[numCircles]; + } + + public void update(float[] bands) { + System.arraycopy(bands, 0, this.bands, 0, Math.min(this.bands.length, bands.length)); + } + + public void draw() { + visual.lights(); + visual.pushMatrix(); + visual.translate(visual.width / 2, visual.height / 2); + + for (int i = 0; i < numCircles; i++) { + float bandValue = bands[i % bands.length]; + // Adjust the base size and dynamic range, and limit the maximum size of the circles + float circleSize = PApplet.map(bandValue, 0, 1, 20, 50); // Circle size now ranges from 20 to 50 based on bandValue + + float hue = PApplet.map(i, 0, numCircles, 0, 255); // Color mapped across the spectrum + + visual.pushMatrix(); + visual.stroke(hue, 204, 255); // Vibrant colors + visual.fill(hue, 204, 255, 127); // Semi-transparent fill for a cleaner look + visual.rotateY(PApplet.radians(a + i)); + visual.rotateX(PApplet.radians(a / 2 + i)); + visual.circle(0, 0, circleSize); + visual.popMatrix(); + } + + visual.popMatrix(); + a += 0.05; // Maintain rotation speed for smoothness + } +} diff --git a/java/src/Mercury/BohemianRhapsody.java b/java/src/Mercury/BohemianRhapsody.java new file mode 100644 index 000000000..976a5d4e8 --- /dev/null +++ b/java/src/Mercury/BohemianRhapsody.java @@ -0,0 +1,71 @@ +package Mercury; + +import ie.tudublin.Visual; +import C22739165.Alex; +import C22410766.AaronVisual; +import C22410766.start; +import C22483302.SergeiAwesomeVisual; +import C22483302.SergeiAwesomeVisual2; + +public class BohemianRhapsody extends Visual { + int mode = 1; + Alex alex; + AaronVisual aaron; + SergeiAwesomeVisual sergei; + SergeiAwesomeVisual2 sergei2; + start start1; + + public void settings() { + //size(800, 600, P3D); + fullScreen(P3D, SPAN); + } + + public void setup() { + startMinim(); + // Make sure the path is correct. It assumes the file is in the data folder. + loadAudio("java/data/Section3.mp3"); + getAudioPlayer().play(); // Start playing the audio for debugging + colorMode(HSB); + alex = new Alex(this); // Pass 'this' as the PApplet context + aaron = new AaronVisual(this); + sergei = new SergeiAwesomeVisual(this); + sergei2 = new SergeiAwesomeVisual2(this); + start1 = new start(this); + } + + public void keyPressed() { + if (key == 'p') { // Press 'p' to play/pause for testing + if (getAudioPlayer().isPlaying()) { + getAudioPlayer().pause(); + } else { + getAudioPlayer().play(); + } + } + if (key >= '0' && key <= '9') { + mode = key - '0'; + } + } + + public void draw() { + switch (mode) { + case 0: + alex.draw(); + break; + case 1: + aaron.draw(); + break; + case 2: + sergei.draw(); + break; + case 3: + sergei2.draw(); + break; + case 4: + start1.draw(); + break; + default: + background(0); // Default background + break; + } + } +} diff --git a/java/src/c123456/BryansVisual.java b/java/src/c123456/BryansVisual.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/java/src/example/MyVisual.java b/java/src/example/MyVisual.java index 8a71fe3f6..1ed2ee28d 100644 --- a/java/src/example/MyVisual.java +++ b/java/src/example/MyVisual.java @@ -20,10 +20,10 @@ public void setup() { startMinim(); // Call loadAudio to load an audio file to process - // loadAudio("heroplanet.mp3"); + loadAudio("java/data/QueenBohemianRhapsody.mp3"); // Call this instead to read audio from the microphone - startListening(); + //startListening(); wf = new WaveForm(this); abv = new AudioBandsVisual(this); diff --git a/java/src/example/RotatingAudioBands.java b/java/src/example/RotatingAudioBands.java index 72fd7a223..daeb7cae5 100644 --- a/java/src/example/RotatingAudioBands.java +++ b/java/src/example/RotatingAudioBands.java @@ -9,7 +9,7 @@ public class RotatingAudioBands extends Visual { public void settings() { size(800, 800, P3D); - println("CWD: " + System.getProperty("user.dir")); + println("CWD: " + System.getProperty("user.dir")); //fullScreen(P3D, SPAN); } diff --git a/java/src/ie/tudublin/Main.java b/java/src/ie/tudublin/Main.java index 67e93d892..0afae95d2 100644 --- a/java/src/ie/tudublin/Main.java +++ b/java/src/ie/tudublin/Main.java @@ -1,14 +1,14 @@ package ie.tudublin; -import example.CubeVisual; -import example.MyVisual; -import example.RotatingAudioBands; +import Mercury.BohemianRhapsody; + + public class Main { public void startUI() { String[] a = { "MAIN" }; - processing.core.PApplet.runSketch(a, new MyVisual()); + processing.core.PApplet.runSketch(a, new BohemianRhapsody()); } public static void main(String[] args) { diff --git a/java/src/ie/tudublin/Visual.java b/java/src/ie/tudublin/Visual.java index 927fe57b1..ed86f62ad 100644 --- a/java/src/ie/tudublin/Visual.java +++ b/java/src/ie/tudublin/Visual.java @@ -31,6 +31,7 @@ public void startMinim() bands = new float[(int) log2(frameSize)]; smoothedBands = new float[bands.length]; + } @@ -38,7 +39,7 @@ float log2(float f) { return log(f) / log(2.0f); } - protected void calculateFFT() throws VisualException + public void calculateFFT() throws VisualException { fft.window(FFT.HAMMING); if (ab != null) @@ -64,7 +65,7 @@ public void calculateAverageAmplitude() } - protected void calculateFrequencyBands() { + public void calculateFrequencyBands() { for (int i = 0; i < bands.length; i++) { int start = (int) pow(2, i) - 1; int w = (int) pow(2, i); diff --git a/java/src/visual/Lines.java b/java/src/visual/Lines.java new file mode 100644 index 000000000..b8326db64 --- /dev/null +++ b/java/src/visual/Lines.java @@ -0,0 +1,5 @@ +package visual; + +public class Lines { + +}