rms_power   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/vu_meter.xtm

Implementation

(bind-func rms_power
  (lambda (data:SAMPLE* len)
    (let ((data_vec:/4,SAMPLE/* (cast data))
          (sum_vec:/4,SAMPLE/* (alloc))
          (j 0))
      (dotimes (j (/ len 4))
        (pset! sum_vec 0 (+ (* (pref-ptr data_vec j)
                               (pref-ptr data_vec j))
                            sum_vec)))
      (/ (+ (vref sum_vec 0) (vref sum_vec 1)
            (vref sum_vec 2) (vref sum_vec 3))
         (convert len)))))


Back to Index

Similar Entries