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
bfe020e0
Commit
bfe020e0
authored
Dec 22, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Volume: make PCM_VOLUME_1 a "constexpr"
parent
5aae5606
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
PcmMix.cxx
src/pcm/PcmMix.cxx
+5
-6
PcmVolume.cxx
src/pcm/PcmVolume.cxx
+3
-3
PcmVolume.hxx
src/pcm/PcmVolume.hxx
+5
-4
No files found.
src/pcm/PcmMix.cxx
View file @
bfe020e0
...
...
@@ -36,8 +36,8 @@ PcmAddVolume(typename Traits::value_type _a, typename Traits::value_type _b,
typename
Traits
::
long_type
a
(
_a
),
b
(
_b
);
typename
Traits
::
value_type
c
=
((
a
*
volume1
+
b
*
volume2
)
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
pcm_volume_dither
()
+
PCM_VOLUME_1S
/
2
)
/
PCM_VOLUME_1
S
;
return
PcmClamp
<
F
,
Traits
>
(
c
);
}
...
...
@@ -204,7 +204,6 @@ bool
pcm_mix
(
void
*
buffer1
,
const
void
*
buffer2
,
size_t
size
,
SampleFormat
format
,
float
portion1
)
{
int
vol1
;
float
s
;
/* portion1 is between 0.0 and 1.0 for crossfading, MixRamp uses -1
...
...
@@ -215,8 +214,8 @@ pcm_mix(void *buffer1, const void *buffer2, size_t size,
s
=
sin
(
M_PI_2
*
portion1
);
s
*=
s
;
vol1
=
s
*
PCM_VOLUME_1
+
0.5
;
vol1
=
Clamp
<
int
>
(
vol1
,
0
,
PCM_VOLUME_1
);
int
vol1
=
s
*
PCM_VOLUME_1S
+
0.5
;
vol1
=
Clamp
<
int
>
(
vol1
,
0
,
PCM_VOLUME_1
S
);
return
pcm_add_vol
(
buffer1
,
buffer2
,
size
,
vol1
,
PCM_VOLUME_1
-
vol1
,
format
);
return
pcm_add_vol
(
buffer1
,
buffer2
,
size
,
vol1
,
PCM_VOLUME_1
S
-
vol1
,
format
);
}
src/pcm/PcmVolume.cxx
View file @
bfe020e0
...
...
@@ -36,8 +36,8 @@ pcm_volume_change(typename Traits::pointer_type buffer,
typename
Traits
::
long_type
sample
=
*
buffer
;
sample
=
(
sample
*
volume
+
pcm_volume_dither
()
+
PCM_VOLUME_1
/
2
)
/
PCM_VOLUME_1
;
PCM_VOLUME_1
S
/
2
)
/
PCM_VOLUME_1
S
;
*
buffer
++
=
PcmClamp
<
F
,
Traits
>
(
sample
);
}
...
...
@@ -132,7 +132,7 @@ pcm_volume(void *buffer, size_t length,
SampleFormat
format
,
int
volume
)
{
if
(
volume
==
PCM_VOLUME_1
)
if
(
volume
==
PCM_VOLUME_1
S
)
return
true
;
if
(
volume
<=
0
)
{
...
...
src/pcm/PcmVolume.hxx
View file @
bfe020e0
...
...
@@ -26,10 +26,11 @@
#include <stdint.h>
#include <stddef.h>
enum
{
/** this value means "100% volume" */
PCM_VOLUME_1
=
1024
,
};
/**
* This value means "100% volume".
*/
static
constexpr
unsigned
PCM_VOLUME_1
=
1024
;
static
constexpr
int
PCM_VOLUME_1S
=
PCM_VOLUME_1
;
struct
AudioFormat
;
...
...
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