64 Commits

Author SHA1 Message Date
David Reid 3898fff8ed Version 0.11.18 2023-08-07 11:05:14 +10:00
David Reid 9eca9ce0cd Update dr_libs. 2023-08-07 10:00:49 +10:00
David Reid d4fd8411c4 Update Emscripten test. 2023-08-06 15:39:54 +10:00
David Reid efa9e7d727 Web Audio: Memory usage optimization to the Audio Worklet path.
This applies only to duplex devices.
2023-08-06 15:31:50 +10:00
David Reid c24829cbb9 Web Audio: Refactoring to the ScriptProcessorNode path.
This unifies, as much as possible, the ScriptProcessorNode path with
the AudioWorklets path to avoid some code duplication, and to also make
the two paths more similar to each other to ease in maintenance.
2023-08-06 15:06:37 +10:00
David Reid fde7d20414 More improvements to the AudioWorklets Web Audio backend.
* Duplex mode now only creates a single AudioContext and AudioWorklet
  * Devices should now automatically start in response to a gesture
2023-08-06 10:42:48 +10:00
David Reid c36b391cc5 Update changes. 2023-08-05 17:58:01 +10:00
David Reid 4d23c1c5ab Update build instructions for Emscripten. 2023-08-05 17:53:58 +10:00
David Reid 810cdc2380 Improvements to Audio Worklets support for Web Audio.
Public issue https://github.com/mackron/miniaudio/issues/597
2023-08-05 17:02:26 +10:00
David Reid 53907863c7 Add support for stopping and sound and fading out.
This adds the following APIs:

  * ma_sound_stop_with_fade_in_pcm_frames()
  * ma_sound_stop_with_fade_in_milliseconds()
  * ma_sound_set_stop_time_with_fade_in_pcm_frames()
  * ma_sound_set_stop_time_with_fade_in_milliseconds()

These functions will overwrite any existing fades. For the
set_stop_time variants, you specify the time that the sound will be put
into it's stopped state. The fade will start at stopTime - fadeLength.
If the fade length is greater than the stop time, the fade length will
be clamped.

Public issue https://github.com/mackron/miniaudio/issues/669
2023-08-05 10:04:59 +10:00
David Reid f9f542b2fb Fix a fading bug introduced with an earlier commit. 2023-08-05 09:19:17 +10:00
David Reid e43457fcce Add initial implementation for scheduled fades.
This adds the following APIs:

  * ma_sound_set_fade_start_in_pcm_frames()
  * ma_sound_set_fade_start_in_milliseconds()

Public issue https://github.com/mackron/miniaudio/issues/669
2023-08-04 20:28:56 +10:00
David Reid 356eb3252e Set up some infrastructure for starting fades with an offset. 2023-08-04 19:26:55 +10:00
David Reid 3429769623 Update change history. 2023-08-04 12:14:18 +10:00
David Reid ca7284fde5 ALSA: Fix an error where restarting a device can fail. 2023-08-03 17:03:33 +10:00
David Reid 2212965267 Fix errors with the C89 build. 2023-08-03 09:16:59 +10:00
David Reid 320245606a Fix C89 build. 2023-08-02 19:41:06 +10:00
David Reid 18e4756be3 Decouple MA_API and MA_STATIC defines. 2023-08-02 08:39:56 +10:00
David Reid 8df02809b5 Remove stale comment. 2023-07-30 08:19:03 +10:00
Taiko2k 1696031633 Tweak pulseaudio stream flags 2023-07-30 08:17:21 +10:00
David Reid 90bdda29ae Fix a typo. 2023-07-30 08:14:38 +10:00
David Reid 69bc820ae8 Fix an error when loading WAV files.
The sample format of a WAV file is not always being set which results
in get_data_format() returning ma_format_unknown.
2023-07-22 16:39:17 +10:00
David Reid 98a39ded77 Fix compilation error with previous commit. 2023-07-21 18:19:49 +10:00
David Reid 4c7e3218e3 Improvements to decoder initialization.
This change makes use of the onInitFile, onInitFileW and onInitMemory
backend callbacks which enables decoding backends to have optimized
implementations for reading from a file or a block of memory without
having to go through an abstraction layer on the miniaudio side.

Public issue https://github.com/mackron/miniaudio/issues/696
2023-07-21 18:18:15 +10:00
David Reid b2ed26cf76 Fix an error with setting of the cursor when seeking a Vorbis file.
Public issue https://github.com/mackron/miniaudio/issues/707
2023-07-21 07:39:07 +10:00
David Reid 7f0a92a08f Don't call CoUninialize() when CoInitializeEx() fails. 2023-07-09 09:49:01 +10:00
David Reid ab87375257 Add ma_engine_get_volume().
Public issue https://github.com/mackron/miniaudio/issues/700
2023-07-08 09:18:41 +10:00
David Reid 0eadb0f30e Make ma_linear_resampler_set_rate_ratio() more accurate. 2023-07-07 16:47:24 +10:00
David Reid a6eb7d6a6f Update change history. 2023-06-17 08:06:22 +10:00
Jay Baird e9ba163490 Fix issue where duty cycle of a pulsewave was not correctly set at init time 2023-06-10 08:42:27 +10:00
David Reid f9076ef327 Update dr_wav with more AIFF improvements. 2023-06-08 09:10:07 +10:00
David Reid eabc776898 Fix erroneous output with the resampler when in/out rates are the same. 2023-06-08 08:34:04 +10:00
David Reid 4c49c49596 Update change history. 2023-06-07 21:14:58 +10:00
David Reid 34b40bdc17 Update dr_wav with improved AIFF compatibility. 2023-06-07 13:58:46 +10:00
David Reid e1bfeb212a AAudio: Reverse some incorrect logic when setting up streams. 2023-06-05 15:44:27 +10:00
David Reid db8e77cad4 Fix a compilation error with the C++ build. 2023-06-05 15:19:28 +10:00
David Reid 1177997599 Add support for supplying a custom device data callback to ma_engine.
When this is used, the data callback should at some point call
ma_engine_read_pcm_frames() in order to do some processing.
2023-06-05 09:01:30 +10:00
David Reid 5f32336a34 Use float* instead of void* for the engine processing callback. 2023-06-03 16:27:39 +10:00
David Reid a0b952eea6 Add support for setting a processing callback for ma_engine.
This is optional and is fired at the end of each call to
ma_engine_read_process_pcm_frames(). The callback will be passed the
processed audio data so they can do their own processing such as
outputting to a file or whatnot.

