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
d11a0c9f
Commit
d11a0c9f
authored
Dec 23, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Volume: apply volume into destination buffer
parent
7be2abe6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
21 deletions
+37
-21
Volume.cxx
src/pcm/Volume.cxx
+37
-21
No files found.
src/pcm/Volume.cxx
View file @
d11a0c9f
...
...
@@ -92,47 +92,53 @@ pcm_volume_sample<SampleFormat::S32,
template
<
SampleFormat
F
,
class
Traits
=
SampleTraits
<
F
>>
static
void
pcm_volume_change
(
typename
Traits
::
pointer_type
buffer
,
pcm_volume_change
(
typename
Traits
::
pointer_type
dest
,
typename
Traits
::
const_pointer_type
src
,
typename
Traits
::
const_pointer_type
end
,
int
volume
)
{
while
(
buffer
<
end
)
{
const
auto
sample
=
*
buffer
;
*
buffer
++
=
pcm_volume_sample
<
F
,
Traits
>
(
sample
,
volume
);
while
(
src
<
end
)
{
const
auto
sample
=
*
src
++
;
*
dest
++
=
pcm_volume_sample
<
F
,
Traits
>
(
sample
,
volume
);
}
}
static
void
pcm_volume_change_8
(
int8_t
*
buffer
,
const
int8_t
*
end
,
int
volume
)
pcm_volume_change_8
(
int8_t
*
dest
,
const
int8_t
*
src
,
const
int8_t
*
end
,
int
volume
)
{
pcm_volume_change
<
SampleFormat
::
S8
>
(
buffer
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S8
>
(
dest
,
src
,
end
,
volume
);
}
static
void
pcm_volume_change_16
(
int16_t
*
buffer
,
const
int16_t
*
end
,
int
volume
)
pcm_volume_change_16
(
int16_t
*
dest
,
const
int16_t
*
src
,
const
int16_t
*
end
,
int
volume
)
{
pcm_volume_change
<
SampleFormat
::
S16
>
(
buffer
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S16
>
(
dest
,
src
,
end
,
volume
);
}
static
void
pcm_volume_change_24
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
pcm_volume_change_24
(
int32_t
*
dest
,
const
int32_t
*
src
,
const
int32_t
*
end
,
int
volume
)
{
pcm_volume_change
<
SampleFormat
::
S24_P32
>
(
buffer
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S24_P32
>
(
dest
,
src
,
end
,
volume
);
}
static
void
pcm_volume_change_32
(
int32_t
*
buffer
,
const
int32_t
*
end
,
int
volume
)
pcm_volume_change_32
(
int32_t
*
dest
,
const
int32_t
*
src
,
const
int32_t
*
end
,
int
volume
)
{
pcm_volume_change
<
SampleFormat
::
S32
>
(
buffer
,
end
,
volume
);
pcm_volume_change
<
SampleFormat
::
S32
>
(
dest
,
src
,
end
,
volume
);
}
static
void
pcm_volume_change_float
(
float
*
buffer
,
const
float
*
end
,
float
volume
)
pcm_volume_change_float
(
float
*
dest
,
const
float
*
src
,
const
float
*
end
,
float
volume
)
{
while
(
buffer
<
end
)
{
float
sample
=
*
buffer
;
while
(
src
<
end
)
{
float
sample
=
*
src
++
;
sample
*=
volume
;
*
buffer
++
=
sample
;
*
dest
++
=
sample
;
}
}
...
...
@@ -157,27 +163,37 @@ pcm_volume(void *buffer, size_t length,
return
false
;
case
SampleFormat
:
:
S8
:
pcm_volume_change_8
((
int8_t
*
)
buffer
,
(
const
int8_t
*
)
end
,
pcm_volume_change_8
((
int8_t
*
)
buffer
,
(
const
int8_t
*
)
buffer
,
(
const
int8_t
*
)
end
,
volume
);
return
true
;
case
SampleFormat
:
:
S16
:
pcm_volume_change_16
((
int16_t
*
)
buffer
,
(
const
int16_t
*
)
end
,
pcm_volume_change_16
((
int16_t
*
)
buffer
,
(
const
int16_t
*
)
buffer
,
(
const
int16_t
*
)
end
,
volume
);
return
true
;
case
SampleFormat
:
:
S24_P32
:
pcm_volume_change_24
((
int32_t
*
)
buffer
,
(
const
int32_t
*
)
end
,
pcm_volume_change_24
((
int32_t
*
)
buffer
,
(
const
int32_t
*
)
buffer
,
(
const
int32_t
*
)
end
,
volume
);
return
true
;
case
SampleFormat
:
:
S32
:
pcm_volume_change_32
((
int32_t
*
)
buffer
,
(
const
int32_t
*
)
end
,
pcm_volume_change_32
((
int32_t
*
)
buffer
,
(
const
int32_t
*
)
buffer
,
(
const
int32_t
*
)
end
,
volume
);
return
true
;
case
SampleFormat
:
:
FLOAT
:
pcm_volume_change_float
((
float
*
)
buffer
,
(
const
float
*
)
end
,
pcm_volume_change_float
((
float
*
)
buffer
,
(
const
float
*
)
buffer
,
(
const
float
*
)
end
,
pcm_volume_to_float
(
volume
));
return
true
;
}
...
...
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