MixAudioSource

@RequiresApi(value = 29)
class MixAudioSource(mediaProjection: MediaProjection, microphoneAudioSource: Int = MediaRecorder.AudioSource.DEFAULT) : AudioSource

Mix microphone and internal audio sources in one source to allow send both at the same time. NOTES: Recommended configure prepareAudio with: echoCanceler = true, noiseSuppressor = true This is to avoid echo in microphone track.

Recommended increase microphone volume to 2f, because the internal audio normally is higher and you can't hear audio track properly.

Tested in 2 devices (Android 12 and Android 14). This could change depend of the model or not, I'm not sure: MediaRecorder.AudioSource.DEFAULT, MediaRecorder.AudioSource.MIC -> If other app open the microphone you receive buffers with silence from the microphone until the other app release the microphone (maybe you need close the app). MediaRecorder.AudioSource.CAMCORDER -> Block the access to microphone to others apps. Others apps can't instantiate the microphone. MediaRecorder.AudioSource.VOICE_COMMUNICATION -> Block the access to microphone to others apps. Others apps can instantiate the microphone but receive buffers with silence from the microphone.

Constructors

Link copied to clipboard
constructor(mediaProjection: MediaProjection, microphoneAudioSource: Int = MediaRecorder.AudioSource.DEFAULT)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun init(sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun isRunning(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun release()
Link copied to clipboard
open override fun start(getMicrophoneData: GetMicrophoneData)
Link copied to clipboard
open override fun stop()
Link copied to clipboard
Link copied to clipboard