mixCreateSineWaveAudio function mixer

Pointer<MixAudio> mixCreateSineWaveAudio(
  1. Pointer<MixMixer> mixer,
  2. int hz,
  3. double amplitude,
  4. int ms,
)

Create a MIX_Audio that generates a sinewave.

This is useful just to have something to play, perhaps for testing or debugging purposes.

You specify its frequency in Hz (determines the pitch of the sinewave's audio) and amplitude (determines the volume of the sinewave: 1.0f is very loud, 0.0f is silent).

A number of milliseconds of audio to generate can be specified. Specifying a value less than zero will generate infinite audio (when assigned to a MIX_Track, the sinewave will play forever).

MIX_Audio objects can be shared between multiple mixers. The mixer parameter just suggests the most likely mixer to use this audio, in case some optimization might be applied, but this is not required, and a NULL mixer may be specified.

\param mixer a mixer this audio is intended to be used with. May be NULL. \param hz the sinewave's frequency in Hz. \param amplitude the sinewave's amplitude from 0.0f to 1.0f. \param ms the maximum number of milliseconds of audio to generate, or less than zero to generate infinite audio. \returns an audio object that can be used to make sound on a mixer, or NULL 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_DestroyAudio \sa MIX_SetTrackAudio \sa MIX_LoadAudio_IO

extern SDL_DECLSPEC MIX_Audio * SDLCALL MIX_CreateSineWaveAudio(MIX_Mixer *mixer, int hz, float amplitude, Sint64 ms)

Implementation

Pointer<MixAudio> mixCreateSineWaveAudio(
  Pointer<MixMixer> mixer,
  int hz,
  double amplitude,
  int ms,
) {
  final mixCreateSineWaveAudioLookupFunction = _libMixer
      .lookupFunction<
        Pointer<MixAudio> Function(
          Pointer<MixMixer> mixer,
          Int32 hz,
          Float amplitude,
          Int64 ms,
        ),
        Pointer<MixAudio> Function(
          Pointer<MixMixer> mixer,
          int hz,
          double amplitude,
          int ms,
        )
      >('MIX_CreateSineWaveAudio');
  return mixCreateSineWaveAudioLookupFunction(mixer, hz, amplitude, ms);
}