Jump to content

OMN processing function creation example


Recommended Posts

Hi,

 

Here is a short example of OMN deconstruction/reconstruction technique useful when you want to do functions for working directly with omn.

 

;; Example of function application based on binary-list.              
(flatten (do-section '(0 1 0) '(chord-interval-add '(4)  x) (mclist '(c4 d4 e4))))

;;; Function example to search for '1/4 length and process the corresponding
;;; pitch for add Major 3rd interval when '1/4 is found.
;;; It is also a good example of deconstruction/reconstruction of OMN 
;;; inside a function

(defun add-3rd-quarter (omn)
  (let ((plist (disassemble-omn omn)))
    (setf (getf plist :pitch)
          (flatten 
           (do-section
            (binary-invert (gen-binary-remove '1/4 (getf plist :length)))
            '(chord-interval-add '(4) x)
            (mclist (getf plist :pitch)))))
    (apply 'make-omn plist)))

(add-3rd-quarter '(e c4 p d4 q e4 f stacc e f4 p a4 q g4 f stacc))
=> (e c4 p d4 q e4gs4 f stacc e f4 p a4 q g4b4 f stacc)

SB.

Link to comment
Share on other sites

an other solution... same result...

greetings

andré

;;; by using SINGLE-EVENTS ->  my preferred tool

(defun alt-add-3rd-quarter (omn-list)
  (loop for i in (single-events omn-list)
    when (equal (first i) 'q)
    append (omn-replace :pitch (chord-interval-add '(4) (list (second i))) i)
    else append i))
  

(alt-add-3rd-quarter '(e c4 p d4 q e4 f stacc e f4 p a4 q g4 f stacc))
=> (e c4 p e d4 p q e4gs4 f stacc e f4 p e a4 p q g4b4 f stacc)

 

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