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
8491aa91
Commit
8491aa91
authored
Feb 07, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support setting ceiling for Limiter.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
550067e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
limiter.cc
src/limiter.cc
+11
-4
limiter.hh
src/limiter.hh
+2
-0
No files found.
src/limiter.cc
View file @
8491aa91
...
...
@@ -26,6 +26,13 @@ Limiter::set_release (double release_ms)
release_factor
=
max
(
release_factor
,
0.5
);
}
void
Limiter
::
set_ceiling
(
double
new_ceiling
)
{
ceiling
=
new_ceiling
;
maximum
=
ceiling
;
}
vector
<
float
>
Limiter
::
process
(
const
vector
<
float
>&
samples
)
{
...
...
@@ -35,18 +42,18 @@ Limiter::process (const vector<float>& samples)
for
(
size_t
i
=
0
;
i
<
samples
.
size
();
i
++
)
{
buffer
.
push_back
(
samples
[
i
]);
max_buffer
.
push_back
(
1
);
max_buffer
.
push_back
(
ceiling
);
}
for
(
size_t
i
=
0
;
i
<
buffer
.
size
();
i
++
)
{
if
(
fabs
(
buffer
[
i
])
>
1
)
if
(
fabs
(
buffer
[
i
])
>
ceiling
)
{
for
(
uint
j
=
0
;
j
<
look_ahead
;
j
++
)
{
if
(
int
(
i
)
-
int
(
j
)
>=
0
)
{
double
alpha
=
double
(
j
)
/
look_ahead
;
max_buffer
[
i
-
j
]
=
max
<
float
>
(
max_buffer
[
i
-
j
],
fabs
(
buffer
[
i
])
*
(
1
-
alpha
)
+
1
*
alpha
);
max_buffer
[
i
-
j
]
=
max
<
float
>
(
max_buffer
[
i
-
j
],
fabs
(
buffer
[
i
])
*
(
1
-
alpha
)
+
ceiling
*
alpha
);
}
}
}
...
...
@@ -62,7 +69,7 @@ Limiter::process (const vector<float>& samples)
if
(
maximum
<
max_buffer
[
i
])
maximum
=
max_buffer
[
i
];
out
.
push_back
(
buffer
[
i
]
/
maximum
);
out
.
push_back
(
buffer
[
i
]
/
maximum
*
ceiling
);
//printf ("%f %f\n", buffer[i], out.back());
}
...
...
src/limiter.hh
View file @
8491aa91
...
...
@@ -6,6 +6,7 @@
class
Limiter
{
double
ceiling
=
1
;
double
maximum
=
1
;
double
release_factor
=
0
;
uint
look_ahead
=
0
;
...
...
@@ -18,6 +19,7 @@ public:
void
set_release
(
double
value_ms
);
void
set_attack
(
double
value_ms
);
void
set_ceiling
(
double
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