]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mix.c
customizable loading screen picture scale, including limiting to screen bounds in...
[xonotic/darkplaces.git] / snd_mix.c
index 8b77d96de9b51fa0ceb304d3f1df323cf136655a..9094ce6ccd5f959aa1cddfd7f86d2085f87c2d97 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -183,23 +183,13 @@ CHANNEL MIXING
 
 static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint, unsigned int count)
 {
-       int snd_vol, vol[SND_LISTENERS];
+       int vol[SND_LISTENERS];
        const snd_buffer_t *sb;
        unsigned int i, sb_offset;
 
-       // If this channel manages its own volume
-       if (ch->flags & CHANNELFLAG_FULLVOLUME)
-               snd_vol = (int)(mastervolume.value * 256);
-       else
-               snd_vol = (int)(mastervolume.value * volume.value * 256);
-
-       // calculate mixing volumes based on channel volumes and volume cvar
-       // also limit the volumes to values that won't clip
+       // move to the stack (do we need to?)
        for (i = 0;i < SND_LISTENERS;i++)
-       {
-               vol[i] = ch->listener_volume[i] * snd_vol;
-               vol[i] = bound(0, vol[i], 65536);
-       }
+               vol[i] = ch->listener_volume[i];
 
        // if volumes are all zero, just return
        for (i = 0;i < SND_LISTENERS;i++)
@@ -267,12 +257,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint,
                                                samples += 2;
                                        }
                                }
+                               else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1)
+                               {
+                                       for (i = 0;i < count;i++)
+                                       {
+                                               paint[i].sample[0] += (samples[0] * vol[0]) >> 8;
+                                               paint[i].sample[1] -= (samples[1] * vol[1]) >> 8;
+                                               samples += 2;
+                                       }
+                               }
                                else if (vol[0] + vol[1] > 0)
                                {
                                        for (i = 0;i < count;i++)
                                        {
                                                paint[i].sample[0] += (samples[0] * vol[0]) >> 8;
-                                               paint[i].sample[1] += (samples[1] * vol[1] * ch->prologic_invert) >> 8;
+                                               paint[i].sample[1] += (samples[1] * vol[1]) >> 8;
                                                samples += 2;
                                        }
                                }
@@ -318,12 +317,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint,
                                                samples += 1;
                                        }
                                }
+                               else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1)
+                               {
+                                       for (i = 0;i < count;i++)
+                                       {
+                                               paint[i].sample[0] += (samples[0] * vol[0]) >> 8;
+                                               paint[i].sample[1] -= (samples[0] * vol[1]) >> 8;
+                                               samples += 1;
+                                       }
+                               }
                                else if (vol[0] + vol[1] > 0)
                                {
                                        for (i = 0;i < count;i++)
                                        {
                                                paint[i].sample[0] += (samples[0] * vol[0]) >> 8;
-                                               paint[i].sample[1] += (samples[0] * vol[1] * ch->prologic_invert) >> 8;
+                                               paint[i].sample[1] += (samples[0] * vol[1]) >> 8;
                                                samples += 1;
                                        }
                                }
@@ -377,12 +385,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint,
                                                samples += 2;
                                        }
                                }
+                               else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1)
+                               {
+                                       for (i = 0;i < count;i++)
+                                       {
+                                               paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+                                               paint[i].sample[1] -= (samples[1] * vol[1]) >> 16;
+                                               samples += 2;
+                                       }
+                               }
                                else if (vol[0] + vol[1] > 0)
                                {
                                        for (i = 0;i < count;i++)
                                        {
                                                paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
-                                               paint[i].sample[1] += (samples[1] * vol[1] * ch->prologic_invert) >> 16;
+                                               paint[i].sample[1] += (samples[1] * vol[1]) >> 16;
                                                samples += 2;
                                        }
                                }
@@ -428,12 +445,21 @@ static qboolean SND_PaintChannel (channel_t *ch, portable_sampleframe_t *paint,
                                                samples += 1;
                                        }
                                }
+                               else if (vol[0] + vol[1] > 0 && ch->prologic_invert == -1)
+                               {
+                                       for (i = 0;i < count;i++)
+                                       {
+                                               paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
+                                               paint[i].sample[1] -= (samples[0] * vol[1]) >> 16;
+                                               samples += 1;
+                                       }
+                               }
                                else if (vol[0] + vol[1] > 0)
                                {
                                        for (i = 0;i < count;i++)
                                        {
                                                paint[i].sample[0] += (samples[0] * vol[0]) >> 16;
-                                               paint[i].sample[1] += (samples[0] * vol[1] * ch->prologic_invert) >> 16;
+                                               paint[i].sample[1] += (samples[0] * vol[1]) >> 16;
                                                samples += 1;
                                        }
                                }