hann   xtlang


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

2 implementations of hann: #1 /digego/extempore/tree/v0.8.9/libs/core/audio_dsp.xtm · #2 /digego/extempore/tree/v0.8.9/libs/core/audio_dsp.xtm


Implementation

;; a repeating hann signal of width
;;
;; where a cycle is
;; time 0.0 -> width
;;
;; repeat is:
;; 1.0 - repeat immediately
;; 2.0 - repeat after two cycles
;; 4.0 - repeat after four cycles etc..
;;
(bind-func hann
  (lambda (time:i64 width:i64 repeat:i64)
    (if (or (< width 1)
            (> (% time (* width repeat)) width))
        0.0
        (* 0.5
           (- 1.0
              (cos (* STWOPI (/ (convert time)
                                (convert width)))))))))


Back to Index

Similar Entries