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
ce63254c
Commit
ce63254c
authored
Apr 20, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix floating point wav input format.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
597fc3fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
19 deletions
+40
-19
sfinputstream.cc
src/sfinputstream.cc
+39
-19
sfinputstream.hh
src/sfinputstream.hh
+1
-0
No files found.
src/sfinputstream.cc
View file @
ce63254c
...
@@ -67,13 +67,18 @@ SFInputStream::open (const string& filename)
...
@@ -67,13 +67,18 @@ SFInputStream::open (const string& filename)
m_bit_depth
=
24
;
m_bit_depth
=
24
;
break
;
break
;
case
SF_FORMAT_FLOAT
:
case
SF_FORMAT_PCM_32
:
case
SF_FORMAT_PCM_32
:
m_bit_depth
=
32
;
m_bit_depth
=
32
;
break
;
break
;
case
SF_FORMAT_FLOAT
:
m_bit_depth
=
32
;
m_read_float_data
=
true
;
break
;
case
SF_FORMAT_DOUBLE
:
case
SF_FORMAT_DOUBLE
:
m_bit_depth
=
64
;
m_bit_depth
=
64
;
m_read_float_data
=
true
;
break
;
break
;
default
:
default
:
...
@@ -101,7 +106,21 @@ SFInputStream::read_frames (vector<float>& samples, size_t count)
...
@@ -101,7 +106,21 @@ SFInputStream::read_frames (vector<float>& samples, size_t count)
{
{
assert
(
m_state
==
State
::
OPEN
);
assert
(
m_state
==
State
::
OPEN
);
if
(
m_read_float_data
)
/* float or double input */
{
samples
.
resize
(
count
*
m_n_channels
);
sf_count_t
r_count
=
sf_readf_float
(
m_sndfile
,
&
samples
[
0
],
count
);
if
(
sf_error
(
m_sndfile
))
return
Error
(
sf_strerror
(
m_sndfile
));
samples
.
resize
(
r_count
*
m_n_channels
);
}
else
/* integer input */
{
vector
<
int
>
isamples
(
count
*
m_n_channels
);
vector
<
int
>
isamples
(
count
*
m_n_channels
);
sf_count_t
r_count
=
sf_readf_int
(
m_sndfile
,
&
isamples
[
0
],
count
);
sf_count_t
r_count
=
sf_readf_int
(
m_sndfile
,
&
isamples
[
0
],
count
);
if
(
sf_error
(
m_sndfile
))
if
(
sf_error
(
m_sndfile
))
...
@@ -119,6 +138,7 @@ SFInputStream::read_frames (vector<float>& samples, size_t count)
...
@@ -119,6 +138,7 @@ SFInputStream::read_frames (vector<float>& samples, size_t count)
const
double
norm
=
1.0
/
0x80000000LL
;
const
double
norm
=
1.0
/
0x80000000LL
;
for
(
size_t
i
=
0
;
i
<
samples
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
samples
.
size
();
i
++
)
samples
[
i
]
=
isamples
[
i
]
*
norm
;
samples
[
i
]
=
isamples
[
i
]
*
norm
;
}
return
Error
::
Code
::
NONE
;
return
Error
::
Code
::
NONE
;
}
}
...
...
src/sfinputstream.hh
View file @
ce63254c
...
@@ -31,6 +31,7 @@ class SFInputStream : public AudioInputStream
...
@@ -31,6 +31,7 @@ class SFInputStream : public AudioInputStream
int
m_n_values
=
0
;
int
m_n_values
=
0
;
int
m_bit_depth
=
0
;
int
m_bit_depth
=
0
;
int
m_sample_rate
=
0
;
int
m_sample_rate
=
0
;
bool
m_read_float_data
=
false
;
enum
class
State
{
enum
class
State
{
NEW
,
NEW
,
...
...
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