//-------------------------------------------------------------- void ofApp::keyPressed(int key){ ofPixels pixels; uint64_t t ; switch (key) { case 's': case 'S': t = ofGetElapsedTimeMicros(); //recorder.snapshot(renderFbo); ofLogNotice()<< "time snapshot ="<< (ofGetElapsedTimeMicros() - t) / 1000.0<< " ms"; break; case 'm': case 'M': { std::stringstream filename; auto t = std::time(nullptr); auto tm = *std::localtime(&t); filename << "toto_" << std::put_time(&tm, "%Y%m%d_%H%M%S") << ".mp4"; const std::string tmp = filename.str(); c.open(tmp.c_str()); //recorder.startMovie(); break; } case 'n': case 'N': c.close(); //recorder.endMovie(); break; default: break; } }
//-------------------------------------------------------------- void ofApp::update(){ SensorEvent gyro; float foo = ofSignedNoise(ofGetElapsedTimef(), 0, 0)*9.8; float bar = (9.8-foo)/2.0; gyro.reading.set(foo/9.8,bar/9.8 , bar/9.8); gyro.timestamp = ofGetElapsedTimeMicros(); gyro.type = GYRO; tracking.processSensorEvent(gyro); SensorEvent accel; accel.reading.set(foo, bar , bar); accel.reading.normalize(); accel.reading.scale(9.8); accel.timestamp = ofGetElapsedTimeMicros(); accel.type = ACCEL; tracking.processSensorEvent(accel); // SensorEvent gyro; // gyro.reading.set(abs(ofSignedNoise(sin(ofGetElapsedTimef())))*0.01, abs(ofSignedNoise(sin(ofGetElapsedTimef())))*0.01, abs(ofSignedNoise(sin(ofGetElapsedTimef())))*0.01); // gyro.timestamp = ofGetElapsedTimeMicros(); // gyro.type = GYRO; // tracking.processSensorEvent(gyro); // // // SensorEvent accel; // accel.reading.set(9.8-abs(ofSignedNoise(cos(ofGetElapsedTimef())))*9.8, 9.8-abs(ofSignedNoise(sin(ofGetElapsedTimef())))*9.8, 0.01*abs(ofSignedNoise(sin(ofGetElapsedTimef())))); // accel.timestamp = ofGetElapsedTimeMicros(); // accel.type = ACCEL; // tracking.processSensorEvent(accel); }
//------------------------------------------ void ofNotifyDraw(){ if(ofGetCurrentRenderer()){ ofNotifyEvent( ofEvents().draw, voidEventArgs ); } nFrameCount++; // calculate sleep time to adjust to target fps unsigned long long timeNow = ofGetElapsedTimeMicros(); #ifndef TARGET_EMSCRIPTEN if (nFrameCount != 0 && bFrameRateSet == true){ unsigned long long diffMicros = timeNow - prevMicrosForFPS; prevMicrosForFPS = timeNow; if(diffMicros < microsForFrame){ unsigned long long waitMicros = microsForFrame - diffMicros; // Theoretical value to compensate for the extra time that it might sleep prevMicrosForFPS += waitMicros; #ifdef TARGET_WIN32 Sleep(waitMicros*MICROS_TO_MILLIS); #else usleep(waitMicros); #endif } }else{ prevMicrosForFPS = timeNow; } #endif // calculate fps timeNow = ofGetElapsedTimeMicros(); if(nFrameCount==0){ timeThen = timeNow; if(bFrameRateSet) fps = targetRate; }else{ unsigned long long oneSecDiff = timeNow-oneSec; if( oneSecDiff >= 1000000 ){ fps = nFramesForFPS/(oneSecDiff*MICROS_TO_SEC); oneSec = timeNow; nFramesForFPS = 0; }else{ double deltaTime = ((double)oneSecDiff)*MICROS_TO_SEC; if( deltaTime > 0.0 ){ fps = fps*0.99 + (nFramesForFPS/deltaTime)*0.01; } } nFramesForFPS++; lastFrameTime = timeNow-timeThen; timeThen = timeNow; } }
//-------------------------------------------------------------- void testApp::update(){ if (bUsePBO) { //pbo.writeToTexture(texture); pbo.allocate(2048, 2048, GL_RGBA32I); //unsigned int* gpuMemory = (unsigned int*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, 2048*2048*4, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT); unsigned int* gpuMemory = (unsigned int*)pbo.map(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); if (gpuMemory) { updatePixels(gpuMemory); //glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); pbo.unmap(); } else { GLenum error = glGetError(); if (error != GL_NO_ERROR) ofLogError("update()", ofToString(gluErrorString(error))); } //glEnable(GL_TEXTURE_RECTANGLE); glBindTexture(GL_TEXTURE_RECTANGLE, tex); pbo.bind(); glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); //glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); unsigned long long start = ofGetElapsedTimeMicros(); glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, 2048, 2048, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0); time = (ofGetElapsedTimeMicros() - start) * 0.1 + time * 0.9; pbo.unbind(); glBindTexture(GL_TEXTURE_RECTANGLE, 0); //glDisable(GL_TEXTURE_RECTANGLE); glFlush(); } else { updatePixels(cpuMemory); unsigned long long start = ofGetElapsedTimeMicros(); glEnable(GL_TEXTURE_RECTANGLE); glBindTexture(GL_TEXTURE_RECTANGLE, tex); glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, 2048, 2048, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, cpuMemory); //glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, 2048, 2048, 0, GL_RGBA, GL_UNSIGNED_BYTE, cpuMemory); GLenum error = glGetError(); if (error != GL_NO_ERROR) ofLogError("update()", ofToString(gluErrorString(error))); glBindTexture(GL_TEXTURE_RECTANGLE, 0); glDisable(GL_TEXTURE_RECTANGLE); //glDisable(GL_TEXTURE0); glFlush(); time = (ofGetElapsedTimeMicros() - start) * 0.1 + time * 0.9; } }
void VideoRate::threadedFunction(){ while(isThreadRunning()){ unsigned long long time = ofGetElapsedTimeMicros(); if(back!=NULL){ mutexFront.lock(); framesToSend.push(back); mutexFront.unlock(); } time = ofGetElapsedTimeMicros()-time; long long sleeptime = 1000000./fps-time; if(sleeptime>0){ usleep(sleeptime); } } }
void ofxTimeMeasurements::stopMeasuring(string ID){ if (!enabled) return; map<string,TimeMeasurement>::iterator it; it = times.find(ID); if ( it == times.end() ){ //not found! ofLog( OF_LOG_WARNING, "ID (%s)not found at stopMeasuring(). Make sure you called startMeasuring with that ID first.", ID.c_str()); }else{ if ( times[ID].measuring ){ TimeMeasurement t; t.measuring = false; t.error = false; t.microsecondsStop = ofGetElapsedTimeMicros(); t.microsecondsStart = times[ID].microsecondsStart; t.duration = t.microsecondsStop - t.microsecondsStart; t.avgDuration = (1.0f - timeAveragePercent) * times[ID].avgDuration + t.duration * timeAveragePercent; times[ID] = t; }else{ //wrong use, start first, then stop ofLog( OF_LOG_WARNING, "Can't stopMeasuring(%s). Make sure you called startMeasuring with that ID first.", ID.c_str()); } } }
void arduinoThread::initializeVariables(){ start_path = false; start_transition = true; x_timer = y_timer = z_timer = i_timer = ofGetElapsedTimeMicros(); x_steps = y_steps = z_steps = i_steps = x_inc = y_inc = z_inc = i_inc = 0; x_go = y_go = z_go = i_go = ARD_HIGH; }
screenItem::screenItem(float _x, float _y) { birth=ofGetElapsedTimeMicros(); age = 0.0; x = _x; y = _y; dx = 0; dy = 0; }
//---------- void NullDevice::getFrame(shared_ptr<Frame> frame) { auto & pixels = frame->getPixels(); pixels.allocate(this->settings.width, this->settings.height, OF_PIXELS_MONO); pixels.set(0, 0); ofSleepMillis(1e3 / this->settings.frameRate); frame->setFrameIndex(this->frameIndex++); frame->setTimestamp(ofGetElapsedTimeMicros()); }
ofxNotify::~ofxNotify() { if (msgMutex.tryLock()){ if(!bPrinted){ if(message.str().empty()){ message; } messages[ofGetElapsedTimeMicros()] = message.str(); } msgMutex.unlock(); } }
void ofxTimeMeasurements::startMeasuring(string ID){ if (!enabled) return; TimeMeasurement t; t.measuring = true; t.microsecondsStart = ofGetElapsedTimeMicros(); t.microsecondsStop = 0; t.duration = 0; t.avgDuration = times[ID].avgDuration; t.error = true; times[ID] = t; }
//-------------------------------------------------------------------------------- /// Return values: /// SOCKET_TIMEOUT indicates timeout /// SOCKET_ERROR in case of a problem. int ofxTCPManager::ReceiveAll(char* pBuff, const int iSize) { if (m_hSocket == INVALID_SOCKET) return(SOCKET_ERROR); auto timestamp = ofGetElapsedTimeMicros(); auto timeleftSecs = m_dwTimeoutReceive; auto timeleftMicros = 0; int totalBytes=0; do { if (m_dwTimeoutReceive != NO_TIMEOUT){ auto ret = WaitReceive(timeleftSecs, timeleftMicros); if(ret!=0){ return ret; } } int ret = recv(m_hSocket, pBuff+totalBytes, iSize-totalBytes, 0); if (ret==0 && totalBytes != iSize){ return SOCKET_ERROR; } if (ret < 0){ return SOCKET_ERROR; } totalBytes += ret; if (m_dwTimeoutReceive != NO_TIMEOUT){ auto now = ofGetElapsedTimeMicros(); auto diff = now - timestamp; if(diff > m_dwTimeoutReceive){ return SOCKET_TIMEOUT; } float timeFloat = m_dwTimeoutSend - diff/1000000.; timeleftSecs = timeFloat; timeleftMicros = (timeFloat - timeleftSecs) * 1000000; } }while(totalBytes < iSize); return totalBytes; }
//-------------------------------------------------------------------------------- /// Return values: /// SOCKET_TIMEOUT indicates timeout /// SOCKET_ERROR in case of a problem. int ofxUDPManager::SendAll(const char* pBuff, const int iSize) { if (m_hSocket == INVALID_SOCKET) return(SOCKET_ERROR); auto timestamp = ofGetElapsedTimeMicros(); auto timeleftSecs = m_dwTimeoutSend; auto timeleftMicros = 0; int total= 0; int bytesleft = iSize; int ret=-1; while (total < iSize) { if (m_dwTimeoutSend != NO_TIMEOUT){ auto ret = WaitSend(timeleftSecs,timeleftMicros); if(ret!=0){ return ret; } } ret = sendto(m_hSocket, (char*)pBuff, iSize, 0, (sockaddr *)&saClient, sizeof(sockaddr)); if (ret == SOCKET_ERROR) { return SOCKET_ERROR; } total += ret; bytesleft -=ret; if (m_dwTimeoutSend != NO_TIMEOUT){ auto now = ofGetElapsedTimeMicros(); auto diff = now - timestamp; if (diff > m_dwTimeoutSend * 1000000){ return SOCKET_TIMEOUT; } float timeFloat = m_dwTimeoutSend - diff/1000000.; timeleftSecs = timeFloat; timeleftMicros = (timeFloat - timeleftSecs) * 1000000; } } return total; }
//---------- Specification DeckLink::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) { auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings); auto devices = ofxBlackmagic::Iterator::getDeviceList(); if (devices.empty()) { throw(ofxMachineVision::Exception("No DeckLink devices available")); } if (devices.size() <= (unsigned int)settings->deviceID) { string str = "deviceID [" + ofToString(settings->deviceID) + "] out of range. [" + ofToString(devices.size()) + "] devices available"; throw(ofxMachineVision::Exception(str)); } this->device = devices[settings->deviceID]; int width, height; this->displayMode = static_cast<_BMDDisplayMode>(settings->displayMode.get()); try { CHECK_ERRORS(device.device->QueryInterface(IID_IDeckLinkInput, (void**)&this->input), "Failed to query interface"); CHECK_ERRORS(this->input->SetCallback(this), "Failed to set input callback"); //find the current display mode IDeckLinkDisplayModeIterator * displayModeIterator = 0; CHECK_ERRORS(input->GetDisplayModeIterator(&displayModeIterator), "Couldn't get DisplayModeIterator"); IDeckLinkDisplayMode * displayModeTest = nullptr; IDeckLinkDisplayMode * displayModeFound = nullptr; while (displayModeIterator->Next(&displayModeTest) == S_OK) { if (displayModeTest->GetDisplayMode() == this->displayMode) { displayModeFound = displayModeTest; } } if (!displayModeFound) { CHECK_ERRORS(S_FALSE, "Cannot find displayMode"); } width = displayModeFound->GetWidth(); height = displayModeFound->GetHeight(); } catch (std::exception e) { throw(ofxMachineVision::Exception(e.what())); } this->openTime = ofGetElapsedTimeMicros(); this->frameIndex = 0; Specification specification(width, height, "BlackMagic", device.modelName); specification.addFeature(ofxMachineVision::Feature::Feature_DeviceID); specification.addFeature(ofxMachineVision::Feature::Feature_FreeRun); return specification; }
//--------- HRESULT DeckLink::VideoInputFrameArrived(IDeckLinkVideoInputFrame* videoFrame, IDeckLinkAudioInputPacket* audioFrame) { if (videoFrame == NULL) { return S_OK; } const auto width = videoFrame->GetWidth(); const auto height = videoFrame->GetHeight(); const auto pixelCount = width * height; try { //try to lock for writing int tryCount = 0; while (!this->incomingFrame->lockForWriting()) { ofSleepMillis(1); if (tryCount++ > 100) { throw(ofxMachineVision::Exception("Timeout processing incoming frame")); } } //check allocation if (this->incomingFrame->getPixels().getWidth() != width || this->incomingFrame->getPixels().getHeight() != height) { this->incomingFrame->getPixels().allocate(width, height, OF_IMAGE_GRAYSCALE); } //copy bytes out from frame unsigned char * yuvBytes = nullptr; CHECK_ERRORS(videoFrame->GetBytes((void**)& yuvBytes), "Failed to pull bytes from incoming video frame"); //copy UYVY -> YY auto out = this->incomingFrame->getPixels().getPixels(); for (int i = 0; i < pixelCount; i++) { //this method seems to be auto-SIMD optimised out[i] = yuvBytes[i * 2 + 1]; } this->incomingFrame->setTimestamp(ofGetElapsedTimeMicros() - this->openTime); this->incomingFrame->setFrameIndex(this->frameIndex++); this->incomingFrame->unlock(); //alert the grabber this->onNewFrame(this->incomingFrame); } catch (ofxMachineVision::Exception e) { OFXMV_ERROR << e.what(); } return S_OK; }
ofMatrix4x4 headTracking::getLastHeadView(ofMatrix4x4 headView) { if (!mTracker.isReady()) { return headView; } ofOrientation fooRot = ofGetOrientation(); double rotation = 0.0; if (fooRot == OF_ORIENTATION_DEFAULT) { rotation = 0.0; } else if (fooRot == OF_ORIENTATION_90_LEFT) { rotation = 90.0; } else if (fooRot == OF_ORIENTATION_90_RIGHT) { rotation = 180.0; } else { rotation = 270.0; } if (fooRot != mDisplayRotation) { mDisplayRotation = fooRot; mSensorToDisplay.makeRotationMatrix( ofQuaternion(0.0, ofVec3f(1, 0, 0), -rotation, ofVec3f(0, 0, 1), 0.0, ofVec3f(0, 1, 0))); mEkfToHeadTracker.makeRotationMatrix( ofQuaternion(0.0, ofVec3f(1, 0, 0), rotation, ofVec3f(0, 0, 1), 0.0, ofVec3f(0, 1, 0))); } double secondsSinceLastGyroEvent = (ofGetElapsedTimeMicros() - mLastGyroEventTimeNanos) * 1E-6; double secondsToPredictForward = secondsSinceLastGyroEvent + 0.0166666666; mTmpHeadView = mTracker.getPredictedGLMatrix(secondsToPredictForward); mTmpHeadView2.makeFromMultiplicationOf(mSensorToDisplay, mTmpHeadView); headView.makeFromMultiplicationOf(mTmpHeadView2, mEkfToHeadTracker); if (mNeckModelEnabled) { mTmpHeadView.makeFromMultiplicationOf(mNeckModelTranslation, headView); mTmpHeadView.translate(ofVec3f(0, 0.075, 0.0)); headView = mTmpHeadView; } return headView; }
//------------------------------------------------------------------------- unsigned int FingersClassifierSVM::classify(const vector<float>& sample) { if (!bCalibrating) { uint64_t t = ofGetElapsedTimeMicros(); if (t- lastClassifyTime > minClassifyTime) { lastClassifyTime = t; vector<double> sampleD; for (int i = 0; i < sample.size(); i++) { sampleD.push_back((double)sample[i]/maxAll); } double p =classifier.predict(sampleD); int pf = (int)(5*p); // cout << name << " classify: " << pf << endl; primaryFinger = pf; return primaryFinger; } } return 0; }
void ofxNotify::draw(){ if (messages.empty()) return; // -------- Invariant: there are messages to display. unsigned long long elapsedTimeNow = ofGetElapsedTimeMicros(); int i = 0; map<unsigned long long, string>::iterator it = messages.begin(); while (it != messages.end()){ ofDrawBitmapStringHighlight(it->second, ofGetWidth() - (it->second.size()*8 + 10), ofGetHeight() - (i*20 + 15) , (i == messages.size()-1) ? (ofColor::white) : (ofColor::whiteSmoke), (i == messages.size()-1) ? (ofColor::black) : (ofColor::black)); it++; i++; } it = messages.begin(); bool hasFoundDeadMessage = false; while (it != messages.end()){ if (elapsedTimeNow - it->first > messageLifeTimeInMilliseconds*1000){ it++; hasFoundDeadMessage = true; } else { break; } } if (hasFoundDeadMessage && msgMutex.tryLock()){ messages.erase(messages.begin(), it); msgMutex.unlock(); } }
void baseScene::resetTiming(){ startTime = ofGetElapsedTimeMicros(); startFrame = ofGetFrameNum(); }
//---------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------- void arduinoThread::threadedFunction(){ unsigned long long now = ofGetElapsedTimeMicros(); while(isThreadRunning() != 0){ usleep(1); // X axis if (x_steps > 0 && x_inc < x_steps) { now = ofGetElapsedTimeMicros(); if (now - x_timer > HIGH_DELAY) { if (x_go) { x_go = false; x_timer = now; ard.sendDigital(X_STEP_PIN, ARD_HIGH); x_inc++; } else if (now - x_timer > x_delay) { x_go = true; x_timer = now; ard.sendDigital(X_STEP_PIN, ARD_LOW); } } } // Y axis if (y_steps > 0 && y_inc < y_steps) { now = ofGetElapsedTimeMicros(); if (now - y_timer > HIGH_DELAY) { if (y_go) { y_go = false; y_timer = now; ard.sendDigital(Y_STEP_PIN, ARD_HIGH); y_inc++; } else if (now - y_timer > y_delay) { y_go = true; y_timer = now; ard.sendDigital(Y_STEP_PIN, ARD_LOW); } } } // Z axis if (z_steps > 0 && z_inc < z_steps) { now = ofGetElapsedTimeMicros(); if (now - z_timer > HIGH_DELAY) { if (z_go) { z_go = false; z_timer = now; ard.sendDigital(Z_STEP_PIN, ARD_HIGH); z_inc++; } else if (now - z_timer > z_delay) { z_go = true; z_timer = now; ard.sendDigital(Z_STEP_PIN, ARD_LOW); } } } // Syringe if (i_steps > 0 && i_inc < i_steps) { now = ofGetElapsedTimeMicros(); if (now - i_timer > HIGH_DELAY) { if (i_go) { i_go = false; i_timer = now; ard.sendDigital(INK_STEP_PIN, ARD_HIGH); i_inc++; } else if (now - i_timer > i_delay) { i_go = true; i_timer = now; ard.sendDigital(INK_STEP_PIN, ARD_LOW); } } } } }
void threadedSerial::serialparse(unsigned char *c) { int i, j; long sum; char tempBuf[20]; dParserStartT = ofGetElapsedTimeMicros(); // do the circular buffer thing three times independently for (j = 0; j < 3; j++) { // push bytes forward in the three circular buffers "serialStream[j]" for (i = 0; i < streamSize[j]-1; i++) { serialStream[j][i] = serialStream[j][i+1]; } serialStream[j][streamSize[j]-1] = c[0]; // append new byte to each serialStream[j] buffer } dParserStopT = ofGetElapsedTimeMicros(); dParserSum += (dParserStopT - dParserStartT); // pattern matching if (serialStream[0][0] == 65) { // packet start marker if(serialStream[0][1] == 240) { // left hand packet if(serialStream[0][22] == 90) { for(i = 0; i < 20; i++) { // collect n-2 bytes into buffer input[0][i] = serialStream[0][i+2]; } printf("LEFT - serial parsing time: %lld us\n", dParserSum); dBuffer.append("LEFT; "); sprintf(tempBuf, "%lld", dParserSum); dBuffer.append(tempBuf); dBuffer.append("; "); dParserSum = 0; dLhStartT = ofGetElapsedTimeMicros(); dLhParsing = true; haveInput[0] = true; parseLeft(); calcKeycode(); } } } // v3.5 comm structure if (serialStream[1][0] == 65) { // packet start marker if(serialStream[1][1] == 241) { // right hand packet if(serialStream[1][41] == 90) { for(i = 0; i < 39; i++) { // collect n-2 bytes into buffer input[1][i] = serialStream[1][i+2]; } printf("RIGHT - serial parsing time: %lld us\n", dParserSum); dBuffer.append("RIGHT; "); sprintf(tempBuf, "%lld", dParserSum); dBuffer.append(tempBuf); dBuffer.append("; "); dParserSum = 0; dRhStartT = ofGetElapsedTimeMicros(); dRhParsing = true; haveInput[1] = true; // printf("input[1][35] = %x\n", input[1][35]); parseRight(); calcKeycode(); parseIMU(); } } } // // v3.4 comm structure // if (serialStream[1][0] == 65) { // packet start marker // if(serialStream[1][1] == 241) { // right hand packet // if(serialStream[1][39] == 90) { // for(i = 0; i < 37; i++) { // collect n-2 bytes into buffer // input[1][i] = serialStream[1][i+2]; // } // haveInput[1] = true; // parseRight(); // calcKeycode(); // parseIMU(); // } // } // } if (serialStream[2][0] == 65) { // packet start marker if(serialStream[2][1] == 242) { // AirMems packet if(serialStream[2][14] == 90) { for(i = 0; i < 12; i++) { // collect n-2 bytes into buffer input[2][i] = serialStream[2][i+2]; } printf("AM - serial parsing time: %lld us\n", dParserSum); dBuffer.append("airMEMS; "); sprintf(tempBuf, "%lld", dParserSum); dBuffer.append(tempBuf); dBuffer.append("; "); dParserSum = 0; dAmStartT = ofGetElapsedTimeMicros(); dAmParsing = true; haveInput[2] = true; parseAir(); } } } }
bool screenItem::update() { unsigned long long now; now=ofGetElapsedTimeMicros(); age=((double)(now-birth)/1000000.0); }
/* Call to render the next GL frame */ void Java_cc_openframeworks_OFAndroid_render( JNIEnv* env, jclass thiz ) { unsigned long beginFrameMicros = ofGetElapsedTimeMicros(); if(paused) return; lastFrameTime = double(beginFrameMicros - previousFrameMicros)/1000000.; previousFrameMicros = beginFrameMicros; if(!threadedTouchEvents){ mutex.lock(); while(!touchEventArgsQueue.empty()){ switch(touchEventArgsQueue.front().type){ case ofTouchEventArgs::down: ofNotifyEvent(ofEvents().touchDown,touchEventArgsQueue.front()); break; case ofTouchEventArgs::up: ofNotifyEvent(ofEvents().touchUp,touchEventArgsQueue.front()); break; case ofTouchEventArgs::move: ofNotifyEvent(ofEvents().touchMoved,touchEventArgsQueue.front()); break; case ofTouchEventArgs::doubleTap: ofNotifyEvent(ofEvents().touchDoubleTap,touchEventArgsQueue.front()); break; } touchEventArgsQueue.pop(); } mutex.unlock(); } ofNotifyUpdate(); int width, height; width = sWindowWidth; height = sWindowHeight; height = height > 0 ? height : 1; // set viewport, clear the screen //glViewport( 0, 0, width, height ); ofViewport(0, 0, width, height, false); // used to be glViewport( 0, 0, width, height ); float * bgPtr = ofBgColorPtr(); bool bClearAuto = ofbClearBg(); if ( bClearAuto == true || nFrameCount < 3){ ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255); } if(bSetupScreen) ofSetupScreen(); ofNotifyDraw(); unsigned long currTime = ofGetElapsedTimeMicros(); unsigned long frameMicros = currTime - beginFrameMicros; nFrameCount++; // increase the overall frame count*/ frames++; if(currTime - onesec>=1000000){ frameRate = frames; frames = 0; onesec = currTime; } if(bFrameRateSet && frameMicros<oneFrameTime) usleep(oneFrameTime-frameMicros); }
//-------------------------------------------------------------- void ofApp::draw(){ renderFbo.begin(); ofClear(255,255,255,255); ofFill(); ofSetHexColor(0xe0be21); //------(a)-------------------------------------- // // draw a star // // use poly winding odd, the default rule // // info about the winding rules is here: // http://glprogramming.com/red/images/Image128.gif // ofSetPolyMode(OF_POLY_WINDING_ODD); // this is the normal mode ofBeginShape(); ofVertex(200,135); ofVertex(15,135); ofVertex(165,25); ofVertex(105,200); ofVertex(50,25); ofEndShape(); //------(b)-------------------------------------- // // draw a star // // use poly winding nonzero // // info about the winding rules is here: // http://glprogramming.com/red/images/Image128.gif // ofSetHexColor(0xb5de10); ofSetPolyMode(OF_POLY_WINDING_NONZERO); ofBeginShape(); ofVertex(400,135); ofVertex(215,135); ofVertex(365,25); ofVertex(305,200); ofVertex(250,25); ofEndShape(); //------------------------------------- //------(c)-------------------------------------- // // draw a star dynamically // // use the mouse position as a pct // to calc nPoints and internal point radius // float xPct = (float)(mouseX) / (float)(ofGetWidth()); float yPct = (float)(mouseY) / (float)(ofGetHeight()); int nTips = 5 + xPct * 60; int nStarPts = nTips * 2; float angleChangePerPt = TWO_PI / (float)nStarPts; float innerRadius = 0 + yPct*80; float outerRadius = 80; float origx = 525; float origy = 100; float angle = 0; ofSetHexColor(0xa16bca); ofBeginShape(); for (int i = 0; i < nStarPts; i++){ if (i % 2 == 0) { // inside point: float x = origx + innerRadius * cos(angle); float y = origy + innerRadius * sin(angle); ofVertex(x,y); } else { // outside point float x = origx + outerRadius * cos(angle); float y = origy + outerRadius * sin(angle); ofVertex(x,y); } angle += angleChangePerPt; } ofEndShape(); //------------------------------------- //------(d)-------------------------------------- // // poylgon of random points // // lots of self intersection, 500 pts is a good stress test // // ofSetHexColor(0x0cb0b6); ofSetPolyMode(OF_POLY_WINDING_ODD); ofBeginShape(); for (int i = 0; i < 10; i++){ ofVertex(ofRandom(650,850), ofRandom(20,200)); } ofEndShape(); //------------------------------------- //------(e)-------------------------------------- // // use sin cos and time to make some spirally shape // ofPushMatrix(); ofTranslate(100,300,0); ofSetHexColor(0xff2220); ofFill(); ofSetPolyMode(OF_POLY_WINDING_ODD); ofBeginShape(); float angleStep = TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60); float radiusAdder = 0.5f; float radius = 0; for (int i = 0; i < 200; i++){ float anglef = (i) * angleStep; float x = radius * cos(anglef); float y = radius * sin(anglef); ofVertex(x,y); radius += radiusAdder; } ofEndShape(OF_CLOSE); ofPopMatrix(); //------------------------------------- //------(f)-------------------------------------- // // ofCurveVertex // // because it uses catmul rom splines, we need to repeat the first and last // items so the curve actually goes through those points // ofSetHexColor(0x2bdbe6); ofBeginShape(); for (int i = 0; i < nCurveVertices; i++){ // sorry about all the if/states here, but to do catmull rom curves // we need to duplicate the start and end points so the curve acutally // goes through them. // for i == 0, we just call the vertex twice // for i == nCurveVertices-1 (last point) we call vertex 0 twice // otherwise just normal ofCurveVertex call if (i == 0){ ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0 ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0 } else if (i == nCurveVertices-1){ ofCurveVertex(curveVertices[i].x, curveVertices[i].y); ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // to draw a curve from pt 6 to pt 0 ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we duplicate the first point twice } else { ofCurveVertex(curveVertices[i].x, curveVertices[i].y); } } ofEndShape(); // show a faint the non-curve version of the same polygon: ofEnableAlphaBlending(); ofNoFill(); ofSetColor(0,0,0,40); ofBeginShape(); for (int i = 0; i < nCurveVertices; i++){ ofVertex(curveVertices[i].x, curveVertices[i].y); } ofEndShape(true); ofSetColor(0,0,0,80); for (int i = 0; i < nCurveVertices; i++){ if (curveVertices[i].bOver == true) ofFill(); else ofNoFill(); ofDrawCircle(curveVertices[i].x, curveVertices[i].y,4); } ofDisableAlphaBlending(); //------------------------------------- //------(g)-------------------------------------- // // ofBezierVertex // // with ofBezierVertex we can draw a curve from the current vertex // through the the next three vertices we pass in. // (two control points and the final bezier point) // float x0 = 500; float y0 = 300; float x1 = 550+50*cos(ofGetElapsedTimef()*1.0f); float y1 = 300+100*sin(ofGetElapsedTimef()/3.5f); float x2 = 600+30*cos(ofGetElapsedTimef()*2.0f); float y2 = 300+100*sin(ofGetElapsedTimef()); float x3 = 650; float y3 = 300; ofFill(); ofSetHexColor(0xFF9933); ofBeginShape(); ofVertex(x0,y0); ofBezierVertex(x1,y1,x2,y2,x3,y3); ofEndShape(); ofEnableAlphaBlending(); ofFill(); ofSetColor(0,0,0,40); ofDrawCircle(x0,y0,4); ofDrawCircle(x1,y1,4); ofDrawCircle(x2,y2,4); ofDrawCircle(x3,y3,4); ofDisableAlphaBlending(); //------(h)-------------------------------------- // // holes / ofNextContour // // with ofNextContour we can create multi-contour shapes // this allows us to draw holes, for example... // ofFill(); ofSetHexColor(0xd3ffd3); ofDrawRectangle(80,480,140,70); ofSetHexColor(0xff00ff); ofBeginShape(); ofVertex(100,500); ofVertex(180,550); ofVertex(100,600); ofNextContour(true); ofVertex(120,520); ofVertex(160,550); ofVertex(120,580); ofEndShape(true); //------------------------------------- //------(i)-------------------------------------- // // CSG / ofNextContour // // with different winding rules, you can even use ofNextContour to // perform constructive solid geometry // // be careful, the clockwiseness or counter clockwisenss of your multiple // contours matters with these winding rules. // // for csg ideas, see : http://glprogramming.com/red/chapter11.html // // info about the winding rules is here: // http://glprogramming.com/red/images/Image128.gif // ofNoFill(); ofPushMatrix(); ofSetPolyMode(OF_POLY_WINDING_ODD); ofBeginShape(); ofVertex(300,500); ofVertex(380,550); ofVertex(300,600); ofNextContour(true); for (int i = 0; i < 20; i++){ float anglef = ((float)i / 19.0f) * TWO_PI; float x = 340 + 30 * cos(anglef); float y = 550 + 30 * sin(anglef); ofVertex(x,y); radius += radiusAdder; } ofEndShape(true); ofTranslate(100,0,0); ofSetPolyMode(OF_POLY_WINDING_NONZERO); ofBeginShape(); ofVertex(300,500); ofVertex(380,550); ofVertex(300,600); ofNextContour(true); for (int i = 0; i < 20; i++){ float anglef = ((float)i / 19.0f) * TWO_PI; float x = 340 + 30 * cos(anglef); float y = 550 + 30 * sin(anglef); ofVertex(x,y); radius += radiusAdder; } ofEndShape(true); ofTranslate(100,0,0); ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO); ofBeginShape(); ofVertex(300,500); ofVertex(380,550); ofVertex(300,600); ofNextContour(true); for (int i = 0; i < 20; i++){ float anglef = ((float)i / 19.0f) * TWO_PI; float x = 340 + 30 * cos(anglef); float y = 550 + 30 * sin(anglef); ofVertex(x,y); radius += radiusAdder; } ofEndShape(true); ofPopMatrix(); //------------------------------------- ofSetHexColor(0x000000); ofDrawBitmapString("(a) star\nwinding rule odd", 20,210); ofSetHexColor(0x000000); ofDrawBitmapString("(b) star\nwinding rule nonzero", 220,210); ofSetHexColor(0x000000); ofDrawBitmapString("(c) dynamically\ncreated shape", 420,210); ofSetHexColor(0x000000); ofDrawBitmapString("(d) random points\npoly", 670,210); ofSetHexColor(0x000000); ofDrawBitmapString("(e) fun with sin/cos", 20,410); ofSetHexColor(0x000000); ofDrawBitmapString("(f) ofCurveVertex\nuses catmull rom\nto make curved shapes", 220,410); ofSetHexColor(0x000000); ofDrawBitmapString("(g) ofBezierVertex\nuses bezier to draw curves", 460,410); ofSetHexColor(0x000000); ofDrawBitmapString("(h) ofNextContour\nallows for holes", 20,610); ofSetHexColor(0x000000); ofDrawBitmapString("(i) ofNextContour\ncan even be used for CSG operations\nsuch as union and intersection", 260,620); renderFbo.end(); //Now draw to the screen renderFbo.draw(0,0); // Write the frame rate in green ofSetHexColor(0x00ff00); ofDrawBitmapString("Fps: " + ofToString( ofGetFrameRate()), 15,15); ofSetHexColor(0xffffff); uint64_t t = ofGetElapsedTimeMicros(); //recorder.draw(renderFbo); c.writeframe(); //ofLogNotice()<< "time recorder ="<< (ofGetElapsedTimeMicros() - t) / 1000.0<< " ms"; }
float baseScene::getElapsedTimef(){ return (ofGetElapsedTimeMicros() - startTime)/1000000.; }
//-------------------------------------------------------------- void testApp::drawPointCloud(){ //=================================================== //DEEP MEDITATION MODE=============================== //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ //=================================================== if(meditationLevel >= 80){ ofVboMesh mesh; mesh.setUsage(GL_DYNAMIC_DRAW); mesh.setMode(OF_PRIMITIVE_POINTS); mesh.getNormals().resize(5000,ofVec3f(0)); int w = 640; int h = 480; int i = 0; float t = (ofGetElapsedTimef()) * 0.9f; vector<target> targets; for(int y=0;y<h;y+=step){ for(int x=0;x<w;x+=step){ if(kinect.getDistanceAt(x, y) > 200 && kinect.getDistanceAt(x, y) < 1300){ mesh.addVertex(ofVec3f(kinect.getWorldCoordinateAt(x, y))); mesh.setNormal(i,ofVec3f(particleSize+ofNoise(t+i),0,0)); i++; } } } ofPushMatrix(); ofSetColor(255); glDisable(GL_DEPTH_TEST); ofScale(-1,-1,1); ofRotateY(yangle); ofRotateZ(zangle); ofRotateX(xangle); ofTranslate(pointCloudPos); ofScale(kinectImageScale, kinectImageScale, kinectImageScale); billboardShader.begin(); ofEnablePointSprites(); texture.getTextureReference().bind(); mesh.draw(); texture.getTextureReference().unbind(); ofDisablePointSprites(); billboardShader.end(); glEnable(GL_DEPTH_TEST); ofPopMatrix(); //=================================================== //LOW MEDITATION MODE=============================== //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ //=================================================== }else{ ofVboMesh mesh; mesh.setUsage(GL_DYNAMIC_DRAW); mesh.setMode(OF_PRIMITIVE_POINTS); int w = 640; int h = 480; //Get original data from kinect and strore them into 'targets' vector<target> targets; for(int y=0;y<h;y+=step){ for(int x=0;x<w;x+=step){ if(kinect.getDistanceAt(x, y) > 200 && kinect.getDistanceAt(x, y) < 1300){ targets.push_back(ofVec3f(kinect.getWorldCoordinateAt(x, y))); //arrange all of the particle to the correct position in the first time so they won't seek the same target... if(firstRun == false){ ps.push_back(ofVec3f(kinect.getWorldCoordinateAt(x, y))); } } } } firstRun = true; //compare the amount between our Particle Vector and all kinect particles while(targets.size() > ps.size()){ ps.push_back(ofVec3f(ofRandom(-300,300), ofRandom(-300,300) , 800)); } //set normals mesh.getNormals().resize(ps.size(),ofVec3f(0)); //===============SET TARGETS=============== for(int i=0;i<ps.size();i++){ //=========== if meditationlevel is too low, make particles move totally randomly ====== if (meditationLevel < 15) { if(ofGetFrameNum()%20==0){ ps[i].seek(ofVec3f( ofRandom(-6000,6000),ofRandom(-6000,6000),ofRandom(-6000,6000) ) ); } ps[i].update(); }else{ float minDistance = 1000000; float index = 0; for(int b=0;b<targets.size();b++){ if(targets[b].choosen==false){ float distance; distance = ps[i].location.distance(targets[b].location); if(distance < minDistance){ minDistance = distance; index = b; } } } ps[i].seek(targets[index].location + ofVec3f( ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1), ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1), ofNoise(ofGetElapsedTimef()) * 2000 * ofMap(meditationLevel, 15, 80, 1, 0) * ofRandom(-1,1) ) ); ps[i].target_assigned = true; targets[index].choosen = true; ps[i].update(); //adjust movement parameter based on Meditation Level if(meditationLevel > 60){ ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) * 2; ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 10; }else if(meditationLevel > 40 && meditationLevel <= 60){ ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) * 1; ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 7; }else if(meditationLevel >= 15){ ps[i].maxforce = ofNoise(ofGetElapsedTimeMicros()) / 2 ; ps[i].maxspeed = ofNoise(ofGetElapsedTimeMicros()) * 16; }else{ if(ofGetFrameNum()%50==0){ ps[i].maxforce = ofRandom(-0.01,0.1); ps[i].maxspeed = ofRandom(1,3); } } } mesh.addVertex(ps[i].getPosition()); mesh.setNormal(i,ofVec3f(particleSize+ofNoise(ofGetElapsedTimef()+i),0,0)); i++; } //==================JUST DRAW=============== ofPushMatrix(); ofPushStyle(); ofSetColor(255); //point one flip function... // ofScale(1,-1,1); glDisable(GL_DEPTH_TEST); ofScale(-1, -1,1); ofRotateY(yangle); ofRotateZ(zangle); ofRotateX(xangle); ofTranslate(pointCloudPos); ofScale(kinectImageScale, kinectImageScale, kinectImageScale); billboardShader.begin(); ofEnablePointSprites(); texture.getTextureReference().bind(); mesh.draw(); texture.getTextureReference().unbind(); ofDisablePointSprites(); billboardShader.end(); glEnable(GL_DEPTH_TEST); ofPopStyle(); ofPopMatrix(); } }
void threadedSerial::sendOSC(int ID, bool resetFlags) { int i, j; char tempBuf[20]; // The standard mode if( (senderMode[ID] & 1) == 1) { // Keys ------------------------ systemTimestamp = ofGetElapsedTimeMillis(); if(sendFullFrame) { m[0].clear(); m[0].setAddress( "/sabre/dataframe" ); // timestamp server m[0].addStringArg( "begin" ); sender[ID].sendMessage( m[0] ); } m[1].clear(); m[1].setAddress( timestampAddressServer ); // timestamp server m[1].addIntArg( deltaTimeL ); m[1].addIntArg( deltaTimeR ); m[1].addIntArg( systemTimestamp ); m[2].clear(); m[2].setAddress( timestampAddressLeft ); // timestamp Left m[2].addIntArg( timestampLeft ); m[3].clear(); m[3].setAddress( timestampAddressRight ); // timestamp Right m[3].addIntArg( timestampRight ); m[4].clear(); m[4].setAddress( timestampAddressAir ); // timestamp m[4].addIntArg( timestampAir ); m[5].clear(); m[5].setAddress( airaddresses[0] ); // air pressure m[5].addFloatArg( airValue.continuous); m[6].clear(); m[6].setAddress( airaddresses[1] ); // air temperature m[6].addFloatArg( air[1]); // send first batch for(i = 1; i < 7; i++) { sender[ID].sendMessage( m[i] ); } if(keycodeChanged) { // keycode m[7].clear(); m[7].setAddress( keycodeaddress ); m[7].addIntArg( keycode ); sender[ID].sendMessage( m[7] ); if(resetFlags) { keycodeChanged = false; } if(validMidiNote) { m[8].clear(); // midinote derived from keycode m[8].setAddress( midinoteaddress ); m[8].addIntArg( midinote ); sender[ID].sendMessage( m[8] ); } } for(i = 9, j = 2; i < 12; i++, j--) { // buttons if(buttonChanged[j]) { m[i].clear(); m[i].setAddress( buttonaddresses[j] ); m[i].addIntArg( button[j] ); if(resetFlags) { buttonChanged[j] = false; } sender[ID].sendMessage( m[i] ); } } for(i = 12, j = 0; i < 37; i++, j++) { // binary key values if(keys[j].binaryChanged) { m[i].clear(); m[i].setAddress( keys[j].oscaddress+"/down"); m[i].addIntArg( keys[j].binary ); if(resetFlags) { keys[j].binaryChanged = false; } sender[ID].sendMessage( m[i] ); } } for(i = 37, j = 0; i < 62; i++, j++) { // continuous key values if(keys[j].changed) { m[i].clear(); m[i].setAddress( keys[j].oscaddress+"/continuous"); m[i].addFloatArg( keys[j].continuous ); if(!sendRawValues && resetFlags) { keys[j].changed = false; } sender[ID].sendMessage( m[i] ); } } if(sendRawValues) { for(i = 62, j = 0; i < 87; i++, j++) { // raw key values if(keys[j].changed) { m[i].clear(); m[i].setAddress( keys[j].oscaddress+"/raw"); m[i].addIntArg( keys[j].raw ); if(resetFlags) { keys[j].changed = false; } sender[ID].sendMessage( m[i] ); } } } // IMU ------------------------ m[87].clear(); m[87].setAddress( imuaddresses[0] ); // IMU accelero scaled m[87].addFloatArg( IMU[0] ); m[87].addFloatArg( IMU[1] ); m[87].addFloatArg( IMU[2] ); m[88].clear(); m[88].setAddress( imuaddresses[1] ); // IMU gyro scaled m[88].addFloatArg( IMU[3] ); m[88].addFloatArg( IMU[4] ); m[88].addFloatArg( IMU[5] ); m[89].clear(); m[89].setAddress( imuaddresses[2] ); // IMU magneto scaled m[89].addFloatArg( IMU[6] ); m[89].addFloatArg( IMU[7] ); m[89].addFloatArg( IMU[8] ); m[90].clear(); m[90].setAddress( imuaddresses[6] ); // IMU accelero summed m[90].addFloatArg( summedIMU[0] ); m[91].clear(); m[91].setAddress( imuaddresses[7] ); // IMU gyro summed m[91].addFloatArg( summedIMU[1] ); m[92].clear(); m[92].setAddress( imuaddresses[8] ); // IMU magneto summed m[92].addFloatArg( summedIMU[2] ); m[93].clear(); m[93].setAddress( imuaddresses[10] ); // IMU heading from accelerometer m[93].addFloatArg( heading ); m[94].clear(); m[94].setAddress( imuaddresses[11] ); // IMU tilt from accelerometer m[94].addFloatArg( tilt ); m[95].clear(); m[95].setAddress( imuaddresses[9] ); // IMU temperature in degreee celsius m[95].addFloatArg( IMU[9] ); for(i = 87; i < 96; i++) { sender[ID].sendMessage( m[i] ); } if(sendRawValues) { m[96].clear(); m[96].setAddress( imuaddresses[3] ); // IMU accelero raw m[96].addFloatArg( rawIMU[0] ); m[96].addFloatArg( rawIMU[1] ); m[96].addFloatArg( rawIMU[2] ); m[97].clear(); m[97].setAddress( imuaddresses[4] ); // IMU gyro raw m[97].addFloatArg( rawIMU[3] ); m[97].addFloatArg( rawIMU[4] ); m[97].addFloatArg( rawIMU[5] ); m[98].clear(); m[98].setAddress( imuaddresses[5] ); // IMU magneto raw m[98].addFloatArg( rawIMU[6] ); m[98].addFloatArg( rawIMU[7] ); m[98].addFloatArg( rawIMU[8] ); for(i = 96; i < 99; i++) { sender[ID].sendMessage( m[i] ); } } m[99].clear(); m[99].setAddress( batteryAddressAir ); // air battery m[99].addIntArg( batteryLevelAir); m[100].clear(); m[100].setAddress( linkQualityAddressAir ); // air link quality m[100].addIntArg( linkQualityAir); m[101].clear(); m[101].setAddress( linkQualityAddressLeft ); // left link quality m[101].addIntArg( linkQualityLeft ); m[102].clear(); m[102].setAddress( linkQualityAddressRight ); // right link quality m[102].addIntArg( linkQualityRight ); m[103].clear(); m[103].setAddress( batteryAddressMain ); // battery level main m[103].addIntArg( batteryLevelRight ); for(i = 99; i < 104; i++) { sender[ID].sendMessage( m[i] ); } if(sendFullFrame) { m[104].clear(); m[104].setAddress( "/sabre/dataframe" ); // timestamp server m[104].addStringArg( "end" ); sender[ID].sendMessage( m[104] ); } } // Gerhard Eckels direct SC-server Mode if( ((senderMode[ID] >> 4) & 1) == 1){ m[0].clear(); m[0].setAddress( "/c_setn" ); // SC server command m[0].addIntArg( 0 ); // SC server Bus Nr. m[0].addIntArg( 26 ); // SC server NumArgs if(sendRawValues == 0){ m[0].addFloatArg( airValue.continuous); for(i = 0; i < 25; i++){ m[0].addFloatArg( keys[i].continuous ); } }else if(sendRawValues == 1){ m[0].addFloatArg( airValue.relative); for(i = 0; i < 25; i++){ m[0].addIntArg( keys[i].raw ); } } sender[ID].sendMessage( m[0] ); } if(dLhParsing) { dLhStopT = ofGetElapsedTimeMicros(); printf("LH time: %01.03f ms\n\n", ((float)(dLhStopT - dLhStartT)/1000)); sprintf(tempBuf, "%lld", (dLhStopT-dLhStartT)); dBuffer.append(tempBuf); dBuffer.append(";\n"); dLhStartT = 0; dLhStopT = 0; dLhParsing = false; } if(dRhParsing) { dRhStopT = ofGetElapsedTimeMicros(); printf("RH time: %01.03f ms\n\n", ((float)(dRhStopT - dRhStartT)/1000)); sprintf(tempBuf, "%lld", (dRhStopT-dRhStartT)); dBuffer.append(tempBuf); dBuffer.append(";\n"); dRhStartT = 0; dRhStopT = 0; dRhParsing = false; } if(dAmParsing) { dAmStopT = ofGetElapsedTimeMicros(); printf("aM time: %01.03f ms\n\n", ((float)(dAmStopT - dAmStartT)/1000)); sprintf(tempBuf, "%lld", (dAmStopT-dAmStartT)); dBuffer.append(tempBuf); dBuffer.append(";\n"); dAmStartT = 0; dAmStopT = 0; dAmParsing = false; } return; }