import ddf.minim.*; import ddf.minim.analysis.*; import ddf.minim.signals.*; Minim minim; AudioInput in; FFT fft; float loudestFreqAmp = 0; float loudestFreq = 0; void setup() { size(588,200); frameRate(15); smooth(); minim = new Minim(this); minim.debugOn(); background(255); noStroke(); in = minim.getLineIn(Minim.STEREO, 1024); fft = new FFT(in.bufferSize(), in.sampleRate()); } void draw() { background(0,0,0); PFont font; font = loadFont("CourierNewPS-BoldMT-70.vlw"); fft.window(FFT.HAMMING); for(int i = 0; i < fft.specSize(); i++) { if (fft.getBand(i) > loudestFreqAmp && fft.getBand(i) > 10) { loudestFreqAmp = fft.getBand(i); loudestFreq = i * 4; fill(loudestFreq * 10, 255 - loudestFreq, loudestFreq * 20, 128 ); if(loudestFreq > 15) { background(0,0,0); textFont(font); fill(200); text("A", 15, 70); rect(7,0,7,200); rect(56,0,7,200);} if(loudestFreq > 18) { background(0,0,0); textFont(font); fill(200); text("B", 36, 70); rect(28,0,7,200); rect(77,0,7,200);} if(loudestFreq > 20) { background(0,0,0); textFont(font); fill(200); text("C", 57, 70); rect(49,0,7,200); rect(98,0,7,200);} if(loudestFreq > 23) { background(0,0,0); textFont(font); fill(200); text("D", 77, 70); rect(69,0,7,200); rect(118,0,7,200);} if(loudestFreq > 25) { background(0,0,0); textFont(font); fill(200); text("E", 98, 70); rect(90,0,7,200); rect(139,0,7,200);} if(loudestFreq > 28) { background(0,0,0); textFont(font); fill(200); text("F", 119, 70); rect(111,0,7,200); rect(60,0,7,200);} if(loudestFreq > 31) { background(0,0,0); textFont(font); fill(200); text("G", 140, 70); rect(132,0,7,200); rect(181,0,7,200);} if(loudestFreq > 33) { background(0,0,0); textFont(font); fill(200); text("H", 161, 70); rect(153,0,7,200); rect(202,0,7,200);} if(loudestFreq > 36) { background(0,0,0); textFont(font); fill(200); text("I", 181, 70); rect(173,0,7,200); rect(222,0,7,200);} if(loudestFreq > 38) { background(0,0,0); textFont(font); fill(200); text("J", 202, 70); rect(194,0,7,200); rect(243,0,7,200);} if(loudestFreq > 41) { background(0,0,0); textFont(font); fill(200); text("K", 223, 70); rect(215,0,7,200); rect(264,0,7,200);} if(loudestFreq > 44) { background(0,0,0); textFont(font); fill(200); text("L", 244, 70); rect(236,0,7,200); rect(295,0,7,200);} if(loudestFreq > 46) { background(0,0,0); textFont(font); fill(200); text("M", 265, 70); rect(257,0,7,200); rect(306,0,7,200);} if(loudestFreq > 49) { background(0,0,0); textFont(font); fill(200); text("N", 285, 70); rect(277,0,7,200); rect(326,0,7,200);} if(loudestFreq > 51) { background(0,0,0); textFont(font); fill(200); text("O", 306, 70); rect(298,0,7,200); rect(347,0,7,200);} if(loudestFreq > 54) { background(0,0,0); textFont(font); fill(200); text("P", 327, 70); rect(319,0,7,200); rect(368,0,7,200);} if(loudestFreq > 57) { background(0,0,0); textFont(font); fill(200); text("Q", 348, 70); rect(340,0,7,200); rect(389,0,7,200);} if(loudestFreq > 59) { background(0,0,0); textFont(font); fill(200); text("R", 369, 70); rect(361,0,7,200); rect(410,0,7,200);} if(loudestFreq > 62) { background(0,0,0); textFont(font); fill(200); text("S", 389, 70); rect(381,0,7,200); rect(430,0,7,200);} if(loudestFreq > 64) { background(0,0,0); textFont(font); fill(200); text("T", 410, 70); rect(402,0,7,200); rect(451,0,7,200);} if(loudestFreq > 67) { background(0,0,0); textFont(font); fill(200); text("U", 431, 70); rect(423,0,7,200); rect(472,0,7,200);} if(loudestFreq > 70) { background(0,0,0); textFont(font); fill(200); text("V", 452, 70); rect(444,0,7,200); rect(493,0,7,200);} if(loudestFreq > 72) { background(0,0,0); textFont(font); fill(200); text("W", 473, 70); rect(465,0,7,200); rect(514,0,7,200);} if(loudestFreq > 75) { background(0,0,0); textFont(font); fill(200); text("X", 493, 70); rect(485,0,7,200); rect(534,0,7,200);} if(loudestFreq > 77) { background(0,0,0); textFont(font); fill(200); text("Y", 514, 70); rect(506,0,7,200); rect(555,0,7,200);} if(loudestFreq > 80) { background(0,0,0); textFont(font); fill(200); text("Z", 535, 70); rect(527,0,7,200); rect(576,0,7,200);} } } loudestFreqAmp = 0; fft.forward(in.mix); } void stop() { in.close(); minim.stop(); super.stop(); }