diff --git a/README.md b/README.md index 19ba88c75..19901b711 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Music Visualiser Project -Name: +Name: Ryan Keogh -Student Number: +Student Number: C19444404 ## Instructions - Fork this repository and use it a starter project for your assignment @@ -12,13 +12,14 @@ Student Number: - Check out the WaveForm and AudioBandsVisual for examples of how to call the Processing functions from other classes that are not subclasses of PApplet # Description of the assignment - +For my assignment I decided to try and implement as much as I could of what Bryan has taught us. From experiencing him first hand teaching us the art of audio visuals with java I found myself intrigued as someone who has a strong passion for music. I decided to choose my favourite song 'Live Forever' by my favourit band 'Oasis'. I tried to get creative for the project and implement some of Bryans ideas but also some of my own creations that I tried to brainstorm. Although some may be random I feel like that is what is special about this project, there may be grading for code, but in terms of design and creativity there is no right or wrong, just whatever the students can conjure up in our minds. Of course I had troubles and stressful times doing this project but I also had a great time doing it. There is also no better feeling than finally getting something youve been trying at for ages to finally compile. I hope you enjoy. # Instructions +To use my assignment the user is displayed with a screen. The user must then push the space bar to start the music and then can scroll through all of my visuals using the numbers 1-7. # How it works - +I used a lot of polymorphism to complete my assignment. I incorporated a separate vision class to allow all of my files to be accessed in the the RyansVisuals file. This allows me to simple call each file from that file instead of having to clump up all of my code into one switch in the RyansVisual file. This incorpotates neatness and also was great help in identifying visuals which had errors. The project links my visuals to an audio file and reacts based on things such as the audio buffer size, the amplitude and the sample size of the audio in my attempt to create as smooth an experience for the viewer. I tried my best to have all my visuals different and unique. # What I am most proud of in the assignment - +I am most proud of my used of polymorphism in this assignment. At times I can be a slow learner and polymorphism was something that i was struggling to get my head around for some time. But thanks to Bryans help and a lot of my own research I can now say that i can completely understand what i was originally doing wrong in my code. So i am very happy that i managed to learn a great deal in my assignment as well as creating cool audio visuals. # Markdown Tutorial This is *emphasis* diff --git a/java/data/liveforever.mp3 b/java/data/liveforever.mp3 new file mode 100644 index 000000000..f5d0e7ba9 Binary files /dev/null and b/java/data/liveforever.mp3 differ diff --git a/java/src/c19444404/RyansVisual.java b/java/src/c19444404/RyansVisual.java new file mode 100644 index 000000000..95941b6d8 --- /dev/null +++ b/java/src/c19444404/RyansVisual.java @@ -0,0 +1,116 @@ +package c19444404; + + +import ie.tudublin.*; + +public class RyansVisual extends Visual{ + +Vision vision; + + public void settings() + { + //size(600, 600, P3D); + fullScreen(P3D); + } + + + + public void setup() + { + startMinim(); + loadAudio("liveforever.mp3"); + colorMode(HSB); + vision = new Wave(this); + //vision = new SphereCircle(this); + + + } + + +public void keyPressed() { + + if (key == ' ') + { + getAudioPlayer().cue(0); + getAudioPlayer().play(); + } + + + if (key == '2') + { + vision = new SphereCircle(this); + } + if ( key == '8') + { + vision = new Sphere(this); + } + if (key =='3') + { + vision = new Circles(this); + } + if (key == '4') + { + vision = new Spiral(this); + } + if (key == '1') + { + vision = new Wave(this); + } + if (key == '6') + { + vision = new Line(this); + } + if (key == '5') + { + vision = new Spirals(this); + } + if (key == '7') + { + vision = new Abduction(this); + } + + + +} + + + // float[] lerpedBuffer; + + + 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(); + vision.render(); + // will draw either a circle or rect depending on what the instance of vision is + + + + + } + + +} + + + + + + + + + diff --git a/java/src/example/CubeVisual1.java b/java/src/example/CubeVisual1.java index 8eebd97f8..8edb593eb 100644 --- a/java/src/example/CubeVisual1.java +++ b/java/src/example/CubeVisual1.java @@ -2,8 +2,13 @@ import ie.tudublin.Visual; + + public class CubeVisual1 extends Visual { + + + public void settings() { size(800, 600, P3D); @@ -48,6 +53,6 @@ public void draw() popMatrix(); angle += 0.01f; } +} -} \ No newline at end of file diff --git a/java/src/ie/tudublin/Abduction.java b/java/src/ie/tudublin/Abduction.java new file mode 100644 index 000000000..a202f7953 --- /dev/null +++ b/java/src/ie/tudublin/Abduction.java @@ -0,0 +1,91 @@ +package ie.tudublin; + +import c19444404.RyansVisual; +import processing.core.PApplet; + +public class Abduction extends Vision { + + public Abduction (RyansVisual rv) + { + super(rv); + } + + float[] lerpedBuffer = new float[512]; + + public void render()// cow abduction + { + + rv.background(0); + + + for(int i=0;i< rv.getAudioBuffer().size(); i++) + { + float c = PApplet.map(i,0,rv.getAudioBuffer().size(),0,255); + rv.stroke(c,255,255); + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f); + } + + float r = 1f; + int numPoints = 2; + float thetaInc = PApplet.TWO_PI / (float) numPoints; + rv.strokeWeight(1); + float lastX = rv.width /4 , lastY = rv.height/4 ; + for(int i = 0 ; i < 100 ; i ++) // creating rays for the ufo + { + rv.noFill(); + float c = PApplet.map(i, 0, 300, 0, 255) % 255.0f; //mapping colours + rv.stroke(c, 255, 255, 100); + float theta = i * (thetaInc + rv.getSmoothedAmplitude() * 5); + float x = rv.width / 2 + PApplet.sin(theta) * r;// the rotations + float y = rv.height / 2 - PApplet.cos(theta) * r; + r += 0.5f + rv.getSmoothedAmplitude(); + rv.line(lastX, lastY, x, y); + + } + for(int i = 0 ; i < 100 ; i ++)// creating of the second ray + { + float c = PApplet.map(i, 0, 300, 0, 255) % 255.0f; + rv.stroke(c, 255, 255, 100); + float theta = i * (thetaInc + rv.getSmoothedAmplitude() * 5); + float x = rv.width / 4 + PApplet.sin(theta) * r; + float y = rv.height / 4 - PApplet.cos(theta) * r; + r += 0.5f + rv.getSmoothedAmplitude(); + rv.line(lastX, lastY, x, y); + + } + + rv.noFill(); + + rv.stroke(255); // design of the cow and of the ufo + rv.fill(255); + rv.ellipse(rv.width/2,rv.height/2,140,60); + rv.ellipse(rv.width/2+70,rv.height/2-30,40,20); + rv.rect(rv.width/2-35,rv.height/2+25,15,30); + rv.rect(rv.width/2+30,rv.height/2+20,15,35); + + rv.fill(0); + rv.noStroke(); + rv.ellipse(rv.width/2-20,rv.height/2+20,25,18);//spot one + rv.ellipse(rv.width/2-25,rv.height/2+15,30,18);//spot one + rv.ellipse(rv.width/2-45,rv.height/2,25,18);//spot one + + + + + rv. ellipse(rv.width/2-35,rv.height/2-8,30,12);//spot two + rv. ellipse(rv.width/2-20,rv.height/2+10,20,12); + + rv.ellipse(rv.width/2+40,rv.height/2,20,25);//spot three + rv.ellipse(rv.width/2+30,rv.height/2+13,30,20);//spot three + + + rv.ellipse(rv.width/2+5,rv.height/2-10,20,25);//spot three + rv.ellipse(rv.width/2,rv.height/2-13,30,20);//spot three + + rv.fill(120); + rv.ellipse(rv.width/4, rv.height/4,150,70); + rv.fill(120); + rv.ellipse(rv.width/4, rv.height/4 -30,80,50); + } + +} diff --git a/java/src/ie/tudublin/Circles.java b/java/src/ie/tudublin/Circles.java new file mode 100644 index 000000000..426acf438 --- /dev/null +++ b/java/src/ie/tudublin/Circles.java @@ -0,0 +1,74 @@ +package ie.tudublin; + + +import c19444404.*; +import processing.core.*; + +public class Circles extends Vision { + + + public Circles(RyansVisual rv){ + super(rv); + } + +float[] lerpedBuffer = new float [1024]; + +int border = 20; +@Override +public void render() +{ + + //rv.noFill() + // stroke(255); + rv.noFill(); + for(int i=0;i < rv.getAudioBuffer().size(); i++) + { + float c = PApplet.map(i, 0, rv.getAudioBuffer().size(), 0, 255); + rv.stroke(c,255,255); + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f);//lerped buffer change + + + + + //this is all of the circles being drawn to the screen with the middle ones using a lerped buffer to adapt to music + + rv.ellipse(rv.width/2,rv.height/2 + lerpedBuffer[i] * rv.height/2 * 2,100 + (rv.getSmoothedAmplitude() * 500), 100 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/2 - 50,rv.height/2 + lerpedBuffer[i] * rv.height/2 * 2,100 + (rv.getSmoothedAmplitude() * 500), 100 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/2 + 50,rv.height/2 + lerpedBuffer[i] * rv.height/2 * 2,100 + (rv.getSmoothedAmplitude() * 500), 100 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/2,rv.height/2 + 50 + lerpedBuffer[i] * rv.height/2 * 2,100 + (rv.getSmoothedAmplitude() * 500), 100 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/2,rv.height/2 - 50 + lerpedBuffer[i] * rv.height/2 ,100 + (rv.getSmoothedAmplitude() * 500), 100 + (rv.getSmoothedAmplitude() * 500)); + + + rv.ellipse(rv.width/4,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width/4 -25,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/4 + 25,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width/4,rv.height/4 + 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width/4,rv.height/4 - 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + + rv.ellipse(rv.width-rv.width/4,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width-rv. width/4 -25,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width - rv.width/4 + 25,rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv.width- rv.width/4,rv.height/4 + 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width - rv.width/4,rv.height/4 - 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + + rv.ellipse(rv.width-rv.width/4, rv.height -rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width- rv.width/4 -25,rv.height - rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width - rv.width/4 + 25, rv.height - rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width- rv.width/4, rv.height - rv.height/4 + 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv.width - rv.width/4, rv.height - rv.height/4 - 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + + + rv.ellipse(rv.width/4, rv.height -rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse(rv. width/4 -25,rv.height - rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse(rv. width/4 + 25, rv.height - rv.height/4,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv. ellipse( rv.width/4, rv.height -rv. height/4 + 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); + rv.ellipse( rv.width/4,rv. height - rv.height/4 - 25,50 + (rv.getSmoothedAmplitude() * 500), 50 + (rv.getSmoothedAmplitude() * 500)); +} + + +} +} + + + + diff --git a/java/src/ie/tudublin/Line.java b/java/src/ie/tudublin/Line.java new file mode 100644 index 000000000..e79dce762 --- /dev/null +++ b/java/src/ie/tudublin/Line.java @@ -0,0 +1,49 @@ +package ie.tudublin; + + +import c19444404.*; +import processing.core.*; + +public class Line extends Vision { + + + public Line(RyansVisual rv){ + super(rv); + } + + +float angle =0; +float[] lerpedBuffer = new float[512]; + +@Override +public void render() +{ + + rv.noFill(); + rv.strokeWeight(20); + + for (int i = 0; i < rv.getAudioBuffer().size(); i++) { + + float c = PApplet.map(i, 0, rv.getAudioBuffer().size() , 0, 255); + + rv.stroke(c,255,255); + + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f); + rv.line(i * 2.5f + 50, rv.height/2 - lerpedBuffer[i] * rv.height/2 * 4, i * 2.5f - 50, rv.height/2 + lerpedBuffer[i] * rv.height/2 * 4); + + +} + + + + +}} + + + + + + + + + diff --git a/java/src/ie/tudublin/Main.java b/java/src/ie/tudublin/Main.java index 27489f824..911c6094f 100644 --- a/java/src/ie/tudublin/Main.java +++ b/java/src/ie/tudublin/Main.java @@ -1,6 +1,8 @@ package ie.tudublin; +import c19444404.RyansVisual; import example.CubeVisual; +import example.CubeVisual1; import example.MyVisual; import example.RotatingAudioBands; @@ -8,6 +10,24 @@ public class Main { public void startUI() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new RyansVisual()); + } + + public void cube() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new CubeVisual()); + } + + public void cube2() + { + String[] a = {"MAIN"}; + processing.core.PApplet.runSketch( a, new CubeVisual1()); + } + + public void MyViis() { String[] a = {"MAIN"}; processing.core.PApplet.runSketch( a, new MyVisual()); diff --git a/java/src/ie/tudublin/Sphere.java b/java/src/ie/tudublin/Sphere.java new file mode 100644 index 000000000..76e6cddfb --- /dev/null +++ b/java/src/ie/tudublin/Sphere.java @@ -0,0 +1,56 @@ +package ie.tudublin; + + +import c19444404.*; +import processing.core.*; + +public class Sphere extends Vision { + + + public Sphere(RyansVisual rv){ + super(rv); + } + + +float angle =0; +float[] lerpedBuffer = new float[512]; + +@Override +public void render() +{ + + rv.noFill(); + rv.strokeWeight(20); + for(int i=0;i< rv.getAudioBuffer().size(); i++) + { + + float c = PApplet.map(i,0,rv.getAudioBuffer().size(),0,255); + rv.stroke(c,255,255); + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f); + + + + rv.pushMatrix(); + rv.translate(rv.width/2 * 200,rv.height/2); + rv.camera(0, 0, 0, 0, 0, -1, 0, 1, 0); + rv.rotateY(angle); + rv.rotateZ(angle); + rv.sphere(60 + lerpedBuffer[i] * 200); + rv.popMatrix(); + } + angle += 0.1f; + +} + + + + +} + + + + + + + + diff --git a/java/src/ie/tudublin/SphereCircle.java b/java/src/ie/tudublin/SphereCircle.java new file mode 100644 index 000000000..eaac55440 --- /dev/null +++ b/java/src/ie/tudublin/SphereCircle.java @@ -0,0 +1,55 @@ +package ie.tudublin; + + +import c19444404.*; +import processing.core.*; + +public class SphereCircle extends Vision { + + + public SphereCircle(RyansVisual rv){ + super(rv); + } + +float[] lerpedBuffer = new float [512]; + +@Override +public void render() +{ + + rv.noFill(); + + + for(int i=0;i< rv.getAudioBuffer().size(); i++) + { + float c = PApplet.map(i,0,rv.getAudioBuffer().size(),0,255);// the colour + rv.stroke(c,255,255); + + + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f);//lerped buffer function + + + float wave = PApplet.sin(PApplet.radians(rv.frameCount/2));// creating the glide effect for the circles + + rv.ellipse(rv.width/2 + wave * 200 + lerpedBuffer[i] * 200 , rv.height/2 + wave * 200,100,100); //all 4 circles + rv.ellipse(rv.width/2 - wave * 200 + lerpedBuffer[i] * 200, rv.height/2 - wave * 200,100,100); + + rv.ellipse(rv.width/2 + wave * 200 + lerpedBuffer[i] * 200, rv.height/2 - wave * 200,100,100); + rv.ellipse(rv.width/2 - wave * 200 + lerpedBuffer[i]* 200, rv.height/2 + wave * 200,100,100); + + } + + rv.pushMatrix(); // the sphere in centre screen + rv.translate(rv.width/2,rv.height/2); + rv.rotate(PApplet.radians(100)); + rv.sphere(40); + rv.popMatrix(); +} + + +} + + + + + diff --git a/java/src/ie/tudublin/Spiral.java b/java/src/ie/tudublin/Spiral.java new file mode 100644 index 000000000..59065c26c --- /dev/null +++ b/java/src/ie/tudublin/Spiral.java @@ -0,0 +1,60 @@ +package ie.tudublin; + +import c19444404.RyansVisual; +import processing.core.*; + +public class Spiral extends Vision { + + public Spiral(RyansVisual rv){ + super(rv); + } + + + float angle = 0; //angle of spin + //for changing stroke colour + + int angleChange = 5;//amount spin is incremented by + final int LIM = 360; //max rotation + + int gap = 50; //gap between arcs + int thickness = 10; //thickness of each arc + float[] lerpedBuffer = new float [512]; + + @Override + public void render() + { + + + rv.noFill(); + rv.pushMatrix(); //prevents entire canvas from being transformed + rv. translate(rv.width/2, rv.height/2); //move the 0,0 position to the center of the screen so w/2, h/2 + rv.rotate(PApplet.radians(-angle)); //rotate negative anti clockwise + + for(int j = 0; j< rv.getAudioBuffer().size(); j++){ //for loop through the total size of the audio buffer, used for expanding arc lines + for(int i = gap; i< rv.width-gap; i+= gap){ //used to create the maximum size the spiral can become + //Colour formatting + float c = PApplet.map(i, 0, rv.getAudioBuffer().size(), 0, 255); + rv.stroke(c, 255, 255); + + + //angle of the arcs and the lerped buffer given it's value which will constantly change depending on music frequency buffer size + float angle = PApplet.radians(i); + lerpedBuffer[j] = PApplet.lerp(lerpedBuffer[j], rv.getAudioBuffer().get(j), 0.1f); + + //arc starting at 0,0 so middle of the screen after the translate and the final value is using lerped buffer to let the arc length change + rv.arc(0, 0, i, i, angle, angle + (lerpedBuffer[j] * 10)); + } + } + // angle of rotation + angle += angleChange; + //if it hits 360 then it will reset to 0 + if (angle >= LIM || angle < 0) + { + angle = 0; + } + rv.popMatrix(); + + } + + +} diff --git a/java/src/ie/tudublin/Spirals.java b/java/src/ie/tudublin/Spirals.java new file mode 100644 index 000000000..d6db5ad0c --- /dev/null +++ b/java/src/ie/tudublin/Spirals.java @@ -0,0 +1,38 @@ +package ie.tudublin; + + +import c19444404.RyansVisual; +import processing.core.*; + +public class Spirals extends Vision { + + public Spirals( RyansVisual rv) + { + super(rv); + } + + public void render() + { + float rad = 2f; // the float size for the spiral + int numPoints = 6; + float point = PApplet.TWO_PI / (float) numPoints; + rv.strokeWeight(7); + float x1 = rv.width / 2, y1 = rv.height / 2; + for(int i = 0 ; i < 100 ; i ++) + { + for (int j=0; j< 10 ; j++) + { + float c = PApplet.map(i, 0, 300, 0, 255) % 255.0f; + rv.stroke(c, 255, 255, 255); + float theta = i * (point + rv.getSmoothedAmplitude() * 5); + float x = rv.width / 2 + PApplet.sin(theta) * rad; // the rotation x + float y = rv.height / 2 - PApplet.cos(theta) * rad;// rotation y + rad += 0.5f + rv.getSmoothedAmplitude(); // the rotation movement + rv.line(x1, y1, x, y);// the lines mapped + x1 = x;//declaration + y1 = y; + } + } + } + +} diff --git a/java/src/ie/tudublin/Test1.java b/java/src/ie/tudublin/Test1.java new file mode 100644 index 000000000..ea9169acf --- /dev/null +++ b/java/src/ie/tudublin/Test1.java @@ -0,0 +1,18 @@ +package ie.tudublin; +import c19444404.*; + + +public class Test1 extends Vision{ + + + public Test1(RyansVisual rv) { + super(rv); + } + + @Override + public void render() { + rv.fill(255); + rv.ellipse(rv.width / 2, rv.height / 2, 100, 100); + } +} + diff --git a/java/src/ie/tudublin/Vision.java b/java/src/ie/tudublin/Vision.java new file mode 100644 index 000000000..e35a44caa --- /dev/null +++ b/java/src/ie/tudublin/Vision.java @@ -0,0 +1,16 @@ +package ie.tudublin; + +import c19444404.RyansVisual; +import processing.core.*; +// vision method to use polymorhpism to access all visuals in my RyansVisual +public abstract class Vision { + RyansVisual rv; + + + protected Vision(RyansVisual rv) + { + this.rv = rv; + } + + public abstract void render(); +} diff --git a/java/src/ie/tudublin/Visual.java b/java/src/ie/tudublin/Visual.java index a6bea8bab..c1dfb41ba 100644 --- a/java/src/ie/tudublin/Visual.java +++ b/java/src/ie/tudublin/Visual.java @@ -1,10 +1,11 @@ package ie.tudublin; + import processing.core.PApplet; import ddf.minim.*; import ddf.minim.analysis.FFT; -public abstract class Visual extends PApplet +public abstract class Visual extends PApplet { private int frameSize = 512; private int sampleRate = 44100; @@ -50,7 +51,7 @@ protected void calculateFFT() throws VisualException throw new VisualException("You must call startListening or loadAudio before calling fft"); } } - + public void calculateAverageAmplitude() { diff --git a/java/src/ie/tudublin/Wave.java b/java/src/ie/tudublin/Wave.java new file mode 100644 index 000000000..be46b9352 --- /dev/null +++ b/java/src/ie/tudublin/Wave.java @@ -0,0 +1,47 @@ +package ie.tudublin; + +import c19444404.RyansVisual; +import processing.core.*; +public class Wave extends Vision{ + + public Wave(RyansVisual rv) + { + super(rv); + } +//float halfHeight = rv.height/2; +float[] lerpedBuffer = new float[512]; //the lerped render buffer +boolean color = false; + + public void render() + { + + rv.strokeWeight(1); + rv.background(0); + + rv.rectMode(PApplet.CENTER); + rv.fill(255); + rv.rect(rv.width/2,rv.height/2,740,400);// creating the banner of oasis + rv.fill(0); + rv.rect(rv.width/2,rv.height/2,700,350); + + rv.fill(255); + rv.textSize(200); + rv.text("OASIS",rv.width/2 - 280,rv.height/2 + 80);// oasis printed on the screen + + + + for (int i = 0; i < rv.getAudioBuffer().size(); i++) { // wave with small stroke on the bottom of the screen + + float c = PApplet.map(i, 0, rv.getAudioBuffer().size() , 0, 255); + + rv.stroke(c,255,255); + + lerpedBuffer[i] = PApplet.lerp(lerpedBuffer[i], rv.getAudioBuffer().get(i), 0.1f); + rv.line(i * 2.5f, rv.height - lerpedBuffer[i] * rv.height * 4, i * 2.5f, rv.height + lerpedBuffer[i] * rv.height * 4); + + } + } + + + +}