diff --git a/README.md b/README.md index 19ba88c75..270e1d219 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,247 @@ # Music Visualiser Project -Name: +Name: Alexander Dergach, Jaycel Estrellado, Mendbayar Bat-Orshikh -Student Number: +Student Number: C20401562, C20372876, C20458384 -## Instructions -- Fork this repository and use it a starter project for your assignment -- Create a new package named your student number and put all your code in this package. -- You should start by creating a subclass of ie.tudublin.Visual -- 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 +Song: Love Is A Miracle, *Jinco* # Description of the assignment +Welcome to our Music Visualizer Project. This assignment will consist of 5 distinct visual effects. An interactive menu will be displayed and as the user, you are able to switch through different renders using button clicks. + +### First Visual + +The first Visual is comprised of 3 components, center, side and top/bottom. +In the center there is two distorted semi circles, made of thin lines each respective line being sound responsive with both size and colour, they are separated giving room for a row of ellipses in the middle, which are also synchronizing with the music. From the very center steams a flower pattern made of dots along with a beam of colour going off to the corner of the screen, the flower petal design vibrating as the music plays intensifies with the amplitude, the lazer beam also being sound responsive and only visible when the actual song is playing. +At the sides you will find two identically placed illustrations, made of ellipses with no fill creating a scribble effect and the width and height of the ellipses changing with the song. +Random generated lines are placed at the top and bottom of the screen and it is also synchronizing with the music- adding a more visualizing effect to the program. +Adding this randomly generated beams, creates a more chaotic approach to the visual contrasting with the other effects. + +![An image](java/data/FirstVis.png) + +### Second Visual + +The second Visual has a more symmetrical element, using 3 cubes on the center line, with a sphere in the very center, and sin waves covering the border of the screen. +The very center Cube is actually comprised of multiple smaller cubes creating one large cuboid, this cube is a plain grey colour at first but it changes colour values only when the beat is detected. In the center of the cuboid is a white sphere with a fixed position giving the user a fixed point on the visual. This is needed as each cube is rotating and it gives a sense of order to the elements. This rotation is depended on the amplitude of the song playing, when paused the cubes remain in there fixed position only rotating by the default amount. +The two side cubes are music responsive and will rotate as well as change colour with the music as the cuboid, since they are not filled in, with the rotation and colour change they give a slight pop out visual - adding to the already 3D effect. +The Sin waves on the borders are sound responsive and move according to the calculated frequency, there colours being of the full rainbow spectrum giving the visual a nice colour. This vibrant colour scheme will be seen through the rest of the visuals. + +![An image](java/data/secondvis.png) + +### Third Visual + +Our Third Visual contains the most aspects. In the center we have a custom made *Devil* emoji, lines radiating from the center in a black circle that has a smooth sin wave curving in and our of the circles borders. On the sides we have two almost 3D looking rotating triangles creating an X graphic, a beat responsive practical background. All the colours being of the rainbow spectrum responsive to the amplitude of the song to keep this visual uniform. +The devil emoji creates a center piece for the visual, with the strokes being colour responsive to the music, around it are vertical and horizontal lines that are also colour responsive along with moving with the sound, as it intensifies the lines start creating different shapes around the devil emoji creating a very interesting effect, from donuts to squares. The circle that holds both those elements has a sin wave as its border, smoothened to create a wave effect that is amplified with the song. +The two side graphics are made to look 3D a lot they are just triangles rotating from the center, once fully rotated creating an X and its scale, once fully rotated, is depended on the amplitude of the song. +The background is made of a natural flowing partials that speed up the flow as the songs frequency increases along with partials that only appear upon beat detection. + +![An image](java/data/thirdvis.png) + +### Fourth Visual + +The fourth visual, is the more geometrical of the visuals, giving a new sense to the project, comprised of a 3D center piece along with multiple evenly placed sin waves. +In the center are four nested triangles made up of vectors, each triangle being colour responsive to the sound and getting bigger as the layers go. The center triangle is a fixed white colour to match the 4 spheres that are around the triangle, giving the visual a fixed look. The spheres along with the triangles are being rotated by a fixed rate, amplified by the songs amplitude, similar to the cuboid logic. The spheres along with being rotated also scale in size with the sound. The colours for this visuals are a little darker to change the up the feel of the very vibrant visuals, with the sin waves being black rather then rainbow, being evenly places horizontally and vertically. + +![An image](java/data/fourthvis.png) + +### Fifth Visual + +The fifth visual makes a pulsating "eye" effect. + +It features a big red outermost layer of the eye that is made up of an array of ellipses giving it the further detail that an eye has while also changing size depending on the amplitude of the song. The outermost layer also changes to random colours when a beat is detected giving it a creepy vibe. The middle layer is there to fill in the space between the iris and outer layer so the composition of the graphic doesn't look empty. The iris is made to bump up and down like the outer layer but instead of soreading to the inside and outside, this layer just spreads outside. This effect also lets us have an after image when the song is finished where the irish slowly transitions and fades away. + +![An image](java/data/fifthvis.png) + # Instructions +### Starting Visuals + +- First you clone this repository +- Open it in an IDE, press *F5* to run the visual +- Opening the Main Menu + +### Main Menu + +- You may select a render and press on the middle play button to play that persons render + +![An image](java/data/MainMenu.png) + +- Menu will collapse into a lower menu, you are able to *loop*, *pause/play*, or *change* to another persons render + +![An image](java/data/Lowermenu.png) + # How it works -# What I am most proud of in the assignment +Being the assignment we created a Main class to operate our renders, extending the visuals class from ie/tudublin and inheriting from the Mimim library. +- 3D = True +- Size of window = 1400 x 800 +- Colour Mode = HSB + +Also to give a big thank you to past years creative inspirations! + +From here we were able to call all the other classes within a switch statement starting with the menu class by default. +```java + if(allowToPlay){ + switch (mode) + { + + case 0: + break; + case 1: + jay.render(); + startm.lowerMenu(); + break; + case 2: + jay2.render(); + startm.lowerMenu(); + break; + case 3: + for(int i = 0; i < particals; i++) + { + partical[i].render(); + } + alex.render(); + startm.lowerMenu(); + break; + case 4: + alex2.render(); + startm.lowerMenu(); + break; + case 5: + mende.render(); + startm.lowerMenu(); + break; + + } + }else{ + startm.render(); + } +``` + +The menu works off the *public void mouseClicked()* method, creating statements to allow the program to verify which render the user selected on the menu, and if it was selected then the user is allowed to play, the mode for the switch statement set for which render the user picked. +Once the user selects a render the menu is collapsed down, with an array of renders showing at the button along with a responsive play/pause button which changes depending on the songs state. + +The sub classes, inherit from *Start.java* along with *Visuals.java*. With the use of processing we were able to create sound responsive designs by mapping the values from index's of a for loop and the audio buffers of the song as such: -# Markdown Tutorial +```java + float index = PApplet.map(i, 0 , 180 , 0, ab.size() - 1); + s.stroke(PApplet.map(index, 0, ab.size(), 0, 255), 255,255); +``` -This is *emphasis* +The same logic being used to make it rotate to sound and grow in scale. +For a lot of the geometrical aspects of the visuals we needed to use mathematical formals such as sin, cos and radius' and example being the third graphics center circles smoothened border waves. -This is a bulleted list +```java + for(float i = 0f; i < 360; i += space){ -- Item -- Item + float xoff = PApplet.map(cos(i), -1, 1, 0 ,3); + float yoff = PApplet.map(sin(i), -1, 1, 0 ,3); -This is a numbered list + float n = noise(xoff + start, yoff + start); -1. Item -1. Item + float h = PApplet.map(n, 0, 1, (amp*250) * -1 ,amp*500); -This is a [hyperlink](http://bryanduggan.org) + s.fill(map(amp, 0, 1, 0, 255), 255, 255); -# Headings -## Headings -#### Headings -##### Headings + s.rotate(space); -This is code: + s.rect(250,0,h,3); -```Java -public void render() -{ - ui.noFill(); - ui.stroke(255); - ui.rect(x, y, width, height); - ui.textAlign(PApplet.CENTER, PApplet.CENTER); - ui.text(text, x + width * 0.5f, y + height * 0.5f); -} + } ``` +Using the processing library along with mapping of the sin position of the *i* index that's to 360, allowing us to create circles. Every visual being easer to map onto the screen using *push/pop Matrix's* along with *translate*, the idea of these processes is to change the coordinates of the starting x and y positions from 0,0 to the desired location and still keep it as 0,0 for indexing as such: + +```java + //______________Center Matrix + s.pushMatrix(); -So is this without specifying the language: + //Translating to middle of the screen + s.translate(s.width/2, s.height/2); + //_________________Center Circle + s.fill(15); + s.circle(0, 0, 500); + + s.popMatrix(); ``` -public void render() -{ - ui.noFill(); - ui.stroke(255); - ui.rect(x, y, width, height); - ui.textAlign(PApplet.CENTER, PApplet.CENTER); - ui.text(text, x + width * 0.5f, y + height * 0.5f); -} + +Moving from 2D shapes we were able to use 3D graphics as outlined in our setup method in the *Start.java*. Creating items such as spheres and cubes that responsive to sound, with scale and rotation. + +```java + s.sphere(30 * s.getSmoothedAmplitude() * 7); + + s.rotateY(s.angle); + s.rotateX(s.angle); + s.box(f); ``` -This is an image using a relative URL: +# Project Managment + +For effective team work we seperated our roles. -![An image](images/p8.png) +| Team Member | Roles | +|-----------|-----------| +|Jay | Two Renders, Designer | +|Alex | Two Renders, Merge Handler, Menu Creation| +|Mende | Render| -This is an image using an absolute URL: +# What I am most proud of in the assignment -![A different image](https://bryanduggandotorg.files.wordpress.com/2019/02/infinite-forms-00045.png?w=595&h=&zoom=2) +As a group we were proud of the whole project but to identifiy each renders outstanding values would be : -This is a youtube video: +1. Menu - +When it came to the menu, the complex use of the mouse methods from proccessing, allowing to create an almost high end menu. Helping me understand how menus such as Spotify or Youtube are created. With the ability to select specific renders within the respective ranges. I have further gained knowledge while coding the menu part in processing - loading in png and jpg images onto the screen. I really love the aesthetic that we have gone with our menu with the background contrasting with the buttons and when a render is chosen, it highlights the opposite colour around it. -[![YouTube](http://img.youtube.com/vi/J2kHSSFA4NU/0.jpg)](https://www.youtube.com/watch?v=J2kHSSFA4NU) +2. Visual 3 - +The third visual is one of my favourite in this assignment. Whether idea and implementation, both made me really excited after achieving the final result. Especially the custom devil emoji that was created, which was very fun and interesting to make. The use of mathematical concepts in processing to create a sine wave that curves around a circle creating a smoothened wave thats sound and colour responsive. -This is a table: +3. Default Rotation - +Another aspect of our project that I am most proud of is the default rotation of shapes when the music stops. The rotation depends on the amplitude of the song playing. In regards to the rotation and turning - I am also very proud of the rubix cube from the Second Visual. It was an idea I did not think I would be able to visualise on the project. As I was doing research on what to do for the project, I came across a forum on rubix cubes and thought how I would be able to implement small cubes that make up a bigger cube that rotates and turns. I thought that it would consist of some heavy coding but to my surprise it was very short to implement. + +```java +float size = 100; + + s.pushMatrix(); + + s.translate(s.width/2, s.height/2); + + //Rotation Of Cubiod + + s.rotateX(s.angle); + s.rotateY(s.angle); + s.rotateZ(s.angle); + + for (int xo = (int)-size; xo <= size; xo += 30) { //Spacing between each box + for (int yo = (int)-size; yo <= size; yo += 30) { + for (int zo = (int)-size; zo <= size; zo += 30) { + s.pushMatrix(); + s.translate(xo, yo, zo); //Positions of each cube + + //Rotates boxes + s.rotateX(s.angle); + s.rotateY(s.angle); + s.rotateZ(s.angle); + s.noStroke(); + + s.strokeWeight(4); + s.fill(c); //Filling the inside of the boxes white + + //Changing cubiod colour on beat detection + if(s.beat.isOnset()){ + s.fill(c, 255, 255); + } + + s.box((float) (15 + (Math.sin(s.angle1)) * 10)); + s.popMatrix(); + } + s.angle += 0.00005f; //Speed of rotation + s.angle1 += 0.00005f; +``` + + +Our YouTube Video: + +[![YouTube]](https://www.youtube.com/watch?v=RUKFmpijMn4) -| Heading 1 | Heading 2 | -|-----------|-----------| -|Some stuff | Some more stuff in this column | -|Some stuff | Some more stuff in this column | -|Some stuff | Some more stuff in this column | -|Some stuff | Some more stuff in this column | diff --git a/bash.exe.stackdump b/bash.exe.stackdump new file mode 100644 index 000000000..77b81849d --- /dev/null +++ b/bash.exe.stackdump @@ -0,0 +1,16 @@ +Stack trace: +Frame Function Args +000FFFFCD30 0018006293E (001802847A0, 0018026FE51, 00000000059, 000FFFFB710) +000FFFFCD30 0018004846A (000FFFFCD30, 00100000000, 00000000000, 00000000001) +000FFFFCD30 001800484A2 (00000000000, 00000000000, 00000000059, 9069A7B88A6C96FF) +000FFFFCD30 0018006E2A6 (00180045323, 001803529C8, 00000000000, 0000000000D) +000FFFFCD30 0018006E2B9 (00180045170, 001802377E0, 001800448F2, 000FFFFC910) +000FFFFCD30 00180070CE4 (00000000013, 00000000001, 000FFFFC910, 00180272640) +000FFFFCD30 0018005AB45 (000FFFFCA60, 00000000000, 00000000000, 008FFFFFFFF) +000FFFFCD30 0018005B315 (00800000010, 00000000000, 000FFFFCD30, 000000303E9) +000FFFFCD30 0018005B827 (001800D995E, 00000000000, 00000000000, 00000000000) +000FFFFCD30 0018005BB36 (00000000000, 000FFFFCD30, FFFFFFFFFFFFFFC9, 00000000000) +000FFFFCD30 00180048C0C (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 00180047716 (00000000000, 00000000000, 00000000000, 00000000000) +000FFFFFFF0 001800477C4 (00000000000, 00000000000, 00000000000, 00000000000) +End of stack trace diff --git a/java/data/BG.jpg b/java/data/BG.jpg new file mode 100644 index 000000000..f708978bc Binary files /dev/null and b/java/data/BG.jpg differ diff --git a/java/data/FirstVis.png b/java/data/FirstVis.png new file mode 100644 index 000000000..60229713e Binary files /dev/null and b/java/data/FirstVis.png differ diff --git a/java/data/Lowermenu.png b/java/data/Lowermenu.png new file mode 100644 index 000000000..256d5c62e Binary files /dev/null and b/java/data/Lowermenu.png differ diff --git a/java/data/MainMenu.png b/java/data/MainMenu.png new file mode 100644 index 000000000..d328c96ae Binary files /dev/null and b/java/data/MainMenu.png differ diff --git a/java/data/Song.wav b/java/data/Song.wav new file mode 100644 index 000000000..71aae56bf Binary files /dev/null and b/java/data/Song.wav differ diff --git a/java/data/fifthvis.png b/java/data/fifthvis.png new file mode 100644 index 000000000..735afae82 Binary files /dev/null and b/java/data/fifthvis.png differ diff --git a/java/data/fourthvis.png b/java/data/fourthvis.png new file mode 100644 index 000000000..cb03aad22 Binary files /dev/null and b/java/data/fourthvis.png differ diff --git a/java/data/heroplanet.mp3 b/java/data/heroplanet.mp3 deleted file mode 100644 index 681f02d31..000000000 Binary files a/java/data/heroplanet.mp3 and /dev/null differ diff --git a/java/data/secondvis.png b/java/data/secondvis.png new file mode 100644 index 000000000..4a299bd60 Binary files /dev/null and b/java/data/secondvis.png differ diff --git a/java/data/thirdvis.png b/java/data/thirdvis.png new file mode 100644 index 000000000..1dfe7482f Binary files /dev/null and b/java/data/thirdvis.png differ diff --git a/java/src/C20401562/AlexsVisual.java b/java/src/C20401562/AlexsVisual.java new file mode 100644 index 000000000..2453fc86e --- /dev/null +++ b/java/src/C20401562/AlexsVisual.java @@ -0,0 +1,173 @@ +package C20401562; + +import ie.tudublin.*; +import processing.core.*; + +public class AlexsVisual extends Visual{ + + Start s; + float start = 0; + + //_____________Constructor + + public AlexsVisual(Start start) + { + this.s = start; + } + + public void render() + { + float amp = s.getSmoothedAmplitude(); + + + s.fill(map(amp, 0, 1, 0, 255), 255, 255); + s.noStroke(); + + //Creating Random dots on the scren as soon as beat is detected + if(s.beat.isOnset()){ + for(int i = 0; i < 50; i++){ + s.ellipse(random(s.width), random(s.height), 6, 6); + } + } + + //______________Center Matrix + s.pushMatrix(); + //Translating to middle of the screen + s.translate(s.width/2, s.height/2); + + + //_________________Center Circle + s.fill(15); + s.circle(0, 0, 500); + + //_________________Center Graphic + for(int i = 0 ; i <= 180 ; i++) + { + + s.strokeWeight(2); + float index = PApplet.map(i, 0 , 180 , 0, ab.size() - 1); + s.stroke(PApplet.map(index, 0, ab.size(), 0, 255), 255,255); + + //Setting the length mapped to the index of the current audioBuffer + float lenght = PApplet.map(ab.get((int)index) /2, -1 , 1, 0, 250); + + //Setting X and Y + float x = lenght * -sin(i); + float y = lenght * cos(i); + + //Multiple Lines created to give the effect + s.line(x, y,x *1.25f,y); + s.line(y, x,y *1.25f ,x); + s.line(x, y * 1.25f,x,y); + + } + + + //_______________Devil Face + + s.stroke(map(amp, 0, 1, 0, 255), 255, 255); + s.fill(0); + s.strokeWeight(6); + + //Right horn + s.line(-15,-45,-35,-65); + s.line(-30,-40,-35,-65); + + //Left horn + s.line(15,-45,35,-65); + s.line(30,-40,35,-65); + + s.strokeWeight(6); + + s.circle(0, 0, 100); + + //EyeLids + s.curve(-10, 10, 8, -10, 28, -20, 30, 0); + s.curve(10, 10, -8, -10, -28, -20, -30, 0); + + //Eyes + s.ellipse(-15, 0, 5, 15); + s.ellipse(15, 0, 5, 15); + + //Smile + s.strokeWeight(3); + s.curve(-30, -180, -30, 10, 30, 10, 30, -180); + + + //_________________Outer Circle Waves + + float space = 0.1f; + s.noStroke(); + + for(float i = 0f; i < 360; i += space){ + + float xoff = PApplet.map(cos(i), -1, 1, 0 ,3); + float yoff = PApplet.map(sin(i), -1, 1, 0 ,3); + + float n = noise(xoff + start, yoff + start); + + //Height of rectangles + float h = PApplet.map(n, 0, 1, (amp*250) * -1 ,amp*500); + + //Colour to change with song Amp + s.fill(map(amp, 0, 1, 0, 255), 255, 255); + + //Rotate each rect around the circle + s.rotate(space); + + s.rect(250,0,h,3); + + } + //Increment starting value + start += 0.1f; + + s.popMatrix(); + + //___________End Of Center Matrix + + + + //____________Side Graphics + + s.stroke(map(amp/2, 0, 1, 0, 255), 255, 255); + s.strokeWeight(1); + + float rot = 0; + rot += amp / 8.0f; + //Changing size on aplitude + float r = PApplet.map(amp, 0, 1, 10, 100); + + s.pushMatrix(); + //Right Side + s.translate(s.width/2 + 500, s.height/2); + + for (int i = 0; i < 360; i++){ + float x = r * cos(i); + float y = r * sin(i); + + s.rotateY(rot); + s.triangle(x, y, x *1.5f, y * 1.5f, x * 2.75f, x * 2.75f); + } + + s.popMatrix(); + + s.pushMatrix(); + //Left Side + s.translate(s.width/2 - 500, s.height/2); + + for (int i = 0; i < 360; i++) { + float x = r * cos(i); + float y = r * sin(i); + + s.rotateY(rot); + s.triangle(x, y, x *1.5f, y * 1.5f, x * 2.75f, x * 2.75f); + } + + s.popMatrix(); + + + + } + //________________End Render + +} diff --git a/java/src/C20401562/AlexsVisual2.java b/java/src/C20401562/AlexsVisual2.java new file mode 100644 index 000000000..33d47ea01 --- /dev/null +++ b/java/src/C20401562/AlexsVisual2.java @@ -0,0 +1,132 @@ +package C20401562; + +import ie.tudublin.Visual; +import processing.core.*; + +public class AlexsVisual2 extends Visual{ + + Start s; + float[] triangle = {145, 105, 65, 25}; + float lerpedAverage = 0; + + //_____________Constructor + + public AlexsVisual2(Start start) + { + this.s = start; + } + + //_______________Render + + public void render() + { + + float average = 0; + float sum = 0; + + //Average of the buffer + for(int i =0; i < ab.size(); i++) + { + sum += abs(ab.get(i)); + } + + average = sum / ab.size(); + + //Calculate the average amplitutde + lerpedAverage = lerp(lerpedAverage,average, 0.1f); + + //Black Lines on Screen + s.stroke(0); + s.line(0,s.height/2,s.width,s.height/2); + s.line(300,0,300,s.height); + s.line(1100,0,1100,s.height); + + + //Sin Waves built on the lerpedBuffer + for (int i = 0; i < ab.size(); i++){ + + s.lerpedBuffer[i] = lerp(s.lerpedBuffer[i], ab.get(i), 0.1f); + + //Horizontal + s.line(i*3, s.height/2 - s.lerpedBuffer[i] * s.height, i*3, s.height/2 + s.lerpedBuffer[i] * s.height); + //Vertical + s.line(300 - s.lerpedBuffer[i] * 350, i * 3,300 + s.lerpedBuffer[i] * 350, i * 3); + s.line(1100 - s.lerpedBuffer[i] * 350, i * 3,1100 + s.lerpedBuffer[i] * 350, i * 3); + } + + s.pushMatrix(); + + s.translate(s.width/2, s.height/2); + + s.noFill(); + + //Determine the rotation speed on the song if its playing or not + if(s.ap.isPlaying()){ + s.angle += 0.01f + s.getSmoothedAmplitude() / 8; + s.angle1 += 0.02f + s.getSmoothedAmplitude() / 8; + s.angle2 += 0.03f + s.getSmoothedAmplitude() / 8; + } + + s.rotateX(s.angle); + s.rotateY(s.angle1); + s.rotateZ(s.angle2); + + s.beginShape(); + + //For Loop to iterate through the triangle array and print all the layers of the center graphic + + for(int i = 0; i <= 3; i++){ + + //Change colour of middle triangle to match spheres + if(i == 3){ + s.stroke(255); + }else{ + s.stroke(PApplet.map(s.getSmoothedAmplitude()*4*i, 0, 1, 0, 255), 255, 255); //React to the colors + } + + //Vertex layers building the triangles + + s.vertex(-triangle[i], -triangle[i], -triangle[i]); + s.vertex( triangle[i], -triangle[i], -triangle[i]); + s.vertex( 0, 0, triangle[i]); + + s.vertex( triangle[i], -triangle[i], -triangle[i]); + s.vertex( triangle[i], triangle[i], -triangle[i]); + s.vertex( 0, 0, triangle[i]); + + s.vertex( triangle[i], triangle[i], -triangle[i]); + s.vertex(-triangle[i], triangle[i], -triangle[i]); + s.vertex( 0, 0, triangle[i]); + + s.vertex(-triangle[i], triangle[i], -triangle[i]); + s.vertex(-triangle[i], -triangle[i], -triangle[i]); + s.vertex( 0, 0, triangle[i]); + + s.angle += 0.01f; + + } + + s.endShape(); + + s.stroke(255); + s.strokeWeight(1); + + //Spheres Rotating around the Triangle + s.translate(200, 200, 0); + s.sphere(30 * s.getSmoothedAmplitude() * 7); + + s.translate(-100, -100, 0); + s.sphere(30 * s.getSmoothedAmplitude() * 7); + + s.translate(-200, -200, 0); + s.sphere(30 * s.getSmoothedAmplitude() * 7); + + s.translate(-100, -100, 0); + s.sphere(30 * s.getSmoothedAmplitude() * 7); + + s.popMatrix(); + + } + //________________End Render + +} diff --git a/java/src/C20401562/JaycelsVisual.java b/java/src/C20401562/JaycelsVisual.java new file mode 100644 index 000000000..bbe8e1f49 --- /dev/null +++ b/java/src/C20401562/JaycelsVisual.java @@ -0,0 +1,197 @@ +package C20401562; + +import ie.tudublin.*; +import processing.core.PApplet; + +import java.util.Random; + +public class JaycelsVisual extends Visual{ + + Start start; + + float rot = 0; + + float x; + float y; + float z; + + float colour; + + int beamLength = 80; + + float lerpedAverage = 0; + + float average; + float sum; + + public JaycelsVisual(Start start) + { + this.start = start; + + //Creating random x and y cords + x = RandomNumber(); + y = RandomNumber(); + z = y + beamLength; + + } + + //Method for center beam graphic + public void update() + { + y += 9; + z += 9; + + if(y > start.height / 2) + { + y = 0; + z = y + beamLength; + } + } + + //Generating Random Numbers for colours + public int RandomNumber() + { + Random rand = new Random(); + return rand.nextInt(start.width); + } + + //_______Render + + public void render() + { + + start.background(0); + + average = 0; + sum = 0; + + // Calculate the average of the buffer + for (int i = 0; i < start.getAudioBuffer().size(); i ++) + { + sum += abs(start.getAudioBuffer().get(i)); + } + average = sum / start.getAudioBuffer().size(); + // Move lerpedAverage 10% closer to average every frame + lerpedAverage = lerp(lerpedAverage, average, 0.1f); + + + //start.getFFT().forward(start.ap.mix); //load the audio to the fft + start.pushMatrix(); + + start.translate(start.width/2, start.height/2); //translate to the center of the screen + start.setBands(start.getFFT().getSpectrumReal()); //load the fft to bands + + //Circle + float angle = 0; + float cir = 180; // radius + + + //Center Ellipses + for (int i = 0; i < 360; i++) { + + float color = start.getBands()[i] / 2; //get the current fft used for color + start.noStroke(); + start.fill(start.random(color, 400), start.random(color, 300), 280); + + start.lerpedBuffer[i] = PApplet.lerp(start.getAmplitude()*20, start.getBands()[i], 0.08f); //smooth the circle + start.ellipse(sin(angle) * ( start.lerpedBuffer[i]), -cos(angle) * (cir + start.lerpedBuffer[i]), PApplet.abs(start.lerpedBuffer[i] * 4), PApplet.abs(start.lerpedBuffer[i] * 4)); + + angle += PI / 20; //Draw 20 circles on the screen to form a big circle + } + + //Ring + float ang = 0; + int stick = 15; //Length of the stick + + for (int j = 0; j < 360; j++) { + float color = start.getBands()[j]; //Get the current fft used for color + start.stroke(start.random(color, 400), start.random(color, 300), 300, 200); + start.strokeWeight(3); + start.lerpedBuffer2[j] = PApplet.lerp(start.getAmplitude()*40, start.getBands()[j], 0.5f); //smooth the circle + start.line(-cos(ang) * (start.lerpedBuffer2[j] + stick), sin(ang) * (cir + start.lerpedBuffer2[j] + stick), -cos(ang) * (cir - start.lerpedBuffer2[j] - stick), sin(ang) * (cir - start.lerpedBuffer2[j] - stick)); + ang += PI / 40; //Draw 40 lines on the screen to form a big circle + } + + //To only show when the song is playing + if(start.ap.isPlaying()) { + + //Top lines + for (int x = 0; x < 60; x += 2) { + float color = start.getBands()[x]; //get the current fft us for color + float position = start.random(color, start.width); //find a random position to draw the line + start.stroke(start.random(color, 400), start.random(color, 300), 300); + start.strokeWeight(5); + start.line(position - start.width / 2, -(start.height / 2), position - start.width / 2, color * 2 + 40 - start.height / 2); + } + + //Bottom lines + for (int x = 0; x < 60; x += 2) { + float color = start.getBands()[x]; //get the current fft us for color + float position = start.random(color, start.width); //find a random position to draw the line + start.stroke(start.random(color, 400), start.random(color, 300), 300); + start.strokeWeight(5); + start.line(position - start.width / 2, start.height / 2 - 60 , position - start.width / 2 , -(color * 2) - 40 + start.height /2 - 60); + } + + //Random triangle from center + colour = map(RandomNumber(), 0, start.width / 2, 0, 255); + + start.stroke(colour, 150, 255); + start.strokeWeight(2); + start.triangle(x, y, x, z, -10, -10); + } + + + //Flower dots + start.rotate(radians(rot)); + + for(int i = 0; i < 360; i++) { + float color = start.getBands()[i] / 2; //get the current fft used for color + start.stroke(start.random(color, 400), start.random(color, 300), 300, 200); + + float r = 30 * cos(6 * i); + float x = r * cos(i); + float y = r * sin(i); + + start.point(10 *(x - 40 * lerpedAverage * 2f), 10 * (y - 40 * lerpedAverage * 2f)); // get lerp avg + + rot += 1; + } + + start.popMatrix(); + + + //___________Side Graphics + + float r = 1f; + float t = PApplet.TWO_PI / (float) 3; + + for (int i = 0; i < 75; i++) { + + start.strokeWeight(2); + + //Mapping on Amp + start.fill(map(start.getSmoothedAmplitude(), 0, 1, 0, 255), 255, 255); + float theta = i * (t + start.getSmoothedAmplitude() * 5); + + start.pushMatrix(); + + start.translate(start.width / 2 - 500, start.height / 2); + + //X Y and Radius + x = 50 + PApplet.sin(theta) * r; + y = 50 - PApplet.cos(theta) * r; + r += 2f + start.getSmoothedAmplitude(); + + start.fill(0); + //Two side graphics + start.ellipse(0, 0, x, y); + start.translate(1000, 0); + start.ellipse(0, 0, x, y); + + start.popMatrix(); + } ///End Loop + + } + //End of render +} diff --git a/java/src/C20401562/JaycelsVisual2.java b/java/src/C20401562/JaycelsVisual2.java new file mode 100644 index 000000000..e9a87fdac --- /dev/null +++ b/java/src/C20401562/JaycelsVisual2.java @@ -0,0 +1,165 @@ +package C20401562; + +import ie.tudublin.*; +import processing.core.PApplet; + +public class JaycelsVisual2 extends Visual{ + + Start s; + + float lerpedAverage = 0; + + public JaycelsVisual2(Start start) + { + this.s = start; + + + circles = 12; + theta = 1.0f; + + } + + float circles; + float theta; + + //____________Render + + public void render() { + + s.noFill(); + + s.pushMatrix(); + + s.translate(s.width / 2, s.height / 2); + s.strokeWeight(4); + + //Setting the rotation to the song playing + if(s.ap.isPlaying()){ + s.angle += 0.01f + s.getSmoothedAmplitude() / 8; + s.angle1 += 0.02f + s.getSmoothedAmplitude() / 8; + s.angle2 += 0.03f + s.getSmoothedAmplitude() / 8; + + s.rotateX(s.angle); + s.rotateY(s.angle1); + s.rotateZ(s.angle2); + + }else{//If paused slow rotaion + s.rotateX(1); + s.rotateY(1); + s.rotateZ(1); + } + + //Center Sphere + s.stroke(255); + s.sphere(40); + + s.popMatrix(); + + //Creating Sin waves on the border + for (int i = 0; i < ab.size(); i++) { + + float c = PApplet.map(i, 0, ab.size(), 0, 255); + s.stroke(c, 255, 255); + s.lerpedBuffer[i] = lerp(s.lerpedBuffer[i], ab.get(i), 0.1f); + + //Waves + s.line(0, i * 2f, s.lerpedBuffer[i] * s.height, i * 2f); + s.line(s.width, i * 2f, s.width - (s.lerpedBuffer[i] * s.height), i * 2); + s.line(i * 3, 0, i * 3, s.lerpedBuffer[i] * s.height); + } + + float average = 0; + float sum = 0; + + //Average of the buffer + for(int i =0; i < ab.size(); i++) + { + sum += abs(ab.get(i)); + } + + average = sum / ab.size(); + + //Calculate the average amplitutde + lerpedAverage = lerp(lerpedAverage,average, 0.1f); + + //Shading + s.lights(); + s.strokeWeight(2); + + float c = PApplet.map(lerpedAverage * 10, 0, 1, 0, 255); + s.stroke(c, 255, 255); + s.noFill(); + + //Set cubiod rotation to the song + if(s.ap.isPlaying()){ + s.angle += 0.01f + s.getSmoothedAmplitude() / 5; + } + + float f = 100 + (100 * lerpedAverage * 10); + + //Side Boxes + //Left + s.pushMatrix(); + s.translate(s.width / 4 - 120, s.height / 2); + + s.rotateY(s.angle); + s.rotateX(s.angle); + s.box(f); + s.popMatrix(); + + //Right + s.pushMatrix(); + s.translate(s.width * 0.75f + 120, s.height / 2); + + s.rotateY(s.angle); + s.rotateX(s.angle); + s.box(f); + s.popMatrix(); + + //____________Center Cubiod Graphic + + float size = 100; + + s.pushMatrix(); + + s.translate(s.width/2, s.height/2); + + //Rotation Of Cubiod + + s.rotateX(s.angle); + s.rotateY(s.angle); + s.rotateZ(s.angle); + + for (int xo = (int)-size; xo <= size; xo += 30) { //Spacing between each box + for (int yo = (int)-size; yo <= size; yo += 30) { + for (int zo = (int)-size; zo <= size; zo += 30) { + s.pushMatrix(); + s.translate(xo, yo, zo); //Positions of each cube + + //Rotates boxes + s.rotateX(s.angle); + s.rotateY(s.angle); + s.rotateZ(s.angle); + s.noStroke(); + + s.strokeWeight(4); + s.fill(c); //Filling the inside of the boxes white + + //Changing cubiod colour on beat detection + if(s.beat.isOnset()){ + s.fill(c, 255, 255); + } + + s.box((float) (15 + (Math.sin(s.angle1)) * 10)); + s.popMatrix(); + } + s.angle += 0.00005f; //Speed of rotation + s.angle1 += 0.00005f; + } + } + + s.popMatrix(); + + } + +} diff --git a/java/src/C20401562/MendesVisual.java b/java/src/C20401562/MendesVisual.java new file mode 100644 index 000000000..faa23ceac --- /dev/null +++ b/java/src/C20401562/MendesVisual.java @@ -0,0 +1,68 @@ +package C20401562; + +import ie.tudublin.*; +import processing.core.*; + +public class MendesVisual extends Visual{ + + Start s; + float lerpedAverage = 0; + float y= 0; + float bigpend = 0; + float bigpstart = 15; + float smallpstart = 0; + float space = 0.2f; + + public MendesVisual(Start start) + { + this.s = start; + } + + public void render() + { + + + s.pushMatrix(); + s.fill(map(s.getSmoothedAmplitude(), 0, 1, 0, 255), 255, 255); + s.noStroke(); + s.translate(s.width/2, s.height/2); + s.fill(170,255,250); + s.circle(0, 0, 600); + s.strokeWeight(s.width/120); + + if (s.beat.isOnset() == true) { + bigpstart =bigpstart + 5 % 255; + bigpend =bigpend + random(200) % 255; + } + + if (s.beat.isHat()) { + smallpstart = smallpstart + 120; + } + + for(float i = 0f; i < 360; i++){ + //big pupil size + float pb = PApplet.map(y, 0, 1, (s.getSmoothedAmplitude()*600) * -1 ,s.getSmoothedAmplitude()*300); + + //colour to change with the beat + s.stroke( + PApplet.map(i, 0, s.getAudioBuffer().size(),bigpstart , bigpend), 255, 255 + ); + s.ellipse(290,0,pb,10); + + s.rotate(space); + } + + for(float i = 0f; i < 360; i++){ + //small pupil size + float ps = PApplet.map(y, 0, 1, (s.getSmoothedAmplitude() * 1000) * 1 ,s.getSmoothedAmplitude()*150); + //colour to change with the beat + s.stroke( + PApplet.map(i, 0, s.getAudioBuffer().size(),255 , smallpstart), 255, smallpstart); + s.ellipse(5,0,0,ps); + + s.rotate(space); + } + s.popMatrix(); + } + +} diff --git a/java/src/C20401562/Particals.java b/java/src/C20401562/Particals.java new file mode 100644 index 000000000..16431ef7e --- /dev/null +++ b/java/src/C20401562/Particals.java @@ -0,0 +1,69 @@ +package C20401562; + +import ie.tudublin.Visual; +import processing.core.PApplet; + +public class Particals extends Visual{ + + Start s; + + Particals[] partical = new Particals[400]; + + float y; + float x; + float z; + + //____________Constructor + + public Particals(Start s){ + + this.s = s; + + //Creating random cordinates filling the screen + y = s.random(-s.height, s.height); + x = s.random(-s.width, s.width); + z = s.random(s.width); + + } + + //Updating Cordinates poistion + public void update(){ + + z = z - 10; + + if(z < 1){ + z = s.width; + y = s.random(-s.height, s.height); + x = s.random(-s.width, s.width); + } + } + + //___________Start Render + + public void render(){ + + update(); + + s.fill(255); + s.stroke(48, 139, 206); + + float sx = PApplet.map(x / z , 0, 1, 0, s.width); + float sy = PApplet.map(y / z, 0, 1, 0, s.height); + + float n = PApplet.map(z, 0, s.width, 16, 0); + + //Particals + s.ellipse(sx, sy, n, n); + + y += ((1000 * s.getAmplitude()) * 0.2f); + + if (y >= 1000) + { + y = -1000; + } + + + } + + //__________End Render +} \ No newline at end of file diff --git a/java/src/C20401562/Start.java b/java/src/C20401562/Start.java new file mode 100644 index 000000000..e1e1839f6 --- /dev/null +++ b/java/src/C20401562/Start.java @@ -0,0 +1,276 @@ +package C20401562; + +import ddf.minim.analysis.*; +import ie.tudublin.*; +import processing.core.PApplet; +import processing.core.PImage; + +public class Start extends Visual{ + + PImage img; + + //For Beat Detection + BeatDetect beat; + Particals[] partical = new Particals[300]; + public boolean fourCircles = false; + public boolean fourCubes = false; + float h = height / 2; + + float angle = 0; + float angle1 = 0; + float angle2 = 0; + + //Menu Varibles + int mode = 0; + int colour = 0; + int choice = 0; + int firstClick = 0; + int particals = 300; + + int buttonMode = 1; + + //Booleans for Menu + boolean isPlaying = false; + boolean allowToPlay = false; + + float lerpedAverage = 0; + float average; + float sum; + + //Smooth the shapes In Visuals + float[] lerpedBuffer; + float[] lerpedBuffer2; + + + String[] name = {"","Jay", "Jay 2", "Alex", "Alex 2","Mende"}; + + + //____Initializing Visuals + AlexsVisual alex; + AlexsVisual2 alex2; + JaycelsVisual jay; + JaycelsVisual2 jay2; + MendesVisual mende; + StartMenu startm; + + public void settings() + { + size(1400, 800, PApplet.P3D); + + noSmooth(); + + } + + public void keyPressed() + { + //Pause or Play Song + + if (key == ' ') + { + if(ap.isPlaying()){ + ap.pause(); + + buttonMode = 0; + isPlaying = false; + }else if(allowToPlay){ + ap.play(); + + buttonMode = 1; + isPlaying = true; + } + + } + } + + public void setup() + { + + startMinim(); + loadAudio("Song.wav"); + + // startListening(); + + + img = loadImage("BG.jpg"); + + img.filter(BLUR, 6); + + + beat = new BeatDetect(); + + colorMode(HSB); + + for(int i = 0; i < particals; i++) + { + partical[i] = new Particals(this); + + } + + + lerpedBuffer = new float[width]; + lerpedBuffer2 = new float[width]; + + + } + + public void draw() + { + //Creat Beat Detection On Ap + beat.detect(ap.mix); + + background(30); + + calculateAverageAmplitude(); + + alex = new AlexsVisual(this); + alex2 = new AlexsVisual2(this); + jay = new JaycelsVisual(this); + jay2 = new JaycelsVisual2(this); + mende = new MendesVisual(this); + startm = new StartMenu(this); + + //_______________Switch Statment For Visuals + + if(allowToPlay){ + switch (mode) + { + case 0: + break; + case 1: + //First Visual + jay.render(); + startm.lowerMenu(); + break; + case 2: + //Second Visual + jay2.render(); + startm.lowerMenu(); + break; + case 3: + //Third Visual + for(int i = 0; i < particals; i++) + { + partical[i].render(); + } + alex.render(); + startm.lowerMenu(); + break; + case 4: + //Fourth Visual + alex2.render(); + startm.lowerMenu(); + break; + case 5: + //Fifth Visual + mende.render(); + startm.lowerMenu(); + break; + } + }else{ + //At the start when song isnt playing show menu + startm.render(); + } + } + //___________________End Draw Method() + + + public void mouseClicked() + { + //If statments to check the cordinates of the mouse and which box it is selecting + + if(isPlaying == false && mouseX >= startm.jayBoxX && mouseX <= startm.jayBoxX + startm.BoxWidth && mouseY >= startm.BoxY && mouseY <= startm.BoxY + startm.BoxHeight){ + + firstClick = 1; + mode = 1; + choice = 1; + colour = 200; + + }else if(isPlaying == false && mouseX >= startm.jayBox2X && mouseX <= startm.jayBox2X + startm.BoxWidth && mouseY >= startm.BoxY && mouseY <= startm.BoxY + startm.BoxHeight){ + + firstClick = 1; + mode = 2; + choice = 2; + colour = 200; + + }else if(isPlaying == false && mouseX >= startm.alexBoxX && mouseX <= startm.alexBoxX + startm.BoxWidth && mouseY >= startm.BoxY && mouseY <= startm.BoxY + startm.BoxHeight){ + + firstClick = 1; + mode = 3; + choice = 3; + colour = 200; + + }else if(isPlaying == false && mouseX >= startm.alexBox2X && mouseX <= startm.alexBox2X + startm.BoxWidth && mouseY >= startm.BoxY && mouseY <= startm.BoxY + startm.BoxHeight){ + + firstClick = 1; + mode = 4; + choice = 4; + colour = 200; + + }else if(isPlaying == false && mouseX >= startm.mendeBoxX && mouseX <= startm.mendeBoxX + startm.BoxWidth && mouseY >= startm.BoxY && mouseY <= startm.BoxY + startm.BoxHeight){ + + firstClick = 1; + mode = 5; + choice = 5; + colour = 200; + + } + + //Mouse coridnates for the play button, first checks if the first click was made + if(firstClick != 0 && mouseX <= startm.playButtonX + 50 && mouseX >= startm.playButtonX - 50 && mouseY >= startm.playButtonY - 50 && mouseY <= startm.playButtonY + 50){ + + allowToPlay = true; + ap.play(); + isPlaying = true; + + } + + //If the Song is Playing + if(allowToPlay){ + + //Lower Menu Button to pause and play the song + if(mouseX <= startm.pressButtonX + startm.ButtoRadius && mouseX >= startm.pressButtonX - startm.ButtoRadius && mouseY >= startm.ButtonY - startm.ButtoRadius && mouseY <= startm.ButtonY + startm.ButtoRadius){ + if(ap.isPlaying()){ + + ap.pause(); + buttonMode = 0; + + }else{ + + buttonMode = 1; + ap.play(); + + } + } + + //Lower Menu Loop button + if(mouseX <= startm.loopButtonX + startm.ButtoRadius && mouseX >= startm.loopButtonX - startm.ButtoRadius && mouseY >= startm.ButtonY - startm.ButtoRadius && mouseY <= startm.ButtonY + startm.ButtoRadius){ + + ap.loop(); + buttonMode = 1; + + } + + //Scrolling through the renders in the lower menu + + if(mouseX <= startm.rightbuttonX + startm.nextButtonWidth && mouseX >= startm.rightbuttonX && mouseY >= startm.nextButtonY && mouseY <= startm.nextButtonY + startm.nextButtonHeight){ + mode = startm.index1; + } + + if(mouseX <= startm.rightbutton2X + startm.nextButtonWidth && mouseX >= startm.rightbutton2X && mouseY >= startm.nextButtonY && mouseY <= startm.nextButtonY + startm.nextButtonHeight){ + mode = startm.index2; + } + + if(mouseX <= startm.leftbuttonX + startm.nextButtonWidth && mouseX >= startm.leftbuttonX && mouseY >= startm.nextButtonY && mouseY <= startm.nextButtonY + startm.nextButtonHeight){ + mode = startm.index3; + } + + if(mouseX <= startm.leftbutton2X + startm.nextButtonWidth && mouseX >= startm.leftbutton2X && mouseY >= startm.nextButtonY && mouseY <= startm.nextButtonY + startm.nextButtonHeight){ + mode = startm.index4; + } + + } + + } + //___________________End Mouse Click Method + +} diff --git a/java/src/C20401562/StartMenu.java b/java/src/C20401562/StartMenu.java new file mode 100644 index 000000000..8264c063f --- /dev/null +++ b/java/src/C20401562/StartMenu.java @@ -0,0 +1,269 @@ +package C20401562; + + +import ie.tudublin.Visual; + +public class StartMenu extends Visual{ + + Start s; + String string = "Select One Of The Renders And Press Play"; + + float space = 0; + int heightOfBox = 0; + + //Variables To Return Back to Start.java + + float alexBoxX; + float alexBox2X; + + float BoxY; + float BoxWidth; + float BoxHeight; + + float jayBoxX; + float jayBox2X; + + float mendeBoxX; + + float playButtonX; + float playButtonY; + float playRadius; + + float loopButtonX; + float pressButtonX; + float ButtonY; + float ButtoRadius; + + float rightbuttonX; + float rightbutton2X; + float leftbuttonX; + float leftbutton2X; + float nextButtonY; + float nextButtonWidth; + float nextButtonHeight; + + int index1; + int index2; + int index3; + int index4; + + + //_____________Constructor + public StartMenu(Start start) + { + this.s = start; + + } + + public void render(){ + + s.image(s.img, 0, 0, s.width, s.height); + + s.pushMatrix(); + s.translate(s.width/2, s.height/2); + + //Top Text + s.fill(250); + s.textSize(40); + s.text(string, -380, -180); + + //Play Button + s.fill(255); + s.circle(0,0, 100); + s.fill(0); + s.noStroke(); + s.triangle(-15, 28, -15, -28, 30, 0); + + s.popMatrix(); + + + space = s.width/10; + heightOfBox = 60; + + s.pushMatrix(); + s.translate(s.width/2, s.height/2 + 140 , 0); + + //RGB for colours matching background image + s.colorMode(RGB); + + //Get choice from Start, when rectangle is clicked then turn that border green + if(s.choice == 1){//Jay1 + s.noFill(); + s.stroke(255, 0, 255); + s.strokeWeight(3); + s.rect(-space * 3.5f, 0, space, heightOfBox, 10); + }else if(s.choice == 2){//Jay2 + s.noFill(); + s.stroke(255, 0, 255); + s.strokeWeight(3); + s.rect(-space * 2, 0, space, heightOfBox, 10); + }else if(s.choice == 3){//Alex + s.noFill(); + s.stroke(64, 0, 255); + s.strokeWeight(3); + s.rect(-space/2, 0, space, heightOfBox, 10); + }else if(s.choice == 4){//Alex2 + s.noFill(); + s.stroke(64, 0, 255); + s.strokeWeight(3); + s.rect(space, 0, space, heightOfBox, 10); + }else if(s.choice == 5){//Mende + s.noFill(); + s.stroke(64, 0, 255); + s.strokeWeight(3); + s.rect(space * 2.5f, 0, space, heightOfBox, 10); + }else{ + s.noStroke(); + s.noFill(); + } + + s.fill(230); + s.noStroke(); + + //Each Persons Rectangle and Respectful name + //Jay + s.fill(64, 0, 255); + s.rect(-space * 2, 0, space, heightOfBox, 10); + s.rect(-space * 3.5f, 0, space, heightOfBox, 10); + s.fill(255, 0, 255); + //Alex + s.rect(-space/2, 0, space, heightOfBox, 10); + s.rect(space, 0, space, heightOfBox, 10); + //Mende + s.rect(space * 2.5f, 0, space, heightOfBox, 10); + s.colorMode(HSB); + s.fill(255); + + s.textSize(40); + s.text("Jay", -space - space*2 - 35, heightOfBox/1.3f); + s.text("Jay 2", -space -space/2 - 40, heightOfBox/1.3f); + s.text("Alex", -40 ,heightOfBox/1.3f); + s.text("Alex 2", space + space/2 -heightOfBox + 5, heightOfBox/1.3f); + s.text("Mende", space + space * 2 -heightOfBox, heightOfBox/1.3f); + + s.popMatrix(); + + + //Setting Variables for Start + BoxY = s.height/2 + 140; + BoxWidth = space; + BoxHeight = heightOfBox; + + alexBoxX = s.width/2 -space/2; + alexBox2X = s.width/2 + space; + + jayBoxX = s.width/2 -space * 3.5f; + jayBox2X = s.width/2 -space * 2; + + mendeBoxX = s.width/2 + space * 2.5f; + + playButtonX = s.width/2; + playButtonY = s.height/2; + playRadius = 100; + + } + //_____________End Of Render + + public void lowerMenu() + { + + s.strokeWeight(2); + + + //Play/Pause Button + s.fill(255); + s.circle(s.width/2 - 40, s.height - 30, 40); + + //Loop Button + s.stroke(255); + s.noFill(); + s.circle(s.width/2 + 40, s.height - 30, 40); + + s.stroke(255); + s.fill(255); + s.triangle(s.width/2 + 50, s.height - 20, s.width/2 + 70, s.height - 20, s.width/2 + 60, s.height - 30); + + + //Grabs if the song is playing or not and changed the button mode from puase to play + if(s.buttonMode == 1){ + s.fill(20); + s.noStroke(); + s.rect(s.width/2 - 38.25f, s.height - 42.5f, 8, 25,2); + s.rect(s.width/2 - 50, s.height - 42.5f, 8, 25,2); + + s.noFill(); + s.stroke(90, 220, 360); + s.circle(s.width/2 - 40, s.height - 30, 40); + }else{ + s.noFill(); + s.stroke(0, 220, 360); + s.circle(s.width/2 - 40, s.height - 30, 40); + + s.fill(20); + s.stroke(40); + s.triangle(s.width/2 - 48, s.height - 42.5f, s.width/2 - 48, s.height - 16.5f, s.width/2 - 25.25f, s.height - 29.5f); + } + + //Creating two rectangles so user can switch through to other graphics + s.stroke(255); + //RightSide + s.rect(s.width/2 + 100, s.height - 50, 100, 40); + s.rect(s.width/2 + 250, s.height - 50, 100, 40); + //Left Side + s.rect(s.width/2 - 200, s.height - 50, 100, 40); + s.rect(s.width/2 - 350, s.height - 50, 100, 40); + + //Loops through array from Start to know which text to put were + s.fill(255); + s.textSize(25); + + int leftbox = 0; + int left2box = 0; + int rightbox = 0; + int right2box = 0; + + for(int i = 1; i < s.name.length; i++){ + //If the index of the array is not the current one playing populate rectangles + if(s.mode != i && leftbox == 0){ + s.text(s.name[i],s.width/2 - 180, s.height - 22); + index3 = i; + leftbox = 1; + }else if(s.mode != i && rightbox == 0){ + s.text(s.name[i],s.width/2 + 118, s.height - 22); + index1 = i; + rightbox = 1; + }else if(s.mode != i && right2box == 0){ + s.text(s.name[i],s.width/2 + 260, s.height - 22); + index2 = i; + right2box = 1; + }else if(s.mode != i && left2box == 0){ + s.text(s.name[i],s.width/2 - 340, s.height - 22); + index4 = i; + left2box = 1; + } + } + + + //Variables for Start + loopButtonX = s.width/2 + 40; + + pressButtonX = s.width/2 - 40; + ButtonY = s.height - 30; + ButtoRadius = 20; + + + rightbuttonX = s.width/2 + 100; + rightbutton2X = s.width/2 + 250; + leftbuttonX = s.width/2 - 200; + leftbutton2X = s.width/2 - 350; + + nextButtonHeight = 40; + nextButtonWidth = 100; + nextButtonY = s.height - 50; + + + } + + //___________________End Lower Menu + +} 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/AudioBandsVisual.java b/java/src/example/AudioBandsVisual.java deleted file mode 100644 index b6b99d6e5..000000000 --- a/java/src/example/AudioBandsVisual.java +++ /dev/null @@ -1,25 +0,0 @@ -package example; - -import processing.core.*; - -// This is an example of a visual that uses the audio bands -public class AudioBandsVisual -{ - MyVisual mv; - - public AudioBandsVisual(MyVisual mv) - { - this.mv = mv; - } - - public void render() - { - float gap = mv.width / (float) mv.getBands().length; - mv.noStroke(); - for(int i = 0 ; i < mv.getBands().length ; i ++) - { - mv.fill(PApplet.map(i, 0, mv.getBands().length, 255, 0), 255, 255); - mv.rect(i * gap, mv.height, gap,-mv.getSmoothedBands()[i] * 0.2f); - } - } -} \ No newline at end of file diff --git a/java/src/example/CubeVisual.java b/java/src/example/CubeVisual.java deleted file mode 100644 index ff8e58798..000000000 --- a/java/src/example/CubeVisual.java +++ /dev/null @@ -1,90 +0,0 @@ -package example; - -import ie.tudublin.Visual; - -public class CubeVisual extends Visual -{ - boolean twocubes = false; - - public void settings() - { - size(800, 800, P3D); - println("CWD: " + System.getProperty("user.dir")); - //fullScreen(P3D, SPAN); - } - - public void keyPressed() - { - if (key == ' ') - { - getAudioPlayer().cue(0); - getAudioPlayer().play(); - - } - if (key == '1') - { - twocubes = ! twocubes; - - } - } - - public void setup() - { - colorMode(HSB); - noCursor(); - - setFrameSize(256); - - startMinim(); - loadAudio("heroplanet.mp3"); - //getAp().play(); - //startListening(); - - } - - float smoothedBoxSize = 0; - - public void draw() - { - calculateAverageAmplitude(); - background(0); - noFill(); - lights(); - stroke(map(getSmoothedAmplitude(), 0, 1, 0, 255), 255, 255); - camera(0, 0, 0, 0, 0, -1, 0, 1, 0); - translate(0, 0, -250); - - float boxSize = 50 + (getAmplitude() * 300);//map(average, 0, 1, 100, 400); - smoothedBoxSize = lerp(smoothedBoxSize, boxSize, 0.2f); - if (twocubes) - { - pushMatrix(); - translate(-100, 0, 0); - rotateY(angle); - rotateX(angle); - box(smoothedBoxSize); - //strokeWeight(1); - //sphere(smoothedBoxSize); - popMatrix(); - pushMatrix(); - translate(100, 0, 0); - rotateY(angle); - rotateX(angle); - strokeWeight(5); - box(smoothedBoxSize); - popMatrix(); - } - else - { - rotateY(angle); - rotateX(angle); - //strokeWeight(1); - //sphere(smoothedBoxSize/ 2); - strokeWeight(5); - - box(smoothedBoxSize); - } - angle += 0.01f; - } - float angle = 0; -} \ No newline at end of file diff --git a/java/src/example/CubeVisual1.java b/java/src/example/CubeVisual1.java deleted file mode 100644 index 8eebd97f8..000000000 --- a/java/src/example/CubeVisual1.java +++ /dev/null @@ -1,53 +0,0 @@ -package example; - -import ie.tudublin.Visual; - -public class CubeVisual1 extends Visual -{ - public void settings() - { - size(800, 600, P3D); - //fullScreen(P3D, SPAN); - } - - public void setup() - { - startMinim(); - //startListening(); - loadAudio("heroplanet.mp3"); - colorMode(HSB); - } - - public void keyPressed() - { - if (key == ' ') - { - getAudioPlayer().cue(0); - getAudioPlayer().play(); - } - } - - float angle = 0; - - public void draw() - { - 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; - } - - -} \ No newline at end of file diff --git a/java/src/example/MyVisual.java b/java/src/example/MyVisual.java deleted file mode 100644 index 849e71bc2..000000000 --- a/java/src/example/MyVisual.java +++ /dev/null @@ -1,65 +0,0 @@ -package example; - -import ie.tudublin.*; - -public class MyVisual extends Visual -{ - WaveForm wf; - AudioBandsVisual abv; - - public void settings() - { - size(1024, 500); - - // Use this to make fullscreen - //fullScreen(); - - // Use this to make fullscreen and use P3D for 3D graphics - //fullScreen(P3D, SPAN); - } - - public void setup() - { - startMinim(); - - // Call loadAudio to load an audio file to process - //loadAudio("heroplanet.mp3"); - - - // Call this instead to read audio from the microphone - startListening(); - - wf = new WaveForm(this); - abv = new AudioBandsVisual(this); - } - - public void keyPressed() - { - if (key == ' ') - { - getAudioPlayer().cue(0); - getAudioPlayer().play(); - } - } - - 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(); - } -} diff --git a/java/src/example/RotatingAudioBands.java b/java/src/example/RotatingAudioBands.java deleted file mode 100644 index 72fd7a223..000000000 --- a/java/src/example/RotatingAudioBands.java +++ /dev/null @@ -1,89 +0,0 @@ -package example; - -import ie.tudublin.Visual; -import ie.tudublin.VisualException; - -public class RotatingAudioBands extends Visual { - - - public void settings() - { - size(800, 800, P3D); - println("CWD: " + System.getProperty("user.dir")); - //fullScreen(P3D, SPAN); - } - - public void keyPressed() - { - if (key == ' ') - { - getAudioPlayer().cue(0); - getAudioPlayer().play(); - - } - - } - - public void setup() - { - colorMode(HSB); - noCursor(); - - setFrameSize(256); - - startMinim(); - loadAudio("heroplanet.mp3"); - getAudioPlayer().play(); - //startListening(); - - } - - float radius = 200; - - float smoothedBoxSize = 0; - - float rot = 0; - - public void draw() - { - calculateAverageAmplitude(); - try - { - calculateFFT(); - } - catch(VisualException e) - { - e.printStackTrace(); - } - calculateFrequencyBands(); - background(0); - noFill(); - stroke(255); - lights(); - stroke(map(getSmoothedAmplitude(), 0, 1, 0, 255), 255, 255); - camera(0, -500, 500, 0, 0, 0, 0, 1, 0); - //translate(0, 0, -250); - - rot += getAmplitude() / 8.0f; - - rotateY(rot); - float[] bands = getSmoothedBands(); - for(int i = 0 ; i < bands.length ; i ++) - { - float theta = map(i, 0, bands.length, 0, TWO_PI); - - stroke(map(i, 0, bands.length, 0, 255), 255, 255); - float x = sin(theta) * radius; - float z = cos(theta) * radius; - float h = bands[i]; - pushMatrix(); - translate(x, - h / 2 , z); - rotateY(theta); - box(50, h, 50); - popMatrix(); - } - - } - float angle = 0; - -} \ No newline at end of file diff --git a/java/src/example/RotatingBands.java b/java/src/example/RotatingBands.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/java/src/example/WaveForm.java b/java/src/example/WaveForm.java deleted file mode 100644 index 5d38aa700..000000000 --- a/java/src/example/WaveForm.java +++ /dev/null @@ -1,31 +0,0 @@ -package example; - -import processing.core.*; - -// This is an example of a visual that renders the waveform -public class WaveForm -{ - MyVisual mv; - float cy = 0; - - public WaveForm(MyVisual mv) - { - this.mv = mv; - cy = this.mv.height / 2; - } - - public void render() - { - mv.colorMode(PApplet.HSB); - for(int i = 0 ; i < mv.getAudioBuffer().size() ; i ++) - { - mv.stroke( - PApplet.map(i, 0, mv.getAudioBuffer().size(), 0, 255) - , 255 - , 255 - ); - - mv.line(i, cy, i, cy + cy * mv.getAudioBuffer().get(i)); - } - } -} \ No newline at end of file diff --git a/java/src/ie/tudublin/Main.java b/java/src/ie/tudublin/Main.java index 27489f824..c639af517 100644 --- a/java/src/ie/tudublin/Main.java +++ b/java/src/ie/tudublin/Main.java @@ -1,21 +1,19 @@ package ie.tudublin; -import example.CubeVisual; -import example.MyVisual; -import example.RotatingAudioBands; +import C20401562.*; public class Main { - public void startUI() + public void start() { String[] a = {"MAIN"}; - processing.core.PApplet.runSketch( a, new MyVisual()); + processing.core.PApplet.runSketch( a, new Start()); } public static void main(String[] args) { Main main = new Main(); - main.startUI(); + main.start(); } } \ No newline at end of file diff --git a/java/src/ie/tudublin/Visual.java b/java/src/ie/tudublin/Visual.java index 927fe57b1..1614e2e02 100644 --- a/java/src/ie/tudublin/Visual.java +++ b/java/src/ie/tudublin/Visual.java @@ -2,7 +2,7 @@ import processing.core.PApplet; import ddf.minim.*; -import ddf.minim.analysis.FFT; +import ddf.minim.analysis.*; public abstract class Visual extends PApplet { @@ -14,8 +14,10 @@ public abstract class Visual extends PApplet private Minim minim; private AudioInput ai; - private AudioPlayer ap; - private AudioBuffer ab; + public AudioSample as; + public AudioPlayer ap; + public static AudioBuffer ab; + public BeatDetect beat; private FFT fft; private float amplitude = 0; @@ -64,7 +66,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); @@ -111,6 +113,10 @@ public float[] getBands() { return bands; } + public void setBands(float[] bands) { + this.bands = bands; + } + public float[] getSmoothedBands() { return smoothedBands; } @@ -143,4 +149,10 @@ public AudioPlayer getAudioPlayer() { public FFT getFFT() { return fft; } -} + + public BeatDetect BeatDetect() + { + beat = new BeatDetect(); + return beat; + } +} \ No newline at end of file