< Back to IRCAM Forum

Common Lisp Function with two outs

I would like to use a common lisp function I’ve made but using two outputs in OM. I’ve tried with (values-list list1 list2) but it didn’t work. Any idea how to do this. A simple example would be very helpfull.
Thank you in advance.


If useful, i Have used values instruction for a pair of functions of my library. I put the code of one of those after the signature. I am not a programmer, so the code can be not too elegant… I put in bold face some focal points.



(om::defmethod! m5m7 ((series list))
:initvals '(nil) ; an initial values list
:indoc '(“Initial series” ) ; an string list with short docs
:icon 112 ; the icon
:numouts 4
:doc “m5m7.
Selection of one pitch every 5 and 7 pitches of the input series.”

(midicent (om/ (flat series) 100))
(pcs (loop for i in midicent collect (mod i 12)))
(M5 (loop for i in (om* pcs 5) collect (mod i 12)))
(M7 (loop for i in (om* pcs 7) collect (mod i 12)))
(M5midicent (om+ (om* (loop for i in M5 collect (mod i 12)) 100) 6000))
(M7midicent (om+ (om* (loop for i in M7 collect (mod i 12)) 100) 6000))
(M5midicent-reverse (reverse M5midicent))
(M7midicent-reverse (reverse M7midicent))

(values (print M5midicent) (print M7midicent) (print M5midicent-reverse) (print M7midicent-reverse))


Thanx Fabio

That’s correct in your example. Just some notes:

values is the standard way to output multiple values in common lisp. However, in order to have multiple outputs in OpenMusic you have to use the om’s defmethod! special function (which is not a standrad defmethod in common lisp) and then add the :numouts key with the number of required outputs.

Best to you two

Thanks for the example, Fabio. It is very useful!

Thank you for the info. I tried something very simple like this but it is not working:

(om::defmethod separate (double)
    :numouts 2
  (values (first double) (second double)))

Do you know what I am missing here?

Thanks in advance.


Oh sorry for the noise. I got it. I forgot the !. Thanks.

Dear Luis,

Yes the ! is important it differentiate the standard defemethod with the om’s special defmethod!