Coverage report: /home/ellis/comp/core/lib/dsp/aud/chroma.lisp

KindCoveredAll%
expression063 0.0
branch02 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; chroma.lisp --- High-level CHROMAPRINT API
2
 
3
 ;; High-level wrapper for CHROMAPRINT IDs
4
 
5
 ;;; Code:
6
 (in-package :aud)
7
 ;; REVIEW 2025-03-30: audio-fingerprint class?
8
 (defclass chromaprint (id)
9
   ((id :initarg :id :type (vector (unsigned-byte 32)) :accessor id))
10
   (:documentation "An ID class wrapper for chromaprint (audio fingerprints)."))
11
 
12
 (defun chromaprint (data samplerate &optional (channels 2) (algo :default) (batch-size 1024))
13
   (let ((len (length data)))
14
     (with-static-vector (d len :initial-contents data)
15
       (with-chromaprint-ctx (ctx :algo algo :samplerate samplerate :channels channels)
16
         (if (< len batch-size)
17
             (chromaprint-feed ctx (static-vector-pointer d) len)
18
             (multiple-value-bind (batches tail) (floor len batch-size)
19
               (loop for i from 0 below batches
20
                     do (chromaprint-feed ctx (static-vector-pointer d :offset (* i batch-size)) batch-size))
21
               (chromaprint-feed ctx (static-vector-pointer d :offset (- len tail)) tail)))
22
         (chromaprint-finish ctx)
23
         (with-alien ((fp-size int)
24
                      (fpa (* unsigned-int)))
25
           (chromaprint-get-raw-fingerprint ctx (addr fpa) (addr fp-size))
26
           (let ((fp (make-array fp-size :element-type '(unsigned-byte 32) :adjustable nil)))
27
             (loop for i from 0 below fp-size
28
                   do (setf (aref fp i) (deref fpa i)))
29
             (values fp fp-size)))))))
30
 
31
 ;; TODO 2025-07-24: 
32
 (defun chromaprint-file (file &optional (default :error))
33
   "Return a chromaprint associated with the audio data contained in FILE."
34
   ;; TODO: retrieve channel-count, samplerate, and audio data buffer - may
35
   ;; want to take advantage of buffering here to stream directly to
36
   ;; CHROMAPRINT-FEED
37
   (declare (ignore file default)))
38