Posted September 12, 20213 yr Hi, When I write functions and make use of setf's, I get the brown colored warning: Undeclared free variable This becomes a problem, when I'd like to put the function into the extensions folder. How can I remedy this? Thanks!
September 12, 20213 yr I need to see what you trying to do. The defparameter is possibly better a solution.
September 12, 20213 yr Author Here is what I've hacked together, thanks for looking into it: (defun plot-pcs-distr (x) (progn (setf c (list (count '0 (flatten (get-pcs x))))) (setf cs (list (count '1 (flatten (get-pcs x))))) (setf d (list (count '2 (flatten (get-pcs x))))) (setf ds (list (count '3 (flatten (get-pcs x))))) (setf e (list (count '4 (flatten (get-pcs x))))) (setf f (list (count '5 (flatten (get-pcs x))))) (setf fs (list (count '6 (flatten (get-pcs x))))) (setf g (list (count '7 (flatten (get-pcs x))))) (setf gs (list (count '8 (flatten (get-pcs x))))) (setf a (list (count '9 (flatten (get-pcs x))))) (setf bb (list (count '10 (flatten (get-pcs x))))) (setf b (list (count '11 (flatten (get-pcs x))))) (setf all (append c cs d ds e f fs g gs a bb b)) (setf liste (loop for x in all for y in '(c cis d dis e f fis g gis a bes b) collect (list x y))) (sort liste #'< :key #'first) (setf liste-plot (loop for i in all for j in '(0 1 2 3 4 5 6 7 8 9 10 11) collect (list j i))) (xy-plot liste-plot :join-points t :point-radius 2 :style :fill :point-style :square) ))
September 12, 20213 yr Not very clear what you like to do. What (would be) is the result of the LIST-PLOT expression. What is the input of the function. What should this do: (list (count 4 (flatten (get-pcs x))))
September 12, 20213 yr Author I've tried to get an overview of which pitches are used how many times in a stem: (plot-pcs-distr '((q c3 c3 d4 f5)(e fs2 fs2 fs2 fs2 fs2 gs4))) ==>((0 2) (1 0) (2 1) (3 0) (4 0) (5 1) (6 5) (7 0) (8 1) (9 0) (10 0) (11 0)) so I can see at a glance there are 2 c's, zero cis's, one d and so forth.. and the plot:
September 13, 20213 yr Here it is: (defun pcs-count-plot (sequence) (do-verbose ("pcs-count-plot") (let* ((i (sort-asc (flatten (modus (pitch-to-integer (melodize (omn :pitch sequence))))))) (r (count-repeat i)) (l (mapcar 'list (remove-duplicates i) r))) (xy-plot l :point-radius 4 :style :axis :point-style :hollow) ))) (pcs-count-plot omn) => ((0 2) (2 1) (5 1) (6 5) (8 1))
September 13, 20213 yr Author Thanks for you efforts of completely rewriting the function! This will serve me well as a model of how to use let*..!
Create an account or sign in to comment