summaryrefslogtreecommitdiff
path: root/04_playobjects
diff options
context:
space:
mode:
Diffstat (limited to '04_playobjects')
-rw-r--r--04_playobjects/src/testApp.cpp69
-rw-r--r--04_playobjects/src/testApp.h12
2 files changed, 14 insertions, 67 deletions
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;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));
if (numDevices>1) 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;i<players.size();i++) {
players[i]=new ofxOpenNI();
- players[i]->setSafeThreading(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;i<players.size();i++) {
if (players[i]!=NULL) {
players[i]->stop();
@@ -71,6 +78,7 @@ class syncOniPlayer{
private:
vector<ofxOpenNI*> players;
vector<string> filenames;
+ ofSoundPlayer soundplayer;
};