From 64a6e2cefebfe5f6d767f709ad8ca60362f47c0f Mon Sep 17 00:00:00 2001 From: Comment Date: Mon, 17 Jun 2013 22:54:00 +0100 Subject: audio edited and synced --- 04_playobjects/src/testApp.cpp | 69 +++--------------------------------------- 04_playobjects/src/testApp.h | 12 ++++++-- 2 files changed, 14 insertions(+), 67 deletions(-) (limited to '04_playobjects') diff --git a/04_playobjects/src/testApp.cpp b/04_playobjects/src/testApp.cpp index dac7306..360d0b0 100644 --- a/04_playobjects/src/testApp.cpp +++ b/04_playobjects/src/testApp.cpp @@ -7,7 +7,7 @@ void testApp::setup() { verdana.loadFont(ofToDataPath("verdana.ttf"), 10); - playing=0; + playing=-1; numDevices=1; string filename="TRSS_nesbitt_recordings.xml"; @@ -19,13 +19,6 @@ void testApp::setup() { int num=XML.getNumTags("rec"); if(num) { for (int i=0;i1) players[i].addPlayer(XML.getAttribute("rec","right","",i)); @@ -35,49 +28,21 @@ void testApp::setup() { 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].stop(); + if (playing>-1) players[playing].stop(); + soundplayer.stop(); + usleep(100000); 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(); } @@ -90,15 +55,6 @@ void testApp::draw(){ 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); @@ -134,23 +90,6 @@ void testApp::keyPressed(int key){ 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; - } - */ } //-------------------------------------------------------------- diff --git a/04_playobjects/src/testApp.h b/04_playobjects/src/testApp.h index a89c2f1..5bbb0c2 100644 --- a/04_playobjects/src/testApp.h +++ b/04_playobjects/src/testApp.h @@ -12,7 +12,7 @@ struct record{ string audio; }; -//in order to play diffferent clips it seems necessary to have a player per clip +//in order to play different clips it seems necessary to have a player per clip class syncOniPlayer{ public: ~syncOniPlayer(){ @@ -25,6 +25,7 @@ class syncOniPlayer{ //players.push_back(o); players.push_back(NULL); filenames.push_back(name); + soundplayer.setLoop(false); //players[players.size()-1]->setSpeed(0.0f); //players[players.size()-1]->setup(true); //players[players.size()-1]->start(); @@ -33,10 +34,15 @@ class syncOniPlayer{ void play(){ for (int i=0;isetSafeThreading(true); + //players[i]->setSafeThreading(true); players[i]->setupFromONI(filenames[i],true); + players[i]->setLooped(false); players[i]->start(); //players[players.size()-1]->setSpeed(1.0f); + if (audio!="") { + soundplayer.loadSound(audio); + soundplayer.play(); + } } } void update(){ @@ -58,6 +64,7 @@ class syncOniPlayer{ } } void stop(){ + soundplayer.stop(); for (int i=0;istop(); @@ -71,6 +78,7 @@ class syncOniPlayer{ private: vector players; vector filenames; + ofSoundPlayer soundplayer; }; -- cgit v1.2.3