brutal/Brutal.Sdl.Mixer/Generated/SdlMixer.HandleMethods.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

1471 lines
71 KiB
C#

// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Mixer
{
public readonly unsafe partial struct MixAudio
{
/// <summary>
/// Convert sample frames for a MIX_Audio's format to milliseconds.
/// </summary>
/// <param name="frames">the audio-specific sample frames to convert to milliseconds.</param>
/// <returns>
/// Converted number of milliseconds, or -1 for errors/no input; call
/// SDL_GetError() for details.
/// </returns>
/// <remarks>
/// <para>
/// This calculates time based on the audio's initial format, even if the
/// format would change mid-stream.
/// </para>
/// <para>
/// Sample frames are more precise than milliseconds, so out of necessity, this
/// function will approximate by rounding down to the closest full millisecond.
/// </para>
/// <para>
/// If <c>frames</c> is &lt; 0, this returns -1.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.AudioMSToFrames"/>
public long FramesToMS(long frames) => SdlMixer.AudioFramesToMS(this, frames);
/// <summary>
/// Convert milliseconds to sample frames for a MIX_Audio's format.
/// </summary>
/// <param name="ms">the milliseconds to convert to audio-specific sample frames.</param>
/// <returns>
/// Converted number of sample frames, or -1 for errors/no input; call
/// SDL_GetError() for details.
/// </returns>
/// <remarks>
/// <para>
/// This calculates time based on the audio's initial format, even if the
/// format would change mid-stream.
/// </para>
/// <para>
/// If <c>ms</c> is &lt; 0, this returns -1.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.AudioFramesToMS"/>
public long MSToFrames(long ms) => SdlMixer.AudioMSToFrames(this, ms);
/// <summary>
/// Destroy the specified audio.
/// </summary>
/// <remarks>
/// <para>
/// MIX_Audio is reference-counted internally, so this function only unrefs it.
/// If doing so causes the reference count to drop to zero, the MIX_Audio will
/// be deallocated. This allows the system to safely operate if the audio is
/// still assigned to a MIX_Track at the time of destruction. The actual
/// destroying will happen when the track stops using it.
/// </para>
/// <para>
/// But from the caller's perspective, once this function is called, it should
/// assume the <c>audio</c> pointer has become invalid.
/// </para>
/// <para>
/// Destroying a NULL MIX_Audio is a legal no-op.
/// </para>
/// <para>
/// This is equivalent to Dispose(): it is a safe no-op on a default (null) handle and otherwise performs
/// the single native free. Because a handle is a copyable value type, it cannot invalidate its own copies
/// after the free, so calling this (or Dispose) more than once on the same handle value — or on separate
/// copies of it — frees the underlying native object more than once. Free each handle exactly once.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public void Destroy()
{
if (IsNull())
{
return;
}
SdlMixer.DestroyAudio(this);
}
/// <summary>
/// Get the length of a MIX_Audio's playback in sample frames.
/// </summary>
/// <returns>
/// the length of the audio in sample frames, or MIX_DURATION_UNKNOWN
/// or MIX_DURATION_INFINITE.
/// </returns>
/// <remarks>
/// <para>
/// This information is also available via the
/// MIX_PROP_METADATA_DURATION_FRAMES_NUMBER property, but it's common enough
/// to provide a simple accessor function.
/// </para>
/// <para>
/// This reports the length of the data in <em>sample frames</em>, so sample-perfect
/// mixing can be possible. Sample frames are only meaningful as a measure of
/// time if the sample rate (frequency) is also known. To convert from sample
/// frames to milliseconds, use MIX_AudioFramesToMS().
/// </para>
/// <para>
/// Not all audio file formats can report the complete length of the data they
/// will produce through decoding: some can't calculate it, some might produce
/// infinite audio.
/// </para>
/// <para>
/// Also, some file formats can only report duration as a unit of time, which
/// means SDL_mixer might have to estimate sample frames from that information.
/// With less precision, the reported duration might be off by a few sample
/// frames in either direction.
/// </para>
/// <para>
/// This will return a value &gt;= 0 if a duration is known. It might also return
/// MIX_DURATION_UNKNOWN or MIX_DURATION_INFINITE.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public long GetDuration() => SdlMixer.GetAudioDuration(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetAudioFormat</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="spec">on success, audio format details will be stored here.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetAudioFormat(this, spec);
/// <summary>
/// Get the properties associated with a MIX_Audio.
/// </summary>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// SDL_mixer offers some properties of its own, but this can also be a
/// convenient place to store app-specific data.
/// </para>
/// <para>
/// A SDL_PropertiesID is created the first time this function is called for a
/// given MIX_Audio, if necessary.
/// </para>
/// <para>
/// The following read-only properties are provided by SDL_mixer:
/// </para>
/// <para>
/// - <c>MIX_PROP_METADATA_TITLE_STRING</c>: the audio's title ("Smells Like Teen
/// Spirit").
/// - <c>MIX_PROP_METADATA_ARTIST_STRING</c>: the audio's artist name ("Nirvana").
/// - <c>MIX_PROP_METADATA_ALBUM_STRING</c>: the audio's album name ("Nevermind").
/// - <c>MIX_PROP_METADATA_COPYRIGHT_STRING</c>: the audio's copyright info
/// ("Copyright (c) 1991")
/// - <c>MIX_PROP_METADATA_TRACK_NUMBER</c>: the audio's track number on the album
/// (1)
/// - <c>MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER</c>: the total tracks on the album
/// (13)
/// - <c>MIX_PROP_METADATA_YEAR_NUMBER</c>: the year the audio was released (1991)
/// - <c>MIX_PROP_METADATA_DURATION_FRAMES_NUMBER</c>: The sample frames worth of
/// PCM data that comprise this audio. It might be off by a little if the
/// decoder only knows the duration as a unit of time.
/// - <c>MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN</c>: if true, audio never runs
/// out of sound to generate. This isn't necessarily always known to
/// SDL_mixer, though.
/// </para>
/// <para>
/// Other properties, documented with MIX_LoadAudioWithProperties(), may also
/// be present.
/// </para>
/// <para>
/// Note that the metadata properties are whatever SDL_mixer finds in things
/// like ID3 tags, and they often have very little standardized formatting, may
/// be missing, and can be completely wrong if the original data is
/// untrustworthy (like an MP3 from a P2P file sharing service).
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public uint GetProperties() => SdlMixer.GetAudioProperties(this);
}
public readonly unsafe partial struct MixAudioDecoder
{
/// <summary>
/// Decode more audio from a MIX_AudioDecoder.
/// </summary>
/// <param name="buffer">the memory buffer to store decoded audio.</param>
/// <param name="buflen">the maximum number of bytes to store to <c>buffer</c>.</param>
/// <param name="spec">the format that audio data will be stored to <c>buffer</c>.</param>
/// <returns>
/// number of bytes decoded, or -1 on error; call SDL_GetError() for
/// more information.
/// </returns>
/// <remarks>
/// <para>
/// Data is decoded on demand in whatever format is requested. The format is
/// permitted to change between calls.
/// </para>
/// <para>
/// This function will return the number of bytes decoded, which may be less
/// than requested if there was an error or end-of-file. A return value of zero
/// means the entire file was decoded, -1 means an unrecoverable error
/// happened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public int DecodeAudio(void* buffer, int buflen, SdlAudioSpec* spec) =>
SdlMixer.DecodeAudio(this, buffer, buflen, spec);
/// <summary>
/// Destroy the specified audio decoder.
/// </summary>
/// <remarks>
/// <para>
/// Destroying a NULL MIX_AudioDecoder is a legal no-op.
/// </para>
/// <para>
/// This is equivalent to Dispose(): it is a safe no-op on a default (null) handle and otherwise performs
/// the single native free. Because a handle is a copyable value type, it cannot invalidate its own copies
/// after the free, so calling this (or Dispose) more than once on the same handle value — or on separate
/// copies of it — frees the underlying native object more than once. Free each handle exactly once.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public void Destroy()
{
if (IsNull())
{
return;
}
SdlMixer.DestroyAudioDecoder(this);
}
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetAudioDecoderFormat</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="spec">on success, audio format details will be stored here.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetAudioDecoderFormat(this, spec);
/// <summary>
/// Get the properties associated with a MIX_AudioDecoder.
/// </summary>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// SDL_mixer offers some properties of its own, but this can also be a
/// convenient place to store app-specific data.
/// </para>
/// <para>
/// A SDL_PropertiesID is created the first time this function is called for a
/// given MIX_AudioDecoder, if necessary.
/// </para>
/// <para>
/// The file-specific metadata exposed through this function is identical to
/// those available through MIX_GetAudioProperties(). Please refer to that
/// function's documentation for details.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.GetAudioProperties"/>
public uint GetProperties() => SdlMixer.GetAudioDecoderProperties(this);
}
public readonly unsafe partial struct MixGroup
{
/// <summary>
/// Destroy a mixing group.
/// </summary>
/// <remarks>
/// <para>
/// Any tracks currently assigned to this group will be reassigned to the
/// mixer's internal default group.
/// </para>
/// <para>
/// This is equivalent to Dispose(): it is a safe no-op on a default (null) handle and otherwise performs
/// the single native free. Because a handle is a copyable value type, it cannot invalidate its own copies
/// after the free, so calling this (or Dispose) more than once on the same handle value — or on separate
/// copies of it — frees the underlying native object more than once. Free each handle exactly once.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.CreateGroup"/>
public void Destroy()
{
if (IsNull())
{
return;
}
SdlMixer.DestroyGroup(this);
}
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetGroupMixer</c>.
/// </summary>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource this
/// call does not own. A null handle is returned on failure.
/// </remarks>
public MixMixer GetMixer() => SdlMixer.GetGroupMixer(this);
/// <summary>
/// Get the properties associated with a group.
/// </summary>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// Currently SDL_mixer assigns no properties of its own to a group, but this
/// can be a convenient place to store app-specific data.
/// </para>
/// <para>
/// A SDL_PropertiesID is created the first time this function is called for a
/// given group.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public uint GetProperties() => SdlMixer.GetGroupProperties(this);
}
public readonly unsafe partial struct MixMixer
{
/// <summary>
/// Ergonomic wrapper over <c>MIX_CreateGroup</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixGroup CreateGroup() => SdlMixer.CreateGroup(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_CreateSineWaveAudio</c>. Throws instead of returning a null handle on
/// failure.
/// </summary>
/// <param name="hz">the sinewave's frequency in Hz.</param>
/// <param name="amplitude">the sinewave's amplitude from 0.0f to 1.0f.</param>
/// <param name="ms">
/// the maximum number of milliseconds of audio to generate, or less
/// than zero to generate infinite audio.
/// </param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio CreateSineWaveAudio(int hz, float amplitude, long ms) =>
SdlMixer.CreateSineWaveAudio(this, hz, amplitude, ms);
/// <summary>
/// Ergonomic wrapper over <c>MIX_CreateTrack</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixTrack CreateTrack() => SdlMixer.CreateTrack(this);
/// <summary>
/// Free a mixer.
/// </summary>
/// <remarks>
/// <para>
/// If this mixer was created with MIX_CreateMixerDevice(), this function will
/// also close the audio device and call SDL_QuitSubSystem(SDL_INIT_AUDIO).
/// </para>
/// <para>
/// Any MIX_Group or MIX_Track created for this mixer will also be destroyed.
/// Do not access them again or attempt to destroy them after the device is
/// destroyed. MIX_Audio objects will not be destroyed, since they can be
/// shared between mixers (but those will all be destroyed during MIX_Quit()).
/// </para>
/// <para>
/// This is equivalent to Dispose(): it is a safe no-op on a default (null) handle and otherwise performs
/// the single native free. Because a handle is a copyable value type, it cannot invalidate its own copies
/// after the free, so calling this (or Dispose) more than once on the same handle value — or on separate
/// copies of it — frees the underlying native object more than once. Free each handle exactly once.
/// </para>
/// </remarks>
/// <threadsafety>
/// If this is used with a MIX_Mixer from MIX_CreateMixerDevice,
/// then this function should only be called on the main thread.
/// If this is used with a MIX_Mixer from MIX_CreateMixer, then
/// it is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.CreateMixerDevice"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.CreateMixer"/>
public void Destroy()
{
if (IsNull())
{
return;
}
SdlMixer.DestroyMixer(this);
}
/// <summary>
/// Generate mixer output when not driving an audio device.
/// </summary>
/// <param name="buffer">a pointer to a buffer to store audio in.</param>
/// <param name="buflen">the number of bytes to store in buffer.</param>
/// <returns>
/// The number of bytes of mixed audio, discounting appended silence,
/// on success, or -1 on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// SDL_mixer allows the creation of MIX_Mixer objects that are not connected
/// to an audio device, by calling MIX_CreateMixer() instead of
/// MIX_CreateMixerDevice(). Such mixers will not generate output until
/// explicitly requested through this function.
/// </para>
/// <para>
/// The caller may request as much audio as desired, so long as <c>buflen</c> is a
/// multiple of the sample frame size specified when creating the mixer (for
/// example, if requesting stereo Sint16 audio, buflen must be a multiple of 4:
/// 2 bytes-per-channel times 2 channels).
/// </para>
/// <para>
/// The mixer will mix as quickly as possible; since it works in sample frames
/// instead of time, it can potentially generate enormous amounts of audio in a
/// small amount of time.
/// </para>
/// <para>
/// On success, this always fills <c>buffer</c> with <c>buflen</c> bytes of audio; if all
/// playing tracks finish mixing, it will fill the remaining buffer with
/// silence.
/// </para>
/// <para>
/// Each call to this function will pick up where it left off, playing tracks
/// will continue to mix from the point the previous call completed, etc. The
/// mixer state can be changed between each call in any way desired: tracks can
/// be added, played, stopped, changed, removed, etc. Effectively this function
/// does the same thing SDL_mixer does internally when the audio device needs
/// more audio to play.
/// </para>
/// <para>
/// This function can not be used with mixers from MIX_CreateMixerDevice();
/// those generate audio as needed internally.
/// </para>
/// <para>
/// This function returns the number of <em>bytes</em> of real audio mixed, which
/// might be less than <c>buflen</c>. While all <c>buflen</c> bytes of <c>buffer</c> will be
/// initialized, if available tracks to mix run out, the end of the buffer will
/// be initialized with silence; this silence will not be counted in the return
/// value, so the caller has the option to identify how much of the buffer has
/// legimitate contents vs appended silence. As such, any value &gt;= 0 signifies
/// success. A return value of -1 means failure (out of memory, invalid
/// parameters, etc).
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.CreateMixer"/>
public int Generate(void* buffer, int buflen) => SdlMixer.Generate(this, buffer, buflen);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetMixerFormat</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="spec">where to store the mixer audio format.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetMixerFormat(this, spec);
/// <summary>
/// Get a mixer's master frequency ratio.
/// </summary>
/// <returns>the mixer's current master frequency ratio.</returns>
/// <remarks>
/// <para>
/// This returns the last value set through MIX_SetMixerFrequencyRatio(), or
/// 1.0f if no value has ever been explicitly set.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.SetMixerFrequencyRatio"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.GetTrackFrequencyRatio"/>
public float GetFrequencyRatio() => SdlMixer.GetMixerFrequencyRatio(this);
/// <summary>
/// Get a mixer's master gain control.
/// </summary>
/// <returns>the mixer's current master gain.</returns>
/// <remarks>
/// <para>
/// This returns the last value set through MIX_SetMixerGain(), or 1.0f if no
/// value has ever been explicitly set.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.SetMixerGain"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.GetTrackGain"/>
public float GetGain() => SdlMixer.GetMixerGain(this);
/// <summary>
/// Get the properties associated with a mixer.
/// </summary>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// The following read-only properties are provided by SDL_mixer:
/// </para>
/// <para>
/// - <c>MIX_PROP_MIXER_DEVICE_NUMBER</c>: the SDL_AudioDeviceID that this mixer has
/// opened for playback. This will be zero (no device) if the mixer was
/// created with Mix_CreateMixer() instead of Mix_CreateMixerDevice().
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public uint GetProperties() => SdlMixer.GetMixerProperties(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTaggedTracks</c>.
/// </summary>
/// <param name="tag">the tag to search.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
/// <remarks>
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy, and
/// the native buffer is freed with <c>SDL_free</c> before this method returns. Each element is a
/// <b>borrowed handle</b>: it is owned by SDL, not created by this call, and must not be disposed. Do not
/// call <see cref="System.IDisposable.Dispose"/> on any element.
/// </remarks>
public MixTrack[] GetTaggedTracks(string tag) => SdlMixer.GetTaggedTracks(this, tag);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadAudio</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="path">the path on the filesystem to load data from.</param>
/// <param name="predecode">if true, data will be fully uncompressed before returning.</param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadAudio(string path, bool predecode) => SdlMixer.LoadAudio(this, path, predecode);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadAudio_IO</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="io">the SDL_IOStream to load data from.</param>
/// <param name="predecode">if true, data will be fully uncompressed before returning.</param>
/// <param name="closeio">
/// true if SDL_mixer should close <c>io</c> before returning
/// (success or failure).
/// </param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadAudioIO(nint io, bool predecode, bool closeio) =>
SdlMixer.LoadAudioIO(this, io, predecode, closeio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadAudioNoCopy</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="data">the buffer where the audio data lives.</param>
/// <param name="datalen">the size, in bytes, of the buffer.</param>
/// <param name="free_when_done">
/// if true, <c>data</c> will be given to SDL_free() when the
/// MIX_Audio is destroyed.
/// </param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadAudioNoCopy(void* data, nuint datalen, bool free_when_done) =>
SdlMixer.LoadAudioNoCopy(this, data, datalen, free_when_done);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadRawAudio</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="data">the raw PCM data to load.</param>
/// <param name="datalen">the size, in bytes, of the raw PCM data.</param>
/// <param name="spec">what format the raw data is in.</param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadRawAudio(void* data, nuint datalen, SdlAudioSpec* spec) =>
SdlMixer.LoadRawAudio(this, data, datalen, spec);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadRawAudio_IO</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="io">the SDL_IOStream to load data from.</param>
/// <param name="spec">what format the raw data is in.</param>
/// <param name="closeio">
/// true if SDL_mixer should close <c>io</c> before returning
/// (success or failure).
/// </param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadRawAudioIO(nint io, SdlAudioSpec* spec, bool closeio) =>
SdlMixer.LoadRawAudioIO(this, io, spec, closeio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_LoadRawAudioNoCopy</c>. Throws instead of returning a null handle on
/// failure.
/// </summary>
/// <param name="data">the buffer where the raw PCM data lives.</param>
/// <param name="datalen">the size, in bytes, of the buffer.</param>
/// <param name="spec">what format the raw data is in.</param>
/// <param name="free_when_done">
/// if true, <c>data</c> will be given to SDL_free() when the
/// MIX_Audio is destroyed.
/// </param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public MixAudio LoadRawAudioNoCopy(void* data, nuint datalen, SdlAudioSpec* spec, bool free_when_done) =>
SdlMixer.LoadRawAudioNoCopy(this, data, datalen, spec, free_when_done);
/// <summary>
/// Lock a mixer by obtaining its internal mutex.
/// </summary>
/// <remarks>
/// <para>
/// While locked, the mixer will not be able to mix more audio or change its
/// internal state in another thread. Those other threads will block until the
/// mixer is unlocked again.
/// </para>
/// <para>
/// Under the hood, this function calls SDL_LockMutex(), so all the same rules
/// apply: the lock can be recursive, it must be unlocked the same number of
/// times from the same thread that locked it, etc.
/// </para>
/// <para>
/// Just about every SDL_mixer API <em>also</em> locks the mixer while doing its work,
/// as does the SDL audio device thread while actual mixing is in progress, so
/// basic use of this library never requires the app to explicitly lock the
/// device to be thread safe. There are two scenarios where this can be useful,
/// however:
/// </para>
/// <para>
/// - The app has a provided a callback that the mixing thread might call, and
/// there is some app state that needs to be protected against race
/// conditions as changes are made and mixing progresses simultaneously. Any
/// lock can be used for this, but this is a conveniently-available lock.
/// - The app wants to make multiple, atomic changes to the mix. For example,
/// to start several tracks at the exact same moment, one would lock the
/// mixer, call MIX_PlayTrack multiple times, and then unlock again; all the
/// tracks will start mixing on the same sample frame.
/// </para>
/// <para>
/// Each call to this function must be paired with a call to MIX_UnlockMixer
/// from the same thread. It is safe to lock a mixer multiple times; it remains
/// locked until the final matching unlock call.
/// </para>
/// <para>
/// Do not lock the mixer for significant amounts of time, or it can cause
/// audio dropouts. Just do simple things quickly and unlock again.
/// </para>
/// <para>
/// Locking a NULL mixer is a safe no-op.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.UnlockMixer"/>
public void Lock() => SdlMixer.LockMixer(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PauseAllTracks</c>. Throws instead of returning false on failure.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void PauseAllTracks() => SdlMixer.PauseAllTracks(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PauseTag</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to use when searching for tracks.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void PauseTag(string tag) => SdlMixer.PauseTag(this, tag);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PlayAudio</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="audio">the audio input to play.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void PlayAudio(MixAudio audio) => SdlMixer.PlayAudio(this, audio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PlayTag</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to use when searching for tracks.</param>
/// <param name="options">the set of options that will be applied to each track.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void PlayTag(string tag, uint options) => SdlMixer.PlayTag(this, tag, options);
/// <summary>
/// Ergonomic wrapper over <c>MIX_ResumeAllTracks</c>. Throws instead of returning false on failure.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void ResumeAllTracks() => SdlMixer.ResumeAllTracks(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_ResumeTag</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to use when searching for tracks.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void ResumeTag(string tag) => SdlMixer.ResumeTag(this, tag);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetMixerFrequencyRatio</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="ratio">the frequency ratio. Must be between 0.01f and 100.0f.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetFrequencyRatio(float ratio) => SdlMixer.SetMixerFrequencyRatio(this, ratio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetMixerGain</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="gain">the new gain value.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetGain(float gain) => SdlMixer.SetMixerGain(this, gain);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTagGain</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to use when searching for tracks.</param>
/// <param name="gain">the new gain value.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetTagGain(string tag, float gain) => SdlMixer.SetTagGain(this, tag, gain);
/// <summary>
/// Ergonomic wrapper over <c>MIX_StopAllTracks</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="fade_out_ms">
/// the number of milliseconds to spend fading out to
/// silence before halting. 0 to stop immediately.
/// </param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void StopAllTracks(long fade_out_ms) => SdlMixer.StopAllTracks(this, fade_out_ms);
/// <summary>
/// Ergonomic wrapper over <c>MIX_StopTag</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to use when searching for tracks.</param>
/// <param name="fade_out_ms">
/// the number of milliseconds to spend fading out to
/// silence before halting. 0 to stop immediately.
/// </param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void StopTag(string tag, long fade_out_ms) => SdlMixer.StopTag(this, tag, fade_out_ms);
/// <summary>
/// Unlock a mixer previously locked by a call to MIX_LockMixer().
/// </summary>
/// <remarks>
/// <para>
/// While locked, the mixer will not be able to mix more audio or change its
/// internal state another thread. Those other threads will block until the
/// mixer is unlocked again.
/// </para>
/// <para>
/// Under the hood, this function calls SDL_LockMutex(), so all the same rules
/// apply: the lock can be recursive, it must be unlocked the same number of
/// times from the same thread that locked it, etc.
/// </para>
/// <para>
/// Unlocking a NULL mixer is a safe no-op.
/// </para>
/// </remarks>
/// <threadsafety>
/// This call must be paired with a previous MIX_LockMixer call
/// on the same thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.LockMixer"/>
public void Unlock() => SdlMixer.UnlockMixer(this);
}
public readonly unsafe partial struct MixTrack
{
/// <summary>
/// Destroy the specified track.
/// </summary>
/// <remarks>
/// <para>
/// If the track is currently playing, it will be stopped immediately, without
/// any fadeout. If there is a callback set through
/// MIX_SetTrackStoppedCallback(), it will <em>not</em> be called.
/// </para>
/// <para>
/// If the mixer is currently mixing in another thread, this will block until
/// it finishes. Destroying a track from the mixer thread itself (during a
/// callback) will cause it to be destroyed as soon as this iteration of the
/// mixer thread is not using it; in this scenario, destroying a track and then
/// making futher changes to it is considered undefined behavior.
/// </para>
/// <para>
/// Destroying a NULL MIX_Track is a legal no-op.
/// </para>
/// <para>
/// This is equivalent to Dispose(): it is a safe no-op on a default (null) handle and otherwise performs
/// the single native free. Because a handle is a copyable value type, it cannot invalidate its own copies
/// after the free, so calling this (or Dispose) more than once on the same handle value — or on separate
/// copies of it — frees the underlying native object more than once. Free each handle exactly once.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public void Destroy()
{
if (IsNull())
{
return;
}
SdlMixer.DestroyTrack(this);
}
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTrack3DPosition</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="position">on successful return, will contain the track's position.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void GetTrack3DPosition(MixPoint3D* position) => SdlMixer.GetTrack3DPosition(this, position);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTrackAudio</c>.
/// </summary>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource this
/// call does not own. A null handle is returned on failure.
/// </remarks>
public MixAudio GetAudio() => SdlMixer.GetTrackAudio(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTrackAudioStream</c>.
/// </summary>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource this
/// call does not own. A null handle is returned on failure.
/// </remarks>
public SdlAudioStream GetAudioStream() => SdlMixer.GetTrackAudioStream(this);
/// <summary>
/// Query whether a given track is fading.
/// </summary>
/// <returns>
/// less than 0 if the track is fading out, greater than 0 if fading
/// in, zero otherwise.
/// </returns>
/// <remarks>
/// <para>
/// This specifically checks if the track is <em>not stopped</em> (paused or playing),
/// and it is fading in or out, and returns the number of frames remaining in
/// the fade.
/// </para>
/// <para>
/// If fading out, the returned value will be negative. When fading in, the
/// returned value will be positive. If not fading, this function returns zero.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns 0, but there is no mechanism to distinguish errors from tracks that
/// aren't fading.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public long GetFadeFrames() => SdlMixer.GetTrackFadeFrames(this);
/// <summary>
/// Query the frequency ratio of a track.
/// </summary>
/// <returns>
/// the current frequency ratio, or 0.0f on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// The frequency ratio is used to adjust the rate at which audio data is
/// consumed. Changing this effectively modifies the speed and pitch of the
/// track's audio. A value greater than 1.0f will play the audio faster, and at
/// a higher pitch. A value less than 1.0f will play the audio slower, and at a
/// lower pitch. 1.0f is normal speed.
/// </para>
/// <para>
/// The default value is 1.0f.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns 0.0f. Since this is not a valid value to set, this can be seen as
/// an error state.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.GetTrackFrequencyRatio"/>
public float GetFrequencyRatio() => SdlMixer.GetTrackFrequencyRatio(this);
/// <summary>
/// Get a track's gain control.
/// </summary>
/// <returns>the track's current gain.</returns>
/// <remarks>
/// <para>
/// This returns the last value set through MIX_SetTrackGain(), or 1.0f if no
/// value has ever been explicitly set.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.SetTrackGain"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.GetMixerGain"/>
public float GetGain() => SdlMixer.GetTrackGain(this);
/// <summary>
/// Query how many loops remain for a given track.
/// </summary>
/// <returns>
/// the number of pending loops, zero if not looping, and -1 if
/// looping infinitely.
/// </returns>
/// <remarks>
/// <para>
/// This returns the number of loops still pending; if a track will eventually
/// complete and loop to play again one more time, this will return 1. If a
/// track <em>was</em> looping but is on its final iteration of the loop (will stop
/// when this iteration completes), this will return zero.
/// </para>
/// <para>
/// A track that is looping infinitely will return -1. This value does not
/// report an error in this case.
/// </para>
/// <para>
/// A track that is stopped (not playing and not paused) will have zero loops
/// remaining.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns zero, but there is no mechanism to distinguish errors from
/// non-looping tracks.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public int GetLoops() => SdlMixer.GetTrackLoops(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTrackMixer</c>.
/// </summary>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource this
/// call does not own. A null handle is returned on failure.
/// </remarks>
public MixMixer GetMixer() => SdlMixer.GetTrackMixer(this);
/// <summary>
/// Get the current input position of a playing track.
/// </summary>
/// <returns>
/// the track's current sample frame position, or -1 on error; call
/// SDL_GetError() for details.
/// </returns>
/// <remarks>
/// <para>
/// (Not to be confused with MIX_GetTrack3DPosition(), which is positioning of
/// the track in 3D space, not the playback position of its audio data.)
/// </para>
/// <para>
/// Position is defined in <em>sample frames</em> of decoded audio, not units of time,
/// so that sample-perfect mixing can be achieved. To instead operate in units
/// of time, use MIX_TrackFramesToMS() to convert the return value to
/// milliseconds.
/// </para>
/// <para>
/// Stopped and paused tracks will report the position when they halted.
/// Playing tracks will report the current position, which will change over
/// time.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.SetTrackPlaybackPosition"/>
public long GetPlaybackPosition() => SdlMixer.GetTrackPlaybackPosition(this);
/// <summary>
/// Get the properties associated with a track.
/// </summary>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// Currently SDL_mixer assigns no properties of its own to a track, but this
/// can be a convenient place to store app-specific data.
/// </para>
/// <para>
/// A SDL_PropertiesID is created the first time this function is called for a
/// given track.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public uint GetProperties() => SdlMixer.GetTrackProperties(this);
/// <summary>
/// Return the number of sample frames remaining to be mixed in a track.
/// </summary>
/// <returns>the total sample frames still to be mixed, or -1 if unknown.</returns>
/// <remarks>
/// <para>
/// If the track is playing or paused, and its total duration is known, this
/// will report how much audio is left to mix. If the track is playing, future
/// calls to this function will report different values.
/// </para>
/// <para>
/// Remaining audio is defined in <em>sample frames</em> of decoded audio, not units
/// of time, so that sample-perfect mixing can be achieved. To instead operate
/// in units of time, use MIX_TrackFramesToMS() to convert the return value to
/// milliseconds.
/// </para>
/// <para>
/// This function does not take into account fade-outs or looping, just the
/// current mixing position vs the duration of the track.
/// </para>
/// <para>
/// If the duration of the track isn't known, or <c>track</c> is NULL, this function
/// returns -1. A stopped track reports 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
public long GetRemaining() => SdlMixer.GetTrackRemaining(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_GetTrackTags</c>.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
/// <remarks>
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy, and
/// the native buffer is freed with <c>SDL_free</c> before this method returns.
/// </remarks>
public string[] GetTags() => SdlMixer.GetTrackTags(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PauseTrack</c>. Throws instead of returning false on failure.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void Pause() => SdlMixer.PauseTrack(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_PlayTrack</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="options">a set of properties that control playback. May be zero.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void Play(uint options) => SdlMixer.PlayTrack(this, options);
/// <summary>
/// Ergonomic wrapper over <c>MIX_ResumeTrack</c>. Throws instead of returning false on failure.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void Resume() => SdlMixer.ResumeTrack(this);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrack3DPosition</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="position">the new 3D position for the track. May be NULL.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetTrack3DPosition(MixPoint3D* position) => SdlMixer.SetTrack3DPosition(this, position);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackAudio</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="audio">the new audio input to set. May be NULL.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetAudio(MixAudio audio) => SdlMixer.SetTrackAudio(this, audio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackAudioStream</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="stream">the audio stream to use as the track's input.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetAudioStream(SdlAudioStream stream) => SdlMixer.SetTrackAudioStream(this, stream);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackFrequencyRatio</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="ratio">the frequency ratio. Must be between 0.01f and 100.0f.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetFrequencyRatio(float ratio) => SdlMixer.SetTrackFrequencyRatio(this, ratio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackGain</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="gain">the new gain value.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetGain(float gain) => SdlMixer.SetTrackGain(this, gain);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackGroup</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="group">the new mixing group to assign to. May be NULL.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetGroup(MixGroup group) => SdlMixer.SetTrackGroup(this, group);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackIOStream</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="io">the new i/o stream to use as the track's input.</param>
/// <param name="closeio">if true, close the stream when done with it.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetIOStream(nint io, bool closeio) => SdlMixer.SetTrackIOStream(this, io, closeio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackLoops</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="num_loops">
/// new number of times to loop. Zero to disable looping, -1
/// to loop infinitely.
/// </param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetLoops(int num_loops) => SdlMixer.SetTrackLoops(this, num_loops);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackOutputChannelMap</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="chmap">the new channel map, NULL to reset to default.</param>
/// <param name="count">The number of channels in the map.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetOutputChannelMap(int* chmap, int count) => SdlMixer.SetTrackOutputChannelMap(this, chmap, count);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackPlaybackPosition</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="frames">the sample frame position to seek to.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetPlaybackPosition(long frames) => SdlMixer.SetTrackPlaybackPosition(this, frames);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackRawIOStream</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="io">the new i/o stream to use as the track's input.</param>
/// <param name="spec">the format of the PCM data that the SDL_IOStream will provide.</param>
/// <param name="closeio">if true, close the stream when done with it.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetRawIOStream(nint io, SdlAudioSpec* spec, bool closeio) =>
SdlMixer.SetTrackRawIOStream(this, io, spec, closeio);
/// <summary>
/// Ergonomic wrapper over <c>MIX_SetTrackStereo</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="gains">the per-channel gains, or NULL to disable spatialization.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void SetStereo(MixStereoGains* gains) => SdlMixer.SetTrackStereo(this, gains);
/// <summary>
/// Ergonomic wrapper over <c>MIX_StopTrack</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="fade_out_frames">
/// the number of sample frames to spend fading out to
/// silence before halting. 0 to stop immediately.
/// </param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void Stop(long fade_out_frames) => SdlMixer.StopTrack(this, fade_out_frames);
/// <summary>
/// Ergonomic wrapper over <c>MIX_TagTrack</c>. Throws instead of returning false on failure.
/// </summary>
/// <param name="tag">the tag to add.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the <c>SDL_GetError</c>
/// text.</exception>
public void Tag(string tag) => SdlMixer.TagTrack(this, tag);
/// <summary>
/// Convert sample frames for a track's current format to milliseconds.
/// </summary>
/// <param name="frames">the track-specific sample frames to convert to milliseconds.</param>
/// <returns>
/// Converted number of milliseconds, or -1 for errors/no input; call
/// SDL_GetError() for details.
/// </returns>
/// <remarks>
/// <para>
/// This calculates time based on the track's current input format, which can
/// change when its input does, and also if that input changes formats
/// mid-stream (for example, if decoding a file that is two MP3s concatenated
/// together).
/// </para>
/// <para>
/// Sample frames are more precise than milliseconds, so out of necessity, this
/// function will approximate by rounding down to the closest full millisecond.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns -1. If the track has no input, this returns -1. If <c>frames</c> is &lt; 0,
/// this returns -1.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.TrackMSToFrames"/>
public long FramesToMS(long frames) => SdlMixer.TrackFramesToMS(this, frames);
/// <summary>
/// Convert milliseconds to sample frames for a track's current format.
/// </summary>
/// <param name="ms">the milliseconds to convert to track-specific sample frames.</param>
/// <returns>
/// Converted number of sample frames, or -1 for errors/no input; call
/// SDL_GetError() for details.
/// </returns>
/// <remarks>
/// <para>
/// This calculates time based on the track's current input format, which can
/// change when its input does, and also if that input changes formats
/// mid-stream (for example, if decoding a file that is two MP3s concatenated
/// together).
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns -1. If the track has no input, this returns -1. If <c>ms</c> is &lt; 0,
/// this returns -1.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.TrackFramesToMS"/>
public long MSToFrames(long ms) => SdlMixer.TrackMSToFrames(this, ms);
/// <summary>
/// Query if a track is currently paused.
/// </summary>
/// <returns>true if paused, false otherwise.</returns>
/// <remarks>
/// <para>
/// If this returns true, the track is not currently contributing to the
/// mixer's output but will when resumed (it's "paused"). It is not playing nor
/// stopped.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns false, but there is no mechanism to distinguish errors from
/// non-playing tracks.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.PlayTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.PauseTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.ResumeTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.StopTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.TrackPlaying"/>
public bool Paused() => SdlMixer.TrackPaused(this);
/// <summary>
/// Query if a track is currently playing.
/// </summary>
/// <returns>true if playing, false otherwise.</returns>
/// <remarks>
/// <para>
/// If this returns true, the track is currently contributing to the mixer's
/// output (it's "playing"). It is not stopped nor paused.
/// </para>
/// <para>
/// On various errors (MIX_Init() was not called, the track is NULL), this
/// returns false, but there is no mechanism to distinguish errors from
/// non-playing tracks.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.PlayTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.PauseTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.ResumeTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.StopTrack"/>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.TrackPaused"/>
public bool Playing() => SdlMixer.TrackPlaying(this);
/// <summary>
/// Remove an arbitrary tag from a track.
/// </summary>
/// <param name="tag">the tag to remove, or NULL to remove all current tags.</param>
/// <remarks>
/// <para>
/// A tag can be any valid C string in UTF-8 encoding. It can be useful to
/// group tracks in various ways. For example, everything in-game might be
/// marked as "game", so when the user brings up the settings menu, the app can
/// pause all tracks involved in gameplay at once, but keep background music
/// and menu sound effects running.
/// </para>
/// <para>
/// It's legal to remove a tag that the track doesn't have; this function
/// doesn't report errors, so this simply does nothing.
/// </para>
/// <para>
/// Specifying a NULL tag will remove all tags on a track.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL_mixer 3.0.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Mixer.SdlMixer.PInvoke.TagTrack"/>
public void Untag(string tag) => SdlMixer.UntagTrack(this, tag);
}
}