Commit 3898fff8 authored by David Reid's avatar David Reid

Version 0.11.18

parent 9eca9ce0
v0.11.18 - TBD
v0.11.18 - 2023-08-07
=====================
* Fix some AIFF compatibility issues.
* Fix an error where the cursor of a Vorbis stream is incorrectly incremented.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.17 - 2023-05-27
miniaudio - v0.11.18 - 2023-08-07
David Reid - mackron@gmail.com
......@@ -20,7 +20,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 11
#define MA_VERSION_REVISION 17
#define MA_VERSION_REVISION 18
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
#if defined(_MSC_VER) && !defined(__clang__)
......@@ -248,36 +248,46 @@ typedef ma_uint16 wchar_t;
#define MA_NO_INLINE
#endif
#if !defined(MA_API)
#if defined(MA_DLL)
#if defined(_WIN32)
#define MA_DLL_IMPORT __declspec(dllimport)
#define MA_DLL_EXPORT __declspec(dllexport)
#define MA_DLL_PRIVATE static
/* MA_DLL is not officially supported. You're on your own if you want to use this. */
#if defined(MA_DLL)
#if defined(_WIN32)
#define MA_DLL_IMPORT __declspec(dllimport)
#define MA_DLL_EXPORT __declspec(dllexport)
#define MA_DLL_PRIVATE static
#else
#if defined(__GNUC__) && __GNUC__ >= 4
#define MA_DLL_IMPORT __attribute__((visibility("default")))
#define MA_DLL_EXPORT __attribute__((visibility("default")))
#define MA_DLL_PRIVATE __attribute__((visibility("hidden")))
#else
#if defined(__GNUC__) && __GNUC__ >= 4
#define MA_DLL_IMPORT __attribute__((visibility("default")))
#define MA_DLL_EXPORT __attribute__((visibility("default")))
#define MA_DLL_PRIVATE __attribute__((visibility("hidden")))
#else
#define MA_DLL_IMPORT
#define MA_DLL_EXPORT
#define MA_DLL_PRIVATE static
#endif
#define MA_DLL_IMPORT
#define MA_DLL_EXPORT
#define MA_DLL_PRIVATE static
#endif
#endif
#endif
#if !defined(MA_API)
#if defined(MA_DLL)
#if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION)
#define MA_API MA_DLL_EXPORT
#else
#define MA_API MA_DLL_IMPORT
#endif
#define MA_PRIVATE MA_DLL_PRIVATE
#else
#define MA_API extern
#endif
#endif
#if !defined(MA_STATIC)
#if defined(MA_DLL)
#define MA_PRIVATE MA_DLL_PRIVATE
#else
#define MA_PRIVATE static
#endif
#endif
/* SIMD alignment in bytes. Currently set to 32 bytes in preparation for future AVX optimizations. */
#define MA_SIMD_ALIGNMENT 32
......@@ -1351,13 +1361,14 @@ typedef struct
float volumeBeg; /* If volumeBeg and volumeEnd is equal to 1, no fading happens (ma_fader_process_pcm_frames() will run as a passthrough). */
float volumeEnd;
ma_uint64 lengthInFrames; /* The total length of the fade. */
ma_uint64 cursorInFrames; /* The current time in frames. Incremented by ma_fader_process_pcm_frames(). */
ma_int64 cursorInFrames; /* The current time in frames. Incremented by ma_fader_process_pcm_frames(). Signed because it'll be offset by startOffsetInFrames in set_fade_ex(). */
} ma_fader;
MA_API ma_result ma_fader_init(const ma_fader_config* pConfig, ma_fader* pFader);
MA_API ma_result ma_fader_process_pcm_frames(ma_fader* pFader, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
MA_API void ma_fader_get_data_format(const ma_fader* pFader, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
MA_API void ma_fader_set_fade(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames);
MA_API void ma_fader_set_fade_ex(ma_fader* pFader, float volumeBeg, float volumeEnd, ma_uint64 lengthInFrames, ma_int64 startOffsetInFrames);
MA_API float ma_fader_get_current_volume(const ma_fader* pFader);
......@@ -3402,7 +3413,7 @@ struct ma_device_config
/*
The callback for handling device enumeration. This is fired from `ma_context_enumerated_devices()`.
The callback for handling device enumeration. This is fired from `ma_context_enumerate_devices()`.
Parameters
......@@ -3976,6 +3987,8 @@ struct ma_context
ma_proc RegOpenKeyExA;
ma_proc RegCloseKey;
ma_proc RegQueryValueExA;
/*HRESULT*/ long CoInitializeResult;
} win32;
#endif
#ifdef MA_POSIX
......@@ -4255,21 +4268,12 @@ struct ma_device
struct
{
/* AudioWorklets path. */
/* EMSCRIPTEN_WEBAUDIO_T */ int audioContextPlayback;
/* EMSCRIPTEN_WEBAUDIO_T */ int audioContextCapture;
/* EMSCRIPTEN_AUDIO_WORKLET_NODE_T */ int workletNodePlayback;
/* EMSCRIPTEN_AUDIO_WORKLET_NODE_T */ int workletNodeCapture;
size_t intermediaryBufferSizeInFramesPlayback;
size_t intermediaryBufferSizeInFramesCapture;
float* pIntermediaryBufferPlayback;
float* pIntermediaryBufferCapture;
void* pStackBufferPlayback;
void* pStackBufferCapture;
ma_bool32 isInitialized;
/* ScriptProcessorNode path. */
int indexPlayback; /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */
int indexCapture;
/* EMSCRIPTEN_WEBAUDIO_T */ int audioContext;
/* EMSCRIPTEN_WEBAUDIO_T */ int audioWorklet;
float* pIntermediaryBuffer;
void* pStackBuffer;
ma_result initResult; /* Set to MA_BUSY while initialization is in progress. */
int deviceIndex; /* We store the device in a list on the JavaScript side. This is used to map our C object to the JS object. */
} webaudio;
#endif
#ifdef MA_SUPPORT_NULL
......@@ -7374,6 +7378,15 @@ typedef struct
MA_ATOMIC(4, ma_bool32) isSpatializationDisabled; /* Set to false by default. When set to false, will not have spatialisation applied. */
MA_ATOMIC(4, ma_uint32) pinnedListenerIndex; /* 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. */
/* When setting a fade, it's not done immediately in ma_sound_set_fade(). It's deferred to the audio thread which means we need to store the settings here. */
struct
{
ma_atomic_float volumeBeg;
ma_atomic_float volumeEnd;
ma_atomic_uint64 fadeLengthInFrames; /* <-- Defaults to (~(ma_uint64)0) which is used to indicate that no fade should be applied. */
ma_atomic_uint64 absoluteGlobalTimeInFrames; /* <-- The time to start the fade. */
} fadeSettings;
/* Memory management. */
ma_bool8 _ownsHeap;
void* _pHeap;
......@@ -7454,6 +7467,8 @@ typedef ma_sound ma_sound_group;
MA_API ma_sound_group_config ma_sound_group_config_init(void); /* Deprecated. Will be removed in version 0.12. Use ma_sound_config_2() instead. */
MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine); /* Will be renamed to ma_sound_config_init() in version 0.12. */
typedef void (* ma_engine_process_proc)(void* pUserData, float* pFramesOut, ma_uint64 frameCount);
typedef struct
{
#if !defined(MA_NO_RESOURCE_MANAGER)
......@@ -7463,6 +7478,7 @@ typedef struct
ma_context* pContext;
ma_device* pDevice; /* If set, the caller is responsible for calling ma_engine_data_callback() in the device's data callback. */
ma_device_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
ma_device_data_proc dataCallback; /* Can be null. Can be used to provide a custom device data callback. */
ma_device_notification_proc notificationCallback;
#endif
ma_log* pLog; /* When set to NULL, will use the context's log. */
......@@ -7479,6 +7495,8 @@ typedef struct
ma_bool32 noDevice; /* When set to true, don't create a default device. ma_engine_read_pcm_frames() can be called manually to read data. */
ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
ma_vfs* pResourceManagerVFS; /* A pointer to a pre-allocated VFS object to use with the resource manager. This is ignored if pResourceManager is not NULL. */
ma_engine_process_proc onProcess; /* 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. */
void* pProcessUserData; /* User data that's passed into onProcess. */
} ma_engine_config;
MA_API ma_engine_config ma_engine_config_init(void);
......@@ -7506,6 +7524,8 @@ struct ma_engine
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. */
ma_uint32 defaultVolumeSmoothTimeInPCMFrames;
ma_mono_expansion_mode monoExpansionMode;
ma_engine_process_proc onProcess;
void* pProcessUserData;
};
MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEngine);
......@@ -7530,7 +7550,9 @@ MA_API ma_uint32 ma_engine_get_sample_rate(const ma_engine* pEngine);
MA_API ma_result ma_engine_start(ma_engine* pEngine);
MA_API ma_result ma_engine_stop(ma_engine* pEngine);
MA_API ma_result ma_engine_set_volume(ma_engine* pEngine, float volume);
MA_API float ma_engine_get_volume(ma_engine* pEngine);
MA_API ma_result ma_engine_set_gain_db(ma_engine* pEngine, float gainDB);
MA_API float ma_engine_get_gain_db(ma_engine* pEngine);
MA_API ma_uint32 ma_engine_get_listener_count(const ma_engine* pEngine);
MA_API ma_uint32 ma_engine_find_closest_listener(const ma_engine* pEngine, float absolutePosX, float absolutePosY, float absolutePosZ);
......@@ -7564,6 +7586,8 @@ MA_API ma_engine* ma_sound_get_engine(const ma_sound* pSound);
MA_API ma_data_source* ma_sound_get_data_source(const ma_sound* pSound);
MA_API ma_result ma_sound_start(ma_sound* pSound);
MA_API ma_result ma_sound_stop(ma_sound* pSound);
MA_API ma_result ma_sound_stop_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 fadeLengthInFrames); /* Will overwrite any scheduled stop and fade. */
MA_API ma_result ma_sound_stop_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 fadeLengthInFrames); /* Will overwrite any scheduled stop and fade. */
MA_API void ma_sound_set_volume(ma_sound* pSound, float volume);
MA_API float ma_sound_get_volume(const ma_sound* pSound);
MA_API void ma_sound_set_pan(ma_sound* pSound, float pan);
......@@ -7606,13 +7630,18 @@ MA_API void ma_sound_set_directional_attenuation_factor(ma_sound* pSound, float
MA_API float ma_sound_get_directional_attenuation_factor(const ma_sound* pSound);
MA_API void ma_sound_set_fade_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames);
MA_API void ma_sound_set_fade_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds);
MA_API void ma_sound_set_fade_start_in_pcm_frames(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInFrames, ma_uint64 absoluteGlobalTimeInFrames);
MA_API void ma_sound_set_fade_start_in_milliseconds(ma_sound* pSound, float volumeBeg, float volumeEnd, ma_uint64 fadeLengthInMilliseconds, ma_uint64 absoluteGlobalTimeInMilliseconds);
MA_API float ma_sound_get_current_fade_volume(const ma_sound* pSound);
MA_API void ma_sound_set_start_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames);
MA_API void ma_sound_set_start_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds);
MA_API void ma_sound_set_stop_time_in_pcm_frames(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInFrames);
MA_API void ma_sound_set_stop_time_in_milliseconds(ma_sound* pSound, ma_uint64 absoluteGlobalTimeInMilliseconds);
MA_API void ma_sound_set_stop_time_with_fade_in_pcm_frames(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInFrames, ma_uint64 fadeLengthInFrames);
MA_API void ma_sound_set_stop_time_with_fade_in_milliseconds(ma_sound* pSound, ma_uint64 stopAbsoluteGlobalTimeInMilliseconds, ma_uint64 fadeLengthInMilliseconds);
MA_API ma_bool32 ma_sound_is_playing(const ma_sound* pSound);
MA_API ma_uint64 ma_sound_get_time_in_pcm_frames(const ma_sound* pSound);
MA_API ma_uint64 ma_sound_get_time_in_milliseconds(const ma_sound* pSound);
MA_API void ma_sound_set_looping(ma_sound* pSound, ma_bool32 isLooping);
MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound);
MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound);
......
/*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.18 - TBD
miniaudio - v0.11.18 - 2023-08-07
David Reid - mackron@gmail.com
......@@ -548,7 +548,7 @@ 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
......@@ -22162,7 +22162,7 @@ static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device
MA_COPY_MEMORY(&wf, pNativeFormat, cbSize);
}
result = MA_SUCCESS;
}
......@@ -28064,12 +28064,12 @@ static ma_result ma_device_stop__alsa(ma_device* pDevice)
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "[ALSA] Preparing capture device successful.\n");
}
/* Clear the wakeupfd. */
resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture, 1, 0);
if (resultPoll > 0) {
ma_uint64 t;
read(((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture)[0].fd, &t, sizeof(t));
}
/* Clear the wakeupfd. */
resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture, 1, 0);
if (resultPoll > 0) {
ma_uint64 t;
read(((struct pollfd*)pDevice->alsa.pPollDescriptorsCapture)[0].fd, &t, sizeof(t));
}
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
......@@ -28086,11 +28086,11 @@ static ma_result ma_device_stop__alsa(ma_device* pDevice)
}
/* Clear the wakeupfd. */
resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback, 1, 0);
if (resultPoll > 0) {
ma_uint64 t;
read(((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback)[0].fd, &t, sizeof(t));
}
resultPoll = poll((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback, 1, 0);
if (resultPoll > 0) {
ma_uint64 t;
read(((struct pollfd*)pDevice->alsa.pPollDescriptorsPlayback)[0].fd, &t, sizeof(t));
}
}
......@@ -28139,7 +28139,7 @@ static ma_result ma_device_wait__alsa(ma_device* pDevice, ma_snd_pcm_t* pPCM, st
ma_snd_pcm_state_t state = ((ma_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)(pPCM);
if (state == MA_SND_PCM_STATE_XRUN) {
/* The PCM is in a xrun state. This will be recovered from at a higher level. We can disregard this. */
} else {
} else {
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[ALSA] POLLERR detected. status = %d\n", ((ma_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)(pPCM));
}
}
......@@ -40402,7 +40402,7 @@ static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_contex
window.miniaudio.device_state.started = $4;
/* Device cache for mapping devices to indexes for JavaScript/C interop. */
miniaudio.devices = [];
miniaudio.devices = [];
miniaudio.track_device = function(device) {
/* Try inserting into a free slot first. */
......@@ -44636,7 +44636,7 @@ static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uin
} else if (ditherMode == ma_dither_mode_rectangle) {
float d0v[4];
float d1v[4];
d0v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax);
d0v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax);
d0v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax);
......@@ -44651,7 +44651,7 @@ static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uin
} else {
float d0v[4];
float d1v[4];
d0v[0] = ma_dither_f32_triangle(ditherMin, ditherMax);
d0v[1] = ma_dither_f32_triangle(ditherMin, ditherMax);
d0v[2] = ma_dither_f32_triangle(ditherMin, ditherMax);
......@@ -56524,7 +56524,7 @@ static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, voi
if (framesToRead > 0xFFFFFFFF) {
framesToRead = 0xFFFFFFFF;
}
mappedFrameCount = (ma_uint32)framesToRead;
result = ma_pcm_rb_acquire_read(pRB, &mappedFrameCount, &pMappedBuffer);
if (result != MA_SUCCESS) {
......@@ -56574,7 +56574,7 @@ static ma_result ma_pcm_rb_data_source__on_get_data_format(ma_data_source* pData
return MA_SUCCESS;
}
static ma_data_source_vtable ma_gRBDataSourceVTable =
static ma_data_source_vtable ma_gRBDataSourceVTable =
{
ma_pcm_rb_data_source__on_read,
NULL, /* onSeek */
......@@ -57638,7 +57638,7 @@ MA_API ma_result ma_data_source_set_range_in_pcm_frames(ma_data_source* pDataSou
pDataSourceBase->loopBegInFrames = 0;
pDataSourceBase->loopEndInFrames = ~((ma_uint64)0);
/*
Seek to within range. Note that our seek positions here are relative to the new range. We don't want
do do this if we failed to retrieve the cursor earlier on because it probably means the data source
......@@ -64686,7 +64686,7 @@ MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, c
static ma_result ma_decoder__preinit_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
{
ma_result result;
result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder);
if (result != MA_SUCCESS) {
return result;
......@@ -64836,7 +64836,7 @@ MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_co
static ma_result ma_decoder__preinit_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
{
ma_result result;
result = ma_decoder__preinit(NULL, NULL, NULL, NULL, pConfig, pDecoder);
if (result != MA_SUCCESS) {
return result;
......@@ -75419,7 +75419,7 @@ MA_API ma_result ma_engine_set_gain_db(ma_engine* pEngine, float gainDB)
MA_API float ma_engine_get_gain_db(ma_engine* pEngine)
{
return ma_volume_linear_to_db(ma_engine_get_volume(pEngine));
return ma_volume_linear_to_db(ma_engine_get_volume(pEngine));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment