mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Update tests.
This commit is contained in:
Vendored
+8207
File diff suppressed because it is too large
Load Diff
Vendored
+1177
File diff suppressed because it is too large
Load Diff
@@ -4,31 +4,7 @@
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ma_result result;
|
ma_register_test("Data Conversion", test_entry__data_converter);
|
||||||
ma_bool32 hasError = MA_FALSE;
|
|
||||||
size_t iTest;
|
|
||||||
|
|
||||||
(void)argc;
|
return ma_run_tests(argc, argv);
|
||||||
(void)argv;
|
|
||||||
|
|
||||||
result = ma_register_test("Data Conversion", test_entry__data_converter);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (iTest = 0; iTest < g_Tests.count; iTest += 1) {
|
|
||||||
printf("=== BEGIN %s ===\n", g_Tests.pTests[iTest].pName);
|
|
||||||
result = g_Tests.pTests[iTest].onEntry(argc, argv);
|
|
||||||
printf("=== END %s : %s ===\n", g_Tests.pTests[iTest].pName, (result == 0) ? "PASSED" : "FAILED");
|
|
||||||
|
|
||||||
if (result != 0) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasError) {
|
|
||||||
return -1; /* Something failed. */
|
|
||||||
} else {
|
|
||||||
return 0; /* Everything passed. */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#include "../../miniaudio.c"
|
#include "../../miniaudio.c"
|
||||||
|
#include "../../external/fs/fs.c"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define MAX_TESTS 64
|
#define MAX_TESTS 64
|
||||||
#define TEST_OUTPUT_DIR "res/output"
|
#define TEST_OUTPUT_DIR "output"
|
||||||
|
|
||||||
typedef int (* ma_test_entry_proc)(int argc, char** argv);
|
typedef int (* ma_test_entry_proc)(int argc, char** argv);
|
||||||
|
|
||||||
@@ -36,3 +37,37 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
|
|||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ma_run_tests(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
ma_bool32 hasError = MA_FALSE;
|
||||||
|
size_t iTest;
|
||||||
|
fs* pFS;
|
||||||
|
|
||||||
|
if (fs_init(NULL, &pFS) != FS_SUCCESS) {
|
||||||
|
printf("Failed to initialize the file system.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs_mkdir(pFS, TEST_OUTPUT_DIR);
|
||||||
|
|
||||||
|
for (iTest = 0; iTest < g_Tests.count; iTest += 1) {
|
||||||
|
printf("=== BEGIN %s ===\n", g_Tests.pTests[iTest].pName);
|
||||||
|
result = g_Tests.pTests[iTest].onEntry(argc, argv);
|
||||||
|
printf("=== END %s : %s ===\n", g_Tests.pTests[iTest].pName, (result == 0) ? "PASSED" : "FAILED");
|
||||||
|
|
||||||
|
if (result != 0) {
|
||||||
|
hasError = MA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs_uninit(pFS);
|
||||||
|
pFS = NULL;
|
||||||
|
|
||||||
|
if (hasError) {
|
||||||
|
return 1; /* Something failed. */
|
||||||
|
} else {
|
||||||
|
return 0; /* Everything passed. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
|
|||||||
decoderConfig = ma_decoder_config_init(format, channels, sampleRate);
|
decoderConfig = ma_decoder_config_init(format, channels, sampleRate);
|
||||||
result = ma_decoder_init_file(pInputFilePath, &decoderConfig, pDecoder);
|
result = ma_decoder_init_file(pInputFilePath, &decoderConfig, pDecoder);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
|
printf("Failed to open \"%s\" for decoding. %s\n", pInputFilePath, ma_result_description(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
encoderConfig = ma_encoder_config_init(ma_encoding_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) {
|
||||||
|
printf("Failed to open \"%s\" for encoding. %s\n", pOutputFilePath, ma_result_description(result));
|
||||||
ma_decoder_uninit(pDecoder);
|
ma_decoder_uninit(pDecoder);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -33,67 +35,14 @@ ma_result filtering_init_decoder_and_encoder(const char* pInputFilePath, const c
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ma_result result;
|
ma_register_test("Dithering", test_entry__dithering);
|
||||||
ma_bool32 hasError = MA_FALSE;
|
ma_register_test("Low-Pass Filtering", test_entry__lpf);
|
||||||
size_t iTest;
|
ma_register_test("High-Pass Filtering", test_entry__hpf);
|
||||||
|
ma_register_test("Band-Pass Filtering", test_entry__bpf);
|
||||||
|
ma_register_test("Notching Filtering", test_entry__notch);
|
||||||
|
ma_register_test("Peaking EQ Filtering", test_entry__peak);
|
||||||
|
ma_register_test("Low Shelf Filtering", test_entry__loshelf);
|
||||||
|
ma_register_test("High Shelf Filtering", test_entry__hishelf);
|
||||||
|
|
||||||
(void)argc;
|
return ma_run_tests(argc, argv);
|
||||||
(void)argv;
|
|
||||||
|
|
||||||
result = ma_register_test("Dithering", test_entry__dithering);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Low-Pass Filtering", test_entry__lpf);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("High-Pass Filtering", test_entry__hpf);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Band-Pass Filtering", test_entry__bpf);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Notching Filtering", test_entry__notch);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Peaking EQ Filtering", test_entry__peak);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Low Shelf Filtering", test_entry__loshelf);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("High Shelf Filtering", test_entry__hishelf);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (iTest = 0; iTest < g_Tests.count; iTest += 1) {
|
|
||||||
printf("=== BEGIN %s ===\n", g_Tests.pTests[iTest].pName);
|
|
||||||
result = g_Tests.pTests[iTest].onEntry(argc, argv);
|
|
||||||
printf("=== END %s : %s ===\n", g_Tests.pTests[iTest].pName, (result == 0) ? "PASSED" : "FAILED");
|
|
||||||
|
|
||||||
if (result != 0) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasError) {
|
|
||||||
return -1; /* Something failed. */
|
|
||||||
} else {
|
|
||||||
return 0; /* Everything passed. */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,36 +6,8 @@
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ma_result result;
|
ma_register_test("Noise", test_entry__noise);
|
||||||
ma_bool32 hasError = MA_FALSE;
|
ma_register_test("Waveform", test_entry__waveform);
|
||||||
size_t iTest;
|
|
||||||
|
|
||||||
(void)argc;
|
return ma_run_tests(argc, argv);
|
||||||
(void)argv;
|
|
||||||
|
|
||||||
result = ma_register_test("Noise", test_entry__noise);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ma_register_test("Waveform", test_entry__waveform);
|
|
||||||
if (result != MA_SUCCESS) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (iTest = 0; iTest < g_Tests.count; iTest += 1) {
|
|
||||||
printf("=== BEGIN %s ===\n", g_Tests.pTests[iTest].pName);
|
|
||||||
result = g_Tests.pTests[iTest].onEntry(argc, argv);
|
|
||||||
printf("=== END %s : %s ===\n", g_Tests.pTests[iTest].pName, (result == 0) ? "PASSED" : "FAILED");
|
|
||||||
|
|
||||||
if (result != 0) {
|
|
||||||
hasError = MA_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasError) {
|
|
||||||
return -1; /* Something failed. */
|
|
||||||
} else {
|
|
||||||
return 0; /* Everything passed. */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
|||||||
encoderConfig = ma_encoder_config_init(ma_encoding_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) {
|
||||||
|
printf("Failed to open \"%s\" for writing. %s\n", pFileName, ma_result_description(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,17 +66,17 @@ ma_result test_noise__s16()
|
|||||||
ma_result result;
|
ma_result result;
|
||||||
ma_bool32 hasError = MA_FALSE;
|
ma_bool32 hasError = MA_FALSE;
|
||||||
|
|
||||||
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_white, TEST_OUTPUT_DIR"/output/noise_s16_white.wav");
|
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_white, TEST_OUTPUT_DIR"/noise_s16_white.wav");
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
hasError = MA_TRUE;
|
hasError = MA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_pink, TEST_OUTPUT_DIR"/output/noise_s16_pink.wav");
|
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_pink, TEST_OUTPUT_DIR"/noise_s16_pink.wav");
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
hasError = MA_TRUE;
|
hasError = MA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_brownian, TEST_OUTPUT_DIR"/output/noise_s16_brownian.wav");
|
result = test_noise__by_format_and_type(ma_format_s16, ma_noise_type_brownian, TEST_OUTPUT_DIR"/noise_s16_brownian.wav");
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
hasError = MA_TRUE;
|
hasError = MA_TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user