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
ce6a81be
Commit
ce6a81be
authored
Nov 20, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use approximation for refining speed matches to improve performance.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
a24027ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
wmget.cc
src/wmget.cc
+15
-8
No files found.
src/wmget.cc
View file @
ce6a81be
...
@@ -1118,13 +1118,13 @@ private:
...
@@ -1118,13 +1118,13 @@ private:
};
};
SyncFinder
sync_finder
;
SyncFinder
sync_finder
;
vector
<
vector
<
Mags
>>
fft_sync_bits
;
vector
<
vector
<
Mags
>>
fft_sync_bits
;
void
prepare_mags
(
const
WavData
&
in_data
,
double
center
);
void
prepare_mags
(
const
WavData
&
in_data
,
double
center
,
double
seconds
);
Score
compare
(
double
relative_speed
,
double
center
);
Score
compare
(
double
relative_speed
,
double
center
);
public
:
public
:
Score
Score
search
(
const
WavData
&
in_data
,
double
center
,
double
step
,
int
n_steps
)
search
(
const
WavData
&
in_data
,
double
center
,
double
step
,
int
n_steps
,
double
seconds
)
{
{
prepare_mags
(
in_data
,
center
);
prepare_mags
(
in_data
,
center
,
seconds
);
Score
best_s
;
Score
best_s
;
for
(
int
p
=
-
n_steps
;
p
<=
n_steps
;
p
++
)
for
(
int
p
=
-
n_steps
;
p
<=
n_steps
;
p
++
)
...
@@ -1153,7 +1153,7 @@ speed_scan (const WavData& in_data)
...
@@ -1153,7 +1153,7 @@ speed_scan (const WavData& in_data)
double
c_speed
=
pow
(
step
,
c
*
(
n_steps
*
2
+
1
));
double
c_speed
=
pow
(
step
,
c
*
(
n_steps
*
2
+
1
));
SpeedSync
speed_sync
;
SpeedSync
speed_sync
;
SpeedSync
::
Score
s
=
speed_sync
.
search
(
in_data
,
c_speed
,
step
,
n_steps
);
SpeedSync
::
Score
s
=
speed_sync
.
search
(
in_data
,
c_speed
,
step
,
n_steps
,
/* seconds */
15
);
if
(
s
.
quality
>
best_s
.
quality
)
if
(
s
.
quality
>
best_s
.
quality
)
best_s
=
s
;
best_s
=
s
;
}
}
...
@@ -1175,8 +1175,15 @@ decode_and_report (const WavData& in_data, const string& orig_pattern)
...
@@ -1175,8 +1175,15 @@ decode_and_report (const WavData& in_data, const string& orig_pattern)
/* SLOW */
/* SLOW */
// speed = detect_speed (in_data, 1.0, 1.001, /* steps */ 200, /* seconds */ 15);
// speed = detect_speed (in_data, 1.0, 1.001, /* steps */ 200, /* seconds */ 15);
/* second pass: refine */
/* second pass: fast refine (not always perfect) */
speed
=
detect_speed
(
in_data
,
speed
,
1.00005
,
/* steps */
20
,
/* seconds */
50
);
SpeedSync
speed_sync
;
SpeedSync
::
Score
score
=
speed_sync
.
search
(
in_data
,
speed
,
1.00005
,
20
,
/* seconds */
50
);
speed
=
score
.
speed
;
printf
(
"## speed refined %f
\n
"
,
speed
);
printf
(
"## delta %.5f %%
\n
"
,
100
*
fabs
(
speed
-
Params
::
detect_speed_hint
)
/
Params
::
detect_speed_hint
);
/* SLOW */
// speed = detect_speed (in_data, speed, 1.00005, /* steps */ 20, /* seconds */ 50);
int
r
=
Params
::
mark_sample_rate
*
speed
;
int
r
=
Params
::
mark_sample_rate
*
speed
;
if
(
r
!=
Params
::
mark_sample_rate
)
if
(
r
!=
Params
::
mark_sample_rate
)
...
@@ -1249,9 +1256,9 @@ window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
...
@@ -1249,9 +1256,9 @@ window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
}
}
void
void
SpeedSync
::
prepare_mags
(
const
WavData
&
in_data
,
double
center
)
SpeedSync
::
prepare_mags
(
const
WavData
&
in_data
,
double
center
,
double
seconds
)
{
{
WavData
in_data_trc
(
truncate
(
in_data
,
15
));
WavData
in_data_trc
(
truncate
(
in_data
,
seconds
));
// FIXME: can crash if SR=22050
// FIXME: can crash if SR=22050
WavData
in_data_sub
(
resample
(
in_data_trc
,
Params
::
mark_sample_rate
/
2
*
center
));
WavData
in_data_sub
(
resample
(
in_data_trc
,
Params
::
mark_sample_rate
/
2
*
center
));
...
...
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