public void setup() { int window_height = 220; size((int) (window_height * 5.12f), 220); canvas = createGraphics((int) (window_height * 5.12f) / 2, 220, JAVA2D); textMode(SCREEN); textFont(createFont("SanSerif", 12)); minim = new Minim(this); in = minim.getLineIn(Minim.MONO, buffer_size, sample_rate); // create an FFT object that has a time-domain buffer // the same size as line-in's sample buffer fft = new FFT(in.bufferSize(), in.sampleRate()); // Tapered window important for log-domain display fft.window(FFT.HAMMING); // initialize peak-hold structures peaksize = 1 + Math.round(fft.specSize() / binsperband); peaks = new float[peaksize]; peak_age = new int[peaksize]; particles = new Particle[fft.specSize()]; for (int i = 0; i < fft.specSize(); i++) particles[i] = new Particle(i); }
private void drawWaveForm() { for (int i = 0; i < in.bufferSize() - 1; i++) { saved_buffer[i] = in.left.get(i); line(i + 50, height / 2 + in.left.get(i) * 50, i + 51, height / 2 + in.left.get(i + 1) * 50); } }