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
5f718b61
Commit
5f718b61
authored
Feb 05, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use mp3 loader in WavData.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
a7ae7b8b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
mp3.cc
src/mp3.cc
+2
-1
testmp3.cc
src/testmp3.cc
+13
-6
wavdata.cc
src/wavdata.cc
+14
-5
No files found.
src/mp3.cc
View file @
5f718b61
...
...
@@ -36,6 +36,8 @@ mp3_try_load (const string& filename, WavData& wav_data)
err
=
mpg123_open
(
mh
,
filename
.
c_str
());
assert
(
err
==
0
);
err
=
mpg123_getformat
(
mh
,
&
rate
,
&
channels
,
&
encoding
);
if
(
err
!=
0
)
return
false
;
assert
(
err
==
0
);
printf
(
"# %d
\n
"
,
err
);
printf
(
"# %ld %d %d
\n
"
,
rate
,
channels
,
encoding
);
...
...
@@ -54,7 +56,6 @@ mp3_try_load (const string& filename, WavData& wav_data)
{
err
=
mpg123_read
(
mh
,
&
buffer
[
0
],
buffer
.
size
(),
&
done
);
assert
(
err
==
0
||
err
==
MPG123_DONE
);
printf
(
"# done=%zd err=%d
\n
"
,
done
,
err
);
float
*
f
=
reinterpret_cast
<
float
*>
(
&
buffer
[
0
]);
for
(
int
i
=
0
;
i
<
buffer
.
size
()
/
4
;
i
++
)
...
...
src/testmp3.cc
View file @
5f718b61
...
...
@@ -4,7 +4,9 @@ int
main
(
int
argc
,
char
**
argv
)
{
WavData
wd
;
if
(
argc
>=
2
&&
mp3_try_load
(
argv
[
1
],
wd
))
if
(
argc
>=
2
)
{
if
(
mp3_try_load
(
argv
[
1
],
wd
))
{
int
sec
=
wd
.
n_values
()
/
wd
.
sample_rate
();
...
...
@@ -15,4 +17,9 @@ main (int argc, char **argv)
printf
(
"saved wav: %s
\n
"
,
argv
[
2
]);
}
}
else
{
printf
(
"mp3 try load %s failed
\n
"
,
argv
[
1
]);
}
}
}
src/wavdata.cc
View file @
5f718b61
#include "wavdata.hh"
#include "mp3.hh"
#include <math.h>
#include <sndfile.h>
...
...
@@ -34,6 +35,13 @@ WavData::load (const string& filename)
int
error
=
sf_error
(
sndfile
);
if
(
error
)
{
if
(
mp3_try_load
(
filename
,
*
this
))
{
// ok, if its an mp3, take it
return
true
;
}
else
{
m_error_blurb
=
sf_strerror
(
sndfile
);
if
(
sndfile
)
...
...
@@ -41,6 +49,7 @@ WavData::load (const string& filename)
return
false
;
}
}
vector
<
int
>
isamples
(
sfinfo
.
frames
*
sfinfo
.
channels
);
sf_count_t
count
=
sf_readf_int
(
sndfile
,
&
isamples
[
0
],
sfinfo
.
frames
);
...
...
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