Muokkaa

Jaa


Quickstart: Access call volume level in your calling app

Important

Functionality described in this article is currently in public preview. This preview version is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.

Checking the local audio stream volume

As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using VolumeLevel. The VolumeLevel value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).

Example usage

This example shows how to generate the volume level by accessing VolumeLevel of the local audio stream.

//Get the volume of the local audio source
OutgoingAudioStream stream = call.ActiveOutgoingAudioStream;

if (stream != null)
{
    try
    {
        Trace.WriteLine("Current volume is: " + stream.VolumeLevel.ToString());
    }
    catch (Exception ex)
    {
        Trace.WriteLine("Failed to get volume for this audio stream");
    }
}

Important

Functionality described in this article is currently in public preview. This preview version is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.

Checking the local audio stream volume

As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using getVolumeLevel. The getVolumeLevel value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).

Example usage

This example shows how to generate the volume level by accessing getVolumeLevel of the local audio stream.

//Get the volume of the local audio source
OutgoingAudioStream stream = call.getActiveOutgoingAudioStream();
try{
    float volume = stream.getVolumeLevel();
}catch (Exception e) {
    e.printStackTrace();
}

Important

Functionality described in this article is currently in public preview. This preview version is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

As a developer you can have control over checking microphone volume. This quickstart shows examples of how to accomplish it within the Azure Communication Services Calling SDK.

Checking the local audio stream volume

As a developer it can be nice to have the ability to check and display to end users the current local microphone volume level. Azure Communication Services calling API exposes this information using volumeLevel. The volumeLevel value is a float number ranging from 0 to 1 (with 0 noting zero audio detected, 100 as the max level detectable, -1 noting a failed operation).

Example usage

This example shows how to generate the volume level by accessing volumeLevel of the local audio stream.

//Get the volume of the local audio source
if let volume = call?.activeOutgoingAudioStream.volumeLevel {    
    print("Outgoing audio volume is %d", log:log, volume)
} else {
    print("Get volume error")
}

As a developer you can have control over checking microphone volume in JavaScript. This quickstart shows examples of how to accomplish it within the Azure Communication Services WebJS.

Prerequisites

Important

The quick start examples here are available starting in version 1.13.1 of the calling Web SDK. Make sure to use that SDK version or newer when trying this quickstart.

Checking the audio stream volume

As a developer it can be nice to have the ability to check and display to end users the current local microphone volume or the incoming microphone level. Azure Communication Services calling API exposes this information using getVolume. The getVolume value is a number ranging from 0 to 100 (with 0 noting zero audio detected, 100 as the max level detectable). This value is sampled every 200 ms to get near real time value of volume level. Different microphone hardware has different level of sensitivity and it can show different volume levels for the similar environment.

Example usage

This example shows how to generate the volume level by accessing getVolume of the local audio stream and of the remote incoming audio stream.

//Get the volume of the local audio source
const volumeIndicator = await new SDK.LocalAudioStream(deviceManager.selectedMicrophone).getVolume();
volumeIndicator.on('levelChanged', ()=>{
    console.log(`Volume is ${volumeIndicator.level}`)
})

//Get the volume level of the remote incoming audio source
const remoteAudioStream = call.remoteAudioStreams[0];
const volumeIndicator = await remoteAudioStream.getVolume();
volumeIndicator.on('levelChanged', ()=>{
    console.log(`Volume is ${volumeIndicator.level}`)
})

For a more detailed code sample on how to create a UI display to show the local and current incoming audio level, see here.

Next steps

For more information, see the following article: