UnexpectedGirl
YaBB Newbies
Offline
Posts: 2
BeatDetect - substitute image for text?
Feb 18th , 2010, 6:11am
Hi I want to substitute an image in place of the text a Minim BeatDetect tutorial. It's the Frequency Energy one. My major issue is that whilst I can get an image in place of the text, I can't get it to resize itself in response to the beat ((kickSize) in the sketch). Basically I want the image to pulse to the beat instead of the text. I'm new to Processing, so I'm sure it's probably just a syntax thing - I'm sorry if I'm just being a bit dim here, or if I've missed another thread on this. Any help would be greatly appreciated! I've posted the code from the tutorial below because I can't post active links yet. Thanks :) import ddf.minim.*; import ddf.minim.analysis.*; Minim minim; AudioPlayer song; BeatDetect beat; BeatListener bl; float kickSize, snareSize, hatSize; void setup() { size(512, 200, P3D); minim = new Minim(this); song = minim.loadFile("marcus_kellis_theme.mp3", 2048); song.play(); beat = new BeatDetect(song.bufferSize(), song.sampleRate()); beat.setSensitivity(300); kickSize = snareSize = hatSize = 16; bl = new BeatListener(beat, song); textFont(createFont("Helvetica", 16)); textAlign(CENTER); } void draw() { background(0); fill(255); if ( beat.isKick() ) kickSize = 32; if ( beat.isSnare() ) snareSize = 32; if ( beat.isHat() ) hatSize = 32; textSize(kickSize); text("KICK", width/4, height/2); textSize(snareSize); text("SNARE", width/2, height/2); textSize(hatSize); text("HAT", 3*width/4, height/2); kickSize = constrain(kickSize * 0.95, 16, 32); snareSize = constrain(snareSize * 0.95, 16, 32); hatSize = constrain(hatSize * 0.95, 16, 32); } void stop() { song.close(); minim.stop(); super.stop(); }