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
cf4c077d
Commit
cf4c077d
authored
Nov 30, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Randomize short/long clip location for speed detection.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
1f9c81b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
wmspeed.cc
src/wmspeed.cc
+15
-6
No files found.
src/wmspeed.cc
View file @
cf4c077d
...
...
@@ -366,8 +366,8 @@ SpeedSync::compare (double relative_speed, double center)
return
best_score
;
}
WavData
get_
speed_clip
(
const
WavData
&
in_data
,
double
clip_seconds
)
static
double
get_
clip_location
(
const
WavData
&
in_data
)
{
Random
rng
(
0
,
Random
::
Stream
::
speed_clip
);
...
...
@@ -379,8 +379,14 @@ get_speed_clip (const WavData& in_data, double clip_seconds)
rng
.
seed
(
Random
::
seed_from_hash
(
xsamples
),
Random
::
Stream
::
speed_clip
);
return
rng
.
random_double
();
}
static
WavData
get_speed_clip
(
double
location
,
const
WavData
&
in_data
,
double
clip_seconds
)
{
double
end_sec
=
double
(
in_data
.
n_frames
())
/
in_data
.
sample_rate
();
double
start_sec
=
(
double
(
rng
())
/
UINT64_MAX
)
*
(
end_sec
-
clip_seconds
);
double
start_sec
=
location
*
(
end_sec
-
clip_seconds
);
if
(
start_sec
<
0
)
start_sec
=
0
;
...
...
@@ -413,15 +419,18 @@ detect_speed (const WavData& in_data)
}
else
/* better performance, less accurate */
{
double
clip_location
=
get_clip_location
(
in_data
);
/* speed is between 0.8 and 1.25, so we use a clip seconds factor of 1.3 to provide enough samples */
WavData
in_clip
=
get_speed_clip
(
in_data
,
21
*
1.3
);
WavData
in_clip_short
=
get_speed_clip
(
clip_location
,
in_data
,
21
*
1.3
);
WavData
in_clip_long
=
get_speed_clip
(
clip_location
,
in_data
,
50
*
1.3
);
/* first pass: find approximation for speed */
speed
=
speed_scan
(
in_clip
);
speed
=
speed_scan
(
in_clip
_short
);
/* second pass: fast refine (not always perfect) */
SpeedSync
speed_sync
;
auto
scores
=
speed_sync
.
search
(
in_
data
,
speed
,
1.00005
,
20
,
/* seconds */
50
);
auto
scores
=
speed_sync
.
search
(
in_
clip_long
,
speed
,
1.00005
,
20
,
/* seconds */
50
);
sort
(
scores
.
begin
(),
scores
.
end
(),
[]
(
SpeedSync
::
Score
s_a
,
SpeedSync
::
Score
s_b
)
{
return
s_a
.
quality
>
s_b
.
quality
;
});
if
(
!
scores
.
empty
())
speed
=
scores
[
0
].
speed
;
...
...
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