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
d2ab035f
Commit
d2ab035f
authored
May 30, 2022
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add audiowmark helper commands for make check.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
ebabcd3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
TODO
src/TODO
+0
-1
audiowmark.cc
src/audiowmark.cc
+56
-0
No files found.
src/TODO
View file @
d2ab035f
release todo:
release todo:
- provide better diagnostics for command line options
- provide better diagnostics for command line options
- merge infinite wav header generator
- merge infinite wav header generator
- make check
speed detection possible improvements:
speed detection possible improvements:
- would n-best search make detect-speed-patient better?
- would n-best search make detect-speed-patient better?
...
...
src/audiowmark.cc
View file @
d2ab035f
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include "wmcommon.hh"
#include "wmcommon.hh"
#include "shortcode.hh"
#include "shortcode.hh"
#include "hls.hh"
#include "hls.hh"
#include "resample.hh"
#include <assert.h>
#include <assert.h>
...
@@ -332,6 +333,47 @@ test_speed (int seed)
...
@@ -332,6 +333,47 @@ test_speed (int seed)
return
0
;
return
0
;
}
}
int
test_gen_noise
(
const
string
&
out_file
,
double
seconds
,
int
rate
)
{
const
int
channels
=
2
;
const
int
bits
=
16
;
vector
<
float
>
noise
;
Random
rng
(
0
,
/* there is no stream for this test */
Random
::
Stream
::
data_up_down
);
for
(
size_t
i
=
0
;
i
<
size_t
(
rate
*
seconds
)
*
channels
;
i
++
)
noise
.
push_back
(
rng
.
random_double
()
*
2
-
1
);
WavData
out_wav_data
(
noise
,
channels
,
rate
,
bits
);
Error
err
=
out_wav_data
.
save
(
out_file
);
if
(
err
)
{
error
(
"audiowmark: error saving %s: %s
\n
"
,
out_file
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
}
int
test_change_speed
(
const
string
&
in_file
,
const
string
&
out_file
,
double
speed
)
{
WavData
in_data
;
Error
err
=
in_data
.
load
(
in_file
);
if
(
err
)
{
error
(
"audiowmark: error loading %s: %s
\n
"
,
in_file
.
c_str
(),
err
.
message
());
return
1
;
}
WavData
out_data
=
resample_ratio
(
in_data
,
1
/
speed
,
in_data
.
sample_rate
());
err
=
out_data
.
save
(
out_file
);
if
(
err
)
{
error
(
"audiowmark: error saving %s: %s
\n
"
,
out_file
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
}
int
int
gen_key
(
const
string
&
outfile
)
gen_key
(
const
string
&
outfile
)
{
{
...
@@ -734,6 +776,20 @@ main (int argc, char **argv)
...
@@ -734,6 +776,20 @@ main (int argc, char **argv)
if
(
ap
.
parse_args
(
1
,
args
))
if
(
ap
.
parse_args
(
1
,
args
))
return
test_speed
(
atoi
(
args
[
0
].
c_str
()));
return
test_speed
(
atoi
(
args
[
0
].
c_str
()));
}
}
else
if
(
ap
.
parse_cmd
(
"test-gen-noise"
))
{
parse_shared_options
(
ap
);
if
(
ap
.
parse_args
(
3
,
args
))
return
test_gen_noise
(
args
[
0
],
atof
(
args
[
1
].
c_str
()),
atoi
(
args
[
2
].
c_str
()));
}
else
if
(
ap
.
parse_cmd
(
"test-change-speed"
))
{
parse_shared_options
(
ap
);
if
(
ap
.
parse_args
(
3
,
args
))
return
test_change_speed
(
args
[
0
],
args
[
1
],
atof
(
args
[
2
].
c_str
()));
}
error
(
"audiowmark: error parsing commandline args (use audiowmark -h)
\n
"
);
error
(
"audiowmark: error parsing commandline args (use audiowmark -h)
\n
"
);
return
1
;
return
1
;
}
}
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