AudioTrack.SetVolume(Single) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the specified output gain value on all channels of this track.
[Android.Runtime.Register("setVolume", "(F)I", "GetSetVolume_FHandler")]
public virtual Android.Media.TrackStatus SetVolume (float gain);
[<Android.Runtime.Register("setVolume", "(F)I", "GetSetVolume_FHandler")>]
abstract member SetVolume : single -> Android.Media.TrackStatus
override this.SetVolume : single -> Android.Media.TrackStatus
Parameters
- gain
- Single
output gain for all channels.
Returns
error code or success, see #SUCCESS
,
#ERROR_INVALID_OPERATION
- Attributes
Remarks
Sets the specified output gain value on all channels of this track.
Gain values are clamped to the closed interval [0.0, max] where max is the value of #getMaxVolume
. A value of 0.0 results in zero gain (silence), and a value of 1.0 means unity gain (signal unchanged). The default value is 1.0 meaning unity gain.
This API is preferred over #setStereoVolume
, as it more gracefully scales down to mono, and up to multi-channel content beyond stereo.
The word "volume" in the API name is historical; this is actually a linear gain.
Java documentation for android.media.AudioTrack.setVolume(float)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.