Do you mean to say, you want to record VOICE_DOWNLINK i.e. Recieved audio during voice call ? If so, you can specify the source of media as :
m_Recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);
Question
My app needs to visualize voice when a call occurs, so I registered a Service
to listen to call states.
So when onAttachedView
occurs I call my mic record class which extends Thread
and this is the run method:
public void run() {
try {
mRecordInstance.startRecording();
float splValue = 0.0f;
float rmsValue = 0.0f;
while (this.mIsRunning) {
// creating these variables here so that
// the mode change can be handled
int SIZE = BUFFSIZE;
short[] tempBuffer = new short[SIZE];
mRecordInstance.read(tempBuffer, 0, SIZE);
for (int i = 0; i < SIZE - 1; i++) {
rmsValue += tempBuffer[i] * tempBuffer[i];
}
rmsValue = rmsValue / SIZE;
rmsValue = (float) Math.sqrt(rmsValue);
splValue = (float) (20 * Math.log10(rmsValue / P0));
splValue = splValue + mCaliberationValue;
splValue = (float) round(splValue, 2);
if (mMaxValue < splValue) {
mMaxValue = splValue;
}
if (!mShowMaxValue) {
Message msg = mHandle.obtainMessage(MY_MSG, splValue);
mHandle.sendMessage(msg);
} else {
Message msg = mHandle.obtainMessage(MY_MSG, mMaxValue);
mHandle.sendMessage(msg);
Thread.sleep(2000);
msg = mHandle.obtainMessage(MAXOVER_MSG, mMaxValue);
mHandle.sendMessage(msg);
mShowMaxValue = false;
}
writeLog(splValue);
}
} catch (Exception e) {
e.printStackTrace();
Message msg = mHandle.obtainMessage(ERROR_MSG,
e.getLocalizedMessage()+"");
mHandle.sendMessage(msg);
}
if(mRecordInstance != null){
mRecordInstance.stop();
mRecordInstance.release();
mRecordInstance = null;
}
}
This class sends a message via handler to the class that visualize the voice. it works great when off call a circle is drawn by the voice decibel level.
When I am in call I don't receive mic input. Any ideas?
Solution
Do you mean to say, you want to record VOICE_DOWNLINK i.e. Recieved audio during voice call ? If so, you can specify the source of media as :
m_Recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);