16.1. Low-level audio bindings (miniaudio)
Module audio
16.1.1. Constants
- MA_SAMPLE_RATE = 48000
Audio output sample rate in Hz (default 48000, configured at compile time via CMake).
16.1.2. Enumerations
- I3DL2Preset
I3DL2 reverb environment preset.
- Values:
Generic = 0 - Generic room with moderate reflections.
PaddedCell = 1 - Small padded cell with very short decay.
Room = 2 - Standard room.
Bathroom = 3 - Bathroom with hard reflective surfaces.
LivingRoom = 4 - Living room with moderate absorption.
StoneRoom = 5 - Stone room with strong reflections.
Auditorium = 6 - Auditorium with long decay.
ConcertHall = 7 - Concert hall with rich reverb.
Cave = 8 - Cave with very long decay and diffusion.
Arena = 9 - Arena with large open space reverb.
Hangar = 10 - Hangar with metallic reflections.
CarpetedHallway = 11 - Carpeted hallway with damped reflections.
Hallway = 12 - Hallway with moderate reflections.
StoneCorridor = 13 - Stone corridor with bright reflections.
Alley = 14 - Alley with short outdoor reverb.
Forest = 15 - Forest with natural outdoor absorption.
City = 16 - City with urban reflections.
Mountains = 17 - Mountains with distant echoes.
Quarry = 18 - Quarry with hard surface reflections.
Plain = 19 - Open plain with minimal reverb.
ParkingLot = 20 - Parking lot with concrete reflections.
SewerPipe = 21 - Sewer pipe with tubular resonance.
Underwater = 22 - Underwater with heavily filtered sound.
- ma_channel_mix_mode
Channel mixing strategy when converting between channel counts.
- Values:
ma_channel_mix_mode_rectangular = 0 - Rectangular panning (simple matrix mix).
ma_channel_mix_mode_simple = 1 - Simple channel mapping (drop or duplicate channels).
ma_channel_mix_mode_custom_weights = 2 - Custom weight matrix.
ma_channel_mix_mode_default = 0 - Default mixing mode.
- ma_dither_mode
Dithering mode for format conversion.
- Values:
ma_dither_mode_none = 0 - No dithering.
ma_dither_mode_rectangle = 1 - Rectangular probability distribution dither.
ma_dither_mode_triangle = 2 - Triangular probability distribution dither.
- ma_format
Audio sample format.
- Values:
ma_format_unknown = 0 - Unknown or unspecified format.
ma_format_u8 = 1 - Unsigned 8-bit integer.
ma_format_s16 = 2 - Signed 16-bit integer.
ma_format_s24 = 3 - Signed 24-bit integer (packed).
ma_format_s32 = 4 - Signed 32-bit integer.
ma_format_f32 = 5 - 32-bit floating point.
- ma_resample_algorithm
Sample rate conversion algorithm.
- Values:
ma_resample_algorithm_linear = 0 - Linear interpolation.
ma_resample_algorithm_custom = 1 - Custom resampling algorithm.
- ma_result
Miniaudio result code.
- Values:
MA_SUCCESS = 0 - Operation completed successfully.
MA_ERROR = -1 - Generic error.
MA_INVALID_ARGS = -2 - Invalid arguments.
MA_INVALID_OPERATION = -3 - Invalid operation for current state.
MA_OUT_OF_MEMORY = -4 - Out of memory.
MA_OUT_OF_RANGE = -5 - Value out of range.
MA_ACCESS_DENIED = -6 - Access denied.
MA_DOES_NOT_EXIST = -7 - Resource does not exist.
MA_ALREADY_EXISTS = -8 - Resource already exists.
MA_TOO_MANY_OPEN_FILES = -9 - Too many open files.
MA_INVALID_FILE = -10 - Invalid file.
MA_TOO_BIG = -11 - Data too big.
MA_PATH_TOO_LONG = -12 - Path too long.
MA_NAME_TOO_LONG = -13 - Name too long.
MA_NOT_DIRECTORY = -14 - Not a directory.
MA_IS_DIRECTORY = -15 - Is a directory.
MA_DIRECTORY_NOT_EMPTY = -16 - Directory not empty.
MA_AT_END = -17 - Reached end of data.
MA_NO_SPACE = -18 - No space available.
MA_BUSY = -19 - Resource is busy.
MA_IO_ERROR = -20 - I/O error.
MA_INTERRUPT = -21 - Operation interrupted.
MA_UNAVAILABLE = -22 - Resource unavailable.
MA_ALREADY_IN_USE = -23 - Resource already in use.
MA_BAD_ADDRESS = -24 - Bad address.
MA_BAD_SEEK = -25 - Bad seek position.
MA_BAD_PIPE = -26 - Bad pipe.
MA_DEADLOCK = -27 - Deadlock detected.
MA_TOO_MANY_LINKS = -28 - Too many links.
MA_NOT_IMPLEMENTED = -29 - Not implemented.
MA_NO_MESSAGE = -30 - No message available.
MA_BAD_MESSAGE = -31 - Bad message format.
MA_NO_DATA_AVAILABLE = -32 - No data available.
MA_INVALID_DATA = -33 - Invalid data.
MA_TIMEOUT = -34 - Operation timed out.
MA_NO_NETWORK = -35 - No network.
MA_NOT_UNIQUE = -36 - Not unique.
MA_NOT_SOCKET = -37 - Not a socket.
MA_NO_ADDRESS = -38 - No address.
MA_BAD_PROTOCOL = -39 - Bad protocol.
MA_PROTOCOL_UNAVAILABLE = -40 - Protocol unavailable.
MA_PROTOCOL_NOT_SUPPORTED = -41 - Protocol not supported.
MA_PROTOCOL_FAMILY_NOT_SUPPORTED = -42 - Protocol family not supported.
MA_ADDRESS_FAMILY_NOT_SUPPORTED = -43 - Address family not supported.
MA_SOCKET_NOT_SUPPORTED = -44 - Socket not supported.
MA_CONNECTION_RESET = -45 - Connection reset.
MA_ALREADY_CONNECTED = -46 - Already connected.
MA_NOT_CONNECTED = -47 - Not connected.
MA_CONNECTION_REFUSED = -48 - Connection refused.
MA_NO_HOST = -49 - No host found.
MA_IN_PROGRESS = -50 - Operation in progress.
MA_CANCELLED = -51 - Operation cancelled.
MA_MEMORY_ALREADY_MAPPED = -52 - Memory already mapped.
MA_FORMAT_NOT_SUPPORTED = -200 - Audio format not supported.
MA_DEVICE_TYPE_NOT_SUPPORTED = -201 - Device type not supported.
MA_SHARE_MODE_NOT_SUPPORTED = -202 - Share mode not supported.
MA_NO_BACKEND = -203 - No audio backend available.
MA_NO_DEVICE = -204 - No audio device found.
MA_API_NOT_FOUND = -205 - API not found.
MA_INVALID_DEVICE_CONFIG = -206 - Invalid device configuration.
MA_LOOP = -207 - Loop detected.
MA_DEVICE_NOT_INITIALIZED = -300 - Device not initialized.
MA_DEVICE_ALREADY_INITIALIZED = -301 - Device already initialized.
MA_DEVICE_NOT_STARTED = -302 - Device not started.
MA_DEVICE_NOT_STOPPED = -303 - Device not stopped.
MA_FAILED_TO_INIT_BACKEND = -400 - Failed to initialize backend.
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -401 - Failed to open backend device.
MA_FAILED_TO_START_BACKEND_DEVICE = -402 - Failed to start backend device.
MA_FAILED_TO_STOP_BACKEND_DEVICE = -403 - Failed to stop backend device.
16.1.3. Handled structures
- ma_decoder
Audio decoder instance. Supports WAV, MP3, FLAC, and Vorbis.
- Fields:
outputFormat : ma_format - Output audio sample format.
outputChannels : uint - Output sample rate in Hz.
outputSampleRate : uint - Number of output channels.
- ma_delay
Miniaudio stereo delay effect with an internal ring buffer for storing delayed samples.
- ma_limiter
Look-ahead brick-wall limiter.
- Fields:
gain : float[254] - Number of channels.
nChannels : uint - Gain reduction buffer.
attack_samples : uint - Look-ahead attack in samples.
threshold : float - Attack smoothing coefficient.
attack_coeff : float - Limiter threshold (0.0 to 1.0).
release_coeff : float - Release smoothing coefficient.
linear_limiter : float - Linear limiter bypass flag.
- ma_volume_mixer
Volume and pan processor with fade support.
- Fields:
volume : float - Target volume for fade.
dvolume : float - Number of channels.
tvolume : float - Current volume level.
pan : float - Stereo pan position (-1.0 left, 1.0 right).
channels : uint - Volume delta per frame during fade.
- I3DL2Reverb
I3DL2 reverb processor instance.
- ConvolutionReverb
Partitioned FFT convolution reverb with synthetic impulse response. Uses overlap-save convolution with a frequency-domain delay line for efficient real-time processing.
- Fields:
decayTime : float - decayTime: Reverb decay time in seconds (time to reach -60dB).
lpFreqStart : float - lpFreqStart: Lowpass filter starting frequency in Hz.
lpFreqEnd : float - lpFreqEnd: Lowpass filter ending frequency at -60dB in Hz.
fadeIn : float - fadeIn: Impulse response fade-in time in seconds.
sampleRate : uint - sampleRate: Audio sample rate in Hz.
fft_size : uint - fft_size: FFT size used for partitioned convolution (2 x block size).
ir_length : uint - ir_length: Impulse response length in samples.
num_partitions : uint - num_partitions: Number of IR partitions (ir_length / block_size, rounded up).
- I3DL2ReverbProperties
I3DL2 reverb parameters.
- Fields:
lRoom : int - Room effect level in millibels.
lRoomHF : int - Room effect high-frequency level in millibels.
flDecayTime : float - Decay time in seconds.
flDecayHFRatio : float - High-frequency decay time ratio.
lReflections : int - Early reflections level in millibels.
flReflectionsDelay : float - Early reflections delay in seconds.
lReverb : int - Late reverb level in millibels.
flReverbDelay : float - Late reverb delay in seconds.
flDiffusion : float - Echo density percentage (0-100).
flDensity : float - Modal density percentage (0-100).
- ma_sf2_envelope
SF2 ADSR envelope generator.
- Fields:
stage : int - Level at start of release phase.
level : float - Release time in seconds.
release_level : float - Decay time in seconds.
slope : float - Current envelope stage.
is_exponential : int - Current envelope level.
is_amp_env : int - Hold time in seconds.
midi_velocity : int - MIDI velocity value (0-127).
samples_until_next : float - Samples remaining until next stage transition.
delay_sec : float - Current level change rate per sample.
attack_sec : float - Delay time in seconds.
hold_sec : float - Sustain level (0.0 to 1.0).
decay_sec : float - Attack time in seconds.
sustain_level : float - Whether this is an amplitude envelope.
release_sec : float - Whether decay/release use exponential curves.
- ma_sf2_voice
SF2 voice – sample playback with pitch, envelopes, filter, and LFO modulation.
- Fields:
sample_start : int - Sample loop end position.
sample_end : int - Loop mode (0=none, 1=continuous, 3=until release).
loop_start : int - Current playback position in samples.
loop_end : int - Modulation LFO delay in seconds.
loop_mode : int - Right channel sample start offset (stereo).
sample_start_r : int - Vibrato LFO delay in seconds.
sample_end_r : int - Modulation LFO phase accumulator.
loop_start_r : int - Vibrato LFO pitch modulation in cents.
loop_end_r : int - Right channel sample end offset (stereo).
stereo : int - Whether this is a stereo voice.
position : double - Right channel loop end offset (stereo).
phase_inc : double - Biquad resonant filter state.
vol_env : ma_sf2_envelope - Pitch bend offset in cents.
mod_env : ma_sf2_envelope - Whether note-off has been received.
filter : ma_sf2_biquad - Whether the voice has finished playing.
filter_r : ma_sf2_biquad - Modulation envelope state.
initial_filter_fc : float - Sample loop start position.
initial_filter_q : float - Modulation LFO elapsed time.
mod_env_to_pitch : float - Volume attenuation in centibels.
mod_lfo_to_pitch : float - Base sample rate in Hz.
vib_lfo_to_pitch : float - Right channel loop start offset (stereo).
mod_env_to_filter_fc : float - Vibrato LFO phase accumulator.
mod_lfo_to_filter_fc : float - Volume envelope state.
mod_lfo_to_volume : float - Phase increment per output sample.
mod_lfo_phase : float - Stereo pan position (-0.5 left, 0.5 right).
mod_lfo_freq : float - Modulation LFO to volume depth in centibels.
mod_lfo_delay : float - Initial filter resonance Q.
mod_lfo_elapsed : float - Modulation envelope to pitch depth in cents.
vib_lfo_phase : float - Sample end position.
vib_lfo_freq : float - Modulation LFO to pitch depth in cents.
vib_lfo_delay : float - Modulation envelope to filter cutoff depth in cents.
vib_lfo_elapsed : float - Modulation LFO to filter cutoff depth in cents.
pitch_bend_cents : float - Initial filter cutoff frequency in cents.
attenuation : float - Vibrato LFO frequency in Hz.
pan : float - Vibrato LFO elapsed time.
released : int - Modulation LFO frequency in Hz.
finished : int - Sample start position.
sample_rate : float - Right channel biquad filter state (stereo).
- ma_decoder_config
Audio decoder configuration.
- Fields:
format : ma_format - Number of output channels.
channels : uint - Channel mixing mode.
channelMap : uint8? - Dithering mode for format conversion.
channelMixMode : ma_channel_mix_mode - Channel mapping array (null for default).
ditherMode : ma_dither_mode - Output sample format.
- ma_channel_converter_config
Channel converter configuration.
- Fields:
format : ma_format - Number of input channels.
channelsIn : uint - Number of output channels.
channelsOut : uint - Channel mixing mode.
channelMapIn : uint8? - Custom mixing weight matrix (null for default).
channelMapOut : uint8? - Input channel map (null for default).
mixingMode : ma_channel_mix_mode - Sample format.
weights : float?? - Output channel map (null for default).
- ma_hrtf
HRTF binaural 3D audio processor using CIPIC database.
- Fields:
taps : uint - Number of filter taps.
azimuth : int - Left ear FIR filter pointer.
elevation : int - Elevation angle in degrees.
sampleRate : uint - Azimuth angle in degrees.
leftfip : int16? - Right ear FIR filter pointer.
rightfip : int16? - FFT size.
fft_size : uint - Sample rate in Hz.
- ma_resampler_config
Sample rate converter configuration.
- Fields:
format : ma_format - Number of channels.
channels : uint - Sample format.
sampleRateIn : uint - Output sample rate in Hz.
sampleRateOut : uint - Input sample rate in Hz.
- ma_channel_converter
Channel layout converter instance (e.g. mono to stereo).
- ma_resampler
Sample rate converter instance.
- Fields:
format : ma_format - Number of channels.
channels : uint - Sample format.
sampleRateIn : uint - Output sample rate in Hz.
sampleRateOut : uint - Input sample rate in Hz.
- ma_chorus_config
Chorus effect configuration.
- Fields:
rate : float - Base delay in milliseconds.
depth : float - LFO modulation rate in Hz.
feedback : float - Wet/dry mix (0.0 dry, 1.0 fully wet).
delay_ms : float - LFO modulation depth.
wet : float - Feedback amount.
- ma_sf2_biquad
SF2 biquad resonant filter (transposed direct form II).
- Fields:
q_inv : double - Inverse of Q (resonance).
a0 : double - Feedforward coefficient a0.
a1 : double - Feedforward coefficient a1.
b1 : double - Feedback coefficient b1.
b2 : double - Feedback coefficient b2.
z1 : double - Filter state z1.
z2 : double - Filter state z2.
active : int - Whether the filter is active.
- ma_chorus
Stereo chorus processor with 4 modulated delay taps.
16.1.4. Audio device
- mixer_context(): Context&
Get the audio mixer thread’s context.
- sound_finalize()
Shut down the audio device and release resources.
- sound_initalize(mixer: function<(array<float>#;int;int;float):void>; rate: int; channels: int; context: Context): bool
Initialize the audio device with a mixer callback. Call once before any audio playback.
- Arguments:
mixer : function<(array<float>#;int;int;float):void>
rate : int
channels : int
context : Context implicit
16.1.5. Decoder
ma_decoder_get_available_frames (decoder: ma_decoder?; pAvailableFrames: uint64?) : ma_result
ma_decoder_get_cursor_in_pcm_frames (decoder: ma_decoder?; pCursor: uint64?) : ma_result
ma_decoder_get_length_in_pcm_frames (decoder: ma_decoder?) : uint64
ma_decoder_read_pcm_frames (decoder: ma_decoder?; pFramesOut: void?; frameCount: uint64) : uint64
ma_decoder_seek_to_pcm_frame (decoder: ma_decoder?; frameIndex: uint64) : ma_result
- ma_decoder_config_init(outputFormat: ma_format; outputChannels: uint; outputSampleRate: uint): ma_decoder_config
Create a decoder config with the specified output format, channels, and sample rate.
- Arguments:
outputFormat : ma_format
outputChannels : uint
outputSampleRate : uint
- ma_decoder_config_init_default(): ma_decoder_config
Create a decoder config with default settings (auto-detect format).
- ma_decoder_get_available_frames(decoder: ma_decoder?; pAvailableFrames: uint64?): ma_result
Get the number of frames available for reading.
- Arguments:
decoder : ma_decoder? implicit
pAvailableFrames : uint64? implicit
- ma_decoder_get_cursor_in_pcm_frames(decoder: ma_decoder?; pCursor: uint64?): ma_result
Get the current read position in PCM frames.
- Arguments:
decoder : ma_decoder? implicit
pCursor : uint64? implicit
- ma_decoder_get_length_in_pcm_frames(decoder: ma_decoder?): uint64
Get the total length of the audio in PCM frames.
- Arguments:
decoder : ma_decoder? implicit
- ma_decoder_init_file(pFilePath: string; config: ma_decoder_config const?; decoder: ma_decoder?): ma_result
Initialize a decoder from an audio file path. Supports WAV, MP3, FLAC, and Vorbis.
- Arguments:
pFilePath : string implicit
config : ma_decoder_config? implicit
decoder : ma_decoder? implicit
- ma_decoder_init_memory(pData: void?; dataSize: uint64; config: ma_decoder_config const?; decoder: ma_decoder?): ma_result
Initialize a decoder from an in-memory audio buffer.
- Arguments:
pData : void? implicit
dataSize : uint64
config : ma_decoder_config? implicit
decoder : ma_decoder? implicit
- ma_decoder_read_pcm_frames(decoder: ma_decoder?; pFramesOut: void?; frameCount: uint64): uint64
Read PCM frames from the decoder into a buffer. Returns the number of frames actually read.
- Arguments:
decoder : ma_decoder? implicit
pFramesOut : void? implicit
frameCount : uint64
- ma_decoder_seek_to_pcm_frame(decoder: ma_decoder?; frameIndex: uint64): ma_result
Seek to a specific PCM frame position.
- Arguments:
decoder : ma_decoder? implicit
frameIndex : uint64
- ma_decoder_uninit(decoder: ma_decoder?): ma_result
Uninitialize a decoder and release its resources.
- Arguments:
decoder : ma_decoder? implicit
16.1.6. Resampler
ma_resampler_disable_linear_filtering (config: ma_resampler_config?)
ma_resampler_get_input_latency (resampler: ma_resampler const?) : uint64
ma_resampler_get_output_latency (resampler: ma_resampler const?) : uint64
ma_resampler_init (config: ma_resampler_config const?; resampler: ma_resampler?) : ma_result
ma_resampler_set_rate_ratio (resampler: ma_resampler?; ratioInOut: float) : ma_result
- ma_resampler_config_init(format: ma_format; channels: uint; sampleRateIn: uint; sampleRateOut: uint; algorithm: ma_resample_algorithm): ma_resampler_config
Create a resampler config with format, channels, input rate, output rate, and algorithm.
- Arguments:
format : ma_format
channels : uint
sampleRateIn : uint
sampleRateOut : uint
algorithm : ma_resample_algorithm
- ma_resampler_disable_linear_filtering(config: ma_resampler_config?)
Disable linear interpolation filtering on the resampler config.
- Arguments:
config : ma_resampler_config? implicit
- ma_resampler_get_expected_output_frame_count(resampler: ma_resampler const?; inputFrameCount: uint64): uint64
Get how many output frames will be produced from the given input frames.
- Arguments:
resampler : ma_resampler? implicit
inputFrameCount : uint64
- ma_resampler_get_input_latency(resampler: ma_resampler const?): uint64
Get the input latency in frames.
- Arguments:
resampler : ma_resampler? implicit
- ma_resampler_get_output_latency(resampler: ma_resampler const?): uint64
Get the output latency in frames.
- Arguments:
resampler : ma_resampler? implicit
- ma_resampler_get_required_input_frame_count(resampler: ma_resampler const?; outputFrameCount: uint64): uint64
Get how many input frames are needed to produce the given output frames.
- Arguments:
resampler : ma_resampler? implicit
outputFrameCount : uint64
- ma_resampler_init(config: ma_resampler_config const?; resampler: ma_resampler?): ma_result
Initialize a resampler from a config.
- Arguments:
config : ma_resampler_config? implicit
resampler : ma_resampler? implicit
- ma_resampler_process_pcm_frames(resampler: ma_resampler?; pFramesIn: void?; pFrameCountIn: uint64?; pFramesOut: void?; pFrameCountOut: uint64?): ma_result
Process PCM frames through the resampler, converting between sample rates.
- Arguments:
resampler : ma_resampler? implicit
pFramesIn : void? implicit
pFrameCountIn : uint64? implicit
pFramesOut : void? implicit
pFrameCountOut : uint64? implicit
- ma_resampler_set_rate(resampler: ma_resampler?; sampleRateIn: uint; sampleRateOut: uint): ma_result
Change the input and output sample rates dynamically.
- Arguments:
resampler : ma_resampler? implicit
sampleRateIn : uint
sampleRateOut : uint
- ma_resampler_set_rate_ratio(resampler: ma_resampler?; ratioInOut: float): ma_result
Set the resampling ratio directly as a float.
- Arguments:
resampler : ma_resampler? implicit
ratioInOut : float
- ma_resampler_uninit(resampler: ma_resampler?)
Uninitialize a resampler.
- Arguments:
resampler : ma_resampler? implicit
16.1.7. Channel converter
- ma_channel_converter_config_init(format: ma_format; channelsIn: uint; channelsOut: uint8 const?; channelMapIn: uint; channelMapOut: uint8 const?; mixingMode: ma_channel_mix_mode): ma_channel_converter_config
Create a channel converter config for converting between channel layouts.
- Arguments:
format : ma_format
channelsIn : uint
channelsOut : uint8? implicit
channelMapIn : uint
channelMapOut : uint8? implicit
mixingMode : ma_channel_mix_mode
- ma_channel_converter_init(config: ma_channel_converter_config const?; converter: ma_channel_converter?): ma_result
Initialize a channel converter from a config.
- Arguments:
config : ma_channel_converter_config? implicit
converter : ma_channel_converter? implicit
- ma_channel_converter_process_pcm_frames(converter: ma_channel_converter?; pFramesOut: void?; pFramesIn: void?; frameCount: uint64): ma_result
Convert PCM frames between channel layouts (e.g. mono to stereo).
- Arguments:
converter : ma_channel_converter? implicit
pFramesOut : void? implicit
pFramesIn : void? implicit
frameCount : uint64
- ma_channel_converter_uninit(converter: ma_channel_converter?)
Uninitialize a channel converter.
- Arguments:
converter : ma_channel_converter? implicit
16.1.8. Volume mixer
ma_volume_mixer_init (mixer: ma_volume_mixer?; nChannels: uint)
ma_volume_mixer_set_channels (mixer: ma_volume_mixer?; nChannels: uint)
ma_volume_mixer_set_linear_pan (mixer: ma_volume_mixer?; linearPan: bool)
ma_volume_mixer_set_pan (mixer: ma_volume_mixer?; pan: float)
ma_volume_mixer_set_pan_immediate (mixer: ma_volume_mixer?; pan: float)
ma_volume_mixer_set_volume (mixer: ma_volume_mixer?; volume: float)
ma_volume_mixer_set_volume_over_time (mixer: ma_volume_mixer?; volume: float; nFrames: uint64)
- ma_volume_mixer_init(mixer: ma_volume_mixer?; nChannels: uint)
Initialize a volume mixer with the specified number of channels.
- Arguments:
mixer : ma_volume_mixer? implicit
nChannels : uint
- ma_volume_mixer_process_pcm_frames(mixer: ma_volume_mixer?; pFramesOut: float?; pFramesIn: float?; frameCount: uint64)
Apply volume, pan, and fading to PCM frames.
- Arguments:
mixer : ma_volume_mixer? implicit
pFramesOut : float? implicit
pFramesIn : float? implicit
frameCount : uint64
- ma_volume_mixer_set_channels(mixer: ma_volume_mixer?; nChannels: uint)
Set the number of channels for the volume mixer.
- Arguments:
mixer : ma_volume_mixer? implicit
nChannels : uint
- ma_volume_mixer_set_linear_pan(mixer: ma_volume_mixer?; linearPan: bool)
Enable or disable linear panning mode on the volume mixer. When enabled, pan uses linear gain curves; when disabled, it uses equal-power (constant-power) panning.
- Arguments:
mixer : ma_volume_mixer? implicit
linearPan : bool
- ma_volume_mixer_set_pan(mixer: ma_volume_mixer?; pan: float)
Set stereo pan position (-1.0 left to 1.0 right).
- Arguments:
mixer : ma_volume_mixer? implicit
pan : float
- ma_volume_mixer_set_pan_immediate(mixer: ma_volume_mixer?; pan: float)
Set the stereo pan position on the volume mixer immediately without any smoothing or interpolation, where -1.0 is full left and 1.0 is full right.
- Arguments:
mixer : ma_volume_mixer? implicit
pan : float
- ma_volume_mixer_set_volume(mixer: ma_volume_mixer?; volume: float)
Set the volume level (0.0 to 1.0+).
- Arguments:
mixer : ma_volume_mixer? implicit
volume : float
- ma_volume_mixer_set_volume_over_time(mixer: ma_volume_mixer?; volume: float; nFrames: uint64)
Set volume with a fade over the specified number of frames.
- Arguments:
mixer : ma_volume_mixer? implicit
volume : float
nFrames : uint64
- ma_volume_mixer_uninit(mixer: ma_volume_mixer?)
Uninitialize a volume mixer.
- Arguments:
mixer : ma_volume_mixer? implicit
16.1.9. Limiter
- ma_limiter_get_required_input_frame_count(limiter: ma_limiter?; out_len: uint64): uint64
Get how many input frames are needed for the given output frames.
- Arguments:
limiter : ma_limiter? implicit
out_len : uint64
- ma_limiter_init(limiter: ma_limiter?; threshold: float; attack_time: float; release_time: float; sample_rate: float; nChannels: uint)
Initialize a look-ahead limiter with threshold, attack, release, and sample rate.
- Arguments:
limiter : ma_limiter? implicit
threshold : float
attack_time : float
release_time : float
sample_rate : float
nChannels : uint
- ma_limiter_init_linear(limiter: ma_limiter?; nChannels: uint)
Initialize a limiter in linear (pass-through) mode.
- Arguments:
limiter : ma_limiter? implicit
nChannels : uint
- ma_limiter_process_pcm_frames(limiter: ma_limiter?; InFames: float?; OutFrames: float?; nFrames: uint64)
Process PCM frames through the limiter.
- Arguments:
limiter : ma_limiter? implicit
InFames : float? implicit
OutFrames : float? implicit
nFrames : uint64
- ma_limiter_uninit(limiter: ma_limiter?)
Uninitialize a limiter.
- Arguments:
limiter : ma_limiter? implicit
16.1.10. HRTF
- ma_hrtf_init(hrtf: ma_hrtf?; sampleRate: uint)
Initialize HRTF processor for binaural 3D audio at the given sample rate.
- Arguments:
hrtf : ma_hrtf? implicit
sampleRate : uint
- ma_hrtf_process_frames(hrtf: ma_hrtf?; pOut: float?; pIn: float const?; nChannels: uint; frameCount: uint)
Process mono input frames through HRTF, producing stereo output with spatial positioning.
- Arguments:
hrtf : ma_hrtf? implicit
pOut : float? implicit
pIn : float? implicit
nChannels : uint
frameCount : uint
- ma_hrtf_set_direction(hrtf: ma_hrtf?; azimuth: int; elevation: int)
Set the sound source direction as azimuth and elevation in degrees.
- Arguments:
hrtf : ma_hrtf? implicit
azimuth : int
elevation : int
- ma_hrtf_uninit(hrtf: ma_hrtf?)
Uninitialize HRTF processor and release resources.
- Arguments:
hrtf : ma_hrtf? implicit
16.1.11. I3DL2 Reverb
- get_preset(preset: I3DL2Preset): I3DL2ReverbProperties&
Get the I3DL2ReverbProperties for a named preset.
- Arguments:
preset : I3DL2Preset
- process_mono(reverb: I3DL2Reverb?; input: float?; output: float?; nSamples: int)
Process mono audio through the reverb, producing stereo wet output.
- Arguments:
reverb : I3DL2Reverb? implicit
input : float? implicit
output : float? implicit
nSamples : int
- process_stereo(reverb: I3DL2Reverb?; input: float?; output: float?; nSamples: int)
Process stereo audio through the reverb.
- Arguments:
reverb : I3DL2Reverb? implicit
input : float? implicit
output : float? implicit
nSamples : int
- set_properties(reverb: I3DL2Reverb?; props: I3DL2ReverbProperties)
Set reverb parameters from an I3DL2ReverbProperties struct.
- Arguments:
reverb : I3DL2Reverb? implicit
props : I3DL2ReverbProperties implicit
- set_sample_rate(reverb: I3DL2Reverb?; rate: float)
Set the reverb processor’s sample rate.
- Arguments:
reverb : I3DL2Reverb? implicit
rate : float
16.1.12. Convolution Reverb
- conv_reverb_get_max_ir(): float
Returns the current maximum impulse response length in seconds. See conv_reverb_set_max_ir.
- conv_reverb_init(reverb: ConvolutionReverb?; sample_rate: int; decay_time: float; lp_freq_start: float; lp_freq_end: float; fade_in: float)
Initialize a convolution reverb with a synthetic impulse response. Generates random noise with exponential decay and a gradient lowpass sweep, then partitions it for efficient FFT-based convolution. decay_time is the -60dB fade time in seconds. lp_freq_start and lp_freq_end control the lowpass sweep from bright to dark over the decay. fade_in ramps the IR onset to avoid clicks.
- Arguments:
reverb : ConvolutionReverb? implicit
sample_rate : int
decay_time : float
lp_freq_start : float
lp_freq_end : float
fade_in : float
- conv_reverb_process(reverb: ConvolutionReverb?; input: float?; output: float?; nFrames: int)
Process interleaved stereo audio through the convolution reverb. Input is downmixed to mono, then convolved with separate L/R impulse responses for stereo decorrelation. Output is interleaved stereo. nFrames is the number of stereo frames (not samples).
- Arguments:
reverb : ConvolutionReverb? implicit
input : float? implicit
output : float? implicit
nFrames : int
- conv_reverb_process_mono(reverb: ConvolutionReverb?; input: float?; output: float?; nSamples: int)
Process mono audio through the convolution reverb (left IR only). nSamples is the number of mono samples. Used for baking reverb into pre-rendered drum buffers.
- Arguments:
reverb : ConvolutionReverb? implicit
input : float? implicit
output : float? implicit
nSamples : int
- conv_reverb_set_max_ir(seconds: float)
Set the maximum impulse response length in seconds (default 8.0). Affects newly created reverbs only. Lower values reduce CPU cost; higher values allow longer reverb tails. The IR is capped at min(decayTime * 1.5, max_ir).
- Arguments:
seconds : float
- conv_reverb_uninit(reverb: ConvolutionReverb?)
Release all resources (FFT workspace, arena buffers) owned by the convolution reverb. Must be called before deleting the reverb object.
- Arguments:
reverb : ConvolutionReverb? implicit
16.1.13. Chorus
- chorus_config_default(): ma_chorus_config
Get the default chorus configuration.
- chorus_init(chorus: ma_chorus?; sample_rate: float)
Initialize a 4-tap stereo chorus processor at the given sample rate.
- Arguments:
chorus : ma_chorus? implicit
sample_rate : float
- chorus_process(chorus: ma_chorus?; input: float?; output: float?; nSamples: int)
Process stereo audio through the chorus effect.
- Arguments:
chorus : ma_chorus? implicit
input : float? implicit
output : float? implicit
nSamples : int
- chorus_set_config(chorus: ma_chorus?; config: ma_chorus_config)
Update chorus parameters (rate, depth, feedback, delay, wet mix).
- Arguments:
chorus : ma_chorus? implicit
config : ma_chorus_config implicit
16.1.14. Delay
- delay_init(delay: ma_delay?; sample_rate: int; delay_time_sec: float; feedback: float)
Initialize a stereo delay effect with the given sample rate, delay time in seconds, and feedback (decay) amount, allocating the internal ring buffer.
- Arguments:
delay : ma_delay? implicit
sample_rate : int
delay_time_sec : float
feedback : float
- delay_process(delay: ma_delay?; input: float?; output: float?; nFrames: int)
Process interleaved stereo frames through the delay effect, reading from the input buffer and writing the wet/dry mixed result to the output buffer for the specified number of frames.
- Arguments:
delay : ma_delay? implicit
input : float? implicit
output : float? implicit
nFrames : int
- delay_set_params(delay: ma_delay?; sample_rate: int; delay_time_sec: float; feedback: float)
Reinitialize the delay effect with a new delay time and feedback amount, freeing and reallocating the internal ring buffer to match the updated parameters.
- Arguments:
delay : ma_delay? implicit
sample_rate : int
delay_time_sec : float
feedback : float
- delay_uninit(delay: ma_delay?)
Free the internal ring buffer and resources of a delay effect, releasing all memory allocated by delay_init.
- Arguments:
delay : ma_delay? implicit
16.1.15. SF2 voice
ma_sf2_biquad_setup (bq: ma_sf2_biquad?; fc_normalized: float)
ma_sf2_biquad_setup_hpf (bq: ma_sf2_biquad?; fc_normalized: float)
ma_sf2_biquad_tick (bq: ma_sf2_biquad?; input: float) : float
ma_sf2_envelope_start (env: ma_sf2_envelope?; sample_rate: float)
ma_sf2_voice_init (voice: ma_sf2_voice?; sample_rate: float)
- ma_sf2_biquad_setup(bq: ma_sf2_biquad?; fc_normalized: float)
Configure the SF2 biquad filter at the given sample rate.
- Arguments:
bq : ma_sf2_biquad? implicit
fc_normalized : float
- ma_sf2_biquad_setup_hpf(bq: ma_sf2_biquad?; fc_normalized: float)
Configure the SF2 biquad filter as a high-pass filter at the given normalized cutoff frequency (0.0 to 0.5 of sample rate).
- Arguments:
bq : ma_sf2_biquad? implicit
fc_normalized : float
- ma_sf2_biquad_tick(bq: ma_sf2_biquad?; input: float): float
Process one sample through the SF2 biquad filter and return the filtered output value.
- Arguments:
bq : ma_sf2_biquad? implicit
input : float
- ma_sf2_envelope_init(env: ma_sf2_envelope?)
Initialize an SF2 ADSR envelope to default state.
- Arguments:
env : ma_sf2_envelope? implicit
- ma_sf2_envelope_start(env: ma_sf2_envelope?; sample_rate: float)
Start the envelope at the given sample rate.
- Arguments:
env : ma_sf2_envelope? implicit
sample_rate : float
- ma_sf2_voice_end_quick(voice: ma_sf2_voice?)
Immediately end the voice with a fast fade-out.
- Arguments:
voice : ma_sf2_voice? implicit
- ma_sf2_voice_init(voice: ma_sf2_voice?; sample_rate: float)
Initialize an SF2 voice at the given sample rate.
- Arguments:
voice : ma_sf2_voice? implicit
sample_rate : float
- ma_sf2_voice_is_finished(voice: ma_sf2_voice const?): int
Check if the voice has finished playing (all envelopes completed).
- Arguments:
voice : ma_sf2_voice? implicit
- ma_sf2_voice_note_off(voice: ma_sf2_voice?)
Trigger note-off, starting the release phase of all envelopes.
- Arguments:
voice : ma_sf2_voice? implicit
- ma_sf2_voice_render(voice: ma_sf2_voice?; sample_data: int16 const?; sample_data_len: int; output: float?; output_offset: int; frame_count: int)
Render PCM frames from the voice into an output buffer.
- Arguments:
voice : ma_sf2_voice? implicit
sample_data : int16? implicit
sample_data_len : int
output : float? implicit
output_offset : int
frame_count : int
- ma_sf2_voice_render_send(voice: ma_sf2_voice?; sample_data: int16 const?; sample_data_len: int; dry_output: float?; reverb_output: float?; output_offset: int; frame_count: int; dry_gain: float; wet_gain: float)
Render with reverb send. wet_send controls reverb mix level.
- Arguments:
voice : ma_sf2_voice? implicit
sample_data : int16? implicit
sample_data_len : int
dry_output : float? implicit
reverb_output : float? implicit
output_offset : int
frame_count : int
dry_gain : float
wet_gain : float
- ma_sf2_voice_render_send2(voice: ma_sf2_voice?; sample_data: int16 const?; sample_data_len: int; dry_output: float?; reverb_output: float?; chorus_output: float?; output_offset: int; frame_count: int; dry_gain: float; reverb_gain: float; chorus_gain: float)
Render with reverb and chorus sends.
- Arguments:
voice : ma_sf2_voice? implicit
sample_data : int16? implicit
sample_data_len : int
dry_output : float? implicit
reverb_output : float? implicit
chorus_output : float? implicit
output_offset : int
frame_count : int
dry_gain : float
reverb_gain : float
chorus_gain : float
- ma_sf2_voice_render_send3(voice: ma_sf2_voice?; sample_data: int16 const?; sample_data_len: int; dry_output: float?; reverb_output: float?; chorus_output: float?; delay_output: float?; output_offset: int; frame_count: int; dry_gain: float; reverb_gain: float; chorus_gain: float; delay_gain: float)
Render SF2 voice samples into four separate output buffers (dry, reverb, chorus, and delay sends) simultaneously, applying the corresponding gain to each send.
- Arguments:
voice : ma_sf2_voice? implicit
sample_data : int16? implicit
sample_data_len : int
dry_output : float? implicit
reverb_output : float? implicit
chorus_output : float? implicit
delay_output : float? implicit
output_offset : int
frame_count : int
dry_gain : float
reverb_gain : float
chorus_gain : float
delay_gain : float