(bind-func oscv_mc_c
(lambda (phase chans)
(let ((i:i32 0) (p 0)
(y:/4,float/* (alloc))
(vphase:/4,float/* (alloc))
(srv (v4val SAMPLE_RATE))
(twopiv (v4val TWOPIf)))
(vset! vphase 0 phase)
(lambda (amp:/4,float/* freq:/4,float/*)
(let ((inc (* TWOPIf (/ (vref freq 0) SAMPLE_RATE))))
(dotimes (i 4)
(vset! vphase i phase)
(if (= (% p chans) 0)
(begin (set! phase (+ phase inc))
(if (> phase PIf) (set! phase (- phase TWOPIf)))))
(set! p (+ p 1)))
(pset! y 0 (* amp (_sin vphase)))
y)))))