Files
sunny9898/task8/wk9/wk9_example_2/wk9_example_2.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

30 lines
628 B
Plaintext

// Based on Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 20-1: Simple Sound Playback
import processing.sound.*;
SoundFile song;
Amplitude amp;
float threshold = 0.25;
void setup() {
size(640, 360);
song = new SoundFile(this, "beat.aiff");
// You might get IndexOutOfBoundsException error when loading a mp3 file with mono channel
//song = new SoundFile(this, "beat.mp3");
song.loop();
amp = new Amplitude(this);
amp.input(song);
}
void draw() {
background(amp.analyze()*255);
//if (amp.analyze()>threshold)
// background(255);
//else
// background(0);
}