Android通过摇晃手机的频率来控制声音的频率(2)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:49 点击:次
40 if (!isPlaying) {
41 Log.i(TAG, "sm.play(1, 0, 1.0f);");
42 sm.play(1, 0, 1.0f);
43 }
44 last_x = event.values[SensorManager.DATA_X];
45 last_y = event.values[SensorManager.DATA_Y];
46 last_z = event.values[SensorManager.DATA_Z];
47 return;
48 }
49 lastUpdate = curTime;
50 x = event.values[SensorManager.DATA_X];
51 y = event.values[SensorManager.DATA_Y];
52 z = event.values[SensorManager.DATA_Z];
53 curTime = System.currentTimeMillis();
54 // 每100毫秒检测一次
55 float deltaForce = Math.abs(x + y + z - last_x - last_y - last_z);
56 force = force + deltaForce;
57 updateAudioRate(deltaForce);
58 if (count >= SHAKE_THRESHOLD) {
59 Log.i(TAG, "unSensorListener");
60 // onShakeCallBack(force / count); get the score
61 unSensorListener();
62 if (isPlaying) {
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>