diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-04-11 11:48:04 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-04-11 11:48:04 +0000 |
commit | 44756f5f10717c77b14cd7e3bdade349f0969be7 (patch) | |
tree | 2b55d790d8fc934d2b2a6951bbabe744da1537d9 /src/pcm_utils.c | |
parent | 823a7900bd5c6a14857928102fbad8ec83f97568 (diff) | |
download | mpd-44756f5f10717c77b14cd7e3bdade349f0969be7.tar.gz mpd-44756f5f10717c77b14cd7e3bdade349f0969be7.tar.xz mpd-44756f5f10717c77b14cd7e3bdade349f0969be7.zip |
adjust scaling of software volume
git-svn-id: https://svn.musicpd.org/mpd/trunk@681 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/pcm_utils.c')
-rw-r--r-- | src/pcm_utils.c | 16 |
1 files changed, 8 insertions, 8 deletions
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); } |