SoundplaneModel::SoundplaneModel() : mDeviceState(kNoDevice), mOutputEnabled(false), mSurface(kSoundplaneWidth, kSoundplaneHeight), mpDriver(0), mRawSignal(kSoundplaneWidth, kSoundplaneHeight), mCalibratedSignal(kSoundplaneWidth, kSoundplaneHeight), mTempSignal(kSoundplaneWidth, kSoundplaneHeight), mCookedSignal(kSoundplaneWidth, kSoundplaneHeight), mTestSignal(kSoundplaneWidth, kSoundplaneHeight), mCalibrating(false), mSelectingCarriers(false), mDynamicCarriers(true), mCalibrateSum(kSoundplaneWidth, kSoundplaneHeight), mCalibrateMean(kSoundplaneWidth, kSoundplaneHeight), mCalibrateMeanInv(kSoundplaneWidth, kSoundplaneHeight), mCalibrateStdDev(kSoundplaneWidth, kSoundplaneHeight), // mNotchFilter(kSoundplaneWidth, kSoundplaneHeight), mLopassFilter(kSoundplaneWidth, kSoundplaneHeight), // mHasCalibration(false), // mZoneMap(kSoundplaneAKeyWidth, kSoundplaneAKeyHeight), mHistoryCtr(0), mProcessThread(0), mLastTimeDataWasSent(0), mZoneModeTemp(0), mCarrierMaskDirty(false), mNeedsCarriersSet(true), mNeedsCalibrate(true), mLastInfrequentTaskTime(0), mCarriersMask(0xFFFFFFFF), // //mOSCListenerThread(0), //mpUDPReceiveSocket(nullptr), mTest(0), mKymaIsConnected(0), mTracker(kSoundplaneWidth, kSoundplaneHeight) { // setup geometry mSurfaceWidthInv = 1.f / (float)mSurface.getWidth(); mSurfaceHeightInv = 1.f / (float)mSurface.getHeight(); // setup fixed notch mNotchFilter.setSampleRate(kSoundplaneSampleRate); mNotchFilter.setNotch(300., 0.1); // setup fixed lopass. mLopassFilter.setSampleRate(kSoundplaneSampleRate); mLopassFilter.setLopass(50, 0.707); for(int i=0; i<kSoundplaneMaxTouches; ++i) { mCurrentKeyX[i] = -1; mCurrentKeyY[i] = -1; } mTracker.setSampleRate(kSoundplaneSampleRate); // setup default carriers in case there are no saved carriers for (int car=0; car<kSoundplaneSensorWidth; ++car) { mCarriers[car] = kModelDefaultCarriers[car]; } clearZones(); setAllPropertiesToDefaults(); mTracker.setListener(this); // set up view modes map mViewModeToSignalMap["raw data"] = &mRawSignal; mViewModeToSignalMap["calibrated"] = &mCalibratedSignal; mViewModeToSignalMap["cooked"] = &mCookedSignal; mViewModeToSignalMap["xy"] = &mCalibratedSignal; mViewModeToSignalMap["test1"] = &mTestSignal; mViewModeToSignalMap["test2"] = &(mTracker.getNormalizeMap()); mViewModeToSignalMap["norm. map"] = &(mTracker.getNormalizeMap()); }
//-------------------------------------------------------------- void testApp::keyPressed (int key) { switch (key) { case ' ': ready = !ready; break; case 'b': bLearnBackground = true; break; case 'a': marksOpen=!marksOpen; if(!marksOpen) addNewZone(); break; case 'D': clearZones(); break; case 'o': kinect.setCameraTiltAngle(angle); // go back to prev tilt kinect.open(); break; case 'c': kinect.setCameraTiltAngle(0); // zero the tilt kinect.close(); break; case OF_KEY_UP: angle++; if(angle>30) angle=30; kinect.setCameraTiltAngle(angle); break; case OF_KEY_DOWN: angle--; if(angle<-30) angle=-30; kinect.setCameraTiltAngle(angle); break; case 'w': farThreshold+=20.; //5cm break; case 's': farThreshold-=20.; //5cm break; case 'e': nearThreshold+=20.; //5cm break; case 'd': nearThreshold-=20.; //5cm break; case 'n': touchDiffFarThreshold-=0.5; break; case 'm': touchDiffFarThreshold+=0.5; break; case 'k': touchDiffNearThreshold-=0.5; break; case 'l': touchDiffNearThreshold+=0.5; break; } }