rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c
Go to the documentation of this file.
1 /* Make sure we include the Speex resampler so we can test it. */
2 #define MINIAUDIO_SPEEX_RESAMPLER_IMPLEMENTATION
3 #include "../../extras/speex_resampler/ma_speex_resampler.h"
4 
5 #define MINIAUDIO_IMPLEMENTATION
6 #include "../../miniaudio.h"
7 
8 #include <stdio.h>
9 
10 #define MAX_TESTS 64
11 #define TEST_OUTPUT_DIR "res/output"
12 
13 typedef int (* ma_test_entry_proc)(int argc, char** argv);
14 
15 typedef struct
16 {
17  const char* pName;
18  ma_test_entry_proc onEntry;
19 } ma_test;
20 
21 static struct
22 {
24  size_t count;
25 } g_Tests;
26 
27 ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
28 {
29  MA_ASSERT(pName != NULL);
30  MA_ASSERT(onEntry != NULL);
31 
32  if (g_Tests.count >= MAX_TESTS) {
33  printf("Failed to register test %s because there are too many tests already registered. Increase the value of MAX_TESTS\n", pName);
34  return MA_INVALID_OPERATION;
35  }
36 
37  g_Tests.pTests[g_Tests.count].pName = pName;
38  g_Tests.pTests[g_Tests.count].onEntry = onEntry;
39  g_Tests.count += 1;
40 
41  return MA_SUCCESS;
42 }
43 
45 {
46  drwav_data_format wavFormat;
47 
48  wavFormat.container = drwav_container_riff;
49  wavFormat.channels = channels;
50  wavFormat.sampleRate = sampleRate;
51  wavFormat.bitsPerSample = ma_get_bytes_per_sample(format) * 8;
52 
53  if (format == ma_format_f32) {
55  } else {
56  wavFormat.format = DR_WAVE_FORMAT_PCM;
57  }
58 
59  return wavFormat;
60 }
drwav_data_format_from_minaudio_format
drwav_data_format drwav_data_format_from_minaudio_format(ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:44
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
ma_test
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/tests/test_common/ma_test_common.c:22
ma_format_f32
@ ma_format_f32
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1790
pTests
ma_test pTests[MAX_TESTS]
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:23
ma_format
ma_format
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1779
ma_test_entry_proc
int(* ma_test_entry_proc)(int argc, char **argv)
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:13
count
size_t count
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:24
DR_WAVE_FORMAT_PCM
#define DR_WAVE_FORMAT_PCM
Definition: porcupine/demo/c/dr_libs/dr_wav.h:254
ma_result
int ma_result
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1658
drwav_data_format::format
drwav_uint32 format
Definition: porcupine/demo/c/dr_libs/dr_wav.h:438
drwav_data_format::channels
drwav_uint32 channels
Definition: porcupine/demo/c/dr_libs/dr_wav.h:439
ma_get_bytes_per_sample
ma_uint32 ma_get_bytes_per_sample(ma_format format)
Definition: porcupine/demo/c/pvrecorder/src/miniaudio/extras/miniaudio_split/miniaudio.c:37199
MA_INVALID_OPERATION
#define MA_INVALID_OPERATION
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1662
MA_ASSERT
#define MA_ASSERT(condition)
Definition: porcupine/demo/c/pvrecorder/src/miniaudio/extras/miniaudio_split/miniaudio.c:770
drwav_data_format::container
drwav_container container
Definition: porcupine/demo/c/dr_libs/dr_wav.h:437
drwav_container_riff
@ drwav_container_riff
Definition: porcupine/demo/c/dr_libs/dr_wav.h:276
drwav_data_format::bitsPerSample
drwav_uint32 bitsPerSample
Definition: porcupine/demo/c/dr_libs/dr_wav.h:441
ma_uint32
uint32_t ma_uint32
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1503
ma_register_test
ma_result ma_register_test(const char *pName, ma_test_entry_proc onEntry)
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:27
g_Tests
static struct @1072 g_Tests
python.test_porcupine.argv
argv
Definition: test_porcupine.py:158
drwav_data_format::sampleRate
drwav_uint32 sampleRate
Definition: porcupine/demo/c/dr_libs/dr_wav.h:440
DR_WAVE_FORMAT_IEEE_FLOAT
#define DR_WAVE_FORMAT_IEEE_FLOAT
Definition: porcupine/demo/c/dr_libs/dr_wav.h:256
MA_SUCCESS
#define MA_SUCCESS
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/miniaudio.h:1659
MAX_TESTS
#define MAX_TESTS
Definition: rhino/demo/c/pvrecorder/src/miniaudio/tests/test_common/ma_test_common.c:10
drwav_data_format
Definition: porcupine/demo/c/dr_libs/dr_wav.h:435


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56