Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bryanshelp #5

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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*
Expand Down
Binary file added java/data/liveforever.mp3
Binary file not shown.
116 changes: 116 additions & 0 deletions java/src/c19444404/RyansVisual.java
Original file line number Diff line number Diff line change
@@ -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




}


}









7 changes: 6 additions & 1 deletion java/src/example/CubeVisual1.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import ie.tudublin.Visual;



public class CubeVisual1 extends Visual
{



public void settings()
{
size(800, 600, P3D);
Expand Down Expand Up @@ -48,6 +53,6 @@ public void draw()
popMatrix();
angle += 0.01f;
}
}


}
91 changes: 91 additions & 0 deletions java/src/ie/tudublin/Abduction.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
74 changes: 74 additions & 0 deletions java/src/ie/tudublin/Circles.java
Original file line number Diff line number Diff line change
@@ -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));
}


}
}




49 changes: 49 additions & 0 deletions java/src/ie/tudublin/Line.java
Original file line number Diff line number Diff line change
@@ -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);


}




}}









Loading