@@ -25,14 +25,14 @@ public class VoiceRecognition {
2525 private final static int STATE_STEP1 = 1 ;
2626 private final static int STATE_STEP2 = 2 ;
2727 private final static int INDEX [] = { -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 6 , -1 , -1 , -1 , -1 , 5 , -1 , -1 , -1 , 4 , -1 , -1 , 3 , -1 , -1 , 2 , -1 , -1 , 1 , -1 , -1 , 0 };
28- private final static int MAX_CIRCLE = 31 ;
29- private final static int MIN_CIRCLE = 10 ;
28+ private final static int MAX_SAMPLING_POINT_COUNT = 31 ;
29+ private final static int MIN_SAMPLING_POINT_COUNT = 10 ;
3030
3131 private int mState ;
3232 private Listener mListener ;
3333 private Callback mCallback ;
3434
35- private int mCirclePointCount = 0 ;
35+ private int mSamplingPointCount = 0 ;
3636
3737 private int mSampleRate ;
3838 private int mChannel ;
@@ -82,7 +82,7 @@ public void start() {
8282
8383 if (null != mCallback ) {
8484 mState = STATE_START ;
85- mCirclePointCount = 0 ;
85+ mSamplingPointCount = 0 ;
8686
8787 mIsStartCounting = false ;
8888 mStep = STATE_STEP1 ;
@@ -142,100 +142,100 @@ private void process(BufferData data) {
142142 } else if (STATE_STEP2 == mStep ) {
143143 if (sh > 0 ) {
144144 mIsStartCounting = true ;
145- mCirclePointCount = 0 ;
145+ mSamplingPointCount = 0 ;
146146 mStep = STATE_STEP1 ;
147147 }
148148 }
149149 } else {
150- ++mCirclePointCount ;
150+ ++mSamplingPointCount ;
151151 if (STATE_STEP1 == mStep ) {
152152 if (sh < 0 ) {
153153 mStep = STATE_STEP2 ;
154154 }
155155 } else if (STATE_STEP2 == mStep ) {
156156 if (sh > 0 ) {
157157 // preprocess the circle
158- int circleCount = preReg (mCirclePointCount );
158+ int samplingPointCount = preReg (mSamplingPointCount );
159159
160160 // recognise voice
161- reg (circleCount );
161+ reg (samplingPointCount );
162162
163- mCirclePointCount = 0 ;
163+ mSamplingPointCount = 0 ;
164164 mStep = STATE_STEP1 ;
165165 }
166166 }
167167 }
168168 }
169169 }
170170
171- private int preReg (int circleCount ) {
172- switch (circleCount ) {
171+ private int preReg (int samplingPointCount ) {
172+ switch (samplingPointCount ) {
173173 case 8 :
174174 case 9 :
175175 case 10 :
176176 case 11 :
177177 case 12 :
178- circleCount = 10 ;
178+ samplingPointCount = 10 ;
179179 break ;
180180
181181 case 13 :
182182 case 14 :
183183 case 15 :
184184 case 16 :
185185 case 17 :
186- circleCount = 15 ;
186+ samplingPointCount = 15 ;
187187 break ;
188188
189189 case 18 :
190190 case 19 :
191191 case 20 :
192- circleCount = 19 ;
192+ samplingPointCount = 19 ;
193193 break ;
194194
195195 case 21 :
196196 case 22 :
197197 case 23 :
198- circleCount = 22 ;
198+ samplingPointCount = 22 ;
199199 break ;
200200
201201 case 24 :
202202 case 25 :
203203 case 26 :
204- circleCount = 25 ;
204+ samplingPointCount = 25 ;
205205 break ;
206206
207207 case 27 :
208208 case 28 :
209209 case 29 :
210- circleCount = 28 ;
210+ samplingPointCount = 28 ;
211211 break ;
212212
213213 case 30 :
214214 case 31 :
215215 case 32 :
216- circleCount = 31 ;
216+ samplingPointCount = 31 ;
217217 break ;
218218
219219 default :
220- circleCount = 0 ;
220+ samplingPointCount = 0 ;
221221 break ;
222222 }
223223
224- return circleCount ;
224+ return samplingPointCount ;
225225 }
226226
227- private void reg (int circleCount ) {
227+ private void reg (int samplingPointCount ) {
228228 if (!mIsBeginning ) {
229229 if (!mStartingDet ) {
230- if (MAX_CIRCLE == circleCount ) {
230+ if (MAX_SAMPLING_POINT_COUNT == samplingPointCount ) {
231231 mStartingDet = true ;
232232 mStartingDetCount = 0 ;
233233 }
234234 } else {
235- if (MAX_CIRCLE == circleCount ) {
235+ if (MAX_SAMPLING_POINT_COUNT == samplingPointCount ) {
236236 ++mStartingDetCount ;
237237
238- if (mStartingDetCount >= MIN_CIRCLE ) {
238+ if (mStartingDetCount >= MIN_SAMPLING_POINT_COUNT ) {
239239 mIsBeginning = true ;
240240 mIsRegStart = false ;
241241 mRegCount = 0 ;
@@ -246,17 +246,17 @@ private void reg(int circleCount) {
246246 }
247247 } else {
248248 if (!mIsRegStart ) {
249- if (circleCount > 0 ) {
250- mRegValue = circleCount ;
251- mRegIndex = INDEX [circleCount ];
249+ if (samplingPointCount > 0 ) {
250+ mRegValue = samplingPointCount ;
251+ mRegIndex = INDEX [samplingPointCount ];
252252 mIsRegStart = true ;
253253 mRegCount = 1 ;
254254 }
255255 } else {
256- if (circleCount == mRegValue ) {
256+ if (samplingPointCount == mRegValue ) {
257257 ++mRegCount ;
258258
259- if (mRegCount >= MIN_CIRCLE ) {
259+ if (mRegCount >= MIN_SAMPLING_POINT_COUNT ) {
260260 // ok
261261 if (mRegValue != mPreRegCircle ) {
262262 if (null != mListener ) {
0 commit comments