# AudioVolume ## **Overview** **Related Modules:** [Audio](Audio.md) **Description:** Provides volume-related APIs for audio rendering or capturing, including functions to set the mute operation, volume, and gain. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Fields

Variable Name

Description

SetMute )(AudioHandle handle, bool mute)

int32_t(* 

Sets the mute operation for the audio.

GetMute )(AudioHandle handle, bool *mute)

int32_t(* 

Obtains the mute operation set for the audio.

SetVolume )(AudioHandle handle, float volume)

int32_t(* 

Sets the audio volume.

GetVolume )(AudioHandle handle, float *volume)

int32_t(* 

Obtains the audio volume.

GetGainThreshold )(AudioHandle handle, float *min, float *max)

int32_t(* 

Obtains the range of the audio gain.

GetGain )(AudioHandle handle, float *gain)

int32_t(* 

Obtains the audio gain.

SetGain )(AudioHandle handle, float gain)

int32_t(* 

Sets the audio gain.

## **Details** ## **Field Documentation** ## GetGain ``` int32_t(* AudioVolume::GetGain) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float *gain) ``` **Description:** Obtains the audio gain. **Parameters:**

Name

Description

handle Indicates the audio handle.
gain Indicates the pointer to the audio gain.
**Returns:** Returns **0** if the audio gain is obtained; returns a negative value otherwise. **See also:** [GetGainThreshold](AudioVolume.md#aa42ff18fa2b7e6780acf120ea49054ed) ## GetGainThreshold ``` int32_t(* AudioVolume::GetGainThreshold) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float *min, float *max) ``` **Description:** Obtains the range of the audio gain. The audio gain can be expressed in one of the following two ways \(depending on the chip platform\), corresponding to two types of value ranges: **Parameters:**

Name

Description

handle Indicates the audio handle.
min Indicates the pointer to the minimum value of the range.
max Indicates the pointer to the maximum value of the range.
**Returns:** Returns **0** if the range is obtained; returns a negative value otherwise. **See also:** [GetGain](AudioVolume.md#a5ff7f9e5b763d20822a1fadecc5a8db7) ## GetMute ``` int32_t(* AudioVolume::GetMute) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool *mute) ``` **Description:** Obtains the mute operation set for the audio. **Parameters:**

Name

Description

handle Indicates the audio handle.
mute Indicates the pointer to the mute operation set for the audio. Value true means that the audio is muted, and false means the opposite.
**Returns:** Returns **0** if the mute operation is obtained; returns a negative value otherwise. **See also:** [SetMute](AudioVolume.md#a79c127fa37eb2dbf8dc5fe9f0ed4421e) ## GetVolume ``` int32_t(* AudioVolume::GetVolume) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float *volume) ``` **Description:** Obtains the audio volume. **Parameters:**

Name

Description

handle Indicates the audio handle.
volume Indicates the pointer to the volume to obtain. The value ranges from 0.0 to 1.0.
**Returns:** Returns **0** if the volume is obtained; returns a negative value otherwise. **See also:** [SetVolume](AudioVolume.md#aebf67caf924cba5f3be9d0f395390908) ## SetGain ``` int32_t(* AudioVolume::SetGain) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float gain) ``` **Description:** Sets the audio gain. **Parameters:**

Name

Description

handle Indicates the audio handle.
gain Indicates the audio gain to set.
**Returns:** Returns **0** if the setting is successful; returns a negative value otherwise. **See also:** [GetGainThreshold](AudioVolume.md#aa42ff18fa2b7e6780acf120ea49054ed) ## SetMute ``` int32_t(* AudioVolume::SetMute) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, bool mute) ``` **Description:** Sets the mute operation for the audio. **Parameters:**

Name

Description

handle Indicates the audio handle.
mute Specifies whether to mute the audio. Value true means to mute the audio, and false means the opposite.
**Returns:** Returns **0** if the setting is successful; returns a negative value otherwise. **See also:** [GetMute](AudioVolume.md#a75fcb5bda7e0ca9b823187f6056ad1d4) ## SetVolume ``` int32_t(* AudioVolume::SetVolume) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, float volume) ``` **Description:** Sets the audio volume. The volume ranges from 0.0 to 1.0. If the volume level in an audio service ranges from 0 to 15, **0.0** indicates that the audio is muted, and **1.0** indicates the maximum volume level \(15\). **Parameters:**

Name

Description

handle Indicates the audio handle.
volume Indicates the volume to set. The value ranges from 0.0 to 1.0.
**Returns:** Returns **0** if the setting is successful; returns a negative value otherwise. **See also:** [GetVolume](AudioVolume.md#a649524ce280ecdb62ddacb78e1a63439)