100 lines
2.9 KiB
Scheme
100 lines
2.9 KiB
Scheme
;;;
|
|
;;; Copyright (C) 2024 Skylar Widulski
|
|
;;;
|
|
;;; This file is part of Yammer.
|
|
;;;
|
|
;;; Yammer is free software: you can redistribute it and/or modify it under the
|
|
;;; terms of the GNU General Public License as published by the Free Software
|
|
;;; Foundation, either version 3 of the License, or (at your option) any later
|
|
;;; version.
|
|
;;;
|
|
;;; Yammer is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
;;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
;;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
;;; details.
|
|
;;;
|
|
;;; You should have received a copy of the GNU General Public License along with
|
|
;;; Yammer. If not, see <https://www.gnu.org/licenses/>.
|
|
;;;
|
|
|
|
(define-module (yammer ffi)
|
|
#:use-module (system foreign)
|
|
#:export (FFTW_ESTIMATE
|
|
fftw_destroy_plan
|
|
init_plan
|
|
do-dft
|
|
make-pa-simple
|
|
read_from_pa
|
|
pa_simple_free))
|
|
|
|
(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 fftw #f)
|
|
(define pulseaudio #f)
|
|
(define libyammer (dynamic-link "libyammer"))
|
|
|
|
(define FFTW_ESTIMATE #f)
|
|
(define fftw_destroy_plan #f)
|
|
(define do_dft #f)
|
|
(define init_plan #f)
|
|
(define (do-dft plan lst len) #f)
|
|
|
|
(define make_pa_simple #f)
|
|
(define (make-pa-simple rate dev) #f)
|
|
(define read_from_pa #f)
|
|
(define pa_simple_free #f)
|
|
|
|
(if using-fftw?
|
|
(begin
|
|
(set! fftw (dynamic-link "libfftw3"))
|
|
(set! FFTW_ESTIMATE 48)
|
|
|
|
(set! fftw_destroy_plan
|
|
(pointer->procedure void
|
|
(dynamic-func "fftw_destroy_plan" fftw)
|
|
(list '*)))
|
|
|
|
(set! do_dft
|
|
(pointer->procedure '*
|
|
(dynamic-func "do_dft" libyammer)
|
|
(list '* '* int)))
|
|
|
|
(set! init_plan
|
|
(pointer->procedure '*
|
|
(dynamic-func "init_plan" libyammer)
|
|
(list int)))
|
|
|
|
(set! do-dft
|
|
(lambda (plan lst len)
|
|
(define out (do_dft plan (bytevector->pointer (list->s16vector lst)) len))
|
|
(pointer->bytevector out (floor/ len 2) (sizeof short) 's16)))))
|
|
|
|
(if using-pulse?
|
|
(begin
|
|
(set! pulseaudio (dynamic-link "libpulse-simple"))
|
|
|
|
(set! make_pa_simple
|
|
(pointer->procedure '*
|
|
(dynamic-func "make_pa_simple" libyammer)
|
|
(list unsigned-int '* int)))
|
|
|
|
(set! make-pa-simple
|
|
(lambda (rate dev latency)
|
|
(make_pa_simple rate (string->pointer dev) latency)))
|
|
|
|
(set! read_from_pa
|
|
(pointer->procedure '*
|
|
(dynamic-func "read_from_pa" libyammer)
|
|
(list '* size_t)))
|
|
|
|
(set! pa_simple_free
|
|
(pointer->procedure void
|
|
(dynamic-func "pa_simple_free" pulseaudio)
|
|
(list '*)))))
|