So im trying to make it so you can talk into the mic and have the output played at the same time, kind of like a microphone connected to a speaker. I have all the buffer stuff and all that figured out. My app still crashes and Log says I'm trying to call startRecording on an uninitialized AudioRecord.
I don't understand because it is clearly initialized. Does anyone have any clue as to what is wrong????
Code:
[LEFT]public void setRecorder() throws IllegalArgumentException
{
int minBuffer = AudioRecord.getMinBufferSize(sampleRate,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);
int bufferSize = minBuffer + 1000;[/LEFT]
[LEFT][B]AudioRecord micr[/B] = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT,
bufferSize);[/LEFT]
[LEFT]AudioTrack micp = new AudioTrack(AudioManager.STREAM_MUSIC,
sampleRate,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
bufferSize,
AudioTrack.MODE_STREAM);[/LEFT]
[LEFT]micp.setPlaybackRate(sampleRate);
byte[] buffer = new byte[bufferSize];
[B]micr.startRecording(); [/B]// THis is whats causing the error
micp.play();
while (isRecording)
{
micr.read(buffer, 0, bufferSize);
micp.write(buffer, 0, bufferSize);
}[/LEFT]
}