Skip to content
View in the app

A better way to browse. Learn more.

Learn more

ratios-to-integers and back

Featured Replies

Make a length sequence integer-valued using the least common multiple, then apply the proportions to gen-length. Another kind of augmentation/diminution.

(defun ratios-to-integers (lst)
  (let* ((lcm (reduce #'lcm (denominators lst))))
    (mapcar (lambda (x) (* x lcm)) lst)))


;; a rhythm to integers via LCM
(list-plot
    (ratios-to-integers
     '(1/12 1/16 1/20 1/24 1/28)) :join-points t)

;; gen same proportions with 1/32
(list-plot
    (gen-length 
     (ratios-to-integers
      '(1/12 1/16 1/20 1/24 1/28))
     1/32)
 :join-points t)


;; very strange proportions back to gen-length 1/32
(gen-length 
     (ratios-to-integers
      '(1/12 -3/12 5/20 1/16 -1/20 1/24 1/28))
     1/32)
  • Author

Slightly extended, but much more interesting/usefull...

The function has been extended in a very simple way: you can now optionally specify the denominator. This means you can convert to arbitrary base units (e.g., 1/16 → 1/12) while keeping the proportions intact. Of course, there are some very special rhythms when different denominators occur within the sequence—like in this example with 1/16 and then also 1/20. Actually, it’s a tempo change.

And if you were to apply the OPMO function <length-rational-quantize> as well, you could then integrate it in a usable way.


(defun ratios-to-integers2 (lst &key (denom nil))
  (let* ((lcm (if (null denom) 
                  (reduce #'lcm (denominators lst))
                denom)))
    (mapcar (lambda (x) (* x lcm)) lst)))



;; EXAMPLE: for "TEMPO-CHANGE"; from 1/16- to 1/12-base

;; 1. a rhythm: take 16 as denominator => all 16,8,4 ... resulting as integers, the rest as ratios

(ratios-to-integers2 '(1/8 1/16 1/16 -3/16 1/16 2/20 1/20 1/4)
                     :denom 16)


=> (2 1 1 -3 1 8/5 4/5 4)




;; 2. create new rhythm with BASE 1/12 (instead of 1/16) - all proportions remain preserved, now based on 1/12. 

(gen-length (ratios-to-integers2 '(1/8 1/16 1/16 -3/16 1/16 2/20 1/20 1/4)
                                 :denom 16)
            1/12)

=> (1/6 1/12 1/12 -1/4 1/12 2/15 1/15 1/3)

Create an account or sign in to comment

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.