Welcome to the chicken scheme pasting service

fftw example added by lemonboy on Sun Jul 30 19:13:38 2017

(define mksin
  (let ((twopi (* 2 (atan 0 -1))))
    ; n = points
    ; f = frequency
    ; sr = sample rate
    (lambda (n f sr)
      (let ((out  (make-f64vector (fx+ n 2)))
            (step (/ 1 sr)))
        (do ((i 0 (fx+ i 1))) ((fx= i n) out)
          (f64vector-set! out i (+ 20.0 (* 1 (sin (* twopi f (* step i)))))))))))

(let* ((nn  50000)
       (sr  50000)
       (osz (fx+ 1 (fx/ nn 2)))
       (in  (mksin nn 12000 sr))
       (out (make-f64vector (fx* 2 osz))))
  (rfft (list nn) in in)

  (do ((i 0 (fx+ i 1))) ((fx>= i nn))
    (f64vector-set! in i (/ (f64vector-ref in i) nn)))

  (do ((i 0 (fx+ i 2))) ((fx>= i nn))
    (let ((re (f64vector-ref in i))
          (im (f64vector-ref in (fx+ 1 i))))
      (print (/ (* (/ (fx- i 0) 2) sr) nn) #\:
        (/ (sqrt (+ (* re re) (* im im))) 1))
      ))

  (irfft (list nn) in in))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
                _        
  ___ _ __ ___ | |_ _ __ 
 / _ \ '_ ` _ \| __| '__|
|  __/ | | | | | |_| |   
 \___|_| |_| |_|\__|_|   
                         
Visually impaired? Let me spell it for you (wav file) download WAV