Jump to content

omn-pitch-position-remove / omn-position-remove


Recommended Posts

;;; removes pitches by its position-number, will be replaced by rests. (starts with 0)

(defun omn-pitch-position-remove (positions omnseq)
  (length-rest-merge (loop for i in (single-events omnseq)
                       with cnt = 0
                       
                       when (and (pitchp (cadr i)) 
                                 (not (equal 'nil (member cnt positions))))
                       append (make-omn :length (list (length-invert (car i))))
                       else append i
                       
                       when (pitchp (cadr i))
                       do (incf cnt))))


(omn-pitch-position-remove '(0 1) '(-q e c4 e d4 e e4 e e e e))
=> (-h e e4 mf e4 e4 e4 e4)

(omn-pitch-position-remove '(2 4) '(-q e c4 e d4 e e4 e e e e))
=> (-q e c4 mf d4 - e4 - e4 e4)

or more common

 



(defun omn-position-remove (positions omnseq &key (type 'pitch))
  (length-rest-merge (loop for i in (single-events omnseq)
                       with cnt = 0
                       
                       when (and (cond ((equal type 'pitch)
                                        (pitchp (cadr i)))
                                       ((equal type 'length)
                                        (lengthp (car i))))                                     
                                 (not (equal 'nil (member cnt positions))))

                       append (make-omn :length (list (length-invert (car i))))
                       else append i
                       
                       when (cond ((equal type 'pitch)
                                   (pitchp (cadr i)))
                                  ((equal type 'length)
                                   (lengthp (car i))))
                       do (incf cnt))))

(omn-position-remove '(2 4) '(-q e c4 e d4 e e4 e e e e) :type 'pitch)
=> (-q e c4 mf d4 - e4 - e4 e4)

(omn-position-remove '(0 4) '(e c4 e d4 e e4 e e e e) :type 'length)
=> (-e d4 mf e4 e4 - e4 e4)

could be also extended for articulation/velocity

 

Edited by AM
edited function
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