help getting started with visualising gain
in
Core Library Questions
•
1 year ago
i'm trying to get an ellipse's radius to increase.decrease according to the amplitude of an audio file. I have found this example in minim, which uses BeatDetect. Will modifying this example work, or should i use some sort of Fourier transform to get the ampiltude of the audio?
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- Minim minim;
- AudioPlayer song;
- BeatDetect beat;
- float eRadius;
- void setup()
- {
- size(200, 200, P3D);
- minim = new Minim(this);
- song = minim.loadFile("davis.aif", 2048);
- song.play();
- // a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
- beat = new BeatDetect();
- ellipseMode(CENTER_RADIUS);
- eRadius = 20;
- }
- void draw()
- {
- background(0);
- beat.detect(song.mix);
- float a = map(eRadius, 20, 80, 60, 255);
- fill(60, 255, 0, a);
- if ( beat.isOnset() ) eRadius = 80;
- ellipse(width/2, height/2, eRadius, eRadius);
- eRadius *= 0.95;
- if ( eRadius < 20 ) eRadius = 20;
- }
- void stop()
- {
- // always close Minim audio classes when you are finished with them
- song.close();
- // always stop Minim before exiting
- minim.stop();
- super.stop();
- }
1