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
479e441a
Commit
479e441a
authored
Feb 01, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use zita resampler instead of libsamplerate for performance reasons.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
12d2aac6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
21 deletions
+29
-21
configure.ac
configure.ac
+4
-6
audiowmark.cc
src/audiowmark.cc
+25
-15
No files found.
configure.ac
View file @
479e441a
...
@@ -18,13 +18,11 @@ AC_DEFUN([AC_SNDFILE_REQUIREMENTS],
...
@@ -18,13 +18,11 @@ AC_DEFUN([AC_SNDFILE_REQUIREMENTS],
])
])
dnl
dnl
dnl
samplerate
dnl
zita resampler
dnl
dnl
AC_DEFUN([AC_
SAMPLERATE
_REQUIREMENTS],
AC_DEFUN([AC_
ZITA
_REQUIREMENTS],
[
[
PKG_CHECK_MODULES(SAMPLERATE, [samplerate])
AC_CHECK_LIB(zita-resampler, _Z28zita_resampler_major_versionv)
AC_SUBST(SAMPLERATE_CFLAGS)
AC_SUBST(SAMPLERATE_LIBS)
])
])
dnl FFTW3
dnl FFTW3
...
@@ -55,7 +53,7 @@ AC_DEFUN([AC_FFTW_CHECK],
...
@@ -55,7 +53,7 @@ AC_DEFUN([AC_FFTW_CHECK],
])
])
AC_SNDFILE_REQUIREMENTS
AC_SNDFILE_REQUIREMENTS
AC_
SAMPLERATE
_REQUIREMENTS
AC_
ZITA
_REQUIREMENTS
AC_FFTW_CHECK
AC_FFTW_CHECK
AM_PATH_LIBGCRYPT
AM_PATH_LIBGCRYPT
...
...
src/audiowmark.cc
View file @
479e441a
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include "convcode.hh"
#include "convcode.hh"
#include "random.hh"
#include "random.hh"
#include
"samplerate.h"
#include
<zita-resampler/resampler.h>
#include <assert.h>
#include <assert.h>
...
@@ -507,22 +507,32 @@ resample (const WavData& wav_data, int rate)
...
@@ -507,22 +507,32 @@ resample (const WavData& wav_data, int rate)
if
(
rate
==
wav_data
.
sample_rate
())
if
(
rate
==
wav_data
.
sample_rate
())
return
wav_data
;
return
wav_data
;
double
ratio
=
double
(
rate
)
/
wav_data
.
sample_rate
();
Resampler
resampler
;
const
int
n_channels
=
wav_data
.
n_channels
();
const
int
hlen
=
16
;
const
double
ratio
=
double
(
rate
)
/
wav_data
.
sample_rate
();
const
vector
<
float
>&
in
=
wav_data
.
samples
();
const
vector
<
float
>&
in
=
wav_data
.
samples
();
vector
<
float
>
out
(
lrint
(
in
.
size
()
/
wav_data
.
n_channels
()
*
ratio
)
*
wav_data
.
n_channels
()
);
vector
<
float
>
out
(
lrint
(
in
.
size
()
/
n_channels
*
ratio
)
*
n_channels
);
SRC_DATA
data
;
resampler
.
setup
(
wav_data
.
sample_rate
(),
rate
,
n_channels
,
hlen
);
data
.
data_in
=
&
in
[
0
];
resampler
.
out_count
=
out
.
size
()
/
n_channels
;
data
.
data_out
=
&
out
[
0
];
resampler
.
out_data
=
&
out
[
0
];
data
.
input_frames
=
in
.
size
()
/
wav_data
.
n_channels
();
data
.
output_frames
=
out
.
size
()
/
wav_data
.
n_channels
();
/* avoid timeshift: zita needs k/2 - 1 samples before the actual input */
data
.
src_ratio
=
ratio
;
resampler
.
inp_count
=
resampler
.
inpsize
()
/
2
-
1
;
if
(
src_simple
(
&
data
,
SRC_SINC_MEDIUM_QUALITY
,
wav_data
.
n_channels
())
!=
0
)
resampler
.
inp_data
=
nullptr
;
{
resampler
.
process
();
fprintf
(
stderr
,
"audiowmark: resampling error occurred
\n
"
);
exit
(
1
);
resampler
.
inp_count
=
in
.
size
()
/
n_channels
;
}
resampler
.
inp_data
=
(
float
*
)
&
in
[
0
];
resampler
.
process
();
/* zita needs k/2 samples after the actual input */
resampler
.
inp_count
=
resampler
.
inpsize
()
/
2
;
resampler
.
inp_data
=
nullptr
;
resampler
.
process
();
return
WavData
(
out
,
wav_data
.
n_channels
(),
rate
,
wav_data
.
bit_depth
());
return
WavData
(
out
,
wav_data
.
n_channels
(),
rate
,
wav_data
.
bit_depth
());
}
}
...
...
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