diff options
Diffstat (limited to '04_playobjects/src/testApp.cpp')
| -rw-r--r-- | 04_playobjects/src/testApp.cpp | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/04_playobjects/src/testApp.cpp b/04_playobjects/src/testApp.cpp new file mode 100644 index 0000000..5683e1f --- /dev/null +++ b/04_playobjects/src/testApp.cpp @@ -0,0 +1,183 @@ +#include "testApp.h" + +//-------------------------------------------------------------- +void testApp::setup() { + + ofSetLogLevel(OF_LOG_NOTICE); + + verdana.loadFont(ofToDataPath("verdana.ttf"), 10); + + playing=0; + numDevices=2; + + string filename="test.xml"; //"TRSS_nesbitt_recordings.xml"; + + if( !XML.loadFile(filename) ){ + printf("unable to load recordings, check data/ folder\n"); + }else{ + if(XML.pushTag("TRSS")) { + int num=XML.getNumTags("rec"); + if(num) { + for (int i=0;i<num;i++) { + /* + syncOniPlayer p; + p.addPlayer(XML.getAttribute("rec","left","",i)); + p.addPlayer(XML.getAttribute("rec","right","",i)); + p.audio=XML.getAttribute("rec","audio","",i); + players.push_back(p); + */ + players.push_back(syncOniPlayer()); + players[i].addPlayer(XML.getAttribute("rec","left","",i)); + players[i].addPlayer(XML.getAttribute("rec","right","",i)); + players[i].audio=XML.getAttribute("rec","audio","",i); + } + } + else printf("no recordings found!\n"); + } + } + /* + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + + //openNIPlayers[deviceID].stop(); + openNIPlayers[deviceID].setup(true); + openNIPlayers[deviceID].start(); + //openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID])); + } + */ + soundplayer.setLoop(false); + startPlayers(0); + + //ofSetFrameRate(25.0f); + offset=0.0f; +} + +void testApp::startPlayers(int newplayer){ + players[playing].pause(); + playing=newplayer; + players[playing].play(); + //for (int deviceID = 0; deviceID < numDevices; deviceID++){ + //openNIPlayers[deviceID].stop(); + //openNIPlayers[deviceID].setup(true); + //openNIPlayers[deviceID].start(); + //openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing].data[deviceID])); + + soundplayer.stop(); + + if (players[playing].audio!=""){ + soundplayer.loadSound(players[playing].audio); + soundplayer.play(); + //mmsoundplayer.setPositionMS(offset); + } + //} +} + +//-------------------------------------------------------------- +void testApp::update(){ + /* + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIPlayers[deviceID].update(); + } + */ + players[playing].update(); +} + +//-------------------------------------------------------------- +void testApp::draw(){ + ofBackground(0, 0, 0); + ofSetColor(255, 255, 255); + + ofPushMatrix(); + + players[playing].draw(); + + /* + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + ofTranslate(0, deviceID * 400); + //openNIPlayers[deviceID].drawDebug(); + openNIPlayers[deviceID].drawDepth(50, 0,520,390); + openNIPlayers[deviceID].drawImage(600, 0,520,390); + } + */ + + ofPopMatrix(); + + ofSetColor(255, 255, 255); + string msg = "MILLIS: " + ofToString(ofGetElapsedTimeMillis()); + msg += "\nFPS: " + ofToString(ofGetFrameRate()); + msg += "\noffset: "+ofToString(offset); + verdana.drawString(msg, 10, 10); +} + +//-------------------------------------------------------------- +void testApp::exit(){ + +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key){ + int newplaying=playing; + switch (key) { + case ',': + newplaying=playing-1; + if (newplaying<0) newplaying=numDevices-1; + break; + case '.': + newplaying=(playing+1)%numDevices; + break; + case 'z': + offset-=1; + break; + case 'x': + offset+=1; + break; + } + if (newplaying!=playing) startPlayers(newplaying); + + /* why do this? + switch (key) { + case 't': + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].toggleRegister(); + } + break; + case 'x': + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].stop(); + } + break; + default: + break; + } + */ +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + |
