Jump to content

# Length-Legato opposite function

## Recommended Posts

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

##### Share on other sites

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

##### Share on other sites

Dear Andre,

Thank you!

Very nice example. I will study this.

Best

Julio

##### Share on other sites

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

```

##### Share on other sites

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

##### Share on other sites

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

##### Share on other sites

Thanks a lot, Ole!

Best,

Julio

##### Share on other sites

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!

##### Share on other sites

Yes, Hope he read throught this. Always amazing ideas coming. Best Julio

##### Share on other sites

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

##### Share on other sites

Tested !!!

It works !!

No XML bug and works w/ sublists.

Thanks André !!

You rock !

Best,

Julio

##### Share on other sites

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.

thanks a lot!

##### Share on other sites

• 8 months later...

length-staccato:

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×

• Lessons
• #### Downloads

• Buy
• Clubs
×
• Create New...