Jump to content

error warning: Undeclared free variable


o_e

Recommended Posts

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!

Link to comment
Share on other sites

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)
))

 

Link to comment
Share on other sites

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:

Bildschirmfoto 2021-09-12 um 17.21.11.jpg

Link to comment
Share on other sites

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))

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy