Jump to content

Recommended Posts

Hello 

 

i try to write a function who could directly apply to an omn list of that form :

 

(set melo1 '(s bb5 f c6 mf bb5 f q mf s c6) (s c6 g5 g5 mp q c5 s bb5 f) (h. g5 f e. mp bb4 ff bb5 mf g5 f) )

 

How may i proceed to access independently pitch , length , velocity or articulation without having to disassemble it . Is there an existing helping function already made on which i could assign a new custom written function .

 

Thanks

 

Patrick  

 

 

Link to comment
Share on other sites

Thank you but what  i am looking for is to create a new function X which could apply his functionality directly in a omn function like 

 

( rnd-order '(h. g3 mp e. bb4 mf q. c5 ff e. bb5 mf)) automatically render all omn component , but if i write a function x it will not automatically understand in the list what is pitch or length etc...

 

I would like to find a way to have direct access without having to extract first length or pitch  and to recombine it in omn later 

 

Thanks

 

Patrick

 

 

 

Link to comment
Share on other sites

you could work with omn-replace (from OM-library)? ...or some other code... have a look... greetings andré

;;; THREE SIMILAR FUNCTIONS FROM MY USER LIBRARY

;;; recognizes the parameter who has to be replaced
(defun omn-component-replace (omn-sequence replace-component)
  (make-omn :length (if (lengthp (car replace-component))
                     (append replace-component)
                     (omn :length omn-sequence))
            :pitch (if (or (pitchp (car replace-component)) (chordp (car replace-component)))
                     (append replace-component)
                     (omn :pitch omn-sequence))
            :velocity (if (velocityp (car replace-component))
                        (append replace-component)
                        (omn :velocity omn-sequence))
            :articulation (if (articulationp (car replace-component))
                            (append replace-component)
                            (omn :articulation omn-sequence))))

;;; the same with multiple inputs at once
(defun omn-component-replace2 (omn-sequence replace-component)
  (car (last (loop for i in replace-component
               collect (setf omn-sequence
                             (make-omn :length (if (lengthp (car i))
                                                 (append i)
                                                 (omn :length omn-sequence))
                                       :pitch (if (pitchp (car i))
                                                (append i)
                                                (omn :pitch omn-sequence))
                                       :velocity (if (velocityp (car i))
                                                   (append i)
                                                   (omn :velocity omn-sequence))
                                       :articulation (if (articulationp (car i))
                                                       (append i)
                                                       (omn :articulation omn-sequence))))))))


;;; replaces a single element
(defun omn-single-element-replace (omn-list old new)
  (let ((new-list (loop for i in (cond ((lengthp old)
                                        (omn :length (flatten omn-list)))
                                       ((pitchp old)
                                        (omn :pitch (flatten omn-list)))
                                       ((velocityp old)
                                        (omn :velocity (flatten omn-list)))
                                       ((articulationp old)
                                        (omn :articulation (flatten omn-list))))
                                        
                    when (equal i old) collect new
                    else collect i)))
    (omn-component-replace (flatten omn-list) new-list)))

;;;;;;;;;;;;;;;;;;

;;; EXAMPLES


(setf seq1 '(s gs3 ppp tasto q.t cs4 pppp tasto s f4 ppp tasto))

(omn-component-replace seq1 '(5/16 7/16 3/32))
=> (qs gs3 ppp tasto q.. cs4 pppp tasto s. f4 ppp tasto)




(omn-component-replace2 '(S C4 PPP TASTO Q.T D4 PPPP TASTO S E4 PPP TASTO) '((p) (ponte) (e2 b2 d2)))
=> (S E2 P PONTE Q.T B2 PONTE S D2 PONTE)



(omn-single-element-replace '(t gs4 pppp tasto a4 tasto bb4 tasto -t) 'bb4 'c4)
=> (t gs4 pppp tasto a4 tasto c4 tasto -)

(omn-single-element-replace '(t gs4 pppp tasto a4 tasto bb4 tasto -t) 'pppp 'ff)
=> (t gs4 ff tasto a4 tasto bb4 tasto -)

 

Link to comment
Share on other sites

Below is a link another way to write functions that process OMN more easily by defining only a function processing the parameter you are interested in, and then turning that quasi-automatically into a function that supports arbitrary OMN expressions (including nested expressions, preserving the nesting, and rests).  

 

Best,

Torsten

Link to comment
Share on other sites

Thank you Torsten 

 

that's exactly what i was looking for , as i compose using Opusmodus first to generate several ideas which once in omn form  i like to process again or edit  afterwards with some home made functions and at the end manual edits . I will try it and come back to you if i have some questions .

 

Patrick

 

 

 

 

Link to comment
Share on other sites

Hi torsten 

 

when i evaluate 

 

(defun edit-omn (type notation fun &key (flat T)))

 

 

i gat this error message maybe i missed something 

 

;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" :
;   In edit-omn: Unused lexical variable flat
;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" :
;   In edit-omn: Unused lexical variable fun
;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" :
;   In edit-omn: Unused lexical variable notation
;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" :
;   In edit-omn: Unused lexical variable type

 

Link to comment
Share on other sites

Looks like you tried to evaluate only the first line of a function definition without any body. The compiler therefore helpfully tells you that you are not using the arguments of this function.

 

What are you actually trying to do, evaluate the function edit-omn that I provided in my post linked above? Have you tried evaluating the content of the code whole box with both function definitions, remove-property and edit-omn.

 

I should perhaps add that how to use the function edit-omn is best understood by Lisp programmers who already know what higher order functions are, which is a somewhat advanced, but very powerful programming concept. In my original post I provided a link to a textbook chapter on functions. The idea will also be discussed in many other Common Lisp text books.

 

Best,

Torsten

Link to comment
Share on other sites

I did something which seems easier for me 

 

(defun my-omn (lis &optional (nbr 0) ) 

(nth nbr (disassemble-omn lis )))

 

from there i mapcar any functions   

 

Ex:  

 

(setf lenomn (my-omn pianomain  ))   ;pianomain is a omn list or lists 

 

(setf newlen (mapcar 'anyfunction lenomn ))

 

then   :   (omn-replace :pitch newlen pianomain )

 

Now if i would like to embed everything in one function with the options ? ( nbr 0 for length 3 for pitch 5 for velocity and 7 for articulation ) plus the omn options for :pitch :length :velocity and :art     with anyfuntion as an additional  argument

 

 That's what i would like to know how to do , now that i have the useful functions set , then i could concentrate everything in one function 

 

Thanks For any help   Patrick  

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