Android通过摇晃手机的频率来控制声音的频率(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:49 点击:次
63 sm.stop();
64 isPlaying = false;
65 }
66 count = - 2;
67 force = 0;
68 return;
69 }
70 last_x = x;
71 last_y = y;
72 last_z = z;
73 }
74 }
75
76
77 @Override
78 public void onAccuracyChanged(Sensor sensor, int accuracy) {
79 }
80
81 private void updateAudioRate(float force) {
82 float rate=0;
83 float prvAudioRate = 1;
84 audioCount =audioCount+1;
85 audioForce=audioForce+force;
86 if(audioCount>3){
87 //from 0-50 maps to 0.6 to 2
88 //rate=audioForce/audioCount*0.03+0.5;
89 //from 0-50 maps to 1 to 1.8
90 rate=(float) (audioForce/audioCount*0.012+1.0);
91 //myAlert(rate);
92 prvAudioRate=prvAudioRate+(rate-prvAudioRate)/3;
93 sm.setRate(prvAudioRate);
94 Log.i(TAG, "sm.setRate=" + prvAudioRate);
95 audioForce=0;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>