42 Commits

Author SHA1 Message Date
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
David Reid ea205fb7b0 Version 0.11.16 2023-05-15 09:36:42 +10:00
David Reid 26c11a7771 Process jobs on the calling thread when WAIT_INIT is used.
Since the calling thread is waiting anyway, it's better to just do the
processing on the calling thread rather than posting it to the job
queue and waiting. This ensures the calling thread stays busy which
will improve performance, but it also makes it so the calling thread
doesn't get stalled while already-queued jobs are getting processed.
2023-05-12 09:11:29 +10:00
David Reid 870ac8a22c Don't link to advapi32.dll for the GDK build. 2023-05-06 08:59:13 +10:00
David Reid a1ea4438ee Fix ma_dlopen() on the GDK build. 2023-05-06 08:50:55 +10:00
David Reid 902c19d6ab WASAPI: Another fix for the GDK build. 2023-05-06 08:41:08 +10:00
David Reid 64f14070a7 WASAPI: Revert an experimental change and try fixing GDK build. 2023-05-06 08:31:32 +10:00
David Reid 6d20ccb701 WASAPI: Experimental change for rerouting. 2023-05-05 10:26:39 +10:00
David Reid 96ac03f184 WASAPI: Log error codes when a device fails to start. 2023-05-05 09:34:31 +10:00
David Reid e913a6d1aa Silence a warning. 2023-05-05 09:24:46 +10:00
David Reid de706d44b8 Experimental fix for better handling of AUDCLNT_E_DEVICE_INVALIDATED. 2023-05-05 09:18:18 +10:00
David Reid 2bf7e03777 WASAPI: Relax validation checks when doing device reroutes. 2023-05-05 08:55:23 +10:00
David Reid ae25dbcdac Fix a memory leak in ma_sound_init_copy().
Public issue https://github.com/mackron/miniaudio/issues/667
2023-05-03 08:02:42 +10:00
David Reid 4326fad97a Update links in readme. 2023-04-30 12:15:38 +10:00
David Reid 937cd9c16c Another update to the readme to make it less wordy. 2023-04-30 12:03:26 +10:00
David Reid d1f3715a08 Playing around with a restructure to the readme. 2023-04-30 11:20:53 +10:00
David Reid 9fe0970e20 Remove the previous experimental change to the readme. Doesn't work. 2023-04-30 08:56:43 +10:00
David Reid a74c2c78d9 Try fixing some HTML formatting. 2023-04-30 08:54:26 +10:00
David Reid 189beb67fa Experiment with a change to the readme. 2023-04-30 08:53:14 +10:00
David Reid 7384bde372 Update change history. 2023-04-30 08:39:53 +10:00
19 changed files with 17964 additions and 21510 deletions
+21 -2
View File
@@ -1,8 +1,27 @@
v0.11.15 - TBD v0.11.7 - 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()`.
* Improve performance of `ma_sound_init_*()` when using the `ASYNC | DECODE` flag combination.
v0.11.15 - 2023-04-30
=====================
* Fix a bug where initialization of a duplex device fails on some backends. * Fix a bug where initialization of a duplex device fails on some backends.
* Fix a bug in ma_gainer where smoothing isn't applied correctly thus resulting in glitching. * Fix a bug in ma_gainer where smoothing isn't applied correctly thus resulting in glitching.
* Add support for volume smoothing to sounds when changing the volume with `ma_sound_set_volume()`. To use this, you must configure it via the `volumeSmoothTimeInPCMFrames` member of ma_sound_config and use `ma_sound_init_ex()` to initialize your sound. Smoothing is disabled by default. * Add support for volume smoothing to sounds when changing the volume with `ma_sound_set_volume()`. To use this, you must configure it via the `volumeSmoothTimeInPCMFrames` member of ma_sound_config and use `ma_sound_init_ex()` to initialize your sound. Smoothing is disabled by default.
* WASAPI: Fix a possible buffer overrun when initializing a device.
* WASAPI: Make device initialization more robust by improving the handling of the querying of the internal data format.
v0.11.14 - 2023-03-29 v0.11.14 - 2023-03-29
+70 -94
View File
@@ -3,7 +3,7 @@
<br> <br>
</h1> </h1>
<h4 align="center">A single file library for audio playback and capture.</h4> <h4 align="center">An audio playback and capture library in a single source file.</h4>
<p align="center"> <p align="center">
<a href="https://discord.gg/9vpqbjU"><img src="https://img.shields.io/discord/712952679415939085?label=discord&logo=discord&style=flat-square" alt="discord"></a> <a href="https://discord.gg/9vpqbjU"><img src="https://img.shields.io/discord/712952679415939085?label=discord&logo=discord&style=flat-square" alt="discord"></a>
@@ -12,14 +12,39 @@
</p> </p>
<p align="center"> <p align="center">
<a href="#features">Features</a> -
<a href="#examples">Examples</a> - <a href="#examples">Examples</a> -
<a href="#building">Building</a> -
<a href="#documentation">Documentation</a> - <a href="#documentation">Documentation</a> -
<a href="#supported-platforms">Supported Platforms</a> - <a href="#supported-platforms">Supported Platforms</a> -
<a href="#backends">Backends</a> - <a href="#license">License</a>
<a href="#major-features">Major Features</a> -
<a href="#building">Building</a>
</p> </p>
miniaudio is written in C with no dependencies except the standard library and should compile clean on all major
compilers without the need to install any additional development packages. All major desktop and mobile platforms
are supported.
Features
========
- Simple build system with no external dependencies.
- Simple and flexible API.
- Low-level API for direct access to raw audio data.
- High-level API for sound management, mixing, effects and optional 3D spatialization.
- Flexible node graph system for advanced mixing and effect processing.
- Resource management for loading sound files.
- Decoding, with built-in support for WAV, FLAC and MP3, in addition to being able to plug in custom decoders.
- Encoding (WAV only).
- Data conversion.
- Resampling, including custom resamplers.
- Channel mapping.
- Basic generation of waveforms and noise.
- Basic effects and filters.
Refer to the [Programming Manual](https://miniaud.io/docs/manual/) for a more complete description of
available features in miniaudio.
Examples Examples
======== ========
@@ -27,27 +52,21 @@ This example shows one way to play a sound using the high level API.
```c ```c
#define MINIAUDIO_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h" #include "miniaudio.h"
#include <stdio.h> #include <stdio.h>
int main(int argc, char** argv) int main()
{ {
ma_result result; ma_result result;
ma_engine engine; ma_engine engine;
if (argc < 2) {
printf("No input file.");
return -1;
}
result = ma_engine_init(NULL, &engine); result = ma_engine_init(NULL, &engine);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
printf("Failed to initialize audio engine.");
return -1; return -1;
} }
ma_engine_play_sound(&engine, argv[1], NULL); ma_engine_play_sound(&engine, "sound.wav", NULL);
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
@@ -62,7 +81,7 @@ This example shows how to decode and play a sound using the low level API.
```c ```c
#define MINIAUDIO_IMPLEMENTATION #define MINIAUDIO_IMPLEMENTATION
#include "../miniaudio.h" #include "miniaudio.h"
#include <stdio.h> #include <stdio.h>
@@ -128,6 +147,34 @@ int main(int argc, char** argv)
More examples can be found in the [examples](examples) folder or online here: https://miniaud.io/docs/examples/ More examples can be found in the [examples](examples) folder or online here: https://miniaud.io/docs/examples/
Building
========
Do the following in one source file:
```c
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"
```
Then just compile. There's no need to install any dependencies. On Windows and macOS there's no need to link
to anything. On Linux just link to `-lpthread`, `-lm` and `-ldl`. On BSD just link to `-lpthread` and `-lm`.
On iOS you need to compile as Objective-C.
If you get errors about undefined references to `__sync_val_compare_and_swap_8`, `__atomic_load_8`, etc. you
need to link with `-latomic`.
If you prefer separate .h and .c files, you can find a split version of miniaudio in the extras/miniaudio_split
folder. From here you can use miniaudio as a traditional .c and .h library - just add miniaudio.c to your source
tree like any other source file and include miniaudio.h like a normal header. If you prefer compiling as a
single translation unit (AKA unity builds), you can just #include the .c file in your main source file:
```c
#include "miniaudio.c"
```
Note that the split version is auto-generated using a tool and is based on the main file in the root directory.
If you want to contribute, please make the change in the main file.
ABI compatibility is not guaranteed between versions so take care if compiling as a DLL/SO. The suggested way
to integrate miniaudio is by adding it directly to your source tree.
Documentation Documentation
============= =============
Online documentation can be found here: https://miniaud.io/docs/ Online documentation can be found here: https://miniaud.io/docs/
@@ -139,17 +186,20 @@ documentation is generated from this in-code documentation.
Supported Platforms Supported Platforms
=================== ===================
- Windows, UWP - Windows
- macOS, iOS - macOS, iOS
- Linux - Linux
- BSD - FreeBSD / OpenBSD / NetBSD
- Android - Android
- Raspberry Pi - Raspberry Pi
- Emscripten / HTML5 - Emscripten / HTML5
miniaudio should compile clean on other platforms, but it will not include any support for playback or capture
by default. To support that, you would need to implement a custom backend. You can do this without needing to
modify the miniaudio source code. See the [custom_backend](examples/custom_backend.c) example.
Backends Backends
======== --------
- WASAPI - WASAPI
- DirectSound - DirectSound
- WinMM - WinMM
@@ -167,80 +217,6 @@ Backends
- Custom - Custom
Major Features License
============== =======
- Your choice of either public domain or [MIT No Attribution](https://github.com/aws/mit-0). Your choice of either public domain or [MIT No Attribution](https://github.com/aws/mit-0).
- Entirely contained within a single file for easy integration into your source tree.
- No external dependencies except for the C standard library and backend libraries.
- Written in C and compilable as C++, enabling miniaudio to work on almost all compilers.
- Supports all major desktop and mobile platforms, with multiple backends for maximum compatibility.
- A low level API with direct access to the raw audio data.
- A high level API with sound management and effects, including 3D spatialization.
- Supports playback, capture, full-duplex and loopback (WASAPI only).
- Device enumeration for connecting to specific devices, not just defaults.
- Connect to multiple devices at once.
- Shared and exclusive mode on supported backends.
- Resource management for loading and streaming sounds.
- A node graph system for advanced mixing and effect processing.
- Data conversion (sample format conversion, channel conversion and resampling).
- Filters.
- Biquads
- Low-pass (first, second and high order)
- High-pass (first, second and high order)
- Band-pass (second and high order)
- Effects.
- Delay/Echo
- Spatializer
- Stereo Pan
- Waveform generation (sine, square, triangle, sawtooth).
- Noise generation (white, pink, Brownian).
- Decoding
- WAV
- FLAC
- MP3
- Vorbis via stb_vorbis (not built in - must be included separately).
- Custom
- Encoding
- WAV
Refer to the [Programming Manual](https://miniaud.io/docs/manual/) for a more complete description of
available features in miniaudio.
Building
========
Do the following in one source file:
```c
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"
```
Then just compile. There's no need to install any dependencies. On Windows and macOS there's no need to link
to anything. On Linux just link to -lpthread, -lm and -ldl. On BSD just link to -lpthread and -lm. On iOS you
need to compile as Objective-C.
If you prefer separate .h and .c files, you can find a split version of miniaudio in the extras/miniaudio_split
folder. From here you can use miniaudio as a traditional .c and .h library - just add miniaudio.c to your source
tree like any other source file and include miniaudio.h like a normal header. If you prefer compiling as a
single translation unit (AKA unity builds), you can just #include the .c file in your main source file:
```c
#include "miniaudio.c"
```
Note that the split version is auto-generated using a tool and is based on the main file in the root directory.
If you want to contribute, please make the change in the main file.
Vorbis Decoding
---------------
Vorbis decoding is enabled via stb_vorbis. To use it, you need to include the header section of stb_vorbis
before the implementation of miniaudio. You can enable Vorbis by doing the following:
```c
#define STB_VORBIS_HEADER_ONLY
#include "extras/stb_vorbis.c" /* Enables Vorbis decoding. */
#define MINIAUDIO_IMPLEMENTATION
#include "miniaudio.h"
/* stb_vorbis implementation must come after the implementation of miniaudio. */
#undef STB_VORBIS_HEADER_ONLY
#include "extras/stb_vorbis.c"
```
+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); ((MA_PFN_SDL_QuitSubSystem)pContextEx->sdl.SDL_QuitSubSystem)(MA_SDL_INIT_AUDIO);
/* Close the handle to the SDL shared object last. */ /* 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; pContextEx->sdl.hSDL = NULL;
return MA_SUCCESS; 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. */ /* 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) { 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) { if (pContextEx->sdl.hSDL != NULL) {
break; 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. */ /* 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_InitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_InitSubSystem");
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_QuitSubSystem"); pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices"); pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName"); pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_CloseAudioDevice"); pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_OpenAudioDevice"); pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_PauseAudioDevice"); pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
#else #else
pContextEx->sdl.SDL_InitSubSystem = (ma_proc)SDL_InitSubSystem; pContextEx->sdl.SDL_InitSubSystem = (ma_proc)SDL_InitSubSystem;
pContextEx->sdl.SDL_QuitSubSystem = (ma_proc)SDL_QuitSubSystem; 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); resultSDL = ((MA_PFN_SDL_InitSubSystem)pContextEx->sdl.SDL_InitSubSystem)(MA_SDL_INIT_AUDIO);
if (resultSDL != 0) { if (resultSDL != 0) {
ma_dlclose(pContext, pContextEx->sdl.hSDL); ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
return MA_ERROR; return MA_ERROR;
} }
File diff suppressed because it is too large Load Diff
+61 -20
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. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.11.15 - 2023-04-30 miniaudio - v0.11.17 - 2023-05-27
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
@@ -20,7 +20,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0 #define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 11 #define MA_VERSION_MINOR 11
#define MA_VERSION_REVISION 15 #define MA_VERSION_REVISION 17
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #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__) #if defined(_MSC_VER) && !defined(__clang__)
@@ -212,6 +212,13 @@ typedef ma_uint16 wchar_t;
#ifdef _MSC_VER #ifdef _MSC_VER
#define MA_INLINE __forceinline #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__) #elif defined(__GNUC__)
/* /*
I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
@@ -228,13 +235,17 @@ typedef ma_uint16 wchar_t;
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__) #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
#define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline)) #define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline))
#define MA_NO_INLINE __attribute__((noinline))
#else #else
#define MA_INLINE MA_GNUC_INLINE_HINT #define MA_INLINE MA_GNUC_INLINE_HINT
#define MA_NO_INLINE __attribute__((noinline))
#endif #endif
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
#define MA_INLINE __inline #define MA_INLINE __inline
#define MA_NO_INLINE
#else #else
#define MA_INLINE #define MA_INLINE
#define MA_NO_INLINE
#endif #endif
#if !defined(MA_API) #if !defined(MA_API)
@@ -464,28 +475,31 @@ typedef enum
MA_CANCELLED = -51, MA_CANCELLED = -51,
MA_MEMORY_ALREADY_MAPPED = -52, MA_MEMORY_ALREADY_MAPPED = -52,
/* General non-standard errors. */
MA_CRC_MISMATCH = -100,
/* General miniaudio-specific errors. */ /* General miniaudio-specific errors. */
MA_FORMAT_NOT_SUPPORTED = -100, MA_FORMAT_NOT_SUPPORTED = -200,
MA_DEVICE_TYPE_NOT_SUPPORTED = -101, MA_DEVICE_TYPE_NOT_SUPPORTED = -201,
MA_SHARE_MODE_NOT_SUPPORTED = -102, MA_SHARE_MODE_NOT_SUPPORTED = -202,
MA_NO_BACKEND = -103, MA_NO_BACKEND = -203,
MA_NO_DEVICE = -104, MA_NO_DEVICE = -204,
MA_API_NOT_FOUND = -105, MA_API_NOT_FOUND = -205,
MA_INVALID_DEVICE_CONFIG = -106, MA_INVALID_DEVICE_CONFIG = -206,
MA_LOOP = -107, MA_LOOP = -207,
MA_BACKEND_NOT_ENABLED = -108, MA_BACKEND_NOT_ENABLED = -208,
/* State errors. */ /* State errors. */
MA_DEVICE_NOT_INITIALIZED = -200, MA_DEVICE_NOT_INITIALIZED = -300,
MA_DEVICE_ALREADY_INITIALIZED = -201, MA_DEVICE_ALREADY_INITIALIZED = -301,
MA_DEVICE_NOT_STARTED = -202, MA_DEVICE_NOT_STARTED = -302,
MA_DEVICE_NOT_STOPPED = -203, MA_DEVICE_NOT_STOPPED = -303,
/* Operation errors. */ /* Operation errors. */
MA_FAILED_TO_INIT_BACKEND = -300, MA_FAILED_TO_INIT_BACKEND = -400,
MA_FAILED_TO_OPEN_BACKEND_DEVICE = -301, MA_FAILED_TO_OPEN_BACKEND_DEVICE = -401,
MA_FAILED_TO_START_BACKEND_DEVICE = -302, MA_FAILED_TO_START_BACKEND_DEVICE = -402,
MA_FAILED_TO_STOP_BACKEND_DEVICE = -303 MA_FAILED_TO_STOP_BACKEND_DEVICE = -403
} ma_result; } ma_result;
@@ -6343,7 +6357,7 @@ struct ma_encoder
ma_encoder_uninit_proc onUninit; ma_encoder_uninit_proc onUninit;
ma_encoder_write_pcm_frames_proc onWritePCMFrames; ma_encoder_write_pcm_frames_proc onWritePCMFrames;
void* pUserData; void* pUserData;
void* pInternalEncoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */ void* pInternalEncoder;
union union
{ {
struct struct
@@ -6408,6 +6422,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_type(ma_waveform* pWaveform, ma_waveform_type type);
MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate); 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 typedef enum
{ {
ma_noise_type_white, ma_noise_type_white,
+8889 -10653
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 = ma_data_converter_config_init(ma_format_s16, ma_format_s16, 1, 1, rateIn, rateOut);
config.resampling.algorithm = algorithm; config.resampling.algorithm = algorithm;
result = ma_data_converter_init(&config, pDataConverter); result = ma_data_converter_init(&config, NULL, pDataConverter);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
} }
@@ -52,7 +52,7 @@ ma_result test_data_converter__resampling_expected_output_fixed_interval(ma_data
ma_uint64 expectedOutputFrameCount; 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. */ /* 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); outputFrameCount = ma_countof(output);
inputFrameCount = frameCountPerIteration; 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); result = test_data_converter__resampling_expected_output_fixed_interval(&converter, frameCountPerIteration);
ma_data_converter_uninit(&converter); ma_data_converter_uninit(&converter, NULL);
if (hasError) { if (hasError) {
return MA_ERROR; return MA_ERROR;
@@ -170,12 +170,6 @@ ma_result test_data_converter__resampling_expected_output()
hasError = MA_TRUE; 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) { if (hasError) {
return MA_ERROR; return MA_ERROR;
} else { } else {
@@ -205,7 +199,7 @@ ma_result test_data_converter__resampling_required_input_fixed_interval(ma_data_
ma_uint64 requiredInputFrameCount; 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. */ /* 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; outputFrameCount = frameCountPerIteration;
inputFrameCount = ma_countof(input); 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); result = test_data_converter__resampling_required_input_fixed_interval(&converter, frameCountPerIteration);
ma_data_converter_uninit(&converter); ma_data_converter_uninit(&converter, NULL);
if (hasError) { if (hasError) {
return MA_ERROR; return MA_ERROR;
@@ -323,12 +317,6 @@ ma_result test_data_converter__resampling_required_input()
hasError = MA_TRUE; 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) { if (hasError) {
return MA_ERROR; return MA_ERROR;
} else { } else {
-17
View File
@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
return MA_SUCCESS; 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 -1
View File
@@ -12,7 +12,7 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
return result; 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); result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, pEncoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(pDecoder); 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead); ma_bpf2_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -97,13 +97,13 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead); ma_bpf_process_pcm_frames(&bpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; break;
@@ -14,7 +14,7 @@ ma_result test_dithering__u8(const char* pInputFilePath)
return result; 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); result = ma_encoder_init_file(pOutputFilePath, &encoderConfig, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
@@ -30,13 +30,13 @@ ma_result test_dithering__u8(const char* pInputFilePath)
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); 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. */ /* Convert, with dithering. */
ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle); ma_convert_pcm_frames_format(tempOut, ma_format_u8, tempIn, decoder.outputFormat, framesJustRead, decoder.outputChannels, ma_dither_mode_triangle);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_hishelf2_process_pcm_frames(&hishelf, tempOut, tempIn, framesJustRead); ma_hishelf2_process_pcm_frames(&hishelf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf1_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -97,13 +97,13 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf2_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -158,13 +158,13 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead); ma_hpf_process_pcm_frames(&hpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_loshelf2_process_pcm_frames(&loshelf, tempOut, tempIn, framesJustRead); ma_loshelf2_process_pcm_frames(&loshelf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf1_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -97,13 +97,13 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf2_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -159,13 +159,13 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead); ma_lpf_process_pcm_frames(&lpf, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_notch2_process_pcm_frames(&notch, tempOut, tempIn, framesJustRead); ma_notch2_process_pcm_frames(&notch, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); 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) { if (result != MA_SUCCESS) {
ma_decoder_uninit(&decoder); ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder); ma_encoder_uninit(&encoder);
@@ -36,13 +36,13 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
ma_uint64 framesJustRead; ma_uint64 framesJustRead;
framesToRead = ma_min(tempCapIn, tempCapOut); framesToRead = ma_min(tempCapIn, tempCapOut);
framesJustRead = ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead); ma_decoder_read_pcm_frames(&decoder, tempIn, framesToRead, &framesJustRead);
/* Filter */ /* Filter */
ma_peak2_process_pcm_frames(&peak, tempOut, tempIn, framesJustRead); ma_peak2_process_pcm_frames(&peak, tempOut, tempIn, framesJustRead);
/* Write to the WAV file. */ /* 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) { if (framesJustRead < framesToRead) {
break; 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); printf(" %s\n", pFileName);
noiseConfig = ma_noise_config_init(format, 1, type, 0, 0.1); 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) { if (result != MA_SUCCESS) {
return result; 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); result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; 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. */ /* We'll do a few seconds of data. */
for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) { for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) {
ma_uint8 temp[1024]; ma_uint8 temp[1024];
ma_noise_read_pcm_frames(&noise, temp, 1); ma_noise_read_pcm_frames(&noise, temp, 1, NULL);
ma_encoder_write_pcm_frames(&encoder, temp, 1); ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
} }
ma_encoder_uninit(&encoder); 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 test_waveform__by_format_and_type(ma_format format, ma_waveform_type type, double amplitude, const char* pFileName)
{ {
ma_result result; ma_result result;
ma_waveform_config waveformConfig; ma_waveform_config waveformConfig;
ma_waveform waveform; ma_waveform waveform;
drwav_data_format wavFormat; ma_encoder_config encoderConfig;
drwav wav; ma_encoder encoder;
ma_uint32 iFrame; ma_uint32 iFrame;
printf(" %s\n", pFileName); 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; return result;
} }
wavFormat = drwav_data_format_from_waveform_config(&waveformConfig); encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, waveformConfig.format, waveformConfig.channels, waveformConfig.sampleRate);
if (!drwav_init_file_write(&wav, pFileName, &wavFormat, NULL)) { result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
return MA_ERROR; /* Could not open file for writing. */ if (result != MA_SUCCESS) {
return result; /* Failed to initialize encoder. */
} }
/* We'll do a few seconds of data. */ /* 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]; float temp[MA_MAX_CHANNELS];
ma_waveform_read_pcm_frames(&waveform, temp, 1); ma_waveform_read_pcm_frames(&waveform, temp, 1, NULL);
drwav_write_pcm_frames(&wav, 1, temp); ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
} }
drwav_uninit(&wav); ma_encoder_uninit(&encoder);
ma_waveform_uninit(&waveform);
return MA_SUCCESS; return MA_SUCCESS;
} }