mixSetTagGain function mixer

bool mixSetTagGain(
  1. Pointer<MixMixer> mixer,
  2. String? tag,
  3. double gain
)

Set the gain control of all tracks with a specific tag.

Each track has its own gain, to adjust its overall volume. Each sample from this track is modulated by this gain value. A gain of zero will generate silence, 1.0f will not change the mixed volume, and larger than 1.0f will increase the volume. Negative values are illegal. There is no maximum gain specified, but this can quickly get extremely loud, so please be careful with this setting.

A track's gain defaults to 1.0f.

This will change the gain control on tracks on the specified mixer that have the specified tag.

From the point of view of the mixing process, all tracks that successfully change gain values will do so at the exact same moment.

This value can be changed at any time to adjust the future mix.

\param mixer the mixer on which to look for tagged tracks. \param tag the tag to use when searching for tracks. \param gain the new gain value. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL_mixer 3.0.0.

\sa MIX_GetTrackGain \sa MIX_SetTrackGain \sa MIX_SetMasterGain \sa MIX_TagTrack

extern SDL_DECLSPEC bool SDLCALL MIX_SetTagGain(MIX_Mixer *mixer, const char *tag, float gain)

Implementation

bool mixSetTagGain(Pointer<MixMixer> mixer, String? tag, double gain) {
  final mixSetTagGainLookupFunction = _libMixer
      .lookupFunction<
        Uint8 Function(Pointer<MixMixer> mixer, Pointer<Utf8> tag, Float gain),
        int Function(Pointer<MixMixer> mixer, Pointer<Utf8> tag, double gain)
      >('MIX_SetTagGain');
  final tagPointer = tag != null ? tag.toNativeUtf8() : nullptr;
  final result = mixSetTagGainLookupFunction(mixer, tagPointer, gain) == 1;
  calloc.free(tagPointer);
  return result;
}