We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I was wondering if there's a way to detect amplitude peaks in a sound file while being played. I don't need anything fancy really, I just need to find when the "volume" is above a certain level.
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup()
{
minim = new Minim(this);
player = minim.loadFile("/data/samples/sample02.mp3");
player.play();
}
void draw()
{
println("Gain: " + player.getGain()); //always prints 0.0 but I guess it's because it's not what I'm looking for
println("Volume: " + player.getVolume()); //Minim error: Volume is not supported
}
Thank you!
Answers
Please provide your code, your attempt.
Kf
edited
@plux -- I believe you want: (untested)
For related older discussion, see:
to get the overall amp is it ok to get a simple average between the L/R channels? like
(player.right.level() + player.left.level()) /2
It depends on what you are measuring. You could take the average, or the max, or you could look at perceptual loudness, e.g. based on the pan....
I see..the average will do, thanks!