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
d5647e36
Commit
d5647e36
authored
Oct 20, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make speed detect faster by truncating before resampling.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
77d011e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
wmget.cc
src/wmget.cc
+26
-11
No files found.
src/wmget.cc
View file @
d5647e36
...
...
@@ -1031,28 +1031,43 @@ public:
}
};
static
WavData
truncate
(
const
WavData
&
in_data
,
int
seconds
)
{
WavData
out_data
=
in_data
;
vector
<
float
>
short_samples
=
in_data
.
samples
();
const
size_t
want_n_samples
=
in_data
.
sample_rate
()
*
in_data
.
n_channels
()
*
seconds
;
if
(
short_samples
.
size
()
>
want_n_samples
)
{
short_samples
.
resize
(
want_n_samples
);
out_data
.
set_samples
(
short_samples
);
}
return
out_data
;
}
static
float
detect_speed
(
const
WavData
&
wav_data
)
{
for
(
int
p
=
-
20
0
;
p
<=
20
0
;
p
++
)
for
(
int
p
=
-
20
;
p
<=
2
0
;
p
++
)
{
double
speed
=
pow
(
1.001
,
p
);
WavData
wd_resampled
=
wav_data
;
WavData
wd_resampled
=
truncate
(
wav_data
,
20
);
if
(
p
!=
0
)
wd_resampled
=
resample
(
w
av_data
,
Params
::
mark_sample_rate
*
speed
);
wd_resampled
=
resample
(
w
d_resampled
,
Params
::
mark_sample_rate
*
speed
);
vector
<
float
>
short_samples
=
wd_resampled
.
samples
(
);
wd_resampled
=
truncate
(
wd_resampled
,
15
);
const
size_t
want_n_samples
=
wd_resampled
.
sample_rate
()
*
wd_resampled
.
n_channels
()
*
15
;
if
(
short_samples
.
size
()
>
want_n_samples
)
{
short_samples
.
resize
(
want_n_samples
);
wd_resampled
.
set_samples
(
short_samples
);
}
ResultSet
result_set
;
ClipDecoder
clip_decoder
;
clip_decoder
.
run
(
wd_resampled
,
result_set
);
printf
(
"%f %f
\n
"
,
speed
,
result_set
.
best_quality
());
printf
(
"%f %f "
,
speed
,
result_set
.
best_quality
());
if
(
result_set
.
best_quality
()
>
0
)
printf
(
"
\n
"
);
else
printf
(
"
\r
"
);
fflush
(
stdout
);
}
return
1.0
;
}
...
...
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