void nebulaEye::csvRecordCb(bool & flag){ if ( flag ){ csvRecorder.clear(); ofResetElapsedTimeCounter(); stringstream ss; ss << ofGetYear(); ss << setfill('0') << setw(2) << ofGetMonth(); ss << setfill('0') << setw(2) << ofGetDay() << "-"; ss << setfill('0') << setw(2) << ofGetHours(); ss << setfill('0') << setw(2) << ofGetMinutes(); ss << setfill('0') << setw(2) << ofGetSeconds() << ".csv"; ofLog() << "try to create file : " << ss.str(); csvRecorder.filePath = ofToDataPath(ss.str()); ofLog() << "record CSV to : " << csvRecorder.filePath; int idx(0); csvRecorder.setString(0,idx++,"date"); csvRecorder.setString(0,idx++,"time"); csvRecorder.setString(0,idx++,"blob x"); csvRecorder.setString(0,idx++,"blob y"); csvRecorder.setString(0,idx++,"flow zone 0"); csvRecorder.setString(0,idx++,"flow zone 1"); csvRecorder.setString(0,idx++,"flow zone 2"); csvRecorder.setString(0,idx++,"flow zone 3"); } else { csvRecorder.saveFile(); // Save the recorded values in the csvRecorder ofxCsv object // csvRecorder.saveFile( ofToDataPath( csvFileName )); ofLog() << "Saved " << csvRecorder.numRows << " rows to " << csvRecorder.filePath; } }
//-------------------------------------------------------------- ofPoint particleManager::getRandomAttractorParticles(){ //Forum Try int frame_num = ofGetFrameNum(); int elapsedTime = ofGetElapsedTimef(); if(elapsedTime == 5){ random_one_neu = (int)ofRandom(ofGetWidth()); random_two_neu = guiManager::getInstance()->myParticlesYvalue*ofGetHeight(); //cout << "elapsedTime= " << elapsedTime << " random_one_neu = " << random_one_neu << " random_two_neu = " << random_two_neu << endl; ofResetElapsedTimeCounter(); random_one = random_one_neu; random_two = random_two_neu; } else{ random_one_neu = random_one; random_two_neu = random_two; //ofPoint attractPt(random_one_neu, random_two_neu); //cout << "elapsedTime= " << elapsedTime << " random_one_neu = " << random_one_neu << " random_two_neu = " << random_two_neu << endl; } return ofPoint(random_one_neu, random_two_neu); }
void Scene5::stateEnter(){ getSharedData().vidGrabber.setDeviceID(0); getSharedData().vidGrabber.setDesiredFrameRate(60); getSharedData().vidGrabber.initGrabber(camWidth,camHeight); ofResetElapsedTimeCounter(); }
Diamond Pigeon::shitDiamond() { canShit = false; ofResetElapsedTimeCounter(); Diamond newDiamond; newDiamond.setup(position); return newDiamond; }
//-------------------------------------- void ofRunApp(ofBaseApp * OFSA){ OFSAptr = OFSA; if(OFSAptr){ OFSAptr->mouseX = 0; OFSAptr->mouseY = 0; } atexit(ofExitCallback); #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif window->initializeWindow(); ofSeedRandom(); ofResetElapsedTimeCounter(); window->runAppViaInfiniteLoop(OFSAptr); }
void Scene3::stateEnter(){ ofResetElapsedTimeCounter(); kosuri_internal = 0; // if (getSharedData().vidGrabber.listDevices().size() > 1) { // // getSharedData().vidGrabber.setDeviceID(1); // getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight); // // // } else { // getSharedData().vidGrabber.setDeviceID(0); // getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight); // } getSharedData().vidGrabber.setDeviceID(2); getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight); for(int i=0;i<4;i++){ getSharedData().tearai[i].setVolume(0.0); } getSharedData().frameCount = 0; getSharedData().BGMSound.setVolume(0.4); getSharedData().BGMSound2.setVolume(0.0); kosuri = getSharedData().kosuri; kosuri_internal = getSharedData().kosuri; for(int i=0;i<4;i++){ getSharedData().tearai[i].setVolume(0.0); } getSharedData().sceneChange.play(); deg = 0; }
void ofInit(){ if(initialized()) return; initialized() = true; #if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS) // manage own exit #else atexit(ofExitCallback); #endif #if defined(TARGET_LINUX) || defined(TARGET_OSX) // see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals signal(SIGTERM, &ofSignalHandler); signal(SIGQUIT, &ofSignalHandler); signal(SIGINT, &ofSignalHandler); signal(SIGHUP, &ofSignalHandler); // not much to be done here // http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals signal(SIGABRT, &ofSignalHandler); // abort signal #endif #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif #ifdef TARGET_LINUX if(std::locale().name() == "C"){ try{ std::locale::global(std::locale("C.UTF-8")); }catch(...){ if(ofToLower(std::locale("").name()).find("utf-8")==std::string::npos){ ofLogWarning("ofInit") << "Couldn't set UTF-8 locale, string manipulation functions\n" "won't work correctly for non ansi characters unless you specify a UTF-8 locale\n" "manually using std::locale::global(std::locale(\"locale\"))\n" "available locales can be queried with 'locale -a' in a terminal."; } } } #endif ofSeedRandom(); ofResetElapsedTimeCounter(); of::priv::setWorkingDirectoryToDefault(); }
//-------------------------------------------------------------- void testApp::beat() { if (ofGetElapsedTimeMillis() < 100) { return; } // do something that is visibly different from what you're currently doing if (servoPosition > 0) { moveServo(-60, true); }else { moveServo(60, true); } ofResetElapsedTimeCounter(); }
void Scene2::stateEnter(){ if (getSharedData().vidGrabber.listDevices().size() > 1) { getSharedData().vidGrabber.setDeviceID(1); getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight); } else { getSharedData().vidGrabber.setDeviceID(0); getSharedData().vidGrabber.initGrabber(getSharedData().camWidth, getSharedData().camHeight); } ofResetElapsedTimeCounter(); kosuri = getSharedData().kosuri; }
//-------------------------------------- void ofRunApp(ofPtr<ofBaseApp> OFSA){ OFSAptr = OFSA; if(OFSAptr){ OFSAptr->mouseX = 0; OFSAptr->mouseY = 0; } #ifndef TARGET_ANDROID // #ifndef OF_SCREEN_SAVER atexit(ofExitCallback); // #endif #endif #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif window->initializeWindow(); ofSeedRandom(); ofResetElapsedTimeCounter(); ofAddListener(ofEvents().setup,OFSA.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().update,OFSA.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().draw,OFSA.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().exit,OFSA.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().keyPressed,OFSA.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().keyReleased,OFSA.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseMoved,OFSA.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseDragged,OFSA.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mousePressed,OFSA.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseReleased,OFSA.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().windowEntered,OFSA.get(),&ofBaseApp::windowEntry,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().windowResized,OFSA.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().messageEvent,OFSA.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().fileDragEvent,OFSA.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP); window->runAppViaInfiniteLoop(OFSAptr.get()); }
// i get called once void testApp::setup(){ // do some initialization // set the size of the window ofSetWindowShape(250, 250); // the rate at which the program runs (FPS) ofSetFrameRate(30); // we are going to increment this variable each "frame" counter = 0; brightness = 0; ofResetElapsedTimeCounter(); }
//-------------------------------------------------------------- void testApp::setup(){ ///////////// // ofxBeatTracking declarations ////////// // フレームレートを60Hzにセット ofSetFrameRate(60); // オーディオインプットを指定 この値は固定すること // Output->0 Input->mono sampleRate->44100 bufSize->1024 ofSoundStreamSetup(0, 1, this, 44100, testApp_buffer_size, 4); //fbook.loadFont("arial.ttf", 32, true, false); ofBackground(20,20,20); printf("testApp setup() OK!\n"); ///////////// // Arduino Firmata communication setup ////////// ofSetVerticalSync(true); buttonState = "digital pin:"; potValue = "analog pin:"; bgImage.loadImage("background.png"); font.loadFont("franklinGothic.otf", 20); smallFont.loadFont("franklinGothic.otf", 14); // replace the string below with the serial port for your Arduino board // you can get this from the Arduino application or via command line // for OSX, in your terminal type "ls /dev/tty.*" to get a list of serial devices ard.connect("/dev/tty.usbmodem621", 57600); // listen for EInitialized notification. this indicates that // the arduino is ready to receive commands and it is safe to // call setupArduino() ofAddListener(ard.EInitialized, this, &testApp::setupArduino); bSetupArduino = false; // flag so we setup arduino when its ready, you don't need to touch this :) ///////////// // Custom Apache declarations ///////////// servoPosition, servoTarget = 0; // TODO: initialize "servoPositions" and "servoTargets" arrays to {0,0,0} ofResetElapsedTimeCounter(); }
//-------------------------------------------------------------- void testApp::setup(){ screenWidth = 1024; screenHeight = 768; kernelSize = screenWidth / 2; currentLut = 0; currentTrial = 0; bNoiseState = true; bFirstTrial = true; // static const float sigmas[] = {1.5, 1.25, 1.0, 0.75, 0.5, 0.25, 0.125, 0.0625}; // static const float thetas[] = {0, 45, 90, 135, 180, 225, 270, 315}; // static const float freqs[] = {0.0625, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 1.0}; static const float sigmas[] = {1.25, 0.125, 0.25, 1.5, 1.0, 0.5, 0.0625, 0.75}; static const float thetas[] = {0, 45, 225, 270, 135, 180, 315, 90}; static const float freqs[] = {0.375, 0.0625, 0.625, 0.5, 1.0, 0.125, 0.75, 0.25}; this->sigmas = vector<float>(sigmas, sigmas + sizeof(sigmas) / sizeof(sigmas[0]) ); this->thetas = vector<float>(thetas, thetas + sizeof(thetas) / sizeof(thetas[0]) ); this->freqs = vector<float>(freqs, freqs + sizeof(freqs) / sizeof(freqs[0]) ); for (int i = 0; i < this->sigmas.size(); i++) { for (int j = 0; j < this->thetas.size(); j++) { for (int k = 0; k < this->freqs.size(); k++) { int lut[] = {i, j, k}; vector<int> clut(lut, lut + sizeof(lut) / sizeof(lut[0])); this->lut.push_back(clut); } } } ////////////////////////////////////////////////////// // now create the file so that we can start adding frames to it: string filename = getNextFilename("eeg-record-trial-" + ofToString(currentTrial), "txt"); outfile.open( ofToDataPath(filename).c_str() ); oscReceiver.setup(RECEIVE_PORT); atom.allocate(max(screenWidth, screenHeight)); noiseShader.load(ofToDataPath("noise")); ofSetVerticalSync(true); ofSetWindowShape(screenWidth, screenHeight); ofResetElapsedTimeCounter(); }
void ofInit(){ static bool initialized = false; if(initialized) return; initialized = true; Poco::ErrorHandler::set(new ofThreadErrorLogger); #if defined(TARGET_ANDROID) || defined(TARGET_IOS) // manage own exit #else atexit(ofExitCallback); #endif #if defined(TARGET_LINUX) || defined(TARGET_OSX) // see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals signal(SIGTERM, &ofSignalHandler); signal(SIGQUIT, &ofSignalHandler); signal(SIGINT, &ofSignalHandler); signal(SIGHUP, &ofSignalHandler); // not much to be done here // http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals signal(SIGABRT, &ofSignalHandler); // abort signal #endif #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif ofSeedRandom(); ofResetElapsedTimeCounter(); ofSetWorkingDirectoryToDefault(); }
//-------------------------------------------------------------- void ofApp::update(){ #if VIDEO client1.update(); //client2.update(); if(!STATIC_IMAGE){ if(client1.isFrameNewVideo()){ texture1.loadData(client1.getPixelsVideo()); //temp texture2.loadData(client1.getPixelsVideo()); ofResetElapsedTimeCounter(); } //if(client2.isFrameNewVideo()){ // texture2.loadData(client2.getPixelsVideo()); //} } #endif }
//-------------------------------------- void ofRunApp(ofBaseApp * OFSA){ OFSAptr = OFSA; if(OFSAptr){ OFSAptr->mouseX = 0; OFSAptr->mouseY = 0; } #ifdef TARGET_OSX //this internally checks the executable path for osx ofSetDataPathRoot("../../../data/"); #endif atexit(ofExitCallback); #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif // reverse initialize multi-windows for (int i = windowCount-1 ; i >= 0 ; i--) windows[i]->initializeWindow(i); ofSeedRandom(); ofResetElapsedTimeCounter(); window->runAppViaInfiniteLoop(OFSAptr); }
//-------------------------------------------------------------- void cyrilApp::update(){ // Disable all ofxPostProcessing effects so they only activate // if command is present in a running program _state.post[FX_KALEIDOSCOPE]->disable(); _state.post[FX_NOISE_WARP]->disable(); _state.post[FX_PIXELATE]->disable(); _state.post[FX_BLOOM]->disable(); for (int i = 0; i < 10; ++i) { if (running[i]) { if (prog[i]->valid) { prog[i]->update(_state); } } } if (doResetTimers) { (*_state.sym)[REG_FRAME] = 0; ofResetElapsedTimeCounter(); doResetTimers = false; } else { (*_state.sym)[REG_FRAME]++; } (*_state.sym)[REG_TIME] = ofGetElapsedTimeMillis(); (*_state.sym)[REG_SECS] = ofGetElapsedTimef(); (*_state.sym)[REG_FAST] = ofGetElapsedTimef() * 10; (*_state.sym)[REG_SLOW] = ofGetElapsedTimef() * 2; // For beat detection beat.update((*_state.sym)[REG_TIME]); (*_state.sym)[REG_BEAT_MAGNITUDE] = beat.getMagnitude(); (*_state.sym)[REG_BEAT_KICK] = beat.kick(); (*_state.sym)[REG_BEAT_SNARE] = beat.snare(); (*_state.sym)[REG_BEAT_HIHAT] = beat.hihat(); for (int i = REG_BEAT_FFT_START; i < REG_BEAT_FFT_MAX; ++i) { (*_state.sym)[i] = beat.getBand(i - REG_BEAT_FFT_START); } for(vector<Particle*>::iterator it = _state.ps->begin(); it != _state.ps->end(); ++it){ (*it)->update(); } ofRemove(*_state.ps, Particle::isDead); /* // check for waiting OSC messages while(receiver.hasWaitingMessages()){ // get the next message ofxOscMessage m; receiver.getNextMessage(&m); // check for mouse moved message if(m.getAddress() == "/buffer/0"){ string msg_string; msg_string = m.getAddress(); cout << msg_string << endl; } } */ }
// the same hack but in this case the shared_ptr will delete, old versions created the testApp as new... //-------------------------------------- void ofRunApp(ofBaseApp * OFSA){ OFSAptr = ofPtr<ofBaseApp>(OFSA); if(OFSAptr){ OFSAptr->mouseX = 0; OFSAptr->mouseY = 0; } #ifndef TARGET_ANDROID atexit(ofExitCallback); #endif #if defined(TARGET_LINUX) || defined(TARGET_OSX) // see http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals signal(SIGTERM, &sighandler); signal(SIGQUIT, &sighandler); signal(SIGINT, &sighandler); signal(SIGKILL, &sighandler); // not much to be done here signal(SIGHUP, &sighandler); // not much to be done here // http://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html#Program-Error-Signals signal(SIGABRT, &sighandler); // abort signal #endif #ifdef WIN32_HIGH_RES_TIMING timeBeginPeriod(1); // ! experimental, sets high res time // you need to call timeEndPeriod. // if you quit the app other than "esc" // (ie, close the console, kill the process, etc) // at exit wont get called, and the time will // remain high res, that could mess things // up on your system. // info here:http://www.geisswerks.com/ryan/FAQS/timing.html #endif window->initializeWindow(); ofSeedRandom(); ofResetElapsedTimeCounter(); ofSetWorkingDirectoryToDefault(); ofAddListener(ofEvents().setup,OFSAptr.get(),&ofBaseApp::setup,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().update,OFSAptr.get(),&ofBaseApp::update,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().draw,OFSAptr.get(),&ofBaseApp::draw,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().exit,OFSAptr.get(),&ofBaseApp::exit,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().keyPressed,OFSAptr.get(),&ofBaseApp::keyPressed,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().keyReleased,OFSAptr.get(),&ofBaseApp::keyReleased,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseMoved,OFSAptr.get(),&ofBaseApp::mouseMoved,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseDragged,OFSAptr.get(),&ofBaseApp::mouseDragged,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mousePressed,OFSAptr.get(),&ofBaseApp::mousePressed,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().mouseReleased,OFSAptr.get(),&ofBaseApp::mouseReleased,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().windowEntered,OFSAptr.get(),&ofBaseApp::windowEntry,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().windowResized,OFSAptr.get(),&ofBaseApp::windowResized,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().messageEvent,OFSAptr.get(),&ofBaseApp::messageReceived,OF_EVENT_ORDER_APP); ofAddListener(ofEvents().fileDragEvent,OFSAptr.get(),&ofBaseApp::dragged,OF_EVENT_ORDER_APP); window->runAppViaInfiniteLoop(OFSAptr.get()); }
//-------------------------------------------------------------- void testApp::update(){ /* sigma = 2.0 * kernelSize * sinf(ofGetElapsedTimef() / 12.0) / 5.0; theta = 180.0 * cosf(ofGetElapsedTimef() / 6.0); freq = sinf(ofGetElapsedTimef() / 2.0); */ if (!bFirstTrial && ofGetElapsedTimeMillis() >= MS_PER_STIMULI) { ofResetElapsedTimeCounter(); bNoiseState = !bNoiseState; if (bNoiseState) { currentLut++; if (currentLut == 512) { currentLut = 0; currentTrial++; if (currentTrial == 10) { cout << "[OK] Finished!" << endl; outfile.close(); OF_EXIT_APP(0); } outfile.close(); string filename = getNextFilename("eeg-record-trial-" + ofToString(currentTrial), "txt"); outfile.open( ofToDataPath(filename).c_str() ); } } } if (bNoiseState) { } else { sigma = kernelSize * sigmas[lut[currentLut][0]]; theta = thetas[lut[currentLut][1]]; freq = freqs[lut[currentLut][2]]; atom.update(sigma, theta, freq); } string delimiter = ","; #ifdef USE_OSC while (oscReceiver.hasWaitingMessages()) { ofxOscMessage m; if(oscReceiver.getNextMessage(&m)) { if (m.getAddress() == "/eeg") { #endif outfile << ofGetTimestampString() << delimiter << bNoiseState << delimiter << currentTrial << delimiter << currentLut << delimiter << sigma << delimiter << theta << delimiter << freq; #ifdef USE_OSC for (int ch = 0; ch < 22; ch++) { outfile << delimiter << m.getArgAsFloat(ch); } #endif outfile << delimiter; outfile << endl; #ifdef USE_OSC } } } #endif }