The callback is configured via the engine config.
2023-06-03 16:20:16 +10:00
David Reid e7912fa242 Add ma_sound_get_time_in_milliseconds(). 2023-06-03 13:38:55 +10:00
David Reid 0c1c4c7ddc Update dr_wav. 2023-05-29 08:33:31 +10:00
David Reid d76b9a1ac4 Version 0.11.17 2023-05-27 12:49:48 +10:00
David Reid e9b6559be1 Very minor code reorganisation. 2023-05-26 13:41:41 +10:00
Jay Baird 1bd7713e85 swap parameters for better compatibility with ma_data_source 2023-05-26 13:38:45 +10:00
Jay Baird e7e666d827 Add ma_pulsewave generator type 2023-05-26 13:38:45 +10:00
David Reid 8c59e9b736 Update change history. 2023-05-23 19:10:59 +10:00
David Reid a2698a0048 Fix compilation error relating to dlopen() and family. 2023-05-23 14:04:40 +10:00
David Reid ea42e16a79 Fix the C++ build. 2023-05-22 18:27:38 +10:00
David Reid 14be2bd394 Fix some long out of date tests. 2023-05-22 18:20:21 +10:00
David Reid a8f3cb857e Fix compilation errors with MA_NO_DEVICE_IO. 2023-05-22 18:09:04 +10:00
David Reid 563e1c52cb Update change history. 2023-05-22 17:51:08 +10:00
David Reid 4520faa1d2 Update dr_flac amalgamation again to remove redundant error codes. 2023-05-22 17:50:41 +10:00
David Reid 8dec4e0b9b Update amalgamation of dr_flac. 2023-05-22 17:43:27 +10:00
David Reid 69f4a19ef5 Fix a copy/paste error. 2023-05-22 17:41:20 +10:00
David Reid 9374f5e8d2 Update dr_mp3 amalgamation. 2023-05-22 17:25:01 +10:00
David Reid b98acd2422 Update amalgamation of dr_wav.
With this change, dr_wav is now namespaced with "ma" which means dr_wav
can now be used alongside miniaudio.

In addition, some duplicate code has been removed, such as sized types,
result codes, allocation callbacks, etc. which reduces the size of the
file slightly.

This should address the following public issue:
  https://github.com/mackron/miniaudio/issues/673
2023-05-22 16:52:16 +10:00
David Reid 5c099791ee Clean up decoding documentation.
miniaudio is updating it's amalgamation of dr_wav, etc. so that it's
all namespaced with "ma" which will make the amalgamated versions of
dr_libs entirely independent. There's no longer any need to mention
the decoding backends.

Documentation regarding stb_vorbis is removed so as to discourage
new users from using it. Support will not be removed until a
replacement Vorbis decoder can be amalgamated, but new users should
instead be guided to the libvorbis custom decoder in the extras folder.
2023-05-22 16:06:13 +10:00
David Reid 773d97a95c Fix a compilation error with VC6 and VS2003.
These compilers do not support noinline.
2023-05-22 14:48:55 +10:00
David Reid fa7cd81027 Improvements to c89atomic amalgamation.
* Sized types will now use miniaudio's types.
  * Architecture macros now use miniaudio's macros.
  * The c89atomic namespace has been renamed to ma_atomic which makes
    it so c89atomic can be used alongside miniaudio without naming
    conflicts.

Public issue https://github.com/mackron/miniaudio/issues/673
2023-05-21 09:41:49 +10:00
David Reid af46c1fcc0 Minor changes to architecture detection.
This is in preparation for some amalgamation improvements.
2023-05-21 08:25:14 +10:00
David Reid 65574f44e3 Update change history. 2023-05-21 07:57:32 +10:00
David Reid f05bb5306d Try fixing Windows 95/98 build.
This commit makes it so SetFilePointer/Ex() are dynamically loaded at
runtime which allows miniaudio to branch dynamically based on available
support.

This is necessary because versions of Windows prior to XP do not
support the Ex version which results in an error when trying to run the
program.

Public issue https://github.com/mackron/miniaudio/issues/672
2023-05-18 20:44:46 +10:00
David Reid 6eeea700f0 Silence a very minor linting warning in VS2022. 2023-05-17 18:22:24 +10:00
David Reid 04a6fe6eea Work around some bad code generation by Clang. 2023-05-17 18:20:15 +10:00
20 changed files with 21232 additions and 22948 deletions
+29
View File
@@ -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()`.
+4
View File
@@ -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
View File
@@ -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;
}
File diff suppressed because it is too large Load Diff
+124 -54
View File
@@ -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
View File
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 {
-17
View File
@@ -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;
}
+10 -2
View File
@@ -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;
+1 -1
View File
@@ -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);
+6 -6
View File
@@ -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;
+9 -9
View File
@@ -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;
+9 -9
View File
@@ -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(&notchConfig, &notch);
result = ma_notch2_init(&notchConfig, NULL, &notch);
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(&notch, 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;
}