#include "ofApp.h" //-------------------------------------------------------------- ofApp::~ofApp(){ //saveSettings("settings.xml"); } //-------------------------------------------------------------- void ofApp::setup() { loadSettings("settings.xml"); ofBackground(0,0,0); ///ofSetVerticalSync(true); //some model / light stuff /* glShadeModel (GL_SMOOTH); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable (GL_COLOR_MATERIAL); ofDisableLighting(); //ofSetGlobalAmbientColor(ofColor(255,255,255)); */ fullscreen=false; activeView=0; checkers=new ofImage[3]; checkers[0].loadImage("checker_blue.png"); checkers[1].loadImage("checker_green.png"); checkers[2].loadImage("checker_red.png"); int bufferSize= beat.getBufferSize(); //should be based on the size of glitch buffer soundStream.listDevices(); //nb all you have to do to make audio work is to turn off pulseaudio in configuration soundStream.setup(this, 0, 1, 44100, bufferSize, 4); samples.resize(bufferSize); glitch1.setup(512,384,&samples); glitch2.setup(512,384,&samples); glitch3.setup(512,384,&samples); mode=MODE_RUN; kick=snare=hihat=false; } //-------------------------------------------------------------- void ofApp::update() { ofSetWindowTitle(ofToString(ofGetFrameRate())); if (mode==MODE_RUN){ beat.update(ofGetElapsedTimeMillis()); //if (ofRandom(10000)<3) glitch1.set_interp(ofRandom(18)+2,ofRandom(14)+2); //if (ofRandom(10000)<8) glitch2.set_interp(ofRandom(18)+2,ofRandom(14)+2); //if (ofRandom(10000)<20) glitch3.set_interp(ofRandom(18)+2,ofRandom(14)+2); if (beat.kick()>0.9){ if (!kick){ int which=ofRandom(3); switch (which) { case 0: glitch1.set_interp(ofRandom(18)+2,ofRandom(14)+2); break; case 1: glitch2.set_interp(ofRandom(18)+2,ofRandom(14)+2); break; case 2: glitch3.set_interp(ofRandom(18)+2,ofRandom(14)+2); break; } kick=true; } } else { if (kick) kick=false; } if (beat.snare()>0.9){ if (!snare){ int which=ofRandom(3); switch (which) { case 0: glitch1.set_scale((ofRandom(100)*.002)+1.0); break; case 1: glitch2.set_scale((ofRandom(100)*.002)+1.0); break; case 2: glitch3.set_scale((ofRandom(100)*.002)+1.0); break; } snare=true; } } else { if (snare) snare=false; } glitch1.update(); glitch2.update(); glitch3.update(); } } void ofApp::audioIn(float * input, int bufferSize, int nChannels){ for (int i=0;ikeys; XML.getAttributeNames("settings", keys, 0); mapsettings; for (int k=0;kkeys; XML.getAttributeNames("settings", keys, 0); for (int k=0;k