Group Admins

  • Profile picture of Karim
  • Profile picture of Jean


Public Group active 1 day, 15 hours ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Set slot values in Lisp

Author 3 Subscribed Users |
Profile photo of davidsg

I can’t work out how to correctly set slot values for objects in Lisp code.

Here is a minimal example:

(defmethod note->chord ((self note) (offset list))
  (let ((chord (objfromobjs self (mki 'chord))))
    (setf (slot-value chord 'LOffset) offset)

Please see attached screenshot:
When I evaluate the CHORD from the fourth outlet (lonset) the return value is (0), but I was hoping for (50). Can someone help me out?


  1. note-to-chord


October 11, 2018 at 18:26 #28051
Profile photo of Karim

Hi David,

i propose the following, since it is non destructive (it will not change the chord but creates a new one with your offset values.

(defmethod setchordoffset ((self chord) (offsets list))
(let ((clone (clone self)))
(setf (loffset clone) offsets)

Patch in attachment.


October 11, 2018 at 19:16 #28055
Profile photo of Jean

Hi there. The explanation is: the visible slots of score objets (e.g. Loffset, etc.) are kind of “fake” slots, which are used as accessors (get/set) from the OM graphical interface to read or set the list of NOTE objects which actually make the contents of a CHORD object.

In order to change the offset of the notes, you shound therefore either go through this list on NOTEs (using the slot inside), or (as proposed by Karim) use the (setf (loffset chord) offsets) accessor function (which will internally calls the chord-building initializer for you) instead of (setf (slot-value chord 'LOffset) offsets) (which will have no effect on the inside NOTEs).

Best regards,

October 11, 2018 at 19:28 #28060
Profile photo of davidsg

Thank you both for your prompt replies – much appreciated!
All the best

October 11, 2018 at 21:17 #28061

You must be logged in to reply to this topic.

Log in now