7

I'm looking for a way to combine audio recorded from the device microphone with the sound that the device is playing.

Now you might say that it's an easy task, the microphone can record both BUT that's not the case because the audio that the device is playing is played to the headphone jack instead of the speakers.

Is there any way to do this?

ori888
  • 740
  • 1
  • 8
  • 17
  • Please take a look at this http://stackoverflow.com/questions/17676142/record-android-audio-output – darwin Apr 26 '16 at 08:58
  • Is the audio that you want to mix your microphone sound with played by your app only? if so then you can mux two stream digitally. If you want to mix microphone sound with other app's sound that is being played via headset speaker then i don't think there is a way. – Ankit Mar 08 '17 at 09:30

1 Answers1

2

I don't understand what you want. if you are talking about recording input source there are various source android OS provide to you such as MIC, DOWNLINK/Headphone speaker CAMCORDER etc...

Source Sode From android developer site

private void startRecording() {
        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mRecorder.setOutputFile(mFileName);
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

        try {
            mRecorder.prepare();
        } catch (IOException e) {
            Log.e(LOG_TAG, "prepare() failed");
        }

        mRecorder.start();
    }
Attaullah
  • 3,856
  • 3
  • 48
  • 63
  • I think he wants to record what the device is sending out. Kind of a loopback. – f.khantsis Apr 26 '16 at 10:38
  • if recording for sending out then use MediaRecorder.AudioSource.VOICE_UPLINK – Attaullah Apr 26 '16 at 11:18
  • Hi Attaullah, I'm looking for a way to record the audio that the device is playing to the headset jack (not during a call, during playback of audio throughout my app). I tried running your code but VOICE_UPLINK/DOWNLINK didn't work, - always returns an error. I also tried using same source using AudioRecord but with no luck. Any ideas? thanks a lot. – ori888 May 15 '16 at 20:31
  • is It working? I tried both VOICE_UPLINK & VOICE_DOWNLINK but not worked? – Nicky Apr 04 '17 at 11:15
  • Every reference I found pointed out this solution but it never worked – ori888 Apr 28 '17 at 11:13