//-------------------------------------------------------------- void Device::update(float dt) { checkForActivity(dt); if (mp_soundInput) { // Update sound data mp_soundInput->update(); // If stand by, send our own packets if (m_stateStandby == EStandby_standby) { generateSampleStandBy(dt); sampleStandbyInput(); } // sample else { // Sample them and writes into packet sampleSoundInput(); } // Send packets / values to network sendPacketsOSC(); } }
//-------------------------------------------------------------- void DeviceEcho::update(float dt) { // Parent //Device::update(dt); checkForActivity(dt); bool isSample = false; if (m_isDebugSinewave) { if (mp_soundInput) { int nbVolHistory = mp_soundInput->getVolHistory().size(); float value=0.0f; float phase = 0.0f; for (int i=0;i<nbVolHistory;i++) { value = 0.5f*(1.0f+sin( ofDegToRad(m_isDebugSinewaveAngle-phase) )); mp_soundInput->setVolHistoryValue(i, value); phase+= 360.0f / float(nbVolHistory-1); } m_isDebugSinewaveAngle += 0.5f; isSample = true; } } else { if (mp_soundInput) { mp_soundInput->update(); isSample = true; } } if(isSample) { // Sample them and writes into packet sampleSoundInput(); // Send packets / values to network sendPacketsOSC(); } }
//-------------------------------------------------------------- void Device::update(float dt) { checkForActivity(dt); updateBPM(dt); if (mp_soundInput) { // Update sound data mp_soundInput->update(); // Sample them and writes into packet sampleSoundInput(); // Send packets / values to network sendPacketsOSC(); } }
static int system_starter(Action anAction, const char *aService_cstr) { CFStringRef aService = NULL; NSSearchPathDomainMask aMask; if (aService_cstr) aService = CFStringCreateWithCString(kCFAllocatorDefault, aService_cstr, kCFStringEncodingUTF8); StartupContext aStartupContext = (StartupContext) malloc(sizeof(struct StartupContextStorage)); if (!aStartupContext) { syslog(LOG_ERR, "Not enough memory to allocate startup context"); return (1); } if (gDebugFlag && gNoRunFlag) sleep(1); /** * Get a list of Startup Items which are in /Local and /System. * We can't search /Network yet because the network isn't up. **/ aMask = NSSystemDomainMask | NSLocalDomainMask; aStartupContext->aWaitingList = StartupItemListCreateWithMask(aMask); aStartupContext->aFailedList = NULL; aStartupContext->aStatusDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); aStartupContext->aServicesCount = 0; aStartupContext->aRunningCount = 0; if (aService) { CFMutableArrayRef aDependentsList = StartupItemListCreateDependentsList(aStartupContext->aWaitingList, aService, anAction); if (aDependentsList) { CFRelease(aStartupContext->aWaitingList); aStartupContext->aWaitingList = aDependentsList; } else { CF_syslog(LOG_ERR, CFSTR("Unknown service: %@"), aService); return (1); } } aStartupContext->aServicesCount = StartupItemListCountServices(aStartupContext->aWaitingList); /** * Do the run loop **/ while (1) { CFMutableDictionaryRef anItem = StartupItemListGetNext(aStartupContext->aWaitingList, aStartupContext->aStatusDict, anAction); if (anItem) { int err = StartupItemRun(aStartupContext->aStatusDict, anItem, anAction); if (!err) { ++aStartupContext->aRunningCount; MonitorStartupItem(aStartupContext, anItem); } else { /* add item to failed list */ AddItemToFailedList(aStartupContext, anItem); /* Remove the item from the waiting list. */ RemoveItemFromWaitingList(aStartupContext, anItem); } } else { /* * If no item was selected to run, and if no items * are running, startup is done. */ if (aStartupContext->aRunningCount == 0) { syslog(LOG_DEBUG, "none left"); break; } /* * Process incoming IPC messages and item * terminations */ switch (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 3.0, true)) { case kCFRunLoopRunTimedOut: checkForActivity(aStartupContext); break; case kCFRunLoopRunFinished: break; case kCFRunLoopRunStopped: break; case kCFRunLoopRunHandledSource: break; default: /* unknown return value */ break; } } } /** * Good-bye. **/ displayErrorMessages(aStartupContext, anAction); /* clean up */ if (aStartupContext->aStatusDict) CFRelease(aStartupContext->aStatusDict); if (aStartupContext->aWaitingList) CFRelease(aStartupContext->aWaitingList); if (aStartupContext->aFailedList) CFRelease(aStartupContext->aFailedList); free(aStartupContext); return (0); }