summaryrefslogtreecommitdiff
path: root/src/channel.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-30 23:56:05 -0500
committersanine <sanine.not@pm.me>2022-08-30 23:56:05 -0500
commit26952167e940e900cd0e1fa7452c4f163640cbe3 (patch)
tree3b55aa3978a56dabdf957f1ac0804e0b59c61934 /src/channel.c
parenteb4e4cab2d3f24ee7f8d0be7149162084fe98392 (diff)
add stereo panning
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/channel.c b/src/channel.c
index a29e7f7..d039701 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -106,8 +106,15 @@ void channel_get_next_sample(float *left, float *right, struct channel_t *chan)
float l, r;
l = chan->sound.left[chan->pos];
r = chan->sound.right[chan->pos];
- *left = volume * l;
- *right = volume * r;
+
+ float pan_l = ((float)p_atomic_int_get(&(chan->pan_left)))/128;
+ float pan_r = ((float)p_atomic_int_get(&(chan->pan_right)))/128;
+ float gain_ll, gain_lr, gain_rl, gain_rr;
+ pan_gain(&gain_ll, &gain_lr, pan_l);
+ pan_gain(&gain_rl, &gain_rr, pan_r);
+
+ *left = volume * ((gain_ll * l) + (gain_rl * r));
+ *right = volume * ((gain_lr * l) + (gain_rr * r));
}
chan->pos += 1;