< Back to IRCAM Forum

Defmethod! question

Hi,

I am trying to pass some patches to open music and I run into some trouble.
In order not always to have to compile in advance the non OM lisp objects present, I decided to put them into a user library.
Many things work fine, some needed more tweaking, but I run into a problem yesterday.
The bellow code works well as lisp but when I tried to convert it into an object it gives errors.
I think the problem seems to be in the (om::defmethod! addrtm ((&rest lists list)) of the code and don’t know how to resolve it (I know some basic lisp but I am not a programmer…).

The lisp file that works if compiled is:

(in-package :cl-user)

(defun addrtm (&rest lists)
(do* ((minpause nil (reduce #'min (mapcar #'first pauses)))
(result () (cons minpause result))
(pauses lists
(remove nil
(mapcar (lambda (pause-list)
(let ((current-pause (- (first pause-list)
minpause)))
(if (zerop current-pause)
(rest pause-list)
(cons current-pause
(rest pause-list)))))
pauses))))
((endp pauses) (nreverse result))))

The OM object file:

(in-package :mfl)

; Functions definition

(om::defmethod! addrtm ((&rest lists list))
:indoc '(“a list of rtms”)
:icon 130
:doc “Adds into a new rhythmic line the beating points of two rhythmic lines and redistributes the in between rhythms”
(do* ((minpause nil (reduce #'min (mapcar #'first pauses)))
(result () (cons minpause result))
(pauses lists
(remove nil
(mapcar (lambda (pause-list)
(let ((current-pause (- (first pause-list)
minpause)))
(if (zerop current-pause)
(rest pause-list)
(cons current-pause
(rest pause-list)))))
pauses))))
((endp pauses) (nreverse result))))

I tried to use it as well inside a lispfunction box but as well it didn’t work…

Any suggestions?
Is there any documentation for OM libraries creation except the Writing User Libraries | OpenMusic link?

Thank you in advance,

Dimitris

Hi Dimitris,

The problem you have is declaring an arg to a method &rest of a type of lists which of course doesn’t exist. So when you need to put &rest you don’t need to double parenthesis it… That’s all.
It should be like that:

(om::defmethod! addrtm (&rest lists)

Best
K

Thank you a lot Karim!!

Great as always!!!

Dimitris