From 1a7e15a63d78a6351028d977b90052f6b0d6bf7d Mon Sep 17 00:00:00 2001 From: Comment Date: Fri, 28 Jun 2013 23:32:10 +0100 Subject: first performance version --- 06_performance/src/main.cpp | 4 + 06_performance/src/oni.cpp | 38 ++++++++- 06_performance/src/oni.h | 9 +++ 06_performance/src/testApp.cpp | 176 ++++++++++++++++++++++++++++++----------- 06_performance/src/testApp.h | 1 + 5 files changed, 181 insertions(+), 47 deletions(-) (limited to '06_performance') diff --git a/06_performance/src/main.cpp b/06_performance/src/main.cpp index 733d488..464bd9d 100644 --- a/06_performance/src/main.cpp +++ b/06_performance/src/main.cpp @@ -5,7 +5,11 @@ int main( ){ //ofSetupOpenGL(4080,768, OF_WINDOW); // <-------- setup the GL context +<<<<<<< HEAD + ofSetupOpenGL(2400,450, OF_WINDOW); // <-------- setup the GL context +======= ofSetupOpenGL(1400,262, OF_WINDOW); // <-------- setup the GL context +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e diff --git a/06_performance/src/oni.cpp b/06_performance/src/oni.cpp index 9d432d8..f4544a9 100644 --- a/06_performance/src/oni.cpp +++ b/06_performance/src/oni.cpp @@ -18,6 +18,7 @@ void syncOniPlayer::play(){ players[i]=new ofxOpenNI(); //players[i]->setSafeThreading(true); players[i]->setupFromONI(filenames[i],true); + //players[i]->setSafeThreading(true); //players[i]->addDepthGenerator(); //players[i]->addImageGenerator(); //players[i]->setRegister(true); @@ -37,7 +38,7 @@ void syncOniPlayer::play(){ } void syncOniPlayer::update(){ for (int i=0;iupdate(); + if (playerActive) players[i]->update(); } } void syncOniPlayer::pause(){ @@ -47,7 +48,11 @@ void syncOniPlayer::pause(){ } } bool syncOniPlayer::isPlaying(){ +<<<<<<< HEAD + if (players.size()&&playerActive) return players[0]->isPlaying(); +======= if (players.size()) return players[0]->isPlaying(); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e else return false; } int syncOniPlayer::getCurrentFrame(){ @@ -112,14 +117,23 @@ void syncOniPlayer::drawPoints(float _birth,float life,float dx,float dy, float //glEnable(GL_PROGRAM_POINT_SIZE); //glEnable(GL_POINT_SMOOTH); //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); +<<<<<<< HEAD + //glEnable( GL_BLEND ); + //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +======= glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e //glPointSize( size); //glBegin(GL_POINTS); if (playerActive){ //apply envelope +<<<<<<< HEAD + float attackSeconds=0.5f; +======= float attackSeconds=2.0f; +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e float playOutFraction=0.9f; float birth; float clipTime=ofGetElapsedTimef()-startTime; @@ -172,11 +186,21 @@ void syncOniPlayer::drawPoints(float _birth,float life,float dx,float dy, float } } //glEnd(); +<<<<<<< HEAD + //glDisable( GL_BLEND ); +======= glDisable( GL_BLEND ); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e //glDisable(GL_PROGRAM_POINT_SIZE); } int syncOniPlayer::getNumParticles(){ return points.size()-pointPool.size(); +<<<<<<< HEAD +} +string syncOniPlayer::getCurrentFile(){ + return filenames[0]+" "+audio; +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e } void syncOniPlayer::stop(){ soundplayer.stop(); @@ -217,11 +241,19 @@ void oniManager::init(const char* filename){ void oniManager::startPlayer(int newplayer){ if (players.size()>newplayer){ if (playing>-1) players[playing].stop(); +<<<<<<< HEAD + usleep(10000); +======= //usleep(500000); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e playing=newplayer; players[playing].play(); } } +string oniManager::getCurrentFile(){ + if (players.size()>playing&&playing>-1) return players[playing].getCurrentFile(); + else return ""; +} int oniManager::getNumClips(){ return players.size(); } @@ -235,11 +267,11 @@ void oniManager::drawWindows(){ void oniManager::drawCloud(int step){ if (players.size()>playing&&playing>-1) players[playing].drawCloud(step); } -void oniManager::previous(){ +void oniManager::next(){ int newp=(playing+1)%players.size(); startPlayer(newp); } -void oniManager::next(){ +void oniManager::previous(){ int newp=playing-1<0?players.size()-1:playing-1; startPlayer(newp); } diff --git a/06_performance/src/oni.h b/06_performance/src/oni.h index 821dba7..305d8f1 100644 --- a/06_performance/src/oni.h +++ b/06_performance/src/oni.h @@ -43,6 +43,10 @@ class syncOniPlayer{ LUT=NULL; makeLUT(); playerActive=false; +<<<<<<< HEAD + points.reserve(100000); //operator new seems to be causing crshes? +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e } ~syncOniPlayer(){ stop(); @@ -64,6 +68,7 @@ class syncOniPlayer{ int getCurrentFrame(); float getPosition(); int getNumParticles(); + string getCurrentFile(); void drawWindows(); void drawCloud(int step); void drawPoints(float birth,float life,float dx,float dy, float dz,float size); @@ -90,6 +95,10 @@ class oniManager{ int getNumClips(); int getNumParticles(); syncOniPlayer* getCurrentPlayer(); +<<<<<<< HEAD + string getCurrentFile(); +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e void update(); void drawWindows(); void drawCloud(int step); diff --git a/06_performance/src/testApp.cpp b/06_performance/src/testApp.cpp index e1f6d71..0c1f4bb 100644 --- a/06_performance/src/testApp.cpp +++ b/06_performance/src/testApp.cpp @@ -34,7 +34,7 @@ void testApp::setup(){ left = new float[BUFFER_SIZE]; right = new float[BUFFER_SIZE]; - //soundStream.setDeviceID(0); + //soundStream.setDeviceID(7); //ignore to use default? soundStream.setup(this, 0, 2, 44100, BUFFER_SIZE, 4); //soundStream.setup(this, 0, 4, 44100, BUFFER_SIZE, 4); @@ -54,6 +54,10 @@ void testApp::setup(){ rFFTanalyzer.linearEQIntercept = 0.9f; // reduced gain at lowest frequency rFFTanalyzer.linearEQSlope = 0.01f; // increasing gain at higher frequencies +<<<<<<< HEAD +/* +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e if (4chan) { lFFTanalyzer2.setup(44100, BUFFER_SIZE/2,32); @@ -70,6 +74,10 @@ void testApp::setup(){ rFFTanalyzer2.linearEQIntercept = 0.9f; // reduced gain at lowest frequency rFFTanalyzer2.linearEQSlope = 0.01f; // increasing gain at higher frequencies } +<<<<<<< HEAD + */ +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e ofSetFrameRate(60); @@ -106,7 +114,11 @@ void testApp::setup(){ F_drawFrames=10; F_drawStep=0; F_drawDecay=0.95; +<<<<<<< HEAD + F_lineWidth=1.0; //1.0; +======= F_lineWidth=16.0; //1.0; +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e F_drawAxis=90; //Y @@ -120,6 +132,10 @@ void testApp::setup(){ F_particleAmount=2000; //100 F_particleLife=0.75; //0.5 +<<<<<<< HEAD + F_particleSize=16.0; //1.0; +======= +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e I_fade1=0; I_fade2=0; @@ -153,8 +169,8 @@ void testApp::setup(){ B_glitch=false; - blanker.allocate(64,64,OF_IMAGE_COLOR); - // blanker.loadImage("black.png"); + //blanker.allocate(64,64,OF_IMAGE_COLOR); + blanker.loadImage("black.png"); fullScreen=false; @@ -179,7 +195,12 @@ void testApp::setup(){ videoclips.push_back(ofVideoPlayer()); videoclips[i].loadMovie(XML.getAttribute("video","file","",i)); videoclips[i].setLoopState(OF_LOOP_NONE); +<<<<<<< HEAD + videoclips[i].play(); + videoclips[i].setSpeed(0.0f); +======= videoclips[i].stop(); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e } cerr<<"loaded "<>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e }; @@ -206,36 +233,59 @@ void testApp::update(){ ofxOscMessage m; receiver.getNextMessage(&m); + + ///mrmr/pushbutton/6/Pauls-iPad 1000 vector path; explode(m.getAddress(),'/', back_inserter(path)); - + cerr<<"OSC: "<1) { - string type=path[1]; - int channel=ofToInt(path[2])-1; - int data=m.getArgAsInt32(0); - - cerr<<"type: "< -1)&&videoclips.size()>channel) { - if (data>0) { - cerr<<"playing video "< -1)&&narrator.getNumClips()>channel) { - if (data>0) { - cerr<<"playing narrator "<3){ + if (path[2]=="pushbutton"){ + int channel=ofToInt(path[3]); + if (channel>12) channel--; //12 is missing + if (m.getArgAsInt32(0)==1000) { + //for (int i=0;i -1)&&videoclips.size()>channel) { + if (data>0) { + cerr<<"playing video "< -1)&&narrator.getNumClips()>channel) { + if (data>0) { //???doesn't seem to work + cerr<<"playing narrator "<0.0f) videoclips[i].update(); + if (videoclips[i].getPosition()>0.99f) videoclips[i].setSpeed(0.0f); +======= videoclips[i].update(); if (videoclips[i].getPosition()>0.99f) videoclips[i].stop(); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e } narrator.update(); @@ -335,10 +390,13 @@ void testApp::draw(){ if (B_glitch) { - //glEnable(GL_BLEND); - //glBlendFunc(GL_CONSTANT_COLOR,GL_ONE); - //glBlendColor(1.0f,1.0f,1.0f,0.9f); - //blanker.draw(0,0,ofGetWidth(),ofGetHeight()); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + //glBlendColor(1.0f,1.0f,1.0f,((float)I_fade2)/255.0f); + ofSetColor(255,255,255,I_fade2); + blanker.draw(0,0,renderImage.getWidth(),renderImage.getHeight()); + glDisable(GL_BLEND); + } else { glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); @@ -374,8 +432,8 @@ void testApp::draw(){ glFogfv(GL_FOG_COLOR, fogColor); glFogf(GL_FOG_DENSITY,1.0 ); glHint(GL_FOG_HINT, GL_DONT_CARE); - glFogf(GL_FOG_START, ofGetWidth()*(0.25+F_drawDecay)); - glFogf(GL_FOG_END, ofGetWidth()*(0.75+F_drawDecay)); + glFogf(GL_FOG_START, ofGetHeight()*(0.1+(F_drawDecay*5))); + glFogf(GL_FOG_END, ofGetHeight()*(0.5+(F_drawDecay*5))); glEnable(GL_FOG); //reverse draw order when looking from back @@ -411,11 +469,11 @@ void testApp::draw(){ if (B_fill) { glBegin(GL_QUAD_STRIP); for (int i = 0; i < lFFTanalyzer.nAverages-1; i++){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,(FFTbuffer[0][i][fB] * F_scale),0); glVertex3f((i*xStep)-hw,0,0); } for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); glVertex3f((i*xStep)-hw,0,0); } glEnd(); @@ -426,10 +484,10 @@ void testApp::draw(){ ofSetColor(I_fade1,I_fade1,I_fade1); glBegin(GL_LINE_STRIP); for (int i = 0; i < lFFTanalyzer.nAverages; i++){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,(FFTbuffer[0][i][fB] * F_scale),0); } for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); } glEnd(); ofPopMatrix(); @@ -439,7 +497,11 @@ void testApp::draw(){ ofPopMatrix(); for (int i=0;i0.0f) { +======= if (videoclips[i].isPlaying()) { +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e if (videoclips[i].getPosition()<0.1f) { glEnable(GL_BLEND); uint8_t b=uint8_t((videoclips[i].getPosition()/0.1f)*255); @@ -456,6 +518,17 @@ void testApp::draw(){ glDisable(GL_BLEND); } } +<<<<<<< HEAD + + ofPushMatrix(); + //ofTranslate(hw,hh); + camera.begin(); + ofRotateX(F_xRotation); + ofRotateY(F_yRotation); + ofRotateZ(F_zRotation); + + ofPushMatrix(); +======= ofPushMatrix(); //ofTranslate(hw,hh); @@ -465,13 +538,14 @@ void testApp::draw(){ ofRotateZ(F_zRotation); ofPushMatrix(); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e //ofTranslate(0,-100,-1050); ofScale(sModel,sModel,sModel); //ofTranslate(xModel*sModel,yModel*sModel,zModel*sModel); ofTranslate(xModel,yModel,zModel); //narrator.drawCloud(2); - narrator.drawPoints(F_lineWidth,F_particleAmount,F_particleLife,F_particleX,F_particleY,F_particleZ); + narrator.drawPoints(F_particleSize,F_particleAmount,F_particleLife,F_particleX,F_particleY,F_particleZ); ofPopMatrix(); ofSetColor(255,255,255); @@ -610,7 +684,14 @@ void testApp::draw(){ msg+="\n"+ofToString(narrator.getNumParticles())+" size "+ofToString(F_lineWidth); msg+="\n"+ofToString(xModel)+","+ofToString(yModel)+","+ofToString(zModel)+" * "+ofToString(sModel); syncOniPlayer *player=narrator.getCurrentPlayer(); +<<<<<<< HEAD + if (player) { + msg+="\n"+ofToString(player->getCurrentFrame())+","+ofToString(player->getPosition(),2); + msg+=player->getCurrentFile(); + } +======= if (player) msg+="\n"+ofToString(player->getCurrentFrame())+","+ofToString(player->getPosition(),2); +>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e ofDrawBitmapString(msg,20,20); } } @@ -625,6 +706,9 @@ void testApp::keyPressed (int key){ fullScreen=!fullScreen; ofSetFullscreen(fullScreen); } + if(key == '/'){ + narrator.startPlayer(23); + } if(key == ','){ narrator.previous(); } @@ -634,11 +718,14 @@ void testApp::keyPressed (int key){ if(key>='1'&key<='9'){ int clip=key-'1'; cerr<<"playing video clip "<clip) videoclips[clip].play(); + if (videoclips.size()>clip) { + videoclips[clip].setPosition(0.0f); + videoclips[clip].setSpeed(1.0f); + } } if(key == 't'){ for (int i=0;i0.0f) { cerr<<"videoclip "<