Jump to content

Rhythmically Odd Rhythms


Recommended Posts

I am reading a very good book "The Geometry of Musical Rhythms". Chapter 15 discusses an interesting idea called "Rhythmic Oddity". In today's blog of mine, I have briefly written about this idea and how it can be implemented in Opusmodus. 

 

Hope members will find it useful in their work. Do read the book for many great insights!

 

Regards,

Rangarajan

Link to comment
Share on other sites

Good result indeed (score). I like your coding stile and your knowledge of lisp.

The only problem here is that we can end with NIL.

I don't have the book therefore I can comment on possible solution to avoid the NIL result.

 

In theory - I think - we could make something like:

(defun binary-series (size number &key rotate)
  (let* ((binary (decimal-to-binary number))
         (out (gen-repeat size binary)))
    (if rotate (gen-rotate rotate out) out)))
        
(binary-series 22 4)
=> (1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0)

 

Other possibility (flexibility):

(defun binary-series (size number level &key rotate)
  (let* ((binary (reverse (binary-level number level)))
         (out (gen-repeat size binary)))
    (if rotate (gen-rotate rotate out) out)))
        
(binary-series 8 1 2)
=> (1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)

(binary-series 8 1 3)
=> (1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0)

(binary-series 8 1 4)
=> (1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0)

(binary-series 8 3 4)
=> (1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0)

(binary-series 8 3 6)
=> (1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0)

 

I will add the BINARY-SERIES function to our system with few more options.

Thank you Rangarajan for the inspiration.

Link to comment
Share on other sites

Hi Janusz,

Thanks for your comment. The function is expected to return NIL if num-pulses argument is ODD or if the rhythmic oddity cannot be satisfied for the given set of arguments. 

 

I think the function you have given solves a different problem.

 

Regards,

Rangarajan

Link to comment
Share on other sites

Done. The final function:

 

;; -------------------------------------------------------------------------
;; gen-binary-series
;; -------------------------------------------------------------------------

(defun gen-binary-series (size number level &key rotate variant seed)
  (do-verbose ("gen-binary-series")
    (rnd-seed seed)
    (flet ((binary-series (size number level &key rotate)
             (let* ((binary (reverse (binary-level number level)))
                    (out (gen-trim* size binary)))
               (if rotate (gen-rotate rotate out) out))))
      
      (let* ((size (list! size))
             (number (list! number))
             (level (list! level))
             (len (find-max (mapcar 'length (list size number level))))
             (series (mapcar #'(lambda (a b c d) (binary-series a b c :rotate d))
                             (gen-trim* len size)
                             (gen-trim* len number)
                             (gen-trim* len level)
                             (gen-trim* len (list! rotate))))
             (out (if (and (listsp series) (< 1 (length series))) series (car series))))
        (if variant (binary-variant out variant :seed (seed)) out)))))


(gen-binary-series 24 1 2)
=> (1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)

(gen-binary-series 24 1 '(3 2 4))
=> ((1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0)
    (1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0)
    (1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0))

(gen-binary-series 24 '(1 3 4) '(3 5 4) :rotate -2)
=> ((0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0)
    (0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1)
    (1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0))

(gen-binary-series '(8 12 16) '(1 3 4) '(3 5 4) :rotate '(1 -1 0))
=> ((0 1 0 0 1 0 0 1)
    (1 0 0 0 1 1 0 0 0 1 1 1)
    (0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0))

(gen-binary-series '(8 12 16) '(1 3 4) '(3 5 4)
                   :rotate '(1 -1 0) :variant '? :seed 786)
=> ((0 1 0 0 1 0 0 1) (1 0 0 0 1 1 0 0 0 1 1 1) (1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1))

(gen-binary-series '(8 12 16) '(1 3 4) '(3 5 4)
                   :rotate '(1 -1 0) :variant '(? r ri) :seed 786)
=> ((0 1 0 0 1 0 0 1) (1 1 1 0 0 0 1 1 0 0 0 1) (1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1))

Added variant as well.

Link to comment
Share on other sites

That was quick!

 

One of the biggest challenges in mastering a powerful platform such as Opusmodus is getting the bigger picture, and learning to use the wide variety of functions in the library. I hope someone writes a great "Beginners" guide to working with the software!

 

Regards,

Rangarajan

Link to comment
Share on other sites

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