// // Generated by Brutal.Sdl.Generate; do not edit by hand. #nullable enable namespace Brutal.SdlApi.Mixer { public readonly unsafe partial struct MixAudio { /// /// Convert sample frames for a MIX_Audio's format to milliseconds. /// /// the audio-specific sample frames to convert to milliseconds. /// /// Converted number of milliseconds, or -1 for errors/no input; call /// SDL_GetError() for details. /// /// /// /// This calculates time based on the audio's initial format, even if the /// format would change mid-stream. /// /// /// Sample frames are more precise than milliseconds, so out of necessity, this /// function will approximate by rounding down to the closest full millisecond. /// /// /// If frames is < 0, this returns -1. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public long FramesToMS(long frames) => SdlMixer.AudioFramesToMS(this, frames); /// /// Convert milliseconds to sample frames for a MIX_Audio's format. /// /// the milliseconds to convert to audio-specific sample frames. /// /// Converted number of sample frames, or -1 for errors/no input; call /// SDL_GetError() for details. /// /// /// /// This calculates time based on the audio's initial format, even if the /// format would change mid-stream. /// /// /// If ms is < 0, this returns -1. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public long MSToFrames(long ms) => SdlMixer.AudioMSToFrames(this, ms); /// /// Destroy the specified audio. /// /// /// /// 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. /// /// /// But from the caller's perspective, once this function is called, it should /// assume the audio pointer has become invalid. /// /// /// Destroying a NULL MIX_Audio is a legal no-op. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public void Destroy() { if (IsNull()) { return; } SdlMixer.DestroyAudio(this); } /// /// Get the length of a MIX_Audio's playback in sample frames. /// /// /// the length of the audio in sample frames, or MIX_DURATION_UNKNOWN /// or MIX_DURATION_INFINITE. /// /// /// /// 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. /// /// /// This reports the length of the data in sample frames, 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(). /// /// /// 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. /// /// /// 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. /// /// /// This will return a value >= 0 if a duration is known. It might also return /// MIX_DURATION_UNKNOWN or MIX_DURATION_INFINITE. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public long GetDuration() => SdlMixer.GetAudioDuration(this); /// /// Ergonomic wrapper over MIX_GetAudioFormat. Throws instead of returning false on failure. /// /// on success, audio format details will be stored here. /// The SDL call failed; the message carries the SDL_GetError /// text. public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetAudioFormat(this, spec); /// /// Get the properties associated with a MIX_Audio. /// /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// SDL_mixer offers some properties of its own, but this can also be a /// convenient place to store app-specific data. /// /// /// A SDL_PropertiesID is created the first time this function is called for a /// given MIX_Audio, if necessary. /// /// /// The following read-only properties are provided by SDL_mixer: /// /// /// - MIX_PROP_METADATA_TITLE_STRING: the audio's title ("Smells Like Teen /// Spirit"). /// - MIX_PROP_METADATA_ARTIST_STRING: the audio's artist name ("Nirvana"). /// - MIX_PROP_METADATA_ALBUM_STRING: the audio's album name ("Nevermind"). /// - MIX_PROP_METADATA_COPYRIGHT_STRING: the audio's copyright info /// ("Copyright (c) 1991") /// - MIX_PROP_METADATA_TRACK_NUMBER: the audio's track number on the album /// (1) /// - MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER: the total tracks on the album /// (13) /// - MIX_PROP_METADATA_YEAR_NUMBER: the year the audio was released (1991) /// - MIX_PROP_METADATA_DURATION_FRAMES_NUMBER: 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. /// - MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN: if true, audio never runs /// out of sound to generate. This isn't necessarily always known to /// SDL_mixer, though. /// /// /// Other properties, documented with MIX_LoadAudioWithProperties(), may also /// be present. /// /// /// 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). /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public uint GetProperties() => SdlMixer.GetAudioProperties(this); } public readonly unsafe partial struct MixAudioDecoder { /// /// Decode more audio from a MIX_AudioDecoder. /// /// the memory buffer to store decoded audio. /// the maximum number of bytes to store to buffer. /// the format that audio data will be stored to buffer. /// /// number of bytes decoded, or -1 on error; call SDL_GetError() for /// more information. /// /// /// /// Data is decoded on demand in whatever format is requested. The format is /// permitted to change between calls. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public int DecodeAudio(void* buffer, int buflen, SdlAudioSpec* spec) => SdlMixer.DecodeAudio(this, buffer, buflen, spec); /// /// Destroy the specified audio decoder. /// /// /// /// Destroying a NULL MIX_AudioDecoder is a legal no-op. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public void Destroy() { if (IsNull()) { return; } SdlMixer.DestroyAudioDecoder(this); } /// /// Ergonomic wrapper over MIX_GetAudioDecoderFormat. Throws instead of returning false on failure. /// /// on success, audio format details will be stored here. /// The SDL call failed; the message carries the SDL_GetError /// text. public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetAudioDecoderFormat(this, spec); /// /// Get the properties associated with a MIX_AudioDecoder. /// /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// SDL_mixer offers some properties of its own, but this can also be a /// convenient place to store app-specific data. /// /// /// A SDL_PropertiesID is created the first time this function is called for a /// given MIX_AudioDecoder, if necessary. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public uint GetProperties() => SdlMixer.GetAudioDecoderProperties(this); } public readonly unsafe partial struct MixGroup { /// /// Destroy a mixing group. /// /// /// /// Any tracks currently assigned to this group will be reassigned to the /// mixer's internal default group. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public void Destroy() { if (IsNull()) { return; } SdlMixer.DestroyGroup(this); } /// /// Ergonomic wrapper over MIX_GetGroupMixer. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource this /// call does not own. A null handle is returned on failure. /// public MixMixer GetMixer() => SdlMixer.GetGroupMixer(this); /// /// Get the properties associated with a group. /// /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// Currently SDL_mixer assigns no properties of its own to a group, but this /// can be a convenient place to store app-specific data. /// /// /// A SDL_PropertiesID is created the first time this function is called for a /// given group. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public uint GetProperties() => SdlMixer.GetGroupProperties(this); } public readonly unsafe partial struct MixMixer { /// /// Ergonomic wrapper over MIX_CreateGroup. Throws instead of returning a null handle on failure. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixGroup CreateGroup() => SdlMixer.CreateGroup(this); /// /// Ergonomic wrapper over MIX_CreateSineWaveAudio. Throws instead of returning a null handle on /// failure. /// /// the sinewave's frequency in Hz. /// the sinewave's amplitude from 0.0f to 1.0f. /// /// the maximum number of milliseconds of audio to generate, or less /// than zero to generate infinite audio. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio CreateSineWaveAudio(int hz, float amplitude, long ms) => SdlMixer.CreateSineWaveAudio(this, hz, amplitude, ms); /// /// Ergonomic wrapper over MIX_CreateTrack. Throws instead of returning a null handle on failure. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixTrack CreateTrack() => SdlMixer.CreateTrack(this); /// /// Free a mixer. /// /// /// /// If this mixer was created with MIX_CreateMixerDevice(), this function will /// also close the audio device and call SDL_QuitSubSystem(SDL_INIT_AUDIO). /// /// /// 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()). /// /// /// 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. /// /// /// /// 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. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// public void Destroy() { if (IsNull()) { return; } SdlMixer.DestroyMixer(this); } /// /// Generate mixer output when not driving an audio device. /// /// a pointer to a buffer to store audio in. /// the number of bytes to store in buffer. /// /// The number of bytes of mixed audio, discounting appended silence, /// on success, or -1 on failure; call SDL_GetError() for more /// information. /// /// /// /// 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. /// /// /// The caller may request as much audio as desired, so long as buflen 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). /// /// /// 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. /// /// /// On success, this always fills buffer with buflen bytes of audio; if all /// playing tracks finish mixing, it will fill the remaining buffer with /// silence. /// /// /// 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. /// /// /// This function can not be used with mixers from MIX_CreateMixerDevice(); /// those generate audio as needed internally. /// /// /// This function returns the number of bytes of real audio mixed, which /// might be less than buflen. While all buflen bytes of buffer 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 >= 0 signifies /// success. A return value of -1 means failure (out of memory, invalid /// parameters, etc). /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public int Generate(void* buffer, int buflen) => SdlMixer.Generate(this, buffer, buflen); /// /// Ergonomic wrapper over MIX_GetMixerFormat. Throws instead of returning false on failure. /// /// where to store the mixer audio format. /// The SDL call failed; the message carries the SDL_GetError /// text. public void GetFormat(SdlAudioSpec* spec) => SdlMixer.GetMixerFormat(this, spec); /// /// Get a mixer's master frequency ratio. /// /// the mixer's current master frequency ratio. /// /// /// This returns the last value set through MIX_SetMixerFrequencyRatio(), or /// 1.0f if no value has ever been explicitly set. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// public float GetFrequencyRatio() => SdlMixer.GetMixerFrequencyRatio(this); /// /// Get a mixer's master gain control. /// /// the mixer's current master gain. /// /// /// This returns the last value set through MIX_SetMixerGain(), or 1.0f if no /// value has ever been explicitly set. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// public float GetGain() => SdlMixer.GetMixerGain(this); /// /// Get the properties associated with a mixer. /// /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// The following read-only properties are provided by SDL_mixer: /// /// /// - MIX_PROP_MIXER_DEVICE_NUMBER: 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(). /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public uint GetProperties() => SdlMixer.GetMixerProperties(this); /// /// Ergonomic wrapper over MIX_GetTaggedTracks. /// /// the tag to search. /// The SDL call failed; the message carries the SDL_GetError /// text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, and /// the native buffer is freed with SDL_free before this method returns. Each element is a /// borrowed handle: it is owned by SDL, not created by this call, and must not be disposed. Do not /// call on any element. /// public MixTrack[] GetTaggedTracks(string tag) => SdlMixer.GetTaggedTracks(this, tag); /// /// Ergonomic wrapper over MIX_LoadAudio. Throws instead of returning a null handle on failure. /// /// the path on the filesystem to load data from. /// if true, data will be fully uncompressed before returning. /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadAudio(string path, bool predecode) => SdlMixer.LoadAudio(this, path, predecode); /// /// Ergonomic wrapper over MIX_LoadAudio_IO. Throws instead of returning a null handle on failure. /// /// the SDL_IOStream to load data from. /// if true, data will be fully uncompressed before returning. /// /// true if SDL_mixer should close io before returning /// (success or failure). /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadAudioIO(nint io, bool predecode, bool closeio) => SdlMixer.LoadAudioIO(this, io, predecode, closeio); /// /// Ergonomic wrapper over MIX_LoadAudioNoCopy. Throws instead of returning a null handle on failure. /// /// the buffer where the audio data lives. /// the size, in bytes, of the buffer. /// /// if true, data will be given to SDL_free() when the /// MIX_Audio is destroyed. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadAudioNoCopy(void* data, nuint datalen, bool free_when_done) => SdlMixer.LoadAudioNoCopy(this, data, datalen, free_when_done); /// /// Ergonomic wrapper over MIX_LoadRawAudio. Throws instead of returning a null handle on failure. /// /// the raw PCM data to load. /// the size, in bytes, of the raw PCM data. /// what format the raw data is in. /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadRawAudio(void* data, nuint datalen, SdlAudioSpec* spec) => SdlMixer.LoadRawAudio(this, data, datalen, spec); /// /// Ergonomic wrapper over MIX_LoadRawAudio_IO. Throws instead of returning a null handle on failure. /// /// the SDL_IOStream to load data from. /// what format the raw data is in. /// /// true if SDL_mixer should close io before returning /// (success or failure). /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadRawAudioIO(nint io, SdlAudioSpec* spec, bool closeio) => SdlMixer.LoadRawAudioIO(this, io, spec, closeio); /// /// Ergonomic wrapper over MIX_LoadRawAudioNoCopy. Throws instead of returning a null handle on /// failure. /// /// the buffer where the raw PCM data lives. /// the size, in bytes, of the buffer. /// what format the raw data is in. /// /// if true, data will be given to SDL_free() when the /// MIX_Audio is destroyed. /// /// The created handle (never a null handle). /// The SDL call failed; the message carries the SDL_GetError /// text. public MixAudio LoadRawAudioNoCopy(void* data, nuint datalen, SdlAudioSpec* spec, bool free_when_done) => SdlMixer.LoadRawAudioNoCopy(this, data, datalen, spec, free_when_done); /// /// Lock a mixer by obtaining its internal mutex. /// /// /// /// 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. /// /// /// 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. /// /// /// Just about every SDL_mixer API also 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: /// /// /// - 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. /// /// /// 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. /// /// /// Do not lock the mixer for significant amounts of time, or it can cause /// audio dropouts. Just do simple things quickly and unlock again. /// /// /// Locking a NULL mixer is a safe no-op. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public void Lock() => SdlMixer.LockMixer(this); /// /// Ergonomic wrapper over MIX_PauseAllTracks. Throws instead of returning false on failure. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void PauseAllTracks() => SdlMixer.PauseAllTracks(this); /// /// Ergonomic wrapper over MIX_PauseTag. Throws instead of returning false on failure. /// /// the tag to use when searching for tracks. /// The SDL call failed; the message carries the SDL_GetError /// text. public void PauseTag(string tag) => SdlMixer.PauseTag(this, tag); /// /// Ergonomic wrapper over MIX_PlayAudio. Throws instead of returning false on failure. /// /// the audio input to play. /// The SDL call failed; the message carries the SDL_GetError /// text. public void PlayAudio(MixAudio audio) => SdlMixer.PlayAudio(this, audio); /// /// Ergonomic wrapper over MIX_PlayTag. Throws instead of returning false on failure. /// /// the tag to use when searching for tracks. /// the set of options that will be applied to each track. /// The SDL call failed; the message carries the SDL_GetError /// text. public void PlayTag(string tag, uint options) => SdlMixer.PlayTag(this, tag, options); /// /// Ergonomic wrapper over MIX_ResumeAllTracks. Throws instead of returning false on failure. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void ResumeAllTracks() => SdlMixer.ResumeAllTracks(this); /// /// Ergonomic wrapper over MIX_ResumeTag. Throws instead of returning false on failure. /// /// the tag to use when searching for tracks. /// The SDL call failed; the message carries the SDL_GetError /// text. public void ResumeTag(string tag) => SdlMixer.ResumeTag(this, tag); /// /// Ergonomic wrapper over MIX_SetMixerFrequencyRatio. Throws instead of returning false on failure. /// /// the frequency ratio. Must be between 0.01f and 100.0f. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetFrequencyRatio(float ratio) => SdlMixer.SetMixerFrequencyRatio(this, ratio); /// /// Ergonomic wrapper over MIX_SetMixerGain. Throws instead of returning false on failure. /// /// the new gain value. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetGain(float gain) => SdlMixer.SetMixerGain(this, gain); /// /// Ergonomic wrapper over MIX_SetTagGain. Throws instead of returning false on failure. /// /// the tag to use when searching for tracks. /// the new gain value. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetTagGain(string tag, float gain) => SdlMixer.SetTagGain(this, tag, gain); /// /// Ergonomic wrapper over MIX_StopAllTracks. Throws instead of returning false on failure. /// /// /// the number of milliseconds to spend fading out to /// silence before halting. 0 to stop immediately. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void StopAllTracks(long fade_out_ms) => SdlMixer.StopAllTracks(this, fade_out_ms); /// /// Ergonomic wrapper over MIX_StopTag. Throws instead of returning false on failure. /// /// the tag to use when searching for tracks. /// /// the number of milliseconds to spend fading out to /// silence before halting. 0 to stop immediately. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void StopTag(string tag, long fade_out_ms) => SdlMixer.StopTag(this, tag, fade_out_ms); /// /// Unlock a mixer previously locked by a call to MIX_LockMixer(). /// /// /// /// 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. /// /// /// 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. /// /// /// Unlocking a NULL mixer is a safe no-op. /// /// /// /// This call must be paired with a previous MIX_LockMixer call /// on the same thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public void Unlock() => SdlMixer.UnlockMixer(this); } public readonly unsafe partial struct MixTrack { /// /// Destroy the specified track. /// /// /// /// 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 not be called. /// /// /// 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. /// /// /// Destroying a NULL MIX_Track is a legal no-op. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public void Destroy() { if (IsNull()) { return; } SdlMixer.DestroyTrack(this); } /// /// Ergonomic wrapper over MIX_GetTrack3DPosition. Throws instead of returning false on failure. /// /// on successful return, will contain the track's position. /// The SDL call failed; the message carries the SDL_GetError /// text. public void GetTrack3DPosition(MixPoint3D* position) => SdlMixer.GetTrack3DPosition(this, position); /// /// Ergonomic wrapper over MIX_GetTrackAudio. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource this /// call does not own. A null handle is returned on failure. /// public MixAudio GetAudio() => SdlMixer.GetTrackAudio(this); /// /// Ergonomic wrapper over MIX_GetTrackAudioStream. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource this /// call does not own. A null handle is returned on failure. /// public SdlAudioStream GetAudioStream() => SdlMixer.GetTrackAudioStream(this); /// /// Query whether a given track is fading. /// /// /// less than 0 if the track is fading out, greater than 0 if fading /// in, zero otherwise. /// /// /// /// This specifically checks if the track is not stopped (paused or playing), /// and it is fading in or out, and returns the number of frames remaining in /// the fade. /// /// /// 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. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public long GetFadeFrames() => SdlMixer.GetTrackFadeFrames(this); /// /// Query the frequency ratio of a track. /// /// /// the current frequency ratio, or 0.0f on failure; call /// SDL_GetError() for more information. /// /// /// /// 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. /// /// /// The default value is 1.0f. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public float GetFrequencyRatio() => SdlMixer.GetTrackFrequencyRatio(this); /// /// Get a track's gain control. /// /// the track's current gain. /// /// /// This returns the last value set through MIX_SetTrackGain(), or 1.0f if no /// value has ever been explicitly set. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// public float GetGain() => SdlMixer.GetTrackGain(this); /// /// Query how many loops remain for a given track. /// /// /// the number of pending loops, zero if not looping, and -1 if /// looping infinitely. /// /// /// /// 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 was looping but is on its final iteration of the loop (will stop /// when this iteration completes), this will return zero. /// /// /// A track that is looping infinitely will return -1. This value does not /// report an error in this case. /// /// /// A track that is stopped (not playing and not paused) will have zero loops /// remaining. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public int GetLoops() => SdlMixer.GetTrackLoops(this); /// /// Ergonomic wrapper over MIX_GetTrackMixer. /// /// /// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be /// disposed. Do not call on it; doing so would free a resource this /// call does not own. A null handle is returned on failure. /// public MixMixer GetMixer() => SdlMixer.GetTrackMixer(this); /// /// Get the current input position of a playing track. /// /// /// the track's current sample frame position, or -1 on error; call /// SDL_GetError() for details. /// /// /// /// (Not to be confused with MIX_GetTrack3DPosition(), which is positioning of /// the track in 3D space, not the playback position of its audio data.) /// /// /// Position is defined in sample frames 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. /// /// /// Stopped and paused tracks will report the position when they halted. /// Playing tracks will report the current position, which will change over /// time. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public long GetPlaybackPosition() => SdlMixer.GetTrackPlaybackPosition(this); /// /// Get the properties associated with a track. /// /// /// a valid property ID on success or 0 on failure; call /// SDL_GetError() for more information. /// /// /// /// Currently SDL_mixer assigns no properties of its own to a track, but this /// can be a convenient place to store app-specific data. /// /// /// A SDL_PropertiesID is created the first time this function is called for a /// given track. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public uint GetProperties() => SdlMixer.GetTrackProperties(this); /// /// Return the number of sample frames remaining to be mixed in a track. /// /// the total sample frames still to be mixed, or -1 if unknown. /// /// /// 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. /// /// /// Remaining audio is defined in sample frames 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. /// /// /// This function does not take into account fade-outs or looping, just the /// current mixing position vs the duration of the track. /// /// /// If the duration of the track isn't known, or track is NULL, this function /// returns -1. A stopped track reports 0. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// public long GetRemaining() => SdlMixer.GetTrackRemaining(this); /// /// Ergonomic wrapper over MIX_GetTrackTags. /// /// The SDL call failed; the message carries the SDL_GetError /// text. /// /// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy, and /// the native buffer is freed with SDL_free before this method returns. /// public string[] GetTags() => SdlMixer.GetTrackTags(this); /// /// Ergonomic wrapper over MIX_PauseTrack. Throws instead of returning false on failure. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void Pause() => SdlMixer.PauseTrack(this); /// /// Ergonomic wrapper over MIX_PlayTrack. Throws instead of returning false on failure. /// /// a set of properties that control playback. May be zero. /// The SDL call failed; the message carries the SDL_GetError /// text. public void Play(uint options) => SdlMixer.PlayTrack(this, options); /// /// Ergonomic wrapper over MIX_ResumeTrack. Throws instead of returning false on failure. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void Resume() => SdlMixer.ResumeTrack(this); /// /// Ergonomic wrapper over MIX_SetTrack3DPosition. Throws instead of returning false on failure. /// /// the new 3D position for the track. May be NULL. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetTrack3DPosition(MixPoint3D* position) => SdlMixer.SetTrack3DPosition(this, position); /// /// Ergonomic wrapper over MIX_SetTrackAudio. Throws instead of returning false on failure. /// /// the new audio input to set. May be NULL. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetAudio(MixAudio audio) => SdlMixer.SetTrackAudio(this, audio); /// /// Ergonomic wrapper over MIX_SetTrackAudioStream. Throws instead of returning false on failure. /// /// the audio stream to use as the track's input. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetAudioStream(SdlAudioStream stream) => SdlMixer.SetTrackAudioStream(this, stream); /// /// Ergonomic wrapper over MIX_SetTrackFrequencyRatio. Throws instead of returning false on failure. /// /// the frequency ratio. Must be between 0.01f and 100.0f. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetFrequencyRatio(float ratio) => SdlMixer.SetTrackFrequencyRatio(this, ratio); /// /// Ergonomic wrapper over MIX_SetTrackGain. Throws instead of returning false on failure. /// /// the new gain value. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetGain(float gain) => SdlMixer.SetTrackGain(this, gain); /// /// Ergonomic wrapper over MIX_SetTrackGroup. Throws instead of returning false on failure. /// /// the new mixing group to assign to. May be NULL. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetGroup(MixGroup group) => SdlMixer.SetTrackGroup(this, group); /// /// Ergonomic wrapper over MIX_SetTrackIOStream. Throws instead of returning false on failure. /// /// the new i/o stream to use as the track's input. /// if true, close the stream when done with it. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetIOStream(nint io, bool closeio) => SdlMixer.SetTrackIOStream(this, io, closeio); /// /// Ergonomic wrapper over MIX_SetTrackLoops. Throws instead of returning false on failure. /// /// /// new number of times to loop. Zero to disable looping, -1 /// to loop infinitely. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetLoops(int num_loops) => SdlMixer.SetTrackLoops(this, num_loops); /// /// Ergonomic wrapper over MIX_SetTrackOutputChannelMap. Throws instead of returning false on failure. /// /// the new channel map, NULL to reset to default. /// The number of channels in the map. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetOutputChannelMap(int* chmap, int count) => SdlMixer.SetTrackOutputChannelMap(this, chmap, count); /// /// Ergonomic wrapper over MIX_SetTrackPlaybackPosition. Throws instead of returning false on failure. /// /// the sample frame position to seek to. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetPlaybackPosition(long frames) => SdlMixer.SetTrackPlaybackPosition(this, frames); /// /// Ergonomic wrapper over MIX_SetTrackRawIOStream. Throws instead of returning false on failure. /// /// the new i/o stream to use as the track's input. /// the format of the PCM data that the SDL_IOStream will provide. /// if true, close the stream when done with it. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetRawIOStream(nint io, SdlAudioSpec* spec, bool closeio) => SdlMixer.SetTrackRawIOStream(this, io, spec, closeio); /// /// Ergonomic wrapper over MIX_SetTrackStereo. Throws instead of returning false on failure. /// /// the per-channel gains, or NULL to disable spatialization. /// The SDL call failed; the message carries the SDL_GetError /// text. public void SetStereo(MixStereoGains* gains) => SdlMixer.SetTrackStereo(this, gains); /// /// Ergonomic wrapper over MIX_StopTrack. Throws instead of returning false on failure. /// /// /// the number of sample frames to spend fading out to /// silence before halting. 0 to stop immediately. /// /// The SDL call failed; the message carries the SDL_GetError /// text. public void Stop(long fade_out_frames) => SdlMixer.StopTrack(this, fade_out_frames); /// /// Ergonomic wrapper over MIX_TagTrack. Throws instead of returning false on failure. /// /// the tag to add. /// The SDL call failed; the message carries the SDL_GetError /// text. public void Tag(string tag) => SdlMixer.TagTrack(this, tag); /// /// Convert sample frames for a track's current format to milliseconds. /// /// the track-specific sample frames to convert to milliseconds. /// /// Converted number of milliseconds, or -1 for errors/no input; call /// SDL_GetError() for details. /// /// /// /// 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). /// /// /// Sample frames are more precise than milliseconds, so out of necessity, this /// function will approximate by rounding down to the closest full millisecond. /// /// /// 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 frames is < 0, /// this returns -1. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public long FramesToMS(long frames) => SdlMixer.TrackFramesToMS(this, frames); /// /// Convert milliseconds to sample frames for a track's current format. /// /// the milliseconds to convert to track-specific sample frames. /// /// Converted number of sample frames, or -1 for errors/no input; call /// SDL_GetError() for details. /// /// /// /// 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). /// /// /// 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 ms is < 0, /// this returns -1. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public long MSToFrames(long ms) => SdlMixer.TrackMSToFrames(this, ms); /// /// Query if a track is currently paused. /// /// true if paused, false otherwise. /// /// /// 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. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// /// /// /// public bool Paused() => SdlMixer.TrackPaused(this); /// /// Query if a track is currently playing. /// /// true if playing, false otherwise. /// /// /// If this returns true, the track is currently contributing to the mixer's /// output (it's "playing"). It is not stopped nor paused. /// /// /// 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. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// /// /// /// /// public bool Playing() => SdlMixer.TrackPlaying(this); /// /// Remove an arbitrary tag from a track. /// /// the tag to remove, or NULL to remove all current tags. /// /// /// 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. /// /// /// It's legal to remove a tag that the track doesn't have; this function /// doesn't report errors, so this simply does nothing. /// /// /// Specifying a NULL tag will remove all tags on a track. /// /// /// /// It is safe to call this function from any thread. /// /// /// This function is available since SDL_mixer 3.0.0. /// /// public void Untag(string tag) => SdlMixer.UntagTrack(this, tag); } }