mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Merge branch 'dev' into dev-0.12
This commit is contained in:
+22
-2
@@ -1,7 +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 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
|
||||||
|
|||||||
@@ -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
@@ -532,7 +532,7 @@ static ma_result ma_context_uninit__sdl(void* pUserData, 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;
|
||||||
@@ -563,7 +563,7 @@ static ma_result ma_context_init__sdl(void* pUserData, ma_context* pContext, 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;
|
||||||
}
|
}
|
||||||
@@ -574,13 +574,13 @@ static ma_result ma_context_init__sdl(void* pUserData, ma_context* pContext, 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;
|
||||||
@@ -593,7 +593,7 @@ static ma_result ma_context_init__sdl(void* pUserData, ma_context* pContext, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9014
-10651
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||||
miniaudio - v0.11.14 - 2023-03-29
|
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 14
|
#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,
|
||||||
@@ -7302,6 +7343,7 @@ typedef struct
|
|||||||
ma_uint32 channelsIn;
|
ma_uint32 channelsIn;
|
||||||
ma_uint32 channelsOut;
|
ma_uint32 channelsOut;
|
||||||
ma_uint32 sampleRate; /* Only used when the type is set to ma_engine_node_type_sound. */
|
ma_uint32 sampleRate; /* Only used when the type is set to ma_engine_node_type_sound. */
|
||||||
|
ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
|
||||||
ma_mono_expansion_mode monoExpansionMode;
|
ma_mono_expansion_mode monoExpansionMode;
|
||||||
ma_bool8 isPitchDisabled; /* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
|
ma_bool8 isPitchDisabled; /* Pitching can be explicitly disabled with MA_SOUND_FLAG_NO_PITCH to optimize processing. */
|
||||||
ma_bool8 isSpatializationDisabled; /* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
|
ma_bool8 isSpatializationDisabled; /* Spatialization can be explicitly disabled with MA_SOUND_FLAG_NO_SPATIALIZATION. */
|
||||||
@@ -7317,11 +7359,14 @@ typedef struct
|
|||||||
ma_node_base baseNode; /* Must be the first member for compatiblity with the ma_node API. */
|
ma_node_base baseNode; /* Must be the first member for compatiblity with the ma_node API. */
|
||||||
ma_engine* pEngine; /* A pointer to the engine. Set based on the value from the config. */
|
ma_engine* pEngine; /* A pointer to the engine. Set based on the value from the config. */
|
||||||
ma_uint32 sampleRate; /* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */
|
ma_uint32 sampleRate; /* The sample rate of the input data. For sounds backed by a data source, this will be the data source's sample rate. Otherwise it'll be the engine's sample rate. */
|
||||||
|
ma_uint32 volumeSmoothTimeInPCMFrames;
|
||||||
ma_mono_expansion_mode monoExpansionMode;
|
ma_mono_expansion_mode monoExpansionMode;
|
||||||
ma_fader fader;
|
ma_fader fader;
|
||||||
ma_linear_resampler resampler; /* For pitch shift. */
|
ma_linear_resampler resampler; /* For pitch shift. */
|
||||||
ma_spatializer spatializer;
|
ma_spatializer spatializer;
|
||||||
ma_panner panner;
|
ma_panner panner;
|
||||||
|
ma_gainer volumeGainer; /* This will only be used if volumeSmoothTimeInPCMFrames is > 0. */
|
||||||
|
ma_atomic_float volume; /* Defaults to 1. */
|
||||||
MA_ATOMIC(4, float) pitch;
|
MA_ATOMIC(4, float) pitch;
|
||||||
float oldPitch; /* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */
|
float oldPitch; /* For determining whether or not the resampler needs to be updated to reflect the new pitch. The resampler will be updated on the mixing thread. */
|
||||||
float oldDopplerPitch; /* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */
|
float oldDopplerPitch; /* For determining whether or not the resampler needs to be updated to take a new doppler pitch into account. */
|
||||||
@@ -7356,6 +7401,7 @@ typedef struct
|
|||||||
ma_uint32 channelsOut; /* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */
|
ma_uint32 channelsOut; /* Set this to 0 (default) to use the engine's channel count. Set to MA_SOUND_SOURCE_CHANNEL_COUNT to use the data source's channel count (only used if using a data source as input). */
|
||||||
ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
|
ma_mono_expansion_mode monoExpansionMode; /* Controls how the mono channel should be expanded to other channels when spatialization is disabled on a sound. */
|
||||||
ma_uint32 flags; /* A combination of MA_SOUND_FLAG_* flags. */
|
ma_uint32 flags; /* A combination of MA_SOUND_FLAG_* flags. */
|
||||||
|
ma_uint32 volumeSmoothTimeInPCMFrames; /* The number of frames to smooth over volume changes. Defaults to 0 in which case no smoothing is used. */
|
||||||
ma_uint64 initialSeekPointInPCMFrames; /* Initializes the sound such that it's seeked to this location by default. */
|
ma_uint64 initialSeekPointInPCMFrames; /* Initializes the sound such that it's seeked to this location by default. */
|
||||||
ma_uint64 rangeBegInPCMFrames;
|
ma_uint64 rangeBegInPCMFrames;
|
||||||
ma_uint64 rangeEndInPCMFrames;
|
ma_uint64 rangeEndInPCMFrames;
|
||||||
@@ -7411,27 +7457,28 @@ MA_API ma_sound_group_config ma_sound_group_config_init_2(ma_engine* pEngine);
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
#if !defined(MA_NO_RESOURCE_MANAGER)
|
#if !defined(MA_NO_RESOURCE_MANAGER)
|
||||||
ma_resource_manager* pResourceManager; /* Can be null in which case a resource manager will be created for you. */
|
ma_resource_manager* pResourceManager; /* Can be null in which case a resource manager will be created for you. */
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MA_NO_DEVICE_IO)
|
#if !defined(MA_NO_DEVICE_IO)
|
||||||
ma_context* pContext;
|
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* 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_id* pPlaybackDeviceID; /* The ID of the playback device to use with the default listener. */
|
||||||
ma_device_notification_proc notificationCallback;
|
ma_device_notification_proc notificationCallback;
|
||||||
#endif
|
#endif
|
||||||
ma_log* pLog; /* When set to NULL, will use the context's log. */
|
ma_log* pLog; /* When set to NULL, will use the context's log. */
|
||||||
ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
|
ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
|
||||||
ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
|
ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
|
||||||
ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */
|
ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */
|
||||||
ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
|
ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
|
||||||
ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */
|
ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */
|
||||||
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
|
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
|
||||||
ma_uint32 gainSmoothTimeInMilliseconds; /* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
|
ma_uint32 gainSmoothTimeInMilliseconds; /* When set to 0, gainSmoothTimeInFrames will be used. If both are set to 0, a default value will be used. */
|
||||||
|
ma_uint32 defaultVolumeSmoothTimeInPCMFrames; /* Defaults to 0. Controls the default amount of smoothing to apply to volume changes to sounds. High values means more smoothing at the expense of high latency (will take longer to reach the new volume). */
|
||||||
ma_allocation_callbacks allocationCallbacks;
|
ma_allocation_callbacks allocationCallbacks;
|
||||||
ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
|
ma_bool32 noAutoStart; /* When set to true, requires an explicit call to ma_engine_start(). This is false by default, meaning the engine will be started automatically in ma_engine_init(). */
|
||||||
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_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_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_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_config;
|
} ma_engine_config;
|
||||||
|
|
||||||
MA_API ma_engine_config ma_engine_config_init(void);
|
MA_API ma_engine_config ma_engine_config_init(void);
|
||||||
@@ -7457,6 +7504,7 @@ struct ma_engine
|
|||||||
ma_sound_inlined* pInlinedSoundHead; /* The first inlined sound. Inlined sounds are tracked in a linked list. */
|
ma_sound_inlined* pInlinedSoundHead; /* The first inlined sound. Inlined sounds are tracked in a linked list. */
|
||||||
MA_ATOMIC(4, ma_uint32) inlinedSoundCount; /* The total number of allocated inlined sound objects. Used for debugging. */
|
MA_ATOMIC(4, ma_uint32) inlinedSoundCount; /* The total number of allocated inlined sound objects. Used for debugging. */
|
||||||
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. */
|
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. */
|
||||||
|
ma_uint32 defaultVolumeSmoothTimeInPCMFrames;
|
||||||
ma_mono_expansion_mode monoExpansionMode;
|
ma_mono_expansion_mode monoExpansionMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+8987
-10677
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 {
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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(¬chConfig, ¬ch);
|
result = ma_notch2_init(¬chConfig, NULL, ¬ch);
|
||||||
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(¬ch, tempOut, tempIn, framesJustRead);
|
ma_notch2_process_pcm_frames(¬ch, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user