setAttenuationModel method

Future<int?> setAttenuationModel(
  1. AttenuationType type,
  2. float coefficient
)

@detail api @author huangshouqin @brief Set the volume roll-off mode that a 3D sound has in an audio source when using the Range Audio feature. @param type Volume roll-off mode. It is linear roll-off mode by default. Refer to AttenuationType{@link #AttenuationType} for more details. @param coefficient Coefficient for the exponential roll-off mode. The default value is 1. It ranges 0.1,100. We recommended to set it to 50. The volume roll-off speed gets faster as this value increases. @return Result of the call
- 0: Success - -1: Failure because of calling this API before the user has joined a room or before enabling the Range Audio feature by calling enableRangeAudio{@link #IRangeAudio#enableRangeAudio}. @note Call updateReceiveRange{@link #IRangeAudio#updateReceiveRange} to set the range outside which the volume of the sound does not attenuate.

Implementation

Future<int?> setAttenuationModel(
    AttenuationType type, float coefficient) async {
  $a() => ($instance as $p_a.IRangeAudio).setAttenuationModel(
      t_AttenuationType.code_to_android(type), coefficient);
  $i() => ($instance as $p_i.ByteRTCRangeAudio)
      .setAttenuationModel(t_AttenuationType.code_to_ios(type), coefficient);

  if (Platform.isAndroid) {
    return $a();
  } else if (Platform.isIOS) {
    return $i();
  } else {
    throw UnsupportedError(
        'Not Support Platform ${Platform.operatingSystem}');
  }
}