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
666f39c9
Commit
666f39c9
authored
Dec 10, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial work on a basic test program for the resampler.
This test will be replaced later with something better.
parent
c8ba70cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
3 deletions
+63
-3
research/tests/mal_resampler_test_0.c
research/tests/mal_resampler_test_0.c
+63
-3
No files found.
research/tests/mal_resampler_test_0.c
View file @
666f39c9
#define DR_WAV_IMPLEMENTATION
#include "../../../../dr_libs/dr_wav.h"
#define MAL_DEBUG_OUTPUT
#define MAL_DEBUG_OUTPUT
#define MINI_AL_IMPLEMENTATION
#define MINI_AL_IMPLEMENTATION
#include "../../mini_al.h"
#include "../../mini_al.h"
#include "../mal_resampler.h"
#include "../mal_resampler.h"
#define SAMPLE_RATE_IN 44100
#define SAMPLE_RATE_OUT 44100
#define CHANNELS 1
#define OUTPUT_FILE "output.wav"
mal_sine_wave
sineWave
;
mal_uint32
on_read
(
mal_resampler
*
pResampler
,
mal_uint32
frameCount
,
void
**
ppFramesOut
)
{
mal_assert
(
pResampler
->
config
.
format
==
mal_format_f32
);
return
(
mal_uint32
)
mal_sine_wave_read_ex
(
&
sineWave
,
frameCount
,
pResampler
->
config
.
channels
,
pResampler
->
config
.
layout
,
(
float
**
)
ppFramesOut
);
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
(
void
)
argc
;
mal_result
result
;
(
void
)
argv
;
mal_resampler_config
resamplerConfig
;
mal_resampler
resampler
;
mal_zero_object
(
&
resamplerConfig
);
resamplerConfig
.
format
=
mal_format_f32
;
resamplerConfig
.
channels
=
CHANNELS
;
resamplerConfig
.
sampleRateIn
=
SAMPLE_RATE_IN
;
resamplerConfig
.
sampleRateOut
=
SAMPLE_RATE_OUT
;
resamplerConfig
.
algorithm
=
mal_resampler_algorithm_linear
;
resamplerConfig
.
endOfInputMode
=
mal_resampler_end_of_input_mode_consume
;
resamplerConfig
.
layout
=
mal_stream_layout_interleaved
;
resamplerConfig
.
onRead
=
on_read
;
resamplerConfig
.
pUserData
=
NULL
;
result
=
mal_resampler_init
(
&
resamplerConfig
,
&
resampler
);
if
(
result
!=
MAL_SUCCESS
)
{
printf
(
"Failed to initialize resampler.
\n
"
);
return
-
1
;
}
mal_sine_wave_init
(
0
.
5
,
400
,
resamplerConfig
.
sampleRateIn
,
&
sineWave
);
// Write to a WAV file. We'll do about 10 seconds worth, making sure we read in chunks to make sure everything is seamless.
drwav_data_format
format
;
format
.
container
=
drwav_container_riff
;
format
.
format
=
DR_WAVE_FORMAT_IEEE_FLOAT
;
format
.
channels
=
resampler
.
config
.
channels
;
format
.
sampleRate
=
resampler
.
config
.
sampleRateOut
;
format
.
bitsPerSample
=
32
;
drwav
*
pWavWriter
=
drwav_open_file_write
(
OUTPUT_FILE
,
&
format
);
float
buffer
[
SAMPLE_RATE_IN
*
CHANNELS
];
float
*
pBuffer
=
buffer
;
mal_uint32
iterations
=
10
;
mal_uint32
framesToReadPerIteration
=
mal_countof
(
buffer
)
/
CHANNELS
;
for
(
mal_uint32
i
=
0
;
i
<
iterations
;
++
i
)
{
mal_uint32
framesRead
=
(
mal_uint32
)
mal_resampler_read
(
&
resampler
,
framesToReadPerIteration
,
&
pBuffer
);
drwav_write
(
pWavWriter
,
framesRead
*
CHANNELS
,
buffer
);
}
//float** test = &buffer;
drwav_close
(
pWavWriter
);
(
void
)
argc
;
(
void
)
argv
;
return
0
;
return
0
;
}
}
\ No newline at end of file
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