Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
4bb23ea9
Commit
4bb23ea9
authored
Feb 11, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use floats internally in limiter for performance reasons.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
138c6142
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
limiter.cc
src/limiter.cc
+6
-6
limiter.hh
src/limiter.hh
+6
-6
No files found.
src/limiter.cc
View file @
4bb23ea9
...
...
@@ -14,21 +14,21 @@ Limiter::Limiter (int n_channels, int sample_rate) :
}
void
Limiter
::
set_attack
(
double
attack_ms
)
Limiter
::
set_attack
(
float
attack_ms
)
{
look_ahead
=
sample_rate
/
1000.0
*
attack_ms
;
look_ahead
=
max
(
look_ahead
,
1u
);
}
void
Limiter
::
set_release
(
double
release_ms
)
Limiter
::
set_release
(
float
release_ms
)
{
release_factor
=
exp
(
log
(
0.5
)
/
(
sample_rate
/
1000.0
*
release_ms
));
release_factor
=
max
(
release_factor
,
0.5
);
release_factor
=
max
(
release_factor
,
0.5
f
);
}
void
Limiter
::
set_ceiling
(
double
new_ceiling
)
Limiter
::
set_ceiling
(
float
new_ceiling
)
{
ceiling
=
new_ceiling
;
maximum
=
ceiling
;
...
...
@@ -58,8 +58,8 @@ Limiter::process (const vector<float>& samples)
{
if
(
int
(
i
)
-
int
(
j
)
>=
0
)
{
double
alpha
=
double
(
j
)
/
look_ahead
;
max_buffer
[
i
-
j
]
=
max
<
float
>
(
max_buffer
[
i
-
j
],
channel_max
*
(
1
-
alpha
)
+
ceiling
*
alpha
);
float
alpha
=
float
(
j
)
/
look_ahead
;
max_buffer
[
i
-
j
]
=
max
(
max_buffer
[
i
-
j
],
channel_max
*
(
1
-
alpha
)
+
ceiling
*
alpha
);
}
}
}
...
...
src/limiter.hh
View file @
4bb23ea9
...
...
@@ -6,9 +6,9 @@
class
Limiter
{
double
ceiling
=
1
;
double
maximum
=
1
;
double
release_factor
=
0
;
float
ceiling
=
1
;
float
maximum
=
1
;
float
release_factor
=
0
;
uint
look_ahead
=
0
;
uint
n_channels
=
0
;
uint
sample_rate
=
0
;
...
...
@@ -18,9 +18,9 @@ class Limiter
public
:
Limiter
(
int
n_channels
,
int
sample_rate
);
void
set_release
(
double
value_ms
);
void
set_attack
(
double
value_ms
);
void
set_ceiling
(
double
ceiling
);
void
set_release
(
float
value_ms
);
void
set_attack
(
float
value_ms
);
void
set_ceiling
(
float
ceiling
);
std
::
vector
<
float
>
process
(
const
std
::
vector
<
float
>&
samples
);
};
...
...
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