mixVolumeChunk function

int mixVolumeChunk(
  1. Pointer<MixChunk> chunk,
  2. int volume
)

Set the volume for a specific chunk.

In addition to channels having a volume setting, individual chunks also maintain a separate volume. Both values are considered when mixing, so both affect the final attenuation of the sound. This lets an app adjust the volume for all instances of a sound in addition to specific instances of that sound.

The volume must be between 0 (silence) and MIX_MAX_VOLUME (full volume). Note that MIX_MAX_VOLUME is 128. Values greater than MIX_MAX_VOLUME are clamped to MIX_MAX_VOLUME.

Specifying a negative volume will not change the current volume; as such, this can be used to query the current volume without making changes, as this function returns the previous (in this case, still-current) value.

The default volume for a chunk is MIX_MAX_VOLUME (no attenuation).

\param chunk the chunk whose volume to adjust. \param volume the new volume, between 0 and MIX_MAX_VOLUME, or -1 to query. \returns the previous volume. If the specified volume is -1, this returns the current volume. If chunk is NULL, this returns -1.

\since This function is available since SDL_mixer 2.0.0.

extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume)

Implementation

int mixVolumeChunk(Pointer<MixChunk> chunk, int volume) {
  final mixVolumeChunkLookupFunction = libSdl2Mixer.lookupFunction<
      Int32 Function(Pointer<MixChunk> chunk, Int32 volume),
      int Function(Pointer<MixChunk> chunk, int volume)>('Mix_VolumeChunk');
  return mixVolumeChunkLookupFunction(chunk, volume);
}