Skip to content
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
4 changes: 2 additions & 2 deletions java/.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
</natures>
<filteredResources>
<filter>
<id>1616413840733</id>
<id>1682958522475</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
Binary file added java/data/strawberry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added java/data/strawberry_fields_forever.mp3
Binary file not shown.
49 changes: 39 additions & 10 deletions java/src/ie/tudublin/Main.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
package ie.tudublin;

import example.CubeVisual;
import example.MyVisual;
import example.RotatingAudioBands;

public class Main
{
{
public static void strawberry()
{
String[] a = {"MAIN"};
processing.core.PApplet.runSketch(a, new StrawberryBush());
}

public void startUI()
public static void Tree()
{
String[] a = {"MAIN"};
processing.core.PApplet.runSketch( a, new MyVisual());
}
processing.core.PApplet.runSketch( a, new tree());
}



public static void Flower()
{
String[] a = {"MAIN"};
processing.core.PApplet.runSketch( a, new flower());
}

public static void main(String[] args)
public static void vines()
{
Main main = new Main();
main.startUI();
String[] a = {"MAIN"};
processing.core.PApplet.runSketch( a, new vines());
}

public static void notes()
{
String[] a = {"MAIN"};
processing.core.PApplet.runSketch( a, new notes());
}

public static void main(String[] args) throws InterruptedException
{
System.out.println("Hello world");

//Tree();
//strawberry();
//Flower();
vines();
//notes();
}


}
48 changes: 48 additions & 0 deletions java/src/ie/tudublin/StrawberryBush.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ie.tudublin;

import processing.core.PApplet;
import processing.core.PImage;
import ddf.minim.AudioBuffer;
import ddf.minim.AudioInput;
import ddf.minim.AudioPlayer;
import ddf.minim.Minim;


public class StrawberryBush extends PApplet {
Minim minim;
AudioInput ai;
AudioPlayer ap;
AudioBuffer ab;
PImage photo;

// global variables go here

public void settings() {
size(500, 500);
photo = loadImage("strawberry.png");
}

public void setup() {
minim = new Minim(this);
ap = minim.loadFile("strawberry_fields_forever.mp3", 1024);
ap.play();
ab = ap.mix;
colorMode(HSB);

}

// any necessary methods related to the draw method go here

public void draw() {
background(0);
// get the current amplitude of the audio signal
float amplitude = ab.level();

// use the amplitude to set the size of the image
float imageSize = map(amplitude, 0, 1, 50, 200);

// display the image with the new size
image(photo, width/2, height/2, imageSize, imageSize);
}

}
114 changes: 114 additions & 0 deletions java/src/ie/tudublin/flower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package ie.tudublin;

import ddf.minim.AudioBuffer;
import ddf.minim.AudioInput;
import ddf.minim.AudioPlayer;
import ddf.minim.Minim;
import ddf.minim.analysis.FFT;
import processing.core.PApplet;

public class flower extends PApplet {
Minim minim;
AudioPlayer ap;
AudioInput ai;
AudioBuffer ab;
FFT fft;

int mode = 0;

float y = 0;
float smoothedY = 0;
float smoothedAmplitude = 0;

public void settings() {
size(1024, 1000, P3D);
}

public void setup() {
minim = new Minim(this);
ap = minim.loadFile("strawberry_fields_forever.mp3", 1024);
ap.play();
ab = ap.mix;
colorMode(HSB);

y = height / 2;
smoothedY = y;

fft = new FFT(width, 1024);
}

public void sinFlower(float h, float w, float c) {

strokeWeight(0);

fill(20, 255, 220);

fill(c, 255, 220);

circle(h + 50, w + 10, 75); // works
circle(h - 50, w - 10, 75);
circle(h - 10, w + 50, 75);
circle(h + 10, w - 50, 75);

fill(50, 255, 255);
circle(h, w, 50);


}



float lerpedBuffer[] = new float[1024];

public void draw() {
background(80, 190, 150);
float halfH = height / 2;
float halfW = width / 2;
float average = 0;
float sum = 0;

int highestIndex = 0;
for(int i = 0 ;i < fft.specSize() / 2 ; i ++)
{
line(i * 2.0f, height, i * 2.0f, height - fft.getBand(i) * 5.0f);

if (fft.getBand(i) > fft.getBand(highestIndex))
{
highestIndex = i;
}
}

// Calculate sum and average of the samples
// Also lerp each element of buffer;
for (int i = 0; i < ab.size(); i++) {

sum += abs(ab.get(i));
lerpedBuffer[i] = lerp(lerpedBuffer[i], ab.get(i), 0.1f);

average = sum / (float) ab.size();
smoothedAmplitude = lerp(smoothedAmplitude, average, 0.5f);

float freq = (int)(average * 50000.0f);

System.out.println(freq);

float c = map(i, 0, freq, 0, 255);

//float f = lerpedBuffer[i] * halfH * 4.0f;
//float pos = halfH + random(-500,500);
// float pos2 = halfW + random(-500,500);


sinFlower(halfH, halfW, c+50); // middle flower
sinFlower(height/4, width/4, c+50);
sinFlower(height-300, width/3, c+50);

sinFlower(halfH+300, halfW+300, c+50);
sinFlower(halfH-350, halfW+50, c+50);
sinFlower(height/5, width-200, c+50);

}

}
}

