Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
48002320
Commit
48002320
authored
Oct 23, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok, resampling and converting to mono no works
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2309
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
12597322
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
27 deletions
+41
-27
pcm_utils.c
src/pcm_utils.c
+41
-27
No files found.
src/pcm_utils.c
View file @
48002320
...
...
@@ -242,28 +242,42 @@ void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t
else
{
/* only works if outFormat is 16-bit stereo! */
/* resampling code blatantly ripped from ESD */
mpd_
s
int32
rd_dat
=
0
;
mpd_
u
int32
rd_dat
=
0
;
mpd_uint32
wr_dat
=
0
;
mpd_sint16
lsample
,
rsample
;
register
mpd_sint16
*
out
=
(
mpd_sint16
*
)
outBuffer
;
register
mpd_sint16
*
in
=
(
mpd_sint16
*
)
dataChannelConv
;
const
int
shift
=
sizeof
(
mpd_sint16
);
mpd_uint32
nlen
=
(((
dataChannelLen
>>
shift
)
*
mpd_sint16
*
out
=
(
mpd_sint16
*
)
outBuffer
;
mpd_sint16
*
in
=
(
mpd_sint16
*
)
dataChannelConv
;
const
int
shift
=
sizeof
(
mpd_sint16
)
*
outFormat
->
channels
;
mpd_uint32
nlen
=
(((
dataChannelLen
/
shift
)
*
(
mpd_uint32
)(
outFormat
->
sampleRate
))
/
inFormat
->
sampleRate
);
nlen
<<=
shift
;
nlen
*=
outFormat
->
channels
;
while
(
wr_dat
<
nlen
/
shift
)
{
rd_dat
=
wr_dat
*
inFormat
->
sampleRate
/
outFormat
->
sampleRate
;
rd_dat
&=
~
1
;
switch
(
outFormat
->
channels
)
{
case
1
:
while
(
wr_dat
<
nlen
)
{
rd_dat
=
wr_dat
*
inFormat
->
sampleRate
/
outFormat
->
sampleRate
;
lsample
=
in
[
rd_dat
++
];
out
[
wr_dat
++
]
=
lsample
;
}
break
;
case
2
:
while
(
wr_dat
<
nlen
)
{
rd_dat
=
wr_dat
*
inFormat
->
sampleRate
/
outFormat
->
sampleRate
;
rd_dat
&=
~
1
;
lsample
=
in
[
rd_dat
++
];
rsample
=
in
[
rd_dat
++
];
lsample
=
in
[
rd_dat
++
];
rsample
=
in
[
rd_dat
++
];
out
[
wr_dat
++
]
=
lsample
;
out
[
wr_dat
++
]
=
rsample
;
}
out
[
wr_dat
++
]
=
lsample
;
out
[
wr_dat
++
]
=
rsample
;
}
break
;
}
}
return
;
...
...
@@ -272,7 +286,7 @@ void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t
size_t
pcm_sizeOfOutputBufferForAudioFormatConversion
(
AudioFormat
*
inFormat
,
size_t
inSize
,
AudioFormat
*
outFormat
)
{
const
int
shift
=
sizeof
(
mpd_sint16
);
const
int
shift
=
sizeof
(
mpd_sint16
)
*
outFormat
->
channels
;
size_t
outSize
=
inSize
;
switch
(
inFormat
->
bits
)
{
...
...
@@ -286,21 +300,21 @@ size_t pcm_sizeOfOutputBufferForAudioFormatConversion(AudioFormat * inFormat,
exit
(
EXIT_FAILURE
);
}
switch
(
in
Format
->
channels
)
{
case
1
:
outSize
=
(
outSize
>>
1
)
<<
2
;
break
;
case
2
:
break
;
default:
ERROR
(
"only 1 or 2 channels are supported for conversion!
\n
"
)
;
exit
(
EXIT_FAILURE
);
if
(
inFormat
->
channels
!=
out
Format
->
channels
)
{
switch
(
inFormat
->
channels
)
{
case
1
:
outSize
=
(
outSize
>>
1
)
<<
2
;
break
;
case
2
:
//outSize >>= 1;
break
;
}
}
outSize
=
(((
outSize
>>
shift
)
*
(
mpd_uint32
)(
outFormat
->
sampleRate
))
/
outSize
=
(((
outSize
/
shift
)
*
(
mpd_uint32
)(
outFormat
->
sampleRate
))
/
inFormat
->
sampleRate
);
outSize
<<
=
shift
;
outSize
*
=
shift
;
return
outSize
;
}
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