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
4a3e34aa
Commit
4a3e34aa
authored
Jan 30, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make detection sample rate constant: 44100, resample if necessary.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
b2ac0e2f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
Makefile.am
src/Makefile.am
+1
-1
audiowmark.cc
src/audiowmark.cc
+32
-1
No files found.
src/Makefile.am
View file @
4a3e34aa
...
...
@@ -3,7 +3,7 @@ bin_PROGRAMS = audiowmark
COMMON_SRC
=
utils.hh utils.cc convcode.hh convcode.cc random.hh random.cc
audiowmark_SOURCES
=
audiowmark.cc wavdata.cc wavdata.hh fft.cc fft.hh
$(COMMON_SRC)
audiowmark_LDFLAGS
=
$(SNDFILE_LIBS)
$(FFTW_LIBS)
$(LIBGCRYPT_LIBS)
audiowmark_LDFLAGS
=
$(SNDFILE_LIBS)
$(
SAMPLERATE_LIBS)
$(
FFTW_LIBS)
$(LIBGCRYPT_LIBS)
noinst_PROGRAMS
=
testconvcode testrandom
...
...
src/audiowmark.cc
View file @
4a3e34aa
...
...
@@ -11,6 +11,8 @@
#include "convcode.hh"
#include "random.hh"
#include "samplerate.h"
#include <assert.h>
#include "config.h"
...
...
@@ -42,6 +44,7 @@ namespace Params
static
double
sync_threshold2
=
0.7
;
// minimum refined quality
static
size_t
frames_pad_start
=
250
;
// padding at start, in case track starts with silence
static
int
mark_sample_rate
=
44100
;
// watermark generation and detection sample rate
static
int
test_cut
=
0
;
// for sync test
}
...
...
@@ -1073,7 +1076,35 @@ get_watermark (const string& infile, const string& orig_pattern)
fprintf
(
stderr
,
"audiowmark: error loading %s: %s
\n
"
,
infile
.
c_str
(),
wav_data
.
error_blurb
());
return
1
;
}
if
(
fabs
(
wav_data
.
mix_freq
()
-
Params
::
mark_sample_rate
)
>
0.1
)
{
printf
(
"sample rate: %f -> autoconvert
\n
"
,
wav_data
.
mix_freq
());
double
ratio
=
double
(
Params
::
mark_sample_rate
)
/
wav_data
.
mix_freq
();
const
vector
<
float
>&
in
=
wav_data
.
samples
();
vector
<
float
>
out
(
lrint
(
in
.
size
()
/
wav_data
.
n_channels
()
*
ratio
)
*
wav_data
.
n_channels
());
SRC_DATA
data
;
data
.
data_in
=
&
in
[
0
];
data
.
data_out
=
&
out
[
0
];
data
.
input_frames
=
in
.
size
()
/
wav_data
.
n_channels
();
data
.
output_frames
=
out
.
size
()
/
wav_data
.
n_channels
();
data
.
src_ratio
=
ratio
;
if
(
src_simple
(
&
data
,
SRC_SINC_MEDIUM_QUALITY
,
wav_data
.
n_channels
())
!=
0
)
{
fprintf
(
stderr
,
"audiowmark: resampling error occurred
\n
"
);
return
1
;
}
WavData
resampled_data
(
out
,
wav_data
.
n_channels
(),
Params
::
mark_sample_rate
,
wav_data
.
bit_depth
());
return
decode_and_report
(
resampled_data
,
orig_pattern
);
}
else
{
return
decode_and_report
(
wav_data
,
orig_pattern
);
}
}
int
...
...
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