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
44756f5f
Commit
44756f5f
authored
Apr 11, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust scaling of software volume
git-svn-id:
https://svn.musicpd.org/mpd/trunk@681
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
823a7900
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
18 deletions
+17
-18
pcm_utils.c
src/pcm_utils.c
+8
-8
player.c
src/player.c
+1
-1
player.h
src/player.h
+1
-1
playerData.c
src/playerData.c
+1
-1
volume.c
src/volume.c
+6
-7
No files found.
src/pcm_utils.c
View file @
44756f5f
...
...
@@ -47,7 +47,7 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format,
mpd_sint8
*
buffer8
=
(
mpd_sint8
*
)
buffer
;
mpd_sint16
*
buffer16
=
(
mpd_sint16
*
)
buffer
;
if
(
volume
>=
100
)
return
;
if
(
volume
>=
100
0
)
return
;
if
(
volume
<=
0
)
{
memset
(
buffer
,
0
,
bufferSize
);
...
...
@@ -59,7 +59,7 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format,
while
(
bufferSize
>
0
)
{
temp32
=
*
buffer16
;
temp32
*=
volume
;
temp32
/=
100
;
temp32
/=
100
0
;
*
buffer16
=
temp32
>
32767
?
32767
:
(
temp32
<-
32768
?
-
32768
:
temp32
);
buffer16
++
;
...
...
@@ -70,7 +70,7 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format,
while
(
bufferSize
>
0
)
{
temp32
=
*
buffer8
;
temp32
*=
volume
;
temp32
/=
100
;
temp32
/=
100
0
;
*
buffer8
=
temp32
>
127
?
127
:
(
temp32
<-
128
?
-
128
:
temp32
);
buffer8
++
;
...
...
@@ -96,7 +96,7 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1,
switch
(
format
->
bits
)
{
case
16
:
while
(
bufferSize1
>
0
&&
bufferSize2
>
0
)
{
temp32
=
(
vol1
*
(
*
buffer16_1
)
+
vol2
*
(
*
buffer16_2
))
/
100
;
temp32
=
(
vol1
*
(
*
buffer16_1
)
+
vol2
*
(
*
buffer16_2
))
/
100
0
;
*
buffer16_1
=
temp32
>
32767
?
32767
:
(
temp32
<-
32768
?
-
32768
:
temp32
);
buffer16_1
++
;
...
...
@@ -108,7 +108,7 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1,
break
;
case
8
:
while
(
bufferSize1
>
0
&&
bufferSize2
>
0
)
{
temp32
=
(
vol1
*
(
*
buffer8_1
)
+
vol2
*
(
*
buffer8_2
))
/
100
;
temp32
=
(
vol1
*
(
*
buffer8_1
)
+
vol2
*
(
*
buffer8_2
))
/
100
0
;
*
buffer8_1
=
temp32
>
127
?
127
:
(
temp32
<-
128
?
-
128
:
temp32
);
buffer8_1
++
;
...
...
@@ -131,8 +131,8 @@ void pcm_mix(char * buffer1, char * buffer2, size_t bufferSize1,
float
s
=
sin
(
M_PI_2
*
portion1
);
s
*=
s
;
vol1
=
s
*
100
+
0
.
5
;
vol1
=
vol1
>
100
?
1
00
:
(
vol1
<
0
?
0
:
vol1
);
vol1
=
s
*
100
0
+
0
.
5
;
vol1
=
vol1
>
100
0
?
10
00
:
(
vol1
<
0
?
0
:
vol1
);
pcm_add
(
buffer1
,
buffer2
,
bufferSize1
,
bufferSize2
,
vol1
,
100
-
vol1
,
format
);
pcm_add
(
buffer1
,
buffer2
,
bufferSize1
,
bufferSize2
,
vol1
,
100
0
-
vol1
,
format
);
}
src/player.c
View file @
44756f5f
...
...
@@ -422,7 +422,7 @@ void setPlayerCrossFade(float crossFadeInSeconds) {
void
setPlayerSoftwareVolume
(
int
volume
)
{
PlayerControl
*
pc
;
volume
=
(
volume
>
100
)
?
1
00
:
(
volume
<
0
?
0
:
volume
);
volume
=
(
volume
>
100
0
)
?
10
00
:
(
volume
<
0
?
0
:
volume
);
pc
=
&
(
getPlayerData
()
->
playerControl
);
...
...
src/player.h
View file @
44756f5f
...
...
@@ -74,7 +74,7 @@ typedef struct _PlayerControl {
mpd_sint8
seek
;
double
seekWhere
;
float
crossFade
;
mpd_
sint8
softwareVolume
;
mpd_
uint16
softwareVolume
;
double
totalPlayTime
;
int
decode_pid
;
}
PlayerControl
;
...
...
src/playerData.c
View file @
44756f5f
...
...
@@ -111,7 +111,7 @@ void initPlayerData() {
memset
(
playerData_pd
->
playerControl
.
file
,
0
,
MAXPATHLEN
+
1
);
memset
(
playerData_pd
->
playerControl
.
erroredFile
,
0
,
MAXPATHLEN
+
1
);
playerData_pd
->
playerControl
.
crossFade
=
crossfade
;
playerData_pd
->
playerControl
.
softwareVolume
=
100
;
playerData_pd
->
playerControl
.
softwareVolume
=
100
0
;
playerData_pd
->
playerControl
.
totalPlayTime
=
0
;
playerData_pd
->
playerControl
.
decode_pid
=
0
;
...
...
src/volume.c
View file @
44756f5f
...
...
@@ -48,7 +48,7 @@
int
volume_mixerType
=
VOLUME_MIXER_TYPE_SOFTWARE
;
char
*
volume_mixerDevice
;
int
volume_softwareSet
=
-
1
;
int
volume_softwareSet
=
100
;
#ifndef NO_OSS_MIXER
int
volume_ossFd
;
...
...
@@ -373,11 +373,7 @@ void openVolumeDevice() {
}
int
getSoftwareVolume
()
{
if
(
volume_softwareSet
>=
0
)
{
return
volume_softwareSet
;
}
return
50
*
log
((
getPlayerSoftwareVolume
()
*
(
M_E
*
M_E
-
1
)
/
100
.
0
)
+
1
)
+
0
.
5
;
}
int
getVolumeLevel
()
{
...
...
@@ -400,14 +396,17 @@ int getVolumeLevel() {
int
changeSoftwareVolume
(
FILE
*
fp
,
int
change
,
int
rel
)
{
int
new
=
change
;
if
(
rel
)
new
+=
getSoftwareVolume
();
if
(
rel
)
new
+=
getSoftwareVolume
()
/
10
.
0
+
0
.
5
;
if
(
new
>
100
)
new
=
100
;
else
if
(
new
<
0
)
new
=
0
;
volume_softwareSet
=
new
;
new
=
100
.
0
*
(
exp
(
new
/
50
.
0
)
-
1
)
/
(
M_E
*
M_E
-
1
)
+
0
.
5
;
/*new = 100.0*(exp(new/50.0)-1)/(M_E*M_E-1)+0.5;*/
if
(
new
>=
100
)
new
=
1000
;
else
if
(
new
<=
0
)
new
=
0
;
else
new
=
1000
.
0
*
(
exp
(
new
/
20
.
0
)
-
1
)
/
(
148
.
413159103
F
-
1
)
+
0
.
5
;
setPlayerSoftwareVolume
(
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