Jump to content

Post processing adding operations in a loop for i


Recommended Posts

This is from Stephane Jeu2 pour piano example , i am looking to add computation on this omn2-1

i would like it to do as well :

 

(< (omn-encode (car x)) 1/16)
                                     (chord-interval-add '(-12 5 6 ) x)

 

Plus  as well 

 

(= (omn-encode (car x)) 1/16)
                                     (chord-interval-add '(36 ) x)


for example , but i do not know how to group all operation within the same loop for i or even if it is possible ,

 

 

 

;; omn post processing (adding interval if length > 1/16)


(setf omn2-1 (ambitus
              '(c2 c5)
               (loop for i in (single-events omn2)
                 collect (mapcar (lambda(x) 
                                   (if (> (omn-encode (car x)) 1/16)
                                     (chord-interval-add '(-4) x)
                                     x))
                                 i))))

 

Thank you  for your answer

 

Patrick 

 

Jeu2aPourPiano.opmo

Link to comment
Share on other sites

I think the easy way and best way is to use my function (revised by Torsten) ADD-INTERVAL-IF-LENGTH:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;       ADD-INTERVAL-IF-LENGTH                    ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; USAGE
#|
(setf seq '((e c4 p stacc d4 stacc e4 stacc f4 stacc q g4 g3)
            (q c4 mf e c6 b5 a5 g5 f5 d5)
            (s e4 f4 e4 d4 q g4 b4 d5)
            (q g5 ff marc g4 marc h c5 )))

; with default parameters
(add-interval-if-length '(1/4 c4 d4 e4 1/8 e4 f4))
(add-interval-if-length seq)
; with specified condition
(add-interval-if-length seq :condition '<)
(add-interval-if-length seq :condition '=)
; with specifird conditions en length value specification
(add-interval-if-length seq :condition '= :length-val '1/4)
|#

;;; VERSION REVISEE PAR TORSTEN
;;; ==============================================
;;; UTILITY FUNCTIONS
;;;
(defun add-interval-if-length-aux (omn &key (test #'>) (length-val 1/8) (interval-list '(4 3 4 7 4 3 5 4 7 3)))
  (let ((s-events (single-events omn)))
    (loop 
      for e in s-events
      for i in (gen-trim (length s-events) interval-list)
      when (funcall test (omn-encode (first e)) length-val)
      append (omn-replace :pitch (chord-interval-add (list i) (list (second e))) e)
      else append e)))

;(add-interval-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '(10 11))

;;; =============================
;;; MAIN FUNCTION
(defun add-interval-if-length (omn &key (test #'>) (length-val 1/8) (interval-list '(4 3 4 7 4 3 5 4 7 3)))
  (do-verbose ("add-interval-if-length")
    (let ((test-fn (case test
                     (> #'>)
                     (< #'<)
                     (= #'=)
                     (otherwise test))))
      (if (listp (car omn))
        (mapcar #'(lambda (x) 
                    (add-interval-if-length-aux x :test test-fn :length-val (omn-encode length-val) :interval-list interval-list)) 
                omn)
        (add-interval-if-length-aux omn :test test-fn :length-val (omn-encode length-val) :interval-list interval-list)))))
  

;(add-interval-if-length '((q c4 d4 e4 f4 e g4 a4) (e f4 e4 q d4 c4 a4 g4 f4)) :interval-list '(10 11))
;(add-interval-if-length '((q c4 d4 e4 f4 e g4 a4) (e f4 e4 q d4 c4 a4 g4 h f4)) :interval-list '(3 4) :test #'>= :length-val 'q)

 

you can setf a phrase processed first by this function and another one with another processing with the same function but with other parameters:

(setf seq '((e c4 p stacc d4 stacc e4 stacc f4 stacc q g4 g3)
            (q c4 mf e c6 b5 a5 g5 f5 d5)
            (s e4 f4 e4 d4 q g4 b4 d5)
            (q g5 ff marc g4 marc h c5 )))

; with default parameters
(setf proc1 (add-interval-if-length seq))

(setf proc2 (add-interval-if-length proc1 :interval-list '(3 4) :test #'>= :length-val 'q))

SB.

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