Jump to content

Parameter as variable?

Recommended Posts


I want to make the following construction:

(defun mapping-integers (x y)
  (interval-to-pitch (integer-to-interval x) :start y))

(mapping-integers '(0 4 5 9 11) 'c5)

I get an error-warning having the wrong start parameter, how could this be done?

I have a list of integers (0 4 5 9 11) and a list of root notes (c5) and want them to process to get lists like (c5 e5 f5 a5 b5)..


Link to post
Share on other sites

to answer my own question, I found a workaround:

(defun mapping-integers-2 (x y)
  (chordize (pitch-transpose (pitch-to-integer y) (integer-to-pitch x))))

(mapping-integers-2 '(0 4 5 9 11) 'g4)

nevertheless I would like to know if it is possible to handle the keyword parameters with variables..

Link to post
Share on other sites


(pitch-transpose-start 'c5 (integer-to-pitch '(0 4 5 9 11)))
=> (c5 e5 f5 a5 b5)

with &key

(defun mapping-integers (l &key start)
  (if start (pitch-transpose-start start (integer-to-pitch l))
    (integer-to-pitch l)))

(mapping-integers '(0 4 5 9 11) :start 'c5)
=> (c5 e5 f5 a5 b5)
with &optional
(defun mapping-integers2 (l &optional start)
  (if start (pitch-transpose-start start (integer-to-pitch l))
    (integer-to-pitch l)))

(mapping-integers2 '(0 4 5 9 11) 'c5)
=> (c5 e5 f5 a5 b5)
Link to post
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.

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.

  • Similar Topics

    • By JoostVK
      Dear creators of Opusmodus,
      I'm currently trying out the demo, so I'm in the first stages of getting to know OM.
      I'm trying to do a very simple referral to a variable to make an OMN-snippet, but I get all sorts of error codes from the listener. Even to the point that copying some of the tutorial code, and replacing the names of the variables makes the code generate errors...?
      Here's the example, so any help or suggestion is welcome:
      (example is based on 'stage2'-code, I only replaced the names of the variables):
      (setf p_arp0 '(c4 cs4 fs4 g4 c5)) (setf l_arp0 (span p_arp0 '(e))) (setf d_arp0 '(p< < < < ff)) (setf arpeg0 (make-omn :length l_arp0 :pitch p_arp0 :velocity d_arp0))when I evaluate the snippet with the original variables, being 'pitches', 'length' and so on, it works. When I use my own names, however, like in the pasted example, it gives the following error code:
      "> Error: OMN Parse Error: (annotate (parse-omn-audition-phrase) (fail nil ((setf l_arp0 (span p_arp0 '(e))) (setf d_arp0 '(p< < < < ff)) (setf arpeg0 (make-omn length l_arp0 pitch p_arp0 velocity d_arp0))))) > While executing: omn-audition-to-ast, in process Listener-1(6). > Type cmd-. to abort, cmd-\ for a list of available restarts. > Type :? for other options. 5 >"or it shows just any previous evaluation in the Assistant (ignoring the fact that I changed some notes,...)
      Another case:
      this example works:
      (setf arp1 '(w eb4e4gs4a4d5 arp)) this doesn't:
      (setf p_arp1 '(eb4e4gs4a4d5) (setf arp1 '(w p_arp1 arp)) Is there a certain way to name variables? Is there any interference with program-keywords? It would be a vital function, since I compose on paper mostly using a system of variable-substition to keep economy in my material.
      Could you please help. I can't find anywhere in the documentation what I'm doing wrong. I'm seriously interested in using/buying Opusmodus...
      Greetings from Brussels, Joost Van kerkhoven
    • By geoffroy
      I've just installed Opusmodus and I don't understand why I'm getting this error
      > Error: Unbound variable: > While executing: ccl::toplevel-eval, in process Listener-1(8). > Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts. > If continued: Retry getting the value of . > Type :? for other options.It happens when I copied and paste this expression from the Getting Started PDF
      (vector-map '(c4 d4 f4 gs4 as4 b4 cs5 e5) (gen-sine 120 6 0.5 :modulation (gen-sine 120 6 0.2)))If I evaluate the line with cmd+E, it's working, but if I'm trying to evaluate or play the whole document, I get this error.
      Here's a screencast

      Sorry for the newbie question
  • Create New...