summaryrefslogtreecommitdiff
path: root/06_performance/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-06-28 23:32:10 +0100
committerComment <tim@gray.(none)>2013-06-28 23:32:10 +0100
commit1a7e15a63d78a6351028d977b90052f6b0d6bf7d (patch)
tree8345507e9c4dd871cd08eb884fe8b9fe2816137d /06_performance/src
parentfd8dc2aa23c4bbc297e835e4f920aaf5342aba5e (diff)
first performance version
Diffstat (limited to '06_performance/src')
-rw-r--r--06_performance/src/main.cpp4
-rw-r--r--06_performance/src/oni.cpp38
-rw-r--r--06_performance/src/oni.h9
-rw-r--r--06_performance/src/testApp.cpp176
-rw-r--r--06_performance/src/testApp.h1
5 files changed, 181 insertions, 47 deletions
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;i<players.size();i++) {
- players[i]->update();
+ 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 "<<i<<" video clips"<<endl;
}
@@ -189,9 +210,15 @@ void testApp::setup(){
xOffs=startX=yOffs=startY=0;
xModel=0;
+<<<<<<< HEAD
+ yModel=-25;
+ zModel=-1050;
+ sModel=3.5f;
+=======
yModel=0;
zModel=-550;
sModel=4.0f;
+>>>>>>> fd8dc2aa23c4bbc297e835e4f920aaf5342aba5e
};
@@ -206,36 +233,59 @@ void testApp::update(){
ofxOscMessage m;
receiver.getNextMessage(&m);
+
+ ///mrmr/pushbutton/6/Pauls-iPad 1000
vector<string> path;
explode(m.getAddress(),'/', back_inserter(path));
-
+ cerr<<"OSC: "<<m.getAddress()<<endl;
if (path.size()>1) {
- string type=path[1];
- int channel=ofToInt(path[2])-1;
- int data=m.getArgAsInt32(0);
-
- cerr<<"type: "<<type<<" channel: "<<channel<<" data: "<<m.getArgAsInt32(0)<<endl;
-
- if (type=="video"){
- if ((channel > -1)&&videoclips.size()>channel) {
- if (data>0) {
- cerr<<"playing video "<<channel<<endl;
- videoclips[channel].play();
- }
- }
- }
- if (type=="narrator"){
- if ((channel > -1)&&narrator.getNumClips()>channel) {
- if (data>0) {
- cerr<<"playing narrator "<<channel<<endl;
- narrator.startPlayer(channel);
+ if (path[1]=="mrmr"){
+ if (path.size()>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<videoclips.size();i++) {
+ // videoclips[i].stop();
+ // videoclips[i].setPosition(0.01f);
+ //}
+ videoclips[channel].setPosition(0.0f);
+ videoclips[channel].setSpeed(1.0f);
+ }
}
}
}
+ else {
+ string type=path[1];
+ if (type=="narrator"||type=="video") {
+ int channel=ofToInt(path[2])-1;
+ int data=m.getArgAsInt32(0);
+
+ cerr<<"type: "<<type<<" channel: "<<channel<<" data: "<<data<<endl;
+
+ if (type=="video"){
+ if ((channel > -1)&&videoclips.size()>channel) {
+ if (data>0) {
+ cerr<<"playing video "<<channel<<endl;
+ videoclips[channel].setPosition(0.0f);
+ videoclips[channel].setSpeed(1.0f);
+ }
+ }
+ }
+ if (type=="narrator"){
+ if ((channel > -1)&&narrator.getNumClips()>channel) {
+ if (data>0) { //???doesn't seem to work
+ cerr<<"playing narrator "<<channel<<endl;
+ narrator.startPlayer(channel);
+ }
+ }
+ }
+ }
+ }
}
}
@@ -265,8 +315,13 @@ void testApp::update(){
//blendImage.idleMovie();
for (int i=0;i<videoclips.size();i++) {
+<<<<<<< HEAD
+ if (videoclips[i].getSpeed()>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;i<videoclips.size();i++) {
+<<<<<<< HEAD
+ if (videoclips[i].getSpeed()>0.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<<endl;
- if (videoclips.size()>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;i<videoclips.size();i++) {
- if (videoclips[i].isPlaying()) {
+ if (videoclips[i].getSpeed()>0.0f) {
cerr<<"videoclip "<<i<<" is playing"<<endl;
}
}
@@ -762,10 +849,10 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
case 176: //control change 1-8 x 4 banks
switch(eventArgs.byteOne) {
case 1:
- F_scale = ((float)eventArgs.byteTwo)*.2;
+ F_scale = ((float)eventArgs.byteTwo)*.25;
break;
case 2:
- F_lineWidth=(float)eventArgs.byteTwo*0.1;
+ F_particleSize=(float)eventArgs.byteTwo*0.25;
break;
case 3:
F_drawAxis=((float) eventArgs.byteTwo-64)*(360.0/127);
@@ -914,7 +1001,8 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
F_drawStep=(((float) eventArgs.byteTwo)-64)*.1;
break;
case 85:
- F_movieSpeed=((float)eventArgs.byteTwo)/64.0;
+ //F_movieSpeed=((float)eventArgs.byteTwo)/64.0;
+ F_lineWidth=((float)eventArgs.byteTwo)/8.0;
break;
case 86:
F_drawDecay=((float)eventArgs.byteTwo)/127.0;
@@ -934,9 +1022,9 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
midiOut.sendControlChange(1, 91, 0);
break;
case 92: //front
- F_xRotation=0;
- F_yRotation=180;
- F_zRotation=0;
+ F_xRotation=180;
+ F_yRotation=180; //was 180
+ F_zRotation=0;
midiOut.sendControlChange(1, 92, 0);
break;
@@ -956,7 +1044,7 @@ void testApp::setMidiState(){
for (int i=0;i<8;i++) faders[i]=0;
knobs[0] = (F_scale * 5);
- knobs[1]=(F_lineWidth*10);
+ knobs[1]=(F_particleSize*4);
knobs[2]=(F_drawAxis/(360.0/127))+64;
knobs[3]=F_particleAmount/(10000.0f/127);
@@ -987,7 +1075,7 @@ void testApp::setMidiState(){
faders[1]=(F_yRotate*10)+64;
faders[2]=(F_zRotate*10)+64;
faders[3]=(F_drawStep*10)+64;
- faders[4]=F_movieSpeed*127;
+ faders[4]=F_lineWidth*8;
faders[5]=(F_drawDecay*127);
diff --git a/06_performance/src/testApp.h b/06_performance/src/testApp.h
index 5174e29..aec2a73 100644
--- a/06_performance/src/testApp.h
+++ b/06_performance/src/testApp.h
@@ -159,6 +159,7 @@ class testApp : public ofBaseApp, public ofxMidiListener{
float F_particleAmount;
float F_particleLife;
+ float F_particleSize;
float F_particleX;
float F_particleY;
float F_particleZ;