## Recommended Posts

For generating a harmonic rhythm, I needed to merge notes that are tied. If extracting only the length values with omn directly, then all ties are lost.

(omn :length '((h c4 pizz q arco+tie) (q h tie) (h.)))
=> ((1/2 1/4) (1/4 1/2) (3/4))

So, I wrote myself a function that merges the lengths of tied notes.

(lengths-with-merged-ties '((h c4 pizz q arco+tie) (q h tie) (h.)))
=> (1/2 1/2 5/4)

The definition is below.

Best,

Torsten

```(defun lengths-with-merged-ties (sequence)
"Returns a flat list of lengths that preserves the lengths in sequence including their tied notes.

Example:
(lengths-with-merged-ties '((h c4 pizz q arco+tie) (q h tie) (h.)))
=> (1/2 1/2 5/4)

Contrast:
(omn :length '((h c4 pizz q arco+tie) (q h tie) (h.)))
=> ((1/2 1/4) (1/4 1/2) (3/4))"
(butlast
(reduce #'(lambda (&optional accum pair2)
(when (and accum pair2)
(append
(butlast accum 2)
(if (equal (first (last accum)) 'tie)
(list (+ (first (last (butlast accum))) (first pair2)) (second pair2))
(list (first (last (butlast accum))) (first pair2) (second pair2)))
)))
(matrix-transpose
(list (omn :length (flatten-omn sequence))
(mapcar #'(lambda (arts)
(when (member 'tie arts)
'tie))
(mapcar #'disassemble-articulations
(omn :articulation (flatten-omn sequence)))))))))

;; I shared the function disassemble-articulations alongside similar functions before,
;; but repeat it here for your convenience
(defun disassemble-articulations (art)
"Splits a combined OMN articulations into a list of its individual attributes.

Example:
(disassemble-articulations 'leg+ponte)
=> (leg ponte)"
(mapcar #'intern (split-string (symbol-name art) :separator "+")))```

##### Share on other sites
```(omn-merge-ties '(q a4 stacc+tie e gliss+tie))
=> (q. a4 stacc+gliss+tie)

(omn-merge-ties '(q a4 stacc+tie e gliss))
=> (q. a4 stacc+gliss)```

##### Share on other sites

nice, but didn't found this function in the library, so you has to code...

##### Share on other sites

Great, thanks! Would you consider adding a documentation file for that function? If not, could you at least add a doc string to the code, so that it could be of use for at least more advanced users?

For everyone else: when you are searching for a function that is not documented by its own RTF file and thus cannot be found via the standard Opusmodus documentation search, you could use the following function. Some internal Opusmodus functions without standard Opusmodus documentation have at least a documentation string.

;; return all functions that contain 'omn' in their name, together with their documentation string (if there is any).

(apropos-function-documentation "omn")

The function apropos-function-documentation is defined below.

Best,

Torsten

```(defun apropos-function-documentation (my-string &optional (package *package*))
"Lists all functions that contain `my-string' alongside their documentation in a list of pairs
(<function-symbol> <doc-string>)"
(mapcar #'(lambda (x) (list x (documentation x 'function)))
(remove-if-not #'fboundp (apropos-list my-string package))))```

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account. ×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• ### Similar Topics

• By terekita
Hello,

For various reasons, I need to start with rhythms defined in one time signature and remap them. I'm having trouble doing this because of what happens to ties when you use omn :length (though I realize they are being collected under :articulation).

In this case, I'm taking bars of 4/4 regrouping into bars of 2/4.

(setf myr '( (s s -s s -e s s -s s -e t t t t s s) (e e_q -h))) (setf tr (omn-to-time-signature myr '(2 4)))
Now I take the result of the above and assign it to a new variable ( this would be the same as (setf foo tr) ):
(setf foo '((s c4 c4 - c4 -e s c4 c4) (-s c4 -e t c4 c4 c4 c4 s s) (e c4 c4 tie q) (-h)))
As you can see, there is a tie in the third bar.

Now, how can I extract that rhythm so that I can apply to another set of pitches?

If I do the following, I no longer have the tie represented in the rhythm:
(omn :length foo) ;; results in ;; ((1/16 1/16 -1/16 1/16 -1/8 1/16 1/16) (-1/16 1/16 -1/8 1/32 1/32 1/32 1/32 1/16 1/16) (1/8 1/8 1/4) (-1/2)) ;; i.e., no tie in the third bar
Also, if I try to span the rhythm onto another set of pitches, I again get a result that is missing the tie:
(setf my-pitches '(c4 d4 e4)) (make-omn :length foo :pitch my-pitches)
What I'd really love is to get back a list of lengths that is like my original list, just regrouped in new time signatures. So, ideally something like:
(setf myr '( (s s -s s -e s s -s s -e t t t t s s) (e e_q -h))) ;; imaginary function (regroup-to-two-four myr) ;;would result in the following: ;; ((s s -s s -e s s)(-s s -e t t t t s s)(e e_q)(-h))
Finally, I should add that in a related problem, I need to extract the number of attacks in a bar after it has been regrouped. So, for this reason again, I need to figure out how to extract the rhythm while preserving ties and not re-attacking tied notes.

I'd very appreciate and thank you kindly for any assistance in doing this.

Thanks very much, Michael
• By terekita
Hello,

When I take the following:
(setf lens '((e = = e tie)(e e e e))) (setf notes '((c4 d4 = d4)(d4 g4 = =))) and then call make-omn

(make-omn :length lens :pitch notes) the tie at the end of the first bar is not preserved. Nor is it if I instead have the tie at the end of the first bar of the notes list (or at the end of the first bar in both lists).

What is the proper way to construct an omn list from separate lengths and pitches such that ties are preserved? In this case I am trying to create the equivalent of the following:
(setf test '((e c4 d4 = d4 tie)(e d4 g4 = =)))
thanks very much, Michael

• By AM
;;; FUNCTION: for some coding-cases i needed THIS function, to keep the OMN-notation ;;; and not to change to RATIO (otherwise i got strange results in NOTATION because the "ties are gone") (defun length-invert** (length-val) (append (compress (list '- length-val)))) ;;; EXAMPLES ;;; new => keeps OMN (length-invert** (car '(q e4 mp))) => -q ; in this case i wanted to keep the format with tie (length-invert** (car '(3q_q e4 mp))) => -3q_q ;;; original => changes to ratio (length-invert (car '(q e4 mp))) => -1/4 ; no tie here! i was in trouble :-) (length-invert (car '(3q_q e4 mp))) => -1/3
×

• Lessons