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
8fabcc44
Commit
8fabcc44
authored
Jan 18, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for passing in null for the input buffer to the resampler.
parent
6817dc84
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
17 deletions
+70
-17
research/ma_resampler.h
research/ma_resampler.h
+70
-17
No files found.
research/ma_resampler.h
View file @
8fabcc44
...
@@ -233,6 +233,17 @@ static ma_result ma_resampler_process__seek__linear_lpf(ma_resampler* pResampler
...
@@ -233,6 +233,17 @@ static ma_result ma_resampler_process__seek__linear_lpf(ma_resampler* pResampler
return
ma_resampler_process__seek__linear
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFrameCountOut
);
return
ma_resampler_process__seek__linear
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFrameCountOut
);
}
}
static
ma_result
ma_resampler_process__seek__linear_lpf
(
ma_resampler
*
pResampler
,
const
void
*
pFramesIn
,
ma_uint64
*
pFrameCountIn
,
ma_uint64
*
pFrameCountOut
)
{
/* TODO: Implement me. */
(
void
)
pResampler
;
(
void
)
pFramesIn
;
(
void
)
pFrameCountIn
;
(
void
)
pFrameCountOut
;
return
MA_INVALID_OPERATION
;
}
static
ma_result
ma_resampler_process__seek
(
ma_resampler
*
pResampler
,
const
void
*
pFramesIn
,
ma_uint64
*
pFrameCountIn
,
ma_uint64
*
pFrameCountOut
)
static
ma_result
ma_resampler_process__seek
(
ma_resampler
*
pResampler
,
const
void
*
pFramesIn
,
ma_uint64
*
pFrameCountIn
,
ma_uint64
*
pFrameCountOut
)
{
{
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pResampler
!=
NULL
);
...
@@ -249,6 +260,13 @@ static ma_result ma_resampler_process__seek(ma_resampler* pResampler, const void
...
@@ -249,6 +260,13 @@ static ma_result ma_resampler_process__seek(ma_resampler* pResampler, const void
return
ma_resampler_process__seek__linear_lpf
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFrameCountOut
);
return
ma_resampler_process__seek__linear_lpf
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFrameCountOut
);
}
break
;
}
break
;
case
ma_resample_algorithm_speex
:
{
#if defined(MA_HAS_SPEEX_RESAMPLER)
return
ma_resampler_process__seek__speex
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFrameCountOut
);
#endif
}
break
;
default:
return
MA_INVALID_ARGS
;
/* Should never hit this. */
default:
return
MA_INVALID_ARGS
;
/* Should never hit this. */
}
}
}
}
...
@@ -271,7 +289,6 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
...
@@ -271,7 +289,6 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFramesIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
frameCountOut
=
*
pFrameCountOut
;
frameCountOut
=
*
pFrameCountOut
;
...
@@ -294,9 +311,17 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
...
@@ -294,9 +311,17 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
if
(
frameCountIn
>
0
)
{
if
(
frameCountIn
>
0
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
if
(
pXF32
!=
NULL
)
{
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[
iChannel
];
}
else
{
}
else
{
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
0
;
}
}
else
{
if
(
pXS16
!=
NULL
)
{
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
0
;
}
}
}
}
}
iFrameIn
+=
1
;
iFrameIn
+=
1
;
...
@@ -320,13 +345,23 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
...
@@ -320,13 +345,23 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXF32
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pXF32
[(
iFrameIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pXF32
[(
iFrameIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
iFrameIn
-
0
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
iFrameIn
-
0
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
0
;
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
0
;
}
}
}
}
else
{
}
else
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXS16
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pXS16
[(
iFrameIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pXS16
[(
iFrameIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
iFrameIn
-
0
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
iFrameIn
-
0
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
0
;
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
0
;
}
}
}
}
}
...
@@ -338,25 +373,45 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
...
@@ -338,25 +373,45 @@ static ma_result ma_resampler_process__read__linear(ma_resampler* pResampler, co
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
if
(
pResampler
->
config
.
format
==
ma_format_f32
)
{
if
(
frameCountIn
>
1
)
{
if
(
frameCountIn
>
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXF32
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
2
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
2
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
0
;
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
0
;
}
}
}
}
else
{
}
else
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXF32
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
];
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
pXF32
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
f32
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
f32
[
iChannel
]
=
0
;
}
}
}
}
}
}
else
{
}
else
{
if
(
frameCountIn
>
1
)
{
if
(
frameCountIn
>
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXS16
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
2
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
2
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
0
;
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
0
;
}
}
}
}
else
{
}
else
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
for
(
iChannel
=
0
;
iChannel
<
pResampler
->
config
.
channels
;
iChannel
+=
1
)
{
if
(
pXS16
!=
NULL
)
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
];
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
pXS16
[(
frameCountIn
-
1
)
*
pResampler
->
config
.
channels
+
iChannel
];
}
else
{
pResampler
->
state
.
linear
.
x0
.
s16
[
iChannel
]
=
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
];
pResampler
->
state
.
linear
.
x1
.
s16
[
iChannel
]
=
0
;
}
}
}
}
}
}
}
...
@@ -398,7 +453,6 @@ static ma_result ma_resampler_process__read__linear_lpf(ma_resampler* pResampler
...
@@ -398,7 +453,6 @@ static ma_result ma_resampler_process__read__linear_lpf(ma_resampler* pResampler
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFramesIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
result
=
ma_resampler_process__read__linear
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFramesOut
,
pFrameCountOut
);
result
=
ma_resampler_process__read__linear
(
pResampler
,
pFramesIn
,
pFrameCountIn
,
pFramesOut
,
pFrameCountOut
);
...
@@ -427,7 +481,6 @@ static ma_result ma_resampler_process__read__speex(ma_resampler* pResampler, con
...
@@ -427,7 +481,6 @@ static ma_result ma_resampler_process__read__speex(ma_resampler* pResampler, con
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pResampler
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFramesOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFrameCountOut
!=
NULL
);
MA_ASSERT
(
pFramesIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
MA_ASSERT
(
pFrameCountIn
!=
NULL
);
/* Speex uses unsigned int counts, whereas miniaudio uses 64-bit. We'll need to process in a loop. */
/* Speex uses unsigned int counts, whereas miniaudio uses 64-bit. We'll need to process in a loop. */
...
...
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