Jump to content

Recommended Posts

Hi,

i've made this function for my own usage.

Sharing here if it can be useful for some others.

It is a function who replace articulation by a given one on repeated notes.

Best

SB.

 

;;; OMN-REPLACE-ARTICULATION-IF-REPEAT

(defun omn-replace-articulation-if-repeat (new-art omn-sequence)
  (do-verbose ("omn-replace-articulation-if-repeat")
  (let ((spn '())
        (res '())
        )
 (progn
   (setf spn (get-span omn-sequence))
   (setf res
   (loop for i from 0 to (- (length (flatten-sublist (single-events omn-sequence))) 1)
     collect
     (if (or 
          (eq (second (nth i (flatten-sublist (single-events omn-sequence)))) (second (nth (+ 1 i) (flatten-sublist (single-events omn-sequence)))))
          (if (>  i 0)
            (eq (second (nth i (flatten-sublist (single-events omn-sequence)))) (second (nth (- i 1) (flatten-sublist (single-events omn-sequence)))))
            )
          )
       (omn-replace :articulation new-art (nth i (flatten-sublist (single-events omn-sequence))))
       (nth i (flatten-sublist (single-events omn-sequence)))
       )))
   (length-span spn (flatten res))))))


;;; EXEMPLE
#|
(setf mat '((s c4 p leg d4 leg e4 leg f4 q g4 f marc)(s a4 mp leg g4 leg leg f4 leg e4 leg leg  leg d4 q c4 mf marc)))

(omn-replace-articulation-if-repeat '(stacc) mat)

=> '((s c4 p leg d4 leg e4 leg f4 q g4 f marc) (s a4 mp leg g4 stacc g4 stacc f4 leg e4 stacc e4 stacc e4 stacc d4 q c4 mf marc))
|#

 

 

Link to post
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