Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Processing Sound Library, Example 6
- *
- * This sketch shows how to use the Amplitude class to analyze a
- * stream of sound. In this case a sample is analyzed. The smoothFactor
- * variable determines how much the signal will be smoothed on a scale
- * from 0 - 1.
- */
- import processing.sound.*;
- // Declare the processing sound variables
- SoundFile sample;
- Amplitude rms;
- // Declare a scaling factor
- float scale = 5.0;
- // Declare a smooth factor
- float smoothFactor = 0.25;
- // Used for smoothing
- float sum;
- void setup() {
- size(640, 360);
- //Load and play a soundfile and loop it
- sample = new SoundFile(this, "beat.aiff");
- sample.loop();
- // Create and patch the rms tracker
- rms = new Amplitude(this);
- rms.input(sample);
- }
- void draw() {
- // Smooth the rms data by smoothing factor
- sum += (rms.analyze() - sum) * smoothFactor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement