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
ed7e78fe
Commit
ed7e78fe
authored
Dec 13, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move speed detection ratio resample function to resample.cc/hh.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
6704c6e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
43 deletions
+20
-43
TODO
src/TODO
+0
-1
resample.cc
src/resample.cc
+18
-0
resample.hh
src/resample.hh
+1
-0
wmspeed.cc
src/wmspeed.cc
+1
-42
No files found.
src/TODO
View file @
ed7e78fe
speed detection:
- double decode
- cleanup resampler api
- maybe truncate cleanup
- remove pad start scaling
- average speed if more than one best-quality 50s estimate is produced
...
...
src/resample.cc
View file @
ed7e78fe
...
...
@@ -89,4 +89,22 @@ resample (const WavData& wav_data, int rate)
exit
(
1
);
}
WavData
resample_ratio
(
const
WavData
&
wav_data
,
double
ratio
,
int
new_rate
)
{
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
(),
new_rate
,
wav_data
.
bit_depth
());
}
src/resample.hh
View file @
ed7e78fe
...
...
@@ -21,5 +21,6 @@
#include "wavdata.hh"
WavData
resample
(
const
WavData
&
wav_data
,
int
rate
);
WavData
resample_ratio
(
const
WavData
&
wav_data
,
double
ratio
,
int
new_rate
);
#endif
/* AUDIOWMARK_RESAMPLE_HH */
src/wmspeed.cc
View file @
ed7e78fe
...
...
@@ -20,55 +20,14 @@
#include "syncfinder.hh"
#include "threadpool.hh"
#include "fft.hh"
#include "resample.hh"
#include <algorithm>
#include <zita-resampler/vresampler.h>
using
std
::
vector
;
using
std
::
sort
;
using
std
::
max
;
/* FIXME: dedup this template */
template
<
class
R
>
static
void
process_resampler
(
R
&
resampler
,
const
vector
<
float
>&
in
,
vector
<
float
>&
out
)
{
resampler
.
out_count
=
out
.
size
()
/
resampler
.
nchan
();
resampler
.
out_data
=
&
out
[
0
];
/* avoid timeshift: zita needs k/2 - 1 samples before the actual input */
resampler
.
inp_count
=
resampler
.
inpsize
()
/
2
-
1
;
resampler
.
inp_data
=
nullptr
;
resampler
.
process
();
resampler
.
inp_count
=
in
.
size
()
/
resampler
.
nchan
();
resampler
.
inp_data
=
(
float
*
)
&
in
[
0
];
resampler
.
process
();
/* zita needs k/2 samples after the actual input */
resampler
.
inp_count
=
resampler
.
inpsize
()
/
2
;
resampler
.
inp_data
=
nullptr
;
resampler
.
process
();
}
static
WavData
resample_ratio
(
const
WavData
&
wav_data
,
double
ratio
,
int
new_rate
)
{
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
(),
new_rate
,
wav_data
.
bit_depth
());
}
static
WavData
truncate
(
const
WavData
&
in_data
,
double
seconds
)
{
...
...
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