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
7b27cda7
Commit
7b27cda7
authored
Jan 18, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for s16 format to biquad and low-pass filters.
parent
705e54c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
23 deletions
+21
-23
research/ma_lpf.h
research/ma_lpf.h
+21
-23
No files found.
research/ma_lpf.h
View file @
7b27cda7
...
...
@@ -18,29 +18,6 @@ typedef struct
double
b0
;
double
b1
;
double
b2
;
#if 0
union
{
struct
{
double a0;
double a1;
double a2;
double b0;
double b1;
double b2;
} f32;
struct
{
ma_int32 a0;
ma_int32 a1;
ma_int32 a2;
ma_int32 b0;
ma_int32 b1;
ma_int32 b2;
} s16;
} constants;
#endif
}
ma_biquad_config
;
ma_biquad_config
ma_biquad_config_init
(
ma_format
format
,
ma_uint32
channels
,
double
a0
,
double
a1
,
double
a2
,
double
b0
,
double
b1
,
double
b2
);
...
...
@@ -187,7 +164,28 @@ ma_result ma_biquad_process(ma_biquad* pBQ, void* pFramesOut, const void* pFrame
pBQ
->
y1
[
c
]
=
(
float
)
y0
;
}
}
}
else
if
(
pBQ
->
config
.
format
==
ma_format_s16
)
{
/* */
ma_int16
*
pY
=
(
ma_int16
*
)
pFramesOut
;
const
ma_int16
*
pX
=
(
const
ma_int16
*
)
pFramesIn
;
for
(
n
=
0
;
n
<
frameCount
;
n
+=
1
)
{
for
(
c
=
0
;
c
<
pBQ
->
config
.
channels
;
c
+=
1
)
{
double
x2
=
pBQ
->
x2
[
c
];
double
x1
=
pBQ
->
x1
[
c
];
double
x0
=
pX
[
n
*
pBQ
->
config
.
channels
+
c
]
*
0
.
00003051757
8125
;
/* s16 -> f32 */
double
y2
=
pBQ
->
y2
[
c
];
double
y1
=
pBQ
->
y1
[
c
];
double
y0
=
b0
*
x0
+
b1
*
x1
+
b2
*
x2
-
a1
*
y1
-
a2
*
y2
;
pY
[
n
*
pBQ
->
config
.
channels
+
c
]
=
(
ma_int16
)(
y0
*
32767
.
0
);
/* f32 -> s16 */
pBQ
->
x2
[
c
]
=
(
float
)
x1
;
pBQ
->
x1
[
c
]
=
(
float
)
x0
;
pBQ
->
y2
[
c
]
=
(
float
)
y1
;
pBQ
->
y1
[
c
]
=
(
float
)
y0
;
}
}
}
else
{
MA_ASSERT
(
MA_FALSE
);
return
MA_INVALID_ARGS
;
/* Format not supported. Should never hit this because it's checked in ma_biquad_init(). */
}
...
...
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