rsc3/doc/help/ugen/fft/pvcollect.help.scrbl

95 lines
1.9 KiB
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
#lang scribble/manual
@(require (for-label racket))
@title{(pvcollect chain numframes func frombin tobin zeroothers)}
2022-08-28 10:27:01 +00:00
2022-08-24 13:53:18 +00:00
Process each bin of an fft chain separately.
pvcollect applies function func to each bin of an fft chain. func
should be a function that takes magnitude, phase, index as inputs
and returns a resulting [magnitude, phase].
The "index" is the integer bin number, starting at 0 for DC. You
can optionally ignore the phase and only return a single
(magnitude) value, in which case the phase is assumed to be left
unchanged.
frombin, tobin, and zeroothers are optional arguments which limit
the processing to a specified integer range of fft bins. If
zeroothers is set to 1 then bins outside of the range being
processed are silenced.
Note that this procedure can be relatively CPU-heavy, depending on
how you use it.
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define no-op
(lambda (m p _)
(list m p)))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define rand-phase
(lambda (m p _)
(list m (rand 0 3.14))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define noise-phase
(lambda (m p _)
(list m (lin-lin (lf-noise0 kr 3) -1 1 0 3.14))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define combf
(lambda (m p i)
(list (if (= (modulo i 7) 0) m 0) p)))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define noise-mag
(lambda (m p _)
(list (mul (gt (lf-noise0 kr 10) 0) m) p)))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define spectral-delay
(lambda (m p _)
(let ((v (lin-lin (lf-par kr 0.5 0) -1 1 0.1 1)))
(list (add m (delay-n m 1 v)) p))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(define (bpf-sweep nf)
(lambda (m p i)
(let ((e (u:abs (sub i (lin-lin (lf-par kr 0.1 0) -1 1 2 (/ nf 20))))))
(list (mul (lt e 10) m) p))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(with-sc3
(lambda (fd)
(async fd (b-alloc 10 1024 1))
(async fd (b-alloc-read 11 "/home/rohan/audio/metal.wav" 0 0))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(let* ((nf 1024)
(i (play-buf 1 11 (buf-rate-scale kr 11) 1 0 1))
(c1 (fft* 10 i))
(c2 (pvcollect c1 nf spectral-delay 0 250 0)))
(audition (out 0 (mul 0.1 (ifft* c2)))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00