Hello everyone!
I’m having trouble knowing how my wave moves at the same time as my music. In this sense, I would like to know if anyone can help me to resolve this issue?
I already created my wave and put my music on processing:
import ddf.minim.*;
Minim minim;
AudioPlayer song;
void setup(){
size(1000, 1000);
background(#357BC4);
minim = new Minim(this);
song = minim.loadFile("Maroon 5 - Beautiful Mistakes ft. Megan Thee Stallion (Official Lyric Video)");
song.play();
smooth();
}
void draw() {
line(0, 550, width, 550);
stroke(255);
float x = 0;
while(x < width) {
point(x, 550+ 20 * sin(x/10));
x = x + 1;
}
}
Hello again! I found this example in the processing library:
import processing.sound.*;
SoundFile sample;
Amplitude rms;
float smoothingFactor = 0.25;
float sum;
public void setup() {
size(640, 360);
sample = new SoundFile(this, "beat.aiff");
sample.loop();
rms = new Amplitude(this);
rms.input(sample);
}
public void draw() {
background(125, 255, 125);
noStroke();
fill(255, 0, 150);
sum += (rms.analyze() - sum) * smoothingFactor;
float rms_scaled = sum * (height/2) * 5;
ellipse(width/2, height/2, rms_scaled, rms_scaled);
and that was what I was looking for, but when I change the song in the place where it is to a meter, the song I want does not play. And the song has already imported it into the same folder where this sketch is located, can someone help me understand what I’m doing wrong? Thank you
abr 30, 2021 12:03:31 PM com.jsyn.devices.javasound.JavaSoundAudioDevice
INFO: JSyn: default output latency set to 80 msec for Windows 10
Sound library error: unable to find file Maroon 5 - Nobody’s Love (Official Lyric Video).wav
NullPointerException
NullPointerException
NullPointerException
NullPointerException
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
Good afternoon.
In the meantime I manage to solve some problems that I had in relation to this issue of mine, but other questions arose.
I already have this code and I managed to get my wave to work at the same time as my music, however, there is a delay or something like that, that doesn’t let the wave accompany the music, I think it’s from frameRate, but when I shoot it background colors change too fast and I don’t want that. Can someone help me solve this problem? Thank you.
import processing.sound.*;
SoundFile sample;
Waveform waveform;
int samples = 100;
float r;
float g;
float b;
void setup(){
size(640, 360);
background(255);
frameRate(1);
sample = new SoundFile(this, "Maroon 5 - Nobody's Love.wav");
sample.loop();
waveform = new Waveform(this, samples);
waveform.input(sample);
}
void draw() {
r = random(255);
g = random(255);
b = random(255);
background(r, g, b);
stroke(255);
strokeWeight(5);
noFill();
waveform.analyze();
beginShape();
for(int i = 0; i < samples; i++){
// Draw current data of the waveform
// Each sample in the data array is between -1 and +1
vertex(
map(i, 0, samples, 0, width),
map(waveform.data[i], -1, 1, 0, height)
);
}
endShape();
}
However, if your FPS is higher than your refresh rate, your display will not be able to display all of the frames your computer is producing, so although the refresh rate doesn’t technically limit the frame rate, it does effectively set a cap.