Posted December 15, 20177 yr Dear Friends, What is the exact opposite function of length-legato ? Lenght-legato turns this: onto this: I want exactly the reverse: Changing this: to this: Thanks for help ! Best ! Julio
December 15, 20177 yr dear julio i don't know if there is a solution in the om-library... coded quickly one for your problem... the basic-rhythms (denominator) should stay constant like in your examples, then it works... first value has to be your "stacc-length", second your omn-list or a length-list, have a look to the example... greetings andré (defun length-staccato (n alist) (let ((newlengths (loop for i in (omn :length alist) when (> i 0) append (list n (* -1 (abs (- i n)))) else collect i))) (if (omn-formp alist) (make-omn :length newlengths :pitch (omn :pitch alist) :velocity (omn :velocity alist) :articulation (omn :articulation alist)) newlengths))) (length-staccato 1/16 '(q e4 mp q tasto q -q q q))
December 15, 20177 yr Hi, Just a minor improvement, the function is now also working with sublists :-) best ole (defun length-staccato-lists (n alist) (let ((newlengths (loop for i in (omn :length (flatten alist)) when (> i 0) append (list n (* -1 (abs (- i n)))) else collect i))) (if (omn-formp alist) (omn-to-time-signature (make-omn :length newlengths :pitch (omn :pitch alist) :velocity (omn :velocity alist) :articulation (omn :articulation alist)) (get-time-signature alist)) newlengths))) (length-staccato-lists 1/16 '((q e4 mp q tasto q -q q q)(q e4 mp q tasto q -q q q))) -->((s e4 mp -e. s e4 tasto -e. s e4 -e. -q s e4 -e. s e4 -e.) (s e4 -e. s e4 tasto -e. s e4 -e. -q s e4 -e. s e4 -e.))
December 15, 20177 yr Author Thanks a lot, Ole ! I noticed that problem. I got a strange musicXML result when evaluating this: (length-staccato-lists 1/16 '((e. c4 eb4 fs4 a4 tie) (s a4 e. cs4 e4 g4 e bb4 tie) (e bb4 e. d4 f4 gs4 s b4))) In the screen it appears somewhat buggy and in the XML, the result is unaltered (no staccato at all) Best ! Julio bugxml_lengthfunction2.xml
December 15, 20177 yr Hi Julio, I've found two problems. The weird one you had I think I could find and solve, but the function also does not handle tied notes properly and I have no idea how to remedy that. That goes waay above my hacking abilities :-) (length-staccato 1/16 '((e. c4 eb4 fs4 a4 tie) (s a4 e. cs4 e4 g4 e bb4 tie) (e bb4 e. d4 f4 gs4 s b4))) -->((s c4 -e s eb4 -e s fs4 -e s a4 -e) (s a4 cs4 -e s e4 -e s g4 -e s bb4 -) (s bb4 - d4 -e s f4 -e s gs4 -e s b4)) Nevertheless the code with the one correction, so it's not perfect but maybe somehow useful for you.. best ole (defun length-staccato (n alist) (let ((newlengths (loop for i in (omn :length (flatten alist)) when (> i n) append (list n (* -1 (abs (- i n)))) else collect i))) (if (omn-formp alist) (omn-to-time-signature (make-omn :length newlengths :pitch (omn :pitch alist) :velocity (omn :velocity alist) :articulation (omn :articulation alist)) (get-time-signature alist)) newlengths)))
December 15, 20177 yr You are welcome! Maybe Janusz can chime in and tell us something about how to handle tied notes in functions like this. I really would like to know that!
December 15, 20177 yr Author Yes, Hope he read throught this. Always amazing ideas coming. Best Julio
December 15, 20177 yr the solution... (defun length-staccato (n alist) (let ((newlengths) (new-omn (omn-merge-ties (flatten alist))) (time-sign (get-time-signature alist))) (progn (setf newlengths (loop for i in (omn :length new-omn) when (> i 0) append (if (= n i) (list i) (list n (* -1 (abs (- i n))))) else collect i)) (if (omn-formp alist) (omn-to-time-signature (make-omn :length newlengths :pitch (omn :pitch new-omn) :velocity (omn :velocity new-omn) :articulation (omn :articulation new-omn)) time-sign) newlengths)))) (length-staccato 1/16 '(q -q q q)) (length-staccato 1/16 '(q e4 mp q tasto q -q q q)) (length-staccato 1/16 '((e. c4 eb4 fs4 a4 tie) (s a4 e. cs4 e4 g4 e bb4 tie) (e bb4 e. d4 f4 gs4 s b4)))
December 15, 20177 yr Author Tested !!! It works !! No XML bug and works w/ sublists. Thanks André !! You rock ! Best, Julio
December 15, 20177 yr it was necessary to re-organize "OMN with ties" by "omn-merge-ties" first... and find a solution if staccato-length = length ... added 2 minutes later you're welcome... it's a bit like "BRAINFOOD" solving such things... but TORSTEN is the "code-master" for the complicated things!! 🙂 so, i have to compose now, the real hard work.
Create an account or sign in to comment