Jump to content

Recommended Posts

Posted

Dear Friends,

 

What is the exact opposite function of length-legato ?

 

Lenght-legato turns this:

 

image.png.a479c853c70760bf5c1c34348aa0e0bf.png

 

onto this:

 

image.png.a012187a1aa8dc4196691bd3bc370b53.png

 

I want exactly the reverse:

Changing this:

image.png.85b853406242cd7fa71fdf078b6c726f.png

to this:

image.png.a479c853c70760bf5c1c34348aa0e0bf.png

 

Thanks for help !

 

Best !

Julio

Posted

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))

 

 

Posted

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.))

Posted

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

screen_BUG.png.4d5181f04673c6792719f9153537fc03.png

bugxml_lengthfunction2.xml

Posted

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))

 

5a343ccd0afd1_Bildschirmfoto2017-12-15um22_17_58.jpg.aac8244db0091797b20ab8e21271ef2e.jpg

 

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))) 

Posted

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)))

 

Posted

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.

  • 8 months later...

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