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
b6d05910
Commit
b6d05910
authored
Feb 23, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor restructuring.
parent
f1abfccb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
56 deletions
+58
-56
miniaudio.h
miniaudio.h
+58
-56
No files found.
miniaudio.h
View file @
b6d05910
...
...
@@ -1845,7 +1845,7 @@ ma_uint32 ma_bpf_get_latency(ma_bpf* pBPF);
/**************************************************************************************************************************************************************
Peaking EQ
Filter
Notching
Filter
**************************************************************************************************************************************************************/
typedef struct
...
...
@@ -1853,27 +1853,26 @@ typedef struct
ma_format format;
ma_uint32 channels;
ma_uint32 sampleRate;
double gainDB;
double q;
double frequency;
} ma_
peak
2_config;
} ma_
notch
2_config;
ma_
peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB
, double q, double frequency);
ma_
notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate
, double q, double frequency);
typedef struct
{
ma_biquad bq;
} ma_
peak
2;
} ma_
notch
2;
ma_result ma_
peak2_init(const ma_peak2_config* pConfig, ma_peak
2* pFilter);
ma_result ma_
peak2_reinit(const ma_peak2_config* pConfig, ma_peak
2* pFilter);
ma_result ma_
peak2_process_pcm_frames(ma_peak
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
ma_uint32 ma_
peak2_get_latency(ma_peak
2* pFilter);
ma_result ma_
notch2_init(const ma_notch2_config* pConfig, ma_notch
2* pFilter);
ma_result ma_
notch2_reinit(const ma_notch2_config* pConfig, ma_notch
2* pFilter);
ma_result ma_
notch2_process_pcm_frames(ma_notch
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
ma_uint32 ma_
notch2_get_latency(ma_notch
2* pFilter);
/**************************************************************************************************************************************************************
Notching
Filter
Peaking EQ
Filter
**************************************************************************************************************************************************************/
typedef struct
...
...
@@ -1881,21 +1880,22 @@ typedef struct
ma_format format;
ma_uint32 channels;
ma_uint32 sampleRate;
double gainDB;
double q;
double frequency;
} ma_
notch
2_config;
} ma_
peak
2_config;
ma_
notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate
, double q, double frequency);
ma_
peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB
, double q, double frequency);
typedef struct
{
ma_biquad bq;
} ma_
notch
2;
} ma_
peak
2;
ma_result ma_
notch2_init(const ma_notch2_config* pConfig, ma_notch
2* pFilter);
ma_result ma_
notch2_reinit(const ma_notch2_config* pConfig, ma_notch
2* pFilter);
ma_result ma_
notch2_process_pcm_frames(ma_notch
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
ma_uint32 ma_
notch2_get_latency(ma_notch
2* pFilter);
ma_result ma_
peak2_init(const ma_peak2_config* pConfig, ma_peak
2* pFilter);
ma_result ma_
peak2_reinit(const ma_peak2_config* pConfig, ma_peak
2* pFilter);
ma_result ma_
peak2_process_pcm_frames(ma_peak
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
ma_uint32 ma_
peak2_get_latency(ma_peak
2* pFilter);
...
...
@@ -30892,25 +30892,20 @@ ma_uint32 ma_bpf_get_latency(ma_bpf* pBPF)
/**************************************************************************************************************************************************************
Peaking EQ
Filter
Notching
Filter
**************************************************************************************************************************************************************/
ma_
peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB
, double q, double frequency)
ma_
notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate
, double q, double frequency)
{
ma_
peak
2_config config;
ma_
notch
2_config config;
MA_ZERO_OBJECT(&config);
config.format = format;
config.channels = channels;
config.sampleRate = sampleRate;
config.gainDB = gainDB;
config.q = q;
config.frequency = frequency;
if (config.gainDB == 0) {
config.gainDB = 6;
}
if (config.q == 0) {
config.q = 0.707107;
}
...
...
@@ -30919,7 +30914,7 @@ ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_ui
}
static MA_INLINE ma_biquad_config ma_
peak2__get_biquad_config(const ma_peak
2_config* pConfig)
static MA_INLINE ma_biquad_config ma_
notch2__get_biquad_config(const ma_notch
2_config* pConfig)
{
ma_biquad_config bqConfig;
double q;
...
...
@@ -30927,7 +30922,6 @@ static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_con
double s;
double c;
double a;
double A;
MA_ASSERT(pConfig != NULL);
...
...
@@ -30936,14 +30930,13 @@ static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_con
s = ma_sin(w);
c = ma_cos(w);
a = s / (2*q);
A = ma_pow(10, (pConfig->gainDB / 40));
bqConfig.b0 = 1
+ (a * A)
;
bqConfig.b0 = 1;
bqConfig.b1 = -2 * c;
bqConfig.b2 = 1
- (a * A)
;
bqConfig.a0 = 1 +
(a / A)
;
bqConfig.b2 = 1;
bqConfig.a0 = 1 +
a
;
bqConfig.a1 = -2 * c;
bqConfig.a2 = 1 -
(a / A)
;
bqConfig.a2 = 1 -
a
;
bqConfig.format = pConfig->format;
bqConfig.channels = pConfig->channels;
...
...
@@ -30951,7 +30944,7 @@ static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_con
return bqConfig;
}
ma_result ma_
peak2_init(const ma_peak2_config* pConfig, ma_peak
2* pFilter)
ma_result ma_
notch2_init(const ma_notch2_config* pConfig, ma_notch
2* pFilter)
{
ma_result result;
ma_biquad_config bqConfig;
...
...
@@ -30966,7 +30959,7 @@ ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter)
return MA_INVALID_ARGS;
}
bqConfig = ma_
peak
2__get_biquad_config(pConfig);
bqConfig = ma_
notch
2__get_biquad_config(pConfig);
result = ma_biquad_init(&bqConfig, &pFilter->bq);
if (result != MA_SUCCESS) {
return result;
...
...
@@ -30975,7 +30968,7 @@ ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter)
return MA_SUCCESS;
}
ma_result ma_
peak2_reinit(const ma_peak2_config* pConfig, ma_peak
2* pFilter)
ma_result ma_
notch2_reinit(const ma_notch2_config* pConfig, ma_notch
2* pFilter)
{
ma_result result;
ma_biquad_config bqConfig;
...
...
@@ -30984,7 +30977,7 @@ ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter)
return MA_INVALID_ARGS;
}
bqConfig = ma_
peak
2__get_biquad_config(pConfig);
bqConfig = ma_
notch
2__get_biquad_config(pConfig);
result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
if (result != MA_SUCCESS) {
return result;
...
...
@@ -30993,17 +30986,17 @@ ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter)
return MA_SUCCESS;
}
static MA_INLINE void ma_
peak2_process_pcm_frame_s16(ma_peak
2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
static MA_INLINE void ma_
notch2_process_pcm_frame_s16(ma_notch
2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
{
ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
}
static MA_INLINE void ma_
peak2_process_pcm_frame_f32(ma_peak
2* pFilter, float* pFrameOut, const float* pFrameIn)
static MA_INLINE void ma_
notch2_process_pcm_frame_f32(ma_notch
2* pFilter, float* pFrameOut, const float* pFrameIn)
{
ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
}
ma_result ma_
peak2_process_pcm_frames(ma_peak
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
ma_result ma_
notch2_process_pcm_frames(ma_notch
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
{
if (pFilter == NULL) {
return MA_INVALID_ARGS;
...
...
@@ -31012,7 +31005,7 @@ ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const
return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
}
ma_uint32 ma_
peak2_get_latency(ma_peak
2* pFilter)
ma_uint32 ma_
notch2_get_latency(ma_notch
2* pFilter)
{
if (pFilter == NULL) {
return 0;
...
...
@@ -31022,22 +31015,28 @@ ma_uint32 ma_peak2_get_latency(ma_peak2* pFilter)
}
/**************************************************************************************************************************************************************
Notching
Filter
Peaking EQ
Filter
**************************************************************************************************************************************************************/
ma_
notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate
, double q, double frequency)
ma_
peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB
, double q, double frequency)
{
ma_
notch
2_config config;
ma_
peak
2_config config;
MA_ZERO_OBJECT(&config);
config.format = format;
config.channels = channels;
config.sampleRate = sampleRate;
config.gainDB = gainDB;
config.q = q;
config.frequency = frequency;
if (config.gainDB == 0) {
config.gainDB = 6;
}
if (config.q == 0) {
config.q = 0.707107;
}
...
...
@@ -31046,7 +31045,7 @@ ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_
}
static MA_INLINE ma_biquad_config ma_
notch2__get_biquad_config(const ma_notch
2_config* pConfig)
static MA_INLINE ma_biquad_config ma_
peak2__get_biquad_config(const ma_peak
2_config* pConfig)
{
ma_biquad_config bqConfig;
double q;
...
...
@@ -31054,6 +31053,7 @@ static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_c
double s;
double c;
double a;
double A;
MA_ASSERT(pConfig != NULL);
...
...
@@ -31062,13 +31062,14 @@ static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_c
s = ma_sin(w);
c = ma_cos(w);
a = s / (2*q);
A = ma_pow(10, (pConfig->gainDB / 40));
bqConfig.b0 = 1;
bqConfig.b0 = 1
+ (a * A)
;
bqConfig.b1 = -2 * c;
bqConfig.b2 = 1;
bqConfig.a0 = 1 +
a
;
bqConfig.b2 = 1
- (a * A)
;
bqConfig.a0 = 1 +
(a / A)
;
bqConfig.a1 = -2 * c;
bqConfig.a2 = 1 -
a
;
bqConfig.a2 = 1 -
(a / A)
;
bqConfig.format = pConfig->format;
bqConfig.channels = pConfig->channels;
...
...
@@ -31076,7 +31077,7 @@ static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_c
return bqConfig;
}
ma_result ma_
notch2_init(const ma_notch2_config* pConfig, ma_notch
2* pFilter)
ma_result ma_
peak2_init(const ma_peak2_config* pConfig, ma_peak
2* pFilter)
{
ma_result result;
ma_biquad_config bqConfig;
...
...
@@ -31091,7 +31092,7 @@ ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter)
return MA_INVALID_ARGS;
}
bqConfig = ma_
notch
2__get_biquad_config(pConfig);
bqConfig = ma_
peak
2__get_biquad_config(pConfig);
result = ma_biquad_init(&bqConfig, &pFilter->bq);
if (result != MA_SUCCESS) {
return result;
...
...
@@ -31100,7 +31101,7 @@ ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter)
return MA_SUCCESS;
}
ma_result ma_
notch2_reinit(const ma_notch2_config* pConfig, ma_notch
2* pFilter)
ma_result ma_
peak2_reinit(const ma_peak2_config* pConfig, ma_peak
2* pFilter)
{
ma_result result;
ma_biquad_config bqConfig;
...
...
@@ -31109,7 +31110,7 @@ ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter)
return MA_INVALID_ARGS;
}
bqConfig = ma_
notch
2__get_biquad_config(pConfig);
bqConfig = ma_
peak
2__get_biquad_config(pConfig);
result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
if (result != MA_SUCCESS) {
return result;
...
...
@@ -31118,17 +31119,17 @@ ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter)
return MA_SUCCESS;
}
static MA_INLINE void ma_
notch2_process_pcm_frame_s16(ma_notch
2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
static MA_INLINE void ma_
peak2_process_pcm_frame_s16(ma_peak
2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
{
ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
}
static MA_INLINE void ma_
notch2_process_pcm_frame_f32(ma_notch
2* pFilter, float* pFrameOut, const float* pFrameIn)
static MA_INLINE void ma_
peak2_process_pcm_frame_f32(ma_peak
2* pFilter, float* pFrameOut, const float* pFrameIn)
{
ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
}
ma_result ma_
notch2_process_pcm_frames(ma_notch
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
ma_result ma_
peak2_process_pcm_frames(ma_peak
2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
{
if (pFilter == NULL) {
return MA_INVALID_ARGS;
...
...
@@ -31137,7 +31138,7 @@ ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, con
return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
}
ma_uint32 ma_
notch2_get_latency(ma_notch
2* pFilter)
ma_uint32 ma_
peak2_get_latency(ma_peak
2* pFilter)
{
if (pFilter == NULL) {
return 0;
...
...
@@ -31148,6 +31149,7 @@ ma_uint32 ma_notch2_get_latency(ma_notch2* pFilter)
/**************************************************************************************************************************************************************
Resampling
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