Skip to content

Commit

Permalink
Add fft functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Nov 27, 2023
1 parent 3b6e6f9 commit a2c8806
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
8 changes: 8 additions & 0 deletions buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@

(defmethod framesize ((buffer buffer))
(samplesize :float))

(defun forward-fft (framesize in out)
(with-error-on-failure ()
(mixed:fwd-fft framesize (data-ptr in) (data-ptr out))))

(defun inverse-fft (framesize in out)
(with-error-on-failure ()
(mixed:inv-fft framesize (data-ptr in) (data-ptr out))))
20 changes: 19 additions & 1 deletion documentation.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,25 @@ See BUFFER")
BUFFERS should be a list of symbols, to each of which a
fresh instance of a BUFFER with a size of SAMPLES will
be bound."))
be bound.")

(function forward-fft
"Perform a forward FFT on the samples in IN and store the frequency data in OUT.
FRAMESIZE must be a power of two in [2^1, 2^13] and the
buffers must be sized accordingly.
See BUFFER
See INVERSE-FFT")

(function inverse-fft
"Perform an inverse FFT on the frequency data in IN and store the samples in OUT.
FRAMESIZE must be a power of two in [2^1, 2^13] and the
buffers must be sized accordingly.
See BUFFER
See FORWARD-FFT"))

;; c-object.lisp
(docs:define-docs
Expand Down
10 changes: 10 additions & 0 deletions low-level.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,16 @@
(defcfun (samplesize "mixed_samplesize") :uint8
(encoding encoding))

(defcfun (fwd-fft "mixed_fwd_fft") :int
(framesize :uint16)
(in :pointer)
(out :pointer))

(defcfun (inv-fft "mixed_inv_fft") :int
(framesize :uint16)
(in :pointer)
(out :pointer))

(defcfun (translator-from "mixed_translator_from") :pointer
(encoding encoding))

Expand Down
6 changes: 5 additions & 1 deletion package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
#:make-segment-info
#:make-segment
#:samplesize
#:fwd-fft
#:inv-fft
#:translator-from
#:translator-to
#:error
Expand Down Expand Up @@ -177,7 +179,9 @@
#:size
#:clear
#:with-buffers
#:transfer)
#:transfer
#:forward-fft
#:inverse-fft)
;; c-object.lisp
(:export
#:handle
Expand Down

0 comments on commit a2c8806

Please sign in to comment.