Interpolate non-fft values too

Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
Skylar "The Cobra" Widulski 2023-12-22 10:39:58 -05:00
parent 9e45e98004
commit 9287e222a5
Signed by: cobra
GPG Key ID: 4FD8F812083FF6F9
3 changed files with 8 additions and 5 deletions

View File

@ -26,7 +26,7 @@ Below is a list of values and what they do
* `bgcolor`: Background color * `bgcolor`: Background color
* `queue-size`: The size of the queue (minimum of 1), delays displaying bars by `queue-size` frames. Useful if desync is noticed * `queue-size`: The size of the queue (minimum of 1), delays displaying bars by `queue-size` frames. Useful if desync is noticed
* `fft`: Whether or not to perform a fourier transform to show frequencies (like `spectrum` mode in most other visualizers) * `fft`: Whether or not to perform a fourier transform to show frequencies (like `spectrum` mode in most other visualizers)
* `fft-interpolation`: Number of points to interpolate between fft values. <1 means disable * `interpolation`: Number of points to interpolate between values. <1 means disable
* `smoothing`: Smoothing mode. Possible values are: * `smoothing`: Smoothing mode. Possible values are:
* `#f`: No smoothing or interpolation. Disregards `fft-interpolation` * `#f`: No smoothing or interpolation. Disregards `fft-interpolation`
* `'none`: No smoothing * `'none`: No smoothing

View File

@ -8,7 +8,7 @@
(define bgcolor #x2e2016ff) (define bgcolor #x2e2016ff)
(define queue-size 1) (define queue-size 1)
(define fft #f) (define fft #f)
(define fft-interpolation 0) (define interpolation 0)
(define smoothing-mode 'none) (define smoothing-mode 'none)
(define moving-average-block-size 25) (define moving-average-block-size 25)
(define exponential-factor 0.5) (define exponential-factor 0.5)

View File

@ -142,7 +142,7 @@
(define input lst) (define input lst)
(define ret '()) (define ret '())
(define window 0) (define window 0)
(if (> fft-interpolation 0) (if (> interpolation 0)
;; Interpolate FFT values ;; Interpolate FFT values
(begin (begin
(set! input '()) (set! input '())
@ -150,7 +150,7 @@
((>= (1+ i) (length lst))) ((>= (1+ i) (length lst)))
(set! input (append input (list (list-ref lst i)))) (set! input (append input (list (list-ref lst i))))
(do ((j 0 (1+ j))) (do ((j 0 (1+ j)))
((> j fft-interpolation)) ((> j interpolation))
(let ((n (- (list-ref lst (1+ i)) (list-ref lst i)))) (let ((n (- (list-ref lst (1+ i)) (list-ref lst i))))
(set! input (append input (list (* (expt (1+ j) (/ n 100000)) (set! input (append input (list (* (expt (1+ j) (/ n 100000))
(list-ref lst i)))))))))) (list-ref lst i))))))))))
@ -219,7 +219,10 @@
(do-dft plan (map cadr plst) (do-dft plan (map cadr plst)
(length plst)))))) (length plst))))))
;; No FFT ;; No FFT
(draw ren plst)))) (if (not (equal? smoothing-mode #f))
(draw ren (map list (smooth (map car plst) smoothing-mode)
(smooth (map cadr plst) smoothing-mode)))
(draw ren plst)))))
(touch sleep-future))) (touch sleep-future)))
;; Initially open the MPD FIFO ;; Initially open the MPD FIFO