summaryrefslogtreecommitdiff
path: root/03_play/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-06-13 00:10:35 +0100
committerComment <tim@gray.(none)>2013-06-13 00:10:35 +0100
commit71582d96b78a52747c65c1aaf89d00e0a7d408a0 (patch)
treea48713749cf26f476f343b69641d187aebd3ad67 /03_play/src
parent08bd1788cc640f4f6595152cd27f1922bea7d76c (diff)
investigating sound sync
Diffstat (limited to '03_play/src')
-rw-r--r--03_play/src/main.cpp2
-rw-r--r--03_play/src/testApp.cpp55
-rw-r--r--03_play/src/testApp.h4
3 files changed, 44 insertions, 17 deletions
diff --git a/03_play/src/main.cpp b/03_play/src/main.cpp
index 87dc35f..f0d25bb 100644
--- a/03_play/src/main.cpp
+++ b/03_play/src/main.cpp
@@ -7,7 +7,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1600,900, OF_FULLSCREEN); // <-------- setup the GL context
+ ofSetupOpenGL(&window, 1200,800, OF_WINDOW); // <-------- setup the GL context
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
diff --git a/03_play/src/testApp.cpp b/03_play/src/testApp.cpp
index 74f0799..3670a8b 100644
--- a/03_play/src/testApp.cpp
+++ b/03_play/src/testApp.cpp
@@ -10,7 +10,9 @@ void testApp::setup() {
playing=0;
numDevices=2;
- if( !XML.loadFile("TRSS_nesbitt_recordings.xml") ){
+ string filename="TRSS_nesbitt_recordings.xml";
+
+ if( !XML.loadFile(filename) ){
printf("unable to load recordings, check data/ folder\n");
}else{
if(XML.pushTag("TRSS")) {
@@ -26,12 +28,28 @@ void testApp::setup() {
else printf("no recordings!\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.loadSound("02.wav");
+ startPlayers();
+ ofSetFrameRate(25.0f);
+}
+
+void testApp::startPlayers(){
for (int deviceID = 0; deviceID < numDevices; deviceID++){
- openNIPlayers[deviceID].setup(false);
- openNIPlayers[deviceID].start();
+ //openNIPlayers[deviceID].stop();
+ //openNIPlayers[deviceID].setup(false);
+ //openNIPlayers[deviceID].start();
openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID]));
+
+ soundplayer.setPosition(0.0f);
+ soundplayer.play();
}
}
@@ -50,17 +68,18 @@ void testApp::draw(){
ofPushMatrix();
for (int deviceID = 0; deviceID < numDevices; deviceID++){
- ofTranslate(0, deviceID * 450);
+ ofTranslate(0, deviceID * 400);
//openNIPlayers[deviceID].drawDebug();
- openNIPlayers[deviceID].drawDepth(200, 0,600,450);
- openNIPlayers[deviceID].drawImage(800, 0,600,450);
+ openNIPlayers[deviceID].drawDepth(50, 0,520,390);
+ openNIPlayers[deviceID].drawImage(600, 0,520,390);
}
ofPopMatrix();
ofSetColor(255, 255, 255);
- string msg = "MILLIS: " + ofToString(ofGetElapsedTimeMillis()) + "\nFPS: " + ofToString(ofGetFrameRate());
-
+ string msg = "MILLIS: " + ofToString(ofGetElapsedTimeMillis());
+ msg += "\nFPS: " + ofToString(ofGetFrameRate());
+ msg += "\nset: "+ofToString(playing);
verdana.drawString(msg, 10, 10);
}
@@ -73,21 +92,25 @@ void testApp::exit(){
//--------------------------------------------------------------
void testApp::keyPressed(int key){
+ bool changed=false;
switch (key) {
- case '.':
+ case ',':
if (playing==0) playing=recs.size();
playing--;
- for (int deviceID = 0; deviceID < numDevices; deviceID++){
- openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID]));
- }
+ changed=true;
break;
- case ',':
+ case '.':
playing=(playing+1)%recs.size();
- for (int deviceID = 0; deviceID < numDevices; deviceID++){
- openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID]));
- }
+ changed=true;
+ break;
+ case 'z':
+ soundplayer.setPosition(soundplayer.getPosition()-.04f);
+ break;
+ case 'x':
+ soundplayer.setPosition(soundplayer.getPosition()+.04f);
break;
}
+ if (changed) startPlayers();
/* why do this?
switch (key) {
diff --git a/03_play/src/testApp.h b/03_play/src/testApp.h
index db29f0c..a276a59 100644
--- a/03_play/src/testApp.h
+++ b/03_play/src/testApp.h
@@ -23,6 +23,8 @@ public:
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
+ void startPlayers();
+
int numDevices;
ofxOpenNI openNIPlayers[MAX_DEVICES];
@@ -35,6 +37,8 @@ public:
ofxXmlSettings XML;
vector<pair<string,string> > filenames;
+
+ ofSoundPlayer soundplayer;
};