package vendor:miniaudio

⌘K
Ctrl+K
or
/

    Overview

    Bindings for miniaudio audio playback and capture library.

    Choice of public domain or MIT-0. See license statements at the end of this file. miniaudio - v0.11.21 - 2023-11-15

    David Reid - mackron@gmail.com

    Website: https://miniaud.io Documentation: https://miniaud.io/docs GitHub: https://github.com/mackron/miniaudio

    1. Introduction =============== miniaudio is a single file library for audio playback and capture. To use it, do the following in one .c file:

    `c #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" `

    You can do #include "miniaudio.h" in other parts of the program just like any other header.

    miniaudio includes both low level and high level APIs. The low level API is good for those who want to do all of their mixing themselves and only require a light weight interface to the underlying audio device. The high level API is good for those who have complex mixing and effect requirements.

    In miniaudio, objects are transparent structures. Unlike many other libraries, there are no handles to opaque objects which means you need to allocate memory for objects yourself. In the examples presented in this documentation you will often see objects declared on the stack. You need to be careful when translating these examples to your own code so that you don't accidentally declare your objects on the stack and then cause them to become invalid once the function returns. In addition, you must ensure the memory address of your objects remain the same throughout their lifetime. You therefore cannot be making copies of your objects.

    A config/init pattern is used throughout the entire library. The idea is that you set up a config object and pass that into the initialization routine. The advantage to this system is that the config object can be initialized with logical defaults and new properties added to it without breaking the API. The config object can be allocated on the stack and does not need to be maintained after initialization of the corresponding object.

    1.1. Low Level API ------------------ The low level API gives you access to the raw audio data of an audio device. It supports playback, capture, full-duplex and loopback (WASAPI only). You can enumerate over devices to determine which physical device(s) you want to connect to.

    The low level API uses the concept of a "device" as the abstraction for physical devices. The idea is that you choose a physical device to emit or capture audio from, and then move data to/from the device when miniaudio tells you to. Data is delivered to and from devices asynchronously via a callback which you specify when initializing the device.

    When initializing the device you first need to configure it. The device configuration allows you to specify things like the format of the data delivered via the callback, the size of the internal buffer and the ID of the device you want to emit or capture audio from.

    Once you have the device configuration set up you can initialize the device. When initializing a device you need to allocate memory for the device object beforehand. This gives the application complete control over how the memory is allocated. In the example below we initialize a playback device on the stack, but you could allocate it on the heap if that suits your situation better.

    `c void data_callback(ma_device pDevice, void pOutput, const void* pInput, ma_uint32 frameCount) { // In playback mode copy data to pOutput. In capture mode read data from pInput. In full-duplex mode, both // pOutput and pInput will be valid and you can move data from pInput into pOutput. Never process more than // frameCount frames. }

    int main() { ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.format = ma_format_f32; // Set to ma_format_unknown to use the device's native format. config.playback.channels = 2; // Set to 0 to use the device's native channel count. config.sampleRate = 48000; // Set to 0 to use the device's native sample rate. config.dataCallback = data_callback; // This function will be called when miniaudio needs more data. config.pUserData = pMyCustomData; // Can be accessed from the device object (device.pUserData).

    ma_device device; if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) { return -1; // Failed to initialize the device. }

    ma_device_start(&device); // The device is sleeping by default so you'll need to start it manually.

    // Do something here. Probably your program's main loop.

    ma_device_uninit(&device); return 0; } `

    In the example above, data_callback() is where audio data is written and read from the device. The idea is in playback mode you cause sound to be emitted from the speakers by writing audio data to the output buffer (pOutput in the example). In capture mode you read data from the input buffer (pInput) to extract sound captured by the microphone. The frameCount parameter tells you how many frames can be written to the output buffer and read from the input buffer. A "frame" is one sample for each channel. For example, in a stereo stream (2 channels), one frame is 2 samples: one for the left, one for the right. The channel count is defined by the device config. The size in bytes of an individual sample is defined by the sample format which is also specified in the device config. Multi-channel audio data is always interleaved, which means the samples for each frame are stored next to each other in memory. For example, in a stereo stream the first pair of samples will be the left and right samples for the first frame, the second pair of samples will be the left and right samples for the second frame, etc.

    The configuration of the device is defined by the ma_device_config structure. The config object is always initialized with ma_device_config_init(). It's important to always initialize the config with this function as it initializes it with logical defaults and ensures your program doesn't break when new members are added to the ma_device_config structure. The example above uses a fairly simple and standard device configuration. The call to ma_device_config_init() takes a single parameter, which is whether or not the device is a playback, capture, duplex or loopback device (loopback devices are not supported on all backends). The config.playback.format member sets the sample format which can be one of the following (all formats are native-endian):

    +---------------+----------------------------------------+---------------------------+ | Symbol | Description | Range | +---------------+----------------------------------------+---------------------------+ | ma_format_f32 | 32-bit floating point | [-1, 1] | | ma_format_s16 | 16-bit signed integer | [-32768, 32767] | | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607] | | ma_format_s32 | 32-bit signed integer | [-2147483648, 2147483647] | | ma_format_u8 | 8-bit unsigned integer | [0, 255] | +---------------+----------------------------------------+---------------------------+

    The config.playback.channels member sets the number of channels to use with the device. The channel count cannot exceed MA_MAX_CHANNELS. The config.sampleRate member sets the sample rate (which must be the same for both playback and capture in full-duplex configurations). This is usually set to 44100 or 48000, but can be set to anything. It's recommended to keep this between 8000 and 384000, however.

    Note that leaving the format, channel count and/or sample rate at their default values will result in the internal device's native configuration being used which is useful if you want to avoid the overhead of miniaudio's automatic data conversion.

    In addition to the sample format, channel count and sample rate, the data callback and user data pointer are also set via the config. The user data pointer is not passed into the callback as a parameter, but is instead set to the pUserData member of ma_device which you can access directly since all miniaudio structures are transparent.

    Initializing the device is done with ma_device_init(). This will return a result code telling you what went wrong, if anything. On success it will return MA_SUCCESS. After initialization is complete the device will be in a stopped state. To start it, use ma_device_start(). Uninitializing the device will stop it, which is what the example above does, but you can also stop the device with ma_device_stop(). To resume the device simply call ma_device_start() again. Note that it's important to never stop or start the device from inside the callback. This will result in a deadlock. Instead you set a variable or signal an event indicating that the device needs to stop and handle it in a different thread. The following APIs must never be called inside the callback:

    `c ma_device_init() ma_device_init_ex() ma_device_uninit() ma_device_start() ma_device_stop() `

    You must never try uninitializing and reinitializing a device inside the callback. You must also never try to stop and start it from inside the callback. There are a few other things you shouldn't do in the callback depending on your requirements, however this isn't so much a thread-safety thing, but rather a real-time processing thing which is beyond the scope of this introduction.

    The example above demonstrates the initialization of a playback device, but it works exactly the same for capture. All you need to do is change the device type from ma_device_type_playback to ma_device_type_capture when setting up the config, like so:

    `c ma_device_config config = ma_device_config_init(ma_device_type_capture); config.capture.format = MY_FORMAT; config.capture.channels = MY_CHANNEL_COUNT; `

    In the data callback you just read from the input buffer (pInput in the example above) and leave the output buffer alone (it will be set to NULL when the device type is set to ma_device_type_capture).

    These are the available device types and how you should handle the buffers in the callback:

    +-------------------------+--------------------------------------------------------+ | Device Type | Callback Behavior | +-------------------------+--------------------------------------------------------+ | ma_device_type_playback | Write to output buffer, leave input buffer untouched. | | ma_device_type_capture | Read from input buffer, leave output buffer untouched. | | ma_device_type_duplex | Read from input buffer, write to output buffer. | | ma_device_type_loopback | Read from input buffer, leave output buffer untouched. | +-------------------------+--------------------------------------------------------+

    You will notice in the example above that the sample format and channel count is specified separately for playback and capture. This is to support different data formats between the playback and capture devices in a full-duplex system. An example may be that you want to capture audio data as a monaural stream (one channel), but output sound to a stereo speaker system. Note that if you use different formats between playback and capture in a full-duplex configuration you will need to convert the data yourself. There are functions available to help you do this which will be explained later.

    The example above did not specify a physical device to connect to which means it will use the operating system's default device. If you have multiple physical devices connected and you want to use a specific one you will need to specify the device ID in the configuration, like so:

    `c config.playback.pDeviceID = pMyPlaybackDeviceID; // Only if requesting a playback or duplex device. config.capture.pDeviceID = pMyCaptureDeviceID; // Only if requesting a capture, duplex or loopback device. `

    To retrieve the device ID you will need to perform device enumeration, however this requires the use of a new concept called the "context". Conceptually speaking the context sits above the device. There is one context to many devices. The purpose of the context is to represent the backend at a more global level and to perform operations outside the scope of an individual device. Mainly it is used for performing run-time linking against backend libraries, initializing backends and enumerating devices. The example below shows how to enumerate devices.

    `c ma_context context; if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { // Error. }

    ma_device_info* pPlaybackInfos; ma_uint32 playbackCount; ma_device_info* pCaptureInfos; ma_uint32 captureCount; if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) { // Error. }

    // Loop over each device info and do something with it. Here we just print the name with their index. You may want // to give the user the opportunity to choose which device they'd prefer. for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) { printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name); }

    ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.pDeviceID = &pPlaybackInfos[chosenPlaybackDeviceIndex].id; config.playback.format = MY_FORMAT; config.playback.channels = MY_CHANNEL_COUNT; config.sampleRate = MY_SAMPLE_RATE; config.dataCallback = data_callback; config.pUserData = pMyCustomData;

    ma_device device; if (ma_device_init(&context, &config, &device) != MA_SUCCESS) { // Error }

    ...

    ma_device_uninit(&device); ma_context_uninit(&context); `

    The first thing we do in this example is initialize a ma_context object with ma_context_init(). The first parameter is a pointer to a list of ma_backend values which are used to override the default backend priorities. When this is NULL, as in this example, miniaudio's default priorities are used. The second parameter is the number of backends listed in the array pointed to by the first parameter. The third parameter is a pointer to a ma_context_config object which can be NULL, in which case defaults are used. The context configuration is used for setting the logging callback, custom memory allocation callbacks, user-defined data and some backend-specific configurations.

    Once the context has been initialized you can enumerate devices. In the example above we use the simpler ma_context_get_devices(), however you can also use a callback for handling devices by using ma_context_enumerate_devices(). When using ma_context_get_devices() you provide a pointer to a pointer that will, upon output, be set to a pointer to a buffer containing a list of ma_device_info structures. You also provide a pointer to an unsigned integer that will receive the number of items in the returned buffer. Do not free the returned buffers as their memory is managed internally by miniaudio.

    The ma_device_info structure contains an id member which is the ID you pass to the device config. It also contains the name of the device which is useful for presenting a list of devices to the user via the UI.

    When creating your own context you will want to pass it to ma_device_init() when initializing the device. Passing in NULL, like we do in the first example, will result in miniaudio creating the context for you, which you don't want to do since you've already created a context. Note that internally the context is only tracked by it's pointer which means you must not change the location of the ma_context object. If this is an issue, consider using malloc() to allocate memory for the context.

    1.2. High Level API ------------------- The high level API consists of three main parts:

    * Resource management for loading and streaming sounds. * A node graph for advanced mixing and effect processing. * A high level "engine" that wraps around the resource manager and node graph.

    The resource manager (ma_resource_manager) is used for loading sounds. It supports loading sounds fully into memory and also streaming. It will also deal with reference counting for you which avoids the same sound being loaded multiple times.

    The node graph is used for mixing and effect processing. The idea is that you connect a number of nodes into the graph by connecting each node's outputs to another node's inputs. Each node can implement its own effect. By chaining nodes together, advanced mixing and effect processing can be achieved.

    The engine encapsulates both the resource manager and the node graph to create a simple, easy to use high level API. The resource manager and node graph APIs are covered in more later sections of this manual.

    The code below shows how you can initialize an engine using it's default configuration.

    `c ma_result result; ma_engine engine;

    result = ma_engine_init(NULL, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } `

    This creates an engine instance which will initialize a device internally which you can access with ma_engine_get_device(). It will also initialize a resource manager for you which can be accessed with ma_engine_get_resource_manager(). The engine itself is a node graph (ma_node_graph) which means you can pass a pointer to the engine object into any of the ma_node_graph APIs (with a cast). Alternatively, you can use ma_engine_get_node_graph() instead of a cast.

    Note that all objects in miniaudio, including the ma_engine object in the example above, are transparent structures. There are no handles to opaque structures in miniaudio which means you need to be mindful of how you declare them. In the example above we are declaring it on the stack, but this will result in the struct being invalidated once the function encapsulating it returns. If allocating the engine on the heap is more appropriate, you can easily do so with a standard call to malloc() or whatever heap allocation routine you like:

    `c ma_engine pEngine = malloc(sizeof(pEngine)); `

    The ma_engine API uses the same config/init pattern used all throughout miniaudio. To configure an engine, you can fill out a ma_engine_config object and pass it into the first parameter of ma_engine_init():

    `c ma_result result; ma_engine engine; ma_engine_config engineConfig;

    engineConfig = ma_engine_config_init(); engineConfig.pResourceManager = &myCustomResourceManager; // <-- Initialized as some earlier stage.

    result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; } `

    This creates an engine instance using a custom config. In this particular example it's showing how you can specify a custom resource manager rather than having the engine initialize one internally. This is particularly useful if you want to have multiple engine's share the same resource manager.

    The engine must be uninitialized with ma_engine_uninit() when it's no longer needed.

    By default the engine will be started, but nothing will be playing because no sounds have been initialized. The easiest but least flexible way of playing a sound is like so:

    `c ma_engine_play_sound(&engine, "my_sound.wav", NULL); `

    This plays what miniaudio calls an "inline" sound. It plays the sound once, and then puts the internal sound up for recycling. The last parameter is used to specify which sound group the sound should be associated with which will be explained later. This particular way of playing a sound is simple, but lacks flexibility and features. A more flexible way of playing a sound is to first initialize a sound:

    `c ma_result result; ma_sound sound;

    result = ma_sound_init_from_file(&engine, "my_sound.wav", 0, NULL, NULL, &sound); if (result != MA_SUCCESS) { return result; }

    ma_sound_start(&sound); `

    This returns a ma_sound object which represents a single instance of the specified sound file. If you want to play the same file multiple times simultaneously, you need to create one sound for each instance.

    Sounds should be uninitialized with ma_sound_uninit().

    Sounds are not started by default. Start a sound with ma_sound_start() and stop it with ma_sound_stop(). When a sound is stopped, it is not rewound to the start. Use ma_sound_seek_to_pcm_frame(&sound, 0) to seek back to the start of a sound. By default, starting and stopping sounds happens immediately, but sometimes it might be convenient to schedule the sound the be started and/or stopped at a specific time. This can be done with the following functions:

    `c ma_sound_set_start_time_in_pcm_frames() ma_sound_set_start_time_in_milliseconds() ma_sound_set_stop_time_in_pcm_frames() ma_sound_set_stop_time_in_milliseconds() `

    The start/stop time needs to be specified based on the absolute timer which is controlled by the engine. The current global time in PCM frames can be retrieved with ma_engine_get_time_in_pcm_frames(). The engine's global time can be changed with ma_engine_set_time_in_pcm_frames() for synchronization purposes if required. Note that scheduling a start time still requires an explicit call to ma_sound_start() before anything will play:

    `c ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2); ma_sound_start(&sound); `

    The third parameter of ma_sound_init_from_file() is a set of flags that control how the sound be loaded and a few options on which features should be enabled for that sound. By default, the sound is synchronously loaded fully into memory straight from the file system without any kind of decoding. If you want to decode the sound before storing it in memory, you need to specify the MA_SOUND_FLAG_DECODE flag. This is useful if you want to incur the cost of decoding at an earlier stage, such as a loading stage. Without this option, decoding will happen dynamically at mixing time which might be too expensive on the audio thread.

    If you want to load the sound asynchronously, you can specify the MA_SOUND_FLAG_ASYNC flag. This will result in ma_sound_init_from_file() returning quickly, but the sound will not start playing until the sound has had some audio decoded.

    The fourth parameter is a pointer to sound group. A sound group is used as a mechanism to organise sounds into groups which have their own effect processing and volume control. An example is a game which might have separate groups for sfx, voice and music. Each of these groups have their own independent volume control. Use ma_sound_group_init() or ma_sound_group_init_ex() to initialize a sound group.

    Sounds and sound groups are nodes in the engine's node graph and can be plugged into any ma_node API. This makes it possible to connect sounds and sound groups to effect nodes to produce complex effect chains.

    A sound can have its volume changed with ma_sound_set_volume(). If you prefer decibel volume control you can use ma_volume_db_to_linear() to convert from decibel representation to linear.

    Panning and pitching is supported with ma_sound_set_pan() and ma_sound_set_pitch(). If you know a sound will never have its pitch changed with ma_sound_set_pitch() or via the doppler effect, you can specify the MA_SOUND_FLAG_NO_PITCH flag when initializing the sound for an optimization.

    By default, sounds and sound groups have spatialization enabled. If you don't ever want to spatialize your sounds, initialize the sound with the MA_SOUND_FLAG_NO_SPATIALIZATION flag. The spatialization model is fairly simple and is roughly on feature parity with OpenAL. HRTF and environmental occlusion are not currently supported, but planned for the future. The supported features include:

    * Sound and listener positioning and orientation with cones * Attenuation models: none, inverse, linear and exponential * Doppler effect

    Sounds can be faded in and out with ma_sound_set_fade_in_pcm_frames().

    To check if a sound is currently playing, you can use ma_sound_is_playing(). To check if a sound is at the end, use ma_sound_at_end(). Looping of a sound can be controlled with ma_sound_set_looping(). Use ma_sound_is_looping() to check whether or not the sound is looping.

    2. Building =========== miniaudio should work cleanly out of the box without the need to download or install any dependencies. See below for platform-specific details.

    Note that GCC and Clang require -msse2, -mavx2, etc. for SIMD optimizations.

    If you get errors about undefined references to __sync_val_compare_and_swap_8, __atomic_load_8, etc. you need to link with -latomic.

    2.1. Windows ------------ The Windows build should compile cleanly on all popular compilers without the need to configure any include paths nor link to any libraries.

    The UWP build may require linking to mmdevapi.lib if you get errors about an unresolved external symbol for ActivateAudioInterfaceAsync().

    2.2. macOS and iOS ------------------ The macOS build should compile cleanly without the need to download any dependencies nor link to any libraries or frameworks. The iOS build needs to be compiled as Objective-C and will need to link the relevant frameworks but should compile cleanly out of the box with Xcode. Compiling through the command line requires linking to -lpthread and -lm.

    Due to the way miniaudio links to frameworks at runtime, your application may not pass Apple's notarization process. To fix this there are two options. The first is to compile with -DMA_NO_RUNTIME_LINKING which in turn will require linking with -framework CoreFoundation -framework CoreAudio -framework AudioToolbox. If you get errors about AudioToolbox, try with -framework AudioUnit instead. You may get this when using older versions of iOS. Alternatively, if you would rather keep using runtime linking you can add the following to your entitlements.xcent file:

    ` <key>com.apple.security.cs.allow-dyld-environment-variables</key> <true/> <key>com.apple.security.cs.allow-unsigned-executable-memory</key> <true/> `

    See this discussion for more info: https://github.com/mackron/miniaudio/issues/203.

    2.3. Linux ---------- The Linux build only requires linking to -ldl, -lpthread and -lm. You do not need any development packages. You may need to link with -latomic if you're compiling for 32-bit ARM.

    2.4. BSD -------- The BSD build only requires linking to -lpthread and -lm. NetBSD uses audio(4), OpenBSD uses sndio and FreeBSD uses OSS. You may need to link with -latomic if you're compiling for 32-bit ARM.

    2.5. Android ------------ AAudio is the highest priority backend on Android. This should work out of the box without needing any kind of compiler configuration. Support for AAudio starts with Android 8 which means older versions will fall back to OpenSL|ES which requires API level 16+.

    There have been reports that the OpenSL|ES backend fails to initialize on some Android based devices due to dlopen() failing to open "libOpenSLES.so". If this happens on your platform you'll need to disable run-time linking with MA_NO_RUNTIME_LINKING and link with -lOpenSLES.

    2.6. Emscripten --------------- The Emscripten build emits Web Audio JavaScript directly and should compile cleanly out of the box. You cannot use -std=c* compiler flags, nor -ansi.

    You can enable the use of AudioWorkets by defining MA_ENABLE_AUDIO_WORKLETS and then compiling with the following options:

    -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY

    An example for compiling with AudioWorklet support might look like this:

    emcc program.c -o bin/program.html -DMA_ENABLE_AUDIO_WORKLETS -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY

    To run locally, you'll need to use emrun:

    emrun bin/program.html

    2.7. Build Options ------------------ #define these options before including miniaudio.c, or pass them as compiler flags:

    +----------------------------------+--------------------------------------------------------------------+ | Option | Description | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WASAPI | Disables the WASAPI backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DSOUND | Disables the DirectSound backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WINMM | Disables the WinMM backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ALSA | Disables the ALSA backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_PULSEAUDIO | Disables the PulseAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_JACK | Disables the JACK backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_COREAUDIO | Disables the Core Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_SNDIO | Disables the sndio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AUDIO4 | Disables the audio(4) backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_OSS | Disables the OSS backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AAUDIO | Disables the AAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_OPENSL | Disables the OpenSL|ES backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WEBAUDIO | Disables the Web Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_CUSTOM | Disables support for custom backends. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NULL | Disables the null backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_ONLY_SPECIFIC_BACKENDS | Disables all backends by default and requires MA_ENABLE_* to | | | enable specific backends. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WASAPI | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the WASAPI backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_DSOUND | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the DirectSound backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WINMM | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the WinMM backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_ALSA | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the ALSA backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_PULSEAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the PulseAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_JACK | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the JACK backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_COREAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the Core Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_SNDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the sndio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_AUDIO4 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the audio(4) backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_OSS | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the OSS backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_AAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the AAudio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_OPENSL | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the OpenSL|ES backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_WEBAUDIO | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the Web Audio backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_CUSTOM | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable custom backends. | +----------------------------------+--------------------------------------------------------------------+ | MA_ENABLE_NULL | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to | | | enable the null backend. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DECODING | Disables decoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ENCODING | Disables encoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_WAV | Disables the built-in WAV decoder and encoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_FLAC | Disables the built-in FLAC decoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_MP3 | Disables the built-in MP3 decoder. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_DEVICE_IO | Disables playback and recording. This will disable ma_context | | | and ma_device APIs. This is useful if you only want to use | | | miniaudio's data conversion and/or decoding APIs. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_RESOURCE_MANAGER | Disables the resource manager. When using the engine this will | | | also disable the following functions: | | | | | | ` | | | ma_sound_init_from_file() | | | ma_sound_init_from_file_w() | | | ma_sound_init_copy() | | | ma_engine_play_sound_ex() | | | ma_engine_play_sound() | | | ` | | | | | | The only way to initialize a ma_sound object is to initialize it | | | from a data source. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NODE_GRAPH | Disables the node graph API. This will also disable the engine API | | | because it depends on the node graph. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_ENGINE | Disables the engine API. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_THREADING | Disables the ma_thread, ma_mutex, ma_semaphore and | | | ma_event APIs. This option is useful if you only need to use | | | miniaudio for data conversion, decoding and/or encoding. Some | | | families of APIs require threading which means the following | | | options must also be set: | | | | | | ` | | | MA_NO_DEVICE_IO | | | ` | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_GENERATION | Disables generation APIs such a ma_waveform and ma_noise. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_SSE2 | Disables SSE2 optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_AVX2 | Disables AVX2 optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_NEON | Disables NEON optimizations. | +----------------------------------+--------------------------------------------------------------------+ | MA_NO_RUNTIME_LINKING | Disables runtime linking. This is useful for passing Apple's | | | notarization process. When enabling this, you may need to avoid | | | using -std=c89 or -std=c99 on Linux builds or else you may end | | | up with compilation errors due to conflicts with timespec and | | | timeval data types. | | | | | | You may need to enable this if your target platform does not allow | | | runtime linking via dlopen(). | +----------------------------------+--------------------------------------------------------------------+ | MA_USE_STDINT | (Pass this in a compiler flag. Do not #define this before |

    |                                  | miniaudio.c) Forces the use of stdint.h for sized types.           |
    

    +----------------------------------+--------------------------------------------------------------------+ | MA_DEBUG_OUTPUT | Enable printf() output of debug logs (MA_LOG_LEVEL_DEBUG). | +----------------------------------+--------------------------------------------------------------------+ | MA_COINIT_VALUE | Windows only. The value to pass to internal calls to | | | CoInitializeEx(). Defaults to COINIT_MULTITHREADED. | +----------------------------------+--------------------------------------------------------------------+ | MA_FORCE_UWP | Windows only. Affects only the WASAPI backend. Will force the | | | WASAPI backend to use the UWP code path instead of the regular | | | desktop path. This is normally auto-detected and should rarely be | | | needed to be used explicitly, but can be useful for debugging. | +----------------------------------+--------------------------------------------------------------------+ | MA_ON_THREAD_ENTRY | Defines some code that will be executed as soon as an internal | | | miniaudio-managed thread is created. This will be the first thing | | | to be executed by the thread entry point. | +----------------------------------+--------------------------------------------------------------------+ | MA_ON_THREAD_EXIT | Defines some code that will be executed from the entry point of an | | | internal miniaudio-managed thread upon exit. This will be the last | | | thing to be executed before the thread's entry point exits. | +----------------------------------+--------------------------------------------------------------------+ | MA_THREAD_DEFAULT_STACK_SIZE | If set, specifies the default stack size used by miniaudio-managed | | | threads. | +----------------------------------+--------------------------------------------------------------------+ | MA_API | Controls how public APIs should be decorated. Default is extern. | +----------------------------------+--------------------------------------------------------------------+

    3. Definitions ============== This section defines common terms used throughout miniaudio. Unfortunately there is often ambiguity in the use of terms throughout the audio space, so this section is intended to clarify how miniaudio uses each term.

    3.1. Sample ----------- A sample is a single unit of audio data. If the sample format is f32, then one sample is one 32-bit floating point number.

    3.2. Frame / PCM Frame ---------------------- A frame is a group of samples equal to the number of channels. For a stereo stream a frame is 2 samples, a mono frame is 1 sample, a 5.1 surround sound frame is 6 samples, etc. The terms "frame" and "PCM frame" are the same thing in miniaudio. Note that this is different to a compressed frame. If ever miniaudio needs to refer to a compressed frame, such as a FLAC frame, it will always clarify what it's referring to with something like "FLAC frame".

    3.3. Channel ------------ A stream of monaural audio that is emitted from an individual speaker in a speaker system, or received from an individual microphone in a microphone system. A stereo stream has two channels (a left channel, and a right channel), a 5.1 surround sound system has 6 channels, etc. Some audio systems refer to a channel as a complex audio stream that's mixed with other channels to produce the final mix - this is completely different to miniaudio's use of the term "channel" and should not be confused.

    3.4. Sample Rate ---------------- The sample rate in miniaudio is always expressed in Hz, such as 44100, 48000, etc. It's the number of PCM frames that are processed per second.

    3.5. Formats ------------ Throughout miniaudio you will see references to different sample formats:

    +---------------+----------------------------------------+---------------------------+ | Symbol | Description | Range | +---------------+----------------------------------------+---------------------------+ | ma_format_f32 | 32-bit floating point | [-1, 1] | | ma_format_s16 | 16-bit signed integer | [-32768, 32767] | | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607] | | ma_format_s32 | 32-bit signed integer | [-2147483648, 2147483647] | | ma_format_u8 | 8-bit unsigned integer | [0, 255] | +---------------+----------------------------------------+---------------------------+

    All formats are native-endian.

    4. Data Sources =============== The data source abstraction in miniaudio is used for retrieving audio data from some source. A few examples include ma_decoder, ma_noise and ma_waveform. You will need to be familiar with data sources in order to make sense of some of the higher level concepts in miniaudio.

    The ma_data_source API is a generic interface for reading from a data source. Any object that implements the data source interface can be plugged into any ma_data_source function.

    To read data from a data source:

    `c ma_result result; ma_uint64 framesRead;

    result = ma_data_source_read_pcm_frames(pDataSource, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { return result; // Failed to read data from the data source. } `

    If you don't need the number of frames that were successfully read you can pass in NULL to the pFramesRead parameter. If this returns a value less than the number of frames requested it means the end of the file has been reached. MA_AT_END will be returned only when the number of frames read is 0.

    When calling any data source function, with the exception of ma_data_source_init() and ma_data_source_uninit(), you can pass in any object that implements a data source. For example, you could plug in a decoder like so:

    `c ma_result result; ma_uint64 framesRead; ma_decoder decoder; // <-- This would be initialized with ma_decoder_init_*().

    result = ma_data_source_read_pcm_frames(&decoder, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { return result; // Failed to read data from the decoder. } `

    If you want to seek forward you can pass in NULL to the pFramesOut parameter. Alternatively you can use ma_data_source_seek_pcm_frames().

    To seek to a specific PCM frame:

    `c result = ma_data_source_seek_to_pcm_frame(pDataSource, frameIndex); if (result != MA_SUCCESS) { return result; // Failed to seek to PCM frame. } `

    You can retrieve the total length of a data source in PCM frames, but note that some data sources may not have the notion of a length, such as noise and waveforms, and others may just not have a way of determining the length such as some decoders. To retrieve the length:

    `c ma_uint64 length;

    result = ma_data_source_get_length_in_pcm_frames(pDataSource, &length); if (result != MA_SUCCESS) { return result; // Failed to retrieve the length. } `

    Care should be taken when retrieving the length of a data source where the underlying decoder is pulling data from a data stream with an undefined length, such as internet radio or some kind of broadcast. If you do this, ma_data_source_get_length_in_pcm_frames() may never return.

    The current position of the cursor in PCM frames can also be retrieved:

    `c ma_uint64 cursor;

    result = ma_data_source_get_cursor_in_pcm_frames(pDataSource, &cursor); if (result != MA_SUCCESS) { return result; // Failed to retrieve the cursor. } `

    You will often need to know the data format that will be returned after reading. This can be retrieved like so:

    `c ma_format format; ma_uint32 channels; ma_uint32 sampleRate; ma_channel channelMap[MA_MAX_CHANNELS];

    result = ma_data_source_get_data_format(pDataSource, &format, &channels, &sampleRate, channelMap, MA_MAX_CHANNELS); if (result != MA_SUCCESS) { return result; // Failed to retrieve data format. } `

    If you do not need a specific data format property, just pass in NULL to the respective parameter.

    There may be cases where you want to implement something like a sound bank where you only want to read data within a certain range of the underlying data. To do this you can use a range:

    `c result = ma_data_source_set_range_in_pcm_frames(pDataSource, rangeBegInFrames, rangeEndInFrames); if (result != MA_SUCCESS) { return result; // Failed to set the range. } `

    This is useful if you have a sound bank where many sounds are stored in the same file and you want the data source to only play one of those sub-sounds. Note that once the range is set, everything that takes a position, such as cursors and loop points, should always be relatvie to the start of the range. When the range is set, any previously defined loop point will be reset.

    Custom loop points can also be used with data sources. By default, data sources will loop after they reach the end of the data source, but if you need to loop at a specific location, you can do the following:

    `c result = ma_data_set_loop_point_in_pcm_frames(pDataSource, loopBegInFrames, loopEndInFrames); if (result != MA_SUCCESS) { return result; // Failed to set the loop point. } `

    The loop point is relative to the current range.

    It's sometimes useful to chain data sources together so that a seamless transition can be achieved. To do this, you can use chaining:

    `c ma_decoder decoder1; ma_decoder decoder2;

    // ... initialize decoders with ma_decoder_init_*() ...

    result = ma_data_source_set_next(&decoder1, &decoder2); if (result != MA_SUCCESS) { return result; // Failed to set the next data source. }

    result = ma_data_source_read_pcm_frames(&decoder1, pFramesOut, frameCount, pFramesRead); if (result != MA_SUCCESS) { return result; // Failed to read from the decoder. } `

    In the example above we're using decoders. When reading from a chain, you always want to read from the top level data source in the chain. In the example above, decoder1 is the top level data source in the chain. When decoder1 reaches the end, decoder2 will start seamlessly without any gaps.

    Note that when looping is enabled, only the current data source will be looped. You can loop the entire chain by linking in a loop like so:

    `c ma_data_source_set_next(&decoder1, &decoder2); // decoder1 -> decoder2 ma_data_source_set_next(&decoder2, &decoder1); // decoder2 -> decoder1 (loop back to the start). `

    Note that setting up chaining is not thread safe, so care needs to be taken if you're dynamically changing links while the audio thread is in the middle of reading.

    Do not use ma_decoder_seek_to_pcm_frame() as a means to reuse a data source to play multiple instances of the same sound simultaneously. This can be extremely inefficient depending on the type of data source and can result in glitching due to subtle changes to the state of internal filters. Instead, initialize multiple data sources for each instance.

    4.1. Custom Data Sources ------------------------ You can implement a custom data source by implementing the functions in ma_data_source_vtable. Your custom object must have ma_data_source_base as it's first member:

    `c struct my_data_source { ma_data_source_base base; ... }; `

    In your initialization routine, you need to call ma_data_source_init() in order to set up the base object (ma_data_source_base):

    `c static ma_result my_data_source_read(ma_data_source pDataSource, void pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { // Read data here. Output in the same format returned by my_data_source_get_data_format(). }

    static ma_result my_data_source_seek(ma_data_source* pDataSource, ma_uint64 frameIndex) { // Seek to a specific PCM frame here. Return MA_NOT_IMPLEMENTED if seeking is not supported. }

    static ma_result my_data_source_get_data_format(ma_data_source pDataSource, ma_format pFormat, ma_uint32 pChannels, ma_uint32 pSampleRate, ma_channel* pChannelMap, size_t channelMapCap) { // Return the format of the data here. }

    static ma_result my_data_source_get_cursor(ma_data_source pDataSource, ma_uint64 pCursor) { // Retrieve the current position of the cursor here. Return MA_NOT_IMPLEMENTED and set *pCursor to 0 if there is no notion of a cursor. }

    static ma_result my_data_source_get_length(ma_data_source pDataSource, ma_uint64 pLength) { // Retrieve the length in PCM frames here. Return MA_NOT_IMPLEMENTED and set *pLength to 0 if there is no notion of a length or if the length is unknown. }

    static ma_data_source_vtable g_my_data_source_vtable = { my_data_source_read, my_data_source_seek, my_data_source_get_data_format, my_data_source_get_cursor, my_data_source_get_length };

    ma_result my_data_source_init(my_data_source* pMyDataSource) { ma_result result; ma_data_source_config baseConfig;

    baseConfig = ma_data_source_config_init(); baseConfig.vtable = &g_my_data_source_vtable;

    result = ma_data_source_init(&baseConfig, &pMyDataSource->base); if (result != MA_SUCCESS) { return result; }

    // ... do the initialization of your custom data source here ...

    return MA_SUCCESS; }

    void my_data_source_uninit(my_data_source* pMyDataSource) { // ... do the uninitialization of your custom data source here ...

    // You must uninitialize the base data source. ma_data_source_uninit(&pMyDataSource->base); } `

    Note that ma_data_source_init() and ma_data_source_uninit() are never called directly outside of the custom data source. It's up to the custom data source itself to call these within their own init/uninit functions.

    5. Engine ========= The ma_engine API is a high level API for managing and mixing sounds and effect processing. The ma_engine object encapsulates a resource manager and a node graph, both of which will be explained in more detail later.

    Sounds are called ma_sound and are created from an engine. Sounds can be associated with a mixing group called ma_sound_group which are also created from the engine. Both ma_sound and ma_sound_group objects are nodes within the engine's node graph.

    When the engine is initialized, it will normally create a device internally. If you would rather manage the device yourself, you can do so and just pass a pointer to it via the engine config when you initialize the engine. You can also just use the engine without a device, which again can be configured via the engine config.

    The most basic way to initialize the engine is with a default config, like so:

    `c ma_result result; ma_engine engine;

    result = ma_engine_init(NULL, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } `

    This will result in the engine initializing a playback device using the operating system's default device. This will be sufficient for many use cases, but if you need more flexibility you'll want to configure the engine with an engine config:

    `c ma_result result; ma_engine engine; ma_engine_config engineConfig;

    engineConfig = ma_engine_config_init(); engineConfig.pDevice = &myDevice;

    result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } `

    In the example above we're passing in a pre-initialized device. Since the caller is the one in control of the device's data callback, it's their responsibility to manually call ma_engine_read_pcm_frames() from inside their data callback:

    `c void playback_data_callback(ma_device pDevice, void pOutput, const void* pInput, ma_uint32 frameCount) { ma_engine_read_pcm_frames(&g_Engine, pOutput, frameCount, NULL); } `

    You can also use the engine independent of a device entirely:

    `c ma_result result; ma_engine engine; ma_engine_config engineConfig;

    engineConfig = ma_engine_config_init(); engineConfig.noDevice = MA_TRUE; engineConfig.channels = 2; // Must be set when not using a device. engineConfig.sampleRate = 48000; // Must be set when not using a device.

    result = ma_engine_init(&engineConfig, &engine); if (result != MA_SUCCESS) { return result; // Failed to initialize the engine. } `

    Note that when you're not using a device, you must set the channel count and sample rate in the config or else miniaudio won't know what to use (miniaudio will use the device to determine this normally). When not using a device, you need to use ma_engine_read_pcm_frames() to process audio data from the engine. This kind of setup is useful if you want to do something like offline processing or want to use a different audio system for playback such as SDL.

    When a sound is loaded it goes through a resource manager. By default the engine will initialize a resource manager internally, but you can also specify a pre-initialized resource manager:

    `c ma_result result; ma_engine engine1; ma_engine engine2; ma_engine_config engineConfig;

    engineConfig = ma_engine_config_init(); engineConfig.pResourceManager = &myResourceManager;

    ma_engine_init(&engineConfig, &engine1); ma_engine_init(&engineConfig, &engine2); `

    In this example we are initializing two engines, both of which are sharing the same resource manager. This is especially useful for saving memory when loading the same file across multiple engines. If you were not to use a shared resource manager, each engine instance would use their own which would result in any sounds that are used between both engine's being loaded twice. By using a shared resource manager, it would only be loaded once. Using multiple engine's is useful when you need to output to multiple playback devices, such as in a local multiplayer game where each player is using their own set of headphones.

    By default an engine will be in a started state. To make it so the engine is not automatically started you can configure it as such:

    `c engineConfig.noAutoStart = MA_TRUE;

    // The engine will need to be started manually. ma_engine_start(&engine);

    // Later on the engine can be stopped with ma_engine_stop(). ma_engine_stop(&engine); `

    The concept of starting or stopping an engine is only relevant when using the engine with a device. Attempting to start or stop an engine that is not associated with a device will result in MA_INVALID_OPERATION.

    The master volume of the engine can be controlled with ma_engine_set_volume() which takes a linear scale, with 0 resulting in silence and anything above 1 resulting in amplification. If you prefer decibel based volume control, use ma_volume_db_to_linear() to convert from dB to linear.

    When a sound is spatialized, it is done so relative to a listener. An engine can be configured to have multiple listeners which can be configured via the config:

    `c engineConfig.listenerCount = 2; `

    The maximum number of listeners is restricted to MA_ENGINE_MAX_LISTENERS. By default, when a sound is spatialized, it will be done so relative to the closest listener. You can also pin a sound to a specific listener which will be explained later. Listener's have a position, direction, cone, and velocity (for doppler effect). A listener is referenced by an index, the meaning of which is up to the caller (the index is 0 based and cannot go beyond the listener count, minus 1). The position, direction and velocity are all specified in absolute terms:

    `c ma_engine_listener_set_position(&engine, listenerIndex, worldPosX, worldPosY, worldPosZ); `

    The direction of the listener represents it's forward vector. The listener's up vector can also be specified and defaults to +1 on the Y axis.

    `c ma_engine_listener_set_direction(&engine, listenerIndex, forwardX, forwardY, forwardZ); ma_engine_listener_set_world_up(&engine, listenerIndex, 0, 1, 0); `

    The engine supports directional attenuation. The listener can have a cone the controls how sound is attenuated based on the listener's direction. When a sound is between the inner and outer cones, it will be attenuated between 1 and the cone's outer gain:

    `c ma_engine_listener_set_cone(&engine, listenerIndex, innerAngleInRadians, outerAngleInRadians, outerGain); `

    When a sound is inside the inner code, no directional attenuation is applied. When the sound is outside of the outer cone, the attenuation will be set to outerGain in the example above. When the sound is in between the inner and outer cones, the attenuation will be interpolated between 1 and the outer gain.

    The engine's coordinate system follows the OpenGL coordinate system where positive X points right, positive Y points up and negative Z points forward.

    The simplest and least flexible way to play a sound is like so:

    `c ma_engine_play_sound(&engine, "my_sound.wav", pGroup); `

    This is a "fire and forget" style of function. The engine will manage the ma_sound object internally. When the sound finishes playing, it'll be put up for recycling. For more flexibility you'll want to initialize a sound object:

    `c ma_sound sound;

    result = ma_sound_init_from_file(&engine, "my_sound.wav", flags, pGroup, NULL, &sound); if (result != MA_SUCCESS) { return result; // Failed to load sound. } `

    Sounds need to be uninitialized with ma_sound_uninit().

    The example above loads a sound from a file. If the resource manager has been disabled you will not be able to use this function and instead you'll need to initialize a sound directly from a data source:

    `c ma_sound sound;

    result = ma_sound_init_from_data_source(&engine, &dataSource, flags, pGroup, &sound); if (result != MA_SUCCESS) { return result; } `

    Each ma_sound object represents a single instance of the sound. If you want to play the same sound multiple times at the same time, you need to initialize a separate ma_sound object.

    For the most flexibility when initializing sounds, use ma_sound_init_ex(). This uses miniaudio's standard config/init pattern:

    `c ma_sound sound; ma_sound_config soundConfig;

    soundConfig = ma_sound_config_init(); soundConfig.pFilePath = NULL; // Set this to load from a file path. soundConfig.pDataSource = NULL; // Set this to initialize from an existing data source. soundConfig.pInitialAttachment = &someNodeInTheNodeGraph; soundConfig.initialAttachmentInputBusIndex = 0; soundConfig.channelsIn = 1; soundConfig.channelsOut = 0; // Set to 0 to use the engine's native channel count.

    result = ma_sound_init_ex(&soundConfig, &sound); if (result != MA_SUCCESS) { return result; } `

    In the example above, the sound is being initialized without a file nor a data source. This is valid, in which case the sound acts as a node in the middle of the node graph. This means you can connect other sounds to this sound and allow it to act like a sound group. Indeed, this is exactly what a ma_sound_group is.

    When loading a sound, you specify a set of flags that control how the sound is loaded and what features are enabled for that sound. When no flags are set, the sound will be fully loaded into memory in exactly the same format as how it's stored on the file system. The resource manager will allocate a block of memory and then load the file directly into it. When reading audio data, it will be decoded dynamically on the fly. In order to save processing time on the audio thread, it might be beneficial to pre-decode the sound. You can do this with the MA_SOUND_FLAG_DECODE flag:

    `c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE, pGroup, NULL, &sound); `

    By default, sounds will be loaded synchronously, meaning ma_sound_init_*() will not return until the sound has been fully loaded. If this is prohibitive you can instead load sounds asynchronously by specifying the MA_SOUND_FLAG_ASYNC flag:

    `c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, NULL, &sound); `

    This will result in ma_sound_init_*() returning quickly, but the sound won't yet have been fully loaded. When you start the sound, it won't output anything until some sound is available. The sound will start outputting audio before the sound has been fully decoded when the MA_SOUND_FLAG_DECODE is specified.

    If you need to wait for an asynchronously loaded sound to be fully loaded, you can use a fence. A fence in miniaudio is a simple synchronization mechanism which simply blocks until it's internal counter hit's zero. You can specify a fence like so:

    `c ma_result result; ma_fence fence; ma_sound sounds[4];

    result = ma_fence_init(&fence); if (result != MA_SUCCESS) { return result; }

    // Load some sounds asynchronously. for (int iSound = 0; iSound < 4; iSound += 1) { ma_sound_init_from_file(&engine, mySoundFilesPaths[iSound], MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_ASYNC, pGroup, &fence, &sounds[iSound]); }

    // ... do some other stuff here in the mean time ...

    // Wait for all sounds to finish loading. ma_fence_wait(&fence); `

    If loading the entire sound into memory is prohibitive, you can also configure the engine to stream the audio data:

    `c ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_STREAM, pGroup, NULL, &sound); `

    When streaming sounds, 2 seconds worth of audio data is stored in memory. Although it should work fine, it's inefficient to use streaming for short sounds. Streaming is useful for things like music tracks in games.

    When loading a sound from a file path, the engine will reference count the file to prevent it from being loaded if it's already in memory. When you uninitialize a sound, the reference count will be decremented, and if it hits zero, the sound will be unloaded from memory. This reference counting system is not used for streams. The engine will use a 64-bit hash of the file name when comparing file paths which means there's a small chance you might encounter a name collision. If this is an issue, you'll need to use a different name for one of the colliding file paths, or just not load from files and instead load from a data source.

    You can use ma_sound_init_copy() to initialize a copy of another sound. Note, however, that this only works for sounds that were initialized with ma_sound_init_from_file() and without the MA_SOUND_FLAG_STREAM flag.

    When you initialize a sound, if you specify a sound group the sound will be attached to that group automatically. If you set it to NULL, it will be automatically attached to the engine's endpoint. If you would instead rather leave the sound unattached by default, you can specify the MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT flag. This is useful if you want to set up a complex node graph.

    Sounds are not started by default. To start a sound, use ma_sound_start(). Stop a sound with ma_sound_stop().

    Sounds can have their volume controlled with ma_sound_set_volume() in the same way as the engine's master volume.

    Sounds support stereo panning and pitching. Set the pan with ma_sound_set_pan(). Setting the pan to 0 will result in an unpanned sound. Setting it to -1 will shift everything to the left, whereas +1 will shift it to the right. The pitch can be controlled with ma_sound_set_pitch(). A larger value will result in a higher pitch. The pitch must be greater than 0.

    The engine supports 3D spatialization of sounds. By default sounds will have spatialization enabled, but if a sound does not need to be spatialized it's best to disable it. There are two ways to disable spatialization of a sound:

    `c // Disable spatialization at initialization time via a flag: ma_sound_init_from_file(&engine, "my_sound.wav", MA_SOUND_FLAG_NO_SPATIALIZATION, NULL, NULL, &sound);

    // Dynamically disable or enable spatialization post-initialization: ma_sound_set_spatialization_enabled(&sound, isSpatializationEnabled); `

    By default sounds will be spatialized based on the closest listener. If a sound should always be spatialized relative to a specific listener it can be pinned to one:

    `c ma_sound_set_pinned_listener_index(&sound, listenerIndex); `

    Like listeners, sounds have a position. By default, the position of a sound is in absolute space, but it can be changed to be relative to a listener:

    `c ma_sound_set_positioning(&sound, ma_positioning_relative); `

    Note that relative positioning of a sound only makes sense if there is either only one listener, or the sound is pinned to a specific listener. To set the position of a sound:

    `c ma_sound_set_position(&sound, posX, posY, posZ); `

    The direction works the same way as a listener and represents the sound's forward direction:

    `c ma_sound_set_direction(&sound, forwardX, forwardY, forwardZ); `

    Sound's also have a cone for controlling directional attenuation. This works exactly the same as listeners:

    `c ma_sound_set_cone(&sound, innerAngleInRadians, outerAngleInRadians, outerGain); `

    The velocity of a sound is used for doppler effect and can be set as such:

    `c ma_sound_set_velocity(&sound, velocityX, velocityY, velocityZ); `

    The engine supports different attenuation models which can be configured on a per-sound basis. By default the attenuation model is set to ma_attenuation_model_inverse which is the equivalent to OpenAL's AL_INVERSE_DISTANCE_CLAMPED. Configure the attenuation model like so:

    `c ma_sound_set_attenuation_model(&sound, ma_attenuation_model_inverse); `

    The supported attenuation models include the following:

    +----------------------------------+----------------------------------------------+ | ma_attenuation_model_none | No distance attenuation. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_inverse | Equivalent to AL_INVERSE_DISTANCE_CLAMPED. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_linear | Linear attenuation. | +----------------------------------+----------------------------------------------+ | ma_attenuation_model_exponential | Exponential attenuation. | +----------------------------------+----------------------------------------------+

    To control how quickly a sound rolls off as it moves away from the listener, you need to configure the rolloff:

    `c ma_sound_set_rolloff(&sound, rolloff); `

    You can control the minimum and maximum gain to apply from spatialization:

    `c ma_sound_set_min_gain(&sound, minGain); ma_sound_set_max_gain(&sound, maxGain); `

    Likewise, in the calculation of attenuation, you can control the minimum and maximum distances for the attenuation calculation. This is useful if you want to ensure sounds don't drop below a certain volume after the listener moves further away and to have sounds play a maximum volume when the listener is within a certain distance:

    `c ma_sound_set_min_distance(&sound, minDistance); ma_sound_set_max_distance(&sound, maxDistance); `

    The engine's spatialization system supports doppler effect. The doppler factor can be configure on a per-sound basis like so:

    `c ma_sound_set_doppler_factor(&sound, dopplerFactor); `

    You can fade sounds in and out with ma_sound_set_fade_in_pcm_frames() and ma_sound_set_fade_in_milliseconds(). Set the volume to -1 to use the current volume as the starting volume:

    `c // Fade in over 1 second. ma_sound_set_fade_in_milliseconds(&sound, 0, 1, 1000);

    // ... sometime later ...

    // Fade out over 1 second, starting from the current volume. ma_sound_set_fade_in_milliseconds(&sound, -1, 0, 1000); `

    By default sounds will start immediately, but sometimes for timing and synchronization purposes it can be useful to schedule a sound to start or stop:

    `c // Start the sound in 1 second from now. ma_sound_set_start_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 1));

    // Stop the sound in 2 seconds from now. ma_sound_set_stop_time_in_pcm_frames(&sound, ma_engine_get_time_in_pcm_frames(&engine) + (ma_engine_get_sample_rate(&engine) * 2)); `

    Note that scheduling a start time still requires an explicit call to ma_sound_start() before anything will play.

    The time is specified in global time which is controlled by the engine. You can get the engine's current time with ma_engine_get_time_in_pcm_frames(). The engine's global time is incremented automatically as audio data is read, but it can be reset with ma_engine_set_time_in_pcm_frames() in case it needs to be resynchronized for some reason.

    To determine whether or not a sound is currently playing, use ma_sound_is_playing(). This will take the scheduled start and stop times into account.

    Whether or not a sound should loop can be controlled with ma_sound_set_looping(). Sounds will not be looping by default. Use ma_sound_is_looping() to determine whether or not a sound is looping.

    Use ma_sound_at_end() to determine whether or not a sound is currently at the end. For a looping sound this should never return true. Alternatively, you can configure a callback that will be fired when the sound reaches the end. Note that the callback is fired from the audio thread which means you cannot be uninitializing sound from the callback. To set the callback you can use ma_sound_set_end_callback(). Alternatively, if you're using ma_sound_init_ex(), you can pass it into the config like so:

    `c soundConfig.endCallback = my_end_callback; soundConfig.pEndCallbackUserData = pMyEndCallbackUserData; `

    The end callback is declared like so:

    `c void my_end_callback(void pUserData, ma_sound pSound) { ... } `

    Internally a sound wraps around a data source. Some APIs exist to control the underlying data source, mainly for convenience:

    `c ma_sound_seek_to_pcm_frame(&sound, frameIndex); ma_sound_get_data_format(&sound, &format, &channels, &sampleRate, pChannelMap, channelMapCapacity); ma_sound_get_cursor_in_pcm_frames(&sound, &cursor); ma_sound_get_length_in_pcm_frames(&sound, &length); `

    Sound groups have the same API as sounds, only they are called ma_sound_group, and since they do not have any notion of a data source, anything relating to a data source is unavailable.

    Internally, sound data is loaded via the ma_decoder API which means by default it only supports file formats that have built-in support in miniaudio. You can extend this to support any kind of file format through the use of custom decoders. To do this you'll need to use a self-managed resource manager and configure it appropriately. See the "Resource Management" section below for details on how to set this up.

    6. Resource Management ====================== Many programs will want to manage sound resources for things such as reference counting and streaming. This is supported by miniaudio via the ma_resource_manager API.

    The resource manager is mainly responsible for the following:

    * Loading of sound files into memory with reference counting. * Streaming of sound data.

    When loading a sound file, the resource manager will give you back a ma_data_source compatible object called ma_resource_manager_data_source. This object can be passed into any ma_data_source API which is how you can read and seek audio data. When loading a sound file, you specify whether or not you want the sound to be fully loaded into memory (and optionally pre-decoded) or streamed. When loading into memory, you can also specify whether or not you want the data to be loaded asynchronously.

    The example below is how you can initialize a resource manager using it's default configuration:

    `c ma_resource_manager_config config; ma_resource_manager resourceManager;

    config = ma_resource_manager_config_init(); result = ma_resource_manager_init(&config, &resourceManager); if (result != MA_SUCCESS) { ma_device_uninit(&device); printf("Failed to initialize the resource manager."); return -1; } `

    You can configure the format, channels and sample rate of the decoded audio data. By default it will use the file's native data format, but you can configure it to use a consistent format. This is useful for offloading the cost of data conversion to load time rather than dynamically converting at mixing time. To do this, you configure the decoded format, channels and sample rate like the code below:

    `c config = ma_resource_manager_config_init(); config.decodedFormat = device.playback.format; config.decodedChannels = device.playback.channels; config.decodedSampleRate = device.sampleRate; `

    In the code above, the resource manager will be configured so that any decoded audio data will be pre-converted at load time to the device's native data format. If instead you used defaults and the data format of the file did not match the device's data format, you would need to convert the data at mixing time which may be prohibitive in high-performance and large scale scenarios like games.

    Internally the resource manager uses the ma_decoder API to load sounds. This means by default it only supports decoders that are built into miniaudio. It's possible to support additional encoding formats through the use of custom decoders. To do so, pass in your ma_decoding_backend_vtable vtables into the resource manager config:

    `c ma_decoding_backend_vtable* pCustomBackendVTables[] = { &g_ma_decoding_backend_vtable_libvorbis, &g_ma_decoding_backend_vtable_libopus };

    ...

    resourceManagerConfig.ppCustomDecodingBackendVTables = pCustomBackendVTables; resourceManagerConfig.customDecodingBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); resourceManagerConfig.pCustomDecodingBackendUserData = NULL; `

    This system can allow you to support any kind of file format. See the "Decoding" section for details on how to implement custom decoders. The miniaudio repository includes examples for Opus via libopus and libopusfile and Vorbis via libvorbis and libvorbisfile.

    Asynchronicity is achieved via a job system. When an operation needs to be performed, such as the decoding of a page, a job will be posted to a queue which will then be processed by a job thread. By default there will be only one job thread running, but this can be configured, like so:

    `c config = ma_resource_manager_config_init(); config.jobThreadCount = MY_JOB_THREAD_COUNT; `

    By default job threads are managed internally by the resource manager, however you can also self manage your job threads if, for example, you want to integrate the job processing into your existing job infrastructure, or if you simply don't like the way the resource manager does it. To do this, just set the job thread count to 0 and process jobs manually. To process jobs, you first need to retrieve a job using ma_resource_manager_next_job() and then process it using ma_job_process():

    `c config = ma_resource_manager_config_init(); config.jobThreadCount = 0; // Don't manage any job threads internally. config.flags = MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING; // Optional. Makes ma_resource_manager_next_job() non-blocking.

    // ... Initialize your custom job threads ...

    void my_custom_job_thread(...) { for (;;) { ma_job job; ma_result result = ma_resource_manager_next_job(pMyResourceManager, &job); if (result != MA_SUCCESS) { if (result == MA_NO_DATA_AVAILABLE) { // No jobs are available. Keep going. Will only get this if the resource manager was initialized // with MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING. continue; } else if (result == MA_CANCELLED) { // MA_JOB_TYPE_QUIT was posted. Exit. break; } else { // Some other error occurred. break; } }

    ma_job_process(&job); } } `

    In the example above, the MA_JOB_TYPE_QUIT event is the used as the termination indicator, but you can use whatever you would like to terminate the thread. The call to ma_resource_manager_next_job() is blocking by default, but can be configured to be non-blocking by initializing the resource manager with the MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING configuration flag. Note that the MA_JOB_TYPE_QUIT will never be removed from the job queue. This is to give every thread the opportunity to catch the event and terminate naturally.

    When loading a file, it's sometimes convenient to be able to customize how files are opened and read instead of using standard fopen(), fclose(), etc. which is what miniaudio will use by default. This can be done by setting pVFS member of the resource manager's config:

    `c // Initialize your custom VFS object. See documentation for VFS for information on how to do this. my_custom_vfs vfs = my_custom_vfs_init();

    config = ma_resource_manager_config_init(); config.pVFS = &vfs; `

    This is particularly useful in programs like games where you want to read straight from an archive rather than the normal file system. If you do not specify a custom VFS, the resource manager will use the operating system's normal file operations.

    To load a sound file and create a data source, call ma_resource_manager_data_source_init(). When loading a sound you need to specify the file path and options for how the sounds should be loaded. By default a sound will be loaded synchronously. The returned data source is owned by the caller which means the caller is responsible for the allocation and freeing of the data source. Below is an example for initializing a data source:

    `c ma_resource_manager_data_source dataSource; ma_result result = ma_resource_manager_data_source_init(pResourceManager, pFilePath, flags, &dataSource); if (result != MA_SUCCESS) { // Error. }

    // ...

    // A ma_resource_manager_data_source object is compatible with the ma_data_source API. To read data, just call // the ma_data_source_read_pcm_frames() like you would with any normal data source. result = ma_data_source_read_pcm_frames(&dataSource, pDecodedData, frameCount, &framesRead); if (result != MA_SUCCESS) { // Failed to read PCM frames. }

    // ...

    ma_resource_manager_data_source_uninit(&dataSource); `

    The flags parameter specifies how you want to perform loading of the sound file. It can be a combination of the following flags:

    ` MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_LOOPING `

    When no flags are specified (set to 0), the sound will be fully loaded into memory, but not decoded, meaning the raw file data will be stored in memory, and then dynamically decoded when ma_data_source_read_pcm_frames() is called. To instead decode the audio data before storing it in memory, use the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE flag. By default, the sound file will be loaded synchronously, meaning ma_resource_manager_data_source_init() will only return after the entire file has been loaded. This is good for simplicity, but can be prohibitively slow. You can instead load the sound asynchronously using the MA_RESOURCE_MANAGER_DATA_SOURCE_ASYNC flag. This will result in ma_resource_manager_data_source_init() returning quickly, but no data will be returned by ma_data_source_read_pcm_frames() until some data is available. When no data is available because the asynchronous decoding hasn't caught up, MA_BUSY will be returned by ma_data_source_read_pcm_frames().

    For large sounds, it's often prohibitive to store the entire file in memory. To mitigate this, you can instead stream audio data which you can do by specifying the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM flag. When streaming, data will be decoded in 1 second pages. When a new page needs to be decoded, a job will be posted to the job queue and then subsequently processed in a job thread.

    The MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_LOOPING flag can be used so that the sound will loop when it reaches the end by default. It's recommended you use this flag when you want to have a looping streaming sound. If you try loading a very short sound as a stream, you will get a glitch. This is because the resource manager needs to pre-fill the initial buffer at initialization time, and if you don't specify the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_LOOPING flag, the resource manager will assume the sound is not looping and will stop filling the buffer when it reaches the end, therefore resulting in a discontinuous buffer.

    For in-memory sounds, reference counting is used to ensure the data is loaded only once. This means multiple calls to ma_resource_manager_data_source_init() with the same file path will result in the file data only being loaded once. Each call to ma_resource_manager_data_source_init() must be matched up with a call to ma_resource_manager_data_source_uninit(). Sometimes it can be useful for a program to register self-managed raw audio data and associate it with a file path. Use the ma_resource_manager_register_*() and ma_resource_manager_unregister_*() APIs to do this. ma_resource_manager_register_decoded_data() is used to associate a pointer to raw, self-managed decoded audio data in the specified data format with the specified name. Likewise, ma_resource_manager_register_encoded_data() is used to associate a pointer to raw self-managed encoded audio data (the raw file data) with the specified name. Note that these names need not be actual file paths. When ma_resource_manager_data_source_init() is called (without the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM flag), the resource manager will look for these explicitly registered data buffers and, if found, will use it as the backing data for the data source. Note that the resource manager does not make a copy of this data so it is up to the caller to ensure the pointer stays valid for its lifetime. Use ma_resource_manager_unregister_data() to unregister the self-managed data. You can also use ma_resource_manager_register_file() and ma_resource_manager_unregister_file() to register and unregister a file. It does not make sense to use the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM flag with a self-managed data pointer.

    6.1. Asynchronous Loading and Synchronization --------------------------------------------- When loading asynchronously, it can be useful to poll whether or not loading has finished. Use ma_resource_manager_data_source_result() to determine this. For in-memory sounds, this will return MA_SUCCESS when the file has been entirely decoded. If the sound is still being decoded, MA_BUSY will be returned. Otherwise, some other error code will be returned if the sound failed to load. For streaming data sources, MA_SUCCESS will be returned when the first page has been decoded and the sound is ready to be played. If the first page is still being decoded, MA_BUSY will be returned. Otherwise, some other error code will be returned if the sound failed to load.

    In addition to polling, you can also use a simple synchronization object called a "fence" to wait for asynchronously loaded sounds to finish. This is called ma_fence. The advantage to using a fence is that it can be used to wait for a group of sounds to finish loading rather than waiting for sounds on an individual basis. There are two stages to loading a sound:

    * Initialization of the internal decoder; and * Completion of decoding of the file (the file is fully decoded)

    You can specify separate fences for each of the different stages. Waiting for the initialization of the internal decoder is important for when you need to know the sample format, channels and sample rate of the file.

    The example below shows how you could use a fence when loading a number of sounds:

    `c // This fence will be released when all sounds are finished loading entirely. ma_fence fence; ma_fence_init(&fence);

    // This will be passed into the initialization routine for each sound. ma_resource_manager_pipeline_notifications notifications = ma_resource_manager_pipeline_notifications_init(); notifications.done.pFence = &fence;

    // Now load a bunch of sounds: for (iSound = 0; iSound < soundCount; iSound += 1) { ma_resource_manager_data_source_init(pResourceManager, pSoundFilePaths[iSound], flags, ¬ifications, &pSoundSources[iSound]); }

    // ... DO SOMETHING ELSE WHILE SOUNDS ARE LOADING ...

    // Wait for loading of sounds to finish. ma_fence_wait(&fence); `

    In the example above we used a fence for waiting until the entire file has been fully decoded. If you only need to wait for the initialization of the internal decoder to complete, you can use the init member of the ma_resource_manager_pipeline_notifications object:

    `c notifications.init.pFence = &fence; `

    If a fence is not appropriate for your situation, you can instead use a callback that is fired on an individual sound basis. This is done in a very similar way to fences:

    `c typedef struct { ma_async_notification_callbacks cb; void* pMyData; } my_notification;

    void my_notification_callback(ma_async_notification* pNotification) { my_notification pMyNotification = (my_notification)pNotification;

    // Do something in response to the sound finishing loading. }

    ...

    my_notification myCallback; myCallback.cb.onSignal = my_notification_callback; myCallback.pMyData = pMyData;

    ma_resource_manager_pipeline_notifications notifications = ma_resource_manager_pipeline_notifications_init(); notifications.done.pNotification = &myCallback;

    ma_resource_manager_data_source_init(pResourceManager, "my_sound.wav", flags, ¬ifications, &mySound); `

    In the example above we just extend the ma_async_notification_callbacks object and pass an instantiation into the ma_resource_manager_pipeline_notifications in the same way as we did with the fence, only we set pNotification instead of pFence. You can set both of these at the same time and they should both work as expected. If using the pNotification system, you need to ensure your ma_async_notification_callbacks object stays valid.

    6.2. Resource Manager Implementation Details -------------------------------------------- Resources are managed in two main ways:

    * By storing the entire sound inside an in-memory buffer (referred to as a data buffer) * By streaming audio data on the fly (referred to as a data stream)

    A resource managed data source (ma_resource_manager_data_source) encapsulates a data buffer or data stream, depending on whether or not the data source was initialized with the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM flag. If so, it will make use of a ma_resource_manager_data_stream object. Otherwise it will use a ma_resource_manager_data_buffer object. Both of these objects are data sources which means they can be used with any ma_data_source_*() API.

    Another major feature of the resource manager is the ability to asynchronously decode audio files. This relieves the audio thread of time-consuming decoding which can negatively affect scalability due to the audio thread needing to complete it's work extremely quickly to avoid glitching. Asynchronous decoding is achieved through a job system. There is a central multi-producer, multi-consumer, fixed-capacity job queue. When some asynchronous work needs to be done, a job is posted to the queue which is then read by a job thread. The number of job threads can be configured for improved scalability, and job threads can all run in parallel without needing to worry about the order of execution (how this is achieved is explained below).

    When a sound is being loaded asynchronously, playback can begin before the sound has been fully decoded. This enables the application to start playback of the sound quickly, while at the same time allowing to resource manager to keep loading in the background. Since there may be less threads than the number of sounds being loaded at a given time, a simple scheduling system is used to keep decoding time balanced and fair. The resource manager solves this by splitting decoding into chunks called pages. By default, each page is 1 second long. When a page has been decoded, a new job will be posted to start decoding the next page. By dividing up decoding into pages, an individual sound shouldn't ever delay every other sound from having their first page decoded. Of course, when loading many sounds at the same time, there will always be an amount of time required to process jobs in the queue so in heavy load situations there will still be some delay. To determine if a data source is ready to have some frames read, use ma_resource_manager_data_source_get_available_frames(). This will return the number of frames available starting from the current position.

    6.2.1. Job Queue ---------------- The resource manager uses a job queue which is multi-producer, multi-consumer, and fixed-capacity. This job queue is not currently lock-free, and instead uses a spinlock to achieve thread-safety. Only a fixed number of jobs can be allocated and inserted into the queue which is done through a lock-free data structure for allocating an index into a fixed sized array, with reference counting for mitigation of the ABA problem. The reference count is 32-bit.

    For many types of jobs it's important that they execute in a specific order. In these cases, jobs are executed serially. For the resource manager, serial execution of jobs is only required on a per-object basis (per data buffer or per data stream). Each of these objects stores an execution counter. When a job is posted it is associated with an execution counter. When the job is processed, it checks if the execution counter of the job equals the execution counter of the owning object and if so, processes the job. If the counters are not equal, the job will be posted back onto the job queue for later processing. When the job finishes processing the execution order of the main object is incremented. This system means the no matter how many job threads are executing, decoding of an individual sound will always get processed serially. The advantage to having multiple threads comes into play when loading multiple sounds at the same time.

    The resource manager's job queue is not 100% lock-free and will use a spinlock to achieve thread-safety for a very small section of code. This is only relevant when the resource manager uses more than one job thread. If only using a single job thread, which is the default, the lock should never actually wait in practice. The amount of time spent locking should be quite short, but it's something to be aware of for those who have pedantic lock-free requirements and need to use more than one job thread. There are plans to remove this lock in a future version.

    In addition, posting a job will release a semaphore, which on Win32 is implemented with ReleaseSemaphore and on POSIX platforms via a condition variable:

    `c pthread_mutex_lock(&pSemaphore->lock); { pSemaphore->value += 1; pthread_cond_signal(&pSemaphore->cond); } pthread_mutex_unlock(&pSemaphore->lock); `

    Again, this is relevant for those with strict lock-free requirements in the audio thread. To avoid this, you can use non-blocking mode (via the MA_JOB_QUEUE_FLAG_NON_BLOCKING flag) and implement your own job processing routine (see the "Resource Manager" section above for details on how to do this).

    6.2.2. Data Buffers ------------------- When the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM flag is excluded at initialization time, the resource manager will try to load the data into an in-memory data buffer. Before doing so, however, it will first check if the specified file is already loaded. If so, it will increment a reference counter and just use the already loaded data. This saves both time and memory. When the data buffer is uninitialized, the reference counter will be decremented. If the counter hits zero, the file will be unloaded. This is a detail to keep in mind because it could result in excessive loading and unloading of a sound. For example, the following sequence will result in a file be loaded twice, once after the other:

    `c ma_resource_manager_data_source_init(pResourceManager, "my_file", ..., &myDataBuffer0); // Refcount = 1. Initial load. ma_resource_manager_data_source_uninit(&myDataBuffer0); // Refcount = 0. Unloaded.

    ma_resource_manager_data_source_init(pResourceManager, "my_file", ..., &myDataBuffer1); // Refcount = 1. Reloaded because previous uninit() unloaded it. ma_resource_manager_data_source_uninit(&myDataBuffer1); // Refcount = 0. Unloaded. `

    A binary search tree (BST) is used for storing data buffers as it has good balance between efficiency and simplicity. The key of the BST is a 64-bit hash of the file path that was passed into ma_resource_manager_data_source_init(). The advantage of using a hash is that it saves memory over storing the entire path, has faster comparisons, and results in a mostly balanced BST due to the random nature of the hash. The disadvantages are that file names are case-sensitive and there's a small chance of name collisions. If case-sensitivity is an issue, you should normalize your file names to upper- or lower-case before initializing your data sources. If name collisions become an issue, you'll need to change the name of one of the colliding names or just not use the resource manager.

    When a sound file has not already been loaded and the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC flag is excluded, the file will be decoded synchronously by the calling thread. There are two options for controlling how the audio is stored in the data buffer - encoded or decoded. When the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE option is excluded, the raw file data will be stored in memory. Otherwise the sound will be decoded before storing it in memory. Synchronous loading is a very simple and standard process of simply adding an item to the BST, allocating a block of memory and then decoding (if MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE is specified).

    When the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC flag is specified, loading of the data buffer is done asynchronously. In this case, a job is posted to the queue to start loading and then the function immediately returns, setting an internal result code to MA_BUSY. This result code is returned when the program calls ma_resource_manager_data_source_result(). When decoding has fully completed MA_SUCCESS will be returned. This can be used to know if loading has fully completed.

    When loading asynchronously, a single job is posted to the queue of the type MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE. This involves making a copy of the file path and associating it with job. When the job is processed by the job thread, it will first load the file using the VFS associated with the resource manager. When using a custom VFS, it's important that it be completely thread-safe because it will be used from one or more job threads at the same time. Individual files should only ever be accessed by one thread at a time, however. After opening the file via the VFS, the job will determine whether or not the file is being decoded. If not, it simply allocates a block of memory and loads the raw file contents into it and returns. On the other hand, when the file is being decoded, it will first allocate a decoder on the heap and initialize it. Then it will check if the length of the file is known. If so it will allocate a block of memory to store the decoded output and initialize it to silence. If the size is unknown, it will allocate room for one page. After memory has been allocated, the first page will be decoded. If the sound is shorter than a page, the result code will be set to MA_SUCCESS and the completion event will be signalled and loading is now complete. If, however, there is more to decode, a job with the code MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE is posted. This job will decode the next page and perform the same process if it reaches the end. If there is more to decode, the job will post another MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE job which will keep on happening until the sound has been fully decoded. For sounds of an unknown length, each page will be linked together as a linked list. Internally this is implemented via the ma_paged_audio_buffer object.

    6.2.3. Data Streams ------------------- Data streams only ever store two pages worth of data for each instance. They are most useful for large sounds like music tracks in games that would consume too much memory if fully decoded in memory. After every frame from a page has been read, a job will be posted to load the next page which is done from the VFS.

    For data streams, the MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC flag will determine whether or not initialization of the data source waits until the two pages have been decoded. When unset, ma_resource_manager_data_source_init() will wait until the two pages have been loaded, otherwise it will return immediately.

    When frames are read from a data stream using ma_resource_manager_data_source_read_pcm_frames(), MA_BUSY will be returned if there are no frames available. If there are some frames available, but less than the number requested, MA_SUCCESS will be returned, but the actual number of frames read will be less than the number requested. Due to the asynchronous nature of data streams, seeking is also asynchronous. If the data stream is in the middle of a seek, MA_BUSY will be returned when trying to read frames.

    When ma_resource_manager_data_source_read_pcm_frames() results in a page getting fully consumed a job is posted to load the next page. This will be posted from the same thread that called ma_resource_manager_data_source_read_pcm_frames().

    Data streams are uninitialized by posting a job to the queue, but the function won't return until that job has been processed. The reason for this is that the caller owns the data stream object and therefore miniaudio needs to ensure everything completes before handing back control to the caller. Also, if the data stream is uninitialized while pages are in the middle of decoding, they must complete before destroying any underlying object and the job system handles this cleanly.

    Note that when a new page needs to be loaded, a job will be posted to the resource manager's job thread from the audio thread. You must keep in mind the details mentioned in the "Job Queue" section above regarding locking when posting an event if you require a strictly lock-free audio thread.

    7. Node Graph ============= miniaudio's routing infrastructure follows a node graph paradigm. The idea is that you create a node whose outputs are attached to inputs of another node, thereby creating a graph. There are different types of nodes, with each node in the graph processing input data to produce output, which is then fed through the chain. Each node in the graph can apply their own custom effects. At the start of the graph will usually be one or more data source nodes which have no inputs and instead pull their data from a data source. At the end of the graph is an endpoint which represents the end of the chain and is where the final output is ultimately extracted from.

    Each node has a number of input buses and a number of output buses. An output bus from a node is attached to an input bus of another. Multiple nodes can connect their output buses to another node's input bus, in which case their outputs will be mixed before processing by the node. Below is a diagram that illustrates a hypothetical node graph setup:

    ` >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Data flows left to right >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    +---------------+ +-----------------+ | Data Source 1 =----+ +----------+ +----= Low Pass Filter =----+ +---------------+ | | =----+ +-----------------+ | +----------+ +----= Splitter | +----= ENDPOINT | +---------------+ | | =----+ +-----------------+ | +----------+ | Data Source 2 =----+ +----------+ +----= Echo / Delay =----+ +---------------+ +-----------------+ `

    In the above graph, it starts with two data sources whose outputs are attached to the input of a splitter node. It's at this point that the two data sources are mixed. After mixing, the splitter performs it's processing routine and produces two outputs which is simply a duplication of the input stream. One output is attached to a low pass filter, whereas the other output is attached to a echo/delay. The outputs of the low pass filter and the echo are attached to the endpoint, and since they're both connected to the same input bus, they'll be mixed.

    Each input bus must be configured to accept the same number of channels, but the number of channels used by input buses can be different to the number of channels for output buses in which case miniaudio will automatically convert the input data to the output channel count before processing. The number of channels of an output bus of one node must match the channel count of the input bus it's attached to. The channel counts cannot be changed after the node has been initialized. If you attempt to attach an output bus to an input bus with a different channel count, attachment will fail.

    To use a node graph, you first need to initialize a ma_node_graph object. This is essentially a container around the entire graph. The ma_node_graph object is required for some thread-safety issues which will be explained later. A ma_node_graph object is initialized using miniaudio's standard config/init system:

    `c ma_node_graph_config nodeGraphConfig = ma_node_graph_config_init(myChannelCount);

    result = ma_node_graph_init(&nodeGraphConfig, NULL, &nodeGraph); // Second parameter is a pointer to allocation callbacks. if (result != MA_SUCCESS) { // Failed to initialize node graph. } `

    When you initialize the node graph, you're specifying the channel count of the endpoint. The endpoint is a special node which has one input bus and one output bus, both of which have the same channel count, which is specified in the config. Any nodes that connect directly to the endpoint must be configured such that their output buses have the same channel count. When you read audio data from the node graph, it'll have the channel count you specified in the config. To read data from the graph:

    `c ma_uint32 framesRead; result = ma_node_graph_read_pcm_frames(&nodeGraph, pFramesOut, frameCount, &framesRead); if (result != MA_SUCCESS) { // Failed to read data from the node graph. } `

    When you read audio data, miniaudio starts at the node graph's endpoint node which then pulls in data from its input attachments, which in turn recursively pull in data from their inputs, and so on. At the start of the graph there will be some kind of data source node which will have zero inputs and will instead read directly from a data source. The base nodes don't literally need to read from a ma_data_source object, but they will always have some kind of underlying object that sources some kind of audio. The ma_data_source_node node can be used to read from a ma_data_source. Data is always in floating-point format and in the number of channels you specified when the graph was initialized. The sample rate is defined by the underlying data sources. It's up to you to ensure they use a consistent and appropriate sample rate.

    The ma_node API is designed to allow custom nodes to be implemented with relative ease, but miniaudio includes a few stock nodes for common functionality. This is how you would initialize a node which reads directly from a data source (ma_data_source_node) which is an example of one of the stock nodes that comes with miniaudio:

    `c ma_data_source_node_config config = ma_data_source_node_config_init(pMyDataSource);

    ma_data_source_node dataSourceNode; result = ma_data_source_node_init(&nodeGraph, &config, NULL, &dataSourceNode); if (result != MA_SUCCESS) { // Failed to create data source node. } `

    The data source node will use the output channel count to determine the channel count of the output bus. There will be 1 output bus and 0 input buses (data will be drawn directly from the data source). The data source must output to floating-point (ma_format_f32) or else an error will be returned from ma_data_source_node_init().

    By default the node will not be attached to the graph. To do so, use ma_node_attach_output_bus():

    `c result = ma_node_attach_output_bus(&dataSourceNode, 0, ma_node_graph_get_endpoint(&nodeGraph), 0); if (result != MA_SUCCESS) { // Failed to attach node. } `

    The code above connects the data source node directly to the endpoint. Since the data source node has only a single output bus, the index will always be 0. Likewise, the endpoint only has a single input bus which means the input bus index will also always be 0.

    To detach a specific output bus, use ma_node_detach_output_bus(). To detach all output buses, use ma_node_detach_all_output_buses(). If you want to just move the output bus from one attachment to another, you do not need to detach first. You can just call ma_node_attach_output_bus() and it'll deal with it for you.

    Less frequently you may want to create a specialized node. This will be a node where you implement your own processing callback to apply a custom effect of some kind. This is similar to initializing one of the stock node types, only this time you need to specify a pointer to a vtable containing a pointer to the processing function and the number of input and output buses. Example:

    `c static void my_custom_node_process_pcm_frames(ma_node pNode, const float* ppFramesIn, ma_uint32 pFrameCountIn, float* ppFramesOut, ma_uint32* pFrameCountOut) { // Do some processing of ppFramesIn (one stream of audio data per input bus) const float* pFramesIn_0 = ppFramesIn[0]; // Input bus @ index 0. const float* pFramesIn_1 = ppFramesIn[1]; // Input bus @ index 1. float* pFramesOut_0 = ppFramesOut[0]; // Output bus @ index 0.

    // Do some processing. On input, pFrameCountIn will be the number of input frames in each // buffer in ppFramesIn and pFrameCountOut will be the capacity of each of the buffers // in ppFramesOut. On output, pFrameCountIn should be set to the number of input frames // your node consumed and pFrameCountOut should be set the number of output frames that // were produced. // // You should process as many frames as you can. If your effect consumes input frames at the // same rate as output frames (always the case, unless you're doing resampling), you need // only look at ppFramesOut and process that exact number of frames. If you're doing // resampling, you'll need to be sure to set both pFrameCountIn and pFrameCountOut // properly. }

    static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called to process your custom node. This is where you'd implement your effect processing. NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. 2, // 2 input buses. 1, // 1 output bus. 0 // Default flags. };

    ...

    // Each bus needs to have a channel count specified. To do this you need to specify the channel // counts in an array and then pass that into the node config. ma_uint32 inputChannels[2]; // Equal in size to the number of input channels specified in the vtable. ma_uint32 outputChannels[1]; // Equal in size to the number of output channels specified in the vtable.

    inputChannels[0] = channelsIn; inputChannels[1] = channelsIn; outputChannels[0] = channelsOut;

    ma_node_config nodeConfig = ma_node_config_init(); nodeConfig.vtable = &my_custom_node_vtable; nodeConfig.pInputChannels = inputChannels; nodeConfig.pOutputChannels = outputChannels;

    ma_node_base node; result = ma_node_init(&nodeGraph, &nodeConfig, NULL, &node); if (result != MA_SUCCESS) { // Failed to initialize node. } `

    When initializing a custom node, as in the code above, you'll normally just place your vtable in static space. The number of input and output buses are specified as part of the vtable. If you need a variable number of buses on a per-node bases, the vtable should have the relevant bus count set to MA_NODE_BUS_COUNT_UNKNOWN. In this case, the bus count should be set in the node config:

    `c static ma_node_vtable my_custom_node_vtable = { my_custom_node_process_pcm_frames, // The function that will be called process your custom node. This is where you'd implement your effect processing. NULL, // Optional. A callback for calculating the number of input frames that are required to process a specified number of output frames. MA_NODE_BUS_COUNT_UNKNOWN, // The number of input buses is determined on a per-node basis. 1, // 1 output bus. 0 // Default flags. };

    ...

    ma_node_config nodeConfig = ma_node_config_init(); nodeConfig.vtable = &my_custom_node_vtable; nodeConfig.inputBusCount = myBusCount; // <-- Since the vtable specifies MA_NODE_BUS_COUNT_UNKNOWN, the input bus count should be set here. nodeConfig.pInputChannels = inputChannels; // <-- Make sure there are nodeConfig.inputBusCount elements in this array. nodeConfig.pOutputChannels = outputChannels; // <-- The vtable specifies 1 output bus, so there must be 1 element in this array. `

    In the above example it's important to never set the inputBusCount and outputBusCount members to anything other than their defaults if the vtable specifies an explicit count. They can only be set if the vtable specifies MA_NODE_BUS_COUNT_UNKNOWN in the relevant bus count.

    Most often you'll want to create a structure to encapsulate your node with some extra data. You need to make sure the ma_node_base object is your first member of the structure:

    `c typedef struct { ma_node_base base; // <-- Make sure this is always the first member. float someCustomData; } my_custom_node; `

    By doing this, your object will be compatible with all ma_node APIs and you can attach it to the graph just like any other node.

    In the custom processing callback (my_custom_node_process_pcm_frames() in the example above), the number of channels for each bus is what was specified by the config when the node was initialized with ma_node_init(). In addition, all attachments to each of the input buses will have been pre-mixed by miniaudio. The config allows you to specify different channel counts for each individual input and output bus. It's up to the effect to handle it appropriate, and if it can't, return an error in it's initialization routine.

    Custom nodes can be assigned some flags to describe their behaviour. These are set via the vtable and include the following:

    +-----------------------------------------+---------------------------------------------------+ | Flag Name | Description | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_PASSTHROUGH | Useful for nodes that do not do any kind of audio | | | processing, but are instead used for tracking | | | time, handling events, etc. Also used by the | | | internal endpoint node. It reads directly from | | | the input bus to the output bus. Nodes with this | | | flag must have exactly 1 input bus and 1 output | | | bus, and both buses must have the same channel | | | counts. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_CONTINUOUS_PROCESSING | Causes the processing callback to be called even | | | when no data is available to be read from input | | | attachments. When a node has at least one input | | | bus, but there are no inputs attached or the | | | inputs do not deliver any data, the node's | | | processing callback will not get fired. This flag | | | will make it so the callback is always fired | | | regardless of whether or not any input data is | | | received. This is useful for effects like | | | echos where there will be a tail of audio data | | | that still needs to be processed even when the | | | original data sources have reached their ends. It | | | may also be useful for nodes that must always | | | have their processing callback fired when there | | | are no inputs attached. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_ALLOW_NULL_INPUT | Used in conjunction with | | | MA_NODE_FLAG_CONTINUOUS_PROCESSING. When this | | | is set, the ppFramesIn parameter of the | | | processing callback will be set to NULL when | | | there are no input frames are available. When | | | this is unset, silence will be posted to the | | | processing callback. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_DIFFERENT_PROCESSING_RATES | Used to tell miniaudio that input and output | | | frames are processed at different rates. You | | | should set this for any nodes that perform | | | resampling. | +-----------------------------------------+---------------------------------------------------+ | MA_NODE_FLAG_SILENT_OUTPUT | Used to tell miniaudio that a node produces only | | | silent output. This is useful for nodes where you | | | don't want the output to contribute to the final | | | mix. An example might be if you want split your | | | stream and have one branch be output to a file. | | | When using this flag, you should avoid writing to | | | the output buffer of the node's processing | | | callback because miniaudio will ignore it anyway. | +-----------------------------------------+---------------------------------------------------+

    If you need to make a copy of an audio stream for effect processing you can use a splitter node called ma_splitter_node. This takes has 1 input bus and splits the stream into 2 output buses. You can use it like this:

    `c ma_splitter_node_config splitterNodeConfig = ma_splitter_node_config_init(channels);

    ma_splitter_node splitterNode; result = ma_splitter_node_init(&nodeGraph, &splitterNodeConfig, NULL, &splitterNode); if (result != MA_SUCCESS) { // Failed to create node. }

    // Attach your output buses to two different input buses (can be on two different nodes). ma_node_attach_output_bus(&splitterNode, 0, ma_node_graph_get_endpoint(&nodeGraph), 0); // Attach directly to the endpoint. ma_node_attach_output_bus(&splitterNode, 1, &myEffectNode, 0); // Attach to input bus 0 of some effect node. `

    The volume of an output bus can be configured on a per-bus basis:

    `c ma_node_set_output_bus_volume(&splitterNode, 0, 0.5f); ma_node_set_output_bus_volume(&splitterNode, 1, 0.5f); `

    In the code above we're using the splitter node from before and changing the volume of each of the copied streams.

    You can start and stop a node with the following:

    `c ma_node_set_state(&splitterNode, ma_node_state_started); // The default state. ma_node_set_state(&splitterNode, ma_node_state_stopped); `

    By default the node is in a started state, but since it won't be connected to anything won't actually be invoked by the node graph until it's connected. When you stop a node, data will not be read from any of its input connections. You can use this property to stop a group of sounds atomically.

    You can configure the initial state of a node in it's config:

    `c nodeConfig.initialState = ma_node_state_stopped; `

    Note that for the stock specialized nodes, all of their configs will have a nodeConfig member which is the config to use with the base node. This is where the initial state can be configured for specialized nodes:

    `c dataSourceNodeConfig.nodeConfig.initialState = ma_node_state_stopped; `

    When using a specialized node like ma_data_source_node or ma_splitter_node, be sure to not modify the vtable member of the nodeConfig object.

    7.1. Timing ----------- The node graph supports starting and stopping nodes at scheduled times. This is especially useful for data source nodes where you want to get the node set up, but only start playback at a specific time. There are two clocks: local and global.

    A local clock is per-node, whereas the global clock is per graph. Scheduling starts and stops can only be done based on the global clock because the local clock will not be running while the node is stopped. The global clocks advances whenever ma_node_graph_read_pcm_frames() is called. On the other hand, the local clock only advances when the node's processing callback is fired, and is advanced based on the output frame count.

    To retrieve the global time, use ma_node_graph_get_time(). The global time can be set with ma_node_graph_set_time() which might be useful if you want to do seeking on a global timeline. Getting and setting the local time is similar. Use ma_node_get_time() to retrieve the local time, and ma_node_set_time() to set the local time. The global and local times will be advanced by the audio thread, so care should be taken to avoid data races. Ideally you should avoid calling these outside of the node processing callbacks which are always run on the audio thread.

    There is basic support for scheduling the starting and stopping of nodes. You can only schedule one start and one stop at a time. This is mainly intended for putting nodes into a started or stopped state in a frame-exact manner. Without this mechanism, starting and stopping of a node is limited to the resolution of a call to ma_node_graph_read_pcm_frames() which would typically be in blocks of several milliseconds. The following APIs can be used for scheduling node states:

    `c ma_node_set_state_time() ma_node_get_state_time() `

    The time is absolute and must be based on the global clock. An example is below:

    `c ma_node_set_state_time(&myNode, ma_node_state_started, sampleRate*1); // Delay starting to 1 second. ma_node_set_state_time(&myNode, ma_node_state_stopped, sampleRate*5); // Delay stopping to 5 seconds. `

    An example for changing the state using a relative time.

    `c ma_node_set_state_time(&myNode, ma_node_state_started, sampleRate*1 + ma_node_graph_get_time(&myNodeGraph)); ma_node_set_state_time(&myNode, ma_node_state_stopped, sampleRate*5 + ma_node_graph_get_time(&myNodeGraph)); `

    Note that due to the nature of multi-threading the times may not be 100% exact. If this is an issue, consider scheduling state changes from within a processing callback. An idea might be to have some kind of passthrough trigger node that is used specifically for tracking time and handling events.

    7.2. Thread Safety and Locking ------------------------------ When processing audio, it's ideal not to have any kind of locking in the audio thread. Since it's expected that ma_node_graph_read_pcm_frames() would be run on the audio thread, it does so without the use of any locks. This section discusses the implementation used by miniaudio and goes over some of the compromises employed by miniaudio to achieve this goal. Note that the current implementation may not be ideal - feedback and critiques are most welcome.

    The node graph API is not entirely lock-free. Only ma_node_graph_read_pcm_frames() is expected to be lock-free. Attachment, detachment and uninitialization of nodes use locks to simplify the implementation, but are crafted in a way such that such locking is not required when reading audio data from the graph. Locking in these areas are achieved by means of spinlocks.

    The main complication with keeping ma_node_graph_read_pcm_frames() lock-free stems from the fact that a node can be uninitialized, and it's memory potentially freed, while in the middle of being processed on the audio thread. There are times when the audio thread will be referencing a node, which means the uninitialization process of a node needs to make sure it delays returning until the audio thread is finished so that control is not handed back to the caller thereby giving them a chance to free the node's memory.

    When the audio thread is processing a node, it does so by reading from each of the output buses of the node. In order for a node to process data for one of its output buses, it needs to read from each of its input buses, and so on an so forth. It follows that once all output buses of a node are detached, the node as a whole will be disconnected and no further processing will occur unless it's output buses are reattached, which won't be happening when the node is being uninitialized. By having ma_node_detach_output_bus() wait until the audio thread is finished with it, we can simplify a few things, at the expense of making ma_node_detach_output_bus() a bit slower. By doing this, the implementation of ma_node_uninit() becomes trivial - just detach all output nodes, followed by each of the attachments to each of its input nodes, and then do any final clean up.

    With the above design, the worst-case scenario is ma_node_detach_output_bus() taking as long as it takes to process the output bus being detached. This will happen if it's called at just the wrong moment where the audio thread has just iterated it and has just started processing. The caller of ma_node_detach_output_bus() will stall until the audio thread is finished, which includes the cost of recursively processing its inputs. This is the biggest compromise made with the approach taken by miniaudio for its lock-free processing system. The cost of detaching nodes earlier in the pipeline (data sources, for example) will be cheaper than the cost of detaching higher level nodes, such as some kind of final post-processing endpoint. If you need to do mass detachments, detach starting from the lowest level nodes and work your way towards the final endpoint node (but don't try detaching the node graph's endpoint). If the audio thread is not running, detachment will be fast and detachment in any order will be the same. The reason nodes need to wait for their input attachments to complete is due to the potential for desyncs between data sources. If the node was to terminate processing mid way through processing its inputs, there's a chance that some of the underlying data sources will have been read, but then others not. That will then result in a potential desynchronization when detaching and reattaching higher-level nodes. A possible solution to this is to have an option when detaching to terminate processing before processing all input attachments which should be fairly simple.

    Another compromise, albeit less significant, is locking when attaching and detaching nodes. This locking is achieved by means of a spinlock in order to reduce memory overhead. A lock is present for each input bus and output bus. When an output bus is connected to an input bus, both the output bus and input bus is locked. This locking is specifically for attaching and detaching across different threads and does not affect ma_node_graph_read_pcm_frames() in any way. The locking and unlocking is mostly self-explanatory, but a slightly less intuitive aspect comes into it when considering that iterating over attachments must not break as a result of attaching or detaching a node while iteration is occurring.

    Attaching and detaching are both quite simple. When an output bus of a node is attached to an input bus of another node, it's added to a linked list. Basically, an input bus is a linked list, where each item in the list is and output bus. We have some intentional (and convenient) restrictions on what can done with the linked list in order to simplify the implementation. First of all, whenever something needs to iterate over the list, it must do so in a forward direction. Backwards iteration is not supported. Also, items can only be added to the start of the list.

    The linked list is a doubly-linked list where each item in the list (an output bus) holds a pointer to the next item in the list, and another to the previous item. A pointer to the previous item is only required for fast detachment of the node - it is never used in iteration. This is an important property because it means from the perspective of iteration, attaching and detaching of an item can be done with a single atomic assignment. This is exploited by both the attachment and detachment process. When attaching the node, the first thing that is done is the setting of the local "next" and "previous" pointers of the node. After that, the item is "attached" to the list by simply performing an atomic exchange with the head pointer. After that, the node is "attached" to the list from the perspective of iteration. Even though the "previous" pointer of the next item hasn't yet been set, from the perspective of iteration it's been attached because iteration will only be happening in a forward direction which means the "previous" pointer won't actually ever get used. The same general process applies to detachment. See ma_node_attach_output_bus() and ma_node_detach_output_bus() for the implementation of this mechanism.

    8. Decoding =========== The ma_decoder API is used for reading audio files. Decoders are completely decoupled from devices and can be used independently. Built-in support is included for the following formats:

    +---------+ | Format | +---------+ | WAV | | MP3 | | FLAC | +---------+

    You can disable the built-in decoders by specifying one or more of the following options before the miniaudio implementation:

    `c #define MA_NO_WAV #define MA_NO_MP3 #define MA_NO_FLAC `

    miniaudio supports the ability to plug in custom decoders. See the section below for details on how to use custom decoders.

    A decoder can be initialized from a file with ma_decoder_init_file(), a block of memory with ma_decoder_init_memory(), or from data delivered via callbacks with ma_decoder_init(). Here is an example for loading a decoder from a file:

    `c ma_decoder decoder; ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder); if (result != MA_SUCCESS) { return false; // An error occurred. }

    ...

    ma_decoder_uninit(&decoder); `

    When initializing a decoder, you can optionally pass in a pointer to a ma_decoder_config object (the NULL argument in the example above) which allows you to configure the output format, channel count, sample rate and channel map:

    `c ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000); `

    When passing in NULL for decoder config in ma_decoder_init*(), the output format will be the same as that defined by the decoding backend.

    Data is read from the decoder as PCM frames. This will output the number of PCM frames actually read. If this is less than the requested number of PCM frames it means you've reached the end. The return value will be MA_AT_END if no samples have been read and the end has been reached.

    `c ma_result result = ma_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead, &framesRead); if (framesRead < framesToRead) { // Reached the end. } `

    You can also seek to a specific frame like so:

    `c ma_result result = ma_decoder_seek_to_pcm_frame(pDecoder, targetFrame); if (result != MA_SUCCESS) { return false; // An error occurred. } `

    If you want to loop back to the start, you can simply seek back to the first PCM frame:

    `c ma_decoder_seek_to_pcm_frame(pDecoder, 0); `

    When loading a decoder, miniaudio uses a trial and error technique to find the appropriate decoding backend. This can be unnecessarily inefficient if the type is already known. In this case you can use encodingFormat variable in the device config to specify a specific encoding format you want to decode:

    `c decoderConfig.encodingFormat = ma_encoding_format_wav; `

    See the ma_encoding_format enum for possible encoding formats.

    The ma_decoder_init_file() API will try using the file extension to determine which decoding backend to prefer.

    8.1. Custom Decoders -------------------- It's possible to implement a custom decoder and plug it into miniaudio. This is extremely useful when you want to use the ma_decoder API, but need to support an encoding format that's not one of the stock formats supported by miniaudio. This can be put to particularly good use when using the ma_engine and/or ma_resource_manager APIs because they use ma_decoder internally. If, for example, you wanted to support Opus, you can do so with a custom decoder (there if a reference Opus decoder in the "extras" folder of the miniaudio repository which uses libopus + libopusfile).

    A custom decoder must implement a data source. A vtable called ma_decoding_backend_vtable needs to be implemented which is then passed into the decoder config:

    `c ma_decoding_backend_vtable* pCustomBackendVTables[] = { &g_ma_decoding_backend_vtable_libvorbis, &g_ma_decoding_backend_vtable_libopus };

    ...

    decoderConfig = ma_decoder_config_init_default(); decoderConfig.pCustomBackendUserData = NULL; decoderConfig.ppCustomBackendVTables = pCustomBackendVTables; decoderConfig.customBackendCount = sizeof(pCustomBackendVTables) / sizeof(pCustomBackendVTables[0]); `

    The ma_decoding_backend_vtable vtable has the following functions:

    ` onInit onInitFile onInitFileW onInitMemory onUninit `

    There are only two functions that must be implemented - onInit and onUninit. The other functions can be implemented for a small optimization for loading from a file path or memory. If these are not specified, miniaudio will deal with it for you via a generic implementation.

    When you initialize a custom data source (by implementing the onInit function in the vtable) you will need to output a pointer to a ma_data_source which implements your custom decoder. See the section about data sources for details on how to implement this. Alternatively, see the "custom_decoders" example in the miniaudio repository.

    The onInit function takes a pointer to some callbacks for the purpose of reading raw audio data from some arbitrary source. You'll use these functions to read from the raw data and perform the decoding. When you call them, you will pass in the pReadSeekTellUserData pointer to the relevant parameter.

    The pConfig parameter in onInit can be used to configure the backend if appropriate. It's only used as a hint and can be ignored. However, if any of the properties are relevant to your decoder, an optimal implementation will handle the relevant properties appropriately.

    If memory allocation is required, it should be done so via the specified allocation callbacks if possible (the pAllocationCallbacks parameter).

    If an error occurs when initializing the decoder, you should leave ppBackend unset, or set to NULL, and make sure everything is cleaned up appropriately and an appropriate result code returned. When multiple custom backends are specified, miniaudio will cycle through the vtables in the order they're listed in the array that's passed into the decoder config so it's important that your initialization routine is clean.

    When a decoder is uninitialized, the onUninit callback will be fired which will give you an opportunity to clean up and internal data.

    9. Encoding =========== The ma_encoding API is used for writing audio files. The only supported output format is WAV. This can be disabled by specifying the following option before the implementation of miniaudio:

    `c #define MA_NO_WAV `

    An encoder can be initialized to write to a file with ma_encoder_init_file() or from data delivered via callbacks with ma_encoder_init(). Below is an example for initializing an encoder to output to a file.

    `c ma_encoder_config config = ma_encoder_config_init(ma_encoding_format_wav, FORMAT, CHANNELS, SAMPLE_RATE); ma_encoder encoder; ma_result result = ma_encoder_init_file("my_file.wav", &config, &encoder); if (result != MA_SUCCESS) { // Error }

    ...

    ma_encoder_uninit(&encoder); `

    When initializing an encoder you must specify a config which is initialized with ma_encoder_config_init(). Here you must specify the file type, the output sample format, output channel count and output sample rate. The following file types are supported:

    +------------------------+-------------+ | Enum | Description | +------------------------+-------------+ | ma_encoding_format_wav | WAV | +------------------------+-------------+

    If the format, channel count or sample rate is not supported by the output file type an error will be returned. The encoder will not perform data conversion so you will need to convert it before outputting any audio data. To output audio data, use ma_encoder_write_pcm_frames(), like in the example below:

    `c ma_uint64 framesWritten; result = ma_encoder_write_pcm_frames(&encoder, pPCMFramesToWrite, framesToWrite, &framesWritten); if (result != MA_SUCCESS) { ... handle error ... } `

    The framesWritten variable will contain the number of PCM frames that were actually written. This is optionally and you can pass in NULL if you need this.

    Encoders must be uninitialized with ma_encoder_uninit().

    10. Data Conversion =================== A data conversion API is included with miniaudio which supports the majority of data conversion requirements. This supports conversion between sample formats, channel counts (with channel mapping) and sample rates.

    10.1. Sample Format Conversion ------------------------------ Conversion between sample formats is achieved with the ma_pcm_*_to_*(), ma_pcm_convert() and ma_convert_pcm_frames_format() APIs. Use ma_pcm_*_to_*() to convert between two specific formats. Use ma_pcm_convert() to convert based on a ma_format variable. Use ma_convert_pcm_frames_format() to convert PCM frames where you want to specify the frame count and channel count as a variable instead of the total sample count.

    10.1.1. Dithering ----------------- Dithering can be set using the ditherMode parameter.

    The different dithering modes include the following, in order of efficiency:

    +-----------+--------------------------+ | Type | Enum Token | +-----------+--------------------------+ | None | ma_dither_mode_none | | Rectangle | ma_dither_mode_rectangle | | Triangle | ma_dither_mode_triangle | +-----------+--------------------------+

    Note that even if the dither mode is set to something other than ma_dither_mode_none, it will be ignored for conversions where dithering is not needed. Dithering is available for the following conversions:

    ` s16 -> u8 s24 -> u8 s32 -> u8 f32 -> u8 s24 -> s16 s32 -> s16 f32 -> s16 `

    Note that it is not an error to pass something other than ma_dither_mode_none for conversions where dither is not used. It will just be ignored.

    10.2. Channel Conversion ------------------------ Channel conversion is used for channel rearrangement and conversion from one channel count to another. The ma_channel_converter API is used for channel conversion. Below is an example of initializing a simple channel converter which converts from mono to stereo.

    `c ma_channel_converter_config config = ma_channel_converter_config_init( ma_format, // Sample format 1, // Input channels NULL, // Input channel map 2, // Output channels NULL, // Output channel map ma_channel_mix_mode_default); // The mixing algorithm to use when combining channels.

    result = ma_channel_converter_init(&config, NULL, &converter); if (result != MA_SUCCESS) { // Error. } `

    To perform the conversion simply call ma_channel_converter_process_pcm_frames() like so:

    `c ma_result result = ma_channel_converter_process_pcm_frames(&converter, pFramesOut, pFramesIn, frameCount); if (result != MA_SUCCESS) { // Error. } `

    It is up to the caller to ensure the output buffer is large enough to accommodate the new PCM frames.

    Input and output PCM frames are always interleaved. Deinterleaved layouts are not supported.

    10.2.1. Channel Mapping ----------------------- In addition to converting from one channel count to another, like the example above, the channel converter can also be used to rearrange channels. When initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, and each channel map contains the same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If, however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is specified when initializing the ma_channel_converter_config object.

    When converting from mono to multi-channel, the mono channel is simply copied to each output channel. When going the other way around, the audio of each output channel is simply averaged and copied to the mono channel.

    In more complicated cases blending is used. The ma_channel_mix_mode_simple mode will drop excess channels and silence extra channels. For example, converting from 4 to 2 channels, the 3rd and 4th channels will be dropped, whereas converting from 2 to 4 channels will put silence into the 3rd and 4th channels.

    The ma_channel_mix_mode_rectangle mode uses spacial locality based on a rectangle to compute a simple distribution between input and output. Imagine sitting in the middle of a room, with speakers on the walls representing channel positions. The MA_CHANNEL_FRONT_LEFT position can be thought of as being in the corner of the front and left walls.

    Finally, the ma_channel_mix_mode_custom_weights mode can be used to use custom user-defined weights. Custom weights can be passed in as the last parameter of ma_channel_converter_config_init().

    Predefined channel maps can be retrieved with ma_channel_map_init_standard(). This takes a ma_standard_channel_map enum as its first parameter, which can be one of the following:

    +-----------------------------------+-----------------------------------------------------------+ | Name | Description | +-----------------------------------+-----------------------------------------------------------+ | ma_standard_channel_map_default | Default channel map used by miniaudio. See below. | | ma_standard_channel_map_microsoft | Channel map used by Microsoft's bitfield channel maps. | | ma_standard_channel_map_alsa | Default ALSA channel map. | | ma_standard_channel_map_rfc3551 | RFC 3551. Based on AIFF. | | ma_standard_channel_map_flac | FLAC channel map. | | ma_standard_channel_map_vorbis | Vorbis channel map. | | ma_standard_channel_map_sound4 | FreeBSD's sound(4). | | ma_standard_channel_map_sndio | sndio channel map. http://www.sndio.org/tips.html. | | ma_standard_channel_map_webaudio | https://webaudio.github.io/web-audio-api/#ChannelOrdering | +-----------------------------------+-----------------------------------------------------------+

    Below are the channel maps used by default in miniaudio (ma_standard_channel_map_default):

    +---------------+---------------------------------+ | Channel Count | Mapping | +---------------+---------------------------------+ | 1 (Mono) | 0: MA_CHANNEL_MONO | +---------------+---------------------------------+ | 2 (Stereo) | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT | +---------------+---------------------------------+ | 3 | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER | +---------------+---------------------------------+ | 4 (Surround) | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER <br> | | | 3: MA_CHANNEL_BACK_CENTER | +---------------+---------------------------------+ | 5 | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER <br> | | | 3: MA_CHANNEL_BACK_LEFT <br> | | | 4: MA_CHANNEL_BACK_RIGHT | +---------------+---------------------------------+ | 6 (5.1) | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER <br> | | | 3: MA_CHANNEL_LFE <br> | | | 4: MA_CHANNEL_SIDE_LEFT <br> | | | 5: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | 7 | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER <br> | | | 3: MA_CHANNEL_LFE <br> | | | 4: MA_CHANNEL_BACK_CENTER <br> | | | 4: MA_CHANNEL_SIDE_LEFT <br> | | | 5: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | 8 (7.1) | 0: MA_CHANNEL_FRONT_LEFT <br> | | | 1: MA_CHANNEL_FRONT_RIGHT <br> | | | 2: MA_CHANNEL_FRONT_CENTER <br> | | | 3: MA_CHANNEL_LFE <br> | | | 4: MA_CHANNEL_BACK_LEFT <br> | | | 5: MA_CHANNEL_BACK_RIGHT <br> | | | 6: MA_CHANNEL_SIDE_LEFT <br> | | | 7: MA_CHANNEL_SIDE_RIGHT | +---------------+---------------------------------+ | Other | All channels set to 0. This | | | is equivalent to the same | | | mapping as the device. | +---------------+---------------------------------+

    10.3. Resampling ---------------- Resampling is achieved with the ma_resampler object. To create a resampler object, do something like the following:

    `c ma_resampler_config config = ma_resampler_config_init( ma_format_s16, channels, sampleRateIn, sampleRateOut, ma_resample_algorithm_linear);

    ma_resampler resampler; ma_result result = ma_resampler_init(&config, NULL, &resampler); if (result != MA_SUCCESS) { // An error occurred... } `

    Do the following to uninitialize the resampler:

    `c ma_resampler_uninit(&resampler); `

    The following example shows how data can be processed

    `c ma_uint64 frameCountIn = 1000; ma_uint64 frameCountOut = 2000; ma_result result = ma_resampler_process_pcm_frames(&resampler, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut); if (result != MA_SUCCESS) { // An error occurred... }

    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the // number of output frames written. `

    To initialize the resampler you first need to set up a config (ma_resampler_config) with ma_resampler_config_init(). You need to specify the sample format you want to use, the number of channels, the input and output sample rate, and the algorithm.

    The sample format can be either ma_format_s16 or ma_format_f32. If you need a different format you will need to perform pre- and post-conversions yourself where necessary. Note that the format is the same for both input and output. The format cannot be changed after initialization.

    The resampler supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.

    The sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only configuration property that can be changed after initialization.

    The miniaudio resampler has built-in support for the following algorithms:

    +-----------+------------------------------+ | Algorithm | Enum Token | +-----------+------------------------------+ | Linear | ma_resample_algorithm_linear | | Custom | ma_resample_algorithm_custom | +-----------+------------------------------+

    The algorithm cannot be changed after initialization.

    Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process frames, use ma_resampler_process_pcm_frames(). On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.

    The sample rate can be changed dynamically on the fly. You can change this with explicit sample rates with ma_resampler_set_rate() and also with a decimal ratio with ma_resampler_set_rate_ratio(). The ratio is in/out.

    Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with ma_resampler_get_required_input_frame_count(). Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of input frames. You can do this with ma_resampler_get_expected_output_frame_count().

    Due to the nature of how resampling works, the resampler introduces some latency. This can be retrieved in terms of both the input rate and the output rate with ma_resampler_get_input_latency() and ma_resampler_get_output_latency().

    10.3.1. Resampling Algorithms ----------------------------- The choice of resampling algorithm depends on your situation and requirements.

    10.3.1.1. Linear Resampling --------------------------- The linear resampler is the fastest, but comes at the expense of poorer quality. There is, however, some control over the quality of the linear resampler which may make it a suitable option depending on your requirements.

    The linear resampler performs low-pass filtering before or after downsampling or upsampling, depending on the sample rates you're converting between. When decreasing the sample rate, the low-pass filter will be applied before downsampling. When increasing the rate it will be performed after upsampling. By default a fourth order low-pass filter will be applied. This can be configured via the lpfOrder configuration variable. Setting this to 0 will disable filtering.

    The low-pass filter has a cutoff frequency which defaults to half the sample rate of the lowest of the input and output sample rates (Nyquist Frequency).

    The API for the linear resampler is the same as the main resampler API, only it's called ma_linear_resampler.

    10.3.2. Custom Resamplers ------------------------- You can implement a custom resampler by using the ma_resample_algorithm_custom resampling algorithm and setting a vtable in the resampler config:

    `c ma_resampler_config config = ma_resampler_config_init(..., ma_resample_algorithm_custom); config.pBackendVTable = &g_customResamplerVTable; `

    Custom resamplers are useful if the stock algorithms are not appropriate for your use case. You need to implement the required functions in ma_resampling_backend_vtable. Note that not all functions in the vtable need to be implemented, but if it's possible to implement, they should be.

    You can use the ma_linear_resampler object for an example on how to implement the vtable. The onGetHeapSize callback is used to calculate the size of any internal heap allocation the custom resampler will need to make given the supplied config. When you initialize the resampler via the onInit callback, you'll be given a pointer to a heap allocation which is where you should store the heap allocated data. You should not free this data in onUninit because miniaudio will manage it for you.

    The onProcess callback is where the actual resampling takes place. On input, pFrameCountIn points to a variable containing the number of frames in the pFramesIn buffer and pFrameCountOut points to a variable containing the capacity in frames of the pFramesOut buffer. On output, pFrameCountIn should be set to the number of input frames that were fully consumed, whereas pFrameCountOut should be set to the number of frames that were written to pFramesOut.

    The onSetRate callback is optional and is used for dynamically changing the sample rate. If dynamic rate changes are not supported, you can set this callback to NULL.

    The onGetInputLatency and onGetOutputLatency functions are used for retrieving the latency in input and output rates respectively. These can be NULL in which case latency calculations will be assumed to be NULL.

    The onGetRequiredInputFrameCount callback is used to give miniaudio a hint as to how many input frames are required to be available to produce the given number of output frames. Likewise, the onGetExpectedOutputFrameCount callback is used to determine how many output frames will be produced given the specified number of input frames. miniaudio will use these as a hint, but they are optional and can be set to NULL if you're unable to implement them.

    10.4. General Data Conversion ----------------------------- The ma_data_converter API can be used to wrap sample format conversion, channel conversion and resampling into one operation. This is what miniaudio uses internally to convert between the format requested when the device was initialized and the format of the backend's native device. The API for general data conversion is very similar to the resampling API. Create a ma_data_converter object like this:

    `c ma_data_converter_config config = ma_data_converter_config_init( inputFormat, outputFormat, inputChannels, outputChannels, inputSampleRate, outputSampleRate );

    ma_data_converter converter; ma_result result = ma_data_converter_init(&config, NULL, &converter); if (result != MA_SUCCESS) { // An error occurred... } `

    In the example above we use ma_data_converter_config_init() to initialize the config, however there's many more properties that can be configured, such as channel maps and resampling quality. Something like the following may be more suitable depending on your requirements:

    `c ma_data_converter_config config = ma_data_converter_config_init_default(); config.formatIn = inputFormat; config.formatOut = outputFormat; config.channelsIn = inputChannels; config.channelsOut = outputChannels; config.sampleRateIn = inputSampleRate; config.sampleRateOut = outputSampleRate; ma_channel_map_init_standard(ma_standard_channel_map_flac, config.channelMapIn, sizeof(config.channelMapIn)/sizeof(config.channelMapIn[0]), config.channelCountIn); config.resampling.linear.lpfOrder = MA_MAX_FILTER_ORDER; `

    Do the following to uninitialize the data converter:

    `c ma_data_converter_uninit(&converter, NULL); `

    The following example shows how data can be processed

    `c ma_uint64 frameCountIn = 1000; ma_uint64 frameCountOut = 2000; ma_result result = ma_data_converter_process_pcm_frames(&converter, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut); if (result != MA_SUCCESS) { // An error occurred... }

    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the number // of output frames written. `

    The data converter supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.

    Sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only configuration property that can be changed after initialization, but only if the resampling.allowDynamicSampleRate member of ma_data_converter_config is set to MA_TRUE. To change the sample rate, use ma_data_converter_set_rate() or ma_data_converter_set_rate_ratio(). The ratio must be in/out. The resampling algorithm cannot be changed after initialization.

    Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process frames, use ma_data_converter_process_pcm_frames(). On input, this function takes the number of output frames you can fit in the output buffer and the number of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.

    Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with ma_data_converter_get_required_input_frame_count(). Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of input frames. You can do this with ma_data_converter_get_expected_output_frame_count().

    Due to the nature of how resampling works, the data converter introduces some latency if resampling is required. This can be retrieved in terms of both the input rate and the output rate with ma_data_converter_get_input_latency() and ma_data_converter_get_output_latency().

    11. Filtering =============

    11.1. Biquad Filtering ---------------------- Biquad filtering is achieved with the ma_biquad API. Example:

    `c ma_biquad_config config = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2); ma_result result = ma_biquad_init(&config, NULL, &biquad); if (result != MA_SUCCESS) { // Error. }

    ...

    ma_biquad_process_pcm_frames(&biquad, pFramesOut, pFramesIn, frameCount); `

    Biquad filtering is implemented using transposed direct form 2. The numerator coefficients are b0, b1 and b2, and the denominator coefficients are a0, a1 and a2. The a0 coefficient is required and coefficients must not be pre-normalized.

    Supported formats are ma_format_s16 and ma_format_f32. If you need to use a different format you need to convert it yourself beforehand. When using ma_format_s16 the biquad filter will use fixed point arithmetic. When using ma_format_f32, floating point arithmetic will be used.

    Input and output frames are always interleaved.

    Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:

    `c ma_biquad_process_pcm_frames(&biquad, pMyData, pMyData, frameCount); `

    If you need to change the values of the coefficients, but maintain the values in the registers you can do so with ma_biquad_reinit(). This is useful if you need to change the properties of the filter while keeping the values of registers valid to avoid glitching. Do not use ma_biquad_init() for this as it will do a full initialization which involves clearing the registers to 0. Note that changing the format or channel count after initialization is invalid and will result in an error.

    11.2. Low-Pass Filtering ------------------------ Low-pass filtering is achieved with the following APIs:

    +---------+------------------------------------------+ | API | Description | +---------+------------------------------------------+ | ma_lpf1 | First order low-pass filter | | ma_lpf2 | Second order low-pass filter | | ma_lpf | High order low-pass filter (Butterworth) | +---------+------------------------------------------+

    Low-pass filter example:

    `c ma_lpf_config config = ma_lpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order); ma_result result = ma_lpf_init(&config, &lpf); if (result != MA_SUCCESS) { // Error. }

    ...

    ma_lpf_process_pcm_frames(&lpf, pFramesOut, pFramesIn, frameCount); `

    Supported formats are ma_format_s16 and ma_format_f32. If you need to use a different format you need to convert it yourself beforehand. Input and output frames are always interleaved.

    Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:

    `c ma_lpf_process_pcm_frames(&lpf, pMyData, pMyData, frameCount); `

    The maximum filter order is limited to MA_MAX_FILTER_ORDER which is set to 8. If you need more, you can chain first and second order filters together.

    `c for (iFilter = 0; iFilter < filterCount; iFilter += 1) { ma_lpf2_process_pcm_frames(&lpf2[iFilter], pMyData, pMyData, frameCount); } `

    If you need to change the configuration of the filter, but need to maintain the state of internal registers you can do so with ma_lpf_reinit(). This may be useful if you need to change the sample rate and/or cutoff frequency dynamically while maintaining smooth transitions. Note that changing the format or channel count after initialization is invalid and will result in an error.

    The ma_lpf object supports a configurable order, but if you only need a first order filter you may want to consider using ma_lpf1. Likewise, if you only need a second order filter you can use ma_lpf2. The advantage of this is that they're lighter weight and a bit more efficient.

    If an even filter order is specified, a series of second order filters will be processed in a chain. If an odd filter order is specified, a first order filter will be applied, followed by a series of second order filters in a chain.

    11.3. High-Pass Filtering ------------------------- High-pass filtering is achieved with the following APIs:

    +---------+-------------------------------------------+ | API | Description | +---------+-------------------------------------------+ | ma_hpf1 | First order high-pass filter | | ma_hpf2 | Second order high-pass filter | | ma_hpf | High order high-pass filter (Butterworth) | +---------+-------------------------------------------+

    High-pass filters work exactly the same as low-pass filters, only the APIs are called ma_hpf1, ma_hpf2 and ma_hpf. See example code for low-pass filters for example usage.

    11.4. Band-Pass Filtering ------------------------- Band-pass filtering is achieved with the following APIs:

    +---------+-------------------------------+ | API | Description | +---------+-------------------------------+ | ma_bpf2 | Second order band-pass filter | | ma_bpf | High order band-pass filter | +---------+-------------------------------+

    Band-pass filters work exactly the same as low-pass filters, only the APIs are called ma_bpf2 and ma_hpf. See example code for low-pass filters for example usage. Note that the order for band-pass filters must be an even number which means there is no first order band-pass filter, unlike low-pass and high-pass filters.

    11.5. Notch Filtering --------------------- Notch filtering is achieved with the following APIs:

    +-----------+------------------------------------------+ | API | Description | +-----------+------------------------------------------+ | ma_notch2 | Second order notching filter | +-----------+------------------------------------------+

    11.6. Peaking EQ Filtering ------------------------- Peaking filtering is achieved with the following APIs:

    +----------+------------------------------------------+ | API | Description | +----------+------------------------------------------+ | ma_peak2 | Second order peaking filter | +----------+------------------------------------------+

    11.7. Low Shelf Filtering ------------------------- Low shelf filtering is achieved with the following APIs:

    +-------------+------------------------------------------+ | API | Description | +-------------+------------------------------------------+ | ma_loshelf2 | Second order low shelf filter | +-------------+------------------------------------------+

    Where a high-pass filter is used to eliminate lower frequencies, a low shelf filter can be used to just turn them down rather than eliminate them entirely.

    11.8. High Shelf Filtering -------------------------- High shelf filtering is achieved with the following APIs:

    +-------------+------------------------------------------+ | API | Description | +-------------+------------------------------------------+ | ma_hishelf2 | Second order high shelf filter | +-------------+------------------------------------------+

    The high shelf filter has the same API as the low shelf filter, only you would use ma_hishelf instead of ma_loshelf. Where a low shelf filter is used to adjust the volume of low frequencies, the high shelf filter does the same thing for high frequencies.

    12. Waveform and Noise Generation =================================

    12.1. Waveforms --------------- miniaudio supports generation of sine, square, triangle and sawtooth waveforms. This is achieved with the ma_waveform API. Example:

    `c ma_waveform_config config = ma_waveform_config_init( FORMAT, CHANNELS, SAMPLE_RATE, ma_waveform_type_sine, amplitude, frequency);

    ma_waveform waveform; ma_result result = ma_waveform_init(&config, &waveform); if (result != MA_SUCCESS) { // Error. }

    ...

    ma_waveform_read_pcm_frames(&waveform, pOutput, frameCount); `

    The amplitude, frequency, type, and sample rate can be changed dynamically with ma_waveform_set_amplitude(), ma_waveform_set_frequency(), ma_waveform_set_type(), and ma_waveform_set_sample_rate() respectively.

    You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative ramp, for example.

    Below are the supported waveform types:

    +---------------------------+ | Enum Name | +---------------------------+ | ma_waveform_type_sine | | ma_waveform_type_square | | ma_waveform_type_triangle | | ma_waveform_type_sawtooth | +---------------------------+

    12.2. Noise ----------- miniaudio supports generation of white, pink and Brownian noise via the ma_noise API. Example:

    `c ma_noise_config config = ma_noise_config_init( FORMAT, CHANNELS, ma_noise_type_white, SEED, amplitude);

    ma_noise noise; ma_result result = ma_noise_init(&config, &noise); if (result != MA_SUCCESS) { // Error. }

    ...

    ma_noise_read_pcm_frames(&noise, pOutput, frameCount); `

    The noise API uses simple LCG random number generation. It supports a custom seed which is useful for things like automated testing requiring reproducibility. Setting the seed to zero will default to MA_DEFAULT_LCG_SEED.

    The amplitude and seed can be changed dynamically with ma_noise_set_amplitude() and ma_noise_set_seed() respectively.

    By default, the noise API will use different values for different channels. So, for example, the left side in a stereo stream will be different to the right side. To instead have each channel use the same random value, set the duplicateChannels member of the noise config to true, like so:

    `c config.duplicateChannels = MA_TRUE; `

    Below are the supported noise types.

    +------------------------+ | Enum Name | +------------------------+ | ma_noise_type_white | | ma_noise_type_pink | | ma_noise_type_brownian | +------------------------+

    13. Audio Buffers ================= miniaudio supports reading from a buffer of raw audio data via the ma_audio_buffer API. This can read from memory that's managed by the application, but can also handle the memory management for you internally. Memory management is flexible and should support most use cases.

    Audio buffers are initialized using the standard configuration system used everywhere in miniaudio:

    `c ma_audio_buffer_config config = ma_audio_buffer_config_init( format, channels, sizeInFrames, pExistingData, &allocationCallbacks);

    ma_audio_buffer buffer; result = ma_audio_buffer_init(&config, &buffer); if (result != MA_SUCCESS) { // Error. }

    ...

    ma_audio_buffer_uninit(&buffer); `

    In the example above, the memory pointed to by pExistingData will not be copied and is how an application can do self-managed memory allocation. If you would rather make a copy of the data, use ma_audio_buffer_init_copy(). To uninitialize the buffer, use ma_audio_buffer_uninit().

    Sometimes it can be convenient to allocate the memory for the ma_audio_buffer structure and the raw audio data in a contiguous block of memory. That is, the raw audio data will be located immediately after the ma_audio_buffer structure. To do this, use ma_audio_buffer_alloc_and_init():

    `c ma_audio_buffer_config config = ma_audio_buffer_config_init( format, channels, sizeInFrames, pExistingData, &allocationCallbacks);

    ma_audio_buffer* pBuffer result = ma_audio_buffer_alloc_and_init(&config, &pBuffer); if (result != MA_SUCCESS) { // Error }

    ...

    ma_audio_buffer_uninit_and_free(&buffer); `

    If you initialize the buffer with ma_audio_buffer_alloc_and_init() you should uninitialize it with ma_audio_buffer_uninit_and_free(). In the example above, the memory pointed to by pExistingData will be copied into the buffer, which is contrary to the behavior of ma_audio_buffer_init().

    An audio buffer has a playback cursor just like a decoder. As you read frames from the buffer, the cursor moves forward. The last parameter (loop) can be used to determine if the buffer should loop. The return value is the number of frames actually read. If this is less than the number of frames requested it means the end has been reached. This should never happen if the loop parameter is set to true. If you want to manually loop back to the start, you can do so with with ma_audio_buffer_seek_to_pcm_frame(pAudioBuffer, 0). Below is an example for reading data from an audio buffer.

    `c ma_uint64 framesRead = ma_audio_buffer_read_pcm_frames(pAudioBuffer, pFramesOut, desiredFrameCount, isLooping); if (framesRead < desiredFrameCount) { // If not looping, this means the end has been reached. This should never happen in looping mode with valid input. } `

    Sometimes you may want to avoid the cost of data movement between the internal buffer and the output buffer. Instead you can use memory mapping to retrieve a pointer to a segment of data:

    `c void* pMappedFrames; ma_uint64 frameCount = frameCountToTryMapping; ma_result result = ma_audio_buffer_map(pAudioBuffer, &pMappedFrames, &frameCount); if (result == MA_SUCCESS) { // Map was successful. The value in frameCount will be how many frames were _actually_ mapped, which may be // less due to the end of the buffer being reached. ma_copy_pcm_frames(pFramesOut, pMappedFrames, frameCount, pAudioBuffer->format, pAudioBuffer->channels);

    // You must unmap the buffer. ma_audio_buffer_unmap(pAudioBuffer, frameCount); } `

    When you use memory mapping, the read cursor is increment by the frame count passed in to ma_audio_buffer_unmap(). If you decide not to process every frame you can pass in a value smaller than the value returned by ma_audio_buffer_map(). The disadvantage to using memory mapping is that it does not handle looping for you. You can determine if the buffer is at the end for the purpose of looping with ma_audio_buffer_at_end() or by inspecting the return value of ma_audio_buffer_unmap() and checking if it equals MA_AT_END. You should not treat MA_AT_END as an error when returned by ma_audio_buffer_unmap().

    14. Ring Buffers ================ miniaudio supports lock free (single producer, single consumer) ring buffers which are exposed via the ma_rb and ma_pcm_rb APIs. The ma_rb API operates on bytes, whereas the ma_pcm_rb operates on PCM frames. They are otherwise identical as ma_pcm_rb is just a wrapper around ma_rb.

    Unlike most other APIs in miniaudio, ring buffers support both interleaved and deinterleaved streams. The caller can also allocate their own backing memory for the ring buffer to use internally for added flexibility. Otherwise the ring buffer will manage it's internal memory for you.

    The examples below use the PCM frame variant of the ring buffer since that's most likely the one you will want to use. To initialize a ring buffer, do something like the following:

    `c ma_pcm_rb rb; ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, NULL, NULL, &rb); if (result != MA_SUCCESS) { // Error } `

    The ma_pcm_rb_init() function takes the sample format and channel count as parameters because it's the PCM variant of the ring buffer API. For the regular ring buffer that operates on bytes you would call ma_rb_init() which leaves these out and just takes the size of the buffer in bytes instead of frames. The fourth parameter is an optional pre-allocated buffer and the fifth parameter is a pointer to a ma_allocation_callbacks structure for custom memory allocation routines. Passing in NULL for this results in MA_MALLOC() and MA_FREE() being used.

    Use ma_pcm_rb_init_ex() if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your sub-buffers you can use ma_pcm_rb_get_subbuffer_stride(), ma_pcm_rb_get_subbuffer_offset() and ma_pcm_rb_get_subbuffer_ptr().

    Use ma_pcm_rb_acquire_read() and ma_pcm_rb_acquire_write() to retrieve a pointer to a section of the ring buffer. You specify the number of frames you need, and on output it will set to what was actually acquired. If the read or write pointer is positioned such that the number of frames requested will require a loop, it will be clamped to the end of the buffer. Therefore, the number of frames you're given may be less than the number you requested.

    After calling ma_pcm_rb_acquire_read() or ma_pcm_rb_acquire_write(), you do your work on the buffer and then "commit" it with ma_pcm_rb_commit_read() or ma_pcm_rb_commit_write(). This is where the read/write pointers are updated. When you commit you need to pass in the buffer that was returned by the earlier call to ma_pcm_rb_acquire_read() or ma_pcm_rb_acquire_write() and is only used for validation. The number of frames passed to ma_pcm_rb_commit_read() and ma_pcm_rb_commit_write() is what's used to increment the pointers, and can be less that what was originally requested.

    If you want to correct for drift between the write pointer and the read pointer you can use a combination of ma_pcm_rb_pointer_distance(), ma_pcm_rb_seek_read() and ma_pcm_rb_seek_write(). Note that you can only move the pointers forward, and you should only move the read pointer forward via the consumer thread, and the write pointer forward by the producer thread. If there is too much space between the pointers, move the read pointer forward. If there is too little space between the pointers, move the write pointer forward.

    You can use a ring buffer at the byte level instead of the PCM frame level by using the ma_rb API. This is exactly the same, only you will use the ma_rb functions instead of ma_pcm_rb and instead of frame counts you will pass around byte counts.

    The maximum size of the buffer in bytes is 0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1) due to the most significant bit being used to encode a loop flag and the internally managed buffers always being aligned to MA_SIMD_ALIGNMENT.

    Note that the ring buffer is only thread safe when used by a single consumer thread and single producer thread.

    15. Backends ============ The following backends are supported by miniaudio. These are listed in order of default priority. When no backend is specified when initializing a context or device, miniaudio will attempt to use each of these backends in the order listed in the table below.

    Note that backends that are not usable by the build target will not be included in the build. For example, ALSA, which is specific to Linux, will not be included in the Windows build.

    +-------------+-----------------------+--------------------------------------------------------+ | Name | Enum Name | Supported Operating Systems | +-------------+-----------------------+--------------------------------------------------------+ | WASAPI | ma_backend_wasapi | Windows Vista+ | | DirectSound | ma_backend_dsound | Windows XP+ | | WinMM | ma_backend_winmm | Windows 95+ | | Core Audio | ma_backend_coreaudio | macOS, iOS | | sndio | ma_backend_sndio | OpenBSD | | audio(4) | ma_backend_audio4 | NetBSD, OpenBSD | | OSS | ma_backend_oss | FreeBSD | | PulseAudio | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android) | | ALSA | ma_backend_alsa | Linux | | JACK | ma_backend_jack | Cross Platform (disabled on BSD and Android) | | AAudio | ma_backend_aaudio | Android 8+ | | OpenSL ES | ma_backend_opensl | Android (API level 16+) | | Web Audio | ma_backend_webaudio | Web (via Emscripten) | | Custom | ma_backend_custom | Cross Platform | | Null | ma_backend_null | Cross Platform (not used on Web) | +-------------+-----------------------+--------------------------------------------------------+

    Some backends have some nuance details you may want to be aware of.

    15.1. WASAPI ------------ Low-latency shared mode will be disabled when using an application-defined sample rate which is different to the device's native sample rate. To work around this, set wasapi.noAutoConvertSRC to true in the device config. This is due to IAudioClient3_InitializeSharedAudioStream() failing when the AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM flag is specified. Setting wasapi.noAutoConvertSRC will result in miniaudio's internal resampler being used instead which will in turn enable the use of low-latency shared mode.

    15.2. PulseAudio ---------------- If you experience bad glitching/noise on Arch Linux, consider this fix from the Arch wiki: https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling. Alternatively, consider using a different backend such as ALSA.

    15.3. Android ------------- To capture audio on Android, remember to add the RECORD_AUDIO permission to your manifest: <uses-permission android:name="android.permission.RECORD_AUDIO" /> With OpenSL|ES, only a single ma_context can be active at any given time. This is due to a limitation with OpenSL|ES. With AAudio, only default devices are enumerated. This is due to AAudio not having an enumeration API (devices are enumerated through Java). You can however perform your own device enumeration through Java and then set the ID in the ma_device_id structure (ma_device_id.aaudio) and pass it to ma_device_init(). The backend API will perform resampling where possible. The reason for this as opposed to using miniaudio's built-in resampler is to take advantage of any potential device-specific optimizations the driver may implement.

    BSD --- The sndio backend is currently only enabled on OpenBSD builds. The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can use it.

    15.4. UWP --------- UWP only supports default playback and capture devices. UWP requires the Microphone capability to be enabled in the application's manifest (Package.appxmanifest):

    ` <Package ...> ... <Capabilities> <DeviceCapability Name="microphone" /> </Capabilities> </Package> `

    15.5. Web Audio / Emscripten ---------------------------- You cannot use -std=c* compiler flags, nor -ansi. This only applies to the Emscripten build. The first time a context is initialized it will create a global object called "miniaudio" whose primary purpose is to act as a factory for device objects. Currently the Web Audio backend uses ScriptProcessorNode's, but this may need to change later as they've been deprecated. Google has implemented a policy in their browsers that prevent automatic media output without first receiving some kind of user input. The following web page has additional details: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes. Starting the device may fail if you try to start playback without first handling some kind of user input.

    16. Optimization Tips ===================== See below for some tips on improving performance.

    16.1. Low Level API ------------------- In the data callback, if your data is already clipped prior to copying it into the output buffer, set the noClip config option in the device config to true. This will disable miniaudio's built in clipping function. By default, miniaudio will pre-silence the data callback's output buffer. If you know that you will always write valid data to the output buffer you can disable pre-silencing by setting the noPreSilence config option in the device config to true.

    16.2. High Level API -------------------- If a sound does not require doppler or pitch shifting, consider disabling pitching by initializing the sound with the MA_SOUND_FLAG_NO_PITCH flag. If a sound does not require spatialization, disable it by initializing the sound with the MA_SOUND_FLAG_NO_SPATIALIZATION flag. It can be re-enabled again post-initialization with ma_sound_set_spatialization_enabled(). If you know all of your sounds will always be the same sample rate, set the engine's sample rate to match that of the sounds. Likewise, if you're using a self-managed resource manager, consider setting the decoded sample rate to match your sounds. By configuring everything to use a consistent sample rate, sample rate conversion can be avoided.

    17. Miscellaneous Notes ======================= Automatic stream routing is enabled on a per-backend basis. Support is explicitly enabled for WASAPI and Core Audio, however other backends such as PulseAudio may naturally support it, though not all have been tested. When compiling with VC6 and earlier, decoding is restricted to files less than 2GB in size. This is due to 64-bit file APIs not being available.

    Index

    Types (254)
    Variables (0)

    This section is empty.

    Procedures (938)
    Procedure Groups (0)

    This section is empty.

    Types

    IMMNotificationClient ¶

    IMMNotificationClient :: struct {
    	lpVtbl:  rawptr,
    	counter: u32,
    	pDevice: ^device,
    }

    aaudio_allowed_capture_policy ¶

    aaudio_allowed_capture_policy :: enum i32 {
    	default = 0, // Leaves the allowed capture policy unset.
    	all,         // AAUDIO_ALLOW_CAPTURE_BY_ALL
    	system,      // AAUDIO_ALLOW_CAPTURE_BY_SYSTEM
    	none,        // AAUDIO_ALLOW_CAPTURE_BY_NONE
    }

    aaudio_content_type ¶

    aaudio_content_type :: enum i32 {
    	default      = 0, // Leaves the content type unset.
    	speech,           // AAUDIO_CONTENT_TYPE_SPEECH
    	music,            // AAUDIO_CONTENT_TYPE_MUSIC
    	movie,            // AAUDIO_CONTENT_TYPE_MOVIE
    	sonification,     // AAUDIO_CONTENT_TYPE_SONIFICATION
    }
     

    AAudio content types.

    aaudio_input_preset ¶

    aaudio_input_preset :: enum i32 {
    	default             = 0, // Leaves the input preset unset.
    	generic,                 // AAUDIO_INPUT_PRESET_GENERIC
    	camcorder,               // AAUDIO_INPUT_PRESET_CAMCORDER
    	voice_recognition,       // AAUDIO_INPUT_PRESET_VOICE_RECOGNITION
    	voice_communication,     // AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION
    	unprocessed,             // AAUDIO_INPUT_PRESET_UNPROCESSED
    	voice_performance,       // AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE
    }
     

    AAudio input presets.

    aaudio_usage ¶

    aaudio_usage :: enum i32 {
    	default                        = 0, // Leaves the usage type unset.
    	media,                              // AAUDIO_USAGE_MEDIA
    	voice_communication,                // AAUDIO_USAGE_VOICE_COMMUNICATION
    	voice_communication_signalling,     // AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING
    	alarm,                              // AAUDIO_USAGE_ALARM
    	notification,                       // AAUDIO_USAGE_NOTIFICATION
    	notification_ringtone,              // AAUDIO_USAGE_NOTIFICATION_RINGTONE
    	notification_event,                 // AAUDIO_USAGE_NOTIFICATION_EVENT
    	assistance_accessibility,           // AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY
    	assistance_navigation_guidance,     // AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
    	assistance_sonification,            // AAUDIO_USAGE_ASSISTANCE_SONIFICATION
    	game,                               // AAUDIO_USAGE_GAME
    	assitant,                           // AAUDIO_USAGE_ASSISTANT
    	emergency,                          // AAUDIO_SYSTEM_USAGE_EMERGENCY
    	safety,                             // AAUDIO_SYSTEM_USAGE_SAFETY
    	vehicle_status,                     // AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS
    	announcement,                       // AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT
    }
     

    AAudio usage types.

    allocation_callbacks ¶

    allocation_callbacks :: struct {
    	pUserData: rawptr,
    	onMalloc:  proc "c" (sz: uint, pUserData: rawptr) -> rawptr,
    	onRealloc: proc "c" (p: rawptr, sz: uint, pUserData: rawptr) -> rawptr,
    	onFree:    proc "c" (p: rawptr, pUserData: rawptr),
    }
    Related Procedures With Parameters

    async_notification ¶

    async_notification :: struct {}
     

    Notification callback for asynchronous operations.

    Related Procedures With Parameters

    async_notification_callbacks ¶

    async_notification_callbacks :: struct {
    	onSignal: proc "c" (pNotification: ^async_notification),
    }

    async_notification_event ¶

    async_notification_event :: struct {
    	cb: async_notification_callbacks,
    	e:  event,
    }
     

    Event Notification

    This uses an ma_event. If threading is disabled (MA_NO_THREADING), initialization will fail.

    Related Procedures With Parameters

    async_notification_poll ¶

    async_notification_poll :: struct {
    	cb:        async_notification_callbacks,
    	signalled: b32,
    }
     

    Simple polling notification.

    This just sets a variable when the notification has been signalled which is then polled with ma_async_notification_poll_is_signalled()

    Related Procedures With Parameters

    atomic_vec3f ¶

    atomic_vec3f :: struct {
    	v:    vec3f,
    	lock: spinlock,
    }

    attenuation_model ¶

    attenuation_model :: enum i32 {
    	none,        // No distance attenuation and no spatialization.
    	inverse,     // Equivalent to OpenAL's AL_INVERSE_DISTANCE_CLAMPED.
    	linear,      // Linear attenuation. Equivalent to OpenAL's AL_LINEAR_DISTANCE_CLAMPED.
    	exponential, // Exponential attenuation. Equivalent to OpenAL's AL_EXPONENT_DISTANCE_CLAMPED.
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    audio_buffer ¶

    audio_buffer :: struct {
    	ref:                 audio_buffer_ref,
    	allocationCallbacks: allocation_callbacks,
    	ownsData:            b32,
    	// Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). 
    	_pExtraData:         [1]u8,
    }
    Related Procedures With Parameters

    audio_buffer_config ¶

    audio_buffer_config :: struct {
    	format:              format,
    	channels:            u32,
    	sampleRate:          u32,
    	sizeInFrames:        u64,
    	pData:               rawptr,
    	// If set to NULL, will allocate a block of memory for you. 
    	allocationCallbacks: allocation_callbacks,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    backend ¶

    backend :: enum i32 {
    	wasapi, 
    	dsound, 
    	winmm, 
    	coreaudio, 
    	sndio, 
    	audio4, 
    	oss, 
    	pulseaudio, 
    	alsa, 
    	jack, 
    	aaudio, 
    	opensl, 
    	webaudio, 
    	custom,     // <-- Custom backend, with callbacks defined by the context config.
    	null,       // <-- Must always be the last item. Lowest priority, and used as the terminator for backend enumeration.
    }
     

    Backend enums must be in priority order.

    Related Procedures With Parameters

    backend_callbacks ¶

    backend_callbacks :: struct {
    	onContextInit:             proc "c" (pContext: ^context_type, pConfig: ^context_config, pCallbacks: ^backend_callbacks) -> result,
    	onContextUninit:           proc "c" (pContext: ^context_type) -> result,
    	onContextEnumerateDevices: proc "c" (pContext: ^context_type, callback: enum_devices_callback_proc, pUserData: rawptr) -> result,
    	onContextGetDeviceInfo:    proc "c" (pContext: ^context_type, deviceType: device_type, pDeviceID: ^device_id, pDeviceInfo: ^device_info) -> result,
    	onDeviceInit:              proc "c" (pDevice: ^device, pConfig: ^device_config, pDescriptorPlayback, pDescriptorCapture: ^device_descriptor) -> result,
    	onDeviceUninit:            proc "c" (pDevice: ^device) -> result,
    	onDeviceStart:             proc "c" (pDevice: ^device) -> result,
    	onDeviceStop:              proc "c" (pDevice: ^device) -> result,
    	onDeviceRead:              proc "c" (pDevice: ^device, pFrames: rawptr, frameCount: u32, pFramesRead: ^u32) -> result,
    	onDeviceWrite:             proc "c" (pDevice: ^device, pFrames: rawptr, frameCount: u32, pFramesWritten: ^u32) -> result,
    	onDeviceDataLoop:          proc "c" (pDevice: ^device) -> result,
    	onDeviceDataLoopWakeup:    proc "c" (pDevice: ^device) -> result,
    	onDeviceGetInfo:           proc "c" (pDevice: ^device, type: device_type, pDeviceInfo: ^device_info) -> result,
    }
     

    These are the callbacks required to be implemented for a backend. These callbacks are grouped into two parts: context and device. There is one context to many devices. A device is created from a context.

    The general flow goes like this:

    1) A context is created with onContextInit() 1a) Available devices can be enumerated with onContextEnumerateDevices() if required. 1b) Detailed information about a device can be queried with onContextGetDeviceInfo() if required. 2) A device is created from the context that was created in the first step using onDeviceInit(), and optionally a device ID that was selected from device enumeration via onContextEnumerateDevices(). 3) A device is started or stopped with onDeviceStart() / onDeviceStop() 4) Data is delivered to and from the device by the backend. This is always done based on the native format returned by the prior call to onDeviceInit(). Conversion between the device's native format and the format requested by the application will be handled by miniaudio internally.

    Initialization of the context is quite simple. You need to do any necessary initialization of internal objects and then output the callbacks defined in this structure.

    Once the context has been initialized you can initialize a device. Before doing so, however, the application may want to know which physical devices are available. This is where onContextEnumerateDevices() comes in. This is fairly simple. For each device, fire the given callback with, at a minimum, the basic information filled out in ma_device_info. When the callback returns MA_FALSE, enumeration needs to stop and the onContextEnumerateDevices() function returns with a success code.

    Detailed device information can be retrieved from a device ID using onContextGetDeviceInfo(). This takes as input the device type and ID, and on output returns detailed information about the device in ma_device_info. The onContextGetDeviceInfo() callback must handle the case when the device ID is NULL, in which case information about the default device needs to be retrieved.

    Once the context has been created and the device ID retrieved (if using anything other than the default device), the device can be created. This is a little bit more complicated than initialization of the context due to its more complicated configuration. When initializing a device, a duplex device may be requested. This means a separate data format needs to be specified for both playback and capture. On input, the data format is set to what the application wants. On output it's set to the native format which should match as closely as possible to the requested format. The conversion between the format requested by the application and the device's native format will be handled internally by miniaudio.

    On input, if the sample format is set to ma_format_unknown, the backend is free to use whatever sample format it desires, so long as it's supported by miniaudio. When the channel count is set to 0, the backend should use the device's native channel count. The same applies for sample rate. For the channel map, the default should be used when ma_channel_map_is_blank() returns true (all channels set to MA_CHANNEL_NONE). On input, the periodSizeInFrames or periodSizeInMilliseconds option should always be set. The backend should inspect both of these variables. If periodSizeInFrames is set, it should take priority, otherwise it needs to be derived from the period size in milliseconds (periodSizeInMilliseconds) and the sample rate, keeping in mind that the sample rate may be 0, in which case the sample rate will need to be determined before calculating the period size in frames. On output, all members of the ma_device_descriptor object should be set to a valid value, except for periodSizeInMilliseconds which is optional (periodSizeInFrames must be set).

    Starting and stopping of the device is done with onDeviceStart() and onDeviceStop() and should be self-explanatory. If the backend uses asynchronous reading and writing, onDeviceStart() and onDeviceStop() should always be implemented.

    The handling of data delivery between the application and the device is the most complicated part of the process. To make this a bit easier, some helper callbacks are available. If the backend uses a blocking read/write style of API, the onDeviceRead() and onDeviceWrite() callbacks can optionally be implemented. These are blocking and work just like reading and writing from a file. If the backend uses a callback for data delivery, that callback must call ma_device_handle_backend_data_callback() from within its callback. This allows miniaudio to then process any necessary data conversion and then pass it to the miniaudio data callback.

    If the backend requires absolute flexibility with its data delivery, it can optionally implement the onDeviceDataLoop() callback which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional.

    The audio thread should run data delivery logic in a loop while ma_device_get_state() == ma_device_state_started and no errors have been encountered. Do not start or stop the device here. That will be handled from outside the onDeviceDataLoop() callback.

    The invocation of the onDeviceDataLoop() callback will be handled by miniaudio. When you start the device, miniaudio will fire this callback. When the device is stopped, the ma_device_get_state() == ma_device_state_started condition will fail and the loop will be terminated which will then fall through to the part that stops the device. For an example on how to implement the onDeviceDataLoop() callback, look at ma_device_audio_thread__default_read_write(). Implement the onDeviceDataLoopWakeup() callback if you need a mechanism to wake up the audio thread.

    If the backend supports an optimized retrieval of device information from an initialized ma_device object, it should implement the onDeviceGetInfo() callback. This is optional, in which case it will fall back to onContextGetDeviceInfo() which is less efficient.

    biquad_coefficient ¶

    biquad_coefficient :: struct #raw_union {
    	f32: f32,
    	s32: i32,
    }
     

    *********************************

    Biquad Filtering

    *********************************

    biquad_config ¶

    biquad_config :: struct {
    	format:   format,
    	channels: u32,
    	b0:       f64,
    	b1:       f64,
    	b2:       f64,
    	a0:       f64,
    	a1:       f64,
    	a2:       f64,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    biquad_node ¶

    biquad_node :: struct {
    	baseNode: node_base,
    	biquad:   biquad,
    }
    Related Procedures With Parameters

    biquad_node_config ¶

    biquad_node_config :: struct {
    	nodeConfig: node_config,
    	biquad:     biquad_config,
    }
     

    Biquad Node

    Related Procedures With Parameters
    Related Procedures With Returns

    bpf ¶

    bpf :: struct {
    	format:    format,
    	channels:  u32,
    	bpf2Count: u32,
    	pBPF2:     ^bpf2,
    	// Memory management. 
    	_pHeap:    rawptr,
    	_ownsHeap: b32,
    }
    Related Procedures With Parameters

    bpf2_config ¶

    bpf2_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	q:               f64,
    }
     

    *********************************

    Band-Pass Filtering

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    bpf_config ¶

    bpf_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	order:           u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    bpf_node ¶

    bpf_node :: struct {
    	baseNode: node_base,
    	bpf:      bpf,
    }
    Related Procedures With Parameters

    bpf_node_config ¶

    bpf_node_config :: struct {
    	nodeConfig: node_config,
    	bpf:        bpf_config,
    }
     

    Band Pass Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    channel ¶

    channel :: enum u8 {
    	NONE               = 0, 
    	MONO               = 1, 
    	FRONT_LEFT         = 2, 
    	FRONT_RIGHT        = 3, 
    	FRONT_CENTER       = 4, 
    	LFE                = 5, 
    	BACK_LEFT          = 6, 
    	BACK_RIGHT         = 7, 
    	FRONT_LEFT_CENTER  = 8, 
    	FRONT_RIGHT_CENTER = 9, 
    	BACK_CENTER        = 10, 
    	SIDE_LEFT          = 11, 
    	SIDE_RIGHT         = 12, 
    	TOP_CENTER         = 13, 
    	TOP_FRONT_LEFT     = 14, 
    	TOP_FRONT_CENTER   = 15, 
    	TOP_FRONT_RIGHT    = 16, 
    	TOP_BACK_LEFT      = 17, 
    	TOP_BACK_CENTER    = 18, 
    	TOP_BACK_RIGHT     = 19, 
    	AUX_0              = 20, 
    	AUX_1              = 21, 
    	AUX_2              = 22, 
    	AUX_3              = 23, 
    	AUX_4              = 24, 
    	AUX_5              = 25, 
    	AUX_6              = 26, 
    	AUX_7              = 27, 
    	AUX_8              = 28, 
    	AUX_9              = 29, 
    	AUX_10             = 30, 
    	AUX_11             = 31, 
    	AUX_12             = 32, 
    	AUX_13             = 33, 
    	AUX_14             = 34, 
    	AUX_15             = 35, 
    	AUX_16             = 36, 
    	AUX_17             = 37, 
    	AUX_18             = 38, 
    	AUX_19             = 39, 
    	AUX_20             = 40, 
    	AUX_21             = 41, 
    	AUX_22             = 42, 
    	AUX_23             = 43, 
    	AUX_24             = 44, 
    	AUX_25             = 45, 
    	AUX_26             = 46, 
    	AUX_27             = 47, 
    	AUX_28             = 48, 
    	AUX_29             = 49, 
    	AUX_30             = 50, 
    	AUX_31             = 51, 
    	LEFT               = 2, 
    	RIGHT              = 3, 
    	POSITION_COUNT     = 52, 
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    channel_conversion_path ¶

    channel_conversion_path :: enum i32 {
    	unknown, 
    	passthrough, 
    	mono_out,    // Converting to mono.
    	mono_in,     // Converting from mono.
    	shuffle,     // Simple shuffle. Will use this when all channels are present in both input and output channel maps, but just in a different order.
    	weights,     // Blended based on weights.
    }
     

    *********************************

    Channel Conversion

    *********************************

    channel_converter ¶

    channel_converter :: struct {
    	format:         format,
    	channelsIn:     u32,
    	channelsOut:    u32,
    	mixingMode:     channel_mix_mode,
    	conversionPath: channel_conversion_path,
    	pChannelMapIn:  [^]channel,
    	pChannelMapOut: [^]channel,
    	pShuffleTable:  [^]u8,
    	weights:        struct #raw_union {
    		// [in][out] 
    		f32: ^[^]f32,
    		s16: ^[^]i32,
    	},
    	// Memory management. 
    	_pHeap:         rawptr,
    	_ownsHeap:      b32,
    }
    Related Procedures With Parameters

    channel_converter_config ¶

    channel_converter_config :: struct {
    	format:                          format,
    	channelsIn:                      u32,
    	channelsOut:                     u32,
    	pChannelMapIn:                   [^]channel,
    	pChannelMapOut:                  [^]channel,
    	mixingMode:                      channel_mix_mode,
    	calculateLFEFromSpatialChannels: b32,
    	// When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. 
    	ppWeights:                       ^[^]f32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    channel_mix_mode ¶

    channel_mix_mode :: enum i32 {
    	rectangular    = 0, // Simple averaging based on the plane(s) the channel is sitting on.
    	simple,             // Drop excess channels; zeroed out extra channels.
    	custom_weights,     // Use custom weights specified in ma_channel_converter_config.
    	default        = 0, 
    }
    Related Procedures With Parameters

    context_command__wasapi ¶

    context_command__wasapi :: struct {
    	code:   i32,
    	pEvent: ^event,
    	// This will be signalled when the event is complete. 
    	data:   struct #raw_union {
    		quit:               struct {
    			_unused: i32,
    		},
    		createAudioClient:  struct {
    			deviceType:           device_type,
    			pAudioClient:         rawptr,
    			ppAudioClientService: ^rawptr,
    			pResult:              ^result,
    		},
    		releaseAudioClient: struct {
    			pDevice:    ^device,
    			deviceType: device_type,
    		},
    	},
    }
     

    WASAPI specific structure for some commands which must run on a common thread due to bugs in WASAPI.

    context_config ¶

    context_config :: struct {
    	pLog:                ^log,
    	threadPriority:      thread_priority,
    	threadStackSize:     uint,
    	pUserData:           rawptr,
    	allocationCallbacks: allocation_callbacks,
    	dsound:              struct {
    		hWnd: handle,
    	},
    	alsa:                struct {
    		useVerboseDeviceEnumeration: b32,
    	},
    	pulse:               struct {
    		pApplicationName: cstring,
    		pServerName:      cstring,
    		tryAutoSpawn:     b32,
    	},
    	coreaudio:           struct {
    		sessionCategory:          ios_session_category,
    		sessionCategoryOptions:   u32,
    		noAudioSessionActivate:   b32,
    		// iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization. 
    		noAudioSessionDeactivate: b32,
    	},
    	jack:                struct {
    		pClientName:    cstring,
    		tryStartServer: b32,
    	},
    	custom:              backend_callbacks,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    context_type ¶

    context_type :: struct {
    	callbacks:               backend_callbacks,
    	backend:                 backend,
    	// DirectSound, ALSA, etc. 
    	pLog:                    ^log,
    	log:                     log,
    	// Only used if the log is owned by the context. The pLog member will be set to &log in this case. 
    	threadPriority:          thread_priority,
    	threadStackSize:         uint,
    	pUserData:               rawptr,
    	allocationCallbacks:     allocation_callbacks,
    	deviceEnumLock:          mutex,
    	// Used to make ma_context_get_devices() thread safe. 
    	deviceInfoLock:          mutex,
    	// Used to make ma_context_get_device_info() thread safe. 
    	deviceInfoCapacity:      u32,
    	// Total capacity of pDeviceInfos. 
    	playbackDeviceInfoCount: u32,
    	captureDeviceInfoCount:  u32,
    	pDeviceInfos:            [^]device_info,
    	// Playback devices first, then capture. 
    	using _:                 struct #raw_union {
    		wasapi:       struct {
    			commandThread:                   thread,
    			commandLock:                     mutex,
    			commandSem:                      semaphore,
    			commandIndex:                    u32,
    			commandCount:                    u32,
    			commands:                        [4]context_command__wasapi,
    			hAvrt:                           handle,
    			AvSetMmThreadCharacteristicsA:   proc "stdcall" (),
    			AvRevertMmThreadCharacteristics: proc "stdcall" (),
    			hMMDevapi:                       handle,
    			ActivateAudioInterfaceAsync:     proc "stdcall" (),
    		},
    		dsound:       struct {
    			hWnd:                         handle,
    			// Can be null. 
    			hDSoundDLL:                   handle,
    			DirectSoundCreate:            proc "stdcall" (),
    			DirectSoundEnumerateA:        proc "stdcall" (),
    			DirectSoundCaptureCreate:     proc "stdcall" (),
    			DirectSoundCaptureEnumerateA: proc "stdcall" (),
    		},
    		winmm:        struct {
    			hWinMM:                 handle,
    			waveOutGetNumDevs:      proc "stdcall" (),
    			waveOutGetDevCapsA:     proc "stdcall" (),
    			waveOutOpen:            proc "stdcall" (),
    			waveOutClose:           proc "stdcall" (),
    			waveOutPrepareHeader:   proc "stdcall" (),
    			waveOutUnprepareHeader: proc "stdcall" (),
    			waveOutWrite:           proc "stdcall" (),
    			waveOutReset:           proc "stdcall" (),
    			waveInGetNumDevs:       proc "stdcall" (),
    			waveInGetDevCapsA:      proc "stdcall" (),
    			waveInOpen:             proc "stdcall" (),
    			waveInClose:            proc "stdcall" (),
    			waveInPrepareHeader:    proc "stdcall" (),
    			waveInUnprepareHeader:  proc "stdcall" (),
    			waveInAddBuffer:        proc "stdcall" (),
    			waveInStart:            proc "stdcall" (),
    			waveInReset:            proc "stdcall" (),
    		},
    		alsa:         struct {},
    		pulse:        struct {},
    		jack:         struct {
    			jackSO:                        handle,
    			jack_client_open:              proc "stdcall" (),
    			jack_client_close:             proc "stdcall" (),
    			jack_client_name_size:         proc "stdcall" (),
    			jack_set_process_callback:     proc "stdcall" (),
    			jack_set_buffer_size_callback: proc "stdcall" (),
    			jack_on_shutdown:              proc "stdcall" (),
    			jack_get_sample_rate:          proc "stdcall" (),
    			jack_get_buffer_size:          proc "stdcall" (),
    			jack_get_ports:                proc "stdcall" (),
    			jack_activate:                 proc "stdcall" (),
    			jack_deactivate:               proc "stdcall" (),
    			jack_connect:                  proc "stdcall" (),
    			jack_port_register:            proc "stdcall" (),
    			jack_port_name:                proc "stdcall" (),
    			jack_port_get_buffer:          proc "stdcall" (),
    			jack_free:                     proc "stdcall" (),
    			pClientName:                   cstring,
    			tryStartServer:                b32,
    		},
    		coreaudio:    struct {},
    		sndio:        struct {},
    		audio4:       struct {},
    		oss:          struct {},
    		aaudio:       struct {},
    		opensl:       struct {},
    		webaudio:     struct {},
    		null_backend: struct {
    			_unused: i32,
    		},
    	},
    	using _:                 struct #raw_union {
    		win32:   struct {
    			hOle32DLL:           handle,
    			CoInitialize:        proc "stdcall" (),
    			CoInitializeEx:      proc "stdcall" (),
    			CoUninitialize:      proc "stdcall" (),
    			CoCreateInstance:    proc "stdcall" (),
    			CoTaskMemFree:       proc "stdcall" (),
    			PropVariantClear:    proc "stdcall" (),
    			StringFromGUID2:     proc "stdcall" (),
    			hUser32DLL:          handle,
    			GetForegroundWindow: proc "stdcall" (),
    			GetDesktopWindow:    proc "stdcall" (),
    			hAdvapi32DLL:        handle,
    			RegOpenKeyExA:       proc "stdcall" (),
    			RegCloseKey:         proc "stdcall" (),
    			RegQueryValueExA:    proc "stdcall" (),
    			CoInitializeResult:  i32,
    		},
    		posix:   struct {},
    		_unused: i32,
    	},
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    data_converter ¶

    data_converter :: struct {
    	formatIn:                format,
    	formatOut:               format,
    	channelsIn:              u32,
    	channelsOut:             u32,
    	sampleRateIn:            u32,
    	sampleRateOut:           u32,
    	ditherMode:              dither_mode,
    	executionPath:           data_converter_execution_path,
    	// The execution path the data converter will follow when processing. 
    	channelConverter:        channel_converter,
    	resampler:               resampler,
    	hasPreFormatConversion:  b8,
    	hasPostFormatConversion: b8,
    	hasChannelConverter:     b8,
    	hasResampler:            b8,
    	isPassthrough:           b8,
    	// Memory management. 
    	_ownsHeap:               b8,
    	_pHeap:                  rawptr,
    }
    Related Procedures With Parameters

    data_converter_config ¶

    data_converter_config :: struct {
    	formatIn:                        format,
    	formatOut:                       format,
    	channelsIn:                      u32,
    	channelsOut:                     u32,
    	sampleRateIn:                    u32,
    	sampleRateOut:                   u32,
    	pChannelMapIn:                   [^]channel,
    	pChannelMapOut:                  [^]channel,
    	ditherMode:                      dither_mode,
    	channelMixMode:                  channel_mix_mode,
    	calculateLFEFromSpatialChannels: b32,
    	// When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. 
    	ppChannelWeights:                ^[^]f32,
    	// [in][out]. Only used when channelMixMode is set to ma_channel_mix_mode_custom_weights. 
    	allowDynamicSampleRate:          b32,
    	resampling:                      resampler_config,
    }
     

    *********************************

    Data Conversion

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    data_converter_execution_path ¶

    data_converter_execution_path :: enum i32 {
    	passthrough,    // No conversion.
    	format_only,    // Only format conversion.
    	channels_only,  // Only channel conversion.
    	resample_only,  // Only resampling.
    	resample_first, // All conversions, but resample as the first step.
    	channels_first, // All conversions, but channels as the first step.
    }

    data_format_flag ¶

    data_format_flag :: enum i32 {
    	EXCLUSIVE_MODE = 1, // If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode.
    }

    data_format_flags ¶

    data_format_flags :: bit_set[data_format_flag; u32]

    data_source_base ¶

    data_source_base :: struct {
    	vtable:           ^data_source_vtable,
    	rangeBegInFrames: u64,
    	rangeEndInFrames: u64,
    	// Set to -1 for unranged (default). 
    	loopBegInFrames:  u64,
    	// Relative to rangeBegInFrames. 
    	loopEndInFrames:  u64,
    	// Relative to rangeBegInFrames. Set to -1 for the end of the range. 
    	pCurrent:         ^data_source,
    	// When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. 
    	pNext:            ^data_source,
    	// When set to NULL, onGetNext will be used. 
    	onGetNext:        data_source_get_next_proc,
    	// Will be used when pNext is NULL. If both are NULL, no next will be used. 
    	isLooping:        b32,
    }

    data_source_config ¶

    data_source_config :: struct {
    	vtable: ^data_source_vtable,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    data_source_flag ¶

    data_source_flag :: enum i32 {
    	SELF_MANAGED_RANGE_AND_LOOP_POINT = 0, 
    }

    data_source_flags ¶

    data_source_flags :: bit_set[data_source_flag; u32]

    data_source_get_next_proc ¶

    data_source_get_next_proc :: proc "c" (pDataSource: ^data_source) -> ^data_source
    Related Procedures With Parameters
    Related Procedures With Returns

    data_source_node_config ¶

    data_source_node_config :: struct {
    	nodeConfig:  node_config,
    	pDataSource: ^data_source,
    }
     

    Data source node. 0 input buses, 1 output bus. Used for reading from a data source.

    Related Procedures With Parameters
    Related Procedures With Returns

    data_source_vtable ¶

    data_source_vtable :: struct {
    	onRead:          proc "c" (pDataSource: ^data_source, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result,
    	onSeek:          proc "c" (pDataSource: ^data_source, frameIndex: u64) -> result,
    	onGetDataFormat: proc "c" (pDataSource: ^data_source, pFormat: ^format, pChannels: ^u32, pSampleRate: ^u32, pChannelMap: [^]channel, channelMapCap: uint) -> result,
    	onGetCursor:     proc "c" (pDataSource: ^data_source, pCursor: ^u64) -> result,
    	onGetLength:     proc "c" (pDataSource: ^data_source, pLength: ^u64) -> result,
    	onSetLooping:    proc "c" (pDataSource: ^data_source, isLooping: b32) -> result,
    	flags:           bit_set[data_source_flag; u32],
    }

    decoder ¶

    decoder :: struct {
    	ds:                     data_source_base,
    	pBackend:               ^data_source,
    	// The decoding backend we'll be pulling data from. 
    	pBackendVTable:         ^decoding_backend_vtable,
    	// The vtable for the decoding backend. This needs to be stored so we can access the onUninit() callback. 
    	pBackendUserData:       rawptr,
    	onRead:                 decoder_read_proc,
    	onSeek:                 decoder_seek_proc,
    	onTell:                 decoder_tell_proc,
    	pUserData:              rawptr,
    	readPointerInPCMFrames: u64,
    	// In output sample rate. Used for keeping track of how many frames are available for decoding. 
    	outputFormat:           format,
    	outputChannels:         u32,
    	outputSampleRate:       u32,
    	converter:              data_converter,
    	// <-- Data conversion is achieved by running frames through this. 
    	pInputCache:            rawptr,
    	// In input format. Can be null if it's not needed. 
    	inputCacheCap:          u64,
    	// The capacity of the input cache. 
    	inputCacheConsumed:     u64,
    	// The number of frames that have been consumed in the cache. Used for determining the next valid frame. 
    	inputCacheRemaining:    u64,
    	// The number of valid frames remaining in the cache. 
    	allocationCallbacks:    allocation_callbacks,
    	data:                   struct #raw_union {
    		vfs:    struct {
    			pVFS: ^vfs,
    			file: vfs_file,
    		},
    		memory: struct {
    			pData:          [^]u8,
    			dataSize:       uint,
    			currentReadPos: uint,
    		},
    	},
    }
    Related Procedures With Parameters

    decoder_config ¶

    decoder_config :: struct {
    	format:                 format,
    	// Set to 0 or ma_format_unknown to use the stream's internal format. 
    	channels:               u32,
    	// Set to 0 to use the stream's internal channels. 
    	sampleRate:             u32,
    	// Set to 0 to use the stream's internal sample rate. 
    	channelMap:             [^]channel,
    	channelMixMode:         channel_mix_mode,
    	ditherMode:             dither_mode,
    	resampling:             resampler_config,
    	allocationCallbacks:    allocation_callbacks,
    	encodingFormat:         encoding_format,
    	seekPointCount:         u32,
    	// When set to > 0, specifies the number of seek points to use for the generation of a seek table. Not all decoding backends support this. 
    	ppCustomBackendVTables: ^[^]decoding_backend_vtable,
    	customBackendCount:     u32,
    	pCustomBackendUserData: rawptr,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    decoder_read_proc ¶

    decoder_read_proc :: proc "c" (pDecoder: ^decoder, pBufferOut: rawptr, bytesToRead: uint, pBytesRead: ^uint) -> result
     

    Returns the number of bytes read.

    Related Procedures With Parameters

    decoder_seek_proc ¶

    decoder_seek_proc :: proc "c" (pDecoder: ^decoder, byteOffset: i64, origin: seek_origin) -> result
    Related Procedures With Parameters

    decoder_tell_proc ¶

    decoder_tell_proc :: proc "c" (pDecoder: ^decoder, pCursor: ^i64) -> result

    decoding_backend_config ¶

    decoding_backend_config :: struct {
    	preferredFormat: format,
    	seekPointCount:  u32,
    }
    Related Procedures With Returns

    decoding_backend_vtable ¶

    decoding_backend_vtable :: struct {
    	onInit:       proc "c" (pUserData: rawptr, onRead: decoder_read_proc, onSeek: decoder_seek_proc, onTell: decoder_tell_proc, pReadSeekTellUserData: rawptr, pConfig: ^decoding_backend_config, pAllocationCallbacks: ^allocation_callbacks, ppBackend: ^^data_source) -> result,
    	onInitFile:   proc "c" (pUserData: rawptr, pFilePath: cstring, pConfig: ^decoding_backend_config, pAllocationCallbacks: ^allocation_callbacks, ppBackend: ^^data_source) -> result,
    	// Optional. 
    	onInitFileW:  proc "c" (pUserData: rawptr, pFilePath: [^]u16, pConfig: ^decoding_backend_config, pAllocationCallbacks: ^allocation_callbacks, ppBackend: ^^data_source) -> result,
    	// Optional. 
    	onInitMemory: proc "c" (pUserData: rawptr, pData: rawptr, dataSize: uint, pConfig: ^decoding_backend_config, pAllocationCallbacks: ^allocation_callbacks, ppBackend: ^^data_source) -> result,
    	// Optional. 
    	onUninit:     proc "c" (pUserData: rawptr, pBackend: ^data_source, pAllocationCallbacks: ^allocation_callbacks),
    }

    default_vfs ¶

    default_vfs :: struct {
    	cb:                  vfs_callbacks,
    	allocationCallbacks: allocation_callbacks,
    }
    Related Procedures With Parameters

    delay ¶

    delay :: struct {
    	config:             delay_config,
    	cursor:             u32,
    	// Feedback is written to this cursor. Always equal or in front of the read cursor. 
    	bufferSizeInFrames: u32,
    	pBuffer:            [^]f32,
    }
    Related Procedures With Parameters

    delay_config ¶

    delay_config :: struct {
    	channels:      u32,
    	sampleRate:    u32,
    	delayInFrames: u32,
    	delayStart:    b32,
    	// Set to true to delay the start of the output; false otherwise. 
    	wet:           f32,
    	// 0..1. Default = 1. 
    	dry:           f32,
    	// 0..1. Default = 1. 
    	decay:         f32,
    }
     

    Delay

    Related Procedures With Parameters
    Related Procedures With Returns

    delay_node_config ¶

    delay_node_config :: struct {
    	nodeConfig: node_config,
    	delay:      delay_config,
    }
     

    Delay Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    device ¶

    device :: struct {
    	pContext:                  ^context_type,
    	type:                      device_type,
    	sampleRate:                u32,
    	state:                     u32,
    	// atomic
    	// The state of the device is variable and can change at any time on any thread. Must be used atomically. 
    	onData:                    device_data_proc,
    	// Set once at initialization time and should not be changed after. 
    	onNotification:            device_notification_proc,
    	// Set once at initialization time and should not be changed after. 
    	onStop:                    stop_proc,
    	// DEPRECATED. Use the notification callback instead. Set once at initialization time and should not be changed after. 
    	pUserData:                 rawptr,
    	// Application defined data. 
    	startStopLock:             mutex,
    	wakeupEvent:               event,
    	startEvent:                event,
    	stopEvent:                 event,
    	device_thread:             thread,
    	workResult:                result,
    	// This is set by the worker thread after it's finished doing a job. 
    	isOwnerOfContext:          b8,
    	// When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). 
    	noPreSilencedOutputBuffer: b8,
    	noClip:                    b8,
    	noDisableDenormals:        b8,
    	noFixedSizedCallback:      b8,
    	masterVolumeFactor:        f32,
    	// atomic
    	// Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. 
    	duplexRB:                  duplex_rb,
    	// Intermediary buffer for duplex device on asynchronous backends. 
    	resampling:                struct {
    		algorithm:        resample_algorithm,
    		pBackendVTable:   ^resampling_backend_vtable,
    		pBackendUserData: rawptr,
    		linear:           struct {
    			lpfOrder: u32,
    		},
    	},
    	playback:                  struct {
    		pID:                             ^device_id,
    		// Set to NULL if using default ID, otherwise set to the address of "id". 
    		id:                              device_id,
    		// If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. 
    		name:                            [256]u8,
    		// Maybe temporary. Likely to be replaced with a query API. 
    		shareMode:                       share_mode,
    		// Set to whatever was passed in when the device was initialized. 
    		playback_format:                 format,
    		channels:                        u32,
    		channelMap:                      [254]channel,
    		internalFormat:                  format,
    		internalChannels:                u32,
    		internalSampleRate:              u32,
    		internalChannelMap:              [254]channel,
    		internalPeriodSizeInFrames:      u32,
    		internalPeriods:                 u32,
    		channelMixMode:                  channel_mix_mode,
    		calculateLFEFromSpatialChannels: b32,
    		converter:                       data_converter,
    		pIntermediaryBuffer:             rawptr,
    		// For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. 
    		intermediaryBufferCap:           u32,
    		intermediaryBufferLen:           u32,
    		// How many valid frames are sitting in the intermediary buffer. 
    		pInputCache:                     rawptr,
    		// In external format. Can be null. 
    		inputCacheCap:                   u64,
    		inputCacheConsumed:              u64,
    		inputCacheRemaining:             u64,
    	},
    	capture:                   struct {
    		pID:                             ^device_id,
    		// Set to NULL if using default ID, otherwise set to the address of "id". 
    		id:                              device_id,
    		// If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. 
    		name:                            [256]u8,
    		// Maybe temporary. Likely to be replaced with a query API. 
    		shareMode:                       share_mode,
    		// Set to whatever was passed in when the device was initialized. 
    		capture_format:                  format,
    		channels:                        u32,
    		channelMap:                      [254]channel,
    		internalFormat:                  format,
    		internalChannels:                u32,
    		internalSampleRate:              u32,
    		internalChannelMap:              [254]channel,
    		internalPeriodSizeInFrames:      u32,
    		internalPeriods:                 u32,
    		channelMixMode:                  channel_mix_mode,
    		calculateLFEFromSpatialChannels: b32,
    		converter:                       data_converter,
    		pIntermediaryBuffer:             rawptr,
    		// For implementing fixed sized buffer callbacks. Will be null if using variable sized callbacks. 
    		intermediaryBufferCap:           u32,
    		intermediaryBufferLen:           u32,
    	},
    	using _:                   struct #raw_union {
    		wasapi:      struct {
    			pAudioClientPlayback:             rawptr,
    			pAudioClientCapture:              rawptr,
    			pRenderClient:                    rawptr,
    			pCaptureClient:                   rawptr,
    			pDeviceEnumerator:                rawptr,
    			// Used for IMMNotificationClient notifications. Required for detecting default device changes. 
    			notificationClient:               IMMNotificationClient,
    			hEventPlayback:                   handle,
    			hEventCapture:                    handle,
    			// Auto reset. Initialized to unsignaled. 
    			actualPeriodSizeInFramesPlayback: u32,
    			// Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. 
    			actualPeriodSizeInFramesCapture:  u32,
    			originalPeriodSizeInFrames:       u32,
    			originalPeriodSizeInMilliseconds: u32,
    			originalPeriods:                  u32,
    			originalPerformanceProfile:       performance_profile,
    			periodSizeInFramesPlayback:       u32,
    			periodSizeInFramesCapture:        u32,
    			pMappedBufferCapture:             rawptr,
    			mappedBufferCaptureCap:           u32,
    			mappedBufferCaptureLen:           u32,
    			pMappedBufferPlayback:            rawptr,
    			mappedBufferPlaybackCap:          u32,
    			mappedBufferPlaybackLen:          u32,
    			isStartedCapture:                 b32,
    			// atomic
    			// Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. 
    			isStartedPlayback:                b32,
    			// atomic
    			// Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. 
    			loopbackProcessID:                u32,
    			loopbackProcessExclude:           b8,
    			noAutoConvertSRC:                 b8,
    			// When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. 
    			noDefaultQualitySRC:              b8,
    			// When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. 
    			noHardwareOffloading:             b8,
    			allowCaptureAutoStreamRouting:    b8,
    			allowPlaybackAutoStreamRouting:   b8,
    			isDetachedPlayback:               b8,
    			isDetachedCapture:                b8,
    			usage:                            wasapi_usage,
    			hAvrtHandle:                      rawptr,
    			rerouteLock:                      mutex,
    		},
    		dsound:      struct {
    			pPlayback:              rawptr,
    			pPlaybackPrimaryBuffer: rawptr,
    			pPlaybackBuffer:        rawptr,
    			pCapture:               rawptr,
    			pCaptureBuffer:         rawptr,
    		},
    		winmm:       struct {
    			hDevicePlayback:              handle,
    			hDeviceCapture:               handle,
    			hEventPlayback:               handle,
    			hEventCapture:                handle,
    			fragmentSizeInFrames:         u32,
    			iNextHeaderPlayback:          u32,
    			// [0,periods). Used as an index into pWAVEHDRPlayback. 
    			iNextHeaderCapture:           u32,
    			// [0,periods). Used as an index into pWAVEHDRCapture. 
    			headerFramesConsumedPlayback: u32,
    			// The number of PCM frames consumed in the buffer in pWAVEHEADER[iNextHeader]. 
    			headerFramesConsumedCapture:  u32,
    			pWAVEHDRPlayback:             [^]u8,
    			pWAVEHDRCapture:              [^]u8,
    			// One instantiation for each period. 
    			pIntermediaryBufferPlayback:  [^]u8,
    			pIntermediaryBufferCapture:   [^]u8,
    			_pHeapData:                   [^]u8,
    		},
    		alsa:        struct {},
    		pulse:       struct {},
    		jack:        struct {
    			pClient:                     rawptr,
    			pPortsPlayback:              [^]rawptr,
    			pPortsCapture:               [^]rawptr,
    			pIntermediaryBufferPlayback: [^]f32,
    			// Typed as a float because JACK is always floating point. 
    			pIntermediaryBufferCapture:  [^]f32,
    		},
    		coreaudio:   struct {},
    		sndio:       struct {},
    		audio4:      struct {},
    		oss:         struct {},
    		aaudio:      struct {},
    		opensl:      struct {},
    		webaudio:    struct {},
    		null_device: struct {
    			deviceThread:                         thread,
    			operationEvent:                       event,
    			operationCompletionEvent:             event,
    			operationSemaphore:                   semaphore,
    			operation:                            u32,
    			operationResult:                      result,
    			timer:                                timer,
    			priorRunTime:                         f64,
    			currentPeriodFramesRemainingPlayback: u32,
    			currentPeriodFramesRemainingCapture:  u32,
    			lastProcessedFramePlayback:           u64,
    			lastProcessedFrameCapture:            u64,
    			sStarted:                             b32,
    		},
    	},
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    device_config ¶

    device_config :: struct {
    	deviceType:                device_type,
    	sampleRate:                u32,
    	periodSizeInFrames:        u32,
    	periodSizeInMilliseconds:  u32,
    	periods:                   u32,
    	performanceProfile:        performance_profile,
    	noPreSilencedOutputBuffer: b8,
    	// When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to zero. 
    	noClip:                    b8,
    	// When set to true, the contents of the output buffer passed into the data callback will not be clipped after returning. Only applies when the playback sample format is f32. 
    	noDisableDenormals:        b8,
    	// Do not disable denormals when firing the data callback. 
    	noFixedSizedCallback:      b8,
    	// Disables strict fixed-sized data callbacks. Setting this to true will result in the period size being treated only as a hint to the backend. This is an optimization for those who don't need fixed sized callbacks. 
    	dataCallback:              device_data_proc,
    	notificationCallback:      device_notification_proc,
    	stopCallback:              stop_proc,
    	pUserData:                 rawptr,
    	resampling:                resampler_config,
    	playback:                  struct {
    		pDeviceID:                       ^device_id,
    		format:                          format,
    		channels:                        u32,
    		channelMap:                      [^]channel,
    		channelMixMode:                  channel_mix_mode,
    		calculateLFEFromSpatialChannels: b32,
    		// When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. 
    		shareMode:                       share_mode,
    	},
    	capture:                   struct {
    		pDeviceID:                       ^device_id,
    		format:                          format,
    		channels:                        u32,
    		channelMap:                      [^]channel,
    		channelMixMode:                  channel_mix_mode,
    		calculateLFEFromSpatialChannels: b32,
    		// When an output LFE channel is present, but no input LFE, set to true to set the output LFE to the average of all spatial channels (LR, FR, etc.). Ignored when an input LFE is present. 
    		shareMode:                       share_mode,
    	},
    	wasapi:                    struct {
    		usage:                  wasapi_usage,
    		// When configured, uses Avrt APIs to set the thread characteristics. 
    		noAutoConvertSRC:       b8,
    		// When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. 
    		noDefaultQualitySRC:    b8,
    		// When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. 
    		noAutoStreamRouting:    b8,
    		// Disables automatic stream routing. 
    		noHardwareOffloading:   b8,
    		// Disables WASAPI's hardware offloading feature. 
    		loopbackProcessID:      u32,
    		// The process ID to include or exclude for loopback mode. Set to 0 to capture audio from all processes. Ignored when an explicit device ID is specified. 
    		loopbackProcessExclude: b8,
    	},
    	alsa:                      struct {
    		noMMap:         b32,
    		// Disables MMap mode. 
    		noAutoFormat:   b32,
    		// Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. 
    		noAutoChannels: b32,
    		// Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. 
    		noAutoResample: b32,
    	},
    	pulse:                     struct {
    		pStreamNamePlayback: cstring,
    		pStreamNameCapture:  cstring,
    		channelMap:          i32,
    	},
    	coreaudio:                 struct {
    		allowNominalSampleRateChange: b32,
    	},
    	opensl:                    struct {
    		streamType:                     opensl_stream_type,
    		recordingPreset:                opensl_recording_preset,
    		enableCompatibilityWorkarounds: b32,
    	},
    	aaudio:                    struct {
    		usage:                          aaudio_usage,
    		contentType:                    aaudio_content_type,
    		inputPreset:                    aaudio_input_preset,
    		allowedCapturePolicy:           aaudio_allowed_capture_policy,
    		noAutoStartAfterReroute:        b32,
    		enableCompatibilityWorkarounds: b32,
    		allowSetBufferCapacity:         b32,
    	},
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    device_data_proc ¶

    device_data_proc :: proc "c" (pDevice: ^device, pOutput, pInput: rawptr, frameCount: u32)
     

    The callback for processing audio data from the device.

    The data callback is fired by miniaudio whenever the device needs to have more data delivered to a playback device, or when a capture device has some data available. This is called as soon as the backend asks for more data which means it may be called with inconsistent frame counts. You cannot assume the callback will be fired with a consistent frame count.

    Parameters ---------- pDevice (in)

    A pointer to the relevant device.
    
    

    pOutput (out)

    A pointer to the output buffer that will receive audio data that will later be played back through the speakers. This will be non-null for a playback or
    full-duplex device and null for a capture and loopback device.
    
    

    pInput (in)

    A pointer to the buffer containing input data from a recording device. This will be non-null for a capture, full-duplex or loopback device and null for a
    playback device.
    
    

    frameCount (in)

    The number of PCM frames to process. Note that this will not necessarily be equal to what you requested when you initialized the device. The
    `periodSizeInFrames` and `periodSizeInMilliseconds` members of the device config are just hints, and are not necessarily exactly what you'll get. You must
    not assume this will always be the same value each time the callback is fired.
    
    
    

    Remarks ------- You cannot stop and start the device from inside the callback or else you'll get a deadlock. You must also not uninitialize the device from inside the callback. The following APIs cannot be called from inside the callback:

    ma_device_init()
    ma_device_init_ex()
    ma_device_uninit()
    ma_device_start()
    ma_device_stop()
    
    

    The proper way to stop the device is to call ma_device_stop() from a different thread, normally the main application thread.

    device_descriptor ¶

    device_descriptor :: struct {
    	pDeviceID:                ^device_id,
    	shareMode:                share_mode,
    	format:                   format,
    	channels:                 u32,
    	sampleRate:               u32,
    	channelMap:               [254]channel,
    	periodSizeInFrames:       u32,
    	periodSizeInMilliseconds: u32,
    	periodCount:              u32,
    }
     

    Describes some basic details about a playback or capture device.

    Related Procedures With Parameters

    device_id ¶

    device_id :: struct #raw_union {
    	wasapi:      [64]u16,
    	// WASAPI uses a wchar_t string for identification. 
    	dsound:      [16]u8,
    	winmm:       u32,
    	// When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. 
    	alsa:        [256]u8,
    	// ALSA uses a name string for identification. 
    	pulse:       [256]u8,
    	// PulseAudio uses a name string for identification. 
    	jack:        i32,
    	// JACK always uses default devices. 
    	coreaudio:   [256]u8,
    	// Core Audio uses a string for identification. 
    	sndio:       [256]u8,
    	// "snd/0", etc. 
    	audio4:      [256]u8,
    	// "/dev/audio", etc. 
    	oss:         [64]u8,
    	// "dev/dsp0", etc. "dev/dsp" for the default device. 
    	aaudio:      i32,
    	// AAudio uses a 32-bit integer for identification. 
    	opensl:      u32,
    	// OpenSL|ES uses a 32-bit unsigned integer for identification. 
    	webaudio:    [32]u8,
    	// Web Audio always uses default devices for now, but if this changes it'll be a GUID. 
    	custom:      struct #raw_union {
    		i: i32,
    		s: [256]u8,
    		p: rawptr,
    	},
    	// The custom backend could be anything. Give them a few options. 
    	nullbackend: i32,
    }
    Related Procedures With Parameters

    device_info ¶

    device_info :: struct {
    	// Basic info. This is the only information guaranteed to be filled in during device enumeration. 
    	id:                    device_id,
    	name:                  [256]u8,
    	// +1 for null terminator. 
    	isDefault:             b32,
    	nativeDataFormatCount: u32,
    	nativeDataFormats:     [64]struct {
    		// Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. 
    		format:     format,
    		// Sample format. If set to ma_format_unknown, all sample formats are supported. 
    		channels:   u32,
    		// If set to 0, all channels are supported. 
    		sampleRate: u32,
    		// If set to 0, all sample rates are supported. 
    		flags:      bit_set[data_format_flag; u32],
    	},
    }
    Related Procedures With Parameters

    device_job_thread ¶

    device_job_thread :: struct {
    	thread:     thread,
    	jobQueue:   job_queue,
    	_hasThread: b32,
    }
    Related Procedures With Parameters

    device_job_thread_config ¶

    device_job_thread_config :: struct {
    	noThread:         b32,
    	// Set this to true if you want to process jobs yourself. 
    	jobQueueCapacity: u32,
    	jobQueueFlags:    u32,
    }
     

    Device job thread. This is used by backends that require asynchronous processing of certain operations. It is not used by all backends.

    The device job thread is made up of a thread and a job queue. You can post a job to the thread with ma_device_job_thread_post(). The thread will do the processing of the job.

    Related Procedures With Parameters
    Related Procedures With Returns

    device_notification ¶

    device_notification :: struct {
    	pDevice: ^device,
    	type:    device_notification_type,
    	data:    struct #raw_union {
    		started:      struct {
    			_unused: i32,
    		},
    		stopped:      struct {
    			_unused: i32,
    		},
    		rerouted:     struct {
    			_unused: i32,
    		},
    		interruption: struct {
    			_unused: i32,
    		},
    	},
    }

    device_notification_proc ¶

    device_notification_proc :: proc "c" (pNotification: ^device_notification)
     

    The notification callback for when the application should be notified of a change to the device.

    This callback is used for notifying the application of changes such as when the device has started, stopped, rerouted or an interruption has occurred. Note that not all backends will post all notification types. For example, some backends will perform automatic stream routing without any kind of notification to the host program which means miniaudio will never know about it and will never be able to fire the rerouted notification. You should keep this in mind when designing your program.

    The stopped notification will not get fired when a device is rerouted.

    Parameters ---------- pNotification (in) A pointer to a structure containing information about the event. Use the pDevice member of this object to retrieve the relevant device. The type member can be used to discriminate against each of the notification types.

    Remarks ------- Do not restart or uninitialize the device from the callback.

    Not all notifications will be triggered by all backends, however the started and stopped events should be reliable for all backends. Some backends do not have a good way to detect device stoppages due to unplugging the device which may result in the stopped callback not getting fired. This has been observed with at least one BSD variant.

    The rerouted notification is fired after the reroute has occurred. The stopped notification will not get fired when a device is rerouted. The following backends are known to do automatic stream rerouting, but do not have a way to be notified of the change:

    * DirectSound

    The interruption notifications are used on mobile platforms for detecting when audio is interrupted due to things like an incoming phone call. Currently this is only implemented on iOS. None of the Android backends will report this notification.

    device_notification_type ¶

    device_notification_type :: enum i32 {
    	started, 
    	stopped, 
    	rerouted, 
    	interruption_began, 
    	interruption_ended, 
    	unlocked, 
    }
     

    Device notification types.

    device_state ¶

    device_state :: enum i32 {
    	uninitialized = 0, 
    	stopped       = 1, // The device's default state after initialization.
    	started       = 2, // The device is started and is requesting and/or delivering audio data.
    	starting      = 3, // Transitioning from a stopped state to started.
    	stopping      = 4, // Transitioning from a started state to stopped.
    }
    Related Procedures With Returns

    device_type ¶

    device_type :: enum i32 {
    	playback = 1, 
    	capture  = 2, 
    	duplex   = 3, // playback | capture
    	loopback = 4, 
    }
    Related Procedures With Parameters

    duplex_rb ¶

    duplex_rb :: struct {
    	rb: pcm_rb,
    }
     

    The idea of the duplex ring buffer is to act as the intermediary buffer when running two asynchronous devices in a duplex set up. The capture device writes to it, and then a playback device reads from it.

    At the moment this is just a simple naive implementation, but in the future I want to implement some dynamic resampling to seamlessly handle desyncs. Note that the API is work in progress and may change at any time in any version.

    The size of the buffer is based on the capture side since that's what'll be written to the buffer. It is based on the capture period size in frames. The internal sample rate of the capture device is also needed in order to calculate the size.

    Related Procedures With Parameters

    encoder ¶

    encoder :: struct {
    	config:           encoder_config,
    	onWrite:          encoder_write_proc,
    	onSeek:           encoder_seek_proc,
    	onInit:           encoder_init_proc,
    	onUninit:         encoder_uninit_proc,
    	onWritePCMFrames: encoder_write_pcm_frames_proc,
    	pUserData:        rawptr,
    	pInternalEncoder: rawptr,
    	data:             struct {
    		vfs: struct {
    			pVFS: ^vfs,
    			file: vfs_file,
    		},
    	},
    }
    Related Procedures With Parameters

    encoder_config ¶

    encoder_config :: struct {
    	encodingFormat:      encoding_format,
    	format:              format,
    	channels:            u32,
    	sampleRate:          u32,
    	allocationCallbacks: allocation_callbacks,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    encoder_init_proc ¶

    encoder_init_proc :: proc "c" (pEncoder: ^encoder) -> result

    encoder_seek_proc ¶

    encoder_seek_proc :: proc "c" (pEncoder: ^encoder, offset: i64, origin: seek_origin) -> result
    Related Procedures With Parameters

    encoder_uninit_proc ¶

    encoder_uninit_proc :: proc "c" (pEncoder: ^encoder)

    encoder_write_pcm_frames_proc ¶

    encoder_write_pcm_frames_proc :: proc "c" (pEncoder: ^encoder, pFramesIn: rawptr, frameCount: u64, pFramesWritten: ^u64) -> result

    encoder_write_proc ¶

    encoder_write_proc :: proc "c" (pEncoder: ^encoder, pBufferIn: rawptr, bytesToWrite: uint, pBytesWritten: ^uint) -> result
    Related Procedures With Parameters

    encoding_format ¶

    encoding_format :: enum i32 {
    	unknown = 0, 
    	wav, 
    	flac, 
    	mp3, 
    	vorbis, 
    }
    Related Procedures With Parameters

    engine ¶

    engine :: struct {
    	nodeGraph:                          node_graph,
    	// An engine is a node graph. It should be able to be plugged into any ma_node_graph API (with a cast) which means this must be the first member of this struct. 
    	pResourceManager:                   ^resource_manager,
    	pDevice:                            ^device,
    	// Optionally set via the config, otherwise allocated by the engine in ma_engine_init(). 
    	pLog:                               ^log,
    	sampleRate:                         u32,
    	listenerCount:                      u32,
    	listeners:                          [4]spatializer_listener,
    	allocationCallbacks:                allocation_callbacks,
    	ownsResourceManager:                b8,
    	ownsDevice:                         b8,
    	inlinedSoundLock:                   spinlock,
    	// For synchronizing access to the inlined sound list. 
    	pInlinedSoundHead:                  ^sound_inlined,
    	// The first inlined sound. Inlined sounds are tracked in a linked list. 
    	inlinedSoundCount:                  u32,
    	// atomic
    	// The total number of allocated inlined sound objects. Used for debugging. 
    	gainSmoothTimeInFrames:             u32,
    	// The number of frames to interpolate the gain of spatialized sounds across. 
    	defaultVolumeSmoothTimeInPCMFrames: u32,
    	monoExpansionMode:                  mono_expansion_mode,
    	onProcess:                          engine_process_proc,
    	pProcessUserData:                   rawptr,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    engine_config ¶

    engine_config :: struct {
    	pResourceManager:                   ^resource_manager,
    	// Can be null in which case a resource manager will be created for you. 
    	pContext:                           ^context_type,
    	pDevice:                            ^device,
    	// If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. 
    	pPlaybackDeviceID:                  ^device_id,
    	// The ID of the playback device to use with the default listener. 
    	dataCallback:                       device_data_proc,
    	// Can be null. Can be used to provide a custom device data callback. 
    	notificationCallback:               device_notification_proc,
    	pLog:                               ^log,
    	// When set to NULL, will use the context's log. 
    	listenerCount:                      u32,
    	// Must be between 1 and MA_ENGINE_MAX_LISTENERS. 
    	channels:                           u32,
    	// The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. 
    	sampleRate:                         u32,
    	// The sample rate. When set to 0 will use the native channel count of the device. 
    	periodSizeInFrames:                 u32,
    	// If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.
    	periodSizeInMilliseconds:           u32,
    	// Used if periodSizeInFrames is unset. 
    	gainSmoothTimeInFrames:             u32,
    	// The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. 
    	gainSmoothTimeInMilliseconds:       u32,
    	// When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. 
    	defaultVolumeSmoothTimeInPCMFrames: u32,
    	// Defaults to 0. Controls the default amount of smoothing to apply to volume changes to sounds. High values means more smoothing at the expense of high latency (will take longer to reach the new volume). 
    	preMixStackSizeInBytes:             u32,
    	// A stack is used for internal processing in the node graph. This allows you to configure the size of this stack. Smaller values will reduce the maximum depth of your node graph. You should rarely need to modify this. 
    	allocationCallbacks:                allocation_callbacks,
    	noAutoStart:                        b32,
    	// When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). 
    	noDevice:                           b32,
    	// When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. 
    	monoExpansionMode:                  mono_expansion_mode,
    	// Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. 
    	pResourceManagerVFS:                ^vfs,
    	// A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. 
    	onProcess:                          engine_process_proc,
    	// Fired at the end of each call to ma_engine_read_pcm_frames(). For engine's that manage their own internal device (the default configuration), this will be fired from the audio thread, and you do not need to call ma_engine_read_pcm_frames() manually in order to trigger this. 
    	pProcessUserData:                   rawptr,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    engine_node ¶

    engine_node :: struct {
    	baseNode:                    node_base,
    	// Must be the first member for compatibility with the ma_node API. 
    	pEngine:                     ^engine,
    	// A pointer to the engine. Set based on the value from the config. 
    	sampleRate:                  u32,
    	// The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. 
    	volumeSmoothTimeInPCMFrames: u32,
    	monoExpansionMode:           mono_expansion_mode,
    	fader:                       fader,
    	resampler:                   linear_resampler,
    	// For pitch shift. 
    	spatializer:                 spatializer,
    	panner:                      panner,
    	volumeGainer:                gainer,
    	// This will only be used if volumeSmoothTimeInPCMFrames is > 0. 
    	volume:                      f32,
    	// atomic
    	// Defaults to 1. 
    	pitch:                       f32,
    	// atomic
    	oldPitch:                    f32,
    	// For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. 
    	oldDopplerPitch:             f32,
    	// For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. 
    	isPitchDisabled:             b32,
    	// atomic
    	// When set to true, pitching will be disabled which will allow the resampler to be bypassed to save some computation. 
    	isSpatializationDisabled:    b32,
    	// atomic
    	// Set to false by default. When set to false, will not have spatialisation applied. 
    	pinnedListenerIndex:         u32,
    	// atomic
    	// The index of the listener this node should always use for spatialization. If set to MA_LISTENER_INDEX_CLOSEST the engine will use the closest listener. 
    	fadeSettings:                struct {
    		volumeBeg:                  f32,
    		// atomic
    		volumeEnd:                  f32,
    		// atomic
    		fadeLengthInFrames:         u64,
    		// atomic
    		// <-- Defaults to (~(ma_uint64)0) which is used to indicate that no fade should be applied. 
    		absoluteGlobalTimeInFrames: u64,
    	},
    	// Memory management. 
    	_ownsHeap:                   b8,
    	_pHeap:                      rawptr,
    }
     

    Base node object for both ma_sound and ma_sound_group.

    Related Procedures With Parameters

    engine_node_config ¶

    engine_node_config :: struct {
    	pEngine:                     ^engine,
    	type:                        engine_node_type,
    	channelsIn:                  u32,
    	channelsOut:                 u32,
    	sampleRate:                  u32,
    	// Only used when the type is set to ma_engine_node_type_sound. 
    	volumeSmoothTimeInPCMFrames: u32,
    	monoExpansionMode:           mono_expansion_mode,
    	isPitchDisabled:             b8,
    	// Pitching can be explicitly disable with MA_SOUND_FLAG_NO_PITCH to optimize processing. 
    	isSpatializationDisabled:    b8,
    	// Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. 
    	pinnedListenerIndex:         u8,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    engine_node_type ¶

    engine_node_type :: enum i32 {
    	sound, 
    	group, 
    }
    Related Procedures With Parameters

    engine_process_proc ¶

    engine_process_proc :: proc "c" (pUserData: rawptr, pFramesOut: [^]f32, frameCount: u64)

    enum_devices_callback_proc ¶

    enum_devices_callback_proc :: proc "c" (pContext: ^context_type, deviceType: device_type, pInfo: ^device_info, pUserData: rawptr) -> b32
     

    The callback for handling device enumeration. This is fired from ma_context_enumerate_devices().

    Parameters ---------- pContext (in)

    A pointer to the context performing the enumeration.
    
    

    deviceType (in)

    The type of the device being enumerated. This will always be either `ma_device_type_playback` or `ma_device_type_capture`.
    
    

    pInfo (in)

    A pointer to a `ma_device_info` containing the ID and name of the enumerated device. Note that this will not include detailed information about the device,
    only basic information (ID and name). The reason for this is that it would otherwise require opening the backend device to probe for the information which
    is too inefficient.
    
    

    pUserData (in)

    The user data pointer passed into `ma_context_enumerate_devices()`.
    
    Related Procedures With Parameters

    event ¶

    event :: distinct rawptr
    Related Procedures With Parameters

    fader ¶

    fader :: struct {
    	config:         fader_config,
    	volumeBeg:      f32,
    	// If volumeBeg and volumeEnd is equal to 1, no fading happens (ma_fader_process_pcm_frames() will run as a passthrough). 
    	volumeEnd:      f32,
    	lengthInFrames: u64,
    	// The total length of the fade. 
    	cursorInFrames: i64,
    }
    Related Procedures With Parameters

    fader_config ¶

    fader_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    }
     

    Fader.

    Related Procedures With Parameters
    Related Procedures With Returns

    fence ¶

    fence :: struct {
    	e:       event,
    	counter: struct {},
    }
     

    Fence ===== This locks while the counter is larger than 0. Counter can be incremented and decremented by any thread, but care needs to be taken when waiting. It is possible for one thread to acquire the fence just as another thread returns from ma_fence_wait().

    The idea behind a fence is to allow you to wait for a group of operations to complete. When an operation starts, the counter is incremented which locks the fence. When the operation completes, the fence will be released which decrements the counter. ma_fence_wait() will block until the counter hits zero.

    If threading is disabled, ma_fence_wait() will spin on the counter.

    Related Procedures With Parameters

    file_info ¶

    file_info :: struct {
    	sizeInBytes: u64,
    }
    Related Procedures With Parameters

    format ¶

    format :: enum i32 {
    	// 	I like to keep these explicitly defined because they're used as a key into a lookup table. When items are
    	// 	added to this, make sure there are no gaps and that they're added to the lookup table in ma_get_bytes_per_sample().
    	unknown = 0, // Mainly used for indicating an error, but also used as the default for the output format for decoders.
    	u8      = 1, 
    	s16     = 2, // Seems to be the most widely supported format.
    	s24     = 3, // Tightly packed. 3 bytes per sample.
    	s32     = 4, 
    	f32     = 5, 
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    gainer ¶

    gainer :: struct {
    	config:       gainer_config,
    	t:            u32,
    	masterVolume: f32,
    	pOldGains:    [^]f32,
    	pNewGains:    [^]f32,
    	// Memory management. 
    	_pHeap:       rawptr,
    	_ownsHeap:    b32,
    }
    Related Procedures With Parameters

    gainer_config ¶

    gainer_config :: struct {
    	channels:           u32,
    	smoothTimeInFrames: u32,
    }
     

    Gainer for smooth volume changes.

    Related Procedures With Parameters
    Related Procedures With Returns

    handedness ¶

    handedness :: enum i32 {
    	right, 
    	left, 
    }

    handle ¶

    handle :: distinct rawptr

    hishelf_config ¶

    hishelf_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	gainDB:     f64,
    	shelfSlope: f64,
    	frequency:  f64,
    }
     

    *********************************

    High Shelf Filter

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    hishelf_node ¶

    hishelf_node :: struct {
    	baseNode: node_base,
    	hishelf:  hishelf2,
    }
    Related Procedures With Parameters

    hishelf_node_config ¶

    hishelf_node_config :: struct {
    	nodeConfig: node_config,
    	hishelf:    hishelf_config,
    }
     

    High Shelf Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    hpf ¶

    hpf :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	hpf1Count:  u32,
    	hpf2Count:  u32,
    	pHPF1:      ^hpf1,
    	pHPF2:      ^hpf2,
    	// Memory management. 
    	_pHeap:     rawptr,
    	_ownsHeap:  b32,
    }
    Related Procedures With Parameters

    hpf1 ¶

    hpf1 :: struct {
    	format:    format,
    	channels:  u32,
    	a:         biquad_coefficient,
    	pR1:       ^biquad_coefficient,
    	// Memory management. 
    	_pHeap:    rawptr,
    	_ownsHeap: b32,
    }
    Related Procedures With Parameters

    hpf1_config ¶

    hpf1_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	q:               f64,
    }
     

    *********************************

    High-Pass Filtering

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    hpf_config ¶

    hpf_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	order:           u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    hpf_node ¶

    hpf_node :: struct {
    	baseNode: node_base,
    	hpf:      hpf,
    }
    Related Procedures With Parameters

    hpf_node_config ¶

    hpf_node_config :: struct {
    	nodeConfig: node_config,
    	hpf:        hpf_config,
    }
     

    High Pass Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    ios_session_category ¶

    ios_session_category :: enum i32 {
    	default         = 0, // AVAudioSessionCategoryPlayAndRecord.
    	none,                // Leave the session category unchanged.
    	ambient,             // AVAudioSessionCategoryAmbient
    	solo_ambient,        // AVAudioSessionCategorySoloAmbient
    	playback,            // AVAudioSessionCategoryPlayback
    	record,              // AVAudioSessionCategoryRecord
    	play_and_record,     // AVAudioSessionCategoryPlayAndRecord
    	multi_route,         // AVAudioSessionCategoryMultiRoute
    }
     

    iOS/tvOS/watchOS session categories.

    ios_session_category_option ¶

    ios_session_category_option :: enum i32 {
    	mix_with_others                            = 1,  // AVAudioSessionCategoryOptionMixWithOthers
    	duck_others                                = 2,  // AVAudioSessionCategoryOptionDuckOthers
    	allow_bluetooth                            = 4,  // AVAudioSessionCategoryOptionAllowBluetooth
    	default_to_speaker                         = 8,  // AVAudioSessionCategoryOptionDefaultToSpeaker
    	interrupt_spoken_audio_and_mix_with_others = 17, // AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers
    	allow_bluetooth_a2dp                       = 32, // AVAudioSessionCategoryOptionAllowBluetoothA2DP
    	allow_air_play                             = 64, // AVAudioSessionCategoryOptionAllowAirPlay
    }
     

    iOS/tvOS/watchOS session category options

    job ¶

    job :: struct {
    	toc:   struct #raw_union {
    		// 8 bytes. We encode the job code into the slot allocation data to save space. 
    		breakup:    struct {
    			code:     u16,
    			// Job type. 
    			slot:     u16,
    			// Index into a ma_slot_allocator. 
    			refcount: u32,
    		},
    		allocation: u64,
    	},
    	next:  u64,
    	// atomic
    	// refcount + slot for the next item. Does not include the job code. 
    	order: u32,
    	// Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. 
    	data:  struct #raw_union {
    		// Miscellaneous. 
    		custom:          struct {
    			proc_: job_proc,
    			data0: uintptr,
    			data1: uintptr,
    		},
    		// Resource Manager 
    		resourceManager: struct #raw_union {
    			loadDataBufferNode: struct {
    				pResourceManager:  rawptr,
    				pDataBufferNode:   rawptr,
    				pFilePath:         cstring,
    				pFilePathW:        [^]u16,
    				flags:             bit_set[resource_manager_data_source_flag; u32],
    				// Resource manager data source flags that were used when initializing the data buffer. 
    				pInitNotification: ^async_notification,
    				// Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. 
    				pDoneNotification: ^async_notification,
    				// Signalled when the data buffer has been fully decoded. Will be passed through to MA_JOB_TYPE_RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE when decoding. 
    				pInitFence:        ^fence,
    				// Released when initialization of the decoder is complete. 
    				pDoneFence:        ^fence,
    			},
    			freeDataBufferNode: struct {
    				pResourceManager:  rawptr,
    				pDataBufferNode:   rawptr,
    				pDoneNotification: ^async_notification,
    				pDoneFence:        ^fence,
    			},
    			pageDataBufferNode: struct {
    				pResourceManager:  rawptr,
    				pDataBufferNode:   rawptr,
    				pDecoder:          rawptr,
    				pDoneNotification: ^async_notification,
    				// Signalled when the data buffer has been fully decoded. 
    				pDoneFence:        ^fence,
    			},
    			loadDataBuffer:     struct {
    				pDataBuffer:             rawptr,
    				pInitNotification:       ^async_notification,
    				// Signalled when the data buffer has been initialized and the format/channels/rate can be retrieved. 
    				pDoneNotification:       ^async_notification,
    				// Signalled when the data buffer has been fully decoded. 
    				pInitFence:              ^fence,
    				// Released when the data buffer has been initialized and the format/channels/rate can be retrieved. 
    				pDoneFence:              ^fence,
    				// Released when the data buffer has been fully decoded. 
    				rangeBegInPCMFrames:     u64,
    				rangeEndInPCMFrames:     u64,
    				loopPointBegInPCMFrames: u64,
    				loopPointEndInPCMFrames: u64,
    				isLooping:               u32,
    			},
    			freeDataBuffer:     struct {
    				pDataBuffer:       rawptr,
    				pDoneNotification: ^async_notification,
    				pDoneFence:        ^fence,
    			},
    			loadDataStream:     struct {
    				pDataStream:       rawptr,
    				pFilePath:         cstring,
    				// Allocated when the job is posted, freed by the job thread after loading. 
    				pFilePathW:        [^]u16,
    				// ^ As above ^. Only used if pFilePath is NULL. 
    				initialSeekPoint:  u64,
    				pInitNotification: ^async_notification,
    				// Signalled after the first two pages have been decoded and frames can be read from the stream. 
    				pInitFence:        ^fence,
    			},
    			freeDataStream:     struct {
    				pDataStream:       rawptr,
    				pDoneNotification: ^async_notification,
    				pDoneFence:        ^fence,
    			},
    			pageDataStream:     struct {
    				pDataStream: rawptr,
    				pageIndex:   u32,
    			},
    			seekDataStream:     struct {
    				pDataStream: rawptr,
    				frameIndex:  u64,
    			},
    		},
    		// Device. 
    		device:          struct {
    			aaudio: struct {
    				reroute: struct {
    					pDevice:    rawptr,
    					deviceType: u32,
    				},
    			},
    		},
    	},
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    job_proc ¶

    job_proc :: proc "c" (pJob: ^job)
     

    Callback for processing a job. Each job type will have their own processing callback which will be called by ma_job_process().

    job_queue ¶

    job_queue :: struct {
    	flags:     bit_set[job_queue_flag; u32],
    	// Flags passed in at initialization time. 
    	capacity:  u32,
    	// The maximum number of jobs that can fit in the queue at a time. Set by the config. 
    	head:      u64,
    	// atomic
    	// The first item in the list. Required for removing from the top of the list. 
    	tail:      u64,
    	// atomic
    	// The last item in the list. Required for appending to the end of the list. 
    	sem:       semaphore,
    	// Only used when MA_JOB_QUEUE_FLAG_NON_BLOCKING is unset. 
    	allocator: slot_allocator,
    	pJobs:     [^]job,
    	lock:      spinlock,
    	// Memory management. 
    	_pHeap:    rawptr,
    	_ownsHeap: b32,
    }
    Related Procedures With Parameters

    job_queue_config ¶

    job_queue_config :: struct {
    	flags:    bit_set[job_queue_flag; u32],
    	capacity: u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    job_queue_flag ¶

    job_queue_flag :: enum i32 {
    	NON_BLOCKING = 0, 
    }
     

    When set, ma_job_queue_next() will not wait and no semaphore will be signaled in ma_job_queue_post(). ma_job_queue_next() will return MA_NO_DATA_AVAILABLE if nothing is available.

    This flag should always be used for platforms that do not support multithreading.

    Related Constants

    job_queue_flags ¶

    job_queue_flags :: bit_set[job_queue_flag; u32]
    Related Procedures With Parameters

    job_type ¶

    job_type :: enum i32 {
    	// Miscellaneous. 
    	QUIT                                   = 0, 
    	CUSTOM, 
    	// Resource Manager. 
    	RESOURCE_MANAGER_LOAD_DATA_BUFFER_NODE, 
    	RESOURCE_MANAGER_FREE_DATA_BUFFER_NODE, 
    	RESOURCE_MANAGER_PAGE_DATA_BUFFER_NODE, 
    	RESOURCE_MANAGER_LOAD_DATA_BUFFER, 
    	RESOURCE_MANAGER_FREE_DATA_BUFFER, 
    	RESOURCE_MANAGER_LOAD_DATA_STREAM, 
    	RESOURCE_MANAGER_FREE_DATA_STREAM, 
    	RESOURCE_MANAGER_PAGE_DATA_STREAM, 
    	RESOURCE_MANAGER_SEEK_DATA_STREAM, 
    	// Device. 
    	DEVICE_AAUDIO_REROUTE, 
    	// Count. Must always be last. 
    	COUNT, 
    }
     

    When a job type is added here an callback needs to be added go "g_jobVTable" in the implementation section.

    lcg ¶

    lcg :: struct {
    	state: i32,
    }

    linear_resampler ¶

    linear_resampler :: struct {
    	config:        linear_resampler_config,
    	inAdvanceInt:  u32,
    	inAdvanceFrac: u32,
    	inTimeInt:     u32,
    	inTimeFrac:    u32,
    	x0:            struct #raw_union {
    		f32: [^]f32,
    		s16: [^]i16,
    	},
    	// The previous input frame. 
    	x1:            struct #raw_union {
    		f32: [^]f32,
    		s16: [^]i16,
    	},
    	// The next input frame. 
    	lpf:           lpf,
    	// Memory management. 
    	_pHeap:        rawptr,
    	_ownsHeap:     b32,
    }
    Related Procedures With Parameters

    linear_resampler_config ¶

    linear_resampler_config :: struct {
    	format:           format,
    	channels:         u32,
    	sampleRateIn:     u32,
    	sampleRateOut:    u32,
    	lpfOrder:         u32,
    	// The low-pass filter order. Setting this to 0 will disable low-pass filtering. 
    	lpfNyquistFactor: f64,
    }
     

    *********************************

    Resampling

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    log ¶

    log :: struct {
    	callbacks:           [4]log_callback,
    	callbackCount:       u32,
    	allocationCallbacks: allocation_callbacks,
    	// Need to store these persistently because log_postv() might need to allocate a buffer on the heap. 
    	lock:                mutex,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    log_callback ¶

    log_callback :: struct {
    	onLog:     log_callback_proc,
    	pUserData: rawptr,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    log_callback_proc ¶

    log_callback_proc :: proc "c" (pUserData: rawptr, level: u32, pMessage: cstring)
     

    The callback for handling log messages.

    Parameters ---------- pUserData (in) The user data pointer that was passed into ma_log_register_callback().

    logLevel (in) The log level. This can be one of the following:

    +----------------------+ | Log Level | +----------------------+ | MA_LOG_LEVEL_DEBUG | | MA_LOG_LEVEL_INFO | | MA_LOG_LEVEL_WARNING | | MA_LOG_LEVEL_ERROR | +----------------------+

    pMessage (in) The log message.

    Related Procedures With Parameters

    log_level ¶

    log_level :: enum i32 {
    	LOG_LEVEL_DEBUG   = 4, 
    	LOG_LEVEL_INFO    = 3, 
    	LOG_LEVEL_WARNING = 2, 
    	LOG_LEVEL_ERROR   = 1, 
    }

    loshelf_config ¶

    loshelf_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	gainDB:     f64,
    	shelfSlope: f64,
    	frequency:  f64,
    }
     

    *********************************

    Low Shelf Filter

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    loshelf_node ¶

    loshelf_node :: struct {
    	baseNode: node_base,
    	loshelf:  loshelf2,
    }
    Related Procedures With Parameters

    loshelf_node_config ¶

    loshelf_node_config :: struct {
    	nodeConfig: node_config,
    	loshelf:    loshelf_config,
    }
     

    Low Shelf Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    lpf ¶

    lpf :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	lpf1Count:  u32,
    	lpf2Count:  u32,
    	pLPF1:      ^lpf1,
    	pLPF2:      ^lpf2,
    	// Memory management. 
    	_pHeap:     rawptr,
    	_ownsHeap:  b32,
    }
    Related Procedures With Parameters

    lpf1 ¶

    lpf1 :: struct {
    	format:    format,
    	channels:  u32,
    	a:         biquad_coefficient,
    	pR1:       ^biquad_coefficient,
    	// Memory management. 
    	_pHeap:    rawptr,
    	_ownsHeap: b32,
    }
    Related Procedures With Parameters

    lpf1_config ¶

    lpf1_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	q:               f64,
    }
     

    *********************************

    Low-Pass Filtering

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    lpf_config ¶

    lpf_config :: struct {
    	format:          format,
    	channels:        u32,
    	sampleRate:      u32,
    	cutoffFrequency: f64,
    	order:           u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    lpf_node ¶

    lpf_node :: struct {
    	baseNode: node_base,
    	lpf:      lpf,
    }
    Related Procedures With Parameters

    lpf_node_config ¶

    lpf_node_config :: struct {
    	nodeConfig: node_config,
    	lpf:        lpf_config,
    }
     

    Low Pass Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    ma_read_proc ¶

    ma_read_proc :: proc "c" (pUserData: rawptr, pBufferOut: rawptr, bytesToRead: uint, pBytesRead: ^uint) -> result

    ma_seek_proc ¶

    ma_seek_proc :: proc "c" (pUserData: rawptr, offset: i64, origin: seek_origin) -> result

    ma_tell_proc ¶

    ma_tell_proc :: proc "c" (pUserData: rawptr, pCursor: ^i64) -> result

    mono_expansion_mode ¶

    mono_expansion_mode :: enum i32 {
    	duplicate   = 0, // The default.
    	average,         // Average the mono channel across all channels.
    	stereo_only,     // Duplicate to the left and right channels only and ignore the others.
    	default     = 0, 
    }

    mutex ¶

    mutex :: distinct rawptr
    Related Procedures With Parameters

    node_base ¶

    node_base :: struct {
    	// These variables are set once at startup. 
    	pNodeGraph:                  ^node_graph,
    	// The graph this node belongs to. 
    	vtable:                      ^node_vtable,
    	inputBusCount:               u32,
    	outputBusCount:              u32,
    	pInputBuses:                 [^]node_input_bus `fmt:"v,inputBusCount"`,
    	pOutputBuses:                [^]node_output_bus `fmt:"v,outputBusCount"`,
    	pCachedData:                 [^]f32,
    	// Allocated on the heap. Fixed size. Needs to be stored on the heap because reading from output buses is done in separate function calls. 
    	cachedDataCapInFramesPerBus: u16,
    	// These variables are read and written only from the audio thread. 
    	cachedFrameCountOut:         u16,
    	cachedFrameCountIn:          u16,
    	consumedFrameCountIn:        u16,
    	// These variables are read and written between different threads. 
    	state:                       node_state,
    	// atomic
    	// When set to stopped, nothing will be read, regardless of the times in stateTimes. 
    	stateTimes:                  [2]u64,
    	// atomic
    	// Indexed by ma_node_state. Specifies the time based on the global clock that a node should be considered to be in the relevant state. 
    	localTime:                   u64,
    	// Memory management. 
    	_inputBuses:                 [2]node_input_bus,
    	_outputBuses:                [2]node_output_bus,
    	_pHeap:                      rawptr,
    	// A heap allocation for internal use only. pInputBuses and/or pOutputBuses will point to this if the bus count exceeds MA_MAX_NODE_LOCAL_BUS_COUNT. 
    	_ownsHeap:                   b32,
    }

    node_config ¶

    node_config :: struct {
    	vtable:          ^node_vtable,
    	// Should never be null. Initialization of the node will fail if so. 
    	initialState:    node_state,
    	// Defaults to ma_node_state_started. 
    	inputBusCount:   u32,
    	// Only used if the vtable specifies an input bus count of `MA_NODE_BUS_COUNT_UNKNOWN`, otherwise must be set to `MA_NODE_BUS_COUNT_UNKNOWN` (default). 
    	outputBusCount:  u32,
    	// Only used if the vtable specifies an output bus count of `MA_NODE_BUS_COUNT_UNKNOWN`, otherwise  be set to `MA_NODE_BUS_COUNT_UNKNOWN` (default). 
    	pInputChannels:  ^u32,
    	// The number of elements are determined by the input bus count as determined by the vtable, or `inputBusCount` if the vtable specifies `MA_NODE_BUS_COUNT_UNKNOWN`. 
    	pOutputChannels: ^u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    node_flag ¶

    node_flag :: enum i32 {
    	PASSTHROUGH                = 0, 
    	CONTINUOUS_PROCESSING      = 1, 
    	ALLOW_NULL_INPUT           = 2, 
    	DIFFERENT_PROCESSING_RATES = 3, 
    	SILENT_OUTPUT              = 4, 
    }
     

    Node flags.

    node_flags ¶

    node_flags :: bit_set[node_flag; u32]

    node_graph ¶

    node_graph :: struct {
    	// Immutable. 
    	base:                           node_base,
    	// The node graph itself is a node so it can be connected as an input to different node graph. This has zero inputs and calls ma_node_graph_read_pcm_frames() to generate it's output. 
    	endpoint:                       node_base,
    	// Special node that all nodes eventually connect to. Data is read from this node in ma_node_graph_read_pcm_frames(). 
    	pProcessingCache:               [^]f32,
    	// This will be allocated when processingSizeInFrames is non-zero. This is needed because ma_node_graph_read_pcm_frames() can be called with a variable number of frames, and we may need to do some buffering in situations where the caller requests a frame count that's not a multiple of processingSizeInFrames. 
    	processingCacheFramesRemaining: u32,
    	processingSizeInFrames:         u32,
    	// Read and written by multiple threads. 
    	isReading:                      b32,
    	// Modified only by the audio thread. 
    	pPreMixStack:                   ^stack,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    node_graph_config ¶

    node_graph_config :: struct {
    	channels:               u32,
    	processingSizeInFrames: u32,
    	// This is the preferred processing size for node processing callbacks unless overridden by a node itself. Can be 0 in which case it will be based on the frame count passed into ma_node_graph_read_pcm_frames(), but will not be well defined. 
    	preMixStackSizeInBytes: uint,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    node_input_bus ¶

    node_input_bus :: struct {
    	// Mutable via multiple threads. 
    	head:        node_output_bus,
    	// Dummy head node for simplifying some lock-free thread-safety stuff. 
    	nextCounter: u32,
    	// atomic
    	// This is used to determine whether or not the input bus is finding the next node in the list. Used for thread safety when detaching output buses. 
    	lock:        spinlock,
    	// Set once at startup. 
    	channels:    u8,
    }
     

    A node has multiple input buses. The output buses of a node are connecting to the input busses of another. An input bus is essentially just a linked list of output buses.

    node_output_bus ¶

    node_output_bus :: struct {
    	// Immutable. 
    	pNode:                  ^node,
    	// The node that owns this output bus. The input node. Will be null for dummy head and tail nodes. 
    	outputBusIndex:         u8,
    	// The index of the output bus on pNode that this output bus represents. 
    	channels:               u8,
    	// Mutable via multiple threads. Must be used atomically. The weird ordering here is for packing reasons. 
    	inputNodeInputBusIndex: u8,
    	// The index of the input bus on the input. Required for detaching. Will only be used in the spinlock so does not need to be atomic. 
    	flags:                  bit_set[node_output_bus_flag; u32],
    	// atomic
    	// Some state flags for tracking the read state of the output buffer. A combination of MA_NODE_OUTPUT_BUS_FLAG_*. 
    	refCount:               u32,
    	// atomic
    	// Reference count for some thread-safety when detaching. 
    	isAttached:             b32,
    	// atomic
    	// This is used to prevent iteration of nodes that are in the middle of being detached. Used for thread safety. 
    	lock:                   spinlock,
    	// atomic
    	// Unfortunate lock, but significantly simplifies the implementation. Required for thread-safe attaching and detaching. 
    	volume:                 f32,
    	// atomic
    	// Linear. 
    	pNext:                  ^node_output_bus,
    	// atomic
    	// If null, it's the tail node or detached. 
    	pPrev:                  ^node_output_bus,
    	// atomic
    	// If null, it's the head node or detached. 
    	pInputNode:             ^node,
    }
     

    A node has multiple output buses. An output bus is attached to an input bus as an item in a linked list. Think of the input bus as a linked list, with the output bus being an item in that list.

    node_output_bus_flag ¶

    node_output_bus_flag :: enum i32 {
    	HAS_READ = 0, // 0x01
    }

    node_output_bus_flags ¶

    node_output_bus_flags :: bit_set[node_output_bus_flag; u32]

    node_state ¶

    node_state :: enum i32 {
    	started = 0, 
    	stopped = 1, 
    }
     

    The playback state of a node. Either started or stopped.

    Related Procedures With Parameters
    Related Procedures With Returns

    node_vtable ¶

    node_vtable :: struct {
    	// 	Extended processing callback. This callback is used for effects that process input and output
    	// 	at different rates (i.e. they perform resampling). This is similar to the simple version, only
    	// 	they take two separate frame counts: one for input, and one for output.
    	// 
    	// 	On input, `pFrameCountOut` is equal to the capacity of the output buffer for each bus, whereas
    	// 	`pFrameCountIn` will be equal to the number of PCM frames in each of the buffers in `ppFramesIn`.
    	// 
    	// 	On output, set `pFrameCountOut` to the number of PCM frames that were actually output and set
    	// 	`pFrameCountIn` to the number of input frames that were consumed.
    	onProcess:                    proc "c" (pNode: ^node, ppFramesIn: ^[^]f32, pFrameCountIn: ^u32, ppFramesOut: ^[^]f32, pFrameCountOut: ^u32),
    	// 	A callback for retrieving the number of input frames that are required to output the
    	// 	specified number of output frames. You would only want to implement this when the node performs
    	// 	resampling. This is optional, even for nodes that perform resampling, but it does offer a
    	// 	small reduction in latency as it allows miniaudio to calculate the exact number of input frames
    	// 	to read at a time instead of having to estimate.
    	onGetRequiredInputFrameCount: proc "c" (pNode: ^node, outputFrameCount: u32, pInputFrameCount: ^u32) -> result,
    	// 	The number of input buses. This is how many sub-buffers will be contained in the `ppFramesIn`
    	// 	parameters of the callbacks above.
    	inputBusCount:                u8,
    	// 	The number of output buses. This is how many sub-buffers will be contained in the `ppFramesOut`
    	// 	parameters of the callbacks above.
    	outputBusCount:               u8,
    	// 	Flags describing characteristics of the node. This is currently just a placeholder for some
    	// 	ideas for later on.
    	flags:                        bit_set[node_flag; u32],
    }

    noise ¶

    noise :: struct {
    	ds:        data_source_base,
    	config:    noise_config,
    	lcg:       lcg,
    	state:     struct #raw_union {
    		pink:     struct {
    			bin:          ^[^]f64,
    			accumulation: [^]f64,
    			counter:      [^]u32,
    		},
    		brownian: struct {
    			accumulation: [^]f64,
    		},
    	},
    	// Memory management. 
    	_pHeap:    rawptr,
    	_ownsHeap: b32,
    }
    Related Procedures With Parameters

    noise_config ¶

    noise_config :: struct {
    	format:            format,
    	channels:          u32,
    	type:              noise_type,
    	seed:              i32,
    	amplitude:         f64,
    	duplicateChannels: b32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    noise_type ¶

    noise_type :: enum i32 {
    	white, 
    	pink, 
    	brownian, 
    }
    Related Procedures With Parameters

    notch2_config ¶

    notch2_config :: notch_config
    Related Procedures With Parameters
    Related Procedures With Returns

    notch_config ¶

    notch_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	q:          f64,
    	frequency:  f64,
    }
     

    *********************************

    Notching Filter

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    notch_node ¶

    notch_node :: struct {
    	baseNode: node_base,
    	notch:    notch2,
    }
    Related Procedures With Parameters

    notch_node_config ¶

    notch_node_config :: struct {
    	nodeConfig: node_config,
    	notch:      notch_config,
    }
     

    Notching Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    open_mode_flag ¶

    open_mode_flag :: enum i32 {
    	READ  = 0, 
    	WRITE = 1, 
    }

    open_mode_flags ¶

    open_mode_flags :: bit_set[open_mode_flag; u32]
    Related Procedures With Parameters

    opensl_recording_preset ¶

    opensl_recording_preset :: enum i32 {
    	default             = 0, // Leaves the input preset unset.
    	generic,                 // SL_ANDROID_RECORDING_PRESET_GENERIC
    	camcorder,               // SL_ANDROID_RECORDING_PRESET_CAMCORDER
    	voice_recognition,       // SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION
    	voice_communication,     // SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION
    	voice_unprocessed,       // SL_ANDROID_RECORDING_PRESET_UNPROCESSED
    }
     

    OpenSL recording presets.

    opensl_stream_type ¶

    opensl_stream_type :: enum i32 {
    	default      = 0, // Leaves the stream type unset.
    	voice,            // SL_ANDROID_STREAM_VOICE
    	system,           // SL_ANDROID_STREAM_SYSTEM
    	ring,             // SL_ANDROID_STREAM_RING
    	media,            // SL_ANDROID_STREAM_MEDIA
    	alarm,            // SL_ANDROID_STREAM_ALARM
    	notification,     // SL_ANDROID_STREAM_NOTIFICATION
    }
     

    OpenSL stream types.

    paged_audio_buffer ¶

    paged_audio_buffer :: struct {
    	ds:             data_source_base,
    	pData:          ^paged_audio_buffer_data,
    	// Audio data is read from here. Cannot be null. 
    	pCurrent:       ^paged_audio_buffer_page,
    	relativeCursor: u64,
    	// Relative to the current page. 
    	absoluteCursor: u64,
    }
    Related Procedures With Parameters

    paged_audio_buffer_config ¶

    paged_audio_buffer_config :: struct {
    	pData: ^paged_audio_buffer_data,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    paged_audio_buffer_page ¶

    paged_audio_buffer_page :: struct {
    	pNext:        ^paged_audio_buffer_page,
    	// atomic
    	sizeInFrames: u64,
    	pAudioData:   [1]u8,
    }
     

    Paged Audio Buffer ================== A paged audio buffer is made up of a linked list of pages. It's expandable, but not shrinkable. It can be used for cases where audio data is streamed in asynchronously while allowing data to be read at the same time.

    This is lock-free, but not 100% thread safe. You can append a page and read from the buffer across simultaneously across different threads, however only one thread at a time can append, and only one thread at a time can read and seek.

    Related Procedures With Parameters
    Related Procedures With Returns

    pan_mode ¶

    pan_mode :: enum i32 {
    	balance = 0, // Does not blend one side with the other. Technically just a balance. Compatible with other popular audio engines and therefore the default.
    	pan,         // A true pan. The sound from one side will "move" to the other side and blend with it.
    }
     

    Stereo panner.

    Related Procedures With Parameters
    Related Procedures With Returns

    panner ¶

    panner :: struct {
    	format:   format,
    	channels: u32,
    	mode:     pan_mode,
    	pan:      f32,
    }
    Related Procedures With Parameters

    panner_config ¶

    panner_config :: struct {
    	format:   format,
    	channels: u32,
    	mode:     pan_mode,
    	pan:      f32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    peak2_config ¶

    peak2_config :: peak_config
    Related Procedures With Parameters
    Related Procedures With Returns

    peak_config ¶

    peak_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	gainDB:     f64,
    	q:          f64,
    	frequency:  f64,
    }
     

    *********************************

    Peaking EQ Filter

    *********************************

    Related Procedures With Parameters
    Related Procedures With Returns

    peak_node ¶

    peak_node :: struct {
    	baseNode: node_base,
    	peak:     peak2,
    }
    Related Procedures With Parameters

    peak_node_config ¶

    peak_node_config :: struct {
    	nodeConfig: node_config,
    	peak:       peak_config,
    }
     

    Peaking Filter Node

    Related Procedures With Parameters
    Related Procedures With Returns

    performance_profile ¶

    performance_profile :: enum i32 {
    	low_latency  = 0, 
    	conservative, 
    }
    Related Procedures With Parameters

    positioning ¶

    positioning :: enum i32 {
    	absolute, 
    	relative, 
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    pulsewave_config ¶

    pulsewave_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	dutyCycle:  f64,
    	amplitude:  f64,
    	frequency:  f64,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    rb ¶

    rb :: struct {
    	pBuffer:                rawptr,
    	subbufferSizeInBytes:   u32,
    	subbufferCount:         u32,
    	subbufferStrideInBytes: u32,
    	encodedReadOffset:      u32,
    	// atomic
    	// Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. 
    	encodedWriteOffset:     u32,
    	// atomic
    	// Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. 
    	ownsBuffer:             b8,
    	// Used to know whether or not miniaudio is responsible for free()-ing the buffer. 
    	clearOnWriteAcquire:    b8,
    	// When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). 
    	allocationCallbacks:    allocation_callbacks,
    }
     

    *******************************

    Ring Buffer

    *******************************

    Related Procedures With Parameters

    resample_algorithm ¶

    resample_algorithm :: enum i32 {
    	linear = 0, // Fastest, lowest quality. Optional low-pass filtering. Default.
    	custom, 
    }
    Related Procedures With Parameters

    resampler_config ¶

    resampler_config :: struct {
    	format:           format,
    	// Must be either ma_format_f32 or ma_format_s16. 
    	channels:         u32,
    	sampleRateIn:     u32,
    	sampleRateOut:    u32,
    	algorithm:        resample_algorithm,
    	// When set to ma_resample_algorithm_custom, pBackendVTable will be used. 
    	pBackendVTable:   ^resampling_backend_vtable,
    	pBackendUserData: rawptr,
    	linear:           struct {
    		lpfOrder: u32,
    	},
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    resampling_backend ¶

    resampling_backend :: struct {}

    resampling_backend_vtable ¶

    resampling_backend_vtable :: struct {
    	onGetHeapSize:                 proc "c" (pUserData: rawptr, pConfig: ^resampler_config, pHeapSizeInBytes: ^uint) -> result,
    	onInit:                        proc "c" (pUserData: rawptr, pConfig: ^resampler_config, pHeap: rawptr, ppBackend: ^^resampling_backend) -> result,
    	onUninit:                      proc "c" (pUserData: rawptr, pBackend: ^resampling_backend, pAllocationCallbacks: ^allocation_callbacks),
    	onProcess:                     proc "c" (pUserData: rawptr, pBackend: ^resampling_backend, pFramesIn: rawptr, pFrameCountIn: ^u64, pFramesOut: rawptr, pFrameCountOut: ^u64) -> result,
    	onSetRate:                     proc "c" (pUserData: rawptr, pBackend: ^resampling_backend, sampleRateIn: u32, sampleRateOut: u32) -> result,
    	// Optional. Rate changes will be disabled. 
    	onGetInputLatency:             proc "c" (pUserData: rawptr, pBackend: ^resampling_backend) -> u64,
    	// Optional. Latency will be reported as 0. 
    	onGetOutputLatency:            proc "c" (pUserData: rawptr, pBackend: ^resampling_backend) -> u64,
    	// Optional. Latency will be reported as 0. 
    	onGetRequiredInputFrameCount:  proc "c" (pUserData: rawptr, pBackend: ^resampling_backend, outputFrameCount: u64, pInputFrameCount: ^u64) -> result,
    	// Optional. Latency mitigation will be disabled. 
    	onGetExpectedOutputFrameCount: proc "c" (pUserData: rawptr, pBackend: ^resampling_backend, inputFrameCount: u64, pOutputFrameCount: ^u64) -> result,
    	// Optional. Latency mitigation will be disabled. 
    	onReset:                       proc "c" (pUserData: rawptr, pBackend: ^resampling_backend) -> result,
    }

    resource_manager ¶

    resource_manager :: struct {
    	config:              resource_manager_config,
    	pRootDataBufferNode: ^resource_manager_data_buffer_node,
    	// The root buffer in the binary tree. 
    	dataBufferBSTLock:   mutex,
    	// For synchronizing access to the data buffer binary tree. 
    	jobThreads:          [64]thread,
    	// The threads for executing jobs. 
    	jobQueue:            job_queue,
    	// Multi-consumer, multi-producer job queue for managing jobs for asynchronous decoding and streaming. 
    	defaultVFS:          default_vfs,
    	// Only used if a custom VFS is not specified. 
    	log:                 log,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    resource_manager_config ¶

    resource_manager_config :: struct {
    	allocationCallbacks:            allocation_callbacks,
    	pLog:                           ^log,
    	decodedFormat:                  format,
    	// The decoded format to use. Set to ma_format_unknown (default) to use the file's native format. 
    	decodedChannels:                u32,
    	// The decoded channel count to use. Set to 0 (default) to use the file's native channel count. 
    	decodedSampleRate:              u32,
    	// the decoded sample rate to use. Set to 0 (default) to use the file's native sample rate. 
    	jobThreadCount:                 u32,
    	// Set to 0 if you want to self-manage your job threads. Defaults to 1. 
    	jobThreadStackSize:             uint,
    	jobQueueCapacity:               u32,
    	// The maximum number of jobs that can fit in the queue at a time. Defaults to MA_JOB_TYPE_RESOURCE_MANAGER_QUEUE_CAPACITY. Cannot be zero. 
    	flags:                          u32,
    	pVFS:                           ^vfs,
    	// Can be NULL in which case defaults will be used. 
    	ppCustomDecodingBackendVTables: ^[^]decoding_backend_vtable,
    	customDecodingBackendCount:     u32,
    	pCustomDecodingBackendUserData: rawptr,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    resource_manager_data_buffer ¶

    resource_manager_data_buffer :: struct {
    	ds:                     data_source_base,
    	// Base data source. A data buffer is a data source. 
    	pResourceManager:       ^resource_manager,
    	// A pointer to the resource manager that owns this buffer. 
    	pNode:                  ^resource_manager_data_buffer_node,
    	// The data node. This is reference counted and is what supplies the data. 
    	flags:                  bit_set[resource_manager_flag; u32],
    	// The flags that were passed used to initialize the buffer. 
    	executionCounter:       u32,
    	// atomic
    	// For allocating execution orders for jobs. 
    	executionPointer:       u32,
    	// atomic
    	// For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. 
    	seekTargetInPCMFrames:  u64,
    	// Only updated by the public API. Never written nor read from the job thread. 
    	seekToCursorOnNextRead: b32,
    	// On the next read we need to seek to the frame cursor. 
    	result:                 result,
    	// atomic
    	// Keeps track of a result of decoding. Set to MA_BUSY while the buffer is still loading. Set to MA_SUCCESS when loading is finished successfully. Otherwise set to some other code. 
    	isLooping:              b32,
    	// atomic
    	// Can be read and written by different threads at the same time. Must be used atomically. 
    	isConnectorInitialized: b32,
    	// Used for asynchronous loading to ensure we don't try to initialize the connector multiple times while waiting for the node to fully load. 
    	connector:              struct #raw_union {
    		decoder:     decoder,
    		// Supply type is ma_resource_manager_data_supply_type_encoded 
    		buffer:      audio_buffer,
    		// Supply type is ma_resource_manager_data_supply_type_decoded 
    		pagedBuffer: paged_audio_buffer,
    	},
    }
    Related Procedures With Parameters

    resource_manager_data_buffer_node ¶

    resource_manager_data_buffer_node :: struct {
    	hashedName32:                 u32,
    	// The hashed name. This is the key. 
    	refCount:                     u32,
    	result:                       result,
    	// atomic
    	// Result from asynchronous loading. When loading set to MA_BUSY. When fully loaded set to MA_SUCCESS. When deleting set to MA_UNAVAILABLE. 
    	executionCounter:             u32,
    	// atomic
    	// For allocating execution orders for jobs. 
    	executionPointer:             u32,
    	// atomic
    	// For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. 
    	isDataOwnedByResourceManager: b32,
    	// Set to true when the underlying data buffer was allocated the resource manager. Set to false if it is owned by the application (via ma_resource_manager_register_*()). 
    	data:                         resource_manager_data_supply,
    	pParent:                      ^resource_manager_data_buffer_node,
    	pChildLo:                     ^resource_manager_data_buffer_node,
    	pChildHi:                     ^resource_manager_data_buffer_node,
    }

    resource_manager_data_source_config ¶

    resource_manager_data_source_config :: struct {
    	pFilePath:                   cstring,
    	pFilePathW:                  [^]u16,
    	pNotifications:              ^resource_manager_pipeline_notifications,
    	initialSeekPointInPCMFrames: u64,
    	rangeBegInPCMFrames:         u64,
    	rangeEndInPCMFrames:         u64,
    	loopPointBegInPCMFrames:     u64,
    	loopPointEndInPCMFrames:     u64,
    	flags:                       u32,
    	isLooping:                   b32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    resource_manager_data_source_flag ¶

    resource_manager_data_source_flag :: enum i32 {
    	STREAM         = 0, // When set, does not load the entire data source in memory. Disk I/O will happen on job threads.
    	DECODE         = 1, // Decode data before storing in memory. When set, decoding is done at the resource manager level rather than the mixing thread. Results in faster mixing, but higher memory usage.
    	ASYNC          = 2, // When set, the resource manager will load the data source asynchronously.
    	WAIT_INIT      = 3, // When set, waits for initialization of the underlying data source before returning from ma_resource_manager_data_source_init().
    	UNKNOWN_LENGTH = 4, // Gives the resource manager a hint that the length of the data source is unknown and calling `ma_data_source_get_length_in_pcm_frames()` should be avoided.
    	LOOPING        = 5, // When set, configures the data source to loop by default.
    }

    resource_manager_data_stream ¶

    resource_manager_data_stream :: struct {
    	ds:                     data_source_base,
    	// Base data source. A data stream is a data source. 
    	pResourceManager:       ^resource_manager,
    	// A pointer to the resource manager that owns this data stream. 
    	flags:                  u32,
    	// The flags that were passed used to initialize the stream. 
    	decoder:                decoder,
    	// Used for filling pages with data. This is only ever accessed by the job thread. The public API should never touch this. 
    	isDecoderInitialized:   b32,
    	// Required for determining whether or not the decoder should be uninitialized in MA_JOB_TYPE_RESOURCE_MANAGER_FREE_DATA_STREAM. 
    	totalLengthInPCMFrames: u64,
    	// This is calculated when first loaded by the MA_JOB_TYPE_RESOURCE_MANAGER_LOAD_DATA_STREAM. 
    	relativeCursor:         u32,
    	// The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. 
    	absoluteCursor:         u64,
    	// atomic
    	// The playback cursor, in absolute position starting from the start of the file. 
    	currentPageIndex:       u32,
    	// Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. 
    	executionCounter:       u32,
    	// atomic
    	// For allocating execution orders for jobs. 
    	executionPointer:       u32,
    	// Written by the public API, read by the job thread. 
    	isLooping:              b32,
    	// Written by the job thread, read by the public API. 
    	pPageData:              rawptr,
    	// Buffer containing the decoded data of each page. Allocated once at initialization time. 
    	pageFrameCount:         [2]u32,
    	// Written and read by both the public API and the job thread. These must be atomic. 
    	result:                 result,
    	// atomic
    	// Result from asynchronous loading. When loading set to MA_BUSY. When initialized set to MA_SUCCESS. When deleting set to MA_UNAVAILABLE. If an error occurs when loading, set to an error code. 
    	isDecoderAtEnd:         b32,
    	// atomic
    	// Whether or not the decoder has reached the end. 
    	isPageValid:            [2]b32,
    	// atomic
    	// Booleans to indicate whether or not a page is valid. Set to false by the public API, set to true by the job thread. Set to false as the pages are consumed, true when they are filled. 
    	seekCounter:            b32,
    }
    Related Procedures With Parameters

    resource_manager_data_supply ¶

    resource_manager_data_supply :: struct {
    	type:    resource_manager_data_supply_type,
    	// atomic
    	// Read and written from different threads so needs to be accessed atomically. 
    	backend: struct #raw_union {
    		encoded:      struct {
    			pData:       rawptr,
    			sizeInBytes: uint,
    		},
    		decoded:      struct {
    			pData:             rawptr,
    			totalFrameCount:   u64,
    			decodedFrameCount: u64,
    			format:            format,
    			channels:          u32,
    			sampleRate:        u32,
    		},
    		decodedPaged: struct {
    			data:              paged_audio_buffer_data,
    			decodedFrameCount: u64,
    			sampleRate:        u32,
    		},
    	},
    }

    resource_manager_data_supply_type ¶

    resource_manager_data_supply_type :: enum i32 {
    	unknown       = 0, // Used for determining whether or the data supply has been initialized.
    	encoded,           // Data supply is an encoded buffer. Connector is ma_decoder.
    	decoded,           // Data supply is a decoded buffer. Connector is ma_audio_buffer.
    	decoded_paged,     // Data supply is a linked list of decoded buffers. Connector is ma_paged_audio_buffer.
    }

    resource_manager_flag ¶

    resource_manager_flag :: enum i32 {
    	// Indicates ma_resource_manager_next_job() should not block. Only valid when the job thread count is 0. 
    	NON_BLOCKING = 0, 
    	// Disables any kind of multithreading. Implicitly enables MA_RESOURCE_MANAGER_FLAG_NON_BLOCKING. 
    	NO_THREADING = 1, 
    }

    resource_manager_flags ¶

    resource_manager_flags :: bit_set[resource_manager_flag; u32]

    resource_manager_job ¶

    resource_manager_job :: job
     

    BEGIN BACKWARDS COMPATIBILITY TODO: Remove this block in version 0.12.

    Related Procedures With Parameters
    Related Procedures With Returns

    resource_manager_job_queue_config ¶

    resource_manager_job_queue_config :: job_queue_config
    Related Procedures With Parameters
    Related Procedures With Returns

    resource_manager_pipeline_stage_notification ¶

    resource_manager_pipeline_stage_notification :: struct {
    	pNotification: ^async_notification,
    	pFence:        ^fence,
    }
     

    Pipeline notifications used by the resource manager. Made up of both an async notification and a fence, both of which are optional.

    result ¶

    result :: enum i32 {
    	SUCCESS                        = 0, 
    	ERROR                          = -1,   // A generic error.
    	INVALID_ARGS                   = -2, 
    	INVALID_OPERATION              = -3, 
    	OUT_OF_MEMORY                  = -4, 
    	OUT_OF_RANGE                   = -5, 
    	ACCESS_DENIED                  = -6, 
    	DOES_NOT_EXIST                 = -7, 
    	ALREADY_EXISTS                 = -8, 
    	TOO_MANY_OPEN_FILES            = -9, 
    	INVALID_FILE                   = -01, 
    	TOO_BIG                        = -11, 
    	PATH_TOO_LONG                  = -21, 
    	NAME_TOO_LONG                  = -31, 
    	NOT_DIRECTORY                  = -41, 
    	IS_DIRECTORY                   = -51, 
    	DIRECTORY_NOT_EMPTY            = -61, 
    	AT_END                         = -71, 
    	NO_SPACE                       = -81, 
    	BUSY                           = -91, 
    	IO_ERROR                       = -02, 
    	INTERRUPT                      = -12, 
    	UNAVAILABLE                    = -22, 
    	ALREADY_IN_USE                 = -32, 
    	BAD_ADDRESS                    = -42, 
    	BAD_SEEK                       = -52, 
    	BAD_PIPE                       = -62, 
    	DEADLOCK                       = -72, 
    	TOO_MANY_LINKS                 = -82, 
    	NOT_IMPLEMENTED                = -92, 
    	NO_MESSAGE                     = -03, 
    	BAD_MESSAGE                    = -13, 
    	NO_DATA_AVAILABLE              = -23, 
    	INVALID_DATA                   = -33, 
    	TIMEOUT                        = -43, 
    	NO_NETWORK                     = -53, 
    	NOT_UNIQUE                     = -63, 
    	NOT_SOCKET                     = -73, 
    	NO_ADDRESS                     = -83, 
    	BAD_PROTOCOL                   = -93, 
    	PROTOCOL_UNAVAILABLE           = -04, 
    	PROTOCOL_NOT_SUPPORTED         = -14, 
    	PROTOCOL_FAMILY_NOT_SUPPORTED  = -24, 
    	ADDRESS_FAMILY_NOT_SUPPORTED   = -34, 
    	SOCKET_NOT_SUPPORTED           = -44, 
    	CONNECTION_RESET               = -54, 
    	ALREADY_CONNECTED              = -64, 
    	NOT_CONNECTED                  = -74, 
    	CONNECTION_REFUSED             = -84, 
    	NO_HOST                        = -94, 
    	IN_PROGRESS                    = -05, 
    	CANCELLED                      = -15, 
    	MEMORY_ALREADY_MAPPED          = -25, 
    	// General non-standard errors. 
    	CRC_MISMATCH                   = -100, 
    	// General miniaudio-specific errors. 
    	FORMAT_NOT_SUPPORTED           = -200, 
    	DEVICE_TYPE_NOT_SUPPORTED      = -201, 
    	SHARE_MODE_NOT_SUPPORTED       = -202, 
    	NO_BACKEND                     = -203, 
    	NO_DEVICE                      = -204, 
    	API_NOT_FOUND                  = -205, 
    	INVALID_DEVICE_CONFIG          = -206, 
    	LOOP                           = -207, 
    	BACKEND_NOT_ENABLED            = -208, 
    	// State errors. 
    	DEVICE_NOT_INITIALIZED         = -300, 
    	DEVICE_ALREADY_INITIALIZED     = -301, 
    	DEVICE_NOT_STARTED             = -302, 
    	DEVICE_NOT_STOPPED             = -303, 
    	// Operation errors. 
    	FAILED_TO_INIT_BACKEND         = -400, 
    	FAILED_TO_OPEN_BACKEND_DEVICE  = -401, 
    	FAILED_TO_START_BACKEND_DEVICE = -402, 
    	FAILED_TO_STOP_BACKEND_DEVICE  = -403, 
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    seek_origin ¶

    seek_origin :: enum i32 {
    	start, 
    	current, 
    	end,     // Not used by decoders.
    }
    Related Procedures With Parameters

    semaphore ¶

    semaphore :: distinct rawptr
    Related Procedures With Parameters

    share_mode ¶

    share_mode :: enum i32 {
    	shared    = 0, 
    	exclusive, 
    }

    slot_allocator ¶

    slot_allocator :: struct {
    	pGroups:   [^]slot_allocator_group,
    	// Slots are grouped in chunks of 32. 
    	pSlots:    [^]u32,
    	// 32 bits for reference counting for ABA mitigation. 
    	count:     u32,
    	// Allocation count. 
    	capacity:  u32,
    	// Memory management. 
    	_ownsHeap: b32,
    	_pHeap:    rawptr,
    }
    Related Procedures With Parameters

    slot_allocator_config ¶

    slot_allocator_config :: struct {
    	capacity: u32,
    }
     

    Slot Allocator -------------- The idea of the slot allocator is for it to be used in conjunction with a fixed sized buffer. You use the slot allocator to allocator an index that can be used as the insertion point for an object.

    Slots are reference counted to help mitigate the ABA problem in the lock-free queue we use for tracking jobs.

    The slot index is stored in the low 32 bits. The reference counter is stored in the high 32 bits:

    	+-----------------+-----------------+
    	| 32 Bits         | 32 Bits         |
    	+-----------------+-----------------+
    	| Reference Count | Slot Index      |
    	+-----------------+-----------------+
    
    Related Procedures With Parameters
    Related Procedures With Returns

    slot_allocator_group ¶

    slot_allocator_group :: struct {
    	bitfield: u32,
    }

    sound ¶

    sound :: struct {
    	engineNode:                 engine_node,
    	// Must be the first member for compatibility with the ma_node API. 
    	pDataSource:                ^data_source,
    	seekTarget:                 u64,
    	// atomic
    	// The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. 
    	atEnd:                      b32,
    	// atomic
    	endCallback:                sound_end_proc,
    	pEndCallbackUserData:       rawptr,
    	ownsDataSource:             b8,
    	// 	We're declaring a resource manager data source object here to save us a malloc when loading a
    	// 	sound via the resource manager, which I *think* will be the most common scenario.
    	pResourceManagerDataSource: ^resource_manager_data_source,
    }
    Related Procedures With Parameters

    sound_config ¶

    sound_config :: struct {
    	pFilePath:                      cstring,
    	// Set this to load from the resource manager. 
    	pFilePathW:                     [^]u16,
    	// Set this to load from the resource manager. 
    	pDataSource:                    ^data_source,
    	// Set this to load from an existing data source. 
    	pInitialAttachment:             ^node,
    	// If set, the sound will be attached to an input of this node. This can be set to a ma_sound. If set to NULL, the sound will be attached directly to the endpoint unless MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT is set in `flags`. 
    	initialAttachmentInputBusIndex: u32,
    	// The index of the input bus of pInitialAttachment to attach the sound to. 
    	channelsIn:                     u32,
    	// Ignored if using a data source as input (the data source's channel count will be used always). Otherwise, setting to 0 will cause the engine's channel count to be used. 
    	channelsOut:                    u32,
    	// Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). 
    	monoExpansionMode:              mono_expansion_mode,
    	// Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. 
    	flags:                          bit_set[sound_flag; u32],
    	// A combination of MA_SOUND_FLAG_* flags. 
    	volumeSmoothTimeInPCMFrames:    u32,
    	// The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. 
    	initialSeekPointInPCMFrames:    u64,
    	// Initializes the sound such that it's seeked to this location by default. 
    	rangeBegInPCMFrames:            u64,
    	rangeEndInPCMFrames:            u64,
    	loopPointBegInPCMFrames:        u64,
    	loopPointEndInPCMFrames:        u64,
    	endCallback:                    sound_end_proc,
    	// Fired when the sound reaches the end. Will be fired from the audio thread. Do not restart, uninitialize or otherwise change the state of the sound from here. Instead fire an event or set a variable to indicate to a different thread to change the start of the sound. Will not be fired in response to a scheduled stop with ma_sound_set_stop_time_*(). 
    	pEndCallbackUserData:           rawptr,
    	initNotifications:              resource_manager_pipeline_notifications,
    	pDoneFence:                     ^fence,
    	// Deprecated. Use initNotifications instead. Released when the resource manager has finished decoding the entire sound. Not used with streams. 
    	isLooping:                      b32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    sound_end_proc ¶

    sound_end_proc :: proc "c" (pUserData: rawptr, pSound: ^sound)
     

    Callback for when a sound reaches the end.

    Related Procedures With Parameters

    sound_flag ¶

    sound_flag :: enum i32 {
    	// Resource manager flags. 
    	STREAM                = 0,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_STREAM
    	DECODE                = 1,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_DECODE
    	ASYNC                 = 2,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_ASYNC
    	WAIT_INIT             = 3,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT
    	UNKNOWN_LENGTH        = 4,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_UNKNOWN_LENGTH
    	LOOPING               = 5,  // MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_LOOPING
    	// ma_sound specific flags. 
    	NO_DEFAULT_ATTACHMENT = 12, // Do not attach to the endpoint by default. Useful for when setting up nodes in a complex graph system.
    	NO_PITCH              = 13, // Disable pitch shifting with ma_sound_set_pitch() and ma_sound_group_set_pitch(). This is an optimization.
    	NO_SPATIALIZATION     = 14, // Disable spatialization.
    }
     

    Sound flags.

    sound_group ¶

    sound_group :: struct {
    	engineNode:                 engine_node,
    	// Must be the first member for compatibility with the ma_node API. 
    	pDataSource:                ^data_source,
    	seekTarget:                 u64,
    	// atomic
    	// The PCM frame index to seek to in the mixing thread. Set to (~(ma_uint64)0) to not perform any seeking. 
    	atEnd:                      b32,
    	// atomic
    	endCallback:                sound_end_proc,
    	pEndCallbackUserData:       rawptr,
    	ownsDataSource:             b8,
    	// 	We're declaring a resource manager data source object here to save us a malloc when loading a
    	// 	sound via the resource manager, which I *think* will be the most common scenario.
    	pResourceManagerDataSource: ^resource_manager_data_source,
    }
    Related Procedures With Parameters

    sound_group_config ¶

    sound_group_config :: struct {
    	pFilePath:                      cstring,
    	// Set this to load from the resource manager. 
    	pFilePathW:                     [^]u16,
    	// Set this to load from the resource manager. 
    	pDataSource:                    ^data_source,
    	// Set this to load from an existing data source. 
    	pInitialAttachment:             ^node,
    	// If set, the sound will be attached to an input of this node. This can be set to a ma_sound. If set to NULL, the sound will be attached directly to the endpoint unless MA_SOUND_FLAG_NO_DEFAULT_ATTACHMENT is set in `flags`. 
    	initialAttachmentInputBusIndex: u32,
    	// The index of the input bus of pInitialAttachment to attach the sound to. 
    	channelsIn:                     u32,
    	// Ignored if using a data source as input (the data source's channel count will be used always). Otherwise, setting to 0 will cause the engine's channel count to be used. 
    	channelsOut:                    u32,
    	// Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). 
    	monoExpansionMode:              mono_expansion_mode,
    	// Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. 
    	flags:                          bit_set[sound_flag; u32],
    	// A combination of MA_SOUND_FLAG_* flags. 
    	volumeSmoothTimeInPCMFrames:    u32,
    	// The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. 
    	initialSeekPointInPCMFrames:    u64,
    	// Initializes the sound such that it's seeked to this location by default. 
    	rangeBegInPCMFrames:            u64,
    	rangeEndInPCMFrames:            u64,
    	loopPointBegInPCMFrames:        u64,
    	loopPointEndInPCMFrames:        u64,
    	endCallback:                    sound_end_proc,
    	// Fired when the sound reaches the end. Will be fired from the audio thread. Do not restart, uninitialize or otherwise change the state of the sound from here. Instead fire an event or set a variable to indicate to a different thread to change the start of the sound. Will not be fired in response to a scheduled stop with ma_sound_set_stop_time_*(). 
    	pEndCallbackUserData:           rawptr,
    	initNotifications:              resource_manager_pipeline_notifications,
    	pDoneFence:                     ^fence,
    	// Deprecated. Use initNotifications instead. Released when the resource manager has finished decoding the entire sound. Not used with streams. 
    	isLooping:                      b32,
    }
     

    A sound group is just a sound.

    Related Procedures With Parameters
    Related Procedures With Returns

    sound_inlined ¶

    sound_inlined :: struct {
    	sound: sound,
    	pNext: ^sound_inlined,
    	pPrev: ^sound_inlined,
    }
     

    Structure specifically for sounds played with ma_engine_play_sound(). Making this a separate structure to reduce overhead.

    spatializer ¶

    spatializer :: struct {
    	channelsIn:                   u32,
    	channelsOut:                  u32,
    	pChannelMapIn:                [^]channel,
    	attenuationModel:             attenuation_model,
    	positioning:                  positioning,
    	handedness:                   handedness,
    	// Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. 
    	minGain:                      f32,
    	maxGain:                      f32,
    	minDistance:                  f32,
    	maxDistance:                  f32,
    	rolloff:                      f32,
    	coneInnerAngleInRadians:      f32,
    	coneOuterAngleInRadians:      f32,
    	coneOuterGain:                f32,
    	dopplerFactor:                f32,
    	// Set to 0 to disable doppler effect. 
    	directionalAttenuationFactor: f32,
    	// Set to 0 to disable directional attenuation. 
    	gainSmoothTimeInFrames:       u32,
    	// When the gain of a channel changes during spatialization, the transition will be linearly interpolated over this number of frames. 
    	position:                     atomic_vec3f,
    	direction:                    atomic_vec3f,
    	velocity:                     atomic_vec3f,
    	// For doppler effect. 
    	dopplerPitch:                 f32,
    	// Will be updated by ma_spatializer_process_pcm_frames() and can be used by higher level functions to apply a pitch shift for doppler effect. 
    	minSpatializationChannelGain: f32,
    	gainer:                       gainer,
    	// For smooth gain transitions. 
    	pNewChannelGainsOut:          [^]f32,
    	// Memory management. 
    	_pHeap:                       rawptr,
    	_ownsHeap:                    b32,
    }
    Related Procedures With Parameters

    spatializer_config ¶

    spatializer_config :: struct {
    	channelsIn:                   u32,
    	channelsOut:                  u32,
    	pChannelMapIn:                [^]channel,
    	attenuationModel:             attenuation_model,
    	positioning:                  positioning,
    	handedness:                   handedness,
    	// Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. 
    	minGain:                      f32,
    	maxGain:                      f32,
    	minDistance:                  f32,
    	maxDistance:                  f32,
    	rolloff:                      f32,
    	coneInnerAngleInRadians:      f32,
    	coneOuterAngleInRadians:      f32,
    	coneOuterGain:                f32,
    	dopplerFactor:                f32,
    	// Set to 0 to disable doppler effect. 
    	directionalAttenuationFactor: f32,
    	// Set to 0 to disable directional attenuation. 
    	minSpatializationChannelGain: f32,
    	// The minimal scaling factor to apply to channel gains when accounting for the direction of the sound relative to the listener. Must be in the range of 0..1. Smaller values means more aggressive directional panning, larger values means more subtle directional panning. 
    	gainSmoothTimeInFrames:       u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    spatializer_listener_config ¶

    spatializer_listener_config :: struct {
    	channelsOut:             u32,
    	pChannelMapOut:          [^]channel,
    	handedness:              handedness,
    	// Defaults to right. Forward is -1 on the Z axis. In a left handed system, forward is +1 on the Z axis. 
    	coneInnerAngleInRadians: f32,
    	coneOuterAngleInRadians: f32,
    	coneOuterGain:           f32,
    	speedOfSound:            f32,
    	worldUp:                 vec3f,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    spinlock ¶

    spinlock :: distinct u32
     

    Spinlocks are 32-bit for compatibility reasons.

    Related Procedures With Parameters

    splitter_node ¶

    splitter_node :: struct {
    	base: node_base,
    }
    Related Procedures With Parameters

    splitter_node_config ¶

    splitter_node_config :: struct {
    	nodeConfig:     node_config,
    	channels:       u32,
    	outputBusCount: u32,
    }
     

    Splitter Node. 1 input, many outputs. Used for splitting/copying a stream so it can be as input into two separate output nodes.

    Related Procedures With Parameters
    Related Procedures With Returns

    stack ¶

    stack :: struct {
    	offset:      uint,
    	sizeInBytes: uint,
    	_data:       [1]u8,
    }
     

    For some internal memory management of ma_node_graph.

    standard_channel_map ¶

    standard_channel_map :: enum i32 {
    	microsoft, 
    	alsa, 
    	rfc3551,       // Based off AIFF.
    	flac, 
    	vorbis, 
    	sound4,        // FreeBSD's sound(4).
    	sndio,         // www.sndio.org/tips.html
    	webaudio  = 3, // https://webaudio.github.io/web-audio-api/#ChannelOrdering. Only 1, 2, 4 and 6 channels are defined, but can fill in the gaps with logical assumptions.
    	default   = 0, 
    }
    Related Procedures With Parameters

    standard_sample_rate ¶

    standard_sample_rate :: enum u32 {
    	// Standard rates need to be in priority order. 
    	rate_48000  = 48000,  // Most common
    	rate_44100  = 44100, 
    	rate_32000  = 32000,  // Lows
    	rate_24000  = 24000, 
    	rate_22050  = 22050, 
    	rate_88200  = 88200,  // Highs
    	rate_96000  = 96000, 
    	rate_176400 = 176400, 
    	rate_192000 = 192000, 
    	rate_16000  = 16000,  // Extreme lows
    	rate_11025  = 11025, 
    	rate_8000   = 8000, 
    	rate_352800 = 352800, // Extreme highs
    	rate_384000 = 384000, 
    	rate_min    = 8000, 
    	rate_max    = 384000, 
    	rate_count  = 14,     // Need to maintain the count manually. Make sure this is updated if items are added to enum.
    }

    stop_proc ¶

    stop_proc :: proc "c" (pDevice: ^device)
     

    DEPRECATED. Use ma_device_notification_proc instead.

    The callback for when the device has been stopped.

    This will be called when the device is stopped explicitly with ma_device_stop() and also called implicitly when the device is stopped through external forces such as being unplugged or an internal error occurring.

    Parameters ---------- pDevice (in) A pointer to the device that has just stopped.

    Remarks ------- Do not restart or uninitialize the device from the callback.

    stream_format ¶

    stream_format :: enum i32 {
    	pcm = 0, 
    }

    stream_layout ¶

    stream_layout :: enum i32 {
    	interleaved   = 0, 
    	deinterleaved, 
    }

    thread ¶

    thread :: distinct rawptr

    thread_priority ¶

    thread_priority :: enum i32 {
    	idle     = -5, 
    	lowest   = -4, 
    	low      = -3, 
    	normal   = -2, 
    	high     = -1, 
    	highest  = 0, 
    	realtime = 1, 
    	default  = 0, 
    }
     

    Thread priorities should be ordered such that the default priority of the worker thread is 0.

    timer ¶

    timer :: struct #raw_union {
    	counter:  i64,
    	counterD: f64,
    }

    vfs ¶

    vfs :: struct {}
     

    *******************************

    VFS ===

    The VFS object (virtual file system) is what's used to customize file access. This is useful in cases where stdio FILE* based APIs may not be entirely appropriate for a given situation.

    *******************************

    Related Procedures With Parameters

    vfs_callbacks ¶

    vfs_callbacks :: struct {
    	onOpen:  proc "c" (pVFS: ^vfs, pFilePath: cstring, openMode: bit_set[open_mode_flag; u32], pFile: ^vfs_file) -> result,
    	onOpenW: proc "c" (pVFS: ^vfs, pFilePath: [^]u16, openMode: bit_set[open_mode_flag; u32], pFile: ^vfs_file) -> result,
    	onClose: proc "c" (pVFS: ^vfs, file: vfs_file) -> result,
    	onRead:  proc "c" (pVFS: ^vfs, file: vfs_file, pDst: rawptr, sizeInBytes: uint, pBytesRead: ^uint) -> result,
    	onWrite: proc "c" (pVFS: ^vfs, file: vfs_file, pSrc: rawptr, sizeInBytes: uint, pBytesWritten: ^uint) -> result,
    	onSeek:  proc "c" (pVFS: ^vfs, file: vfs_file, offset: i64, origin: seek_origin) -> result,
    	onTell:  proc "c" (pVFS: ^vfs, file: vfs_file, pCursor: ^i64) -> result,
    	onInfo:  proc "c" (pVFS: ^vfs, file: vfs_file, pInfo: ^file_info) -> result,
    }

    vfs_file ¶

    vfs_file :: distinct rawptr
    Related Procedures With Parameters

    wasapi_usage ¶

    wasapi_usage :: enum i32 {
    	default   = 0, 
    	games, 
    	pro_audio, 
    }
     

    WASAPI audio thread priority characteristics.

    waveform_config ¶

    waveform_config :: struct {
    	format:     format,
    	channels:   u32,
    	sampleRate: u32,
    	type:       waveform_type,
    	amplitude:  f64,
    	frequency:  f64,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    waveform_type ¶

    waveform_type :: enum i32 {
    	sine, 
    	square, 
    	triangle, 
    	sawtooth, 
    }
    Related Procedures With Parameters

    Constants

    BACKEND_COUNT ¶

    BACKEND_COUNT: int : len(backend)

    BINDINGS_VERSION ¶

    BINDINGS_VERSION: [3]u32 : [3]u32{BINDINGS_VERSION_MAJOR, BINDINGS_VERSION_MINOR, BINDINGS_VERSION_REVISION}

    BINDINGS_VERSION_MAJOR ¶

    BINDINGS_VERSION_MAJOR: int : 0

    BINDINGS_VERSION_MINOR ¶

    BINDINGS_VERSION_MINOR: int : 11

    BINDINGS_VERSION_REVISION ¶

    BINDINGS_VERSION_REVISION: int : 22

    BINDINGS_VERSION_STRING ¶

    BINDINGS_VERSION_STRING: string : "0.11.22"

    CHANNEL_INDEX_NULL ¶

    CHANNEL_INDEX_NULL: int : 255
     

    *******************************

    Channel Maps

    *******************************

    This is used in the shuffle table to indicate that the channel index is undefined and should be ignored.

    ENGINE_MAX_LISTENERS ¶

    ENGINE_MAX_LISTENERS: int : 4

    JOB_TYPE_RESOURCE_MANAGER_QUEUE_FLAG_NON_BLOCKING ¶

    JOB_TYPE_RESOURCE_MANAGER_QUEUE_FLAG_NON_BLOCKING :: job_queue_flags.NON_BLOCKING

    LISTENER_INDEX_CLOSEST ¶

    LISTENER_INDEX_CLOSEST: int : 255

    MAX_CHANNELS ¶

    MAX_CHANNELS: int : 254

    MAX_DEVICE_NAME_LENGTH ¶

    MAX_DEVICE_NAME_LENGTH: int : 255

    MAX_FILTER_ORDER ¶

    MAX_FILTER_ORDER: int : 8

    MAX_LOG_CALLBACKS ¶

    MAX_LOG_CALLBACKS: int : 4

    MAX_NODE_BUS_COUNT ¶

    MAX_NODE_BUS_COUNT: int : 254
     

    Must never exceed 254.

    MAX_NODE_LOCAL_BUS_COUNT ¶

    MAX_NODE_LOCAL_BUS_COUNT: int : 2
     

    Used internally by miniaudio for memory management. Must never exceed MA_MAX_NODE_BUS_COUNT.

    MINIAUDIO_SHARED ¶

    MINIAUDIO_SHARED: bool : #config(MINIAUDIO_SHARED, false)

    MIN_CHANNELS ¶

    MIN_CHANNELS: int : 1

    NODE_BUS_COUNT_UNKNOWN ¶

    NODE_BUS_COUNT_UNKNOWN: int : 255
     

    Use this when the bus count is determined by the node instance rather than the vtable.

    NO_THREADING ¶

    NO_THREADING: bool : false

    RESOURCE_MANAGER_MAX_JOB_THREAD_COUNT ¶

    RESOURCE_MANAGER_MAX_JOB_THREAD_COUNT: int : 64
     

    Maximum job thread count will be restricted to this, but this may be removed later and replaced with a heap allocation thereby removing any limitation.

    SIMD_ALIGNMENT ¶

    SIMD_ALIGNMENT: int : 32
     

    SIMD alignment in bytes. Currently set to 32 bytes in preparation for future AVX optimizations.

    SOUND_SOURCE_CHANNEL_COUNT ¶

    SOUND_SOURCE_CHANNEL_COUNT: int : 0xFFFFFFFF

    SUPPORT_AAUDIO ¶

    SUPPORT_AAUDIO: bool : false
     

    ODIN_OS == .Android

    SUPPORT_ALSA ¶

    SUPPORT_ALSA: bool : ODIN_OS == .Linux

    SUPPORT_AUDIO4 ¶

    SUPPORT_AUDIO4: bool : false
     

    ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD

    SUPPORT_COREAUDIO ¶

    SUPPORT_COREAUDIO: bool : ODIN_OS == .Darwin

    SUPPORT_CUSTOM ¶

    SUPPORT_CUSTOM: bool : true

    SUPPORT_DSOUND ¶

    SUPPORT_DSOUND: bool : ODIN_OS == .Windows

    SUPPORT_JACK ¶

    SUPPORT_JACK: bool : ODIN_OS == .Windows

    SUPPORT_NULL ¶

    SUPPORT_NULL: bool : true
     

    ODIN_OS != .Emscripten

    SUPPORT_OPENSL ¶

    SUPPORT_OPENSL: bool : false
     

    ODIN_OS == .Android

    SUPPORT_OSS ¶

    SUPPORT_OSS: bool : ODIN_OS == .FreeBSD

    SUPPORT_PULSEAUDIO ¶

    SUPPORT_PULSEAUDIO: bool : ODIN_OS == .Linux

    SUPPORT_SNDIO ¶

    SUPPORT_SNDIO: bool : ODIN_OS == .OpenBSD

    SUPPORT_WASAPI ¶

    SUPPORT_WASAPI: bool : ODIN_OS == .Windows

    SUPPORT_WEBAUDIO ¶

    SUPPORT_WEBAUDIO: bool : false
     

    ODIN_OS == .Emscripten

    SUPPORT_WINMM ¶

    SUPPORT_WINMM: bool : ODIN_OS == .Windows

    USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE ¶

    USE_EXPERIMENTAL_LOCK_FREE_JOB_QUEUE: bool : false

    Variables

    This section is empty.

    Procedures

    aligned_free ¶

    aligned_free :: proc "c" (p: rawptr, pAllocationCallbacks: ^allocation_callbacks) ---
     

    Free's an aligned malloc'd buffer.

    aligned_malloc ¶

    aligned_malloc :: proc "c" (sz, alignment: uint, pAllocationCallbacks: ^allocation_callbacks) -> rawptr ---
     

    Performs an aligned malloc, with the assumption that the alignment is a power of 2.

    apply_volume_factor_f32 ¶

    apply_volume_factor_f32 :: proc "c" (pSamples: [^]f32, sampleCount: u64, factor: f32) ---

    apply_volume_factor_pcm_frames ¶

    apply_volume_factor_pcm_frames :: proc "c" (pFrames: rawptr, frameCount: u64, format: format, channels: u32, factor: f32) ---

    apply_volume_factor_pcm_frames_f32 ¶

    apply_volume_factor_pcm_frames_f32 :: proc "c" (pFrames: [^]f32, frameCount: u64, channels: u32, factor: f32) ---

    apply_volume_factor_pcm_frames_s16 ¶

    apply_volume_factor_pcm_frames_s16 :: proc "c" (pFrames: [^]i16, frameCount: u64, channels: u32, factor: f32) ---

    apply_volume_factor_pcm_frames_s24 ¶

    apply_volume_factor_pcm_frames_s24 :: proc "c" (pFrames: rawptr, frameCount: u64, channels: u32, factor: f32) ---

    apply_volume_factor_pcm_frames_s32 ¶

    apply_volume_factor_pcm_frames_s32 :: proc "c" (pFrames: [^]i32, frameCount: u64, channels: u32, factor: f32) ---

    apply_volume_factor_pcm_frames_u8 ¶

    apply_volume_factor_pcm_frames_u8 :: proc "c" (pFrames: [^]u8, frameCount: u64, channels: u32, factor: f32) ---

    apply_volume_factor_s16 ¶

    apply_volume_factor_s16 :: proc "c" (pSamples: [^]i16, sampleCount: u64, factor: f32) ---

    apply_volume_factor_s24 ¶

    apply_volume_factor_s24 :: proc "c" (pSamples: rawptr, sampleCount: u64, factor: f32) ---

    apply_volume_factor_s32 ¶

    apply_volume_factor_s32 :: proc "c" (pSamples: [^]i32, sampleCount: u64, factor: f32) ---

    apply_volume_factor_u8 ¶

    apply_volume_factor_u8 :: proc "c" (pSamples: [^]u8, sampleCount: u64, factor: f32) ---

    async_notification_event_init ¶

    async_notification_event_init :: proc "c" (pNotificationEvent: ^async_notification_event) -> result ---

    async_notification_event_signal ¶

    async_notification_event_signal :: proc "c" (pNotificationEvent: ^async_notification_event) -> result ---

    async_notification_event_uninit ¶

    async_notification_event_uninit :: proc "c" (pNotificationEvent: ^async_notification_event) -> result ---

    async_notification_event_wait ¶

    async_notification_event_wait :: proc "c" (pNotificationEvent: ^async_notification_event) -> result ---

    async_notification_poll_init ¶

    async_notification_poll_init :: proc "c" (pNotificationPoll: ^async_notification_poll) -> result ---

    async_notification_poll_is_signalled ¶

    async_notification_poll_is_signalled :: proc "c" (pNotificationPoll: ^async_notification_poll) -> b32 ---

    async_notification_signal ¶

    async_notification_signal :: proc "c" (pNotification: ^async_notification) -> result ---

    audio_buffer_alloc_and_init ¶

    audio_buffer_alloc_and_init :: proc "c" (pConfig: ^audio_buffer_config, ppAudioBuffer: ^^audio_buffer) -> result ---
     

    Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit.

    audio_buffer_at_end ¶

    audio_buffer_at_end :: proc "c" (pAudioBuffer: ^audio_buffer) -> b32 ---

    audio_buffer_config_init ¶

    audio_buffer_config_init :: proc "c" (format: format, channels: u32, sizeInFrames: u64, pData: rawptr, pAllocationCallbacks: ^allocation_callbacks) -> audio_buffer_config ---

    audio_buffer_get_available_frames ¶

    audio_buffer_get_available_frames :: proc "c" (pAudioBuffer: ^audio_buffer, pAvailableFrames: ^u64) -> result ---

    audio_buffer_get_cursor_in_pcm_frames ¶

    audio_buffer_get_cursor_in_pcm_frames :: proc "c" (pAudioBuffer: ^audio_buffer, pCursor: ^u64) -> result ---

    audio_buffer_get_length_in_pcm_frames ¶

    audio_buffer_get_length_in_pcm_frames :: proc "c" (pAudioBuffer: ^audio_buffer, pLength: ^u64) -> result ---

    audio_buffer_init ¶

    audio_buffer_init :: proc "c" (pConfig: ^audio_buffer_config, pAudioBuffer: ^audio_buffer) -> result ---

    audio_buffer_init_copy ¶

    audio_buffer_init_copy :: proc "c" (pConfig: ^audio_buffer_config, pAudioBuffer: ^audio_buffer) -> result ---

    audio_buffer_map ¶

    audio_buffer_map :: proc "c" (pAudioBuffer: ^audio_buffer, ppFramesOut: ^rawptr, pFrameCount: ^u64) -> result ---

    audio_buffer_read_pcm_frames ¶

    audio_buffer_read_pcm_frames :: proc "c" (pAudioBuffer: ^audio_buffer, pFramesOut: rawptr, frameCount: u64, loop: b32) -> u64 ---

    audio_buffer_ref_at_end ¶

    audio_buffer_ref_at_end :: proc "c" (pAudioBufferRef: ^audio_buffer_ref) -> b32 ---

    audio_buffer_ref_get_available_frames ¶

    audio_buffer_ref_get_available_frames :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, pAvailableFrames: ^u64) -> result ---

    audio_buffer_ref_get_cursor_in_pcm_frames ¶

    audio_buffer_ref_get_cursor_in_pcm_frames :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, pCursor: ^u64) -> result ---

    audio_buffer_ref_get_length_in_pcm_frames ¶

    audio_buffer_ref_get_length_in_pcm_frames :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, pLength: ^u64) -> result ---

    audio_buffer_ref_init ¶

    audio_buffer_ref_init :: proc "c" (format: format, channels: u32, pData: rawptr, sizeInFrames: u64, pAudioBufferRef: ^audio_buffer_ref) -> result ---

    audio_buffer_ref_map ¶

    audio_buffer_ref_map :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, ppFramesOut: ^rawptr, pFrameCount: ^u64) -> result ---

    audio_buffer_ref_read_pcm_frames ¶

    audio_buffer_ref_read_pcm_frames :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, pFramesOut: rawptr, frameCount: u64, loop: b32) -> u64 ---

    audio_buffer_ref_seek_to_pcm_frame ¶

    audio_buffer_ref_seek_to_pcm_frame :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, frameIndex: u64) -> result ---

    audio_buffer_ref_set_data ¶

    audio_buffer_ref_set_data :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, pData: rawptr, sizeInFrames: u64) -> result ---

    audio_buffer_ref_uninit ¶

    audio_buffer_ref_uninit :: proc "c" (pAudioBufferRef: ^audio_buffer_ref) ---

    audio_buffer_ref_unmap ¶

    audio_buffer_ref_unmap :: proc "c" (pAudioBufferRef: ^audio_buffer_ref, frameCount: u64) -> result ---
     

    Returns MA_AT_END if the end has been reached. This should be considered successful.

    audio_buffer_seek_to_pcm_frame ¶

    audio_buffer_seek_to_pcm_frame :: proc "c" (pAudioBuffer: ^audio_buffer, frameIndex: u64) -> result ---

    audio_buffer_uninit ¶

    audio_buffer_uninit :: proc "c" (pAudioBuffer: ^audio_buffer) ---

    audio_buffer_uninit_and_free ¶

    audio_buffer_uninit_and_free :: proc "c" (pAudioBuffer: ^audio_buffer) ---

    audio_buffer_unmap ¶

    audio_buffer_unmap :: proc "c" (pAudioBuffer: ^audio_buffer, frameCount: u64) -> result ---
     

    Returns MA_AT_END if the end has been reached. This should be considered successful.

    biquad_clear_cache ¶

    biquad_clear_cache :: proc "c" (pBQ: ^biquad) -> result ---

    biquad_config_init ¶

    biquad_config_init :: proc "c" (
    	format:             format, 
    	channels:           u32, 
    	b0, b1, b2, a0, a1, 
    	a2:                 f64, 
    ) -> biquad_config ---

    biquad_get_heap_size ¶

    biquad_get_heap_size :: proc "c" (pConfig: ^biquad_config, pHeapSizeInBytes: ^uint) -> result ---

    biquad_get_latency ¶

    biquad_get_latency :: proc "c" (pBQ: ^biquad) -> u32 ---

    biquad_init ¶

    biquad_init :: proc "c" (pConfig: ^biquad_config, pAllocationCallbacks: ^allocation_callbacks, pBQ: ^biquad) -> result ---

    biquad_init_preallocated ¶

    biquad_init_preallocated :: proc "c" (pConfig: ^biquad_config, pHeap: rawptr, pBQ: ^biquad) -> result ---

    biquad_node_config_init ¶

    biquad_node_config_init :: proc "c" (
    	channels:           u32, 
    	b0, b1, b2, a0, a1, 
    	a2:                 f32, 
    ) -> biquad_node_config ---

    biquad_node_init ¶

    biquad_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^biquad_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^biquad_node) -> result ---

    biquad_node_reinit ¶

    biquad_node_reinit :: proc "c" (pConfig: ^biquad_config, pNode: ^biquad_node) -> result ---

    biquad_node_uninit ¶

    biquad_node_uninit :: proc "c" (pNode: ^biquad_node, pAllocationCallbacks: ^allocation_callbacks) ---

    biquad_process_pcm_frames ¶

    biquad_process_pcm_frames :: proc "c" (pBQ: ^biquad, pFramesOut, pFramesIn: rawptr, frameCount: u64) -> result ---

    biquad_reinit ¶

    biquad_reinit :: proc "c" (pConfig: ^biquad_config, pBQ: ^biquad) -> result ---

    biquad_uninit ¶

    biquad_uninit :: proc "c" (pBQ: ^biquad, pAllocationCallbacks: ^allocation_callbacks) ---

    blend_f32 ¶

    blend_f32 :: proc "c" (pOut, pInA, pInB: [^]f32, factor: f32, channels: u32) ---
     

    Blends two frames in floating point format.

    bpf2_config_init ¶

    bpf2_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency, q: f64) -> bpf2_config ---

    bpf2_get_heap_size ¶

    bpf2_get_heap_size :: proc "c" (pConfig: ^bpf2_config, pHeapSizeInBytes: ^uint) -> result ---

    bpf2_get_latency ¶

    bpf2_get_latency :: proc "c" (pBPF: ^bpf2) -> u32 ---

    bpf2_init ¶

    bpf2_init :: proc "c" (pConfig: ^bpf2_config, pAllocationCallbacks: ^allocation_callbacks, pBPF: ^bpf2) -> result ---

    bpf2_init_preallocated ¶

    bpf2_init_preallocated :: proc "c" (pConfig: ^bpf2_config, pHeap: rawptr, pBPF: ^bpf2) -> result ---

    bpf2_process_pcm_frames ¶

    bpf2_process_pcm_frames :: proc "c" (pBPF: ^bpf2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    bpf2_reinit ¶

    bpf2_reinit :: proc "c" (pConfig: ^bpf2_config, pBPF: ^bpf2) -> result ---

    bpf2_uninit ¶

    bpf2_uninit :: proc "c" (pBPF: ^bpf2, pAllocationCallbacks: ^allocation_callbacks) ---

    bpf_config_init ¶

    bpf_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency: f64, order: u32) -> bpf_config ---

    bpf_get_heap_size ¶

    bpf_get_heap_size :: proc "c" (pConfig: ^bpf_config, pHeapSizeInBytes: ^uint) -> result ---

    bpf_get_latency ¶

    bpf_get_latency :: proc "c" (pBPF: ^bpf) -> u32 ---

    bpf_init ¶

    bpf_init :: proc "c" (pConfig: ^bpf_config, pAllocationCallbacks: ^allocation_callbacks, pBPF: ^bpf) -> result ---

    bpf_init_preallocated ¶

    bpf_init_preallocated :: proc "c" (pConfig: ^bpf_config, pHeap: rawptr, pBPF: ^bpf) -> result ---

    bpf_node_config_init ¶

    bpf_node_config_init :: proc "c" (channels, sampleRate: u32, cutoffFrequency: f64, order: u32) -> bpf_node_config ---

    bpf_node_init ¶

    bpf_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^bpf_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^bpf_node) -> result ---

    bpf_node_reinit ¶

    bpf_node_reinit :: proc "c" (pConfig: ^bpf_config, pNode: ^bpf_node) -> result ---

    bpf_node_uninit ¶

    bpf_node_uninit :: proc "c" (pNode: ^bpf_node, pAllocationCallbacks: ^allocation_callbacks) ---

    bpf_process_pcm_frames ¶

    bpf_process_pcm_frames :: proc "c" (pBPF: ^bpf, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    bpf_reinit ¶

    bpf_reinit :: proc "c" (pConfig: ^bpf_config, pBPF: ^bpf) -> result ---

    bpf_uninit ¶

    bpf_uninit :: proc "c" (pBPF: ^bpf, pAllocationCallbacks: ^allocation_callbacks) ---

    calculate_buffer_size_in_frames_from_descriptor ¶

    calculate_buffer_size_in_frames_from_descriptor :: proc "c" (pDescriptor: ^device_descriptor, nativeSampleRate: u32, performanceProfile: performance_profile) -> u32 ---
     

    Calculates an appropriate buffer size from a descriptor, native sample rate and performance profile.

    This function is used by backends for helping determine an appropriately sized buffer to use with the device depending on the values of periodSizeInFrames and periodSizeInMilliseconds in the pDescriptor object. Since buffer size calculations based on time depends on the sample rate, a best guess at the device's native sample rate is also required which is where nativeSampleRate comes in. In addition, the performance profile is also needed for cases where both the period size in frames and milliseconds are both zero.

    Parameters ---------- pDescriptor (in)

    	A pointer to device descriptor whose `periodSizeInFrames` and `periodSizeInMilliseconds` members
    	will be used for the calculation of the buffer size.
    
    

    nativeSampleRate (in)

    	The device's native sample rate. This is only ever used when the `periodSizeInFrames` member of
    	`pDescriptor` is zero. In this case, `periodSizeInMilliseconds` will be used instead, in which
    	case a sample rate is required to convert to a size in frames.
    
    

    performanceProfile (in)

    	When both the `periodSizeInFrames` and `periodSizeInMilliseconds` members of `pDescriptor` are
    	zero, miniaudio will fall back to a buffer size based on the performance profile. The profile
    	to use for this calculation is determine by this parameter.
    
    
    

    Return Value ------------ The calculated buffer size in frames.

    Thread Safety ------------- This is safe so long as nothing modifies pDescriptor at the same time. However, this function should only ever be called from within the backend's device initialization routine and therefore shouldn't have any multithreading concerns.

    Callback Safety --------------- This is safe to call within the data callback, but there is no reason to ever do this.

    Remarks ------- If nativeSampleRate is zero, this function will fall back to pDescriptor->sampleRate. If that is also zero, MA_DEFAULT_SAMPLE_RATE will be used instead.

    calculate_buffer_size_in_frames_from_milliseconds ¶

    calculate_buffer_size_in_frames_from_milliseconds :: proc "c" (bufferSizeInMilliseconds: u32, sampleRate: u32) -> u32 ---
     

    Calculates a buffer size in frames from the specified number of milliseconds and sample rate.

    calculate_buffer_size_in_milliseconds_from_frames ¶

    calculate_buffer_size_in_milliseconds_from_frames :: proc "c" (bufferSizeInFrames: u32, sampleRate: u32) -> u32 ---
     

    Calculates a buffer size in milliseconds (rounded up) from the specified number of frames and sample rate.

    calloc ¶

    calloc :: proc "c" (sz: uint, pAllocationCallbacks: ^allocation_callbacks) -> rawptr ---
     

    calloc()

    channel_converter_config_init ¶

    channel_converter_config_init :: proc "c" (
    	format:         format, 
    	channelsIn:     u32, 
    	pChannelMapIn:  [^]channel, 
    	channelsOut:    u32, 
    	pChannelMapOut: [^]channel, 
    	mixingMode:     channel_mix_mode, 
    ) -> channel_converter_config ---

    channel_converter_get_heap_size ¶

    channel_converter_get_heap_size :: proc "c" (pConfig: ^channel_converter_config, pHeapSizeInBytes: ^uint) -> result ---

    channel_converter_get_input_channel_map ¶

    channel_converter_get_input_channel_map :: proc "c" (pConverter: ^channel_converter, pChannelMap: [^]channel, channelMapCap: uint) -> result ---

    channel_converter_get_output_channel_map ¶

    channel_converter_get_output_channel_map :: proc "c" (pConverter: ^channel_converter, pChannelMap: [^]channel, channelMapCap: uint) -> result ---

    channel_converter_init ¶

    channel_converter_init :: proc "c" (pConfig: ^channel_converter_config, pAllocationCallbacks: ^allocation_callbacks, pConverter: ^channel_converter) -> result ---

    channel_converter_init_preallocated ¶

    channel_converter_init_preallocated :: proc "c" (pConfig: ^channel_converter_config, pHeap: rawptr, pConverter: ^channel_converter) -> result ---

    channel_converter_process_pcm_frames ¶

    channel_converter_process_pcm_frames :: proc "c" (pConverter: ^channel_converter, pFramesOut, pFramesIn: rawptr, frameCount: u64) -> result ---

    channel_converter_uninit ¶

    channel_converter_uninit :: proc "c" (pConverter: ^channel_converter, pAllocationCallbacks: ^allocation_callbacks) ---

    channel_map_contains_channel_position ¶

    channel_map_contains_channel_position :: proc "c" (channels: u32, pChannelMap: [^]channel, channelPosition: channel) -> b32 ---
     

    Helper for determining whether or not a channel is present in the given channel map.

    The channel map buffer must have a capacity of at least channels.

    channel_map_copy ¶

    channel_map_copy :: proc "c" (pOut: [^]channel, pIn: [^]channel, channels: u32) ---
     

    Copies a channel map.

    Both input and output channel map buffers must have a capacity of at least channels.

    channel_map_copy_or_default ¶

    channel_map_copy_or_default :: proc "c" (pOut: [^]channel, channelMapCapOut: uint, pIn: [^]channel, channels: u32) ---
     

    Copies a channel map if one is specified, otherwise copies the default channel map.

    The output buffer must have a capacity of at least channels. If not NULL, the input channel map must also have a capacity of at least channels.

    channel_map_find_channel_position ¶

    channel_map_find_channel_position :: proc "c" (channels: u32, pChannelMap: [^]channel, channelPosition: channel, pChannelIndex: ^u32) -> b32 ---
     

    Find a channel position in the given channel map. Returns MA_TRUE if the channel is found; MA_FALSE otherwise. The index of the channel is output to pChannelIndex.

    The channel map buffer must have a capacity of at least channels.

    channel_map_get_channel ¶

    channel_map_get_channel :: proc "c" (pChannelMap: [^]channel, channelCount: u32, channelIndex: u32) -> channel ---
     

    Retrieves the channel position of the specified channel in the given channel map.

    The pChannelMap parameter can be null, in which case miniaudio's default channel map will be assumed.

    channel_map_init_blank ¶

    channel_map_init_blank :: proc "c" (pChannelMap: [^]channel, channels: u32) ---
     

    Initializes a blank channel map.

    When a blank channel map is specified anywhere it indicates that the native channel map should be used.

    channel_map_init_standard ¶

    channel_map_init_standard :: proc "c" (standardChannelMap: standard_channel_map, pChannelMap: [^]channel, channelMapCap: uint, channels: u32) ---
     

    Helper for retrieving a standard channel map.

    The output channel map buffer must have a capacity of at least channelMapCap.

    channel_map_is_blank ¶

    channel_map_is_blank :: proc "c" (pChannelMap: [^]channel, channels: u32) -> b32 ---
     

    Helper for determining if a channel map is blank (all channels set to MA_CHANNEL_NONE).

    The channel map buffer must have a capacity of at least channels.

    channel_map_is_equal ¶

    channel_map_is_equal :: proc "c" (pChannelMapA, pChannelMapB: [^]channel, channels: u32) -> b32 ---
     

    Helper for comparing two channel maps for equality.

    This assumes the channel count is the same between the two.

    Both channels map buffers must have a capacity of at least channels.

    channel_map_is_valid ¶

    channel_map_is_valid :: proc "c" (pChannelMap: [^]channel, channels: u32) -> b32 ---
     

    Determines whether or not a channel map is valid.

    A blank channel map is valid (all channels set to MA_CHANNEL_NONE). The way a blank channel map is handled is context specific, but is usually treated as a passthrough.

    Invalid channel maps:

    - A channel map with no channels
    - A channel map with more than one channel and a mono channel
    
    

    The channel map buffer must have a capacity of at least channels.

    channel_map_to_string ¶

    channel_map_to_string :: proc "c" (pChannelMap: [^]channel, channels: u32, pBufferOut: [^]u8, bufferCap: uint) -> uint ---
     

    Generates a string representing the given channel map.

    This is for printing and debugging purposes, not serialization/deserialization.

    Returns the length of the string, not including the null terminator.

    channel_position_to_string ¶

    channel_position_to_string :: proc "c" (channel: channel) -> cstring ---
     

    Retrieves a human readable version of a channel position.

    clip_pcm_frames ¶

    clip_pcm_frames :: proc "c" (pDst, pSrc: rawptr, frameCount: u64, format: format, channels: u32) ---

    clip_samples_f32 ¶

    clip_samples_f32 :: proc "c" (pDst, pSrc: [^]f32, count: u64) ---

    clip_samples_s16 ¶

    clip_samples_s16 :: proc "c" (pDst: [^]i16, pSrc: [^]i32, count: u64) ---

    clip_samples_s24 ¶

    clip_samples_s24 :: proc "c" (pDst: [^]u8, pSrc: [^]i64, count: u64) ---

    clip_samples_s32 ¶

    clip_samples_s32 :: proc "c" (pDst: [^]i32, pSrc: [^]i64, count: u64) ---

    clip_samples_u8 ¶

    clip_samples_u8 :: proc "c" (pDst: [^]u8, pSrc: [^]i16, count: u64) ---
     

    Clips samples.

    context_config_init ¶

    context_config_init :: proc "c" () -> context_config ---
     

    Initializes a ma_context_config object.

    Return Value ------------ A ma_context_config initialized to defaults.

    Remarks ------- You must always use this to initialize the default state of the ma_context_config object. Not using this will result in your program breaking when miniaudio is updated and new members are added to ma_context_config. It also sets logical defaults.

    You can override members of the returned object by changing it's members directly.

    See Also -------- ma_context_init()

    context_enumerate_devices ¶

    context_enumerate_devices :: proc "c" (pContext: ^context_type, callback: enum_devices_callback_proc, pUserData: rawptr) -> result ---
     

    Enumerates over every device (both playback and capture).

    This is a lower-level enumeration function to the easier to use ma_context_get_devices(). Use ma_context_enumerate_devices() if you would rather not incur an internal heap allocation, or it simply suits your code better.

    Note that this only retrieves the ID and name/description of the device. The reason for only retrieving basic information is that it would otherwise require opening the backend device in order to probe it for more detailed information which can be inefficient. Consider using ma_context_get_device_info() for this, but don't call it from within the enumeration callback.

    Returning false from the callback will stop enumeration. Returning true will continue enumeration.

    Parameters ---------- pContext (in)

    	A pointer to the context performing the enumeration.
    
    

    callback (in)

    	The callback to fire for each enumerated device.
    
    

    pUserData (in)

    	A pointer to application-defined data passed to the callback.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Safe. This is guarded using a simple mutex lock.

    Remarks ------- Do _not_ assume the first enumerated device of a given type is the default device.

    Some backends and platforms may only support default playback and capture devices.

    In general, you should not do anything complicated from within the callback. In particular, do not try initializing a device from within the callback. Also, do not try to call ma_context_get_device_info() from within the callback.

    Consider using ma_context_get_devices() for a simpler and safer API, albeit at the expense of an internal heap allocation.

    Example 1 - Simple Enumeration ------------------------------ ma_bool32 ma_device_enum_callback(ma_context pContext, ma_device_type deviceType, const ma_device_info pInfo, void* pUserData) {

    	printf("Device Name: %s\n", pInfo->name);
    	return MA_TRUE;
    

    }

    ma_result result = ma_context_enumerate_devices(&context, my_device_enum_callback, pMyUserData); if (result != MA_SUCCESS) {

    	// Error.
    

    }

    See Also -------- ma_context_get_devices()

    context_get_device_info ¶

    context_get_device_info :: proc "c" (pContext: ^context_type, deviceType: device_type, pDeviceID: ^device_id, pDeviceInfo: ^device_info) -> result ---
     

    Retrieves information about a device of the given type, with the specified ID and share mode.

    Parameters ---------- pContext (in)

    	A pointer to the context performing the query.
    
    

    deviceType (in)

    	The type of the device being queried. Must be either `ma_device_type_playback` or `ma_device_type_capture`.
    
    

    pDeviceID (in)

    	The ID of the device being queried.
    
    

    pDeviceInfo (out)

    	A pointer to the `ma_device_info` structure that will receive the device information.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Safe. This is guarded using a simple mutex lock.

    Remarks ------- Do _not_ call this from within the ma_context_enumerate_devices() callback.

    It's possible for a device to have different information and capabilities depending on whether or not it's opened in shared or exclusive mode. For example, in shared mode, WASAPI always uses floating point samples for mixing, but in exclusive mode it can be anything. Therefore, this function allows you to specify which share mode you want information for. Note that not all backends and devices support shared or exclusive mode, in which case this function will fail if the requested share mode is unsupported.

    This leaves pDeviceInfo unmodified in the result of an error.

    context_get_devices ¶

    context_get_devices :: proc "c" (pContext: ^context_type, ppPlaybackDeviceInfos: ^[^]device_info, pPlaybackDeviceCount: ^u32, ppCaptureDeviceInfos: ^[^]device_info, pCaptureDeviceCount: ^u32) -> result ---
     

    Retrieves basic information about every active playback and/or capture device.

    This function will allocate memory internally for the device lists and return a pointer to them through the ppPlaybackDeviceInfos and ppCaptureDeviceInfos parameters. If you do not want to incur the overhead of these allocations consider using ma_context_enumerate_devices() which will instead use a callback.

    Note that this only retrieves the ID and name/description of the device. The reason for only retrieving basic information is that it would otherwise require opening the backend device in order to probe it for more detailed information which can be inefficient. Consider using ma_context_get_device_info() for this, but don't call it from within the enumeration callback.

    Parameters ---------- pContext (in)

    	A pointer to the context performing the enumeration.
    
    

    ppPlaybackDeviceInfos (out)

    	A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for playback devices.
    
    

    pPlaybackDeviceCount (out)

    	A pointer to an unsigned integer that will receive the number of playback devices.
    
    

    ppCaptureDeviceInfos (out)

    	A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for capture devices.
    
    

    pCaptureDeviceCount (out)

    	A pointer to an unsigned integer that will receive the number of capture devices.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. Since each call to this function invalidates the pointers from the previous call, you should not be calling this simultaneously across multiple threads. Instead, you need to make a copy of the returned data with your own higher level synchronization.

    Remarks ------- It is _not_ safe to assume the first device in the list is the default device.

    You can pass in NULL for the playback or capture lists in which case they'll be ignored.

    The returned pointers will become invalid upon the next call this this function, or when the context is uninitialized. Do not free the returned pointers.

    See Also -------- ma_context_enumerate_devices()

    context_get_log ¶

    context_get_log :: proc "c" (pContext: ^context_type) -> log ---
     

    Retrieves a pointer to the log object associated with this context.

    Remarks ------- Pass the returned pointer to ma_log_post(), ma_log_postv() or ma_log_postf() to post a log message.

    Return Value ------------ A pointer to the ma_log object that the context uses to post log messages. If some error occurs, NULL will be returned.

    context_init ¶

    context_init :: proc "c" (backends: [^]backend, backendCount: u32, pConfig: ^context_config, pContext: ^context_type) -> result ---
     

    Initializes a context.

    The context is used for selecting and initializing an appropriate backend and to represent the backend at a more global level than that of an individual device. There is one context to many devices, and a device is created from a context. A context is required to enumerate devices.

    Parameters ---------- backends (in, optional)

    	A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
    
    

    backendCount (in, optional)

    	The number of items in `backend`. Ignored if `backend` is NULL.
    
    

    pConfig (in, optional)

    	The context configuration.
    
    

    pContext (in)

    	A pointer to the context object being initialized.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. Do not call this function across multiple threads as some backends read and write to global state.

    Remarks ------- When backends is NULL, the default priority order will be used. Below is a list of backends in priority order:

    	|-------------|-----------------------|--------------------------------------------------------|
    	| Name        | Enum Name             | Supported Operating Systems                            |
    	|-------------|-----------------------|--------------------------------------------------------|
    	| WASAPI      | ma_backend_wasapi     | Windows Vista+                                         |
    	| DirectSound | ma_backend_dsound     | Windows XP+                                            |
    	| WinMM       | ma_backend_winmm      | Windows XP+ (may work on older versions, but untested) |
    	| Core Audio  | ma_backend_coreaudio  | macOS, iOS                                             |
    	| ALSA        | ma_backend_alsa       | Linux                                                  |
    	| PulseAudio  | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android)  |
    	| JACK        | ma_backend_jack       | Cross Platform (disabled on BSD and Android)           |
    	| sndio       | ma_backend_sndio      | OpenBSD                                                |
    	| audio(4)    | ma_backend_audio4     | NetBSD, OpenBSD                                        |
    	| OSS         | ma_backend_oss        | FreeBSD                                                |
    	| AAudio      | ma_backend_aaudio     | Android 8+                                             |
    	| OpenSL|ES   | ma_backend_opensl     | Android (API level 16+)                                |
    	| Web Audio   | ma_backend_webaudio   | Web (via Emscripten)                                   |
    	| Null        | ma_backend_null       | Cross Platform (not used on Web)                       |
    	|-------------|-----------------------|--------------------------------------------------------|
    
    

    The context can be configured via the pConfig argument. The config object is initialized with ma_context_config_init(). Individual configuration settings can then be set directly on the structure. Below are the members of the ma_context_config object.

    	pLog
    			A pointer to the `ma_log` to post log messages to. Can be NULL if the application does not
    			require logging. See the `ma_log` API for details on how to use the logging system.
    
    	threadPriority
    			The desired priority to use for the audio thread. Allowable values include the following:
    
    			|--------------------------------------|
    			| Thread Priority                      |
    			|--------------------------------------|
    			| ma_thread_priority_idle              |
    			| ma_thread_priority_lowest            |
    			| ma_thread_priority_low               |
    			| ma_thread_priority_normal            |
    			| ma_thread_priority_high              |
    			| ma_thread_priority_highest (default) |
    			| ma_thread_priority_realtime          |
    			| ma_thread_priority_default           |
    			|--------------------------------------|
    
    	threadStackSize
    			The desired size of the stack for the audio thread. Defaults to the operating system's default.
    
    	pUserData
    			A pointer to application-defined data. This can be accessed from the context object directly such as `context.pUserData`.
    
    	allocationCallbacks
    			Structure containing custom allocation callbacks. Leaving this at defaults will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. These allocation
    			callbacks will be used for anything tied to the context, including devices.
    
    	alsa.useVerboseDeviceEnumeration
    			ALSA will typically enumerate many different devices which can be intrusive and not user-friendly. To combat this, miniaudio will enumerate only unique
    			card/device pairs by default. The problem with this is that you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes
    			it so the ALSA backend includes all devices. Defaults to false.
    
    	pulse.pApplicationName
    			PulseAudio only. The application name to use when initializing the PulseAudio context with `pa_context_new()`.
    
    	pulse.pServerName
    			PulseAudio only. The name of the server to connect to with `pa_context_connect()`.
    
    	pulse.tryAutoSpawn
    			PulseAudio only. Whether or not to try automatically starting the PulseAudio daemon. Defaults to false. If you set this to true, keep in mind that
    			miniaudio uses a trial and error method to find the most appropriate backend, and this will result in the PulseAudio daemon starting which may be
    			intrusive for the end user.
    
    	coreaudio.sessionCategory
    			iOS only. The session category to use for the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
    
    			|-----------------------------------------|-------------------------------------|
    			| miniaudio Token                         | Core Audio Token                    |
    			|-----------------------------------------|-------------------------------------|
    			| ma_ios_session_category_ambient         | AVAudioSessionCategoryAmbient       |
    			| ma_ios_session_category_solo_ambient    | AVAudioSessionCategorySoloAmbient   |
    			| ma_ios_session_category_playback        | AVAudioSessionCategoryPlayback      |
    			| ma_ios_session_category_record          | AVAudioSessionCategoryRecord        |
    			| ma_ios_session_category_play_and_record | AVAudioSessionCategoryPlayAndRecord |
    			| ma_ios_session_category_multi_route     | AVAudioSessionCategoryMultiRoute    |
    			| ma_ios_session_category_none            | AVAudioSessionCategoryAmbient       |
    			| ma_ios_session_category_default         | AVAudioSessionCategoryAmbient       |
    			|-----------------------------------------|-------------------------------------|
    
    	coreaudio.sessionCategoryOptions
    			iOS only. Session category options to use with the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
    
    			|---------------------------------------------------------------------------|------------------------------------------------------------------|
    			| miniaudio Token                                                           | Core Audio Token                                                 |
    			|---------------------------------------------------------------------------|------------------------------------------------------------------|
    			| ma_ios_session_category_option_mix_with_others                            | AVAudioSessionCategoryOptionMixWithOthers                        |
    			| ma_ios_session_category_option_duck_others                                | AVAudioSessionCategoryOptionDuckOthers                           |
    			| ma_ios_session_category_option_allow_bluetooth                            | AVAudioSessionCategoryOptionAllowBluetooth                       |
    			| ma_ios_session_category_option_default_to_speaker                         | AVAudioSessionCategoryOptionDefaultToSpeaker                     |
    			| ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers |
    			| ma_ios_session_category_option_allow_bluetooth_a2dp                       | AVAudioSessionCategoryOptionAllowBluetoothA2DP                   |
    			| ma_ios_session_category_option_allow_air_play                             | AVAudioSessionCategoryOptionAllowAirPlay                         |
    			|---------------------------------------------------------------------------|------------------------------------------------------------------|
    
    	coreaudio.noAudioSessionActivate
    			iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization.
    
    	coreaudio.noAudioSessionDeactivate
    			iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:false] on uninitialization.
    
    	jack.pClientName
    			The name of the client to pass to `jack_client_open()`.
    
    	jack.tryStartServer
    			Whether or not to try auto-starting the JACK server. Defaults to false.
    
    
    

    It is recommended that only a single context is active at any given time because it's a bulky data structure which performs run-time linking for the relevant backends every time it's initialized.

    The location of the context cannot change throughout it's lifetime. Consider allocating the ma_context object with malloc() if this is an issue. The reason for this is that a pointer to the context is stored in the ma_device structure.

    Example 1 - Default Initialization ---------------------------------- The example below shows how to initialize the context using the default configuration.

    `c ma_context context; ma_result result = ma_context_init(NULL, 0, NULL, &context); if (result != MA_SUCCESS) {

    	// Error.
    

    } `

    Example 2 - Custom Configuration -------------------------------- The example below shows how to initialize the context using custom backend priorities and a custom configuration. In this hypothetical example, the program wants to prioritize ALSA over PulseAudio on Linux. They also want to avoid using the WinMM backend on Windows because it's latency is too high. They also want an error to be returned if no valid backend is available which they achieve by excluding the Null backend.

    For the configuration, the program wants to capture any log messages so they can, for example, route it to a log file and user interface.

    `c ma_backend backends[] = {

    	ma_backend_alsa,
    	ma_backend_pulseaudio,
    	ma_backend_wasapi,
    	ma_backend_dsound
    

    };

    ma_log log; ma_log_init(&log); ma_log_register_callback(&log, ma_log_callback_init(my_log_callbac, pMyLogUserData));

    ma_context_config config = ma_context_config_init(); config.pLog = &log; // Specify a custom log object in the config so any logs that are posted from ma_context_init() are captured.

    ma_context context; ma_result result = ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &config, &context); if (result != MA_SUCCESS) {

    	// Error.
    	if (result == MA_NO_BACKEND) {
    			// Couldn't find an appropriate backend.
    	}
    

    }

    // You could also attach a log callback post-initialization: ma_log_register_callback(ma_context_get_log(&context), ma_log_callback_init(my_log_callback, pMyLogUserData)); `

    See Also -------- ma_context_config_init() ma_context_uninit()

    context_is_loopback_supported ¶

    context_is_loopback_supported :: proc "c" (pContext: ^context_type) -> b32 ---
     

    Determines if the given context supports loopback mode.

    Parameters ---------- pContext (in) A pointer to the context getting queried.

    Return Value ------------ MA_TRUE if the context supports loopback mode; MA_FALSE otherwise.

    context_sizeof ¶

    context_sizeof :: proc "c" () -> uint ---
     

    Retrieves the size of the ma_context object.

    This is mainly for the purpose of bindings to know how much memory to allocate.

    context_uninit ¶

    context_uninit :: proc "c" (pContext: ^context_type) -> result ---
     

    Uninitializes a context.

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. Do not call this function across multiple threads as some backends read and write to global state.

    Remarks ------- Results are undefined if you call this while any device created by this context is still active.

    See Also -------- ma_context_init()

    convert_frames ¶

    convert_frames :: proc "c" (
    	pOut:          rawptr, 
    	frameCountOut: u64, 
    	formatOut:     format, 
    	channelsOut:   u32, 
    	sampleRateOut: u32, 
    	pIn:           rawptr, 
    	frameCountIn:  u64, 
    	formatIn:      format, 
    	channelsIn:    u32, 
    	sampleRateIn:  u32, 
    ) -> u64 ---
     

    High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is NULL, frameCountOut is ignored.

    A return value of 0 indicates an error.

    This function is useful for one-off bulk conversions, but if you're streaming data you should use the ma_data_converter APIs instead.

    convert_frames_ex ¶

    convert_frames_ex :: proc "c" (pOut: rawptr, frameCountOut: u64, pIn: rawptr, frameCountIn: u64, pConfig: ^data_converter_config) -> u64 ---

    convert_pcm_frames_format ¶

    convert_pcm_frames_format :: proc "c" (
    	pOut:       rawptr, 
    	formatOut:  format, 
    	pIn:        rawptr, 
    	formatIn:   format, 
    	frameCount: u64, 
    	channels:   u32, 
    	ditherMode: dither_mode, 
    ) ---

    copy_and_apply_volume_factor_f32 ¶

    copy_and_apply_volume_factor_f32 :: proc "c" (pSamplesOut, pSamplesIn: [^]f32, sampleCount: u64, factor: f64) ---

    copy_and_apply_volume_factor_pcm_frames ¶

    copy_and_apply_volume_factor_pcm_frames :: proc "c" (
    	pFramesOut, pFramesIn: rawptr, 
    	frameCount:            u64, 
    	format:                format, 
    	channels:              u32, 
    	factor:                f32, 
    ) ---

    copy_and_apply_volume_factor_pcm_frames_f32 ¶

    copy_and_apply_volume_factor_pcm_frames_f32 :: proc "c" (pPCMFramesOut, pPCMFramesIn: [^]f32, frameCount: u64, channels: u32, factor: f32) ---

    copy_and_apply_volume_factor_pcm_frames_s16 ¶

    copy_and_apply_volume_factor_pcm_frames_s16 :: proc "c" (pPCMFramesOut, pPCMFramesIn: [^]i16, frameCount: u64, channels: u32, factor: f32) ---

    copy_and_apply_volume_factor_pcm_frames_s24 ¶

    copy_and_apply_volume_factor_pcm_frames_s24 :: proc "c" (pPCMFramesOut, pPCMFramesIn: rawptr, frameCount: u64, channels: u32, factor: f32) ---

    copy_and_apply_volume_factor_pcm_frames_s32 ¶

    copy_and_apply_volume_factor_pcm_frames_s32 :: proc "c" (pPCMFramesOut, pPCMFramesIn: [^]i32, frameCount: u64, channels: u32, factor: f32) ---

    copy_and_apply_volume_factor_pcm_frames_u8 ¶

    copy_and_apply_volume_factor_pcm_frames_u8 :: proc "c" (pPCMFramesOut, pPCMFramesIn: [^]u8, frameCount: u64, channels: u32, factor: f32) ---

    copy_and_apply_volume_factor_per_channel_f32 ¶

    copy_and_apply_volume_factor_per_channel_f32 :: proc "c" (pFramesOut, pFramesIn: [^]f32, frameCount: u64, channels: u32, pChannelGains: [^]f32) ---

    copy_and_apply_volume_factor_s16 ¶

    copy_and_apply_volume_factor_s16 :: proc "c" (pSamplesOut, pSamplesIn: [^]i16, sampleCount: u64, factor: f64) ---

    copy_and_apply_volume_factor_s24 ¶

    copy_and_apply_volume_factor_s24 :: proc "c" (pSamplesOut, pSamplesIn: rawptr, sampleCount: u64, factor: f64) ---

    copy_and_apply_volume_factor_s32 ¶

    copy_and_apply_volume_factor_s32 :: proc "c" (pSamplesOut, pSamplesIn: [^]i32, sampleCount: u64, factor: f64) ---

    copy_and_apply_volume_factor_u8 ¶

    copy_and_apply_volume_factor_u8 :: proc "c" (pSamplesOut, pSamplesIn: [^]u8, sampleCount: u64, factor: f64) ---
     

    Helper for applying a volume factor to samples.

    Note that the source and destination buffers can be the same, in which case it'll perform the operation in-place.

    copy_pcm_frames ¶

    copy_pcm_frames :: proc "c" (dst: rawptr, src: rawptr, frameCount: u64, format: format, channels: u32) ---
     

    Copies PCM frames from one buffer to another.

    data_converter_config_init ¶

    data_converter_config_init :: proc "c" (
    	formatIn, formatOut:     format, 
    	channelsIn, channelsOut: u32, 
    	sampleRateIn, 
    	sampleRateOut:           u32, 
    ) -> data_converter_config ---

    data_converter_config_init_default ¶

    data_converter_config_init_default :: proc "c" () -> data_converter_config ---

    data_converter_get_expected_output_frame_count ¶

    data_converter_get_expected_output_frame_count :: proc "c" (pConverter: ^data_converter, inputFrameCount: u64, pOutputFrameCount: ^u64) -> result ---

    data_converter_get_heap_size ¶

    data_converter_get_heap_size :: proc "c" (pConfig: ^data_converter_config, pHeapSizeInBytes: ^uint) -> result ---

    data_converter_get_input_channel_map ¶

    data_converter_get_input_channel_map :: proc "c" (pConverter: ^data_converter, pChannelMap: [^]channel, channelMapCap: uint) -> result ---

    data_converter_get_input_latency ¶

    data_converter_get_input_latency :: proc "c" (pConverter: ^data_converter) -> u64 ---

    data_converter_get_output_channel_map ¶

    data_converter_get_output_channel_map :: proc "c" (pConverter: ^data_converter, pChannelMap: [^]channel, channelMapCap: uint) -> result ---

    data_converter_get_output_latency ¶

    data_converter_get_output_latency :: proc "c" (pConverter: ^data_converter) -> u64 ---

    data_converter_get_required_input_frame_count ¶

    data_converter_get_required_input_frame_count :: proc "c" (pConverter: ^data_converter, outputFrameCount: u64, pInputFrameCount: ^u64) -> result ---

    data_converter_init ¶

    data_converter_init :: proc "c" (pConfig: ^data_converter_config, pAllocationCallbacks: ^allocation_callbacks, pConverter: ^data_converter) -> result ---

    data_converter_init_preallocated ¶

    data_converter_init_preallocated :: proc "c" (pConfig: ^data_converter_config, pHeap: rawptr, pConverter: ^data_converter) -> result ---

    data_converter_process_pcm_frames ¶

    data_converter_process_pcm_frames :: proc "c" (pConverter: ^data_converter, pFramesIn: rawptr, pFrameCountIn: ^u64, pFramesOut: rawptr, pFrameCountOut: ^u64) -> result ---

    data_converter_reset ¶

    data_converter_reset :: proc "c" (pConverter: ^data_converter) -> result ---

    data_converter_set_rate ¶

    data_converter_set_rate :: proc "c" (pConverter: ^data_converter, sampleRateIn, sampleRateOut: u32) -> result ---

    data_converter_set_rate_ratio ¶

    data_converter_set_rate_ratio :: proc "c" (pConverter: ^data_converter, ratioInOut: f32) -> result ---

    data_converter_uninit ¶

    data_converter_uninit :: proc "c" (pConverter: ^data_converter, pAllocationCallbacks: ^allocation_callbacks) ---

    data_source_config_init ¶

    data_source_config_init :: proc "c" () -> data_source_config ---

    data_source_get_current ¶

    data_source_get_current :: proc "c" (pDataSource: ^data_source) -> ^data_source ---

    data_source_get_cursor_in_pcm_frames ¶

    data_source_get_cursor_in_pcm_frames :: proc "c" (pDataSource: ^data_source, pCursor: ^u64) -> result ---

    data_source_get_cursor_in_seconds ¶

    data_source_get_cursor_in_seconds :: proc "c" (pDataSource: ^data_source, pCursor: ^f32) -> result ---

    data_source_get_data_format ¶

    data_source_get_data_format :: proc "c" (
    	pDataSource:   ^data_source, 
    	pFormat:       ^format, 
    	pChannels:     ^u32, 
    	pSampleRate:   ^u32, 
    	pChannelMap:   [^]channel, 
    	channelMapCap: uint, 
    ) -> result ---

    data_source_get_length_in_pcm_frames ¶

    data_source_get_length_in_pcm_frames :: proc "c" (pDataSource: ^data_source, pLength: ^u64) -> result ---
     

    Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this.

    data_source_get_length_in_seconds ¶

    data_source_get_length_in_seconds :: proc "c" (pDataSource: ^data_source, pLength: ^f32) -> result ---

    data_source_get_loop_point_in_pcm_frames ¶

    data_source_get_loop_point_in_pcm_frames :: proc "c" (pDataSource: ^data_source, pLoopBegInFrames: ^u64, pLoopEndInFrames: ^u64) ---

    data_source_get_next ¶

    data_source_get_next :: proc "c" (pDataSource: ^data_source) -> ^data_source ---

    data_source_get_next_callback ¶

    data_source_get_next_callback :: proc "c" (pDataSource: ^data_source) -> ^data_source_get_next_proc ---

    data_source_get_range_in_pcm_frames ¶

    data_source_get_range_in_pcm_frames :: proc "c" (pDataSource: ^data_source, pRangeBegInFrames: ^u64, pRangeEndInFrames: ^u64) ---

    data_source_init ¶

    data_source_init :: proc "c" (pConfig: ^data_source_config, pDataSource: ^data_source) -> result ---

    data_source_is_looping ¶

    data_source_is_looping :: proc "c" (pDataSource: ^data_source) -> b32 ---

    data_source_node_config_init ¶

    data_source_node_config_init :: proc "c" (pDataSource: ^data_source) -> data_source_node_config ---

    data_source_node_init ¶

    data_source_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^data_source_node_config, pAllocationCallbacks: ^allocation_callbacks, pDataSourceNode: ^data_source_node) -> result ---

    data_source_node_is_looping ¶

    data_source_node_is_looping :: proc "c" (pDataSourceNode: ^data_source_node) -> b32 ---

    data_source_node_set_looping ¶

    data_source_node_set_looping :: proc "c" (pDataSourceNode: ^data_source_node, isLooping: b32) -> result ---

    data_source_node_uninit ¶

    data_source_node_uninit :: proc "c" (pDataSourceNode: ^data_source_node, pAllocationCallbacks: ^allocation_callbacks) ---

    data_source_read_pcm_frames ¶

    data_source_read_pcm_frames :: proc "c" (pDataSource: ^data_source, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---
     

    Must support pFramesOut = NULL in which case a forward seek should be performed.

    data_source_seek_pcm_frames ¶

    data_source_seek_pcm_frames :: proc "c" (pDataSource: ^data_source, frameCount: u64, pFramesSeeked: ^u64) -> result ---
     

    Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount);

    data_source_seek_seconds ¶

    data_source_seek_seconds :: proc "c" (pDataSource: ^data_source, secondCount: f32, pSecondsSeeked: ^f32) -> result ---
     

    Can only seek forward. Abstraction to ma_data_source_seek_pcm_frames()

    data_source_seek_to_pcm_frame ¶

    data_source_seek_to_pcm_frame :: proc "c" (pDataSource: ^data_source, frameIndex: u64) -> result ---

    data_source_seek_to_seconds ¶

    data_source_seek_to_seconds :: proc "c" (pDataSource: ^data_source, seekPointInSeconds: f32) -> result ---
     

    Abstraction to ma_data_source_seek_to_pcm_frame()

    data_source_set_current ¶

    data_source_set_current :: proc "c" (pDataSource: ^data_source, pCurrentDataSource: ^data_source) -> result ---

    data_source_set_loop_point_in_pcm_frames ¶

    data_source_set_loop_point_in_pcm_frames :: proc "c" (pDataSource: ^data_source, loopBegInFrames: u64, loopEndInFrames: u64) -> result ---

    data_source_set_looping ¶

    data_source_set_looping :: proc "c" (pDataSource: ^data_source, isLooping: b32) -> result ---

    data_source_set_next ¶

    data_source_set_next :: proc "c" (pDataSource: ^data_source, pNextDataSource: ^data_source) -> result ---

    data_source_set_next_callback ¶

    data_source_set_next_callback :: proc "c" (pDataSource: ^data_source, onGetNext: ^data_source_get_next_proc) -> result ---

    data_source_set_range_in_pcm_frames ¶

    data_source_set_range_in_pcm_frames :: proc "c" (pDataSource: ^data_source, rangeBegInFrames: u64, rangeEndInFrames: u64) -> result ---

    data_source_uninit ¶

    data_source_uninit :: proc "c" (pDataSource: ^data_source) ---

    decode_file ¶

    decode_file :: proc "c" (pFilePath: cstring, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---

    decode_from_vfs ¶

    decode_from_vfs :: proc "c" (pVFS: ^vfs, pFilePath: cstring, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---
     

    Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with ma_free(). On input, pConfig should be set to what you want. On output it will be set to what you got.

    decode_memory ¶

    decode_memory :: proc "c" (pData: rawptr, dataSize: uint, pConfig: ^decoder_config, pFrameCountOut: ^u64, ppPCMFramesOut: ^rawptr) -> result ---

    decoder_config_init ¶

    decoder_config_init :: proc "c" (outputFormat: format, outputChannels, outputSampleRate: u32) -> decoder_config ---

    decoder_config_init_default ¶

    decoder_config_init_default :: proc "c" () -> decoder_config ---

    decoder_get_available_frames ¶

    decoder_get_available_frames :: proc "c" (pDecoder: ^decoder, pAvailableFrames: ^u64) -> result ---
     

    Retrieves the number of frames that can be read before reaching the end.

    This calls ma_decoder_get_length_in_pcm_frames() so you need to be aware of the rules for that function, in particular ensuring you do not call it on streams of an undefined length, such as internet radio.

    If the total length of the decoder cannot be retrieved, such as with Vorbis decoders, MA_NOT_IMPLEMENTED will be returned.

    decoder_get_cursor_in_pcm_frames ¶

    decoder_get_cursor_in_pcm_frames :: proc "c" (pDecoder: ^decoder, pCursor: ^u64) -> result ---
     

    Retrieves the current position of the read cursor in PCM frames.

    decoder_get_data_format ¶

    decoder_get_data_format :: proc "c" (
    	pDecoder:               ^decoder, 
    	pFormat:                ^format, 
    	pChannels, pSampleRate: ^u32, 
    	pChannelMap:            ^channel, 
    	channelMapCap:          uint, 
    ) -> result ---
     

    Retrieves the decoder's output data format.

    decoder_get_length_in_pcm_frames ¶

    decoder_get_length_in_pcm_frames :: proc "c" (pDecoder: ^decoder, pLength: ^u64) -> result ---
     

    Retrieves the length of the decoder in PCM frames.

    Do not call this on streams of an undefined length, such as internet radio.

    If the length is unknown or an error occurs, 0 will be returned.

    This will always return 0 for Vorbis decoders. This is due to a limitation with stb_vorbis in push mode which is what miniaudio uses internally.

    For MP3's, this will decode the entire file. Do not call this in time critical scenarios.

    This function is not thread safe without your own synchronization.

    decoder_init ¶

    decoder_init :: proc "c" (onRead: decoder_read_proc, onSeek: decoder_seek_proc, pUserData: rawptr, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_init_file ¶

    decoder_init_file :: proc "c" (pFilePath: cstring, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_init_file_w ¶

    decoder_init_file_w :: proc "c" (pFilePath: [^]u16, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_init_memory ¶

    decoder_init_memory :: proc "c" (pData: rawptr, dataSize: uint, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_init_vfs ¶

    decoder_init_vfs :: proc "c" (pVFS: ^vfs, pFilePath: cstring, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_init_vfs_w ¶

    decoder_init_vfs_w :: proc "c" (pVFS: ^vfs, pFilePath: [^]u16, pConfig: ^decoder_config, pDecoder: ^decoder) -> result ---

    decoder_read_pcm_frames ¶

    decoder_read_pcm_frames :: proc "c" (pDecoder: ^decoder, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---
     

    Reads PCM frames from the given decoder.

    This is not thread safe without your own synchronization.

    decoder_seek_to_pcm_frame ¶

    decoder_seek_to_pcm_frame :: proc "c" (pDecoder: ^decoder, frameIndex: u64) -> result ---
     

    Seeks to a PCM frame based on its absolute index.

    This is not thread safe without your own synchronization.

    decoder_uninit ¶

    decoder_uninit :: proc "c" (pDecoder: ^decoder) -> result ---
     

    Uninitializes a decoder.

    decoding_backend_config_init ¶

    decoding_backend_config_init :: proc "c" (preferredFormat: format, seekPointCount: u32) -> decoding_backend_config ---

    default_vfs_init ¶

    default_vfs_init :: proc "c" (pVFS: ^default_vfs, pAllocationCallbacks: ^allocation_callbacks) -> result ---

    deinterleave_pcm_frames ¶

    deinterleave_pcm_frames :: proc "c" (format: format, channels: u32, frameCount: u64, pInterleavedPCMFrames: rawptr, ppDeinterleavedPCMFrames: ^rawptr) ---
     

    Deinterleaves an interleaved buffer.

    delay_config_init ¶

    delay_config_init :: proc "c" (channels, sampleRate, delayInFrames: u32, decay: f32) -> delay_config ---

    delay_get_decay ¶

    delay_get_decay :: proc "c" (pDelay: ^delay) -> f32 ---

    delay_get_dry ¶

    delay_get_dry :: proc "c" (pDelay: ^delay) -> f32 ---

    delay_get_wet ¶

    delay_get_wet :: proc "c" (pDelay: ^delay) -> f32 ---

    delay_init ¶

    delay_init :: proc "c" (pConfig: ^delay_config, pAllocationCallbacks: ^allocation_callbacks, pDelay: ^delay) -> result ---

    delay_node_config_init ¶

    delay_node_config_init :: proc "c" (channels, sampleRate, delayInFrames: u32, decay: f32) -> delay_node_config ---

    delay_node_get_decay ¶

    delay_node_get_decay :: proc "c" (pDelayNode: ^delay_node) -> f32 ---

    delay_node_get_dry ¶

    delay_node_get_dry :: proc "c" (pDelayNode: ^delay_node) -> f32 ---

    delay_node_get_wet ¶

    delay_node_get_wet :: proc "c" (pDelayNode: ^delay_node) -> f32 ---

    delay_node_init ¶

    delay_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^delay_node_config, pAllocationCallbacks: ^allocation_callbacks, pDelayNode: ^delay_node) -> result ---

    delay_node_set_decay ¶

    delay_node_set_decay :: proc "c" (pDelayNode: ^delay_node, value: f32) ---

    delay_node_set_dry ¶

    delay_node_set_dry :: proc "c" (pDelayNode: ^delay_node, value: f32) ---

    delay_node_set_wet ¶

    delay_node_set_wet :: proc "c" (pDelayNode: ^delay_node, value: f32) ---

    delay_node_uninit ¶

    delay_node_uninit :: proc "c" (pDelayNode: ^delay_node, pAllocationCallbacks: ^allocation_callbacks) ---

    delay_process_pcm_frames ¶

    delay_process_pcm_frames :: proc "c" (pDelay: ^delay, pFramesOut, pFramesIn: rawptr, frameCount: u32) -> result ---

    delay_set_decay ¶

    delay_set_decay :: proc "c" (pDelay: ^delay, value: f32) ---

    delay_set_dry ¶

    delay_set_dry :: proc "c" (pDelay: ^delay, value: f32) ---

    delay_set_wet ¶

    delay_set_wet :: proc "c" (pDelay: ^delay, value: f32) ---

    delay_uninit ¶

    delay_uninit :: proc "c" (pDelay: ^delay, pAllocationCallbacks: ^allocation_callbacks) ---

    device_config_init ¶

    device_config_init :: proc "c" (deviceType: device_type) -> device_config ---
     

    Initializes a device config with default settings.

    Parameters ---------- deviceType (in)

    	The type of the device this config is being initialized for. This must set to one of the following:
    
    	|-------------------------|
    	| Device Type             |
    	|-------------------------|
    	| ma_device_type_playback |
    	| ma_device_type_capture  |
    	| ma_device_type_duplex   |
    	| ma_device_type_loopback |
    	|-------------------------|
    
    
    

    Return Value ------------ A new device config object with default settings. You will typically want to adjust the config after this function returns. See remarks.

    Thread Safety ------------- Safe.

    Callback Safety --------------- Safe, but don't try initializing a device in a callback.

    Remarks ------- The returned config will be initialized to defaults. You will normally want to customize a few variables before initializing the device. See Example 1 for a typical configuration which sets the sample format, channel count, sample rate, data callback and user data. These are usually things you will want to change before initializing the device.

    See ma_device_init() for details on specific configuration options.

    Example 1 - Simple Configuration -------------------------------- The example below is what a program will typically want to configure for each device at a minimum. Notice how ma_device_config_init() is called first, and then the returned object is modified directly. This is important because it ensures that your program continues to work as new configuration options are added to the ma_device_config structure.

    `c ma_device_config config = ma_device_config_init(ma_device_type_playback); config.playback.format = ma_format_f32; config.playback.channels = 2; config.sampleRate = 48000; config.dataCallback = ma_data_callback; config.pUserData = pMyUserData; `

    See Also -------- ma_device_init() ma_device_init_ex()

    device_get_context ¶

    device_get_context :: proc "c" (pDevice: ^device) -> ^context_type ---
     

    Retrieves a pointer to the context that owns the given device.

    device_get_info ¶

    device_get_info :: proc "c" (pDevice: ^device, type: device_type, pDeviceInfo: ^device_info) -> result ---
     

    Retrieves information about the device.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose information is being retrieved.
    
    

    type (in)

    	The device type. This parameter is required for duplex devices. When retrieving device
    	information, you are doing so for an individual playback or capture device.
    
    

    pDeviceInfo (out)

    	A pointer to the `ma_device_info` that will receive the device information.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. This should be considered unsafe because it may be calling into the backend which may or may not be safe.

    Callback Safety --------------- Unsafe. You should avoid calling this in the data callback because it may call into the backend which may or may not be safe.

    device_get_log ¶

    device_get_log :: proc "c" (pDevice: ^device) -> ^log ---
     

    Helper function for retrieving the log object associated with the context that owns this device.

    device_get_master_volume ¶

    device_get_master_volume :: proc "c" (pDevice: ^device, pVolume: ^f32) -> result ---
     

    Retrieves the master volume factor for the device.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose volume factor is being retrieved.
    
    

    pVolume (in)

    	A pointer to the variable that will receive the volume factor. The returned value will be in the range of [0, 1].
    
    
    

    Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if pVolume is NULL.

    Thread Safety ------------- Safe. This just a simple member retrieval.

    Callback Safety --------------- Safe.

    Remarks ------- If an error occurs, *pVolume will be set to 0.

    See Also -------- ma_device_set_master_volume() ma_device_set_master_volume_gain_db() ma_device_get_master_volume_gain_db()

    device_get_master_volume_db ¶

    device_get_master_volume_db :: proc "c" (pDevice: ^device, pGainDB: ^f32) -> result ---
     

    Retrieves the master gain in decibels.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose gain is being retrieved.
    
    

    pGainDB (in)

    	A pointer to the variable that will receive the gain in decibels. The returned value will be <= 0.
    
    
    

    Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if pGainDB is NULL.

    Thread Safety ------------- Safe. This just a simple member retrieval.

    Callback Safety --------------- Safe.

    Remarks ------- If an error occurs, *pGainDB will be set to 0.

    See Also -------- ma_device_set_master_volume_db() ma_device_set_master_volume() ma_device_get_master_volume()

    device_get_name ¶

    device_get_name :: proc "c" (pDevice: ^device, type: device_type, pName: [^]u8, nameCap: uint, pLengthNotIncludingNullTerminator: ^uint) -> result ---
     

    Retrieves the name of the device.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose information is being retrieved.
    
    

    type (in)

    	The device type. This parameter is required for duplex devices. When retrieving device
    	information, you are doing so for an individual playback or capture device.
    
    

    pName (out)

    	A pointer to the buffer that will receive the name.
    
    

    nameCap (in)

    	The capacity of the output buffer, including space for the null terminator.
    
    

    pLengthNotIncludingNullTerminator (out, optional)

    	A pointer to the variable that will receive the length of the name, not including the null
    	terminator.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. This should be considered unsafe because it may be calling into the backend which may or may not be safe.

    Callback Safety --------------- Unsafe. You should avoid calling this in the data callback because it may call into the backend which may or may not be safe.

    Remarks ------- If the name does not fully fit into the output buffer, it'll be truncated. You can pass in NULL to pName if you want to first get the length of the name for the purpose of memory allocation of the output buffer. Allocating a buffer of size MA_MAX_DEVICE_NAME_LENGTH + 1 should be enough for most cases and will avoid the need for the inefficiency of calling this function twice.

    This is implemented in terms of ma_device_get_info().

    device_get_state ¶

    device_get_state :: proc "c" (pDevice: ^device) -> device_state ---
     

    Retrieves the state of the device.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose state is being retrieved.
    
    
    

    Return Value ------------ The current state of the device. The return value will be one of the following:

    	+-------------------------------+------------------------------------------------------------------------------+
    	| ma_device_state_uninitialized | Will only be returned if the device is in the middle of initialization.      |
    	+-------------------------------+------------------------------------------------------------------------------+
    	| ma_device_state_stopped       | The device is stopped. The initial state of the device after initialization. |
    	+-------------------------------+------------------------------------------------------------------------------+
    	| ma_device_state_started       | The device started and requesting and/or delivering audio data.              |
    	+-------------------------------+------------------------------------------------------------------------------+
    	| ma_device_state_starting      | The device is in the process of starting.                                    |
    	+-------------------------------+------------------------------------------------------------------------------+
    	| ma_device_state_stopping      | The device is in the process of stopping.                                    |
    	+-------------------------------+------------------------------------------------------------------------------+
    
    
    

    Thread Safety ------------- Safe. This is implemented as a simple accessor. Note that if the device is started or stopped at the same time as this function is called, there's a possibility the return value could be out of sync. See remarks.

    Callback Safety --------------- Safe. This is implemented as a simple accessor.

    Remarks ------- The general flow of a devices state goes like this:

    	```
    	ma_device_init()  -> ma_device_state_uninitialized -> ma_device_state_stopped
    	ma_device_start() -> ma_device_state_starting      -> ma_device_state_started
    	ma_device_stop()  -> ma_device_state_stopping      -> ma_device_state_stopped
    	```
    
    

    When the state of the device is changed with ma_device_start() or ma_device_stop() at this same time as this function is called, the value returned by this function could potentially be out of sync. If this is significant to your program you need to implement your own synchronization.

    device_handle_backend_data_callback ¶

    device_handle_backend_data_callback :: proc "c" (pDevice: ^device, pOutput, pInput: rawptr, frameCount: u32) -> result ---
     

    Called from the data callback of asynchronous backends to allow miniaudio to process the data and fire the miniaudio data callback.

    Parameters ---------- pDevice (in)

    	A pointer to device whose processing the data callback.
    
    

    pOutput (out)

    	A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be NULL. On a duplex device
    	this can be NULL, in which case pInput must not be NULL.
    
    

    pInput (in)

    	A pointer to the buffer containing input PCM frame data. On a capture device this must not be NULL. On a duplex device this can be
    	NULL, in which case `pOutput` must not be NULL.
    
    

    frameCount (in)

    	The number of frames being processed.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other result code otherwise.

    Thread Safety ------------- This function should only ever be called from the internal data callback of the backend. It is safe to call this simultaneously between a playback and capture device in duplex setups.

    Callback Safety --------------- Do not call this from the miniaudio data callback. It should only ever be called from the internal data callback of the backend.

    Remarks ------- If both pOutput and pInput are NULL, and error will be returned. In duplex scenarios, both pOutput and pInput can be non-NULL, in which case pInput will be processed first, followed by pOutput.

    If you are implementing a custom backend, and that backend uses a callback for data delivery, you'll need to call this from inside that callback.

    device_id_equal ¶

    device_id_equal :: proc "c" (pA: ^device_id, pB: ^device_id) -> b32 ---

    device_init ¶

    device_init :: proc "c" (pContext: ^context_type, pConfig: ^device_config, pDevice: ^device) -> result ---
     
    Initializes a device.
    
    A device represents a physical audio device. The idea is you send or receive audio data from the device to either play it back through a speaker, or capture it
    from a microphone. Whether or not you should send or receive data from the device (or both) depends on the type of device you are initializing which can be
    playback, capture, full-duplex or loopback. (Note that loopback mode is only supported on select backends.) Sending and receiving audio data to and from the
    device is done via a callback which is fired by miniaudio at periodic time intervals.
    
    The frequency at which data is delivered to and from a device depends on the size of its period. The size of the period can be defined in terms of PCM frames
    or milliseconds, whichever is more convenient. Generally speaking, the smaller the period, the lower the latency at the expense of higher CPU usage and
    increased risk of glitching due to the more frequent and granular data deliver intervals. The size of a period will depend on your requirements, but
    miniaudio's defaults should work fine for most scenarios. If you're building a game you should leave this fairly small, whereas if you're building a simple
    media player you can make it larger. Note that the period size you request is actually just a hint - miniaudio will tell the backend what you want, but the
    backend is ultimately responsible for what it gives you. You cannot assume you will get exactly what you ask for.
    
    When delivering data to and from a device you need to make sure it's in the correct format which you can set through the device configuration. You just set the
    format that you want to use and miniaudio will perform all of the necessary conversion for you internally. When delivering data to and from the callback you
    can assume the format is the same as what you requested when you initialized the device. See Remarks for more details on miniaudio's data conversion pipeline.
    
    
    Parameters
    ----------
    pContext (in, optional)
    		A pointer to the context that owns the device. This can be null, in which case it creates a default context internally.
    
    pConfig (in)
    		A pointer to the device configuration. Cannot be null. See remarks for details.
    
    pDevice (out)
    		A pointer to the device object being initialized.
    
    
    Return Value
    ------------
    MA_SUCCESS if successful; any other error code otherwise.
    
    
    Thread Safety
    -------------
    Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to
    calling this at the same time as `ma_device_uninit()`.
    
    
    Callback Safety
    ---------------
    Unsafe. It is not safe to call this inside any callback.
    
    
    Remarks
    -------
    Setting `pContext` to NULL will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so:
    
    		```c
    		ma_context_init(NULL, 0, NULL, &context);
    		```
    
    Do not set `pContext` to NULL if you are needing to open multiple devices. You can, however, use NULL when initializing the first device, and then use
    device.pContext for the initialization of other devices.
    
    The device can be configured via the `pConfig` argument. The config object is initialized with `ma_device_config_init()`. Individual configuration settings can
    then be set directly on the structure. Below are the members of the `ma_device_config` object.
    
    		deviceType
    				Must be `ma_device_type_playback`, `ma_device_type_capture`, `ma_device_type_duplex` of `ma_device_type_loopback`.
    
    		sampleRate
    				The sample rate, in hertz. The most common sample rates are 48000 and 44100. Setting this to 0 will use the device's native sample rate.
    
    		periodSizeInFrames
    				The desired size of a period in PCM frames. If this is 0, `periodSizeInMilliseconds` will be used instead. If both are 0 the default buffer size will
    				be used depending on the selected performance profile. This value affects latency. See below for details.
    
    		periodSizeInMilliseconds
    				The desired size of a period in milliseconds. If this is 0, `periodSizeInFrames` will be used instead. If both are 0 the default buffer size will be
    				used depending on the selected performance profile. The value affects latency. See below for details.
    
    		periods
    				The number of periods making up the device's entire buffer. The total buffer size is `periodSizeInFrames` or `periodSizeInMilliseconds` multiplied by
    				this value. This is just a hint as backends will be the ones who ultimately decide how your periods will be configured.
    
    		performanceProfile
    				A hint to miniaudio as to the performance requirements of your program. Can be either `ma_performance_profile_low_latency` (default) or
    				`ma_performance_profile_conservative`. This mainly affects the size of default buffers and can usually be left at its default value.
    
    		noPreSilencedOutputBuffer
    				When set to true, the contents of the output buffer passed into the data callback will be left undefined. When set to false (default), the contents of
    				the output buffer will be cleared the zero. You can use this to avoid the overhead of zeroing out the buffer if you can guarantee that your data
    				callback will write to every sample in the output buffer, or if you are doing your own clearing.
    
    		noClip
    

    When set to true, the contents of the output buffer are left alone after returning and it will be left up to the backend itself to decide whether or not to clip. When set to false (default), the contents of the output buffer passed into the data callback will be clipped after returning. This only

    				applies when the playback sample format is f32.
    
    		noDisableDenormals
    				By default, miniaudio will disable denormals when the data callback is called. Setting this to true will prevent the disabling of denormals.
    
    		noFixedSizedCallback
    

    Allows miniaudio to fire the data callback with any frame count. When this is set to false (the default), the data callback will be fired with a consistent frame count as specified by periodSizeInFrames or periodSizeInMilliseconds. When set to true, miniaudio will fire the callback with whatever the backend requests, which could be anything.

    		dataCallback
    				The callback to fire whenever data is ready to be delivered to or from the device.
    
    		notificationCallback
    				The callback to fire when something has changed with the device, such as whether or not it has been started or stopped.
    
    		pUserData
    				The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`.
    
    		resampling.algorithm
    				The resampling algorithm to use when miniaudio needs to perform resampling between the rate specified by `sampleRate` and the device's native rate. The
    				default value is `ma_resample_algorithm_linear`, and the quality can be configured with `resampling.linear.lpfOrder`.
    
    		resampling.pBackendVTable
    				A pointer to an optional vtable that can be used for plugging in a custom resampler.
    
    		resampling.pBackendUserData
    				A pointer that will passed to callbacks in pBackendVTable.
    
    		resampling.linear.lpfOrder
    				The linear resampler applies a low-pass filter as part of its processing for anti-aliasing. This setting controls the order of the filter. The higher
    				the value, the better the quality, in general. Setting this to 0 will disable low-pass filtering altogether. The maximum value is
    				`MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`.
    
    		playback.pDeviceID
    				A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this NULL (default) will use the system's
    				default playback device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
    
    		playback.format
    				The sample format to use for playback. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
    				initialization from the device object directly with `device.playback.format`.
    
    		playback.channels
    				The number of channels to use for playback. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
    				from the device object directly with `device.playback.channels`.
    
    		playback.pChannelMap
    				The channel map to use for playback. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
    				device object direct with `device.playback.pChannelMap`. When set, the buffer should contain `channels` items.
    
    		playback.shareMode
    				The preferred share mode to use for playback. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
    				exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
    				ma_share_mode_shared and reinitializing.
    
    		capture.pDeviceID
    				A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this NULL (default) will use the system's
    				default capture device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
    
    		capture.format
    				The sample format to use for capture. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
    				initialization from the device object directly with `device.capture.format`.
    
    		capture.channels
    				The number of channels to use for capture. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
    				from the device object directly with `device.capture.channels`.
    
    		capture.pChannelMap
    				The channel map to use for capture. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
    				device object direct with `device.capture.pChannelMap`. When set, the buffer should contain `channels` items.
    
    		capture.shareMode
    				The preferred share mode to use for capture. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
    				exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
    				ma_share_mode_shared and reinitializing.
    
    		wasapi.noAutoConvertSRC
    				WASAPI only. When set to true, disables WASAPI's automatic resampling and forces the use of miniaudio's resampler. Defaults to false.
    
    		wasapi.noDefaultQualitySRC
    				WASAPI only. Only used when `wasapi.noAutoConvertSRC` is set to false. When set to true, disables the use of `AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY`.
    				You should usually leave this set to false, which is the default.
    
    		wasapi.noAutoStreamRouting
    				WASAPI only. When set to true, disables automatic stream routing on the WASAPI backend. Defaults to false.
    
    		wasapi.noHardwareOffloading
    				WASAPI only. When set to true, disables the use of WASAPI's hardware offloading feature. Defaults to false.
    
    		alsa.noMMap
    				ALSA only. When set to true, disables MMap mode. Defaults to false.
    
    		alsa.noAutoFormat
    				ALSA only. When set to true, disables ALSA's automatic format conversion by including the SND_PCM_NO_AUTO_FORMAT flag. Defaults to false.
    
    		alsa.noAutoChannels
    				ALSA only. When set to true, disables ALSA's automatic channel conversion by including the SND_PCM_NO_AUTO_CHANNELS flag. Defaults to false.
    
    		alsa.noAutoResample
    				ALSA only. When set to true, disables ALSA's automatic resampling by including the SND_PCM_NO_AUTO_RESAMPLE flag. Defaults to false.
    
    		pulse.pStreamNamePlayback
    				PulseAudio only. Sets the stream name for playback.
    
    		pulse.pStreamNameCapture
    				PulseAudio only. Sets the stream name for capture.
    
    		pulse.channelMap
    			PulseAudio only. Sets the channel map that is requested from PulseAudio. See MA_PA_CHANNEL_MAP_* constants. Defaults to MA_PA_CHANNEL_MAP_AIFF.
    
    		coreaudio.allowNominalSampleRateChange
    				Core Audio only. Desktop only. When enabled, allows the sample rate of the device to be changed at the operating system level. This
    				is disabled by default in order to prevent intrusive changes to the user's system. This is useful if you want to use a sample rate
    				that is known to be natively supported by the hardware thereby avoiding the cost of resampling. When set to true, miniaudio will
    				find the closest match between the sample rate requested in the device config and the sample rates natively supported by the
    				hardware. When set to false, the sample rate currently set by the operating system will always be used.
    
    		opensl.streamType
    				OpenSL only. Explicitly sets the stream type. If left unset (`ma_opensl_stream_type_default`), the
    				stream type will be left unset. Think of this as the type of audio you're playing.
    
    		opensl.recordingPreset
    				OpenSL only. Explicitly sets the type of recording your program will be doing. When left
    				unset, the recording preset will be left unchanged.
    
    		aaudio.usage
    				AAudio only. Explicitly sets the nature of the audio the program will be consuming. When
    				left unset, the usage will be left unchanged.
    
    		aaudio.contentType
    				AAudio only. Sets the content type. When left unset, the content type will be left unchanged.
    
    		aaudio.inputPreset
    				AAudio only. Explicitly sets the type of recording your program will be doing. When left
    				unset, the input preset will be left unchanged.
    
    		aaudio.noAutoStartAfterReroute
    				AAudio only. Controls whether or not the device should be automatically restarted after a
    				stream reroute. When set to false (default) the device will be restarted automatically;
    				otherwise the device will be stopped.
    
    
    Once initialized, the device's config is immutable. If you need to change the config you will need to initialize a new device.
    
    After initializing the device it will be in a stopped state. To start it, use `ma_device_start()`.
    
    If both `periodSizeInFrames` and `periodSizeInMilliseconds` are set to zero, it will default to `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY` or
    `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE`, depending on whether or not `performanceProfile` is set to `ma_performance_profile_low_latency` or
    `ma_performance_profile_conservative`.
    
    If you request exclusive mode and the backend does not support it an error will be returned. For robustness, you may want to first try initializing the device
    in exclusive mode, and then fall back to shared mode if required. Alternatively you can just request shared mode (the default if you leave it unset in the
    config) which is the most reliable option. Some backends do not have a practical way of choosing whether or not the device should be exclusive or not (ALSA,
    for example) in which case it just acts as a hint. Unless you have special requirements you should try avoiding exclusive mode as it's intrusive to the user.
    Starting with Windows 10, miniaudio will use low-latency shared mode where possible which may make exclusive mode unnecessary.
    
    When sending or receiving data to/from a device, miniaudio will internally perform a format conversion to convert between the format specified by the config
    and the format used internally by the backend. If you pass in 0 for the sample format, channel count, sample rate _and_ channel map, data transmission will run
    on an optimized pass-through fast path. You can retrieve the format, channel count and sample rate by inspecting the `playback/capture.format`,
    `playback/capture.channels` and `sampleRate` members of the device object.
    
    When compiling for UWP you must ensure you call this function on the main UI thread because the operating system may need to present the user with a message
    asking for permissions. Please refer to the official documentation for ActivateAudioInterfaceAsync() for more information.
    
    ALSA Specific: When initializing the default device, requesting shared mode will try using the "dmix" device for playback and the "dsnoop" device for capture.
    If these fail it will try falling back to the "hw" device.
    
    
    Example 1 - Simple Initialization
    ---------------------------------
    This example shows how to initialize a simple playback device using a standard configuration. If you are just needing to do simple playback from the default
    playback device this is usually all you need.
    
    ```c
    ma_device_config config = ma_device_config_init(ma_device_type_playback);
    config.playback.format   = ma_format_f32;
    config.playback.channels = 2;
    config.sampleRate        = 48000;
    config.dataCallback      = ma_data_callback;
    config.pMyUserData       = pMyUserData;
    
    ma_device device;
    ma_result result = ma_device_init(NULL, &config, &device);
    if (result != MA_SUCCESS) {
    		// Error
    }
    ```
    
    
    Example 2 - Advanced Initialization
    -----------------------------------
    This example shows how you might do some more advanced initialization. In this hypothetical example we want to control the latency by setting the buffer size
    and period count. We also want to allow the user to be able to choose which device to output from which means we need a context so we can perform device
    enumeration.
    
    ```c
    ma_context context;
    ma_result result = ma_context_init(NULL, 0, NULL, &context);
    if (result != MA_SUCCESS) {
    		// Error
    }
    
    ma_device_info* pPlaybackDeviceInfos;
    ma_uint32 playbackDeviceCount;
    result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL);
    if (result != MA_SUCCESS) {
    		// Error
    }
    
    // ... choose a device from pPlaybackDeviceInfos ...
    
    ma_device_config config = ma_device_config_init(ma_device_type_playback);
    config.playback.pDeviceID       = pMyChosenDeviceID;    // <-- Get this from the `id` member of one of the `ma_device_info` objects returned by ma_context_get_devices().
    config.playback.format          = ma_format_f32;
    config.playback.channels        = 2;
    config.sampleRate               = 48000;
    config.dataCallback             = ma_data_callback;
    config.pUserData                = pMyUserData;
    config.periodSizeInMilliseconds = 10;
    config.periods                  = 3;
    
    ma_device device;
    result = ma_device_init(&context, &config, &device);
    if (result != MA_SUCCESS) {
    		// Error
    }
    ```
    
    
    See Also
    --------
    ma_device_config_init()
    ma_device_uninit()
    ma_device_start()
    ma_context_init()
    ma_context_get_devices()
    ma_context_enumerate_devices()
    

    device_init_ex ¶

    device_init_ex :: proc "c" (backends: [^]backend, backendCount: u32, pContextConfig: ^context_config, pConfig: ^device_config, pDevice: ^device) -> result ---
     

    Initializes a device without a context, with extra parameters for controlling the configuration of the internal self-managed context.

    This is the same as ma_device_init(), only instead of a context being passed in, the parameters from ma_context_init() are passed in instead. This function allows you to configure the internally created context.

    Parameters ---------- backends (in, optional)

    	A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
    
    

    backendCount (in, optional)

    	The number of items in `backend`. Ignored if `backend` is NULL.
    
    

    pContextConfig (in, optional)

    	The context configuration.
    
    

    pConfig (in)

    	A pointer to the device configuration. Cannot be null. See remarks for details.
    
    

    pDevice (out)

    	A pointer to the device object being initialized.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to calling this at the same time as ma_device_uninit().

    Callback Safety --------------- Unsafe. It is not safe to call this inside any callback.

    Remarks ------- You only need to use this function if you want to configure the context differently to its defaults. You should never use this function if you want to manage your own context.

    See the documentation for ma_context_init() for information on the different context configuration options.

    See Also -------- ma_device_init() ma_device_uninit() ma_device_config_init() ma_context_init()

    device_is_started ¶

    device_is_started :: proc "c" (pDevice: ^device) -> b32 ---
     

    Determines whether or not the device is started.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose start state is being retrieved.
    
    
    

    Return Value ------------ True if the device is started, false otherwise.

    Thread Safety ------------- Safe. If another thread calls ma_device_start() or ma_device_stop() at this same time as this function is called, there's a very small chance the return value will be out of sync.

    Callback Safety --------------- Safe. This is implemented as a simple accessor.

    See Also -------- ma_device_start() ma_device_stop()

    device_job_thread_config_init ¶

    device_job_thread_config_init :: proc "c" () -> device_job_thread_config ---

    device_job_thread_init ¶

    device_job_thread_init :: proc "c" (pConfig: ^device_job_thread_config, pAllocationCallbacks: ^allocation_callbacks, pJobThread: ^device_job_thread) -> result ---

    device_job_thread_next ¶

    device_job_thread_next :: proc "c" (pJobThread: ^device_job_thread, pJob: ^job) -> result ---

    device_job_thread_post ¶

    device_job_thread_post :: proc "c" (pJobThread: ^device_job_thread, pJob: ^job) -> result ---

    device_job_thread_uninit ¶

    device_job_thread_uninit :: proc "c" (pJobThread: ^device_job_thread, pAllocationCallbacks: ^allocation_callbacks) ---

    device_post_init ¶

    device_post_init :: proc "c" (pDevice: ^device, deviceType: device_type, pPlaybackDescriptor, pCaptureDescriptor: ^device_descriptor) -> result ---
     

    Performs post backend initialization routines for setting up internal data conversion.

    This should be called whenever the backend is initialized. The only time this should be called from outside of miniaudio is if you're implementing a custom backend, and you would only do it if you are reinitializing the backend due to rerouting or reinitializing for some reason.

    Parameters ---------- pDevice [in]

    	A pointer to the device.
    
    

    deviceType [in]

    	The type of the device that was just reinitialized.
    
    

    pPlaybackDescriptor [in]

    	The descriptor of the playback device containing the internal data format and buffer sizes.
    
    

    pPlaybackDescriptor [in]

    	The descriptor of the capture device containing the internal data format and buffer sizes.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error otherwise.

    Thread Safety ------------- Unsafe. This will be reinitializing internal data converters which may be in use by another thread.

    Callback Safety --------------- Unsafe. This will be reinitializing internal data converters which may be in use by the callback.

    Remarks ------- For a duplex device, you can call this for only one side of the system. This is why the deviceType is specified as a parameter rather than deriving it from the device.

    You do not need to call this manually unless you are doing a custom backend, in which case you need only do it if you're manually performing rerouting or reinitialization.

    device_set_master_volume ¶

    device_set_master_volume :: proc "c" (pDevice: ^device, volume: f32) -> result ---
     

    Sets the master volume factor for the device.

    The volume factor must be between 0 (silence) and 1 (full volume). Use ma_device_set_master_volume_db() to use decibel notation, where 0 is full volume and values less than 0 decreases the volume.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose volume is being set.
    
    

    volume (in)

    	The new volume factor. Must be >= 0.
    
    
    

    Return Value ------------ MA_SUCCESS if the volume was set successfully. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if volume is negative.

    Thread Safety ------------- Safe. This just sets a local member of the device object.

    Callback Safety --------------- Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.

    Remarks ------- This applies the volume factor across all channels.

    This does not change the operating system's volume. It only affects the volume for the given ma_device object's audio stream.

    See Also -------- ma_device_get_master_volume() ma_device_set_master_volume_db() ma_device_get_master_volume_db()

    device_set_master_volume_db ¶

    device_set_master_volume_db :: proc "c" (pDevice: ^device, gainDB: f32) -> result ---
     

    Sets the master volume for the device as gain in decibels.

    A gain of 0 is full volume, whereas a gain of < 0 will decrease the volume.

    Parameters ---------- pDevice (in)

    	A pointer to the device whose gain is being set.
    
    

    gainDB (in)

    	The new volume as gain in decibels. Must be less than or equal to 0, where 0 is full volume and anything less than 0 decreases the volume.
    
    
    

    Return Value ------------ MA_SUCCESS if the volume was set successfully. MA_INVALID_ARGS if pDevice is NULL. MA_INVALID_ARGS if the gain is > 0.

    Thread Safety ------------- Safe. This just sets a local member of the device object.

    Callback Safety --------------- Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.

    Remarks ------- This applies the gain across all channels.

    This does not change the operating system's volume. It only affects the volume for the given ma_device object's audio stream.

    See Also -------- ma_device_get_master_volume_gain_db() ma_device_set_master_volume() ma_device_get_master_volume()

    device_start ¶

    device_start :: proc "c" (pDevice: ^device) -> result ---
     

    Starts the device. For playback devices this begins playback. For capture devices it begins recording.

    Use ma_device_stop() to stop the device.

    Parameters ---------- pDevice (in)

    	A pointer to the device to start.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Safe. It's safe to call this from any thread with the exception of the callback thread.

    Callback Safety --------------- Unsafe. It is not safe to call this inside any callback.

    Remarks ------- For a playback device, this will retrieve an initial chunk of audio data from the client before returning. The reason for this is to ensure there is valid audio data in the buffer, which needs to be done before the device begins playback.

    This API waits until the backend device has been started for real by the worker thread. It also waits on a mutex for thread-safety.

    Do not call this in any callback.

    See Also -------- ma_device_stop()

    device_stop ¶

    device_stop :: proc "c" (pDevice: ^device) -> result ---
     

    Stops the device. For playback devices this stops playback. For capture devices it stops recording.

    Use ma_device_start() to start the device again.

    Parameters ---------- pDevice (in)

    	A pointer to the device to stop.
    
    
    

    Return Value ------------ MA_SUCCESS if successful; any other error code otherwise.

    Thread Safety ------------- Safe. It's safe to call this from any thread with the exception of the callback thread.

    Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.

    Remarks ------- This API needs to wait on the worker thread to stop the backend device properly before returning. It also waits on a mutex for thread-safety. In addition, some backends need to wait for the device to finish playback/recording of the current fragment which can take some time (usually proportionate to the buffer size that was specified at initialization time).

    Backends are required to either pause the stream in-place or drain the buffer if pausing is not possible. The reason for this is that stopping the device and the resuming it with ma_device_start() (which you might do when your program loses focus) may result in a situation where those samples are never output to the speakers or received from the microphone which can in turn result in de-syncs.

    Do not call this in any callback.

    See Also -------- ma_device_start()

    device_uninit ¶

    device_uninit :: proc "c" (pDevice: ^device) ---
     

    Uninitializes a device.

    This will explicitly stop the device. You do not need to call ma_device_stop() beforehand, but it's harmless if you do.

    Parameters ---------- pDevice (in)

    	A pointer to the device to stop.
    
    
    

    Return Value ------------ Nothing

    Thread Safety ------------- Unsafe. As soon as this API is called the device should be considered undefined.

    Callback Safety --------------- Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.

    See Also -------- ma_device_init() ma_device_stop()

    duplex_rb_init ¶

    duplex_rb_init :: proc "c" (
    	captureFormat:                                                format, 
    	captureChannels:                                              u32, 
    	sampleRate:                                                   u32, 
    	captureInternalSampleRate, captureInternalPeriodSizeInFrames: u32, 
    	pAllocationCallbacks:                                         ^allocation_callbacks, 
    	pRB:                                                          ^duplex_rb, 
    ) -> result ---

    duplex_rb_uninit ¶

    duplex_rb_uninit :: proc "c" (pRB: ^duplex_rb) -> result ---

    encoder_config_init ¶

    encoder_config_init :: proc "c" (encodingFormat: encoding_format, format: format, channels: u32, sampleRate: u32) -> encoder_config ---

    encoder_init ¶

    encoder_init :: proc "c" (onWrite: encoder_write_proc, onSeek: encoder_seek_proc, pUserData: rawptr, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---

    encoder_init_file ¶

    encoder_init_file :: proc "c" (pFilePath: cstring, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---

    encoder_init_file_w ¶

    encoder_init_file_w :: proc "c" (pFilePath: [^]u16, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---

    encoder_init_vfs ¶

    encoder_init_vfs :: proc "c" (pVFS: ^vfs, pFilePath: cstring, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---

    encoder_init_vfs_w ¶

    encoder_init_vfs_w :: proc "c" (pVFS: ^vfs, pFilePath: [^]u16, pConfig: ^encoder_config, pEncoder: ^encoder) -> result ---

    encoder_uninit ¶

    encoder_uninit :: proc "c" (pEncoder: ^encoder) ---

    encoder_write_pcm_frames ¶

    encoder_write_pcm_frames :: proc "c" (pEncoder: ^encoder, FramesIn: rawptr, frameCount: u64, pFramesWritten: ^u64) -> result ---

    engine_config_init ¶

    engine_config_init :: proc "c" () -> engine_config ---

    engine_find_closest_listener ¶

    engine_find_closest_listener :: proc "c" (pEngine: ^engine, absolutePosX, absolutePosY, absolutePosZ: f32) -> u32 ---

    engine_get_channels ¶

    engine_get_channels :: proc "c" (pEngine: ^engine) -> u32 ---

    engine_get_device ¶

    engine_get_device :: proc "c" (pEngine: ^engine) -> ^device ---

    engine_get_endpoint ¶

    engine_get_endpoint :: proc "c" (pEngine: ^engine) -> ^node ---

    engine_get_gain_db ¶

    engine_get_gain_db :: proc "c" (pEngine: ^engine) -> f32 ---

    engine_get_listener_count ¶

    engine_get_listener_count :: proc "c" (pEngine: ^engine) -> u32 ---

    engine_get_log ¶

    engine_get_log :: proc "c" (pEngine: ^engine) -> ^log ---

    engine_get_node_graph ¶

    engine_get_node_graph :: proc "c" (pEngine: ^engine) -> ^node_graph ---

    engine_get_resource_manager ¶

    engine_get_resource_manager :: proc "c" (pEngine: ^engine) -> ^resource_manager ---

    engine_get_sample_rate ¶

    engine_get_sample_rate :: proc "c" (pEngine: ^engine) -> u32 ---

    engine_get_time ¶

    engine_get_time :: proc "c" (pEngine: ^engine) -> u64 ---

    engine_get_time_in_milliseconds ¶

    engine_get_time_in_milliseconds :: proc "c" (pEngine: ^engine) -> u64 ---

    engine_get_time_in_pcm_frames ¶

    engine_get_time_in_pcm_frames :: proc "c" (pEngine: ^engine) -> u64 ---

    engine_get_volume ¶

    engine_get_volume :: proc "c" (pEngine: ^engine) -> f32 ---

    engine_init ¶

    engine_init :: proc "c" (pConfig: ^engine_config, pEngine: ^engine) -> result ---

    engine_listener_get_cone ¶

    engine_listener_get_cone :: proc "c" (pEngine: ^engine, listenerIndex: u32, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain: ^f32) ---

    engine_listener_get_direction ¶

    engine_listener_get_direction :: proc "c" (pEngine: ^engine, listenerIndex: u32) -> vec3f ---

    engine_listener_get_position ¶

    engine_listener_get_position :: proc "c" (pEngine: ^engine, listenerIndex: u32) -> vec3f ---

    engine_listener_get_velocity ¶

    engine_listener_get_velocity :: proc "c" (pEngine: ^engine, listenerIndex: u32) -> vec3f ---

    engine_listener_get_world_up ¶

    engine_listener_get_world_up :: proc "c" (pEngine: ^engine, listenerIndex: u32) -> vec3f ---

    engine_listener_is_enabled ¶

    engine_listener_is_enabled :: proc "c" (pEngine: ^engine, listenerIndex: u32) -> b32 ---

    engine_listener_set_cone ¶

    engine_listener_set_cone :: proc "c" (pEngine: ^engine, listenerIndex: u32, innerAngleInRadians, outerAngleInRadians, outerGain: f32) ---

    engine_listener_set_direction ¶

    engine_listener_set_direction :: proc "c" (pEngine: ^engine, listenerIndex: u32, x, y, z: f32) ---

    engine_listener_set_enabled ¶

    engine_listener_set_enabled :: proc "c" (pEngine: ^engine, listenerIndex: u32, isEnabled: b32) ---

    engine_listener_set_position ¶

    engine_listener_set_position :: proc "c" (pEngine: ^engine, listenerIndex: u32, x, y, z: f32) ---

    engine_listener_set_velocity ¶

    engine_listener_set_velocity :: proc "c" (pEngine: ^engine, listenerIndex: u32, x, y, z: f32) ---

    engine_listener_set_world_up ¶

    engine_listener_set_world_up :: proc "c" (pEngine: ^engine, listenerIndex: u32, x, y, z: f32) ---

    engine_node_config_init ¶

    engine_node_config_init :: proc "c" (pEngine: ^engine, type: engine_node_type, flags: bit_set[sound_flag; u32]) -> engine_node_config ---

    engine_node_get_heap_size ¶

    engine_node_get_heap_size :: proc "c" (pConfig: ^engine_node_config, pHeapSizeInBytes: ^uint) -> result ---

    engine_node_init ¶

    engine_node_init :: proc "c" (pConfig: ^engine_node_config, pAllocationCallbacks: ^allocation_callbacks, pEngineNode: ^engine_node) -> result ---

    engine_node_init_preallocated ¶

    engine_node_init_preallocated :: proc "c" (pConfig: ^engine_node_config, pHeap: rawptr, pEngineNode: ^engine_node) -> result ---

    engine_node_uninit ¶

    engine_node_uninit :: proc "c" (pEngineNode: ^engine_node, pAllocationCallbacks: ^allocation_callbacks) ---

    engine_play_sound ¶

    engine_play_sound :: proc "c" (pEngine: ^engine, pFilePath: cstring, pGroup: ^sound_group) -> result ---
     

    Fire and forget.

    engine_play_sound_ex ¶

    engine_play_sound_ex :: proc "c" (pEngine: ^engine, pFilePath: cstring, pNode: ^node, nodeInputBusIndex: u32) -> result ---

    engine_read_pcm_frames ¶

    engine_read_pcm_frames :: proc "c" (pEngine: ^engine, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    engine_set_gain_db ¶

    engine_set_gain_db :: proc "c" (pEngine: ^engine, gainDB: f32) -> result ---

    engine_set_time ¶

    engine_set_time :: proc "c" (pEngine: ^engine, globalTime: u64) -> result ---

    engine_set_time_in_milliseconds ¶

    engine_set_time_in_milliseconds :: proc "c" (pEngine: ^engine, globalTime: u64) -> result ---

    engine_set_time_in_pcm_frames ¶

    engine_set_time_in_pcm_frames :: proc "c" (pEngine: ^engine, globalTime: u64) -> result ---

    engine_set_volume ¶

    engine_set_volume :: proc "c" (pEngine: ^engine, volume: f32) -> result ---

    engine_start ¶

    engine_start :: proc "c" (pEngine: ^engine) -> result ---

    engine_stop ¶

    engine_stop :: proc "c" (pEngine: ^engine) -> result ---

    engine_uninit ¶

    engine_uninit :: proc "c" (pEngine: ^engine) ---

    event_init ¶

    event_init :: proc "c" (pEvent: ^event) -> result ---
     

    Initializes an auto-reset event.

    event_signal ¶

    event_signal :: proc "c" (pEvent: ^event) -> result ---
     

    Signals the specified auto-reset event.

    event_uninit ¶

    event_uninit :: proc "c" (pEvent: ^event) ---
     

    Uninitializes an auto-reset event.

    event_wait ¶

    event_wait :: proc "c" (pEvent: ^event) -> result ---
     

    Waits for the specified auto-reset event to become signalled.

    fader_config_init ¶

    fader_config_init :: proc "c" (format: format, channels, sampleRate: u32) -> fader_config ---

    fader_get_current_volume ¶

    fader_get_current_volume :: proc "c" (pFader: ^fader) -> f32 ---

    fader_get_data_format ¶

    fader_get_data_format :: proc "c" (pFader: ^fader, pFormat: ^format, pChannels, pSampleRate: ^u32) ---

    fader_init ¶

    fader_init :: proc "c" (pConfig: ^fader_config, pFader: ^fader) -> result ---

    fader_process_pcm_frames ¶

    fader_process_pcm_frames :: proc "c" (pFader: ^fader, pFramesOut, pFramesIn: rawptr, frameCount: u64) -> result ---

    fader_set_fade ¶

    fader_set_fade :: proc "c" (pFader: ^fader, volumeBeg, volumeEnd: f32, lengthInFrames: u64) ---

    fader_set_fade_ex ¶

    fader_set_fade_ex :: proc "c" (pFader: ^fader, volumeBeg, volumeEnd: f32, lengthInFrames: u64, startOffsetInFrames: i64) ---

    fence_acquire ¶

    fence_acquire :: proc "c" (pFence: ^fence) -> result ---
     

    Increment counter.

    fence_init ¶

    fence_init :: proc "c" (pFence: ^fence) -> result ---

    fence_release ¶

    fence_release :: proc "c" (pFence: ^fence) -> result ---
     

    Decrement counter.

    fence_uninit ¶

    fence_uninit :: proc "c" (pFence: ^fence) ---

    fence_wait ¶

    fence_wait :: proc "c" (pFence: ^fence) -> result ---
     

    Wait for counter to reach 0.

    free ¶

    free :: proc "c" (p: rawptr, pAllocationCallbacks: ^allocation_callbacks) ---
     

    free()

    gainer_config_init ¶

    gainer_config_init :: proc "c" (channels, smoothTimeInFrames: u32) -> gainer_config ---

    gainer_get_heap_size ¶

    gainer_get_heap_size :: proc "c" (pConfig: ^gainer_config, pHeapSizeInBytes: ^uint) -> result ---

    gainer_get_master_volume ¶

    gainer_get_master_volume :: proc "c" (pGainer: ^gainer, volume: ^f32) -> result ---

    gainer_init ¶

    gainer_init :: proc "c" (pConfig: ^gainer_config, pAllocationCallbacks: ^allocation_callbacks, pGainer: ^gainer) -> result ---

    gainer_init_preallocated ¶

    gainer_init_preallocated :: proc "c" (pConfig: ^gainer_config, pHeap: rawptr, pGainer: ^gainer) -> result ---

    gainer_process_pcm_frames ¶

    gainer_process_pcm_frames :: proc "c" (pGainer: ^gainer, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    gainer_set_gain ¶

    gainer_set_gain :: proc "c" (pGainer: ^gainer, newGain: f32) -> result ---

    gainer_set_gains ¶

    gainer_set_gains :: proc "c" (pGainer: ^gainer, pNewGains: [^]f32) -> result ---

    gainer_set_master_volume ¶

    gainer_set_master_volume :: proc "c" (pGainer: ^gainer, volume: f32) -> result ---

    gainer_uninit ¶

    gainer_uninit :: proc "c" (pGainer: ^gainer, pAllocationCallbacks: ^allocation_callbacks) ---

    get_backend_from_name ¶

    get_backend_from_name :: proc "c" (pBackendName: cstring, pBackend: ^backend) -> result ---
     

    Retrieves the backend enum from the given name.

    get_backend_name ¶

    get_backend_name :: proc "c" (backend: backend) -> cstring ---
     

    Retrieves a friendly name for a backend.

    get_bytes_per_frame ¶

    get_bytes_per_frame :: proc "c" (format: format, channels: u32) -> u32 {…}

    get_bytes_per_sample ¶

    get_bytes_per_sample :: proc "c" (format: format) -> u32 ---
     

    Retrieves the size of a sample in bytes for the given format.

    This API is efficient and is implemented using a lookup table.

    Thread Safety: SAFE This API is pure.

    get_enabled_backends ¶

    get_enabled_backends :: proc "c" (pBackends: [^]backend, backendCap: uint, pBackendCount: ^uint) -> result ---
     

    Retrieves compile-time enabled backends.

    Parameters ---------- pBackends (out, optional)

    	A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting
    	the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends.
    
    

    backendCap (in)

    	The capacity of the `pBackends` buffer.
    
    

    pBackendCount (out)

    	A pointer to the variable that will receive the enabled backend count.
    
    
    

    Return Value ------------ MA_SUCCESS if successful. MA_INVALID_ARGS if pBackendCount is NULL. MA_NO_SPACE if the capacity of pBackends is not large enough.

    If MA_NO_SPACE is returned, the pBackends buffer will be filled with *pBackendCount values.

    Thread Safety ------------- Safe.

    Callback Safety --------------- Safe.

    Remarks ------- If you want to retrieve the number of backends so you can determine the capacity of pBackends buffer, you can call this function with pBackends set to NULL.

    This will also enumerate the null backend. If you don't want to include this you need to check for ma_backend_null when you enumerate over the returned backends and handle it appropriately. Alternatively, you can disable it at compile time with MA_NO_NULL.

    The returned backends are determined based on compile time settings, not the platform it's currently running on. For example, PulseAudio will be returned if it was enabled at compile time, even when the user doesn't actually have PulseAudio installed.

    Example 1 --------- The example below retrieves the enabled backend count using a fixed sized buffer allocated on the stack. The buffer is given a capacity of MA_BACKEND_COUNT which will guarantee it'll be large enough to store all available backends. Since MA_BACKEND_COUNT is always a relatively small value, this should be suitable for most scenarios.

    ` ma_backend enabledBackends[MA_BACKEND_COUNT]; size_t enabledBackendCount;

    result = ma_get_enabled_backends(enabledBackends, MA_BACKEND_COUNT, &enabledBackendCount); if (result != MA_SUCCESS) {

    	// Failed to retrieve enabled backends. Should never happen in this example since all inputs are valid.
    

    } `

    See Also -------- ma_is_backend_enabled()

    get_format_name ¶

    get_format_name :: proc "c" (format: format) -> cstring ---
     

    Retrieves a friendly name for a format.

    hishelf2_config_init ¶

    hishelf2_config_init :: proc "c" (
    	format:             format, 
    	channels:           u32, 
    	sampleRate:         u32, 
    	gainDB, shelfSlope, 
    	frequency:          f64, 
    ) -> hishelf_config ---

    hishelf2_get_heap_size ¶

    hishelf2_get_heap_size :: proc "c" (pConfig: ^hishelf_config, pHeapSizeInBytes: ^uint) -> result ---

    hishelf2_get_latency ¶

    hishelf2_get_latency :: proc "c" (pFilter: ^hishelf2) -> u32 ---

    hishelf2_init ¶

    hishelf2_init :: proc "c" (pConfig: ^hishelf_config, pAllocationCallbacks: ^allocation_callbacks, pFilter: ^hishelf2) -> result ---

    hishelf2_init_preallocated ¶

    hishelf2_init_preallocated :: proc "c" (pConfig: ^hishelf_config, pHeap: rawptr, pFilter: ^hishelf2) -> result ---

    hishelf2_process_pcm_frames ¶

    hishelf2_process_pcm_frames :: proc "c" (pFilter: ^hishelf2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    hishelf2_reinit ¶

    hishelf2_reinit :: proc "c" (pConfig: ^hishelf_config, pFilter: ^hishelf2) -> result ---

    hishelf2_uninit ¶

    hishelf2_uninit :: proc "c" (pFilter: ^hishelf2, pAllocationCallbacks: ^allocation_callbacks) ---

    hishelf_node_config_init ¶

    hishelf_node_config_init :: proc "c" (channels, sampleRate: u32, gainDB, q, frequency: f64) -> hishelf_node_config ---

    hishelf_node_init ¶

    hishelf_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^hishelf_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^hishelf_node) -> result ---

    hishelf_node_reinit ¶

    hishelf_node_reinit :: proc "c" (pConfig: ^hishelf_config, pNode: ^hishelf_node) -> result ---

    hishelf_node_uninit ¶

    hishelf_node_uninit :: proc "c" (pNode: ^hishelf_node, pAllocationCallbacks: ^allocation_callbacks) ---

    hpf1_config_init ¶

    hpf1_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency: f64) -> hpf1_config ---

    hpf1_get_heap_size ¶

    hpf1_get_heap_size :: proc "c" (pConfig: ^hpf1_config, pHeapSizeInBytes: ^uint) -> result ---

    hpf1_get_latency ¶

    hpf1_get_latency :: proc "c" (pHPF: ^hpf1) -> u32 ---

    hpf1_init ¶

    hpf1_init :: proc "c" (pConfig: ^hpf1_config, pAllocationCallbacks: ^allocation_callbacks, pHPF: ^hpf1) -> result ---

    hpf1_init_preallocated ¶

    hpf1_init_preallocated :: proc "c" (pConfig: ^hpf1_config, pHeap: rawptr, pLPF: ^hpf1) -> result ---

    hpf1_process_pcm_frames ¶

    hpf1_process_pcm_frames :: proc "c" (pHPF: ^hpf1, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    hpf1_reinit ¶

    hpf1_reinit :: proc "c" (pConfig: ^hpf1_config, pHPF: ^hpf1) -> result ---

    hpf1_uninit ¶

    hpf1_uninit :: proc "c" (pHPF: ^hpf1, pAllocationCallbacks: ^allocation_callbacks) ---

    hpf2_config_init ¶

    hpf2_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency, q: f64) -> hpf1_config ---

    hpf2_get_heap_size ¶

    hpf2_get_heap_size :: proc "c" (pConfig: ^hpf1_config, pHeapSizeInBytes: ^uint) -> result ---

    hpf2_get_latency ¶

    hpf2_get_latency :: proc "c" (pHPF: ^hpf2) -> u32 ---

    hpf2_init ¶

    hpf2_init :: proc "c" (pConfig: ^hpf1_config, pAllocationCallbacks: ^allocation_callbacks, pHPF: ^hpf2) -> result ---

    hpf2_init_preallocated ¶

    hpf2_init_preallocated :: proc "c" (pConfig: ^hpf1_config, pHeap: rawptr, pHPF: ^hpf2) -> result ---

    hpf2_process_pcm_frames ¶

    hpf2_process_pcm_frames :: proc "c" (pHPF: ^hpf2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    hpf2_reinit ¶

    hpf2_reinit :: proc "c" (pConfig: ^hpf1_config, pHPF: ^hpf2) -> result ---

    hpf2_uninit ¶

    hpf2_uninit :: proc "c" (pHPF: ^hpf2, pAllocationCallbacks: ^allocation_callbacks) ---

    hpf_config_init ¶

    hpf_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency: f64, order: u32) -> hpf_config ---

    hpf_get_heap_size ¶

    hpf_get_heap_size :: proc "c" (pConfig: ^hpf_config, pHeapSizeInBytes: ^uint) -> result ---

    hpf_get_latency ¶

    hpf_get_latency :: proc "c" (pHPF: ^hpf) -> u32 ---

    hpf_init ¶

    hpf_init :: proc "c" (pConfig: ^hpf_config, pAllocationCallbacks: ^allocation_callbacks, pHPF: ^hpf) -> result ---

    hpf_init_preallocated ¶

    hpf_init_preallocated :: proc "c" (pConfig: ^hpf_config, pHeap: rawptr, pLPF: ^hpf) -> result ---

    hpf_node_config_init ¶

    hpf_node_config_init :: proc "c" (channels, sampleRate: u32, cutoffFrequency: f64, order: u32) -> hpf_node_config ---

    hpf_node_init ¶

    hpf_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^hpf_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^hpf_node) -> result ---

    hpf_node_reinit ¶

    hpf_node_reinit :: proc "c" (pConfig: ^hpf_config, pNode: ^hpf_node) -> result ---

    hpf_node_uninit ¶

    hpf_node_uninit :: proc "c" (pNode: ^hpf_node, pAllocationCallbacks: ^allocation_callbacks) ---

    hpf_process_pcm_frames ¶

    hpf_process_pcm_frames :: proc "c" (pHPF: ^hpf, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    hpf_reinit ¶

    hpf_reinit :: proc "c" (pConfig: ^hpf_config, pHPF: ^hpf) -> result ---

    hpf_uninit ¶

    hpf_uninit :: proc "c" (pHPF: ^hpf, pAllocationCallbacks: ^allocation_callbacks) ---

    interleave_pcm_frames ¶

    interleave_pcm_frames :: proc "c" (format: format, channels: u32, frameCount: u64, ppDeinterleavedPCMFrames: ^rawptr, pInterleavedPCMFrames: rawptr) ---
     

    Interleaves a group of deinterleaved buffers.

    is_backend_enabled ¶

    is_backend_enabled :: proc "c" (backend: backend) -> b32 ---
     

    Determines whether or not the given backend is available by the compilation environment.

    is_loopback_supported ¶

    is_loopback_supported :: proc "c" (backend: backend) -> b32 ---
     

    Determines whether or not loopback mode is support by a backend.

    job_init ¶

    job_init :: proc "c" (code: u16) -> job ---

    job_process ¶

    job_process :: proc "c" (pJob: ^job) -> result ---

    job_queue_config_init ¶

    job_queue_config_init :: proc "c" (flags: bit_set[job_queue_flag; u32], capacity: u32) -> job_queue_config ---

    job_queue_get_heap_size ¶

    job_queue_get_heap_size :: proc "c" (pConfig: ^job_queue_config, pHeapSizeInBytes: ^uint) -> result ---

    job_queue_init ¶

    job_queue_init :: proc "c" (pConfig: ^job_queue_config, pAllocationCallbacks: ^allocation_callbacks, pQueue: ^job_queue) -> result ---

    job_queue_init_preallocated ¶

    job_queue_init_preallocated :: proc "c" (pConfig: ^job_queue_config, pHeap: rawptr, pQueue: ^job_queue) -> result ---

    job_queue_next ¶

    job_queue_next :: proc "c" (pQueue: ^job_queue, pJob: ^job) -> result ---
     

    Returns MA_CANCELLED if the next job is a quit job.

    job_queue_post ¶

    job_queue_post :: proc "c" (pQueue: ^job_queue, pJob: ^job) -> result ---

    job_queue_uninit ¶

    job_queue_uninit :: proc "c" (pQueue: ^job_queue, pAllocationCallbacks: ^allocation_callbacks) ---

    linear_resampler_config_init ¶

    linear_resampler_config_init :: proc "c" (format: format, channels: u32, sampleRateIn, sampleRateOut: u32) -> linear_resampler_config ---

    linear_resampler_get_expected_output_frame_count ¶

    linear_resampler_get_expected_output_frame_count :: proc "c" (pResampler: ^linear_resampler, inputFrameCount: u64, pOutputFrameCount: ^u64) -> result ---

    linear_resampler_get_heap_size ¶

    linear_resampler_get_heap_size :: proc "c" (pConfig: ^linear_resampler_config, pHeapSizeInBytes: ^uint) -> result ---

    linear_resampler_get_input_latency ¶

    linear_resampler_get_input_latency :: proc "c" (pResampler: ^linear_resampler) -> u64 ---

    linear_resampler_get_output_latency ¶

    linear_resampler_get_output_latency :: proc "c" (pResampler: ^linear_resampler) -> u64 ---

    linear_resampler_get_required_input_frame_count ¶

    linear_resampler_get_required_input_frame_count :: proc "c" (pResampler: ^linear_resampler, outputFrameCount: u64, pInputFrameCount: ^u64) -> result ---

    linear_resampler_init ¶

    linear_resampler_init :: proc "c" (pConfig: ^linear_resampler_config, pAllocationCallbacks: ^allocation_callbacks, pResampler: ^linear_resampler) -> result ---

    linear_resampler_init_preallocated ¶

    linear_resampler_init_preallocated :: proc "c" (pConfig: ^linear_resampler_config, pHeap: rawptr, pResampler: ^linear_resampler) -> result ---

    linear_resampler_process_pcm_frames ¶

    linear_resampler_process_pcm_frames :: proc "c" (pResampler: ^linear_resampler, pFramesIn: rawptr, pFrameCountIn: ^u64, pFramesOut: rawptr, pFrameCountOut: ^u64) -> result ---

    linear_resampler_reset ¶

    linear_resampler_reset :: proc "c" (pResampler: ^linear_resampler) -> result ---

    linear_resampler_set_rate ¶

    linear_resampler_set_rate :: proc "c" (pResampler: ^linear_resampler, sampleRateIn, sampleRateOut: u32) -> result ---

    linear_resampler_set_rate_ratio ¶

    linear_resampler_set_rate_ratio :: proc "c" (pResampler: ^linear_resampler, ratioInOut: f32) -> result ---

    linear_resampler_uninit ¶

    linear_resampler_uninit :: proc "c" (pResampler: ^linear_resampler, pAllocationCallbacks: ^allocation_callbacks) ---

    log_callback_init ¶

    log_callback_init :: proc "c" (onLog: log_callback_proc, pUserData: rawptr) -> log_callback ---

    log_init ¶

    log_init :: proc "c" (pAllocationCallbacks: ^allocation_callbacks, pLog: ^log) -> result ---

    log_level_to_string ¶

    log_level_to_string :: proc "c" (logLevel: u32) -> cstring ---
     

    Converts a log level to a string.

    log_post ¶

    log_post :: proc "c" (pLog: ^log, level: u32, pMessage: cstring) -> result ---

    log_postf ¶

    log_postf :: proc "c" (pLog: ^log, level: u32, pFormat: cstring, .. args: ..any) -> result ---

    log_postv ¶

    log_postv :: proc "c" (pLog: ^log, level: u32, pFormat: cstring, args: c.va_list) -> result ---

    log_register_callback ¶

    log_register_callback :: proc "c" (pLog: ^log, callback: log_callback) -> result ---

    log_uninit ¶

    log_uninit :: proc "c" (pLog: ^log) ---

    log_unregister_callback ¶

    log_unregister_callback :: proc "c" (pLog: ^log, callback: log_callback) -> result ---

    loshelf2_config_init ¶

    loshelf2_config_init :: proc "c" (
    	format:             format, 
    	channels:           u32, 
    	sampleRate:         u32, 
    	gainDB, shelfSlope, 
    	frequency:          f64, 
    ) -> loshelf_config ---

    loshelf2_get_heap_size ¶

    loshelf2_get_heap_size :: proc "c" (pConfig: ^loshelf_config, pHeapSizeInBytes: ^uint) -> result ---

    loshelf2_get_latency ¶

    loshelf2_get_latency :: proc "c" (pFilter: ^loshelf2) -> u32 ---

    loshelf2_init ¶

    loshelf2_init :: proc "c" (pConfig: ^loshelf_config, pAllocationCallbacks: ^allocation_callbacks, pFilter: ^loshelf2) -> result ---

    loshelf2_init_preallocated ¶

    loshelf2_init_preallocated :: proc "c" (pConfig: ^loshelf_config, pHeap: rawptr, pFilter: ^loshelf2) -> result ---

    loshelf2_process_pcm_frames ¶

    loshelf2_process_pcm_frames :: proc "c" (pFilter: ^loshelf2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    loshelf2_reinit ¶

    loshelf2_reinit :: proc "c" (pConfig: ^loshelf_config, pFilter: ^loshelf2) -> result ---

    loshelf2_uninit ¶

    loshelf2_uninit :: proc "c" (pFilter: ^loshelf2, pAllocationCallbacks: ^allocation_callbacks) ---

    loshelf_node_config_init ¶

    loshelf_node_config_init :: proc "c" (channels, sampleRate: u32, gainDB, q, frequency: f64) -> loshelf_node_config ---

    loshelf_node_init ¶

    loshelf_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^loshelf_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^loshelf_node) -> result ---

    loshelf_node_reinit ¶

    loshelf_node_reinit :: proc "c" (pConfig: ^loshelf_config, pNode: ^loshelf_node) -> result ---

    loshelf_node_uninit ¶

    loshelf_node_uninit :: proc "c" (pNode: ^loshelf_node, pAllocationCallbacks: ^allocation_callbacks) ---

    lpf1_clear_cache ¶

    lpf1_clear_cache :: proc "c" (pLPF: ^lpf1) -> result ---

    lpf1_config_init ¶

    lpf1_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency: f64) -> lpf1_config ---

    lpf1_get_heap_size ¶

    lpf1_get_heap_size :: proc "c" (pConfig: ^lpf1_config, pHeapSizeInBytes: ^uint) -> result ---

    lpf1_get_latency ¶

    lpf1_get_latency :: proc "c" (pLPF: ^lpf1) -> u32 ---

    lpf1_init ¶

    lpf1_init :: proc "c" (pConfig: ^lpf1_config, pAllocationCallbacks: ^allocation_callbacks, pLPF: ^lpf1) -> result ---

    lpf1_init_preallocated ¶

    lpf1_init_preallocated :: proc "c" (pConfig: ^lpf1_config, pHeap: rawptr, pLPF: ^lpf1) -> result ---

    lpf1_process_pcm_frames ¶

    lpf1_process_pcm_frames :: proc "c" (pLPF: ^lpf1, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    lpf1_reinit ¶

    lpf1_reinit :: proc "c" (pConfig: ^lpf1_config, pLPF: ^lpf1) -> result ---

    lpf1_uninit ¶

    lpf1_uninit :: proc "c" (pLPF: ^lpf1, pAllocationCallbacks: ^allocation_callbacks) ---

    lpf2_clear_cache ¶

    lpf2_clear_cache :: proc "c" (pLPF: ^lpf2) -> result ---

    lpf2_config_init ¶

    lpf2_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency, q: f64) -> lpf1_config ---

    lpf2_get_heap_size ¶

    lpf2_get_heap_size :: proc "c" (pConfig: ^lpf1_config, pHeapSizeInBytes: ^uint) -> result ---

    lpf2_get_latency ¶

    lpf2_get_latency :: proc "c" (pLPF: ^lpf2) -> u32 ---

    lpf2_init ¶

    lpf2_init :: proc "c" (pConfig: ^lpf1_config, pAllocationCallbacks: ^allocation_callbacks, pLPF: ^lpf2) -> result ---

    lpf2_init_preallocated ¶

    lpf2_init_preallocated :: proc "c" (pConfig: ^lpf1_config, pHeap: rawptr, pHPF: ^lpf2) -> result ---

    lpf2_process_pcm_frames ¶

    lpf2_process_pcm_frames :: proc "c" (pLPF: ^lpf2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    lpf2_reinit ¶

    lpf2_reinit :: proc "c" (pConfig: ^lpf1_config, pLPF: ^lpf2) -> result ---

    lpf2_uninit ¶

    lpf2_uninit :: proc "c" (pLPF: ^lpf2, pAllocationCallbacks: ^allocation_callbacks) ---

    lpf_clear_cache ¶

    lpf_clear_cache :: proc "c" (pLPF: ^lpf) -> result ---

    lpf_config_init ¶

    lpf_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, cutoffFrequency: f64, order: u32) -> lpf_config ---

    lpf_get_heap_size ¶

    lpf_get_heap_size :: proc "c" (pConfig: ^lpf_config, pHeapSizeInBytes: ^uint) -> result ---

    lpf_get_latency ¶

    lpf_get_latency :: proc "c" (pLPF: ^lpf) -> u32 ---

    lpf_init ¶

    lpf_init :: proc "c" (pConfig: ^lpf_config, pAllocationCallbacks: ^allocation_callbacks, pLPF: ^lpf) -> result ---

    lpf_init_preallocated ¶

    lpf_init_preallocated :: proc "c" (pConfig: ^lpf_config, pHeap: rawptr, pLPF: ^lpf) -> result ---

    lpf_node_config_init ¶

    lpf_node_config_init :: proc "c" (channels, sampleRate: u32, cutoffFrequency: f64, order: u32) -> lpf_node_config ---

    lpf_node_init ¶

    lpf_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^lpf_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^lpf_node) -> result ---

    lpf_node_reinit ¶

    lpf_node_reinit :: proc "c" (pConfig: ^lpf_config, pNode: ^lpf_node) -> result ---

    lpf_node_uninit ¶

    lpf_node_uninit :: proc "c" (pNode: ^lpf_node, pAllocationCallbacks: ^allocation_callbacks) ---

    lpf_process_pcm_frames ¶

    lpf_process_pcm_frames :: proc "c" (pLPF: ^lpf, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    lpf_reinit ¶

    lpf_reinit :: proc "c" (pConfig: ^lpf_config, pLPF: ^lpf) -> result ---

    lpf_uninit ¶

    lpf_uninit :: proc "c" (pLPF: ^lpf, pAllocationCallbacks: ^allocation_callbacks) ---

    ma_copy_and_apply_volume_and_clip_pcm_frames ¶

    ma_copy_and_apply_volume_and_clip_pcm_frames :: proc "c" (
    	pDst, pSrc: rawptr, 
    	frameCount: u64, 
    	format:     format, 
    	channels:   u32, 
    	volume:     f32, 
    ) ---

    ma_copy_and_apply_volume_and_clip_samples_f32 ¶

    ma_copy_and_apply_volume_and_clip_samples_f32 :: proc "c" (pDst, pSrc: [^]f32, count: u64, volume: f32) ---

    ma_copy_and_apply_volume_and_clip_samples_s16 ¶

    ma_copy_and_apply_volume_and_clip_samples_s16 :: proc "c" (pDst: [^]i16, pSrc: [^]i32, count: u64, volume: f32) ---

    ma_copy_and_apply_volume_and_clip_samples_s24 ¶

    ma_copy_and_apply_volume_and_clip_samples_s24 :: proc "c" (pDst: [^]u8, pSrc: [^]i64, count: u64, volume: f32) ---

    ma_copy_and_apply_volume_and_clip_samples_s32 ¶

    ma_copy_and_apply_volume_and_clip_samples_s32 :: proc "c" (pDst: [^]i32, pSrc: [^]i64, count: u64, volume: f32) ---

    ma_copy_and_apply_volume_and_clip_samples_u8 ¶

    ma_copy_and_apply_volume_and_clip_samples_u8 :: proc "c" (pDst: [^]u8, pSrc: [^]i16, count: u64, volume: f32) ---

    ma_mix_pcm_frames_f32 ¶

    ma_mix_pcm_frames_f32 :: proc "c" (pDst: ^f32, pSrc: ^f32, frameCount: u64, channels: u32, volume: f32) -> result ---
     

    Mixes the specified number of frames in floating point format with a volume factor.

    This will run on an optimized path when the volume is equal to 1.

    malloc ¶

    malloc :: proc "c" (sz: uint, pAllocationCallbacks: ^allocation_callbacks) -> rawptr ---
     

    malloc()

    mutex_init ¶

    mutex_init :: proc "c" (pMutex: ^mutex) -> result ---
     

    Creates a mutex.

    A mutex must be created from a valid context. A mutex is initially unlocked.

    mutex_lock ¶

    mutex_lock :: proc "c" (pMutex: ^mutex) ---
     

    Locks a mutex with an infinite timeout.

    mutex_uninit ¶

    mutex_uninit :: proc "c" (pMutex: ^mutex) ---
     

    Deletes a mutex.

    mutex_unlock ¶

    mutex_unlock :: proc "c" (pMutex: ^mutex) ---
     

    Unlocks a mutex.

    node_attach_output_bus ¶

    node_attach_output_bus :: proc "c" (pNode: ^node, outputBusIndex: u32, pOtherNode: ^node, otherNodeInputBusIndex: u32) -> result ---

    node_config_init ¶

    node_config_init :: proc "c" () -> node_config ---

    node_detach_all_output_buses ¶

    node_detach_all_output_buses :: proc "c" (pNode: ^node) -> result ---

    node_detach_output_bus ¶

    node_detach_output_bus :: proc "c" (pNode: ^node, outputBusIndex: u32) -> result ---

    node_get_heap_size ¶

    node_get_heap_size :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^node_config, pHeapSizeInBytes: ^uint) -> result ---

    node_get_input_bus_count ¶

    node_get_input_bus_count :: proc "c" (pNode: ^node) -> u32 ---

    node_get_input_channels ¶

    node_get_input_channels :: proc "c" (pNode: ^node, inputBusIndex: u32) -> u32 ---

    node_get_node_graph ¶

    node_get_node_graph :: proc "c" (pNode: ^node) -> ^node_graph ---

    node_get_output_bus_count ¶

    node_get_output_bus_count :: proc "c" (pNode: ^node) -> u32 ---

    node_get_output_bus_volume ¶

    node_get_output_bus_volume :: proc "c" (pNode: ^node, outputBusIndex: u32) -> f32 ---

    node_get_output_channels ¶

    node_get_output_channels :: proc "c" (pNode: ^node, outputBusIndex: u32) -> u32 ---

    node_get_state ¶

    node_get_state :: proc "c" (pNode: ^node) -> node_state ---

    node_get_state_by_time ¶

    node_get_state_by_time :: proc "c" (pNode: ^node, globalTime: u64) -> node_state ---

    node_get_state_by_time_range ¶

    node_get_state_by_time_range :: proc "c" (pNode: ^node, globalTimeBeg: u64, globalTimeEnd: u64) -> node_state ---

    node_get_state_time ¶

    node_get_state_time :: proc "c" (pNode: ^node, state: node_state) -> u64 ---

    node_get_time ¶

    node_get_time :: proc "c" (pNode: ^node) -> u64 ---

    node_graph_config_init ¶

    node_graph_config_init :: proc "c" (channels: u32) -> node_graph_config ---

    node_graph_get_channels ¶

    node_graph_get_channels :: proc "c" (pNodeGraph: ^node_graph) -> u32 ---

    node_graph_get_endpoint ¶

    node_graph_get_endpoint :: proc "c" (pNodeGraph: ^node_graph) -> ^node ---

    node_graph_get_time ¶

    node_graph_get_time :: proc "c" (pNodeGraph: ^node_graph) -> u64 ---

    node_graph_init ¶

    node_graph_init :: proc "c" (pConfig: ^node_graph_config, pAllocationCallbacks: ^allocation_callbacks, pNodeGraph: ^node_graph) -> result ---

    node_graph_read_pcm_frames ¶

    node_graph_read_pcm_frames :: proc "c" (pNodeGraph: ^node_graph, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    node_graph_set_time ¶

    node_graph_set_time :: proc "c" (pNodeGraph: ^node_graph, globalTime: u64) -> result ---

    node_graph_uninit ¶

    node_graph_uninit :: proc "c" (pNodeGraph: ^node_graph, pAllocationCallbacks: ^allocation_callbacks) ---

    node_init ¶

    node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^node) -> result ---

    node_init_preallocated ¶

    node_init_preallocated :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^node_config, pHeap: rawptr, pNode: ^node) -> result ---

    node_set_output_bus_volume ¶

    node_set_output_bus_volume :: proc "c" (pNode: ^node, outputBusIndex: u32, volume: f32) -> result ---

    node_set_state ¶

    node_set_state :: proc "c" (pNode: ^node, state: node_state) -> result ---

    node_set_state_time ¶

    node_set_state_time :: proc "c" (pNode: ^node, state: node_state, globalTime: u64) -> result ---

    node_set_time ¶

    node_set_time :: proc "c" (pNode: ^node, localTime: u64) -> result ---

    node_uninit ¶

    node_uninit :: proc "c" (pNode: ^node, pAllocationCallbacks: ^allocation_callbacks) ---

    noise_config_init ¶

    noise_config_init :: proc "c" (format: format, channels: u32, type: noise_type, seed: i32, amplitude: f64) -> noise_config ---

    noise_get_heap_size ¶

    noise_get_heap_size :: proc "c" (pConfig: ^noise_config, pHeapSizeInBytes: ^uint) -> result ---

    noise_init ¶

    noise_init :: proc "c" (pConfig: ^noise_config, pAllocationCallbacks: ^allocation_callbacks, pNoise: ^noise) -> result ---

    noise_init_preallocated ¶

    noise_init_preallocated :: proc "c" (pConfig: ^noise_config, pHeap: rawptr, pNoise: ^noise) -> result ---

    noise_read_pcm_frames ¶

    noise_read_pcm_frames :: proc "c" (pNoise: ^noise, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    noise_set_amplitude ¶

    noise_set_amplitude :: proc "c" (pNoise: ^noise, amplitude: f64) -> result ---

    noise_set_seed ¶

    noise_set_seed :: proc "c" (pNoise: ^noise, seed: i32) -> result ---

    noise_set_type ¶

    noise_set_type :: proc "c" (pNoise: ^noise, type: noise_type) -> result ---

    noise_uninit ¶

    noise_uninit :: proc "c" (pNoise: ^noise, pAllocationCallbacks: ^allocation_callbacks) ---

    notch2_config_init ¶

    notch2_config_init :: proc "c" (format: format, channels: u32, sampleRate: u32, q: f64, frequency: f64) -> notch_config ---

    notch2_get_heap_size ¶

    notch2_get_heap_size :: proc "c" (pConfig: ^notch_config, pHeapSizeInBytes: ^uint) -> result ---

    notch2_get_latency ¶

    notch2_get_latency :: proc "c" (pFilter: ^notch2) -> u32 ---

    notch2_init ¶

    notch2_init :: proc "c" (pConfig: ^notch_config, pAllocationCallbacks: ^allocation_callbacks, pFilter: ^notch2) -> result ---

    notch2_init_preallocated ¶

    notch2_init_preallocated :: proc "c" (pConfig: ^notch_config, pHeap: rawptr, pFilter: ^notch2) -> result ---

    notch2_process_pcm_frames ¶

    notch2_process_pcm_frames :: proc "c" (pFilter: ^notch2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    notch2_reinit ¶

    notch2_reinit :: proc "c" (pConfig: ^notch_config, pFilter: ^notch2) -> result ---

    notch2_uninit ¶

    notch2_uninit :: proc "c" (pFilter: ^notch2, pAllocationCallbacks: ^allocation_callbacks) ---

    notch_node_config_init ¶

    notch_node_config_init :: proc "c" (channels, sampleRate: u32, q, frequency: f64) -> notch_node_config ---

    notch_node_init ¶

    notch_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^notch_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^notch_node) -> result ---

    notch_node_reinit ¶

    notch_node_reinit :: proc "c" (pConfig: ^notch_config, pNode: ^notch_node) -> result ---

    notch_node_uninit ¶

    notch_node_uninit :: proc "c" (pNode: ^notch_node, pAllocationCallbacks: ^allocation_callbacks) ---

    offset_pcm_frames_const_ptr ¶

    offset_pcm_frames_const_ptr :: proc "c" (p: rawptr, offsetInFrames: u64, format: format, channels: u32) -> rawptr ---

    offset_pcm_frames_const_ptr_f32 ¶

    offset_pcm_frames_const_ptr_f32 :: proc "c" (p: [^]f32, offsetInFrames: u64, channels: u32) -> [^]f32 {…}

    offset_pcm_frames_ptr ¶

    offset_pcm_frames_ptr :: proc "c" (p: rawptr, offsetInFrames: u64, format: format, channels: u32) -> rawptr ---
     

    Offsets a pointer by the specified number of PCM frames.

    offset_pcm_frames_ptr_f32 ¶

    offset_pcm_frames_ptr_f32 :: proc "c" (p: [^]f32, offsetInFrames: u64, channels: u32) -> [^]f32 {…}

    paged_audio_buffer_config_init ¶

    paged_audio_buffer_config_init :: proc "c" (pData: ^paged_audio_buffer_data) -> paged_audio_buffer_config ---

    paged_audio_buffer_data_allocate_and_append_page ¶

    paged_audio_buffer_data_allocate_and_append_page :: proc "c" (pData: ^paged_audio_buffer_data, pageSizeInFrames: u32, pInitialData: rawptr, pAllocationCallbacks: ^allocation_callbacks) -> result ---

    paged_audio_buffer_data_allocate_page ¶

    paged_audio_buffer_data_allocate_page :: proc "c" (pData: ^paged_audio_buffer_data, pageSizeInFrames: u64, pInitialData: rawptr, pAllocationCallbacks: ^allocation_callbacks, ppPage: ^^paged_audio_buffer_page) -> result ---

    paged_audio_buffer_data_append_page ¶

    paged_audio_buffer_data_append_page :: proc "c" (pData: ^paged_audio_buffer_data, pPage: ^paged_audio_buffer_page) -> result ---

    paged_audio_buffer_data_free_page ¶

    paged_audio_buffer_data_free_page :: proc "c" (pData: ^paged_audio_buffer_data, pPage: ^paged_audio_buffer_page, pAllocationCallbacks: ^allocation_callbacks) -> result ---

    paged_audio_buffer_data_get_head ¶

    paged_audio_buffer_data_get_head :: proc "c" (pData: ^paged_audio_buffer_data) -> ^paged_audio_buffer_page ---

    paged_audio_buffer_data_get_length_in_pcm_frames ¶

    paged_audio_buffer_data_get_length_in_pcm_frames :: proc "c" (pData: ^paged_audio_buffer_data, pLength: ^u64) -> result ---

    paged_audio_buffer_data_get_tail ¶

    paged_audio_buffer_data_get_tail :: proc "c" (pData: ^paged_audio_buffer_data) -> ^paged_audio_buffer_page ---

    paged_audio_buffer_data_init ¶

    paged_audio_buffer_data_init :: proc "c" (format: format, channels: u32, pData: ^paged_audio_buffer_data) -> result ---

    paged_audio_buffer_data_uninit ¶

    paged_audio_buffer_data_uninit :: proc "c" (pData: ^paged_audio_buffer_data, pAllocationCallbacks: ^allocation_callbacks) ---

    paged_audio_buffer_get_cursor_in_pcm_frames ¶

    paged_audio_buffer_get_cursor_in_pcm_frames :: proc "c" (pPagedAudioBuffer: ^paged_audio_buffer, pCursor: ^u64) -> result ---

    paged_audio_buffer_get_length_in_pcm_frames ¶

    paged_audio_buffer_get_length_in_pcm_frames :: proc "c" (pPagedAudioBuffer: ^paged_audio_buffer, pLength: ^u64) -> result ---

    paged_audio_buffer_init ¶

    paged_audio_buffer_init :: proc "c" (pConfig: ^paged_audio_buffer_config, pPagedAudioBuffer: ^paged_audio_buffer) -> result ---

    paged_audio_buffer_read_pcm_frames ¶

    paged_audio_buffer_read_pcm_frames :: proc "c" (pPagedAudioBuffer: ^paged_audio_buffer, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---
     

    Returns MA_AT_END if no more pages available.

    paged_audio_buffer_seek_to_pcm_frame ¶

    paged_audio_buffer_seek_to_pcm_frame :: proc "c" (pPagedAudioBuffer: ^paged_audio_buffer, frameIndex: u64) -> result ---

    paged_audio_buffer_uninit ¶

    paged_audio_buffer_uninit :: proc "c" (pPagedAudioBuffer: ^paged_audio_buffer) ---

    panner_config_init ¶

    panner_config_init :: proc "c" (format: format, channels: u32) -> panner_config ---

    panner_get_mode ¶

    panner_get_mode :: proc "c" (pPanner: ^panner) -> pan_mode ---

    panner_get_pan ¶

    panner_get_pan :: proc "c" (pPanner: ^panner) -> f32 ---

    panner_init ¶

    panner_init :: proc "c" (pConfig: ^panner_config, pPanner: ^panner) -> result ---

    panner_process_pcm_frames ¶

    panner_process_pcm_frames :: proc "c" (pPanner: ^panner, pFramesOut, pFramesIn: rawptr, frameCount: u64) -> result ---

    panner_set_mode ¶

    panner_set_mode :: proc "c" (pPanner: ^panner, mode: pan_mode) ---

    panner_set_pan ¶

    panner_set_pan :: proc "c" (pPanner: ^panner, pan: f32) ---

    pcm_convert ¶

    pcm_convert :: proc "c" (
    	pOut:        rawptr, 
    	formatOut:   format, 
    	pIn:         rawptr, 
    	formatIn:    format, 
    	sampleCount: u64, 
    	ditherMode:  dither_mode, 
    ) ---

    pcm_f32_to_s16 ¶

    pcm_f32_to_s16 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_f32_to_s24 ¶

    pcm_f32_to_s24 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_f32_to_s32 ¶

    pcm_f32_to_s32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_f32_to_u8 ¶

    pcm_f32_to_u8 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_rb_acquire_read ¶

    pcm_rb_acquire_read :: proc "c" (pRB: ^pcm_rb, pSizeInFrames: ^u32, ppBufferOut: ^rawptr) -> result ---

    pcm_rb_acquire_write ¶

    pcm_rb_acquire_write :: proc "c" (pRB: ^pcm_rb, pSizeInFrames: ^u32, ppBufferOut: ^rawptr) -> result ---

    pcm_rb_available_read ¶

    pcm_rb_available_read :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_available_write ¶

    pcm_rb_available_write :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_commit_read ¶

    pcm_rb_commit_read :: proc "c" (pRB: ^pcm_rb, sizeInFrames: u32) -> result ---

    pcm_rb_commit_write ¶

    pcm_rb_commit_write :: proc "c" (pRB: ^pcm_rb, sizeInFrames: u32) -> result ---

    pcm_rb_get_channels ¶

    pcm_rb_get_channels :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_get_format ¶

    pcm_rb_get_format :: proc "c" (pRB: ^pcm_rb) -> format ---

    pcm_rb_get_sample_rate ¶

    pcm_rb_get_sample_rate :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_get_subbuffer_offset ¶

    pcm_rb_get_subbuffer_offset :: proc "c" (pRB: ^pcm_rb, subbufferIndex: u32) -> u32 ---

    pcm_rb_get_subbuffer_ptr ¶

    pcm_rb_get_subbuffer_ptr :: proc "c" (pRB: ^pcm_rb, subbufferIndex: u32, pBuffer: rawptr) -> rawptr ---

    pcm_rb_get_subbuffer_size ¶

    pcm_rb_get_subbuffer_size :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_get_subbuffer_stride ¶

    pcm_rb_get_subbuffer_stride :: proc "c" (pRB: ^pcm_rb) -> u32 ---

    pcm_rb_init ¶

    pcm_rb_init :: proc "c" (
    	format:                      format, 
    	channels:                    u32, 
    	bufferSizeInFrames:          u32, 
    	pOptionalPreallocatedBuffer: rawptr, 
    	pAllocationCallbacks:        ^allocation_callbacks, 
    	pRB:                         ^pcm_rb, 
    ) -> result ---

    pcm_rb_init_ex ¶

    pcm_rb_init_ex :: proc "c" (
    	format:                                                         format, 
    	channels:                                                       u32, 
    	subbufferSizeInFrames, subbufferCount, subbufferStrideInFrames: u32, 
    	pOptionalPreallocatedBuffer:                                    rawptr, 
    	pAllocationCallbacks:                                           ^allocation_callbacks, 
    	pRB:                                                            ^pcm_rb, 
    ) -> result ---

    pcm_rb_pointer_distance ¶

    pcm_rb_pointer_distance :: proc "c" (pRB: ^pcm_rb) -> i32 ---
     

    Return value is in frames.

    pcm_rb_reset ¶

    pcm_rb_reset :: proc "c" (pRB: ^pcm_rb) ---

    pcm_rb_seek_read ¶

    pcm_rb_seek_read :: proc "c" (pRB: ^pcm_rb, offsetInFrames: u32) -> result ---

    pcm_rb_seek_write ¶

    pcm_rb_seek_write :: proc "c" (pRB: ^pcm_rb, offsetInFrames: u32) -> result ---

    pcm_rb_set_sample_rate ¶

    pcm_rb_set_sample_rate :: proc "c" (pRB: ^pcm_rb, sampleRate: u32) ---

    pcm_rb_uninit ¶

    pcm_rb_uninit :: proc "c" (pRB: ^pcm_rb) ---

    pcm_s16_to_f32 ¶

    pcm_s16_to_f32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s16_to_s24 ¶

    pcm_s16_to_s24 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s16_to_s32 ¶

    pcm_s16_to_s32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s16_to_u8 ¶

    pcm_s16_to_u8 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s24_to_f32 ¶

    pcm_s24_to_f32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s24_to_s16 ¶

    pcm_s24_to_s16 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s24_to_s32 ¶

    pcm_s24_to_s32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s24_to_u8 ¶

    pcm_s24_to_u8 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s32_to_f32 ¶

    pcm_s32_to_f32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s32_to_s16 ¶

    pcm_s32_to_s16 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s32_to_s24 ¶

    pcm_s32_to_s24 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_s32_to_u8 ¶

    pcm_s32_to_u8 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_u8_to_f32 ¶

    pcm_u8_to_f32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_u8_to_s16 ¶

    pcm_u8_to_s16 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_u8_to_s24 ¶

    pcm_u8_to_s24 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    pcm_u8_to_s32 ¶

    pcm_u8_to_s32 :: proc "c" (pOut: rawptr, pIn: rawptr, count: u64, ditherMode: dither_mode) ---

    peak2_config_init ¶

    peak2_config_init :: proc "c" (
    	format:     format, 
    	channels:   u32, 
    	sampleRate: u32, 
    	gainDB, q, 
    	frequency:  f64, 
    ) -> peak_config ---

    peak2_get_heap_size ¶

    peak2_get_heap_size :: proc "c" (pConfig: ^peak_config, pHeapSizeInBytes: ^uint) -> result ---

    peak2_get_latency ¶

    peak2_get_latency :: proc "c" (pFilter: ^peak2) -> u32 ---

    peak2_init ¶

    peak2_init :: proc "c" (pConfig: ^peak_config, pAllocationCallbacks: ^allocation_callbacks, pFilter: ^peak2) -> result ---

    peak2_init_preallocated ¶

    peak2_init_preallocated :: proc "c" (pConfig: ^peak_config, pHeap: rawptr, pFilter: ^peak2) -> result ---

    peak2_process_pcm_frames ¶

    peak2_process_pcm_frames :: proc "c" (pFilter: ^peak2, pFramesOut: rawptr, pFramesIn: rawptr, frameCount: u64) -> result ---

    peak2_reinit ¶

    peak2_reinit :: proc "c" (pConfig: ^peak_config, pFilter: ^peak2) -> result ---

    peak2_uninit ¶

    peak2_uninit :: proc "c" (pFilter: ^peak2, pAllocationCallbacks: ^allocation_callbacks) ---

    peak_node_config_init ¶

    peak_node_config_init :: proc "c" (channels, sampleRate: u32, gainDB, q, frequency: f64) -> peak_node_config ---

    peak_node_init ¶

    peak_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^peak_node_config, pAllocationCallbacks: ^allocation_callbacks, pNode: ^peak_node) -> result ---

    peak_node_reinit ¶

    peak_node_reinit :: proc "c" (pConfig: ^peak_config, pNode: ^peak_node) -> result ---

    peak_node_uninit ¶

    peak_node_uninit :: proc "c" (pNode: ^peak_node, pAllocationCallbacks: ^allocation_callbacks) ---

    pulsewave_config_init ¶

    pulsewave_config_init :: proc "c" (
    	format:     format, 
    	channels:   u32, 
    	sampleRate: u32, 
    	dutyCycle:  f64, 
    	amplitude:  f64, 
    	frequency:  f64, 
    ) -> pulsewave_config ---

    pulsewave_init ¶

    pulsewave_init :: proc "c" (pConfig: ^pulsewave_config, pWaveForm: ^pulsewave) -> result ---

    pulsewave_read_pcm_frames ¶

    pulsewave_read_pcm_frames :: proc "c" (pWaveForm: ^pulsewave, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    pulsewave_seek_to_pcm_frame ¶

    pulsewave_seek_to_pcm_frame :: proc "c" (pWaveForm: ^pulsewave, frameIndex: u64) -> result ---

    pulsewave_set_amplitude ¶

    pulsewave_set_amplitude :: proc "c" (pWaveForm: ^pulsewave, amplitude: f64) -> result ---

    pulsewave_set_duty_cycle ¶

    pulsewave_set_duty_cycle :: proc "c" (pWaveForm: ^pulsewave, dutyCycle: f64) -> result ---

    pulsewave_set_frequency ¶

    pulsewave_set_frequency :: proc "c" (pWaveForm: ^pulsewave, frequency: f64) -> result ---

    pulsewave_set_sample_rate ¶

    pulsewave_set_sample_rate :: proc "c" (pWaveForm: ^pulsewave, sampleRate: u32) -> result ---

    pulsewave_uninit ¶

    pulsewave_uninit :: proc "c" (pWaveForm: ^pulsewave) ---

    rb_acquire_read ¶

    rb_acquire_read :: proc "c" (pRB: ^rb, pSizeInBytes: ^uint, ppBufferOut: ^rawptr) -> result ---

    rb_acquire_write ¶

    rb_acquire_write :: proc "c" (pRB: ^rb, pSizeInBytes: ^uint, ppBufferOut: ^rawptr) -> result ---

    rb_available_read ¶

    rb_available_read :: proc "c" (pRB: ^rb) -> u32 ---

    rb_available_write ¶

    rb_available_write :: proc "c" (pRB: ^rb) -> u32 ---

    rb_commit_read ¶

    rb_commit_read :: proc "c" (pRB: ^rb, sizeInBytes: uint) -> result ---

    rb_commit_write ¶

    rb_commit_write :: proc "c" (pRB: ^rb, sizeInBytes: uint) -> result ---

    rb_get_subbuffer_offset ¶

    rb_get_subbuffer_offset :: proc "c" (pRB: ^rb, subbufferIndex: uint) -> uint ---

    rb_get_subbuffer_ptr ¶

    rb_get_subbuffer_ptr :: proc "c" (pRB: ^rb, subbufferIndex: uint, pBuffer: rawptr) -> rawptr ---

    rb_get_subbuffer_size ¶

    rb_get_subbuffer_size :: proc "c" (pRB: ^rb) -> uint ---

    rb_get_subbuffer_stride ¶

    rb_get_subbuffer_stride :: proc "c" (pRB: ^rb) -> uint ---

    rb_init ¶

    rb_init :: proc "c" (bufferSizeInBytes: uint, pOptionalPreallocatedBuffer: rawptr, pAllocationCallbacks: ^allocation_callbacks, pRB: ^rb) -> result ---

    rb_init_ex ¶

    rb_init_ex :: proc "c" (
    	subbufferSizeInBytes, subbufferCount, subbufferStrideInBytes: uint, 
    	pOptionalPreallocatedBuffer:                                  rawptr, 
    	pAllocationCallbacks:                                         ^allocation_callbacks, 
    	pRB:                                                          ^rb, 
    ) -> result ---

    rb_pointer_distance ¶

    rb_pointer_distance :: proc "c" (pRB: ^rb) -> i32 ---
     

    Returns the distance between the write pointer and the read pointer. Should never be negative for a correct program. Will return the number of bytes that can be read before the read pointer hits the write pointer.

    rb_reset ¶

    rb_reset :: proc "c" (pRB: ^rb) ---

    rb_seek_read ¶

    rb_seek_read :: proc "c" (pRB: ^rb, offsetInBytes: uint) -> result ---

    rb_seek_write ¶

    rb_seek_write :: proc "c" (pRB: ^rb, offsetInBytes: uint) -> result ---

    rb_uninit ¶

    rb_uninit :: proc "c" (pRB: ^rb) ---

    realloc ¶

    realloc :: proc "c" (p: rawptr, sz: uint, pAllocationCallbacks: ^allocation_callbacks) -> rawptr ---
     

    realloc()

    resampler_config_init ¶

    resampler_config_init :: proc "c" (format: format, channels: u32, sampleRateIn, sampleRateOut: u32, algorithm: resample_algorithm) -> resampler_config ---

    resampler_get_expected_output_frame_count ¶

    resampler_get_expected_output_frame_count :: proc "c" (pResampler: ^resampler, inputFrameCount: u64, pOutputFrameCount: ^u64) -> result ---
     

    Calculates the number of whole output frames that would be output after fully reading and consuming the specified number of input frames.

    resampler_get_heap_size ¶

    resampler_get_heap_size :: proc "c" (pConfig: ^resampler_config, pHeapSizeInBytes: ^uint) -> result ---

    resampler_get_input_latency ¶

    resampler_get_input_latency :: proc "c" (pResampler: ^resampler) -> u64 ---
     

    Retrieves the latency introduced by the resampler in input frames.

    resampler_get_output_latency ¶

    resampler_get_output_latency :: proc "c" (pResampler: ^resampler) -> u64 ---
     

    Retrieves the latency introduced by the resampler in output frames.

    resampler_get_required_input_frame_count ¶

    resampler_get_required_input_frame_count :: proc "c" (pResampler: ^resampler, outputFrameCount: u64, pInputFrameCount: ^u64) -> result ---
     

    Calculates the number of whole input frames that would need to be read from the client in order to output the specified number of output frames.

    The returned value does not include cached input frames. It only returns the number of extra frames that would need to be read from the input buffer in order to output the specified number of output frames.

    resampler_init ¶

    resampler_init :: proc "c" (pConfig: ^resampler_config, pAllocationCallbacks: ^allocation_callbacks, pResampler: ^resampler) -> result ---
     

    Initializes a new resampler object from a config.

    resampler_init_preallocated ¶

    resampler_init_preallocated :: proc "c" (pConfig: ^resampler_config, pHeap: rawptr, pResampler: ^resampler) -> result ---

    resampler_process_pcm_frames ¶

    resampler_process_pcm_frames :: proc "c" (pResampler: ^resampler, pFramesIn: rawptr, pFrameCountIn: ^u64, pFramesOut: rawptr, pFrameCountOut: ^u64) -> result ---
     

    Converts the given input data.

    Both the input and output frames must be in the format specified in the config when the resampler was initialized.

    On input, [pFrameCountOut] contains the number of output frames to process. On output it contains the number of output frames that were actually processed, which may be less than the requested amount which will happen if there's not enough input data. You can use ma_resampler_get_expected_output_frame_count() to know how many output frames will be processed for a given number of input frames.

    On input, [pFrameCountIn] contains the number of input frames contained in [pFramesIn]. On output it contains the number of whole input frames that were actually processed. You can use ma_resampler_get_required_input_frame_count() to know how many input frames you should provide for a given number of output frames. [pFramesIn] can be NULL, in which case zeroes will be used instead.

    If [pFramesOut] is NULL, a seek is performed. In this case, if [pFrameCountOut] is not NULL it will seek by the specified number of output frames. Otherwise, if [pFramesCountOut] is NULL and [pFrameCountIn] is not NULL, it will seek by the specified number of input frames. When seeking, [pFramesIn] is allowed to NULL, in which case the internal timing state will be updated, but no input will be processed. In this case, any internal filter state will be updated as if zeroes were passed in.

    It is an error for [pFramesOut] to be non-NULL and [pFrameCountOut] to be NULL.

    It is an error for both [pFrameCountOut] and [pFrameCountIn] to be NULL.

    resampler_reset ¶

    resampler_reset :: proc "c" (pResampler: ^resampler) -> result ---
     

    Resets the resampler's timer and clears its internal cache.

    resampler_set_rate ¶

    resampler_set_rate :: proc "c" (pResampler: ^resampler, sampleRateIn, sampleRateOut: u32) -> result ---
     

    Sets the input and output sample rate.

    resampler_set_rate_ratio ¶

    resampler_set_rate_ratio :: proc "c" (pResampler: ^resampler, ratio: f32) -> result ---
     

    Sets the input and output sample rate as a ratio.

    The ration is in/out.

    resampler_uninit ¶

    resampler_uninit :: proc "c" (pResampler: ^resampler, pAllocationCallbacks: ^allocation_callbacks) ---
     

    Uninitializes a resampler.

    resource_manager_config_init ¶

    resource_manager_config_init :: proc "c" () -> resource_manager_config ---

    resource_manager_data_buffer_get_available_frames ¶

    resource_manager_data_buffer_get_available_frames :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, pAvailableFrames: ^u64) -> result ---

    resource_manager_data_buffer_get_cursor_in_pcm_frames ¶

    resource_manager_data_buffer_get_cursor_in_pcm_frames :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, pCursor: ^u64) -> result ---

    resource_manager_data_buffer_get_data_format ¶

    resource_manager_data_buffer_get_data_format :: proc "c" (
    	pDataBuffer:   ^resource_manager_data_buffer, 
    	pFormat:       ^format, 
    	pChannels:     ^u32, 
    	pSampleRate:   ^u32, 
    	pChannelMap:   [^]channel, 
    	channelMapCap: uint, 
    ) -> result ---

    resource_manager_data_buffer_get_length_in_pcm_frames ¶

    resource_manager_data_buffer_get_length_in_pcm_frames :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, pLength: ^u64) -> result ---

    resource_manager_data_buffer_init ¶

    resource_manager_data_buffer_init :: proc "c" (pResourceManager: ^resource_manager, pFilePath: cstring, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataBuffer: ^resource_manager_data_buffer) -> result ---

    resource_manager_data_buffer_init_copy ¶

    resource_manager_data_buffer_init_copy :: proc "c" (pResourceManager: ^resource_manager, pExistingDataBuffer, pDataBuffer: ^resource_manager_data_buffer) -> result ---

    resource_manager_data_buffer_init_ex ¶

    resource_manager_data_buffer_init_ex :: proc "c" (pResourceManager: ^resource_manager, pConfig: ^resource_manager_data_source_config, pDataBuffer: ^resource_manager_data_buffer) -> result ---
     

    Data Buffers.

    resource_manager_data_buffer_init_w ¶

    resource_manager_data_buffer_init_w :: proc "c" (pResourceManager: ^resource_manager, pFilePath: [^]u16, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataBuffer: ^resource_manager_data_buffer) -> result ---

    resource_manager_data_buffer_is_looping ¶

    resource_manager_data_buffer_is_looping :: proc "c" (pDataBuffer: ^resource_manager_data_buffer) -> b32 ---

    resource_manager_data_buffer_read_pcm_frames ¶

    resource_manager_data_buffer_read_pcm_frames :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    resource_manager_data_buffer_result ¶

    resource_manager_data_buffer_result :: proc "c" (pDataBuffer: ^resource_manager_data_buffer) -> result ---

    resource_manager_data_buffer_seek_to_pcm_frame ¶

    resource_manager_data_buffer_seek_to_pcm_frame :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, frameIndex: u64) -> result ---

    resource_manager_data_buffer_set_looping ¶

    resource_manager_data_buffer_set_looping :: proc "c" (pDataBuffer: ^resource_manager_data_buffer, isLooping: b32) -> result ---

    resource_manager_data_buffer_uninit ¶

    resource_manager_data_buffer_uninit :: proc "c" (pDataBuffer: ^resource_manager_data_buffer) -> result ---

    resource_manager_data_source_config_init ¶

    resource_manager_data_source_config_init :: proc "c" () -> resource_manager_data_source_config ---

    resource_manager_data_source_get_available_frames ¶

    resource_manager_data_source_get_available_frames :: proc "c" (pDataSource: ^resource_manager_data_source, pAvailableFrames: ^u64) -> result ---

    resource_manager_data_source_get_cursor_in_pcm_frames ¶

    resource_manager_data_source_get_cursor_in_pcm_frames :: proc "c" (pDataSource: ^resource_manager_data_source, pCursor: ^u64) -> result ---

    resource_manager_data_source_get_data_format ¶

    resource_manager_data_source_get_data_format :: proc "c" (
    	pDataSource:            ^resource_manager_data_source, 
    	pFormat:                ^format, 
    	pChannels, pSampleRate: ^u32, 
    	pChannelMap:            [^]channel, 
    	channelMapCap:          uint, 
    ) -> result ---

    resource_manager_data_source_get_length_in_pcm_frames ¶

    resource_manager_data_source_get_length_in_pcm_frames :: proc "c" (pDataSource: ^resource_manager_data_source, pLength: ^u64) -> result ---

    resource_manager_data_source_init ¶

    resource_manager_data_source_init :: proc "c" (pResourceManager: ^resource_manager, pName: cstring, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataSource: ^resource_manager_data_source) -> result ---

    resource_manager_data_source_init_copy ¶

    resource_manager_data_source_init_copy :: proc "c" (pResourceManager: ^resource_manager, pExistingDataSource, pDataSource: ^resource_manager_data_source) -> result ---

    resource_manager_data_source_init_ex ¶

    resource_manager_data_source_init_ex :: proc "c" (pResourceManager: ^resource_manager, pConfig: ^resource_manager_data_source_config, pDataSource: ^resource_manager_data_source) -> result ---
     

    Data Sources.

    resource_manager_data_source_init_w ¶

    resource_manager_data_source_init_w :: proc "c" (pResourceManager: ^resource_manager, pName: [^]u16, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataSource: ^resource_manager_data_source) -> result ---

    resource_manager_data_source_is_looping ¶

    resource_manager_data_source_is_looping :: proc "c" (pDataSource: ^resource_manager_data_source) -> b32 ---

    resource_manager_data_source_read_pcm_frames ¶

    resource_manager_data_source_read_pcm_frames :: proc "c" (pDataSource: ^resource_manager_data_source, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    resource_manager_data_source_result ¶

    resource_manager_data_source_result :: proc "c" (pDataSource: ^resource_manager_data_source) -> result ---

    resource_manager_data_source_seek_to_pcm_frame ¶

    resource_manager_data_source_seek_to_pcm_frame :: proc "c" (pDataSource: ^resource_manager_data_source, frameIndex: u64) -> result ---

    resource_manager_data_source_set_looping ¶

    resource_manager_data_source_set_looping :: proc "c" (pDataSource: ^resource_manager_data_source, isLooping: b32) -> result ---

    resource_manager_data_source_uninit ¶

    resource_manager_data_source_uninit :: proc "c" (pDataSource: ^resource_manager_data_source) -> result ---

    resource_manager_data_stream_get_available_frames ¶

    resource_manager_data_stream_get_available_frames :: proc "c" (pDataStream: ^resource_manager_data_stream, pAvailableFrames: ^u64) -> result ---

    resource_manager_data_stream_get_cursor_in_pcm_frames ¶

    resource_manager_data_stream_get_cursor_in_pcm_frames :: proc "c" (pDataStream: ^resource_manager_data_stream, pCursor: ^u64) -> result ---

    resource_manager_data_stream_get_data_format ¶

    resource_manager_data_stream_get_data_format :: proc "c" (
    	pDataStream:            ^resource_manager_data_stream, 
    	pFormat:                ^format, 
    	pChannels, pSampleRate: ^u32, 
    	pChannelMap:            [^]channel, 
    	channelMapCap:          uint, 
    ) -> result ---

    resource_manager_data_stream_get_length_in_pcm_frames ¶

    resource_manager_data_stream_get_length_in_pcm_frames :: proc "c" (pDataStream: ^resource_manager_data_stream, pLength: ^u64) -> result ---

    resource_manager_data_stream_init ¶

    resource_manager_data_stream_init :: proc "c" (pResourceManager: ^resource_manager, pFilePath: cstring, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataStream: ^resource_manager_data_stream) -> result ---

    resource_manager_data_stream_init_ex ¶

    resource_manager_data_stream_init_ex :: proc "c" (pResourceManager: ^resource_manager, pConfig: ^resource_manager_data_source_config, pDataStream: ^resource_manager_data_stream) -> result ---
     

    Data Streams.

    resource_manager_data_stream_init_w ¶

    resource_manager_data_stream_init_w :: proc "c" (pResourceManager: ^resource_manager, pFilePath: [^]u16, flags: u32, pNotifications: ^resource_manager_pipeline_notifications, pDataStream: ^resource_manager_data_stream) -> result ---

    resource_manager_data_stream_is_looping ¶

    resource_manager_data_stream_is_looping :: proc "c" (pDataStream: ^resource_manager_data_stream) -> b32 ---

    resource_manager_data_stream_read_pcm_frames ¶

    resource_manager_data_stream_read_pcm_frames :: proc "c" (pDataStream: ^resource_manager_data_stream, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    resource_manager_data_stream_result ¶

    resource_manager_data_stream_result :: proc "c" (pDataStream: ^resource_manager_data_stream) -> result ---

    resource_manager_data_stream_seek_to_pcm_frame ¶

    resource_manager_data_stream_seek_to_pcm_frame :: proc "c" (pDataStream: ^resource_manager_data_stream, frameIndex: u64) -> result ---

    resource_manager_data_stream_set_looping ¶

    resource_manager_data_stream_set_looping :: proc "c" (pDataStream: ^resource_manager_data_stream, isLooping: b32) -> result ---

    resource_manager_data_stream_uninit ¶

    resource_manager_data_stream_uninit :: proc "c" (pDataStream: ^resource_manager_data_stream) -> result ---

    resource_manager_get_log ¶

    resource_manager_get_log :: proc "c" (pResourceManager: ^resource_manager) -> ^log ---

    resource_manager_init ¶

    resource_manager_init :: proc "c" (pConfig: ^resource_manager_config, pResourceManager: ^resource_manager) -> result ---
     

    Init.

    resource_manager_job_init ¶

    resource_manager_job_init :: job_init

    resource_manager_job_queue_init ¶

    resource_manager_job_queue_init :: job_queue_init

    resource_manager_job_queue_next ¶

    resource_manager_job_queue_next :: job_queue_next
     

    Returns MA_CANCELLED if the next job is a quit job.

    resource_manager_job_queue_post ¶

    resource_manager_job_queue_post :: job_queue_post

    resource_manager_job_queue_uninit ¶

    resource_manager_job_queue_uninit :: job_queue_uninit

    resource_manager_next_job ¶

    resource_manager_next_job :: proc "c" (pResourceManager: ^resource_manager, pJob: ^job) -> result ---

    resource_manager_pipeline_notifications_init ¶

    resource_manager_pipeline_notifications_init :: proc "c" () -> resource_manager_pipeline_notifications ---

    resource_manager_post_job ¶

    resource_manager_post_job :: proc "c" (pResourceManager: ^resource_manager, pJob: ^job) -> result ---
     

    Job management.

    resource_manager_post_job_quit ¶

    resource_manager_post_job_quit :: proc "c" (pResourceManager: ^resource_manager) -> result ---
     

    Helper for posting a quit job.

    resource_manager_process_job ¶

    resource_manager_process_job :: proc "c" (pResourceManager: ^resource_manager, pJob: ^job) -> result ---
     

    DEPRECATED. Use ma_job_process(). Will be removed in version 0.12.

    resource_manager_process_next_job ¶

    resource_manager_process_next_job :: proc "c" (pResourceManager: ^resource_manager) -> result ---
     

    Returns MA_CANCELLED if a MA_JOB_TYPE_QUIT job is found. In non-blocking mode, returns MA_NO_DATA_AVAILABLE if no jobs are available.

    resource_manager_register_decoded_data ¶

    resource_manager_register_decoded_data :: proc "c" (
    	pResourceManager: ^resource_manager, 
    	pName:            cstring, 
    	pData:            rawptr, 
    	frameCount:       u64, 
    	format:           format, 
    	channels:         u32, 
    	sampleRate:       u32, 
    ) -> result ---
     

    Does not copy. Increments the reference count if already exists and returns MA_SUCCESS.

    resource_manager_register_decoded_data_w ¶

    resource_manager_register_decoded_data_w :: proc "c" (
    	pResourceManager: ^resource_manager, 
    	pName:            [^]u16, 
    	pData:            rawptr, 
    	frameCount:       u64, 
    	format:           format, 
    	channels:         u32, 
    	sampleRate:       u32, 
    ) -> result ---

    resource_manager_register_encoded_data ¶

    resource_manager_register_encoded_data :: proc "c" (pResourceManager: ^resource_manager, pName: cstring, pData: rawptr, sizeInBytes: uint) -> result ---
     

    Does not copy. Increments the reference count if already exists and returns MA_SUCCESS.

    resource_manager_register_encoded_data_w ¶

    resource_manager_register_encoded_data_w :: proc "c" (pResourceManager: ^resource_manager, pName: [^]u16, pData: rawptr, sizeInBytes: uint) -> result ---

    resource_manager_register_file ¶

    resource_manager_register_file :: proc "c" (pResourceManager: ^resource_manager, pFilePath: cstring, flags: u32) -> result ---
     

    Registration.

    resource_manager_register_file_w ¶

    resource_manager_register_file_w :: proc "c" (pResourceManager: ^resource_manager, pFilePath: [^]u16, flags: u32) -> result ---

    resource_manager_uninit ¶

    resource_manager_uninit :: proc "c" (pResourceManager: ^resource_manager) ---

    resource_manager_unregister_data ¶

    resource_manager_unregister_data :: proc "c" (pResourceManager: ^resource_manager, pName: cstring) -> result ---

    resource_manager_unregister_data_w ¶

    resource_manager_unregister_data_w :: proc "c" (pResourceManager: ^resource_manager, pName: [^]u16) -> result ---

    resource_manager_unregister_file ¶

    resource_manager_unregister_file :: proc "c" (pResourceManager: ^resource_manager, pFilePath: cstring) -> result ---

    resource_manager_unregister_file_w ¶

    resource_manager_unregister_file_w :: proc "c" (pResourceManager: ^resource_manager, pFilePath: [^]u16) -> result ---

    result_description ¶

    result_description :: proc "c" (result: result) -> cstring ---
     

    Retrieves a human readable description of the given result code.

    semaphore_init ¶

    semaphore_init :: proc "c" (initialValue: i32, pSemaphore: ^semaphore) -> result ---

    semaphore_release ¶

    semaphore_release :: proc "c" (pSemaphore: ^semaphore) -> result ---

    semaphore_uninit ¶

    semaphore_uninit :: proc "c" (pSemaphore: ^semaphore) ---

    semaphore_wait ¶

    semaphore_wait :: proc "c" (pSemaphore: ^semaphore) -> result ---

    silence_pcm_frames ¶

    silence_pcm_frames :: proc "c" (p: rawptr, frameCount: u64, format: format, channels: u32) ---
     

    Copies silent frames into the given buffer.

    Remarks ------- For all formats except ma_format_u8, the output buffer will be filled with 0. For ma_format_u8 it will be filled with 128. The reason for this is that it makes more sense for the purpose of mixing to initialize it to the center point.

    slot_allocator_alloc ¶

    slot_allocator_alloc :: proc "c" (pAllocator: ^slot_allocator, pSlot: ^u64) -> result ---

    slot_allocator_config_init ¶

    slot_allocator_config_init :: proc "c" (capacity: u32) -> slot_allocator_config ---

    slot_allocator_free ¶

    slot_allocator_free :: proc "c" (pAllocator: ^slot_allocator, slot: u64) -> result ---

    slot_allocator_get_heap_size ¶

    slot_allocator_get_heap_size :: proc "c" (pConfig: ^slot_allocator_config, pHeapSizeInBytes: ^uint) -> result ---

    slot_allocator_init ¶

    slot_allocator_init :: proc "c" (pConfig: ^slot_allocator_config, pAllocationCallbacks: ^allocation_callbacks, pAllocator: ^slot_allocator) -> result ---

    slot_allocator_init_preallocated ¶

    slot_allocator_init_preallocated :: proc "c" (pConfig: ^slot_allocator_config, pHeap: rawptr, pAllocator: ^slot_allocator) -> result ---

    slot_allocator_uninit ¶

    slot_allocator_uninit :: proc "c" (pAllocator: ^slot_allocator, pAllocationCallbacks: ^allocation_callbacks) ---

    sound_at_end ¶

    sound_at_end :: proc "c" (pSound: ^sound) -> b32 ---

    sound_config_init ¶

    sound_config_init :: proc "c" () -> sound_config ---

    sound_config_init_2 ¶

    sound_config_init_2 :: proc "c" (pEngine: ^engine) -> sound_config ---
     

    Will be renamed to sound_config_init() in version 0.12.

    sound_get_attenuation_model ¶

    sound_get_attenuation_model :: proc "c" (pSound: ^sound) -> attenuation_model ---

    sound_get_cone ¶

    sound_get_cone :: proc "c" (pSound: ^sound, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain: ^f32) ---

    sound_get_current_fade_volume ¶

    sound_get_current_fade_volume :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_cursor_in_pcm_frames ¶

    sound_get_cursor_in_pcm_frames :: proc "c" (pSound: ^sound, pCursor: ^u64) -> result ---

    sound_get_cursor_in_seconds ¶

    sound_get_cursor_in_seconds :: proc "c" (pSound: ^sound, pCursor: ^f32) -> result ---

    sound_get_data_format ¶

    sound_get_data_format :: proc "c" (
    	pSound:                 ^sound, 
    	pFormat:                ^format, 
    	pChannels, pSampleRate: ^u32, 
    	pChannelMap:            ^channel, 
    	channelMapCap:          uint, 
    ) -> result ---

    sound_get_data_source ¶

    sound_get_data_source :: proc "c" (pSound: ^sound) -> ^data_source ---

    sound_get_direction ¶

    sound_get_direction :: proc "c" (pSound: ^sound) -> vec3f ---

    sound_get_direction_to_listener ¶

    sound_get_direction_to_listener :: proc "c" (pSound: ^sound) -> vec3f ---

    sound_get_directional_attenuation_factor ¶

    sound_get_directional_attenuation_factor :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_doppler_factor ¶

    sound_get_doppler_factor :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_engine ¶

    sound_get_engine :: proc "c" (pSound: ^sound) -> ^engine ---

    sound_get_length_in_pcm_frames ¶

    sound_get_length_in_pcm_frames :: proc "c" (pSound: ^sound, pLength: ^u64) -> result ---

    sound_get_length_in_seconds ¶

    sound_get_length_in_seconds :: proc "c" (pSound: ^sound, pLength: ^f32) -> result ---

    sound_get_listener_index ¶

    sound_get_listener_index :: proc "c" (pSound: ^sound) -> u32 ---

    sound_get_max_distance ¶

    sound_get_max_distance :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_max_gain ¶

    sound_get_max_gain :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_min_distance ¶

    sound_get_min_distance :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_min_gain ¶

    sound_get_min_gain :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_pan ¶

    sound_get_pan :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_pan_mode ¶

    sound_get_pan_mode :: proc "c" (pSound: ^sound) -> pan_mode ---

    sound_get_pinned_listener_index ¶

    sound_get_pinned_listener_index :: proc "c" (pSound: ^sound) -> u32 ---

    sound_get_pitch ¶

    sound_get_pitch :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_position ¶

    sound_get_position :: proc "c" (pSound: ^sound) -> vec3f ---

    sound_get_positioning ¶

    sound_get_positioning :: proc "c" (pSound: ^sound) -> positioning ---

    sound_get_rolloff ¶

    sound_get_rolloff :: proc "c" (pSound: ^sound) -> f32 ---

    sound_get_time_in_milliseconds ¶

    sound_get_time_in_milliseconds :: proc "c" (pSound: ^sound) -> u64 ---

    sound_get_time_in_pcm_frames ¶

    sound_get_time_in_pcm_frames :: proc "c" (pSound: ^sound) -> u64 ---

    sound_get_velocity ¶

    sound_get_velocity :: proc "c" (pSound: ^sound) -> vec3f ---

    sound_get_volume ¶

    sound_get_volume :: proc "c" (pSound: ^sound) -> f32 ---

    sound_group_config_init ¶

    sound_group_config_init :: proc "c" () -> sound_group_config ---

    sound_group_config_init_2 ¶

    sound_group_config_init_2 :: proc "c" (pEngine: ^engine) -> sound_group_config ---

    sound_group_get_attenuation_model ¶

    sound_group_get_attenuation_model :: proc "c" (pGroup: ^sound_group) -> attenuation_model ---

    sound_group_get_cone ¶

    sound_group_get_cone :: proc "c" (pGroup: ^sound_group, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain: ^f32) ---

    sound_group_get_current_fade_volume ¶

    sound_group_get_current_fade_volume :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_direction ¶

    sound_group_get_direction :: proc "c" (pGroup: ^sound_group) -> vec3f ---

    sound_group_get_direction_to_listener ¶

    sound_group_get_direction_to_listener :: proc "c" (pGroup: ^sound_group) -> vec3f ---

    sound_group_get_directional_attenuation_factor ¶

    sound_group_get_directional_attenuation_factor :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_doppler_factor ¶

    sound_group_get_doppler_factor :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_engine ¶

    sound_group_get_engine :: proc "c" (pGroup: ^sound_group) -> ^engine ---

    sound_group_get_listener_index ¶

    sound_group_get_listener_index :: proc "c" (pGroup: ^sound_group) -> u32 ---

    sound_group_get_max_distance ¶

    sound_group_get_max_distance :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_max_gain ¶

    sound_group_get_max_gain :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_min_distance ¶

    sound_group_get_min_distance :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_min_gain ¶

    sound_group_get_min_gain :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_pan ¶

    sound_group_get_pan :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_pan_mode ¶

    sound_group_get_pan_mode :: proc "c" (pGroup: ^sound_group) -> pan_mode ---

    sound_group_get_pinned_listener_index ¶

    sound_group_get_pinned_listener_index :: proc "c" (pGroup: ^sound_group) -> u32 ---

    sound_group_get_pitch ¶

    sound_group_get_pitch :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_position ¶

    sound_group_get_position :: proc "c" (pGroup: ^sound_group) -> vec3f ---

    sound_group_get_positioning ¶

    sound_group_get_positioning :: proc "c" (pGroup: ^sound_group) -> positioning ---

    sound_group_get_rolloff ¶

    sound_group_get_rolloff :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_get_time_in_pcm_frames ¶

    sound_group_get_time_in_pcm_frames :: proc "c" (pGroup: ^sound_group) -> u64 ---

    sound_group_get_velocity ¶

    sound_group_get_velocity :: proc "c" (pGroup: ^sound_group) -> vec3f ---

    sound_group_get_volume ¶

    sound_group_get_volume :: proc "c" (pGroup: ^sound_group) -> f32 ---

    sound_group_init ¶

    sound_group_init :: proc "c" (pEngine: ^engine, flags: bit_set[sound_flag; u32], pParentGroup, pGroup: ^sound_group) -> result ---

    sound_group_init_ex ¶

    sound_group_init_ex :: proc "c" (pEngine: ^engine, pConfig: ^sound_group_config, pGroup: ^sound_group) -> result ---

    sound_group_is_playing ¶

    sound_group_is_playing :: proc "c" (pGroup: ^sound_group) -> b32 ---

    sound_group_is_spatialization_enabled ¶

    sound_group_is_spatialization_enabled :: proc "c" (pGroup: ^sound_group) -> b32 ---

    sound_group_set_attenuation_model ¶

    sound_group_set_attenuation_model :: proc "c" (pGroup: ^sound_group, attenuationModel: attenuation_model) ---

    sound_group_set_cone ¶

    sound_group_set_cone :: proc "c" (pGroup: ^sound_group, innerAngleInRadians, outerAngleInRadians, outerGain: f32) ---

    sound_group_set_direction ¶

    sound_group_set_direction :: proc "c" (pGroup: ^sound_group, x, y, z: f32) ---

    sound_group_set_directional_attenuation_factor ¶

    sound_group_set_directional_attenuation_factor :: proc "c" (pGroup: ^sound_group, directionalAttenuationFactor: f32) ---

    sound_group_set_doppler_factor ¶

    sound_group_set_doppler_factor :: proc "c" (pGroup: ^sound_group, dopplerFactor: f32) ---

    sound_group_set_fade_in_milliseconds ¶

    sound_group_set_fade_in_milliseconds :: proc "c" (pGroup: ^sound_group, volumeBeg, volumeEnd: f32, fadeLengthInMilliseconds: u64) ---

    sound_group_set_fade_in_pcm_frames ¶

    sound_group_set_fade_in_pcm_frames :: proc "c" (pGroup: ^sound_group, volumeBeg, volumeEnd: f32, fadeLengthInFrames: u64) ---

    sound_group_set_max_distance ¶

    sound_group_set_max_distance :: proc "c" (pGroup: ^sound_group, maxDistance: f32) ---

    sound_group_set_max_gain ¶

    sound_group_set_max_gain :: proc "c" (pGroup: ^sound_group, maxGain: f32) ---

    sound_group_set_min_distance ¶

    sound_group_set_min_distance :: proc "c" (pGroup: ^sound_group, minDistance: f32) ---

    sound_group_set_min_gain ¶

    sound_group_set_min_gain :: proc "c" (pGroup: ^sound_group, minGain: f32) ---

    sound_group_set_pan ¶

    sound_group_set_pan :: proc "c" (pGroup: ^sound_group, pan: f32) ---

    sound_group_set_pan_mode ¶

    sound_group_set_pan_mode :: proc "c" (pGroup: ^sound_group, panMode: pan_mode) ---

    sound_group_set_pinned_listener_index ¶

    sound_group_set_pinned_listener_index :: proc "c" (pGroup: ^sound_group, listenerIndex: u32) ---

    sound_group_set_pitch ¶

    sound_group_set_pitch :: proc "c" (pGroup: ^sound_group, pitch: f32) ---

    sound_group_set_position ¶

    sound_group_set_position :: proc "c" (pGroup: ^sound_group, x, y, z: f32) ---

    sound_group_set_positioning ¶

    sound_group_set_positioning :: proc "c" (pGroup: ^sound_group, positioning: positioning) ---

    sound_group_set_rolloff ¶

    sound_group_set_rolloff :: proc "c" (pGroup: ^sound_group, rolloff: f32) ---

    sound_group_set_spatialization_enabled ¶

    sound_group_set_spatialization_enabled :: proc "c" (pGroup: ^sound_group, enabled: b32) ---

    sound_group_set_start_time_in_milliseconds ¶

    sound_group_set_start_time_in_milliseconds :: proc "c" (pGroup: ^sound_group, absoluteGlobalTimeInMilliseconds: u64) ---

    sound_group_set_start_time_in_pcm_frames ¶

    sound_group_set_start_time_in_pcm_frames :: proc "c" (pGroup: ^sound_group, absoluteGlobalTimeInFrames: u64) ---

    sound_group_set_stop_time_in_milliseconds ¶

    sound_group_set_stop_time_in_milliseconds :: proc "c" (pGroup: ^sound_group, absoluteGlobalTimeInMilliseconds: u64) ---

    sound_group_set_stop_time_in_pcm_frames ¶

    sound_group_set_stop_time_in_pcm_frames :: proc "c" (pGroup: ^sound_group, absoluteGlobalTimeInFrames: u64) ---

    sound_group_set_velocity ¶

    sound_group_set_velocity :: proc "c" (pGroup: ^sound_group, x, y, z: f32) ---

    sound_group_set_volume ¶

    sound_group_set_volume :: proc "c" (pGroup: ^sound_group, volume: f32) ---

    sound_group_start ¶

    sound_group_start :: proc "c" (pGroup: ^sound_group) -> result ---

    sound_group_stop ¶

    sound_group_stop :: proc "c" (pGroup: ^sound_group) -> result ---

    sound_group_uninit ¶

    sound_group_uninit :: proc "c" (pGroup: ^sound_group) ---

    sound_init_copy ¶

    sound_init_copy :: proc "c" (pEngine: ^engine, pExistingSound: ^sound, flags: bit_set[sound_flag; u32], pGroup: ^sound_group, pSound: ^sound) -> result ---

    sound_init_ex ¶

    sound_init_ex :: proc "c" (pEngine: ^engine, pConfig: ^sound_config, pSound: ^sound) -> result ---

    sound_init_from_data_source ¶

    sound_init_from_data_source :: proc "c" (pEngine: ^engine, pDataSource: ^data_source, flags: bit_set[sound_flag; u32], pGroup: ^sound_group, pSound: ^sound) -> result ---

    sound_init_from_file ¶

    sound_init_from_file :: proc "c" (
    	pEngine:    ^engine, 
    	pFilePath:  cstring, 
    	flags:      bit_set[sound_flag; u32], 
    	pGroup:     ^sound_group, 
    	pDoneFence: ^fence, 
    	pSound:     ^sound, 
    ) -> result ---

    sound_init_from_file_w ¶

    sound_init_from_file_w :: proc "c" (
    	pEngine:    ^engine, 
    	pFilePath:  [^]u16, 
    	flags:      bit_set[sound_flag; u32], 
    	pGroup:     ^sound_group, 
    	pDoneFence: ^fence, 
    	pSound:     ^sound, 
    ) -> result ---

    sound_is_looping ¶

    sound_is_looping :: proc "c" (pSound: ^sound) -> b32 ---

    sound_is_playing ¶

    sound_is_playing :: proc "c" (pSound: ^sound) -> b32 ---

    sound_is_spatialization_enabled ¶

    sound_is_spatialization_enabled :: proc "c" (pSound: ^sound) -> b32 ---

    sound_seek_to_pcm_frame ¶

    sound_seek_to_pcm_frame :: proc "c" (pSound: ^sound, frameIndex: u64) -> result ---
     

    Just a wrapper around ma_data_source_seek_to_pcm_frame().

    sound_seek_to_second ¶

    sound_seek_to_second :: proc "c" (pSound: ^sound, seekPointInSeconds: f32) -> result ---
     

    Abstraction to ma_sound_seek_to_pcm_frame()

    sound_set_attenuation_model ¶

    sound_set_attenuation_model :: proc "c" (pSound: ^sound, attenuationModel: attenuation_model) ---

    sound_set_cone ¶

    sound_set_cone :: proc "c" (pSound: ^sound, innerAngleInRadians, outerAngleInRadians, outerGain: f32) ---

    sound_set_direction ¶

    sound_set_direction :: proc "c" (pSound: ^sound, x, y, z: f32) ---

    sound_set_directional_attenuation_factor ¶

    sound_set_directional_attenuation_factor :: proc "c" (pSound: ^sound, directionalAttenuationFactor: f32) ---

    sound_set_doppler_factor ¶

    sound_set_doppler_factor :: proc "c" (pSound: ^sound, dopplerFactor: f32) ---

    sound_set_end_callback ¶

    sound_set_end_callback :: proc "c" (pSound: ^sound, callback: sound_end_proc, pUserData: rawptr) ---

    sound_set_fade_in_milliseconds ¶

    sound_set_fade_in_milliseconds :: proc "c" (pSound: ^sound, volumeBeg, volumeEnd: f32, fadeLengthInMilliseconds: u64) ---

    sound_set_fade_in_pcm_frames ¶

    sound_set_fade_in_pcm_frames :: proc "c" (pSound: ^sound, volumeBeg, volumeEnd: f32, fadeLengthInFrames: u64) ---

    sound_set_fade_start_in_milliseconds ¶

    sound_set_fade_start_in_milliseconds :: proc "c" (pSound: ^sound, volumeBeg, volumeEnd: f32, fadeLengthInMilliseconds, absoluteGlobalTimeInMilliseconds: u64) ---

    sound_set_fade_start_in_pcm_frames ¶

    sound_set_fade_start_in_pcm_frames :: proc "c" (pSound: ^sound, volumeBeg, volumeEnd: f32, fadeLengthInFrames, absoluteGlobalTimeInFrames: u64) ---

    sound_set_looping ¶

    sound_set_looping :: proc "c" (pSound: ^sound, isLooping: b32) ---

    sound_set_max_distance ¶

    sound_set_max_distance :: proc "c" (pSound: ^sound, maxDistance: f32) ---

    sound_set_max_gain ¶

    sound_set_max_gain :: proc "c" (pSound: ^sound, maxGain: f32) ---

    sound_set_min_distance ¶

    sound_set_min_distance :: proc "c" (pSound: ^sound, minDistance: f32) ---

    sound_set_min_gain ¶

    sound_set_min_gain :: proc "c" (pSound: ^sound, minGain: f32) ---

    sound_set_pan ¶

    sound_set_pan :: proc "c" (pSound: ^sound, pan: f32) ---

    sound_set_pan_mode ¶

    sound_set_pan_mode :: proc "c" (pSound: ^sound, panMode: pan_mode) ---

    sound_set_pinned_listener_index ¶

    sound_set_pinned_listener_index :: proc "c" (pSound: ^sound, listenerIndex: u32) ---

    sound_set_pitch ¶

    sound_set_pitch :: proc "c" (pSound: ^sound, pitch: f32) ---

    sound_set_position ¶

    sound_set_position :: proc "c" (pSound: ^sound, x, y, z: f32) ---

    sound_set_positioning ¶

    sound_set_positioning :: proc "c" (pSound: ^sound, positioning: positioning) ---

    sound_set_rolloff ¶

    sound_set_rolloff :: proc "c" (pSound: ^sound, rolloff: f32) ---

    sound_set_spatialization_enabled ¶

    sound_set_spatialization_enabled :: proc "c" (pSound: ^sound, enabled: b32) ---

    sound_set_start_time_in_milliseconds ¶

    sound_set_start_time_in_milliseconds :: proc "c" (pSound: ^sound, absoluteGlobalTimeInMilliseconds: u64) ---

    sound_set_start_time_in_pcm_frames ¶

    sound_set_start_time_in_pcm_frames :: proc "c" (pSound: ^sound, absoluteGlobalTimeInFrames: u64) ---

    sound_set_stop_time_in_milliseconds ¶

    sound_set_stop_time_in_milliseconds :: proc "c" (pSound: ^sound, absoluteGlobalTimeInMilliseconds: u64) ---

    sound_set_stop_time_in_pcm_frames ¶

    sound_set_stop_time_in_pcm_frames :: proc "c" (pSound: ^sound, absoluteGlobalTimeInFrames: u64) ---

    sound_set_stop_time_with_fade_in_milliseconds ¶

    sound_set_stop_time_with_fade_in_milliseconds :: proc "c" (pSound: ^sound, fadeAbsoluteGlobalTimeInMilliseconds, fadeLengthInMilliseconds: u64) ---

    sound_set_stop_time_with_fade_in_pcm_frames ¶

    sound_set_stop_time_with_fade_in_pcm_frames :: proc "c" (pSound: ^sound, stopAbsoluteGlobalTimeInFrames, fadeLengthInFrames: u64) ---

    sound_set_velocity ¶

    sound_set_velocity :: proc "c" (pSound: ^sound, x, y, z: f32) ---

    sound_set_volume ¶

    sound_set_volume :: proc "c" (pSound: ^sound, volume: f32) ---

    sound_start ¶

    sound_start :: proc "c" (pSound: ^sound) -> result ---

    sound_stop ¶

    sound_stop :: proc "c" (pSound: ^sound) -> result ---

    sound_stop_with_fade_in_milliseconds ¶

    sound_stop_with_fade_in_milliseconds :: proc "c" (pSound: ^sound, fadeLengthInFrames: u64) ---
     

    Will overwrite any scheduled stop and fade.

    sound_stop_with_fade_in_pcm_frames ¶

    sound_stop_with_fade_in_pcm_frames :: proc "c" (pSound: ^sound, fadeLengthInFrames: u64) ---
     

    Will overwrite any scheduled stop and fade.

    sound_uninit ¶

    sound_uninit :: proc "c" (pSound: ^sound) ---

    spatializer_config_init ¶

    spatializer_config_init :: proc "c" (channelsIn, channelsOut: u32) -> spatializer_config ---

    spatializer_get_attenuation_model ¶

    spatializer_get_attenuation_model :: proc "c" (pSpatializer: ^spatializer) -> attenuation_model ---

    spatializer_get_cone ¶

    spatializer_get_cone :: proc "c" (pSpatializer: ^spatializer, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain: ^f32) ---

    spatializer_get_direction ¶

    spatializer_get_direction :: proc "c" (pSpatializer: ^spatializer) -> vec3f ---

    spatializer_get_directional_attenuation_factor ¶

    spatializer_get_directional_attenuation_factor :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_doppler_factor ¶

    spatializer_get_doppler_factor :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_heap_size ¶

    spatializer_get_heap_size :: proc "c" (pConfig: ^spatializer_config, pHeapSizeInBytes: ^uint) -> result ---

    spatializer_get_input_channels ¶

    spatializer_get_input_channels :: proc "c" (pSpatializer: ^spatializer) -> u32 ---

    spatializer_get_master_volume ¶

    spatializer_get_master_volume :: proc "c" (pSpatializer: ^spatializer, pVolume: ^f32) -> result ---

    spatializer_get_max_distance ¶

    spatializer_get_max_distance :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_max_gain ¶

    spatializer_get_max_gain :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_min_distance ¶

    spatializer_get_min_distance :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_min_gain ¶

    spatializer_get_min_gain :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_output_channels ¶

    spatializer_get_output_channels :: proc "c" (pSpatializer: ^spatializer) -> u32 ---

    spatializer_get_position ¶

    spatializer_get_position :: proc "c" (pSpatializer: ^spatializer) -> vec3f ---

    spatializer_get_positioning ¶

    spatializer_get_positioning :: proc "c" (pSpatializer: ^spatializer) -> positioning ---

    spatializer_get_relative_position_and_direction ¶

    spatializer_get_relative_position_and_direction :: proc "c" (pSpatializer: ^spatializer, pListener: ^spatializer_listener, pRelativePos, pRelativeDir: ^vec3f) ---

    spatializer_get_rolloff ¶

    spatializer_get_rolloff :: proc "c" (pSpatializer: ^spatializer) -> f32 ---

    spatializer_get_velocity ¶

    spatializer_get_velocity :: proc "c" (pSpatializer: ^spatializer) -> vec3f ---

    spatializer_init ¶

    spatializer_init :: proc "c" (pConfig: ^spatializer_config, pAllocationCallbacks: ^allocation_callbacks, pSpatializer: ^spatializer) -> result ---

    spatializer_init_preallocated ¶

    spatializer_init_preallocated :: proc "c" (pConfig: ^spatializer_config, pHeap: rawptr, pSpatializer: ^spatializer) -> result ---

    spatializer_listener_config_init ¶

    spatializer_listener_config_init :: proc "c" (channelsOut: u32) -> spatializer_listener_config ---

    spatializer_listener_get_channel_map ¶

    spatializer_listener_get_channel_map :: proc "c" (pListener: ^spatializer_listener) -> ^channel ---

    spatializer_listener_get_cone ¶

    spatializer_listener_get_cone :: proc "c" (pListener: ^spatializer_listener, pInnerAngleInRadians, pOuterAngleInRadians, pOuterGain: ^f32) ---

    spatializer_listener_get_direction ¶

    spatializer_listener_get_direction :: proc "c" (pListener: ^spatializer_listener) -> vec3f ---

    spatializer_listener_get_heap_size ¶

    spatializer_listener_get_heap_size :: proc "c" (pConfig: ^spatializer_listener_config, pHeapSizeInBytes: ^uint) -> result ---

    spatializer_listener_get_position ¶

    spatializer_listener_get_position :: proc "c" (pListener: ^spatializer_listener) -> vec3f ---

    spatializer_listener_get_speed_of_sound ¶

    spatializer_listener_get_speed_of_sound :: proc "c" (pListener: ^spatializer_listener) -> f32 ---

    spatializer_listener_get_velocity ¶

    spatializer_listener_get_velocity :: proc "c" (pListener: ^spatializer_listener) -> vec3f ---

    spatializer_listener_get_world_up ¶

    spatializer_listener_get_world_up :: proc "c" (pListener: ^spatializer_listener) -> vec3f ---

    spatializer_listener_init ¶

    spatializer_listener_init :: proc "c" (pConfig: ^spatializer_listener_config, pAllocationCallbacks: ^allocation_callbacks, pListener: ^spatializer_listener) -> result ---

    spatializer_listener_init_preallocated ¶

    spatializer_listener_init_preallocated :: proc "c" (pConfig: ^spatializer_listener_config, pHeap: rawptr, pListener: ^spatializer_listener) -> result ---

    spatializer_listener_is_enabled ¶

    spatializer_listener_is_enabled :: proc "c" (pListener: ^spatializer_listener) -> b32 ---

    spatializer_listener_set_cone ¶

    spatializer_listener_set_cone :: proc "c" (pListener: ^spatializer_listener, innerAngleInRadians, outerAngleInRadians, outerGain: f32) ---

    spatializer_listener_set_direction ¶

    spatializer_listener_set_direction :: proc "c" (pListener: ^spatializer_listener, x, y, z: f32) ---

    spatializer_listener_set_enabled ¶

    spatializer_listener_set_enabled :: proc "c" (pListener: ^spatializer_listener, isEnabled: b32) ---

    spatializer_listener_set_position ¶

    spatializer_listener_set_position :: proc "c" (pListener: ^spatializer_listener, x, y, z: f32) ---

    spatializer_listener_set_speed_of_sound ¶

    spatializer_listener_set_speed_of_sound :: proc "c" (pListener: ^spatializer_listener, speedOfSound: f32) ---

    spatializer_listener_set_velocity ¶

    spatializer_listener_set_velocity :: proc "c" (pListener: ^spatializer_listener, x, y, z: f32) ---

    spatializer_listener_set_world_up ¶

    spatializer_listener_set_world_up :: proc "c" (pListener: ^spatializer_listener, x, y, z: f32) ---

    spatializer_listener_uninit ¶

    spatializer_listener_uninit :: proc "c" (pListener: ^spatializer_listener, pAllocationCallbacks: ^allocation_callbacks) ---

    spatializer_process_pcm_frames ¶

    spatializer_process_pcm_frames :: proc "c" (pSpatializer: ^spatializer, pListener: ^spatializer_listener, pFramesOut, pFramesIn: rawptr, frameCount: u64) -> result ---

    spatializer_set_attenuation_model ¶

    spatializer_set_attenuation_model :: proc "c" (pSpatializer: ^spatializer, attenuationModel: attenuation_model) ---

    spatializer_set_cone ¶

    spatializer_set_cone :: proc "c" (pSpatializer: ^spatializer, innerAngleInRadians, outerAngleInRadians, outerGain: f32) ---

    spatializer_set_direction ¶

    spatializer_set_direction :: proc "c" (pSpatializer: ^spatializer, x, y, z: f32) ---

    spatializer_set_directional_attenuation_factor ¶

    spatializer_set_directional_attenuation_factor :: proc "c" (pSpatializer: ^spatializer, directionalAttenuationFactor: f32) ---

    spatializer_set_doppler_factor ¶

    spatializer_set_doppler_factor :: proc "c" (pSpatializer: ^spatializer, dopplerFactor: f32) ---

    spatializer_set_master_volume ¶

    spatializer_set_master_volume :: proc "c" (pSpatializer: ^spatializer, volume: f32) -> result ---

    spatializer_set_max_distance ¶

    spatializer_set_max_distance :: proc "c" (pSpatializer: ^spatializer, maxDistance: f32) ---

    spatializer_set_max_gain ¶

    spatializer_set_max_gain :: proc "c" (pSpatializer: ^spatializer, maxGain: f32) ---

    spatializer_set_min_distance ¶

    spatializer_set_min_distance :: proc "c" (pSpatializer: ^spatializer, minDistance: f32) ---

    spatializer_set_min_gain ¶

    spatializer_set_min_gain :: proc "c" (pSpatializer: ^spatializer, minGain: f32) ---

    spatializer_set_position ¶

    spatializer_set_position :: proc "c" (pSpatializer: ^spatializer, x, y, z: f32) ---

    spatializer_set_positioning ¶

    spatializer_set_positioning :: proc "c" (pSpatializer: ^spatializer, positioning: positioning) ---

    spatializer_set_rolloff ¶

    spatializer_set_rolloff :: proc "c" (pSpatializer: ^spatializer, rolloff: f32) ---

    spatializer_set_velocity ¶

    spatializer_set_velocity :: proc "c" (pSpatializer: ^spatializer, x, y, z: f32) ---

    spatializer_uninit ¶

    spatializer_uninit :: proc "c" (pSpatializer: ^spatializer, pAllocationCallbacks: ^allocation_callbacks) ---

    spinlock_lock ¶

    spinlock_lock :: proc "c" (pSpinlock: ^spinlock) -> result ---
     

    Locks a spinlock.

    spinlock_lock_noyield ¶

    spinlock_lock_noyield :: proc "c" (pSpinlock: ^spinlock) -> result ---
     

    Locks a spinlock, but does not yield() when looping.

    spinlock_unlock ¶

    spinlock_unlock :: proc "c" (pSpinlock: ^spinlock) -> result ---
     

    Unlocks a spinlock.

    splitter_node_config_init ¶

    splitter_node_config_init :: proc "c" (channels: u32) -> splitter_node_config ---

    splitter_node_init ¶

    splitter_node_init :: proc "c" (pNodeGraph: ^node_graph, pConfig: ^splitter_node_config, pAllocationCallbacks: ^allocation_callbacks, pSplitterNode: ^splitter_node) -> result ---

    splitter_node_uninit ¶

    splitter_node_uninit :: proc "c" (pSplitterNode: ^splitter_node, pAllocationCallbacks: ^allocation_callbacks) ---

    version ¶

    version :: proc "c" (pMajor, pMinor, pRevision: ^u32) ---

    version_check ¶

    version_check :: proc "contextless" () {…}

    version_string ¶

    version_string :: proc "c" () -> cstring ---

    vfs_close ¶

    vfs_close :: proc "c" (pVFS: ^vfs, file: vfs_file) -> result ---

    vfs_info ¶

    vfs_info :: proc "c" (pVFS: ^vfs, file: vfs_file, pInfo: ^file_info) -> result ---

    vfs_open ¶

    vfs_open :: proc "c" (pVFS: ^vfs, pFilePath: cstring, openMode: bit_set[open_mode_flag; u32], pFile: ^vfs_file) -> result ---

    vfs_open_and_read_file ¶

    vfs_open_and_read_file :: proc "c" (pVFS: ^vfs, pFilePath: cstring, ppData: ^rawptr, pSize: ^uint, pAllocationCallbacks: ^allocation_callbacks) -> result ---

    vfs_open_w ¶

    vfs_open_w :: proc "c" (pVFS: ^vfs, pFilePath: [^]u16, openMode: bit_set[open_mode_flag; u32], pFile: ^vfs_file) -> result ---

    vfs_read ¶

    vfs_read :: proc "c" (pVFS: ^vfs, file: vfs_file, pDst: rawptr, sizeInBytes: uint, pBytesRead: ^uint) -> result ---

    vfs_seek ¶

    vfs_seek :: proc "c" (pVFS: ^vfs, file: vfs_file, offset: i64, origin: seek_origin) -> result ---

    vfs_tell ¶

    vfs_tell :: proc "c" (pVFS: ^vfs, file: vfs_file, pCursor: ^i64) -> result ---

    vfs_write ¶

    vfs_write :: proc "c" (pVFS: ^vfs, file: vfs_file, pSrc: rawptr, sizeInBytes: uint, pBytesWritten: ^uint) -> result ---

    volume_db_to_linear ¶

    volume_db_to_linear :: proc "c" (gain: f32) -> f32 ---
     

    Helper for converting gain in decibels to a linear factor.

    volume_linear_to_db ¶

    volume_linear_to_db :: proc "c" (factor: f32) -> f32 ---
     

    Helper for converting a linear factor to gain in decibels.

    waveform_config_init ¶

    waveform_config_init :: proc "c" (
    	format:     format, 
    	channels:   u32, 
    	sampleRate: u32, 
    	type:       waveform_type, 
    	amplitude:  f64, 
    	frequency:  f64, 
    ) -> waveform_config ---

    waveform_init ¶

    waveform_init :: proc "c" (pConfig: ^waveform_config, pWaveform: ^waveform) -> result ---

    waveform_read_pcm_frames ¶

    waveform_read_pcm_frames :: proc "c" (pWaveform: ^waveform, pFramesOut: rawptr, frameCount: u64, pFramesRead: ^u64) -> result ---

    waveform_seek_to_pcm_frame ¶

    waveform_seek_to_pcm_frame :: proc "c" (pWaveform: ^waveform, frameIndex: u64) -> result ---

    waveform_set_amplitude ¶

    waveform_set_amplitude :: proc "c" (pWaveform: ^waveform, amplitude: f64) -> result ---

    waveform_set_frequency ¶

    waveform_set_frequency :: proc "c" (pWaveform: ^waveform, frequency: f64) -> result ---

    waveform_set_sample_rate ¶

    waveform_set_sample_rate :: proc "c" (pWaveform: ^waveform, sampleRate: u32) -> result ---

    waveform_set_type ¶

    waveform_set_type :: proc "c" (pWaveform: ^waveform, type: waveform_type) -> result ---

    waveform_uninit ¶

    waveform_uninit :: proc "c" (pWaveform: ^waveform) ---

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2025-10 (vendor "odin") Windows_amd64 @ 2025-10-28 21:13:09.526222200 +0000 UTC