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
b0b7371e
Commit
b0b7371e
authored
Dec 09, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Error objects in WavData::save().
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
9324da9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
26 deletions
+15
-26
audiowmark.cc
src/audiowmark.cc
+9
-6
wavdata.cc
src/wavdata.cc
+5
-17
wavdata.hh
src/wavdata.hh
+1
-3
No files found.
src/audiowmark.cc
View file @
b0b7371e
...
...
@@ -1967,9 +1967,10 @@ gentest (const string& infile, const string& outfile)
out_signal
.
push_back
(
in_signal
[
i
+
offset
]);
}
WavData
out_wav_data
(
out_signal
,
wav_data
.
n_channels
(),
wav_data
.
sample_rate
(),
wav_data
.
bit_depth
());
if
(
!
out_wav_data
.
save
(
outfile
))
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
out_wav_data
.
error_blurb
());
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
@@ -1994,9 +1995,10 @@ cut_start (const string& infile, const string& outfile, const string& start_str)
out_signal
.
push_back
(
in_signal
[
i
]);
WavData
out_wav_data
(
out_signal
,
wav_data
.
n_channels
(),
wav_data
.
sample_rate
(),
wav_data
.
bit_depth
());
if
(
!
out_wav_data
.
save
(
outfile
))
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
out_wav_data
.
error_blurb
());
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
@@ -2038,9 +2040,10 @@ test_subtract (const string& infile1, const string& infile2, const string& outfi
out_signal
.
push_back
(
in1_signal
[
i
]
-
in2_signal
[
i
]);
WavData
out_wav_data
(
out_signal
,
in1_data
.
n_channels
(),
in1_data
.
sample_rate
(),
in1_data
.
bit_depth
());
if
(
!
out_wav_data
.
save
(
outfile
))
err
=
out_wav_data
.
save
(
outfile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
out_wav_data
.
error_blurb
());
fprintf
(
stderr
,
"audiowmark: error saving %s: %s
\n
"
,
outfile
.
c_str
(),
err
.
message
());
return
1
;
}
return
0
;
...
...
src/wavdata.cc
View file @
b0b7371e
...
...
@@ -8,7 +8,6 @@
#include <memory>
#include <math.h>
#include <sndfile.h>
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -66,7 +65,7 @@ WavData::load (const string& filename)
return
Error
::
Code
::
NONE
;
}
bool
Error
WavData
::
save
(
const
string
&
filename
)
{
std
::
unique_ptr
<
AudioOutputStream
>
out_stream
;
// FIXME: virtual constructor
...
...
@@ -75,18 +74,13 @@ WavData::save (const string& filename)
out_stream
.
reset
(
sostream
);
Error
err
=
sostream
->
open
(
filename
,
m_n_channels
,
m_sample_rate
,
m_bit_depth
,
m_samples
.
size
()
/
m_n_channels
);
if
(
err
)
{
m_error_blurb
=
err
.
message
();
return
false
;
}
return
err
;
err
=
sostream
->
write_frames
(
m_samples
);
if
(
err
)
{
m_error_blurb
=
err
.
message
();
return
false
;
}
return
true
;
return
err
;
return
Error
::
Code
::
NONE
;
}
int
...
...
@@ -106,9 +100,3 @@ WavData::set_samples (const vector<float>& samples)
{
m_samples
=
samples
;
}
const
char
*
WavData
::
error_blurb
()
const
{
return
m_error_blurb
.
c_str
();
}
src/wavdata.hh
View file @
b0b7371e
...
...
@@ -12,18 +12,16 @@ class WavData
int
m_sample_rate
=
0
;
int
m_n_channels
=
0
;
int
m_bit_depth
=
0
;
std
::
string
m_error_blurb
;
public
:
WavData
();
WavData
(
const
std
::
vector
<
float
>&
samples
,
int
n_channels
,
int
sample_rate
,
int
bit_depth
);
Error
load
(
const
std
::
string
&
filename
);
bool
save
(
const
std
::
string
&
filename
);
Error
save
(
const
std
::
string
&
filename
);
int
sample_rate
()
const
;
int
bit_depth
()
const
;
const
char
*
error_blurb
()
const
;
int
n_channels
()
const
...
...
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