# MixAudioSource

@RequiresApi(value = 29)
class MixAudioSource(mediaProjection: MediaProjection, mediaProjectionCallback: MediaProjection.Callback? = null, microphoneAudioSource: Int = MediaRecorder.AudioSource.DEFAULT) : AudioSource, GetMicrophoneData

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

MixAudioSource
Link copied to clipboard
constructor(mediaProjection: MediaProjection, mediaProjectionCallback: MediaProjection.Callback? = null, microphoneAudioSource: Int = MediaRecorder.AudioSource.DEFAULT)

## Properties

created
Link copied to clipboard
var created: Boolean
echoCanceler
Link copied to clipboard
var echoCanceler: Boolean
internalVolume
Link copied to clipboard
var internalVolume: Float
isStereo
Link copied to clipboard
var isStereo: Boolean
microphoneVolume
Link copied to clipboard
var microphoneVolume: Float
mixVolume
Link copied to clipboard
var mixVolume: Float
noiseSuppressor
Link copied to clipboard
var noiseSuppressor: Boolean
sampleRate
Link copied to clipboard
var sampleRate: Int

## Functions

init
Link copied to clipboard
fun init(sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean
inputPCMData
Link copied to clipboard
open override fun inputPCMData(frame: Frame)
isMuted
Link copied to clipboard
fun isMuted(): Boolean
isRunning
Link copied to clipboard
open override fun isRunning(): Boolean
mute
Link copied to clipboard
fun mute()
release
Link copied to clipboard
open override fun release()
setAudioEffect
Link copied to clipboard
fun setAudioEffect(effect: CustomAudioEffect)
setPreferredDevice
Link copied to clipboard
fun setPreferredDevice(deviceInfo: AudioDeviceInfo?): Boolean
start
Link copied to clipboard
open override fun start(getMicrophoneData: GetMicrophoneData)
stop
Link copied to clipboard
open override fun stop()
unMute
Link copied to clipboard
fun unMute()