Get the amplitude of the sound using source / object / streamType

Can someone help me find some way to find the amplitude of another audio player in the app? I need to know the amplitude of the videoCall sound in my application.

An example in my application I have a videoPlayer (youtube) and videoCall function. Therefore, when I receive videoCall, I need to slow down / stop the sound of the video player when someone speaks on videoCall. Is there any way to find this?

I found a way to get the amplitude of the phone audioPlayer, but this provides the amplitude of playback of all kinds of audio in the application without sending a source identifier or streamType ( MUSIC_STREAMor CALL_STREAM) or any other thing with which I can identify the source of a given amplitude, such as its player or video cards.

This will only help if I provided the audioSessionId AudioPlayer in Visualizer (audioSessionId), but I cannot get the audioSessionId of any player (videoCall, youtube) due to ThirdPartySDK.

private void createVisualizer(){
    int rate = Visualizer.getMaxCaptureRate();
    Visualizer audioOutput = new Visualizer(0); //  get output audio stream
    audioOutput.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
        @Override
        public void onWaveFormDataCapture(Visualizer visualizer, byte[] waveform, int samplingRate) {
            float intensity = ((float) waveform[0] + 128f) / 256;
            Log.d("visualizer = ", "visualizer = "+visualizer+ "visualizer = "+String.valueOf(intensity));
        }

        @Override
        public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {

        }
    },rate , true, false); // waveform not freq data
    Log.d("rate", String.valueOf(Visualizer.getMaxCaptureRate()));
    audioOutput.setEnabled(true);
}

Any suggestion would be helpful, thanks in advance.

+4
source share
1 answer

I found a solution, the SDK that I used for VideoCall provides the entire voice level of the user, so I used this to implement my function.

, , MediaRecorder, , MIC, VOICE_CALL .. SDK MediaRecorder , Android 2 MediaRecorder .

android:

0

Source: https://habr.com/ru/post/1681668/


All Articles