135 changes: 135 additions & 0 deletions java/src/ie/tudublin/notes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package ie.tudublin;

import ddf.minim.AudioBuffer;
// import ddf.minim.AudioBuffer;
import ddf.minim.AudioInput;
import ddf.minim.AudioPlayer;
import ddf.minim.Minim;
import ddf.minim.analysis.FFT;
import processing.core.PApplet;

public class notes extends PApplet{

Minim m;
AudioInput ai;
AudioPlayer ap;
AudioBuffer ab;

FFT fft;

float[] frequencies = {293.66f, 329.63f, 369.99f,
392.00f, 440.00f, 493.88f, 554.37f, 587.33f
, 659.25f, 739.99f, 783.99f, 880.00f, 987.77f, 1108.73f, 1174.66f};
String[] spellings = {"D,", "E,", "F,", "G,", "A,", "B,", "C",
"D", "E", "F", "G", "A", "B","c", "d", "e",
"f", "g", "a", "b", "c'", "d'", "e'", "f'", "g'", "a'", "b'", "c''", "d''"};

public void settings()
{
size(1024, 1024);
}

public void setup()
{
m = new Minim(this);
//ai = m.getLineIn(Minim.MONO, width, 44100, 16);
//ab = ai.mix;

ap = m.loadFile("strawberry_fields_forever.mp3", 1024); //CHANGE
ap.play();
ab = ap.mix;
colorMode(HSB);

fft = new FFT(width, ab.size());
}


public void bubble(float x, float y, float size)
{
float x1;
float y1;

float x2;
float y2;

x1 = 100;
y1 = 700;

x2 = 100;
y2 = 500;

strokeWeight(4);
//stroke(130, 200, 200);
stroke(130, 60, 255);
fill(130, 100, 250);
circle(x, y, size);
stroke(130, 60, 255);
fill(130, 60, 255);
circle(x+20, y-20, size/5);
circle(x+30, y-5, size/10);

}

float lerpedBuffer[] = new float[1024];
public void draw()
{
background(0);
colorMode(HSB);
stroke(255);

float x = 500;
float y = 600;
float size = 100;
float f;

float half = height / 2;
for(int i = 0 ; i < ab.size() ; i ++)
{
background(0);
stroke(map(i, 0, ab.size(), 0, 255), 255, 255);
lerpedBuffer[i] = lerp(lerpedBuffer[i], ab.get(i), 0.1f);
f = abs(lerpedBuffer[i] * half * 5.0f);
//line(i, half + f, i, half - f);
bubble(x,(y-f), size);

}

fft.forward(ab);
stroke(255);

int highestIndex = 0;
for(int i = 0 ;i < fft.specSize() / 2 ; i ++)
{
line(i * 2.0f, height, i * 2.0f, height - (fft.getBand(i) * 100) * 0.50f);

if (fft.getBand(i) > fft.getBand(highestIndex))
{
highestIndex = i;
}

}

float freq = fft.indexToFreq(highestIndex);
freq = freq * 10;
//System.out.println(highestIndex);

for (int i = 0; i > 15; i++){
if (ab.get(i) == frequencies[i]){
//System.out.println(spellings);
}

}

fill(255);
textSize(20);
text("Freq: " + freq, 100, 100);


//bubble(x,y, size);

//println(map(5, 2, 10, 1000, 2000));
//println(map1(5, 2, 10, 1000, 2000));
}

float lerpedY = 0;
}
Binary file added java/src/ie/tudublin/strawberry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading