Refactor everything for easier system install
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
ed890c469b
commit
523b752c16
|
@ -49,14 +49,15 @@ Below is a list of values and what they do
|
|||
* `exponential-factor`: Exponential smoothing factor, lower is more smooth.
|
||||
|
||||
# Running
|
||||
Either install libyammer.so and yammer.h to their respective systemwide locations, or do the following:
|
||||
Either install .libs/libyammer.so, src/c/yammer.h, src/guile/yammer.scm, and src/guile/yammer to their respective systemwide locations, or do the following:
|
||||
```bash
|
||||
export LD_LIBRARY_PATH=.
|
||||
export LD_LIBRARY_PATH=.libs
|
||||
export GUILE_LOAD_PATH=src/guile
|
||||
```
|
||||
|
||||
Then, run yammer.
|
||||
```bash
|
||||
guile -L . yammer.scm
|
||||
./yammer
|
||||
```
|
||||
|
||||
# Screenshots
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
LDFLAGS="$(pkg-config --cflags --libs ${NO_FFTW:-fftw3} ${NO_PULSE:-libpulse-simple})"
|
||||
CFLAGS="-Wall -Wextra -Werror -fPIC -O3 ${DEBUG:+-ggdb}"
|
||||
|
||||
gcc_invoke="gcc ${NO_FFTW:--DUSE_FFTW} ${NO_PULSE:--DUSE_PULSE} -shared yammer.c -o libyammer.so ${CFLAGS} -shared ${LDFLAGS}"
|
||||
gcc_invoke="gcc ${NO_FFTW:--DUSE_FFTW} ${NO_PULSE:--DUSE_PULSE} -shared ${0%/*}/src/c/yammer.c -o ${0%/*}/.libs/libyammer.so ${CFLAGS} -shared ${LDFLAGS}"
|
||||
|
||||
mkdir ${0%/*}/.libs
|
||||
export C_INCLUDE_PATH="${0%/*}/src/c${C_INCLUDE_PATH:+:$C_INCLUDE_PATH}"
|
||||
eval "$gcc_invoke"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env -S guile
|
||||
!#
|
||||
;;;
|
||||
;;; Copyright (C) 2023 Skylar Widulski
|
||||
;;;
|
||||
|
@ -20,7 +18,6 @@
|
|||
;;;
|
||||
|
||||
(define-module (yammer)
|
||||
#:declarative? #f
|
||||
#:use-module (sdl2)
|
||||
#:use-module (sdl2 blend-mode)
|
||||
#:use-module (sdl2 events)
|
||||
|
@ -37,22 +34,89 @@
|
|||
#:use-module (scheme base)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (system foreign)
|
||||
#:use-module (yammer ffi))
|
||||
#:use-module (yammer ffi)
|
||||
#:export (start))
|
||||
|
||||
;; Add this config dir to load path
|
||||
(add-to-load-path
|
||||
(string-append
|
||||
(if (getenv "XDG_CONFIG_HOME")
|
||||
(getenv "XDG_CONFIG_HOME")
|
||||
(string-append (getenv "HOME") "/.config"))
|
||||
"/yammer"))
|
||||
(load-from-path "config.scm")
|
||||
(define fd #f)
|
||||
(define pa-simple #f)
|
||||
|
||||
(define using-fftw? #t)
|
||||
(define using-pulse? #t)
|
||||
(define source "/tmp/mpd.fifo")
|
||||
(define source-type 'mpd)
|
||||
(define bitrate 44100)
|
||||
(define sample-factor 2)
|
||||
(define fps 20)
|
||||
(define resolution 1)
|
||||
(define scale 1)
|
||||
(define color #xff99c8ff)
|
||||
(define bgcolor #x2e2016ff)
|
||||
(define queue-size 1)
|
||||
(define fft #f)
|
||||
(define interpolation 0)
|
||||
(define smoothing-mode 'none)
|
||||
(define moving-average-block-size 24)
|
||||
(define exponential-factor 0.5)
|
||||
|
||||
;; Define widely used constants in relation to config values
|
||||
(define recip-fps (/ 1 fps))
|
||||
(define sample-size
|
||||
(exact (* 4 (round (* sample-factor (* (/ bitrate 4) recip-fps))))))
|
||||
|
||||
(define (start config:using-fftw? config:using-pulse? config:source
|
||||
config:source-type config:bitrate config:sample-factor config:fps
|
||||
config:resolution config:scale config:color config:bgcolor
|
||||
config:queue-size config:fft config:interpolation
|
||||
config:smoothing-mode config:moving-average-block-size
|
||||
config:exponential-factor)
|
||||
(set! using-fftw? config:using-fftw?)
|
||||
(set! using-pulse? config:using-pulse?)
|
||||
(set! source config:source)
|
||||
(set! source-type config:source-type)
|
||||
(set! bitrate config:bitrate)
|
||||
(set! sample-factor config:sample-factor)
|
||||
(set! fps config:fps)
|
||||
(set! resolution config:resolution)
|
||||
(set! scale config:scale)
|
||||
(set! color config:color)
|
||||
(set! bgcolor config:bgcolor)
|
||||
(set! queue-size config:queue-size)
|
||||
(set! fft config:fft)
|
||||
(set! interpolation config:interpolation)
|
||||
(set! smoothing-mode config:smoothing-mode)
|
||||
(set! moving-average-block-size config:moving-average-block-size)
|
||||
(set! exponential-factor config:exponential-factor)
|
||||
|
||||
(set! recip-fps (/ 1 fps))
|
||||
(set! sample-size
|
||||
(exact (* 4 (round (* sample-factor (* (/ bitrate 4) recip-fps))))))
|
||||
|
||||
;; Initially open the MPD FIFO or connect to pulseaudio
|
||||
(cond
|
||||
((eq? source-type 'mpd)
|
||||
(set! fd (open-fifo source)))
|
||||
((eq? source-type 'pulse)
|
||||
(set! pa-simple (make-pa-simple bitrate source pulse-latency))))
|
||||
|
||||
(sdl-init '(video events)) ;; Initialize SDL2
|
||||
(set! window (make-window #:title "Yammer")) ;; Create window
|
||||
(set-window-resizable! window #t) ;; Allow window resizing
|
||||
(set! renderer (make-renderer window)) ;; Create renderer from window
|
||||
|
||||
(lp renderer fft) ;; Run the loop
|
||||
|
||||
(delete-renderer! renderer) ;; Free renderer on close
|
||||
(close-window! window) ;; Close window
|
||||
(sdl-quit) ;; Quit SDL2
|
||||
(cond
|
||||
((eq? source-type 'mpd)
|
||||
(close-port fd))
|
||||
((eq? source-type 'pulse)
|
||||
(pa_simple_free pa-simple)))
|
||||
|
||||
;; Free FFT plan if FFT is enabled
|
||||
(if (and fft using-fftw?) (monitor (fftw_destroy_plan plan))))
|
||||
|
||||
;; Plan definition (if using fft)
|
||||
(define plan #f)
|
||||
(if (and fft using-fftw?)
|
||||
|
@ -246,31 +310,3 @@
|
|||
(smooth (map cadr plst) smoothing-mode)))
|
||||
(draw ren plst)))))
|
||||
(touch sleep-future)))
|
||||
|
||||
;; Initially open the MPD FIFO
|
||||
(define fd #f)
|
||||
(define pa-simple #f)
|
||||
(cond
|
||||
((eq? source-type 'mpd)
|
||||
(set! fd (open-fifo source)))
|
||||
((eq? source-type 'pulse)
|
||||
(set! pa-simple (make-pa-simple bitrate source pulse-latency))))
|
||||
|
||||
(sdl-init '(video events)) ;; Initialize SDL2
|
||||
(set! window (make-window #:title "Yammer")) ;; Create window
|
||||
(set-window-resizable! window #t) ;; Allow window resizing
|
||||
(set! renderer (make-renderer window)) ;; Create renderer from window
|
||||
|
||||
(lp renderer fft) ;; Run the loop
|
||||
|
||||
(delete-renderer! renderer) ;; Free renderer on close
|
||||
(close-window! window) ;; Close window
|
||||
(sdl-quit) ;; Quit SDL2
|
||||
(cond
|
||||
((eq? source-type 'mpd)
|
||||
(close-port fd))
|
||||
((eq? source-type 'pulse)
|
||||
(pa_simple_free pa-simple)))
|
||||
|
||||
;; Free FFT plan if FFT is enabled
|
||||
(if (and fft using-fftw?) (monitor (fftw_destroy_plan plan)))
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env -S guile
|
||||
!#
|
||||
(define using-fftw? #t) (define using-pulse? #t) (define source "/tmp/mpd.fifo") (define source-type 'mpd) (define bitrate 44100) (define sample-factor 2) (define fps 20) (define resolution 1) (define scale 1) (define color #xff99c8ff) (define bgcolor #x2e2016ff) (define queue-size 1) (define fft #f) (define interpolation 0) (define smoothing-mode 'none) (define moving-average-block-size 24) (define exponential-factor 0.5) (set! %load-extensions (quote (".scm"))) (add-to-load-path (string-append (if (getenv "XDG_CONFIG_HOME") (getenv "XDG_CONFIG_HOME") (string-append (getenv "HOME") "/.config")) "/yammer")) (load-from-path "config") (use-modules (yammer)) (start using-fftw? using-pulse? source source-type bitrate sample-factor fps resolution scale color bgcolor queue-size fft interpolation smoothing-mode moving-average-block-size exponential-factor)
|
Loading…
Reference in New Issue