마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

특정 값이 증가,감소하면 사운드도 증가, 감소 하는 것을 하려고 합니다... [closed]

0 추천
int count = 0;


if (action_sound.isPlaying()) {
   //startVol();
   a[count] = RPM_value;

   int vol = a[5] / 500;

   if (count == 5) {
    if (a[0] > a[5]) {
     volDown(vol);

    } else if (a[0] < a[5]) {
     volUp(vol);
    }
    count = 0;
   }
  } else if (base_sound.isPlaying()) {
   stopVol();
  }
}


private void stopVol() {

  int currVol = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  currVol = (currVol * 0) + 6;

  audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currVol,
    AudioManager.FLAG_PLAY_SOUND);
 }

 private void volUp(int vol) {
  int currVol = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  currVol = currVol + vol;
  audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currVol,
    AudioManager.FLAG_PLAY_SOUND);

 }

 private void volDown(int vol) {

  int currVol = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  currVol = currVol - vol;
  audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currVol,
    AudioManager.FLAG_PLAY_SOUND);

 }


Handle{
    if (RPM_value > 850) {
  base_sound.pause();
  action_sound.start();
       
 } else {
  action_sound.pause();
  base_sound.start();

 }

}

RPM이 증가 할 때 볼륨 증가, 감소 하면 볼륨 감소 하는 것을 하려고 합니다.

일단 위의 소스 처럼 배열을 이용해서 값을 비교 하는 것을 하는데 사운드가 나오지 않습니다. 무엇이 문제인지....

문제점이나 다른 좋은 방법이 있는지 알려주시면 감사하겠습니다 ㅜㅜ

 

질문을 종료한 이유: 해결
안왕초보 (1,390 포인트) 님이 2014년 2월 27일 질문
안왕초보님이 2014년 3월 4일 closed
a에 무슨 값들이 들어가나요? 실제 값을 예로 들어주세용
RPM_value는 OBD 블루투스 동굴에서 나오는 값입니다.
차량의 RPM을 계속 받는 값을 a에 넣고 있는 것입니다. 위의 handle는 bluetooth read 부분입니다.
아 위의 소스에 count 증가 값을 안 넣었네요 handle  bluetooth read 부분에 count++ 도 있습니다.

1개의 답변

0 추천
코드를 잘못 봤었네요..

count == 6 이 되어야하지 않나요? 코드 흐름이 그런 의도인것 같은데..
Gioskhan (12,060 포인트) 님이 2014년 2월 27일 답변
음??count가 6이요??
허...제가 정신이 나갔는가 봅니다. int a[] = int[5]를 줘 놓고서는
a[0]하고 a[5]하고 비교문을 쓰고 있었네요 허
int vol = a[5] / 500; 이 라인에서 array index out bound 예외가 떨어졌어야 되는데 뭔가 이상하네요
...