Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
f028e65e
Commit
f028e65e
authored
Feb 23, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update filtering tests.
parent
d6f1d05d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
78 deletions
+63
-78
tests/test_filtering/ma_test_filtering.c
tests/test_filtering/ma_test_filtering.c
+21
-0
tests/test_filtering/ma_test_filtering_lpf.c
tests/test_filtering/ma_test_filtering_lpf.c
+42
-78
No files found.
tests/test_filtering/ma_test_filtering.c
View file @
f028e65e
#include "../test_common/ma_test_common.c"
ma_result
filtering_init_decoder_and_encoder
(
const
char
*
pInputFilePath
,
const
char
*
pOutputFilePath
,
ma_format
format
,
ma_uint32
channels
,
ma_uint32
sampleRate
,
ma_decoder
*
pDecoder
,
drwav
*
pEncoder
)
{
ma_result
result
;
ma_decoder_config
decoderConfig
;
drwav_data_format
wavFormat
;
decoderConfig
=
ma_decoder_config_init
(
format
,
0
,
0
);
result
=
ma_decoder_init_file
(
pInputFilePath
,
&
decoderConfig
,
pDecoder
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
wavFormat
=
drwav_data_format_from_minaudio_format
(
pDecoder
->
outputFormat
,
pDecoder
->
outputChannels
,
pDecoder
->
outputSampleRate
);
if
(
!
drwav_init_file_write
(
pEncoder
,
pOutputFilePath
,
&
wavFormat
,
NULL
))
{
ma_decoder_uninit
(
pDecoder
);
return
MA_ERROR
;
}
return
MA_SUCCESS
;
}
#include "ma_test_filtering_dithering.c"
#include "ma_test_filtering_lpf.c"
#include "ma_test_filtering_hpf.c"
...
...
tests/test_filtering/ma_test_filtering_lpf.c
View file @
f028e65e
ma_result
test_lpf1__f32
(
const
char
*
pInputFilePath
)
ma_result
lpf_init_decoder_and_encoder
(
const
char
*
pInputFilePath
,
const
char
*
pOutputFilePath
,
ma_format
format
,
ma_decoder
*
pDecoder
,
drwav
*
pEncoder
)
{
return
filtering_init_decoder_and_encoder
(
pInputFilePath
,
pOutputFilePath
,
format
,
0
,
0
,
pDecoder
,
pEncoder
);
}
ma_result
test_lpf1__by_format
(
const
char
*
pInputFilePath
,
const
char
*
pOutputFilePath
,
ma_format
format
)
{
const
char
*
pOutputFilePath
=
"output/lpf1_f32.wav"
;
ma_result
result
;
ma_decoder_config
decoderConfig
;
ma_decoder
decoder
;
drwav_data_format
wavFormat
;
drwav
wav
;
ma_lpf1_config
lpfConfig
;
ma_lpf1
lpf
;
decoderConfig
=
ma_decoder_config_init
(
ma_format_f32
,
0
,
0
);
result
=
ma_decoder_init_file
(
pInputFilePath
,
&
decoderConfig
,
&
decoder
);
printf
(
" %s
\n
"
,
pOutputFilePath
);
result
=
lpf_init_decoder_and_encoder
(
pInputFilePath
,
pOutputFilePath
,
format
,
&
decoder
,
&
wav
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
lpfConfig
=
ma_lpf_config_init
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
,
2000
);
lpfConfig
=
ma_lpf
1
_config_init
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
,
2000
);
result
=
ma_lpf1_init
(
&
lpfConfig
,
&
lpf
);
if
(
result
!=
MA_SUCCESS
)
{
ma_decoder_uninit
(
&
decoder
);
drwav_uninit
(
&
wav
);
return
result
;
}
wavFormat
=
drwav_data_format_from_minaudio_format
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
);
if
(
!
drwav_init_file_write
(
&
wav
,
pOutputFilePath
,
&
wavFormat
,
NULL
))
{
ma_decoder_uninit
(
&
decoder
);
return
MA_ERROR
;
}
for
(;;)
{
ma_uint8
tempIn
[
4096
];
ma_uint8
tempOut
[
4096
];
...
...
@@ -55,75 +53,28 @@ ma_result test_lpf1__f32(const char* pInputFilePath)
return
MA_SUCCESS
;
}
ma_result
test_lpf1__
s16
(
const
char
*
pInputFilePath
)
ma_result
test_lpf1__
f32
(
const
char
*
pInputFilePath
)
{
const
char
*
pOutputFilePath
=
"output/lpf1_s16.wav"
;
ma_result
result
;
ma_decoder_config
decoderConfig
;
ma_decoder
decoder
;
drwav_data_format
wavFormat
;
drwav
wav
;
ma_lpf1_config
lpfConfig
;
ma_lpf1
lpf
;
decoderConfig
=
ma_decoder_config_init
(
ma_format_s16
,
0
,
0
);
result
=
ma_decoder_init_file
(
pInputFilePath
,
&
decoderConfig
,
&
decoder
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
lpfConfig
=
ma_lpf_config_init
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
,
2000
);
result
=
ma_lpf1_init
(
&
lpfConfig
,
&
lpf
);
if
(
result
!=
MA_SUCCESS
)
{
ma_decoder_uninit
(
&
decoder
);
return
result
;
}
wavFormat
=
drwav_data_format_from_minaudio_format
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
);
if
(
!
drwav_init_file_write
(
&
wav
,
pOutputFilePath
,
&
wavFormat
,
NULL
))
{
ma_decoder_uninit
(
&
decoder
);
return
MA_ERROR
;
}
for
(;;)
{
ma_uint8
tempIn
[
4096
];
ma_uint8
tempOut
[
4096
];
ma_uint64
tempCapIn
=
sizeof
(
tempIn
)
/
ma_get_bytes_per_frame
(
decoder
.
outputFormat
,
decoder
.
outputChannels
);
ma_uint64
tempCapOut
=
sizeof
(
tempOut
)
/
ma_get_bytes_per_frame
(
decoder
.
outputFormat
,
decoder
.
outputChannels
);
ma_uint64
framesToRead
;
ma_uint64
framesJustRead
;
framesToRead
=
ma_min
(
tempCapIn
,
tempCapOut
);
framesJustRead
=
ma_decoder_read_pcm_frames
(
&
decoder
,
tempIn
,
framesToRead
);
/* Filter */
ma_lpf1_process_pcm_frames
(
&
lpf
,
tempOut
,
tempIn
,
framesJustRead
);
/* Write to the WAV file. */
drwav_write_pcm_frames
(
&
wav
,
framesJustRead
,
tempOut
);
if
(
framesJustRead
<
framesToRead
)
{
break
;
}
}
return
test_lpf1__by_format
(
pInputFilePath
,
"output/lpf1_f32.wav"
,
ma_format_f32
);
}
drwav_uninit
(
&
wav
);
return
MA_SUCCESS
;
ma_result
test_lpf1__s16
(
const
char
*
pInputFilePath
)
{
return
test_lpf1__by_format
(
pInputFilePath
,
"output/lpf1_s16.wav"
,
ma_format_s16
);
}
ma_result
test_lpf2__f32
(
const
char
*
pInputFilePath
)
ma_result
test_lpf2__by_format
(
const
char
*
pInputFilePath
,
const
char
*
pOutputFilePath
,
ma_format
format
)
{
const
char
*
pOutputFilePath
=
"output/lpf2_f32.wav"
;
ma_result
result
;
ma_decoder_config
decoderConfig
;
ma_decoder
decoder
;
drwav_data_format
wavFormat
;
drwav
wav
;
ma_lpf_config
lpfConfig
;
ma_lpf
lpf
;
decoderConfig
=
ma_decoder_config_init
(
ma_format_f32
,
0
,
0
);
result
=
ma_decoder_init_file
(
pInputFilePath
,
&
decoderConfig
,
&
decoder
);
printf
(
" %s
\n
"
,
pOutputFilePath
);
result
=
lpf_init_decoder_and_encoder
(
pInputFilePath
,
pOutputFilePath
,
format
,
&
decoder
,
&
wav
);
if
(
result
!=
MA_SUCCESS
)
{
return
result
;
}
...
...
@@ -132,15 +83,10 @@ ma_result test_lpf2__f32(const char* pInputFilePath)
result
=
ma_lpf_init
(
&
lpfConfig
,
&
lpf
);
if
(
result
!=
MA_SUCCESS
)
{
ma_decoder_uninit
(
&
decoder
);
drwav_uninit
(
&
wav
);
return
result
;
}
wavFormat
=
drwav_data_format_from_minaudio_format
(
decoder
.
outputFormat
,
decoder
.
outputChannels
,
decoder
.
outputSampleRate
);
if
(
!
drwav_init_file_write
(
&
wav
,
pOutputFilePath
,
&
wavFormat
,
NULL
))
{
ma_decoder_uninit
(
&
decoder
);
return
MA_ERROR
;
}
for
(;;)
{
ma_uint8
tempIn
[
4096
];
ma_uint8
tempOut
[
4096
];
...
...
@@ -167,6 +113,17 @@ ma_result test_lpf2__f32(const char* pInputFilePath)
return
MA_SUCCESS
;
}
ma_result
test_lpf2__f32
(
const
char
*
pInputFilePath
)
{
return
test_lpf2__by_format
(
pInputFilePath
,
"output/lpf2_f32.wav"
,
ma_format_f32
);
}
ma_result
test_lpf2__s16
(
const
char
*
pInputFilePath
)
{
return
test_lpf2__by_format
(
pInputFilePath
,
"output/lpf2_s16.wav"
,
ma_format_s16
);
}
int
test_entry__lpf
(
int
argc
,
char
**
argv
)
{
ma_result
result
;
...
...
@@ -190,11 +147,18 @@ int test_entry__lpf(int argc, char** argv)
hasError
=
MA_TRUE
;
}
result
=
test_lpf2__f32
(
pInputFilePath
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
result
=
test_lpf2__s16
(
pInputFilePath
);
if
(
result
!=
MA_SUCCESS
)
{
hasError
=
MA_TRUE
;
}
if
(
hasError
)
{
return
-
1
;
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment