- /* Analyse signal within the symbol length */\r
- /* Decide if we crossed a zero */\r
- if (GraphBuffer[i]*sign < 0) {\r
- /* Crossed a zero, check if this is a ripple or not */\r
- if ( (i-t1) > n/4 ) {\r
- sign = -sign;\r
- t1=i;\r
- if (GraphBuffer[i]*c > 0){\r
- GraphBuffer[i]=1;\r
- } else {\r
- GraphBuffer[i]=0;\r
- }\r
- } else {\r
- /* This is a ripple, set the current sample value\r
- to the same as previous */\r
- GraphBuffer[i] = GraphBuffer[i-1];\r
- }\r
+ /* Transitions are detected at each peak\r
+ * Transitions are either:\r
+ * - we're low: transition if we hit a high\r
+ * - we're high: transition if we hit a low\r
+ * (we need to do it this way because some tags keep high or\r
+ * low for long periods, others just reach the peak and go\r
+ * down)\r
+ */\r
+ if ((GraphBuffer[i]==high) && (GraphBuffer[i-1] == c)) {\r
+ GraphBuffer[i]=1-c;\r
+ } else if ((GraphBuffer[i]==low) && (GraphBuffer[i-1] == (1-c))){\r
+ GraphBuffer[i] = c;\r