-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundManager.pde
48 lines (37 loc) · 1.08 KB
/
SoundManager.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import android.media.MediaRecorder;
import android.media.MediaPlayer;
import android.os.Environment;
import android.content.Context;
class SoundManager {
private MediaRecorder src;
private void recInit()throws IOException {
src = new MediaRecorder();
src.setAudioSource(MediaRecorder.AudioSource.VOICE_RECOGNITION);
src.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
src.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
src.setOutputFile(Environment.getExternalStorageDirectory().getPath()+"/flier_aux.3gp");
src.prepare();
isInitialized = true;
}
private boolean isWorking = false;
private boolean isInitialized = false;
public boolean isWorking(){
return isWorking;
}
public void start()throws IOException{
if(!isInitialized) recInit();
src.start();
isWorking = true;
}
public int getSoundValue(){
int result = src.getMaxAmplitude();
println("Sound is " + result);
return result;
}
public void stop(){
src.stop();
}
public SoundManager() throws IOException{
recInit();
}
};