mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 16:24:04 +02:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3898fff8ed | |||
| 9eca9ce0cd | |||
| d4fd8411c4 | |||
| efa9e7d727 | |||
| c24829cbb9 | |||
| fde7d20414 | |||
| c36b391cc5 | |||
| 4d23c1c5ab | |||
| 810cdc2380 | |||
| 53907863c7 | |||
| f9f542b2fb | |||
| e43457fcce | |||
| 356eb3252e | |||
| 3429769623 | |||
| ca7284fde5 | |||
| 2212965267 | |||
| 320245606a | |||
| 18e4756be3 | |||
| 8df02809b5 | |||
| 1696031633 | |||
| 90bdda29ae | |||
| 69bc820ae8 | |||
| 98a39ded77 | |||
| 4c7e3218e3 | |||
| b2ed26cf76 | |||
| 7f0a92a08f | |||
| ab87375257 | |||
| 0eadb0f30e | |||
| a6eb7d6a6f | |||
| e9ba163490 | |||
| f9076ef327 | |||
| eabc776898 | |||
| 4c49c49596 | |||
| 34b40bdc17 | |||
| e1bfeb212a | |||
| db8e77cad4 | |||
| 1177997599 | |||
| 5f32336a34 | |||
| a0b952eea6 | |||
| e7912fa242 | |||
| 0c1c4c7ddc | |||
| d76b9a1ac4 | |||
| e9b6559be1 | |||
| 1bd7713e85 | |||
| e7e666d827 | |||
| 8c59e9b736 | |||
| a2698a0048 | |||
| ea42e16a79 | |||
| 14be2bd394 | |||
| a8f3cb857e | |||
| 563e1c52cb | |||
| 4520faa1d2 | |||
| 8dec4e0b9b | |||
| 69f4a19ef5 | |||
| 9374f5e8d2 | |||
| b98acd2422 | |||
| 5c099791ee | |||
| 773d97a95c | |||
| fa7cd81027 | |||
| af46c1fcc0 | |||
| 65574f44e3 | |||
| f05bb5306d | |||
| 6eeea700f0 | |||
| 04a6fe6eea |
+29
@@ -1,3 +1,32 @@
|
||||
v0.11.18 - 2023-08-07
|
||||
=====================
|
||||
* Fix some AIFF compatibility issues.
|
||||
* Fix an error where the cursor of a Vorbis stream is incorrectly incremented.
|
||||
* Add support for setting a callback on an `ma_engine` object that get's fired after it processes a chunk of audio. This allows applications to do things such as apply a post-processing effect or output the audio to a file.
|
||||
* Add `ma_engine_get_volume()`.
|
||||
* Add `ma_sound_get_time_in_milliseconds()`.
|
||||
* Decouple `MA_API` and `MA_PRIVATE`. This relaxes applications from needing to define both of them if they're only wanting to redefine one.
|
||||
* Decoding backends will now have their onInitFile/W and onInitMemory initialization routines used where appropriate if they're defined.
|
||||
* Increase the accuracy of the linear resampler when setting the ratio with `ma_linear_resampler_set_rate_ratio()`.
|
||||
* Fix erroneous output with the linear resampler when in/out rates are the same.
|
||||
* AAudio: Fix an error where the buffer size is not configured correctly which sometimes results in excessively high latency.
|
||||
* ALSA: Fix a possible error when stopping and restarting a device.
|
||||
* PulseAudio: Minor changes to stream flags.
|
||||
* Win32: Fix an error where `CoUninialize()` is being called when the corresponding `CoInitializeEx()` fails.
|
||||
* Web / Emscripten: Add support for AudioWorklets. This is opt-in and can be enabled by defining `MA_ENABLE_AUDIO_WORKLETS`. You must compile with `-sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY` for this to work. Requires at least Emscripten v3.1.32.
|
||||
|
||||
|
||||
v0.11.17 - 2023-05-27
|
||||
=====================
|
||||
* Fix compilation errors with MA_USE_STDINT.
|
||||
* Fix a possible runtime error with Windows 95/98.
|
||||
* Fix a very minor linting warning in VS2022.
|
||||
* Add support for AIFF/AIFC decoding.
|
||||
* Add support for RIFX decoding.
|
||||
* Work around some bad code generation by Clang.
|
||||
* Amalgamations of dr_wav, dr_flac, dr_mp3 and c89atomic have been updated so that they're now fully namespaced. This allows each of these libraries to be able to be used alongside miniaudio without any conflicts. In addition, some duplicate code, such as sized type declarations, result codes, etc. has been removed.
|
||||
|
||||
|
||||
v0.11.16 - 2023-05-15
|
||||
=====================
|
||||
* Fix a memory leak with `ma_sound_init_copy()`.
|
||||
|
||||
@@ -11,6 +11,10 @@ path like "C:\emsdk\emsdk_env.bat". Note that PowerShell doesn't work for me for
|
||||
emcc ../simple_playback_sine.c -o bin/simple_playback_sine.html
|
||||
emcc ../simple_playback_sine.c -o bin/simple_playback_sine.html -s WASM=0 -Wall -Wextra
|
||||
|
||||
To compile with support for Audio Worklets:
|
||||
|
||||
emcc ../simple_playback_sine.c -o bin/simple_playback_sine.html -DMA_ENABLE_AUDIO_WORKLETS -sAUDIO_WORKLET=1 -sWASM_WORKERS=1 -sASYNCIFY
|
||||
|
||||
If you output WASM it may not work when running the web page locally. To test you can run with something
|
||||
like this:
|
||||
|
||||
|
||||
+10
-10
@@ -521,7 +521,7 @@ static ma_result ma_context_uninit__sdl(ma_context* pContext)
|
||||
((MA_PFN_SDL_QuitSubSystem)pContextEx->sdl.SDL_QuitSubSystem)(MA_SDL_INIT_AUDIO);
|
||||
|
||||
/* Close the handle to the SDL shared object last. */
|
||||
ma_dlclose(pContext, pContextEx->sdl.hSDL);
|
||||
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
|
||||
pContextEx->sdl.hSDL = NULL;
|
||||
|
||||
return MA_SUCCESS;
|
||||
@@ -551,7 +551,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
|
||||
/* Check if we have SDL2 installed somewhere. If not it's not usable and we need to abort. */
|
||||
for (iName = 0; iName < ma_countof(pSDLNames); iName += 1) {
|
||||
pContextEx->sdl.hSDL = ma_dlopen(pContext, pSDLNames[iName]);
|
||||
pContextEx->sdl.hSDL = ma_dlopen(ma_context_get_log(pContext), pSDLNames[iName]);
|
||||
if (pContextEx->sdl.hSDL != NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -562,13 +562,13 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
}
|
||||
|
||||
/* Now that we have the handle to the shared object we can go ahead and load some function pointers. */
|
||||
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_InitSubSystem");
|
||||
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
|
||||
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
|
||||
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
|
||||
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
|
||||
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
|
||||
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
|
||||
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_InitSubSystem");
|
||||
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
|
||||
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
|
||||
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
|
||||
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
|
||||
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
|
||||
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
|
||||
#else
|
||||
pContextEx->sdl.SDL_InitSubSystem = (ma_proc)SDL_InitSubSystem;
|
||||
pContextEx->sdl.SDL_QuitSubSystem = (ma_proc)SDL_QuitSubSystem;
|
||||
@@ -581,7 +581,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
|
||||
|
||||
resultSDL = ((MA_PFN_SDL_InitSubSystem)pContextEx->sdl.SDL_InitSubSystem)(MA_SDL_INIT_AUDIO);
|
||||
if (resultSDL != 0) {
|
||||
ma_dlclose(pContext, pContextEx->sdl.hSDL);
|
||||
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
|
||||
return MA_ERROR;
|
||||
}
|
||||
|
||||
|
||||
+10422
-11351
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||
miniaudio - v0.11.16 - 2023-05-15
|
||||
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 16
|
||||
#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__)
|
||||
@@ -212,6 +212,13 @@ typedef ma_uint16 wchar_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define MA_INLINE __forceinline
|
||||
|
||||
/* noinline was introduced in Visual Studio 2005. */
|
||||
#if _MSC_VER >= 1400
|
||||
#define MA_NO_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define MA_NO_INLINE
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
/*
|
||||
I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
|
||||
@@ -228,45 +235,59 @@ typedef ma_uint16 wchar_t;
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
|
||||
#define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline))
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#else
|
||||
#define MA_INLINE MA_GNUC_INLINE_HINT
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define MA_INLINE __inline
|
||||
#define MA_NO_INLINE
|
||||
#else
|
||||
#define MA_INLINE
|
||||
#define MA_NO_INLINE
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
#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(_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
|
||||
#define MA_DLL_IMPORT
|
||||
#define MA_DLL_EXPORT
|
||||
#define MA_DLL_PRIVATE static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
@@ -464,28 +485,31 @@ typedef enum
|
||||
MA_CANCELLED = -51,
|
||||
MA_MEMORY_ALREADY_MAPPED = -52,
|
||||
|
||||
/* General non-standard errors. */
|
||||
MA_CRC_MISMATCH = -100,
|
||||
|
||||
/* General miniaudio-specific errors. */
|
||||
MA_FORMAT_NOT_SUPPORTED = -100,
|
||||
MA_DEVICE_TYPE_NOT_SUPPORTED = -101,
|
||||
MA_SHARE_MODE_NOT_SUPPORTED = -102,
|
||||
MA_NO_BACKEND = -103,
|
||||
MA_NO_DEVICE = -104,
|
||||
MA_API_NOT_FOUND = -105,
|
||||
MA_INVALID_DEVICE_CONFIG = -106,
|
||||
MA_LOOP = -107,
|
||||
MA_BACKEND_NOT_ENABLED = -108,
|
||||
MA_FORMAT_NOT_SUPPORTED = -200,
|
||||
MA_DEVICE_TYPE_NOT_SUPPORTED = -201,
|
||||
MA_SHARE_MODE_NOT_SUPPORTED = -202,
|
||||
MA_NO_BACKEND = -203,
|
||||
MA_NO_DEVICE = -204,
|
||||
MA_API_NOT_FOUND = -205,
|
||||
MA_INVALID_DEVICE_CONFIG = -206,
|
||||
MA_LOOP = -207,
|
||||
MA_BACKEND_NOT_ENABLED = -208,
|
||||
|
||||
/* State errors. */
|
||||
MA_DEVICE_NOT_INITIALIZED = -200,
|
||||
MA_DEVICE_ALREADY_INITIALIZED = -201,
|
||||
MA_DEVICE_NOT_STARTED = -202,
|
||||
MA_DEVICE_NOT_STOPPED = -203,
|
||||
MA_DEVICE_NOT_INITIALIZED = -300,
|
||||
MA_DEVICE_ALREADY_INITIALIZED = -301,
|
||||
MA_DEVICE_NOT_STARTED = -302,
|
||||
MA_DEVICE_NOT_STOPPED = -303,
|
||||
|
||||
/* Operation errors. */
|
||||
MA_FAILED_TO_INIT_BACKEND = -300,
|
||||
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -301,
|
||||
MA_FAILED_TO_START_BACKEND_DEVICE = -302,
|
||||
MA_FAILED_TO_STOP_BACKEND_DEVICE = -303
|
||||
MA_FAILED_TO_INIT_BACKEND = -400,
|
||||
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -401,
|
||||
MA_FAILED_TO_START_BACKEND_DEVICE = -402,
|
||||
MA_FAILED_TO_STOP_BACKEND_DEVICE = -403
|
||||
} ma_result;
|
||||
|
||||
|
||||
@@ -1337,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);
|
||||
|
||||
|
||||
@@ -3388,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
|
||||
@@ -3962,6 +3987,8 @@ struct ma_context
|
||||
ma_proc RegOpenKeyExA;
|
||||
ma_proc RegCloseKey;
|
||||
ma_proc RegQueryValueExA;
|
||||
|
||||
/*HRESULT*/ long CoInitializeResult;
|
||||
} win32;
|
||||
#endif
|
||||
#ifdef MA_POSIX
|
||||
@@ -4241,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
|
||||
@@ -6343,7 +6361,7 @@ struct ma_encoder
|
||||
ma_encoder_uninit_proc onUninit;
|
||||
ma_encoder_write_pcm_frames_proc onWritePCMFrames;
|
||||
void* pUserData;
|
||||
void* pInternalEncoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
|
||||
void* pInternalEncoder;
|
||||
union
|
||||
{
|
||||
struct
|
||||
@@ -6408,6 +6426,33 @@ MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double freque
|
||||
MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type);
|
||||
MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ma_format format;
|
||||
ma_uint32 channels;
|
||||
ma_uint32 sampleRate;
|
||||
double dutyCycle;
|
||||
double amplitude;
|
||||
double frequency;
|
||||
} ma_pulsewave_config;
|
||||
|
||||
MA_API ma_pulsewave_config ma_pulsewave_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double dutyCycle, double amplitude, double frequency);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ma_waveform waveform;
|
||||
ma_pulsewave_config config;
|
||||
} ma_pulsewave;
|
||||
|
||||
MA_API ma_result ma_pulsewave_init(const ma_pulsewave_config* pConfig, ma_pulsewave* pWaveform);
|
||||
MA_API void ma_pulsewave_uninit(ma_pulsewave* pWaveform);
|
||||
MA_API ma_result ma_pulsewave_read_pcm_frames(ma_pulsewave* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
|
||||
MA_API ma_result ma_pulsewave_seek_to_pcm_frame(ma_pulsewave* pWaveform, ma_uint64 frameIndex);
|
||||
MA_API ma_result ma_pulsewave_set_amplitude(ma_pulsewave* pWaveform, double amplitude);
|
||||
MA_API ma_result ma_pulsewave_set_frequency(ma_pulsewave* pWaveform, double frequency);
|
||||
MA_API ma_result ma_pulsewave_set_sample_rate(ma_pulsewave* pWaveform, ma_uint32 sampleRate);
|
||||
MA_API ma_result ma_pulsewave_set_duty_cycle(ma_pulsewave* pWaveform, double dutyCycle);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ma_noise_type_white,
|
||||
@@ -7333,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;
|
||||
@@ -7413,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)
|
||||
@@ -7422,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. */
|
||||
@@ -7438,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);
|
||||
@@ -7465,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);
|
||||
@@ -7489,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);
|
||||
@@ -7523,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);
|
||||
@@ -7565,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);
|
||||
|
||||
+10572
-11437
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ ma_result init_data_converter(ma_uint32 rateIn, ma_uint32 rateOut, ma_resample_a
|
||||
config = ma_data_converter_config_init(ma_format_s16, ma_format_s16, 1, 1, rateIn, rateOut);
|
||||
config.resampling.algorithm = algorithm;
|
||||
|
||||
result = ma_data_converter_init(&config, pDataConverter);
|
||||
result = ma_data_converter_init(&config, NULL, pDataConverter);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ ma_result test_data_converter__resampling_expected_output_fixed_interval(ma_data
|
||||
ma_uint64 expectedOutputFrameCount;
|
||||
|
||||
/* We retrieve the required number of input frames for the specified number of output frames, and then compare with what we actually get when reading. */
|
||||
expectedOutputFrameCount = ma_data_converter_get_expected_output_frame_count(pDataConverter, frameCountPerIteration);
|
||||
ma_data_converter_get_expected_output_frame_count(pDataConverter, frameCountPerIteration, &expectedOutputFrameCount);
|
||||
|
||||
outputFrameCount = ma_countof(output);
|
||||
inputFrameCount = frameCountPerIteration;
|
||||
@@ -90,7 +90,7 @@ ma_result test_data_converter__resampling_expected_output_by_algorithm_and_rate_
|
||||
|
||||
result = test_data_converter__resampling_expected_output_fixed_interval(&converter, frameCountPerIteration);
|
||||
|
||||
ma_data_converter_uninit(&converter);
|
||||
ma_data_converter_uninit(&converter, NULL);
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
@@ -170,12 +170,6 @@ ma_result test_data_converter__resampling_expected_output()
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
printf("Speex\n");
|
||||
result = test_data_converter__resampling_expected_output_by_algorithm(ma_resample_algorithm_speex);
|
||||
if (result != 0) {
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
} else {
|
||||
@@ -205,7 +199,7 @@ ma_result test_data_converter__resampling_required_input_fixed_interval(ma_data_
|
||||
ma_uint64 requiredInputFrameCount;
|
||||
|
||||
/* We retrieve the required number of input frames for the specified number of output frames, and then compare with what we actually get when reading. */
|
||||
requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(pDataConverter, frameCountPerIteration);
|
||||
ma_data_converter_get_required_input_frame_count(pDataConverter, frameCountPerIteration, &requiredInputFrameCount);
|
||||
|
||||
outputFrameCount = frameCountPerIteration;
|
||||
inputFrameCount = ma_countof(input);
|
||||
@@ -243,7 +237,7 @@ ma_result test_data_converter__resampling_required_input_by_algorithm_and_rate_f
|
||||
|
||||
result = test_data_converter__resampling_required_input_fixed_interval(&converter, frameCountPerIteration);
|
||||
|
||||
ma_data_converter_uninit(&converter);
|
||||
ma_data_converter_uninit(&converter, NULL);
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
@@ -323,12 +317,6 @@ ma_result test_data_converter__resampling_required_input()
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
printf("Speex\n");
|
||||
result = test_data_converter__resampling_required_input_by_algorithm(ma_resample_algorithm_speex);
|
||||
if (result != MA_SUCCESS) {
|
||||
hasError = MA_TRUE;
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return MA_ERROR;
|
||||
} else {
|
||||
|
||||
@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
drwav_data_format drwav_data_format_from_minaudio_format(ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
|
||||
{
|
||||
drwav_data_format wavFormat;
|
||||
|
||||
wavFormat.container = drwav_container_riff;
|
||||
wavFormat.channels = channels;
|
||||
wavFormat.sampleRate = sampleRate;
|
||||
wavFormat.bitsPerSample = ma_get_bytes_per_sample(format) * 8;
|
||||
|
||||
if (format == ma_format_f32) {
|
||||
wavFormat.format = DR_WAVE_FORMAT_IEEE_FLOAT;
|
||||
} else {
|
||||
wavFormat.format = DR_WAVE_FORMAT_PCM;
|
||||
}
|
||||
|
||||
return wavFormat;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#define MA_DEBUG_OUTPUT
|
||||
#define MA_NO_DECODING
|
||||
#define MA_NO_ENCODING
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
@@ -73,12 +74,13 @@ static void do_duplex()
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_duplex);
|
||||
deviceConfig.capture.pDeviceID = NULL;
|
||||
deviceConfig.capture.format = ma_format_s16;
|
||||
deviceConfig.capture.format = DEVICE_FORMAT;
|
||||
deviceConfig.capture.channels = 2;
|
||||
deviceConfig.capture.shareMode = ma_share_mode_shared;
|
||||
deviceConfig.playback.pDeviceID = NULL;
|
||||
deviceConfig.playback.format = ma_format_s16;
|
||||
deviceConfig.playback.format = DEVICE_FORMAT;
|
||||
deviceConfig.playback.channels = 2;
|
||||
deviceConfig.sampleRate = DEVICE_SAMPLE_RATE;
|
||||
deviceConfig.dataCallback = data_callback_duplex;
|
||||
result = ma_device_init(NULL, &deviceConfig, &device);
|
||||
if (result != MA_SUCCESS) {
|
||||
@@ -102,6 +104,12 @@ static EM_BOOL on_canvas_click(int eventType, const EmscriptenMouseEvent* pMouse
|
||||
}
|
||||
|
||||
isRunning = MA_TRUE;
|
||||
} else {
|
||||
if (ma_device_get_state(&device) == ma_device_state_started) {
|
||||
ma_device_stop(&device);
|
||||
} else {
|
||||
ma_device_start(&device);
|
||||
}
|
||||
}
|
||||
|
||||
(void)eventType;
|
||||
|
||||
@@ -12,7 +12,7 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, pDecoder->outputFormat, pDecoder->outputChannels, pDecoder->outputSampleRate);
|
||||
result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, pEncoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(pDecoder);
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
bpfConfig = ma_bpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_bpf2_init(&bpfConfig, &bpf);
|
||||
result = ma_bpf2_init(&bpfConfig, NULL, &bpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
bpfConfig = ma_bpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 4);
|
||||
result = ma_bpf_init(&bpfConfig, &bpf);
|
||||
result = ma_bpf_init(&bpfConfig, NULL, &bpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@ ma_result test_dithering__u8(const char* pInputFilePath)
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, ma_format_u8, decoder.outputChannels, decoder.outputSampleRate);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, ma_format_u8, decoder.outputChannels, decoder.outputSampleRate);
|
||||
result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
@@ -30,13 +30,13 @@ ma_result test_dithering__u8(const char* pInputFilePath)
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Convert, with dithering. */
|
||||
ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
|
||||
hishelfConfig = ma_hishelf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 18, 1, 16000);
|
||||
result = ma_hishelf2_init(&hishelfConfig, &hishelf);
|
||||
result = ma_hishelf2_init(&hishelfConfig, NULL, &hishelf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hishelf2_process_pcm_frames(&hishelf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf1_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000);
|
||||
result = ma_hpf1_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf1_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_hpf2_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf2_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -142,7 +142,7 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
hpfConfig = ma_hpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 3);
|
||||
result = ma_hpf_init(&hpfConfig, &hpf);
|
||||
result = ma_hpf_init(&hpfConfig, NULL, &hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -158,13 +158,13 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
|
||||
loshelfConfig = ma_loshelf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 6, 1, 200);
|
||||
result = ma_loshelf2_init(&loshelfConfig, &loshelf);
|
||||
result = ma_loshelf2_init(&loshelfConfig, NULL, &loshelf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_loshelf2_process_pcm_frames(&loshelf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf1_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000);
|
||||
result = ma_lpf1_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf1_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -81,7 +81,7 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, 0);
|
||||
result = ma_lpf2_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf2_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -97,13 +97,13 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
@@ -143,7 +143,7 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
|
||||
lpfConfig = ma_lpf_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 2000, /*poles*/3);
|
||||
result = ma_lpf_init(&lpfConfig, &lpf);
|
||||
result = ma_lpf_init(&lpfConfig, NULL, &lpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -159,13 +159,13 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
|
||||
}
|
||||
|
||||
notchConfig = ma_notch2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 1, 60);
|
||||
result = ma_notch2_init(¬chConfig, ¬ch);
|
||||
result = ma_notch2_init(¬chConfig, NULL, ¬ch);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_notch2_process_pcm_frames(¬ch, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -20,7 +20,7 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
|
||||
}
|
||||
|
||||
peakConfig = ma_peak2_config_init(decoder.outputFormat, decoder.outputChannels, decoder.outputSampleRate, 24, 0, 16000);
|
||||
result = ma_peak2_init(&peakConfig, &peak);
|
||||
result = ma_peak2_init(&peakConfig, NULL, &peak);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
@@ -36,13 +36,13 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
|
||||
ma_uint64 framesJustRead;
|
||||
|
||||
framesToRead = ma_min(tempCapIn, tempCapOut);
|
||||
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead);
|
||||
ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
|
||||
|
||||
/* Filter */
|
||||
ma_peak2_process_pcm_frames(&peak, tempOut, tempIn, framesJustRead);
|
||||
|
||||
/* Write to the WAV file. */
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead);
|
||||
ma_encoder_write_pcm_frames(&encoder, tempOut, framesJustRead, NULL);
|
||||
|
||||
if (framesJustRead < framesToRead) {
|
||||
break;
|
||||
|
||||
@@ -11,12 +11,12 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
||||
printf(" %s\n", pFileName);
|
||||
|
||||
noiseConfig = ma_noise_config_init(format, 1, type, 0, 0.1);
|
||||
result = ma_noise_init(&noiseConfig, &noise);
|
||||
result = ma_noise_init(&noiseConfig, NULL, &noise);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, format, noiseConfig.channels, 48000);
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, format, noiseConfig.channels, 48000);
|
||||
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
@@ -25,8 +25,8 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
||||
/* We'll do a few seconds of data. */
|
||||
for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) {
|
||||
ma_uint8 temp[1024];
|
||||
ma_noise_read_pcm_frames(&noise, temp, 1);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1);
|
||||
ma_noise_read_pcm_frames(&noise, temp, 1, NULL);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
|
||||
}
|
||||
|
||||
ma_encoder_uninit(&encoder);
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
|
||||
static drwav_data_format drwav_data_format_from_waveform_config(const ma_waveform_config* pWaveformConfig)
|
||||
{
|
||||
MA_ASSERT(pWaveformConfig != NULL);
|
||||
|
||||
return drwav_data_format_from_minaudio_format(pWaveformConfig->format, pWaveformConfig->channels, pWaveformConfig->sampleRate);
|
||||
}
|
||||
|
||||
ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type type, double amplitude, const char* pFileName)
|
||||
{
|
||||
ma_result result;
|
||||
ma_waveform_config waveformConfig;
|
||||
ma_waveform waveform;
|
||||
drwav_data_format wavFormat;
|
||||
drwav wav;
|
||||
ma_encoder_config encoderConfig;
|
||||
ma_encoder encoder;
|
||||
ma_uint32 iFrame;
|
||||
|
||||
printf(" %s\n", pFileName);
|
||||
@@ -23,19 +16,22 @@ ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type t
|
||||
return result;
|
||||
}
|
||||
|
||||
wavFormat = drwav_data_format_from_waveform_config(&waveformConfig);
|
||||
if (!drwav_init_file_write(&wav, pFileName, &wavFormat, NULL)) {
|
||||
return MA_ERROR; /* Could not open file for writing. */
|
||||
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, waveformConfig.format, waveformConfig.channels, waveformConfig.sampleRate);
|
||||
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result; /* Failed to initialize encoder. */
|
||||
}
|
||||
|
||||
/* We'll do a few seconds of data. */
|
||||
for (iFrame = 0; iFrame < wavFormat.sampleRate * 10; iFrame += 1) {
|
||||
for (iFrame = 0; iFrame < waveformConfig.sampleRate * 10; iFrame += 1) {
|
||||
float temp[MA_MAX_CHANNELS];
|
||||
ma_waveform_read_pcm_frames(&waveform, temp, 1);
|
||||
drwav_write_pcm_frames(&wav, 1, temp);
|
||||
ma_waveform_read_pcm_frames(&waveform, temp, 1, NULL);
|
||||
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
|
||||
}
|
||||
|
||||
drwav_uninit(&wav);
|
||||
ma_encoder_uninit(&encoder);
|
||||
ma_waveform_uninit(&waveform);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user