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
a7fac00b
Commit
a7fac00b
authored
Jun 04, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helpers to audiowmark for better tests.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
a971ce4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
audiowmark.cc
src/audiowmark.cc
+35
-3
No files found.
src/audiowmark.cc
View file @
a7fac00b
...
...
@@ -373,10 +373,9 @@ test_speed (const Key& key, int seed)
}
int
test_gen_noise
(
const
Key
&
key
,
const
string
&
out_file
,
double
seconds
,
int
rate
)
test_gen_noise
(
const
Key
&
key
,
const
string
&
out_file
,
double
seconds
,
int
rate
,
int
bits
)
{
const
int
channels
=
2
;
const
int
bits
=
16
;
vector
<
float
>
noise
;
Random
rng
(
key
,
0
,
/* there is no stream for this test */
Random
::
Stream
::
data_up_down
);
...
...
@@ -433,6 +432,30 @@ test_resample (const string& in_file, const string& out_file, int new_rate)
return
0
;
}
int
test_info
(
const
string
&
in_file
,
const
string
&
property
)
{
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
;
}
if
(
property
==
"bit_depth"
)
{
printf
(
"%d
\n
"
,
in_data
.
bit_depth
());
return
0
;
}
if
(
property
==
"frames"
)
{
printf
(
"%zd
\n
"
,
in_data
.
n_frames
());
return
0
;
}
error
(
"audiowmark: unsupported property for test_info: %s
\n
"
,
property
.
c_str
());
return
1
;
}
static
string
escape_key_name
(
const
string
&
name
)
{
...
...
@@ -962,10 +985,12 @@ main (int argc, char **argv)
else
if
(
ap
.
parse_cmd
(
"test-gen-noise"
))
{
parse_shared_options
(
ap
);
int
bits
=
16
;
ap
.
parse_opt
(
"--bits"
,
bits
);
Key
key
=
parse_key
(
ap
);
args
=
parse_positional
(
ap
,
"output_wav"
,
"seconds"
,
"sample_rate"
);
return
test_gen_noise
(
key
,
args
[
0
],
atof_or_die
(
args
[
1
].
c_str
()),
atoi_or_die
(
args
[
2
].
c_str
()));
return
test_gen_noise
(
key
,
args
[
0
],
atof_or_die
(
args
[
1
].
c_str
()),
atoi_or_die
(
args
[
2
].
c_str
())
,
bits
);
}
else
if
(
ap
.
parse_cmd
(
"test-change-speed"
))
{
...
...
@@ -981,6 +1006,13 @@ main (int argc, char **argv)
args
=
parse_positional
(
ap
,
"input_wav"
,
"output_wav"
,
"new_rate"
);
return
test_resample
(
args
[
0
],
args
[
1
],
atoi_or_die
(
args
[
2
].
c_str
()));
}
else
if
(
ap
.
parse_cmd
(
"test-info"
))
{
parse_shared_options
(
ap
);
args
=
parse_positional
(
ap
,
"input_wav"
,
"property"
);
return
test_info
(
args
[
0
],
args
[
1
]);
}
else
if
(
ap
.
remaining_args
().
size
())
{
string
s
=
ap
.
remaining_args
().
front
();
...
...
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