diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 3bb900508..a51fb8870 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -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>=1000) 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/=1000; *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/=1000; *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))/1000; *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))/1000; *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 ? 100 : ( vol1<0 ? 0 : vol1 ); + vol1 = s*1000+0.5; + vol1 = vol1>1000 ? 1000 : ( vol1<0 ? 0 : vol1 ); - pcm_add(buffer1,buffer2,bufferSize1,bufferSize2,vol1,100-vol1,format); + pcm_add(buffer1,buffer2,bufferSize1,bufferSize2,vol1,1000-vol1,format); } diff --git a/src/player.c b/src/player.c index 63ee4f062..0659b212c 100644 --- a/src/player.c +++ b/src/player.c @@ -422,7 +422,7 @@ void setPlayerCrossFade(float crossFadeInSeconds) { void setPlayerSoftwareVolume(int volume) { PlayerControl * pc; - volume = (volume>100) ? 100 : (volume<0 ? 0 : volume); + volume = (volume>1000) ? 1000 : (volume<0 ? 0 : volume); pc = &(getPlayerData()->playerControl); diff --git a/src/player.h b/src/player.h index a52c511a0..df256ea0b 100644 --- a/src/player.h +++ b/src/player.h @@ -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; diff --git a/src/playerData.c b/src/playerData.c index f86a86cb9..9fc8f830d 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -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 = 1000; playerData_pd->playerControl.totalPlayTime = 0; playerData_pd->playerControl.decode_pid = 0; diff --git a/src/volume.c b/src/volume.c index b55cd1e17..db27c0a13 100644 --- a/src/volume.c +++ b/src/volume.c @@ -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; + return volume_softwareSet; } 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.413159103F-1)+0.5; setPlayerSoftwareVolume(new);