Jump to content

How to use a user defined function in the counterpoint function in :methods?


Recommended Posts

How to use a user defined function, defined in my def-unfold-set "my-mehods" (in-package :Opusmodus), in the counterpoint function?

Example

(setf test-pattern '(e c4 d4 e4 f4 g4 a4 b4 c5))

(unfold ' my-mehods '(amb-c6b6) test-pattern)   ;; works perfectly, shifting up pitches

 

However how do I use this function amb-c6b6 in the counterpoint function?

#|1|# ((2 - 6 5) :methods ( amb-c6b6 - (r t-12) t-12))    ;;error,  how to unfold amb-c6b6?

 

Thanks for any idea!

Link to comment
Share on other sites

To ensure the :set parameter 'my-methods is properly configured in the counterpoint function, and to guarantee that other methods such as t-12 function correctly, you should integrate the entire 'om sets as well. This inclusion is necessary to maintain compatibility and functionality across all methods.

Link to comment
Share on other sites

Thanks!

Where and how do I integrate 'om along with 'my-methods? In the following example of counterpoint, the :set 'om   and :set 'my-methods are passed with no error, but the user defined function amb-g5fs6 still causes an error. Thanks for any example with :set which I did not find neither in the book, nor in the documentation of the assistant.

Or do I have to integrate 'om within def-unfold-set my-methods?

 

(counterpoint motifs-voices

'(

   #|1|# ((1 - 6 5) :methods (amb-g5fs6 - (r t-12) t-12))   ;still error !  I guess my-methods should be known before this line,

                                                                                                 ;otherwise the interpreter does not know the function amb-g5fs6

   #|2|# ((8 3 5 7) :methods (ri - t-12 t-12))

   ...

   #|20|# ((7 2 6 6) :methods (- - - -)) 

)

:index 'voice

:set 'om

:set 'my-methods 

:global-methods '((fl) (cl) (hn) (vc)))

 

 

Link to comment
Share on other sites

Here it is:
 

(counterpoint
(list p1 p2 p3 p4)
'(((- 1 2 3) :methods (- i r -) :tempo 72)
((- 4 3 *) :methods (- ri - -) :tempo 56)
((4 * * *) :methods (r - - -) :tempo 72)
((1 * 2 3) :methods (- - i -) :tempo 56)
((* * * *) :methods (- - - -) :tempo 72))
:global-methods '((fl) (t12 cl) (hn) (t-12 vc))
:global-polyphony '(7 p)
:iterate t
:index 'vox)
:set 'om)

 

or
 

(counterpoint
(list p1 p2 p3 p4)
'(((- 1 2 3) :methods (- i r -) :tempo 72)
((- 4 3 *) :methods (- ri - -) :tempo 56)
((4 * * *) :methods (r - - -) :tempo 72)
((1 * 2 3) :methods (- - i -) :tempo 56)
((* * * *) :methods (- - - -) :tempo 72))
:global-methods '((fl) (t12 cl) (hn) (t-12 vc))
:global-polyphony '(7 p)
:iterate t
:index 'vox)
:set 'my-methods)

 

Link to comment
Share on other sites

Oh, thanks a lot. I totally agree with your example! But:

 

1) In the first example 'om is set in the key :set 'om, which works anyway, because 'om is set by default according to the documentation and the functions i, r, ri etc. are defined in the the library om; therefore we can ommit ":set 'om". 

 

2) In the second example the same functions i, r, ri etc. are used, but they have to be implemented in my-methods, otherwise you get an error: here the standard lib om is not involved anymore (because :set 'my-methods)! I tried it out. That means all the methods (i, r, ri etc.) have to be rewritten (copy paste from om library) in  my-methods! Or, I somehow can integrate 'om in my-methods just by a directive of the type: "include 'om". Then I could use both functions from the standard om library om (i, r, ri etc.) and functions like amb-g5fs6 defined in my-methods. In counterpoint this would look as follows:   #|1|# ((1 - 6 5) :methods (amb-g5fs6 - (r t-12) t-12)) ; see also above.

I intuitively have the feeling, that it is not possible to mix om and my-methods, which would be a pitty. Probably I have to copy all my required functions from om (r, t-12, i ri etc.) to my-methods; which is not a problem, but not elegantly solved.

 

Can you agree with my analysis?

Link to comment
Share on other sites

Hi, yes, it is simple. It works but it is not elegantly solved. Copy paste in software technology is normally not the way to to. But ok, I can live with it.

 

Another interesting solution I got when I asked ChatGPT opusmodus with the question:

how to use functions from a def-unfold-set A and another def-unfold-set B in function counterpoint .

The answer I have attached in a pdf file.

It proposes the following, which in software technology totally makes sense! The problem? It does not work in opus modus and gives me the error message, that the package "my-methods" is not found.

The solution ChatGPC proposes is (in counterpoint) as follows:

counterpoint ...

((- 4 3 *) :methods (my-methods:amb-g5fs6 - ri - -) )   ;giving the name of the package my-methods along with the user defined function amb-g5fs6

 

I think, this is the way opusmodus could solve this issue. Perhaps you may contact the software engineers and Stephane Poussage

Anyway I have a solution and I thank you for your assistance!

Have a nice day!

Daniel

HowToUse different-Set-unfold-sets in Counterpoint 1.pdf

Link to comment
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.

Guest
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.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy