Rangarajan Posted April 12, 2016 Share Posted April 12, 2016 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 opmo 1 Quote Link to comment Share on other sites More sharing options...
opmo Posted April 12, 2016 Share Posted April 12, 2016 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. Quote Link to comment Share on other sites More sharing options...
Rangarajan Posted April 12, 2016 Author Share Posted April 12, 2016 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 Quote Link to comment Share on other sites More sharing options...
opmo Posted April 12, 2016 Share Posted April 12, 2016 I agree Rangarajan, the BINARY-SERIES it is something else but is inspired from your solution. Quote Link to comment Share on other sites More sharing options...
Rangarajan Posted April 12, 2016 Author Share Posted April 12, 2016 Yes, BINARY-SERIES will be a useful addition to the library. Regards, Rangarajan Quote Link to comment Share on other sites More sharing options...
opmo Posted April 12, 2016 Share Posted April 12, 2016 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. Stephane Boussuge 1 Quote Link to comment Share on other sites More sharing options...
Rangarajan Posted April 12, 2016 Author Share Posted April 12, 2016 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 opmo 1 Quote Link to comment Share on other sites More sharing options...
lviklund Posted April 13, 2016 Share Posted April 13, 2016 Thank you Rangarajan. I wish I had the knowledge that you have in the LISP world. /Lasse Quote Link to comment Share on other sites More sharing options...
Rangarajan Posted April 13, 2016 Author Share Posted April 13, 2016 Oh, I think my knowledge of Lisp is just passable. Interestingly, to be able to generate good music in Opusmodus, one need not be an expert in Lisp. Regards, Rangarajan opmo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.