#include "ofApp.h" void ofApp::setup(){ int frameRate=60; ofSetFrameRate(frameRate); ofBackground(0); ofEnableSmoothing(); ofEnableAlphaBlending(); ofSetVerticalSync(true); blockSize = SAMPLERATE / (frameRate*10); //80 ofSoundStreamListDevices(); soundStream.setup(this,0, 1, SAMPLERATE, blockSize, 1); buffer=Buffer(SAMPLERATE); vScale=3.0f; hScale=8.0f; lineWidth=2.0f; lasergui.setup("laser","",5,5); lasergui.add(laser_power.set("power", false)); lasergui.add(laser_intensity.set("intensity", 30, 0, 255)); lasergui.add(laser_points.set("points", 30000, 0, 40000)); lasergui.add(laser_subdivide.set("subdivide", 15, 1, 100)); lasergui.add(laser_blank_num.set("blank points", 8, 0, 32)); lasergui.add(laser_max_angle.set("max angle", 15.0f, 1.0f, 90.0f)); } void ofApp::update(){ laser.set_pts(laser_points); laser.set_subdivide(laser_subdivide); laser.set_blanknum(laser_blank_num); laser.set_maxangle(laser_max_angle); laser.set_intensity(laser_intensity); } int sampleNum=0; int frameNum=0; void ofApp::draw(){ ofBackground(0); ofSetLineWidth(lineWidth); float vpos=ofGetHeight()/2; float scale=ofGetHeight()*vScale; colourPolyline line; line.addVertex(0,vpos+(buffer[0]*scale)); float i=0.0f; while (i<(ofGetWidth()+hScale)){ i+=max(1.0f,hScale); line.curveTo(i,vpos+(buffer[(int)i]*scale)); } line.draw(); int numpts=0; if (laser_power) numpts=laser.draw(line); frameNum++; lasergui.draw(); ofSetWindowTitle(ofToString(ofGetFrameRate())+" fps, pts:"+(numpts?ofToString(numpts):"ERR")); } void ofApp::audioIn(float * input, int blockSize, int nChannels){ //ofLog()<< "frame "<