diff --git a/.DS_Store b/.DS_Store index 55c1fcbeb..06afb2b8b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 19ba88c75..9976e4fcf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Music Visualiser Project -Name: +Name: Cecilia Luan Student Number: diff --git a/java/.DS_Store b/java/.DS_Store index 629e3335c..0b831e57c 100644 Binary files a/java/.DS_Store and b/java/.DS_Store differ diff --git a/java/.project b/java/.project index 0d5afed93..30f59a9de 100644 --- a/java/.project +++ b/java/.project @@ -16,12 +16,12 @@ - 1616413840733 + 1680783242009 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/bin/ie/tudublin/Log.txt b/java/bin/ie/tudublin/Log.txt new file mode 100644 index 000000000..950e57c10 --- /dev/null +++ b/java/bin/ie/tudublin/Log.txt @@ -0,0 +1,49 @@ +6/04/23 :- +Went on call with cece and ad file for mp3 player , +expeirnce file and started our projected + +how to you play a file from another file + +we each have 35 seconds in the () +THIS IS + +this is HADASSAH +Love always feels better when it's true +Love tastes way too bitter when it's you +I'm all out of love, you gave it away +I'm hoping that experience can get you to change +I'm hoping that experience can get you to change +I'm hoping that (ooh, oh) +I'm all out of love, you gave it away +I'm hoping that experience can get you to change +I'm hoping that experience can get you to change +I'm hoping that + +THIS IS cece +Love's no pressure +When it's with someone who tends to +All of your emotions, know you'll +Find someone who's there for you +Find someone who's there for you +Love always feels better when it's true +Love tastes way too bitter when it's you +end 1:35 + +end at 2:10 + + +idea +peace sign +reacord player +grovey pattern +gathered particles beating out +write experiance at the end +cece qriting words goinfg aroud her cirlce + +begin stars shooting dwon enters ino syclidlic area then says :- welcome to experianc +ends with stars shooting out to fast white shoot and the words expeoirance has concluded written + + +cece wants to add a stem to her flower that looks similar to a sound wave +aisha wnats to +hadassah wants to try particle thing , change the colour to silver flashing lights diff --git a/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3 b/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3 new file mode 100644 index 000000000..b7285dce1 Binary files /dev/null and b/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3 differ diff --git a/java/src/assaigment/DiscoBall.java b/java/src/assaigment/DiscoBall.java new file mode 100644 index 000000000..43a7cad98 --- /dev/null +++ b/java/src/assaigment/DiscoBall.java @@ -0,0 +1,190 @@ + + + +package assaigment; + +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.AudioSource; +import ddf.minim.Minim; +import ddf.minim.analysis.FFT; +import jogamp.opengl.glu.nurbs.Curve; +import processing.core.PApplet; + +public class DiscoBall extends PApplet { + + Minim minim; + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + FFT fft; + + + int mode = 0; + float theta = 0; + float rotationSpeed = (float) 0.01; + + public void settings() { + + size(800, 800, P3D); + noSmooth(); + + } + + + public void setup() { + + minim = new Minim(this); + ap = minim.loadFile("Victoria_Mon_t_ft_Khalid_-_Experience.mp3", 1024); + ap.play(); + ap.loop(); + ab = ap.mix; + fft = new FFT(ab.size(), ((AudioSource) ap).sampleRate()); + + // Create gradient background + for (int y = 0; y < height; y++) { + + // Calculate the color at each row + int c = lerpColor(color(139, 0, 139), color(255, 140, 0), map2(y, 0, height, 0, 1)); + + // Set the color for the row + stroke(c); + + // Draw a line for the row + line(0, y, width, y); + + } + } + + public void draw() { + + + pushMatrix(); // Save the current transformation matrix + + // displays hearts on the screen + for (int i = 0; i < 5; i++) { + + Heart heart = new Heart(); + heart.display(); + + } + + popMatrix(); // Restore the previous transformation matrix + + translate(width/2, height/2, 0); // Move the sphere to the center of the screen + float angle = (float) (frameCount * 0.01); // Use a fixed rotation speed based on frame count + rotateY(angle); // Rotate the sphere based on the angle + + fft = new FFT(ap.bufferSize(), ap.sampleRate()); // Initialize FFT with the audio buffer size and sample rate + fft.forward(ab); // Perform FFT on the audio buffer + float[] spectrum = fft.getSpectrumImaginary(); // Get frequency spectrum data + + + float sum = 0; + + for (int i = 0; i < spectrum.length; i++) { + + sum += spectrum[i]; // Calculate the sum of all frequency values + + } + float average = sum / spectrum.length; // Calculate the average frequency value + + rotationSpeed = map2(average, 0, 255, 0.001, 0.1); // Map the average frequency value to a rotation speed range + rotateY(rotationSpeed * frameCount); // Rotate the sphere based on the current frame count and rotation speed + + // set the thickness of the lines in the disco ball + stroke(204,204,255); + strokeWeight((float) 3.5); // sets the thickness of lines in the disco Ball + line(0, -250, 0, 0); + + + + fill(160,160,160);// set th colour of the sphere + sphere(250); // Draw the sphere + + discoBallRope(); + + + } + + private float map2(float value, double f, double g, double d, double e) { + + return (float) (d + (e - d) * ((value - f) / (g - f))); + + } + + + void discoBallRope() { + + stroke(192,192,192); + strokeWeight(10); // Set the thickness of the line + line(0, 0, 0, 0, -height/2, 0); // Draw the line from the top of the sphere to the top of the screen + + } + + class Heart { + + float heartSize; + float heartX; + float heartBottomY; + float r; + + Heart() { + + heartSize = random(10, 100); + heartX = random(width); + heartBottomY = random(height+heartSize); + r = random(255); + + } + + + + + void display() { + + + float level = ap.mix.level(); + + if (level > 0.1) { + + // Set heart position and color + heartX = random(width); + heartBottomY = random(height+heartSize); + r = random(255); + + } + + fill(r, 0, 0); + stroke(r, 0, 0); + + //left half of heart + beginShape(); + curveVertex(heartX, heartBottomY+heartSize); //anchor point + curveVertex(heartX, heartBottomY); //bottom tip + curveVertex(heartX - heartSize/2, (float) (heartBottomY-heartSize/1.5)); //left edge + curveVertex(heartX - heartSize/3, heartBottomY-heartSize); //top of left edge + curveVertex(heartX, (float) (heartBottomY-heartSize*.75)); //top middle dip + curveVertex(heartX, heartBottomY); //guiding point + endShape(); + + //right half of heart + beginShape(); + curveVertex(heartX, heartBottomY); + curveVertex(heartX, (float) (heartBottomY-heartSize*.75)); + curveVertex(heartX + heartSize/3, heartBottomY-heartSize); + curveVertex(heartX + heartSize/2, (float) (heartBottomY-heartSize/1.5)); + curveVertex(heartX, heartBottomY); + curveVertex(heartX, heartBottomY + heartSize); + endShape(); + + } + + + + + + } + +} diff --git a/java/src/assaigment/Main.java b/java/src/assaigment/Main.java new file mode 100644 index 000000000..943c1c896 --- /dev/null +++ b/java/src/assaigment/Main.java @@ -0,0 +1,38 @@ +package assaigment; + + +import ie.tudublin.Experiance; + +public class Main +{ + + public void startUI() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new stars()); + } + public void discoBallUI() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new DiscoBall()); + } + + public void music_noteUI() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new music_note()); + + } + + public void experianceUI() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new Experiance()); + } + + public static void main(String[] args) + { + Main main = new Main(); + main.startUI(); + } +} \ No newline at end of file diff --git a/java/src/ie/tudublin/Visual.java b/java/src/assaigment/Visual.java similarity index 93% rename from java/src/ie/tudublin/Visual.java rename to java/src/assaigment/Visual.java index 927fe57b1..e2bf13a43 100644 --- a/java/src/ie/tudublin/Visual.java +++ b/java/src/assaigment/Visual.java @@ -1,146 +1,146 @@ -package ie.tudublin; - -import processing.core.PApplet; -import ddf.minim.*; -import ddf.minim.analysis.FFT; - -public abstract class Visual extends PApplet -{ - private int frameSize = 512; - private int sampleRate = 44100; - - private float[] bands; - private float[] smoothedBands; - - private Minim minim; - private AudioInput ai; - private AudioPlayer ap; - private AudioBuffer ab; - private FFT fft; - - private float amplitude = 0; - private float smothedAmplitude = 0; - - - - public void startMinim() - { - minim = new Minim(this); - - fft = new FFT(frameSize, sampleRate); - - bands = new float[(int) log2(frameSize)]; - smoothedBands = new float[bands.length]; - - } - - float log2(float f) { - return log(f) / log(2.0f); - } - - protected void calculateFFT() throws VisualException - { - fft.window(FFT.HAMMING); - if (ab != null) - { - fft.forward(ab); - } - else - { - throw new VisualException("You must call startListening or loadAudio before calling fft"); - } - } - - - public void calculateAverageAmplitude() - { - float total = 0; - for(int i = 0 ; i < ab.size() ; i ++) - { - total += abs(ab.get(i)); - } - amplitude = total / ab.size(); - smothedAmplitude = PApplet.lerp(smothedAmplitude, amplitude, 0.1f); - } - - - protected void calculateFrequencyBands() { - for (int i = 0; i < bands.length; i++) { - int start = (int) pow(2, i) - 1; - int w = (int) pow(2, i); - int end = start + w; - float average = 0; - for (int j = start; j < end; j++) { - average += fft.getBand(j) * (j + 1); - } - average /= (float) w; - bands[i] = average * 5.0f; - smoothedBands[i] = lerp(smoothedBands[i], bands[i], 0.05f); - } - } - - public void startListening() - { - ai = minim.getLineIn(Minim.MONO, frameSize, 44100, 16); - ab = ai.left; - } - - public void loadAudio(String filename) - { - ap = minim.loadFile(filename, frameSize); - ab = ap.mix; - } - - public int getFrameSize() { - return frameSize; - } - - public void setFrameSize(int frameSize) { - this.frameSize = frameSize; - } - - public int getSampleRate() { - return sampleRate; - } - - public void setSampleRate(int sampleRate) { - this.sampleRate = sampleRate; - } - - public float[] getBands() { - return bands; - } - - public float[] getSmoothedBands() { - return smoothedBands; - } - - public Minim getMinim() { - return minim; - } - - public AudioInput getAudioInput() { - return ai; - } - - - public AudioBuffer getAudioBuffer() { - return ab; - } - - public float getAmplitude() { - return amplitude; - } - - public float getSmoothedAmplitude() { - return smothedAmplitude; - } - - public AudioPlayer getAudioPlayer() { - return ap; - } - - public FFT getFFT() { - return fft; - } -} +package assaigment; + +import processing.core.PApplet; +import ddf.minim.*; +import ddf.minim.analysis.FFT; + +public abstract class Visual extends PApplet +{ + private int frameSize = 512; + private int sampleRate = 44100; + + private float[] bands; + private float[] smoothedBands; + + private Minim minim; + private AudioInput ai; + private AudioPlayer ap; + private AudioBuffer ab; + private FFT fft; + + private float amplitude = 0; + private float smothedAmplitude = 0; + + + + public void startMinim() + { + minim = new Minim(this); + + fft = new FFT(frameSize, sampleRate); + + bands = new float[(int) log2(frameSize)]; + smoothedBands = new float[bands.length]; + + } + + float log2(float f) { + return log(f) / log(2.0f); + } + + protected void calculateFFT() throws VisualException + { + fft.window(FFT.HAMMING); + if (ab != null) + { + fft.forward(ab); + } + else + { + throw new VisualException("You must call startListening or loadAudio before calling fft"); + } + } + + + public void calculateAverageAmplitude() + { + float total = 0; + for(int i = 0 ; i < ab.size() ; i ++) + { + total += abs(ab.get(i)); + } + amplitude = total / ab.size(); + smothedAmplitude = PApplet.lerp(smothedAmplitude, amplitude, 0.1f); + } + + + protected void calculateFrequencyBands() { + for (int i = 0; i < bands.length; i++) { + int start = (int) pow(2, i) - 1; + int w = (int) pow(2, i); + int end = start + w; + float average = 0; + for (int j = start; j < end; j++) { + average += fft.getBand(j) * (j + 1); + } + average /= (float) w; + bands[i] = average * 5.0f; + smoothedBands[i] = lerp(smoothedBands[i], bands[i], 0.05f); + } + } + + public void startListening() + { + ai = minim.getLineIn(Minim.MONO, frameSize, 44100, 16); + ab = ai.left; + } + + public void loadAudio(String filename) + { + ap = minim.loadFile(filename, frameSize); + ab = ap.mix; + } + + public int getFrameSize() { + return frameSize; + } + + public void setFrameSize(int frameSize) { + this.frameSize = frameSize; + } + + public int getSampleRate() { + return sampleRate; + } + + public void setSampleRate(int sampleRate) { + this.sampleRate = sampleRate; + } + + public float[] getBands() { + return bands; + } + + public float[] getSmoothedBands() { + return smoothedBands; + } + + public Minim getMinim() { + return minim; + } + + public AudioInput getAudioInput() { + return ai; + } + + + public AudioBuffer getAudioBuffer() { + return ab; + } + + public float getAmplitude() { + return amplitude; + } + + public float getSmoothedAmplitude() { + return smothedAmplitude; + } + + public AudioPlayer getAudioPlayer() { + return ap; + } + + public FFT getFFT() { + return fft; + } +} \ No newline at end of file diff --git a/java/src/ie/tudublin/VisualException.java b/java/src/assaigment/VisualException.java similarity index 88% rename from java/src/ie/tudublin/VisualException.java rename to java/src/assaigment/VisualException.java index 65381bcb2..570cece25 100644 --- a/java/src/ie/tudublin/VisualException.java +++ b/java/src/assaigment/VisualException.java @@ -1,21 +1,21 @@ -package ie.tudublin; - -public class VisualException extends Throwable -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - private String message; - - public VisualException(String message) - { - this.message = message; - } - - public String toString() - { - return message; - } +package assaigment; + +public class VisualException extends Throwable +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + private String message; + + public VisualException(String message) + { + this.message = message; + } + + public String toString() + { + return message; + } } \ No newline at end of file diff --git a/java/src/assaigment/music_note.java b/java/src/assaigment/music_note.java new file mode 100644 index 000000000..2656360b8 --- /dev/null +++ b/java/src/assaigment/music_note.java @@ -0,0 +1,267 @@ +package assaigment; + +import java.util.ArrayList; +import processing.core.PApplet; +import ddf.minim.*; +import ddf.minim.analysis.FFT; +import ie.tudublin.Experiance; + +public class music_note extends Visual +{ + AudioPlayer ap; + AudioInput ai; + AudioBuffer ab; + float colour = 0; + int mode = 0; + + FFT fft; + + Star[] stars; + + Experiance pa; + + public void settings() + { + size(1024,1024, P3D); + smooth(); + } + + public void setup() + { + colorMode(HSB); + + // create star objects + stars = new Star[25]; + for (int i = 0; i < stars.length; i++) + { + float x = random(width); + float y = random(height); + float size = random(20, 100); + float speed = random(1, 5); + stars[i] = new Star(this, x, y, size, speed, height, width, stars); + } + startMinim(); + loadAudio("MusicVisuals/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3"); + getAudioPlayer().play(); + } + + + public void draw() + { + background(0); + float amplitude = 0; + float[] bands; + frameRate(50); + + calculateAverageAmplitude(); + amplitude = getSmoothedAmplitude(); + + try + { + calculateFFT(); + } + catch(VisualException e) + { + e.printStackTrace(); + } + calculateFrequencyBands(); + bands = getSmoothedBands(); + + pushMatrix(); + + // loop through al stars in the stars array + for (int i = 0; i < stars.length; i++) + { + Star star = stars[i]; + star.update(); + float size = map(amplitude, 0, 1, 30, 200); + star.size = size; + star.display(bands); + } + + popMatrix(); + drawNotes(bands); + } + + public void drawNotes(float[] bands) + { + pushMatrix(); + stroke(255); + strokeWeight(4); + + // for drawing the notes + int staffHeight = 200; + int staffWidth = width - 300; + int staffY = height/2 + 50; + int staffX = width/2 - staffWidth/2; + int staffSpacing = height / 10; + + int noteSize = width / 25; + int noteX = staffX + staffWidth/10; + int noteY = staffY - staffHeight/5; + int noteDistance = width / 10; + + // for colour of notes + int frameCount = 0; + int colourChangeInterval = 20; + int colour = 0; + + // for drawing the staff on the screen + strokeWeight(1); + for (int i = 0; i < 5; i++) { + int y = staffY - (2 * staffHeight/5) + (i * staffHeight/5); + line(staffX, y, staffX + staffWidth, y); + } + + + // set colour of notes to change + if (frameCount % colourChangeInterval == 0) { + colour = (int) map(bands[2], 0, 255, 0, 255); + } + frameCount++; + + + smooth(); + strokeWeight(4); + int noteX2 = noteX + staffSpacing*2; + int noteY2 = noteY + staffSpacing; + + // Calculate the vertical position of the notes based on the amplitude + float amplitude = getSmoothedAmplitude(); + float yOffset = map(amplitude, 0, 1, -staffHeight/3, staffHeight/2); + + fill(colour, 255, 255); + + // draw first note + ellipse(noteX + noteDistance - 10, noteY2 + yOffset, noteSize, noteSize); + line(noteX + noteDistance + 10, noteY2 + yOffset, noteX + noteDistance, staffY - staffHeight/5 + yOffset); + + ellipse(noteX2 - 10, noteY + (noteDistance/2 + 10) + yOffset, noteSize, noteSize); + line(noteX2 + 10, noteY + (noteDistance/2 + 10) + yOffset, noteX2, staffY - staffHeight/3 + yOffset); + + // connect note + line(noteX + noteDistance, noteY2 - staffSpacing + yOffset, noteX2, noteY - staffSpacing/4 + yOffset); + + // another note + fill(colour, 255, 255); + + ellipse((noteX2 - 10) * 2, noteY + (noteDistance/2 + 10) + yOffset, noteSize, noteSize); + line(noteX2 * 2, noteY + (noteDistance/2 + 10) + yOffset, noteX2 * 2, noteY - staffHeight/15 + yOffset); + + ellipse((noteX + noteDistance - 10) * 2, noteY2 - (noteDistance - 20) + yOffset, noteSize, noteSize); + line((noteX + noteDistance) * 2, noteY2 - (noteDistance - 20) + yOffset, (noteX + noteDistance) * 2, staffY - staffHeight/2 + yOffset); + + // connect note + line((noteX + noteDistance) * 2, staffY - staffHeight/2 + yOffset, noteX2 * 2, noteY - staffHeight/15 + yOffset); + + popMatrix(); + } +} + +class Star extends PApplet +{ + + PApplet p; + float x; + float y; + float size; + float speed; + float height; + float width; + float rotate_Star; + int num_point = 5; + Star[] stars; + int i = 0; + + int colourIndex = (int) random(3); + ArrayList colours = new ArrayList(); + int frameCount = 0; + int colourChangeInterval = 20; // Change colour every 20 frames + + Star(PApplet p, float x, float y, float size, float speed, float height, float width, Star[] stars) + { + this.p = p; + this.x = x; + this.y = y; + this.size = size; + this.speed = speed; + this.height = height; + this.width = width; + this.rotate_Star = 0; + this.stars = stars; + + // initialise colours array list + colours.add(color(230, 0, 255)); + colours.add(color(255, 232, 31)); + colours.add(color(255, 209, 220)); + } + + + void update() + { + y += speed; + rotate_Star += 0.01; + + // star still on screen, update it + if (y > height) + { + y = 0; + x = p.random(width); + size = p.random(20, 200); + speed = p.random(1, 4); + } + else if (y < 0) // reset star to fall from the top of the screen again + { + y = height; + } + + } + + void display(float[] bands) + { + p.pushMatrix(); + p.translate(x, y); + p.rotate(rotate_Star); + p.scale(size/300); + p.noStroke(); + + + // Only change colour every colourChangeInterval frames + if (frameCount % colourChangeInterval == 0) { + colourIndex = (colourIndex + 1) % colours.size(); + } + frameCount++; + + // change colour of stars + p.fill(colours.get(colourIndex)); + + p.beginShape(); + + // change number of points for the star based on the fifth audio frequency band value + num_point = (int) map(bands[4], 0, 255, 5, 10); + for (int i = 0; i < num_point; i++) + { + // calculate angle of the current point + float angle = TWO_PI * i / num_point; + + // calculate the angle of first vertex + float x = cos(angle) * 100; + float y = sin(angle) * 100; + + // add vertex to shape + p.vertex(x, y); + + // get next vertex + angle += TWO_PI / (num_point * 2); + x = cos(angle) * 50; + y = sin(angle) * 50; + + // add vertex to shape + p.vertex(x, y); + } + + p.endShape(); + p.popMatrix(); + } + +} diff --git a/java/src/assaigment/stars.java b/java/src/assaigment/stars.java new file mode 100644 index 000000000..f097cb014 --- /dev/null +++ b/java/src/assaigment/stars.java @@ -0,0 +1,263 @@ +package assaigment; + +import java.util.ArrayList; +import ddf.minim.*; +import ddf.minim.analysis.*; +import processing.core.PApplet; + +public class stars extends PApplet { + + Minim minim; + AudioPlayer player; + FFT fft; + + AudioInput ai; + AudioBuffer ab; + + Heart leftHeart; + Heart rightHeart; + + int mode = 0; + + float y = 0; + float smoothedY = 0; + float smoothedAmplitude = 0; + + ArrayList particles = new ArrayList(); + + public void settings() { + size(1024, 1000, P3D); + // fullScreen(P3D, SPAN); + } + + public void setup() { + start(); + + minim = new Minim(this); + player = minim.loadFile("MusicVisuals/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3", 512); + player.play(); + ab = player.mix; + + fft = new FFT(player.bufferSize(), player.sampleRate()); + + for (int i = 0; i < 100; i++) { + Particle p = new Particle(); + particles.add(p); + } + + y = height / 2; + smoothedY = y; + + // Create the left and right hearts + leftHeart = new Heart(width * 0.2f, height / 2, 10, color(255, 0, 0)); + rightHeart = new Heart(width * 0.8f, height / 2, 10, color(255, 0, 0)); + + } + + float off = 0; + + float lerpedBuffer[] = new float[1024]; + + void drawDaisy() { + + + // Set the center point of the daisy + float centerX = width / 2; + float centerY = height / 2; + float average = 0; + float sum = 0; + + + + // Set the size of the daisy + float daisySize = 200; + + // Calculate sum and average of the samples + for (int i = 0; i < ab.size(); i++) { + sum += abs(ab.get(i)); + } + average = sum / (float) ab.size(); + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.2f); + + // Map the amplitude value to a range of values that will control the size of + // the center circle + float size = map(smoothedAmplitude, 0, 1, 130, 800); + + // Set the color of the daisy + fill(255, 255, 0); // yellow + + // Draw the center of the daisy with the mapped size value + ellipse(centerX, centerY, size, size); + + // Draw the petals of the daisy + fill(255, 255, 255); // white + for (int i = 0; i < 6; i++) { + float angle = i * TWO_PI / 6; + float petalX = centerX + cos(angle) * (daisySize / 2); + float petalY = centerY + sin(angle) * (daisySize / 2); + pushMatrix(); + translate(petalX, petalY); + rotate(angle); + ellipse(0, 0, 110, 100); + popMatrix(); + } + + // Set the color of the daisy + fill(255, 255, 0); // yellow + + // Draw the center of the daisy with the mapped size value + ellipse(centerX, centerY, 130, 130); + + // Set the color and stroke for the smile + // Draw the smile + strokeWeight(5); + stroke(0); + noFill(); + arc(centerX, centerY + 25, 60, 60, 0, PI); + + // Draw the eyes + fill(0); + noStroke(); + ellipse(centerX - 25, centerY - 10, 20, 20); + ellipse(centerX + 25, centerY - 10, 20, 20); + + // blush + fill(255, 192, 203); + noStroke(); + ellipse(centerX - 35, centerY + 9, 15, 10); + ellipse(centerX + 35, centerY + 9, 15, 10); + } + + void drawstem() { + pushMatrix(); // save the current coordinate system + float halfH = (height / 2) + 65; + float halfW = (width / 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.1f); + } + average = sum / (float) ab.size(); + + smoothedAmplitude = lerp(smoothedAmplitude, average, 0.1f); + + for (int i = 0; i < ab.size(); i++) { + float x = halfW - (lerpedBuffer[i] * halfH * 0.5f); + float y = map(i, 0, ab.size(), halfH, height); + stroke(map(i, 0, ab.size(), 0, 255), 252, 0); + line(halfW, y, x, y); + } + popMatrix(); // restore the previous coordinate system + } + + public void draw() { + background(0); + drawDaisy(); + drawstem(); + + + + fft.forward(player.mix); + + // maintain a variable number of particles between 10 and 20 + int minParticles = 10; + int maxParticles = 20; + int numParticles = particles.size(); + int targetParticles = (int) map(fft.getBand(20), 0, 1, minParticles, maxParticles); + if (numParticles < targetParticles) { + for (int i = 0; i < targetParticles - numParticles; i++) { + Particle p = new Particle(); + particles.add(p); + } + } else if (numParticles > targetParticles) { + particles.subList(targetParticles, numParticles).clear(); + } + + for (int i = 0; i < particles.size(); i++) { + Particle p = particles.get(i); + p.update(); + p.draw(); + } + + // Update the left and right hearts based on the audio amplitude + leftHeart.update(smoothedAmplitude); + rightHeart.update(smoothedAmplitude); + + // Draw the left and right hearts + leftHeart.draw(); + rightHeart.draw(); + } + + class Particle { + float x, y; + float vx, vy; + float size; + int color; + + Particle() { + x = random(width); + y = random(height); + vx = random(-1, 1); + vy = 4; // set the falling speed to a constant value of 2 + size = random(10, 20); + color = color(random(255), random(255), random(255)); + } + + void update() { + x += vx; + y += vy; + + if (y > height) { + y = 0; + } + } + + void draw() { + int index = (int) map(x, 100, width, 100, fft.specSize()); + float amplitude = fft.getBand(index); + + size = amplitude * 70; + // limit the maximum size + if (size > 50) { + size = 50; + } + fill(color); + noStroke(); + ellipse(x, y, size, size); + } + } + class Heart { + float x, y; + float size; + int color; + + Heart(float x, float y, float size, int color) { + this.x = x; + this.y = y; + this.size = size; + this.color = color; + } + + void draw() { + // Draw the heart shape using bezier curves + smooth(); + noStroke(); + fill(color); + beginShape(); + vertex(x, y); + bezierVertex(x - size * 1, y - size * 2, x - size * 3, y + size / 2, x, y + size * 2); + bezierVertex(x + size * 3, y + size / 2, x + size * 1, y - size * 2, x, y); + endShape(); + } + + void update(float amplitude) { + // Map the amplitude value to a range of values that will control the size of the heart + size = map(amplitude, 0, 1, 25, 100); + } + } +} \ No newline at end of file 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/CubeVisual.java b/java/src/example/CubeVisual.java index ff8e58798..8f6c506b2 100644 --- a/java/src/example/CubeVisual.java +++ b/java/src/example/CubeVisual.java @@ -1,6 +1,6 @@ package example; -import ie.tudublin.Visual; +import assaigment.Visual; public class CubeVisual extends Visual { diff --git a/java/src/example/CubeVisual1.java b/java/src/example/CubeVisual1.java index 8eebd97f8..ffff3aea1 100644 --- a/java/src/example/CubeVisual1.java +++ b/java/src/example/CubeVisual1.java @@ -1,6 +1,6 @@ package example; -import ie.tudublin.Visual; +import assaigment.Visual; public class CubeVisual1 extends Visual { diff --git a/java/src/example/MyVisual.java b/java/src/example/MyVisual.java index 849e71bc2..2dc28fa7a 100644 --- a/java/src/example/MyVisual.java +++ b/java/src/example/MyVisual.java @@ -1,13 +1,18 @@ package example; +import assaigment.Visual; +import assaigment.VisualException; import ie.tudublin.*; public class MyVisual extends Visual { WaveForm wf; - AudioBandsVisual abv; + // AudioBandsVisual abv; - public void settings() + public MyVisual() { + } + + public void settings() { size(1024, 500); @@ -29,8 +34,8 @@ public void setup() // Call this instead to read audio from the microphone startListening(); - wf = new WaveForm(this); - abv = new AudioBandsVisual(this); + // wf = new WaveForm(this); + // abv = new AudioBandsVisual(this); } public void keyPressed() @@ -60,6 +65,6 @@ public void draw() // Call this is you want to get the average amplitude calculateAverageAmplitude(); wf.render(); - abv.render(); + //abv.render(); } } diff --git a/java/src/example/RotatingAudioBands.java b/java/src/example/RotatingAudioBands.java index 72fd7a223..c7b894efa 100644 --- a/java/src/example/RotatingAudioBands.java +++ b/java/src/example/RotatingAudioBands.java @@ -1,7 +1,7 @@ package example; -import ie.tudublin.Visual; -import ie.tudublin.VisualException; +import assaigment.Visual; +import assaigment.VisualException; public class RotatingAudioBands extends Visual { diff --git a/java/src/example/WaveForm.java b/java/src/example/WaveForm.java index 5d38aa700..a237a01d6 100644 --- a/java/src/example/WaveForm.java +++ b/java/src/example/WaveForm.java @@ -1,17 +1,21 @@ package example; + import processing.core.*; // This is an example of a visual that renders the waveform public class WaveForm { MyVisual mv; - float cy = 0; + float cx = 0; public WaveForm(MyVisual mv) { this.mv = mv; - cy = this.mv.height / 2; + cx = this.mv.width / 2; + } + + public WaveForm() { } public void render() @@ -20,12 +24,14 @@ public void render() for(int i = 0 ; i < mv.getAudioBuffer().size() ; i ++) { mv.stroke( - PApplet.map(i, 0, mv.getAudioBuffer().size(), 0, 255) - , 255 - , 255 + PApplet.map(i, 0, mv.getAudioBuffer().size(), 0, 255), + 255, + 255 ); - mv.line(i, cy, i, cy + cy * mv.getAudioBuffer().get(i)); + float x = cx - (cx * mv.getAudioBuffer().get(i)); // Calculate the x-coordinate of the line + float y = mv.height - i/2; // Calculate the y-coordinate of the line + mv.line(cx, y/2, x, y); } } } \ No newline at end of file diff --git a/java/src/ie/tudublin/Experiance.java b/java/src/ie/tudublin/Experiance.java new file mode 100644 index 000000000..a092d3fda --- /dev/null +++ b/java/src/ie/tudublin/Experiance.java @@ -0,0 +1,79 @@ +package ie.tudublin; + +import assaigment.*; +import ddf.minim.AudioBuffer; +import ddf.minim.AudioInput; +import ddf.minim.AudioPlayer; +import ddf.minim.Minim; +import ddf.minim.analysis.FFT; +import processing.core.PApplet; + +public class Experiance extends PApplet { + + Minim minim; + AudioPlayer player; + AudioBuffer ab; + + + AudioPlayer ap; + AudioInput ai; + + + float smoothedY = 0; + float smoothedAmplitude = 0; + FFT fft; + + int mode = 0; + + float y = 0; + + stars s; // declare a Star instance + + public void keyPressed() { + if (key >= '0' && key <= '9') { + mode = key - '0'; + } + if (keyCode == ' ') { + if (player.isPlaying()) { + player.pause(); + } else { + player.rewind(); + player.play(); + } + } + } + + + public void settings() { + size(1024, 1000, P3D); + } + + public void setup() { + + minim = new Minim(this); + player = minim.loadFile("MusicVisuals/java/data/Victoria_Mon_t_ft_Khalid_-_Experience.mp3", 512); + player.play(); + ab = player.mix; + + s = new stars(this); // initialize the Star instance + s.setup(); + } + + public void draw() { + switch (mode) { + case 0: + + s.render();// render the Star instance + + break; + case 1: + background(0); + break; + case 2: + background(0); + break; + } + } + + +} \ No newline at end of file diff --git a/java/src/ie/tudublin/Log.txt b/java/src/ie/tudublin/Log.txt new file mode 100644 index 000000000..950e57c10 --- /dev/null +++ b/java/src/ie/tudublin/Log.txt @@ -0,0 +1,49 @@ +6/04/23 :- +Went on call with cece and ad file for mp3 player , +expeirnce file and started our projected + +how to you play a file from another file + +we each have 35 seconds in the () +THIS IS + +this is HADASSAH +Love always feels better when it's true +Love tastes way too bitter when it's you +I'm all out of love, you gave it away +I'm hoping that experience can get you to change +I'm hoping that experience can get you to change +I'm hoping that (ooh, oh) +I'm all out of love, you gave it away +I'm hoping that experience can get you to change +I'm hoping that experience can get you to change +I'm hoping that + +THIS IS cece +Love's no pressure +When it's with someone who tends to +All of your emotions, know you'll +Find someone who's there for you +Find someone who's there for you +Love always feels better when it's true +Love tastes way too bitter when it's you +end 1:35 + +end at 2:10 + + +idea +peace sign +reacord player +grovey pattern +gathered particles beating out +write experiance at the end +cece qriting words goinfg aroud her cirlce + +begin stars shooting dwon enters ino syclidlic area then says :- welcome to experianc +ends with stars shooting out to fast white shoot and the words expeoirance has concluded written + + +cece wants to add a stem to her flower that looks similar to a sound wave +aisha wnats to +hadassah wants to try particle thing , change the colour to silver flashing lights diff --git a/java/src/ie/tudublin/Main.java b/java/src/ie/tudublin/Main.java deleted file mode 100644 index 27489f824..000000000 --- a/java/src/ie/tudublin/Main.java +++ /dev/null @@ -1,21 +0,0 @@ -package ie.tudublin; - -import example.CubeVisual; -import example.MyVisual; -import example.RotatingAudioBands; - -public class Main -{ - - public void startUI() - { - String[] a = {"MAIN"}; - processing.core.PApplet.runSketch( a, new MyVisual()); - } - - public static void main(String[] args) - { - Main main = new Main(); - main.startUI(); - } -} \ No newline at end of file