Jump to content
Sign in to follow this  
AM

replace-articulation-of-a-pitch

Recommended Posts

i didn't find a OM-library-solution for this kind of thing, so i coded it...

 

if you want to REPLACE the articulation of some specific pitches. perhaps all 'd4 sould be PONTE... you could use this.

it was necessary to code it like that, because otherwise you get in trouble with the empty parameter-slots...

 

should work fine

greetings

andré

 

;;; SUBFUNCTIONS

(defun eliminate-nil (alist)
  (loop for i in alist
    when (not (null i))
    collect i))

(defun complete-event-slots (omn-list)
  (let ((omn-art (omn :articulation (single-events (flatten omn-list)))))
    (single-events 
     (omn-replace :articulation (flatten 
                                 (eliminate-nil (loop for i in omn-art
                                                  for cnt = 0 then (incf cnt)
                                                  when (equal (car i) '-)
                                                  collect (nth (1- cnt) omn-art)
                                                  else collect i)))
                omn-list))))

;(complete-event-slots '(5q a4 ff pizz 5q e3 -e 5q a4 f))


;;; MAIN FUNCTION

(defun replace-articulation-of-a-pitch (omn-list &key pitches articulation (chance 1.0))
  (loop for i in (complete-event-slots (flatten omn-list))
    when (and (member (car (omn :pitch i)) pitches)
              (prob? chance))
    append (omn-component-replace i (list articulation))
    else append i))





;;; EXAMPLE
(replace-articulation-of-a-pitch '(5q a4 ff pizz 5q e3 p -q 5q d4 pizz)
                                 :pitches '(a4 d4) 
                                 :articulation 'ponte
                                 :chance 1.0)

-> (5q a4 ff ponte 5q e3 p pizz -q 5q d4 p ponte)

 

Edited by AM
missing subfunction, now changed

Share this post


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.

Sign in to follow this  

×
×
  • Create New...