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
31ed83f5
Commit
31ed83f5
authored
May 14, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement skip() function for Limiter.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
c78e8094
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
limiter.cc
src/limiter.cc
+22
-0
limiter.hh
src/limiter.hh
+1
-0
wmadd.cc
src/wmadd.cc
+4
-5
No files found.
src/limiter.cc
View file @
31ed83f5
...
...
@@ -66,6 +66,28 @@ Limiter::process (const vector<float>& samples)
return
out
;
}
size_t
Limiter
::
skip
(
size_t
zeros
)
{
vector
<
float
>
samples
(
zeros
*
n_channels
);
assert
(
block_size
>=
1
);
assert
(
samples
.
size
()
%
n_channels
==
0
);
// process should be called with whole frames
buffer
.
insert
(
buffer
.
end
(),
samples
.
begin
(),
samples
.
end
());
/* need at least two complete blocks in buffer to produce output */
const
uint
buffered_blocks
=
buffer
.
size
()
/
n_channels
/
block_size
;
if
(
buffered_blocks
<
2
)
return
0
;
const
uint
blocks_todo
=
buffered_blocks
-
1
;
buffer
.
erase
(
buffer
.
begin
(),
buffer
.
begin
()
+
blocks_todo
*
block_size
*
n_channels
);
return
blocks_todo
*
block_size
;
}
float
Limiter
::
block_max
(
const
float
*
in
)
{
...
...
src/limiter.hh
View file @
31ed83f5
...
...
@@ -42,6 +42,7 @@ public:
void
set_ceiling
(
float
ceiling
);
std
::
vector
<
float
>
process
(
const
std
::
vector
<
float
>&
samples
);
size_t
skip
(
size_t
zeros
);
std
::
vector
<
float
>
flush
();
};
...
...
src/wmadd.cc
View file @
31ed83f5
...
...
@@ -670,13 +670,12 @@ add_stream_watermark (AudioInputStream *in_stream, AudioOutputStream *out_stream
{
total_input_frames
+=
Params
::
frame_size
;
audio_buffer_frames
+=
Params
::
frame_size
;
samples
.
assign
(
wm_resampler
.
skip
(
Params
::
frame_size
)
*
n_channels
,
0
);
size_t
to_read
=
samples
.
size
()
/
n_channels
;
audio_buffer_frames
-=
to_read
;
size_t
frames
=
wm_resampler
.
skip
(
Params
::
frame_size
);
audio_buffer_frames
-=
frames
;
samples
=
limiter
.
process
(
sampl
es
);
frames
=
limiter
.
skip
(
fram
es
);
err
=
out_stream
->
write_frames
(
samples
);
err
=
out_stream
->
write_frames
(
vector
<
float
>
(
frames
*
n_channels
)
);
total_output_frames
+=
samples
.
size
()
/
n_channels
;
zero_frames
-=
Params
::
frame_size
;
...
...
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