From 1082e9eed74507b6eb5a3d0d7ab8a6cdecf40e19 Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 2 Mar 2014 22:14:34 +0000 Subject: working version for show --- basedProject/addons.make | 1 + basedProject/bin/data/checker_blue.png | Bin 0 -> 2425 bytes basedProject/bin/data/checker_green.png | Bin 0 -> 2790 bytes basedProject/bin/data/checker_red.png | Bin 0 -> 2426 bytes basedProject/bin/data/settings.xml | 6 +- basedProject/bin/data/settings_night2.xml | 12 ++ basedProject/bin/data/settings_opening_night.xml | 12 ++ basedProject/bin/data/settings_stage1.xml | 12 ++ basedProject/bin/data/settings_starting.xml | 12 ++ basedProject/src/audioGlitcher.h | 2 +- basedProject/src/ofApp.cpp | 142 ++++++++++++++++++----- basedProject/src/ofApp.h | 15 ++- basedProject/src/viewpoint.cpp | 4 +- glitcher/src/audioGlitcher.h | 56 +++++++-- glitcher/src/ofApp.cpp | 2 +- 15 files changed, 229 insertions(+), 47 deletions(-) create mode 100644 basedProject/bin/data/checker_blue.png create mode 100644 basedProject/bin/data/checker_green.png create mode 100644 basedProject/bin/data/checker_red.png create mode 100644 basedProject/bin/data/settings_night2.xml create mode 100644 basedProject/bin/data/settings_opening_night.xml create mode 100644 basedProject/bin/data/settings_stage1.xml create mode 100644 basedProject/bin/data/settings_starting.xml diff --git a/basedProject/addons.make b/basedProject/addons.make index 936ebc8..ff39ca1 100644 --- a/basedProject/addons.make +++ b/basedProject/addons.make @@ -1,2 +1,3 @@ ofxXmlSettings ofxOpenCv +ofxBeat diff --git a/basedProject/bin/data/checker_blue.png b/basedProject/bin/data/checker_blue.png new file mode 100644 index 0000000..0cbfb9c Binary files /dev/null and b/basedProject/bin/data/checker_blue.png differ diff --git a/basedProject/bin/data/checker_green.png b/basedProject/bin/data/checker_green.png new file mode 100644 index 0000000..d1490bb Binary files /dev/null and b/basedProject/bin/data/checker_green.png differ diff --git a/basedProject/bin/data/checker_red.png b/basedProject/bin/data/checker_red.png new file mode 100644 index 0000000..089c3da Binary files /dev/null and b/basedProject/bin/data/checker_red.png differ diff --git a/basedProject/bin/data/settings.xml b/basedProject/bin/data/settings.xml index 57d3f12..8ba6a68 100644 --- a/basedProject/bin/data/settings.xml +++ b/basedProject/bin/data/settings.xml @@ -1,12 +1,12 @@ - + - + - + diff --git a/basedProject/bin/data/settings_night2.xml b/basedProject/bin/data/settings_night2.xml new file mode 100644 index 0000000..6a49cac --- /dev/null +++ b/basedProject/bin/data/settings_night2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/basedProject/bin/data/settings_opening_night.xml b/basedProject/bin/data/settings_opening_night.xml new file mode 100644 index 0000000..188d1f9 --- /dev/null +++ b/basedProject/bin/data/settings_opening_night.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/basedProject/bin/data/settings_stage1.xml b/basedProject/bin/data/settings_stage1.xml new file mode 100644 index 0000000..c0b0e75 --- /dev/null +++ b/basedProject/bin/data/settings_stage1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/basedProject/bin/data/settings_starting.xml b/basedProject/bin/data/settings_starting.xml new file mode 100644 index 0000000..68db24d --- /dev/null +++ b/basedProject/bin/data/settings_starting.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/basedProject/src/audioGlitcher.h b/basedProject/src/audioGlitcher.h index 8f48288..130abcf 100644 --- a/basedProject/src/audioGlitcher.h +++ b/basedProject/src/audioGlitcher.h @@ -68,7 +68,7 @@ class audioGlitcher { //transform the low res matrix float tX=trans_x-.05; //fraction of image - float tY=trans_y-.04; //fraction of image + float tY=trans_y-.08; //fraction of image float oX=origin_x; //fraction of image float oY=origin_y; //fraction of image float s=scale; diff --git a/basedProject/src/ofApp.cpp b/basedProject/src/ofApp.cpp index 1b2a074..86c50a7 100644 --- a/basedProject/src/ofApp.cpp +++ b/basedProject/src/ofApp.cpp @@ -1,7 +1,7 @@ #include "ofApp.h" //-------------------------------------------------------------- ofApp::~ofApp(){ - saveSettings("settings.xml"); + //saveSettings("settings.xml"); } //-------------------------------------------------------------- @@ -12,9 +12,11 @@ void ofApp::setup() { ///ofSetVerticalSync(true); + + //some model / light stuff /* - glEnable (GL_DEPTH_TEST); + glShadeModel (GL_SMOOTH); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable (GL_COLOR_MATERIAL); @@ -26,30 +28,95 @@ void ofApp::setup() { fullscreen=false; activeView=0; - xhair.loadImage("crosshairs.png"); + checkers=new ofImage[3]; + + checkers[0].loadImage("checker_blue.png"); + checkers[1].loadImage("checker_green.png"); + checkers[2].loadImage("checker_red.png"); - int bufferSize= 512; //should be based on the size of glitch buffer + 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, 1); + soundStream.setup(this, 0, 1, 44100, bufferSize, 4); + samples.resize(bufferSize); - glitch.setup(512,384,&samples); - glitch.set_interp(ofRandom(30)+2,ofRandom(22)+2); + 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())); - glitch.update(); + 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;i': - //nextMovie(); + case OF_KEY_RIGHT: + mode=(mode+1)%NUM_MODES; break; case '/': //light=!light; //printf(light?"LIGHT ON\n":"LIGHT OFF\n"); break; } + if (mode==MODE_RUN) glDisable (GL_DEPTH_TEST); + else glEnable (GL_DEPTH_TEST); } void ofApp::keyReleased(int key){ diff --git a/basedProject/src/ofApp.h b/basedProject/src/ofApp.h index 3e45838..f1ab52a 100644 --- a/basedProject/src/ofApp.h +++ b/basedProject/src/ofApp.h @@ -30,12 +30,17 @@ have to track how many frames each key has been pressed for #include "ofEvents.h" #include "ofxXmlSettings.h" //#include "ofx3DModelLoader.h" +#include "ofxBeat.h" #include "mapUtils.h" #include "viewpoint.h" #include "audioGlitcher.h" +#define NUM_MODES 2 +#define MODE_RUN 0 +#define MODE_CALIB 1 + class ofApp : public ofBaseApp{ @@ -57,13 +62,19 @@ class ofApp : public ofBaseApp{ int activeView; bool fullscreen; - ofImage xhair; + ofImage *checkers; void audioIn(float * input, int bufferSize, int nChannels); - audioGlitcher glitch; + audioGlitcher glitch1; + audioGlitcher glitch2; + audioGlitcher glitch3; ofSoundStream soundStream; vector samples; + int mode; + + ofxBeat beat; + bool kick,snare,hihat; }; diff --git a/basedProject/src/viewpoint.cpp b/basedProject/src/viewpoint.cpp index 85a3bf5..15424ed 100644 --- a/basedProject/src/viewpoint.cpp +++ b/basedProject/src/viewpoint.cpp @@ -57,9 +57,11 @@ void viewpoint::setLight(){ ofNode c=ofNode(); ofNode t=ofNode(); t.setParent(c); - t.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal()); + //make target controls relative to rotation c.rotate(vars[5].getVal(), ofVec3f(0, 1, 0)); + //changed order 27021 + t.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal()); target.setPosition(t.getGlobalPosition()); //camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target); diff --git a/glitcher/src/audioGlitcher.h b/glitcher/src/audioGlitcher.h index 8f48288..356314b 100644 --- a/glitcher/src/audioGlitcher.h +++ b/glitcher/src/audioGlitcher.h @@ -57,18 +57,29 @@ class audioGlitcher { cv::Mat srcX(interp_x,interp_y,CV_32FC1); cv::Mat srcY(interp_x,interp_y,CV_32FC1); - float xFactor=renderFBO.getWidth()/srcX.cols; - float yFactor=renderFBO.getHeight()/srcX.rows; + //for a sanity check + //512-1 / 16-1 = 34.066666667 + //* 15= + + float* sx = (float*)srcX.data; + float* sy = (float*)srcY.data; + float* dx = (float*)dstX.data; + float* dy = (float*)dstY.data; + + float xFactor=(renderFBO.getWidth()-1)/(srcX.cols-1); + float yFactor=(renderFBO.getHeight()-1)/(srcX.rows-1); for (int i=0;i(j,i)=i*xFactor; - srcY.at(j,i)=j*yFactor; + //srcX.at(j,i)=i*xFactor; + //srcY.at(j,i)=j*yFactor; + sx[i,j]=i*xFactor; + sy[i,j]=j*yFactor; } } //transform the low res matrix - float tX=trans_x-.05; //fraction of image - float tY=trans_y-.04; //fraction of image + float tX=trans_x; //-.05; //fraction of image + float tY=trans_y; //-.08; //fraction of image float oX=origin_x; //fraction of image float oY=origin_y; //fraction of image float s=scale; @@ -117,10 +128,41 @@ class audioGlitcher { cv::resize(dstX,scaledstX, cv::Size(renderFBO.getWidth(),renderFBO.getHeight()), 0, 0, cv::INTER_LINEAR); cv::resize(dstY,scaledstY, cv::Size(renderFBO.getWidth(),renderFBO.getHeight()), 0, 0, cv::INTER_LINEAR); + + + + + + for (int i=0;i(j,i)=i; + //scaledstY.at(j,i)=j; + } + } + + float* psx = (float*)scaledstX.data; + float* psy = (float*)scaledstY.data; + + cerr<<"src: <0,0> "< "< "< "< "< "< "<