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
54e7f74a
Commit
54e7f74a
authored
Dec 11, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups/renames for speed sync.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
fbb99e47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
33 deletions
+28
-33
TODO
src/TODO
+0
-2
wmspeed.cc
src/wmspeed.cc
+28
-31
No files found.
src/TODO
View file @
54e7f74a
speed detection:
- double decode
- propagate debug flag from "cmp" to speed detect
- rename methods => add_search_jobs()...
- cleanup resampler api
- maybe truncate cleanup
- SpeedSync should take struct arg
- remove pad start scaling
- average speed if more than one best-quality 50s estimate is produced
- test code
...
...
src/wmspeed.cc
View file @
54e7f74a
...
...
@@ -104,6 +104,14 @@ get_speed_clip (double location, const WavData& in_data, double clip_seconds)
return
clip_data
;
}
struct
SpeedScanParams
{
double
seconds
=
0
;
double
step
=
0
;
int
n_steps
=
0
;
int
n_center_steps
=
0
;
};
class
SpeedSync
{
public
:
...
...
@@ -113,7 +121,8 @@ public:
double
quality
=
0
;
};
private
:
struct
Mags
{
struct
Mags
{
float
umag
=
0
;
float
dmag
=
0
;
};
...
...
@@ -126,18 +135,14 @@ private:
std
::
mutex
mutex
;
vector
<
Score
>
result_scores
;
const
WavData
&
in_data
;
const
SpeedScanParams
scan_params
;
const
double
center
;
const
double
step
;
const
int
n_steps
;
const
double
seconds
;
const
int
frames_per_block
;
public
:
SpeedSync
(
const
WavData
&
in_data
,
double
center
,
double
step
,
int
n_steps
,
double
seconds
)
:
SpeedSync
(
const
WavData
&
in_data
,
const
SpeedScanParams
&
scan_params
,
double
center
)
:
in_data
(
in_data
),
scan_params
(
scan_params
),
center
(
center
),
step
(
step
),
n_steps
(
n_steps
),
seconds
(
seconds
),
frames_per_block
(
mark_sync_frame_count
()
+
mark_data_frame_count
())
{
// constructor is run in the main thread; everything that is not thread-safe must happen here
...
...
@@ -146,17 +151,17 @@ public:
sync_bits
=
sync_finder
.
get_sync_bits
(
in_data
,
SyncFinder
::
Mode
::
BLOCK
);
}
void
prepare_job
(
ThreadPool
&
thread_pool
)
start_
prepare_job
(
ThreadPool
&
thread_pool
)
{
thread_pool
.
add_job
([
this
]()
{
prepare_mags
();
});
}
void
s
earch
(
ThreadPool
&
thread_pool
)
s
tart_search_jobs
(
ThreadPool
&
thread_pool
)
{
for
(
int
p
=
-
n_steps
;
p
<=
n_steps
;
p
++
)
for
(
int
p
=
-
scan_params
.
n_steps
;
p
<=
scan_params
.
n_steps
;
p
++
)
{
const
double
relative_speed
=
pow
(
step
,
p
);
const
double
relative_speed
=
pow
(
s
can_params
.
s
tep
,
p
);
thread_pool
.
add_job
([
relative_speed
,
this
]()
{
compare
(
relative_speed
);
});
}
...
...
@@ -169,41 +174,31 @@ public:
}
};
struct
SpeedScanParams
{
double
seconds
=
0
;
double
step
=
0
;
int
n_steps
=
0
;
int
n_center_steps
=
0
;
};
static
double
speed_scan
(
ThreadPool
&
thread_pool
,
double
clip_location
,
const
WavData
&
in_data
,
const
SpeedScanParams
&
params
,
double
speed
)
speed_scan
(
ThreadPool
&
thread_pool
,
double
clip_location
,
const
WavData
&
in_data
,
const
SpeedScanParams
&
scan_
params
,
double
speed
)
{
/* 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
(
clip_location
,
in_data
,
params
.
seconds
*
1.3
);
/* n_center_steps / n_steps settings: speed approximately 0.8..1.25 */
WavData
in_clip
=
get_speed_clip
(
clip_location
,
in_data
,
scan_params
.
seconds
*
1.3
);
vector
<
std
::
unique_ptr
<
SpeedSync
>>
speed_sync
;
auto
t
=
get_time
();
for
(
int
c
=
-
params
.
n_center_steps
;
c
<=
params
.
n_center_steps
;
c
++
)
for
(
int
c
=
-
scan_params
.
n_center_steps
;
c
<=
scan_
params
.
n_center_steps
;
c
++
)
{
double
c_speed
=
speed
*
pow
(
params
.
step
,
c
*
(
params
.
n_steps
*
2
+
1
));
double
c_speed
=
speed
*
pow
(
scan_params
.
step
,
c
*
(
scan_
params
.
n_steps
*
2
+
1
));
speed_sync
.
push_back
(
std
::
make_unique
<
SpeedSync
>
(
in_clip
,
c_speed
,
params
.
step
,
params
.
n_steps
,
params
.
seconds
));
speed_sync
.
push_back
(
std
::
make_unique
<
SpeedSync
>
(
in_clip
,
scan_params
,
c_speed
));
}
for
(
auto
&
s
:
speed_sync
)
s
->
prepare_job
(
thread_pool
);
s
->
start_
prepare_job
(
thread_pool
);
thread_pool
.
wait_all
();
printf
(
"## wait prepare jobs: %f
\n
"
,
get_time
()
-
t
);
t
=
get_time
();
for
(
auto
&
s
:
speed_sync
)
s
->
search
(
thread_pool
);
s
->
add_search_jobs
(
thread_pool
);
thread_pool
.
wait_all
();
printf
(
"## wait search jobs: %f
\n
"
,
get_time
()
-
t
);
...
...
@@ -238,7 +233,7 @@ speed_scan (ThreadPool& thread_pool, double clip_location, const WavData& in_dat
best_speed
/=
speed_count
;
printf
(
"detect_speed_%.0f %f %f %f
\n
"
,
params
.
seconds
,
scan_
params
.
seconds
,
best_speed
,
best_quality
,
100
*
fabs
(
best_speed
-
Params
::
detect_speed_hint
)
/
Params
::
detect_speed_hint
);
...
...
@@ -258,7 +253,7 @@ window_hamming (double x) /* sharp (rectangle) cutoffs at boundaries */
void
SpeedSync
::
prepare_mags
()
{
WavData
in_data_trc
(
truncate
(
in_data
,
seconds
/
center
));
WavData
in_data_trc
(
truncate
(
in_data
,
s
can_params
.
s
econds
/
center
));
// we downsample the audio by factor 2 to improve performance
WavData
in_data_sub
(
resample_ratio
(
in_data_trc
,
center
/
2
,
Params
::
mark_sample_rate
/
2
));
...
...
@@ -438,6 +433,8 @@ detect_speed (const WavData& in_data)
ThreadPool
thread_pool
;
/* n_center_steps / n_steps settings: speed approximately 0.8..1.25 */
/* first pass: find approximation for speed */
const
SpeedScanParams
scan1
{
...
...
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