Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 15 hours, 40 minutes ago

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

om voice class in code form?

Author 2 Subscribed Users |
Profile photo of fdsdb
fdsdb

Hi All,

Sorry again to disturb with help for code.
I should need to know how to use the class VOICE in lisp code form. I am testing this code inside a lispfunction object (factor = 500 and num-ser = (1 2 3 5 7 11 13) for example):

(lambda (factor num-ser)
(let*
((durs (loop for i in num-ser collect (* i factor)))
(durs2 (loop for i in durs collect (list i)))
(zeros (om::repeat-n -100000 (length durs2)))
(durs3 (om::mat-trans (list durs zeros)))
(durs4 (loop for i in durs3 collect (om::omquantify i 60 ‘(4 4) 8))))
;(print durs4)
(loop for i in durs4 collect (om::voice nil i 6000 60 100 nil))
))

omquantify give me no problems (I have tested in order the print function from durs variable to durs4 one). But in using om::voice code I receive an error relative to a wrong number of arguments. I have tried to add voice object hidden nil arguments (3 last one, > key on object for visualizing them), quoting, unquoting, adding parenthesis and so on, but the error is always the same or become worst.
My aim is to connect the result of code directly into a poly class, for generating the different voices, so to create the corresponding function object in my library.
The algorithm is relative to a Messiaen technique used in Turangalila Symphony (from a Perspective of New Music paper)

Thank you all for help.

Ciao

Fabio

March 22, 2018 at 16:50 #25973
Profile photo of Karim
Karim

Hi Fabio

Well it seems you are using lisp code in a lispfunction box. Nevermind this should work :

(lambda (factor num-ser)
(let*
((durs (loop for i in num-ser collect (* i factor)))
(durs2 (loop for i in durs collect (list i)))
(zeros (om::repeat-n -100000 (length durs2)))
(durs3 (om::mat-trans (list durs zeros)))
(durs4 (loop for i in durs3 collect (om::omquantify i 60 ‘(4 4) 8)))
(voices (loop for i in durs4
collect (make-instance ‘voice
:tree i))))
(make-instance ‘poly
:voices voices)

))

Comments :
The problem you have is using om::voice as a function (or a method). It is neither of these. It is a class. In order to create a class (produce one) you should always use this expression : make-instance . This will make an instance of the class. I think you got the point. then you can fill the slots of the class as follows :tree ‘(some tree), etc… You don’t need to fill all the slots, since most of the classes have default values which is pretty practical..

Hope this helps

Best
K

March 22, 2018 at 18:07 #25974
Profile photo of fdsdb
fdsdb

Dear Karim,

Thank you very much for your very fast reply.
Perfect, your code runs perfectly. I had read OM online documentation, specifically Writing Code for OM and Writing User Libraries, and analyzed Malt’s ma-lib example, all has been very useful, but sometimes a little too much concise for my capacities (mea culpa of course). Your explanation is very clear and complete, I think I can also modify other objects of my library in progress, so to avoid the use of omloop for visualizing results.
Thank you again, Best, ciao

Fabio

March 22, 2018 at 19:07 #25976

You must be logged in to reply to this topic.

Log in now