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
384cbed4
Commit
384cbed4
authored
Nov 23, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup ratio based resampling for speed sync.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
f16e2d34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
wmget.cc
src/wmget.cc
+21
-7
No files found.
src/wmget.cc
View file @
384cbed4
...
@@ -97,6 +97,24 @@ resample (const WavData& wav_data, int rate)
...
@@ -97,6 +97,24 @@ resample (const WavData& wav_data, int rate)
exit
(
1
);
exit
(
1
);
}
}
static
WavData
resample_ratio
(
const
WavData
&
wav_data
,
double
ratio
)
{
const
int
hlen
=
16
;
const
vector
<
float
>&
in
=
wav_data
.
samples
();
vector
<
float
>
out
(
lrint
(
in
.
size
()
/
wav_data
.
n_channels
()
*
ratio
)
*
wav_data
.
n_channels
());
VResampler
vresampler
;
if
(
vresampler
.
setup
(
ratio
,
wav_data
.
n_channels
(),
hlen
)
!=
0
)
{
error
(
"audiowmark: failed to setup vresampler with ratio=%f
\n
"
,
ratio
);
exit
(
1
);
}
process_resampler
(
vresampler
,
in
,
out
);
return
WavData
(
out
,
wav_data
.
n_channels
(),
wav_data
.
sample_rate
()
*
ratio
,
wav_data
.
bit_depth
());
}
static
int
static
int
frame_count
(
const
WavData
&
wav_data
)
frame_count
(
const
WavData
&
wav_data
)
{
{
...
@@ -1078,11 +1096,7 @@ detect_speed (const WavData& wav_data, double center, double step, int n_steps,
...
@@ -1078,11 +1096,7 @@ detect_speed (const WavData& wav_data, double center, double step, int n_steps,
double
speed
=
center
*
pow
(
step
,
p
);
double
speed
=
center
*
pow
(
step
,
p
);
WavData
wd_resampled
=
wd_truncated
;
WavData
wd_resampled
=
resample_ratio
(
wd_truncated
,
speed
);
const
int
dest_rate
=
lrint
(
Params
::
mark_sample_rate
*
speed
);
if
(
wd_resampled
.
sample_rate
()
!=
dest_rate
)
wd_resampled
=
resample
(
wd_resampled
,
dest_rate
);
wd_resampled
=
truncate
(
wd_resampled
,
seconds
);
wd_resampled
=
truncate
(
wd_resampled
,
seconds
);
ResultSet
result_set
;
ResultSet
result_set
;
...
@@ -1285,10 +1299,10 @@ void
...
@@ -1285,10 +1299,10 @@ void
SpeedSync
::
prepare_mags
(
const
WavData
&
in_data
,
double
center
,
double
seconds
)
SpeedSync
::
prepare_mags
(
const
WavData
&
in_data
,
double
center
,
double
seconds
)
{
{
WavData
in_data_trc
(
truncate
(
in_data
,
seconds
/
center
));
WavData
in_data_trc
(
truncate
(
in_data
,
seconds
/
center
));
// FIXME: can crash if SR=22050
WavData
in_data_sub
(
resample
(
in_data_trc
,
Params
::
mark_sample_rate
/
2
*
center
));
// we downsample the audio by factor 2 to improve performance
// we downsample the audio by factor 2 to improve performance
WavData
in_data_sub
(
resample_ratio
(
in_data_trc
,
center
/
2
));
const
int
sub_frame_size
=
Params
::
frame_size
/
2
;
const
int
sub_frame_size
=
Params
::
frame_size
/
2
;
const
int
sub_sync_search_step
=
Params
::
sync_search_step
/
2
;
const
int
sub_sync_search_step
=
Params
::
sync_search_step
/
2
;
...
...
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