Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Loading...
Searching...
No Matches
processCentroids.h
1 temp = calculateCentroids(wVCentroid, wVCentroidSize, MAX_NUM_CENTROIDS, FIRST_SENSOR_V, LAST_SENSOR_V, numSensors); // Vertical centroids
2 firstActiveSensor = temp & 0xFF;
3 lastActiveSensor = temp >> 8;
4 bActivityDetected = lastActiveSensor >= 0;
5
6 temp = lastActiveSensor - (LAST_SENSOR_V - FIRST_SENSOR_V );// retrieve the (wrapped) index
7 //check for activity in the wraparound area
8 // IF the last centroid ended after wrapping around ...
9 // AND the first centroid was located before the end of the last ...
10 if(lastActiveSensor >= LAST_SENSOR_V - FIRST_SENSOR_V
11 && (((BYTE)temp) << SLIDER_BITS) >= wVCentroid[0] )
12 {
13 // THEN the last touch is used to replace the first one
14 for(counter = MAX_NUM_CENTROIDS - 1; counter >= 1; counter--) {
15 if(0xFFFF == wVCentroid[counter])
16 continue;
17 // replace the first centroid
18 wVCentroidSize[0] = wVCentroidSize[counter];
19 wVCentroid[0] = wVCentroid[counter];
20 // wrap around the position if needed
21 if(wVCentroid[0] >= posEndOfLoop)
22 wVCentroid[0] -= posEndOfLoop;
23 // discard the last centroid
24 wVCentroid[counter] = 0xFFFF;
25 wVCentroidSize[counter] = 0x0;
26 break;
27 }
28 }