;convert LR interleaved signal to 3 buffers buffer_size/2 in length
(bind-func LR_to_MS_2_channels
(lambda (buffer:float* buffer_size:i64 mid:float* side:float*)
(let ((n:i64 0))
(dotimes (n (/ buffer_size 2))
(pset! mid n (+ (pref buffer (* n 2)) (pref buffer (+ (* n 2) 1)))) ;l+r
(pset! side n (- (pref buffer (* n 2)) (pref buffer (+ (* n 2) 1))))) ;l-r
void)))