ref: cb1381e41c056d1aca8eff9237ae4b7820b36015
parent: fea33a2fc4eca3b9a84ec8c549f37ad99a55c2ef
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Aug 24 05:54:01 EDT 2021
piper: mixing that makes sense
--- a/piper/piper.c
+++ b/piper/piper.c
@@ -26,7 +26,7 @@
static int bpm = 120;
static float bar = 2.0;
-static float vol = 1.0;
+static float vol = 0.5;
static QLock grouplock;
static Group *groups;
static int numgroups;
@@ -238,12 +238,13 @@
}
qunlock(&grouplock);
for (n = 0; n < 2*bufframes; n++) {
- f = out[n] * 8192.0 * vol;
- if (f > 32767.0)
- f = 32767.0;
- else if (f < -32767.0)
- f = -32767.0;
- pcm[n] = f;
+ f = out[n] * vol;
+ if (f >= 1.0)
+ pcm[n] = 32767;
+ else if (f <= -1.0)
+ pcm[n] = -32768;
+ else
+ pcm[n] = f * 32767.0;
}
if (write(audio, pcm, 2*bufframes*sizeof(*pcm)) < 0) {
fprint(2, "audio: %r\n");