Love Is The True Reason For The Season

Christmas once brought me mixed feelings. Mom’s health wasn’t all the best and we three children were tasked with taking down all the mundane decorations, packing them away, and then bringing out the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to implement sound waves in Android by using ZEGOCLOUD SDK

sound waves

In the karaoke scene, it is often necessary to pull multiple streams and display the user who is speaking. We need to identify whether the user is speaking, the volume of the speech (sound wave), and display it on the UI.

The SDK provides the following two methods to achieve this function:

Sound level refers to the volume of a stream. The ZEGO Express SDK provides the ability to capture the sound level of a stream in real time and delivers the captured sound level data to the app client through related callbacks. A typical use case of this feature is that you can visualize the sound level data on your app UI to indicate the current active speaker and their volume. The following picture shows an example of such use cases.

Audio spectrum refers to a series of values, each of which represents an audio signal’s energy level at a point in a frequency range. The ZEGO Express SDK provides the ability to capture the audio spectrum data of a stream in real time and delivers the captured audio spectrum data to the app client through related callbacks. A typical use case of this feature is that you can use it to create and display an audio spectrum visualizer on your app UI, especially for those online karaoke apps. The following picture shows an example of audio spectrum visualizers.

Audio spectrum

Before you begin to use sound level and audio spectrum in your project, make sure you complete the following steps:

To enable sound level callbacks, call the startSoundLevelMonitor method.

After the above step is completed:

To enable audio spectrum callbacks, call the startAudioSpectrumMonitor method.

After the above step is completed:

The SDK delivers the sound level data and audio spectrum data of the remote streams as key-value pairs in a HashMap. In each key-value pair, the key is the stream ID of a remote stream published by another user in the same room, and the value is the sound level value or an array of audio spectrum values that stream.

You can first obtain and save the list of remote streams published by the other users in the current room through the onRoomStreamUpdate callback, and then use each stream ID in the list as an index to get the sound level value or the audio spectrum data of that stream from the HashMap.

The following examples show how to obtain the sound level and audio spectrum data from the callbacks. For how to render the data onto the UI of the app, refer to the sample code mentioned in Section 2 above.

To disable the sound level callbacks, call the stopSoundLevelMonitor method.

After the above step is completed, the SDK will stop triggering the callbacks onCapturedSoundLevelUpdate and onRemoteSoundLevelUpdate.

To disable audio spectrum callbacks, call the stopAudioSpectrumMonitor method.

After the above step is completed, the SDK will stop triggering the callbacks onCapturedAudioSpectrumUpdate and onRemoteAudioSpectrumUpdate.

Add a comment

Related posts:

Alone

Lately I have been alone Like a lot of other people. I have been at home But home for me is on my own. No new faces, nor old ones Only sound I hear is keyboard punching. Nobody around to speak to…

How to create knight rider light in Arduino Uno R3

04.Place diodes in terminal strips to make connection to Upper and Lower terminals and place them connecting LEDs cathode. First lights must be switch on and off from left to right and right to left…

When Stress Wants to Claim Too Much Space

I have had to navigate stress most of my life, which has left me with debilitating health challenges. I don’t have complaints. I’m always grateful for the goodness in my life. In fact, the health…