I am trying to analyze internal audio from android system to know wave amplitude of the sound that is being played at the moment. I start playing the audio on the device and after more or less four seconds the apps gets the sound that was playing. I think that the problem could start with the priority of my app on the system that cannot get audio on real time or closer to it.
I am using the AudioRecord
from android
internalRecorder = AudioRecord.Builder()
.setAudioFormat(audioFormat)
.setBufferSizeInBytes(124800)
.setAudioPlaybackCaptureConfig(config)
.build()
and the config:
val config = AudioPlaybackCaptureConfiguration.Builder(mediaProjection!!)
.addMatchingUsage(AudioAttributes.USAGE_MEDIA)
.addMatchingUsage(AudioAttributes.USAGE_UNKNOWN)
.addMatchingUsage(AudioAttributes.USAGE_GAME)
.build()
I have tried to make an accessibility service but this not improve the performance. The audio buffer is having seconds of delay.