evolving rhythms
Good Morning,
i am still working on continuous parameter spaces in music composition. yesterday i wrote a simple Scheme code, which calculates interpolated values between two rhythmic sets.
arguments are:
the rhythms,
the step quantity [which determines the extent of the evolution],
the step duration [that changes the actual tempo]
and the file name [since the code outputs the data by default as a midi file].
i uploaded a sound example and Scheme code, which unfolds the evolution between the rhythms shown below.
download the code via:
ritm-interp.scm
download the sound via:
ritm-interp.mp3
;;generates interpolated values between two rhythmic sets;
(define (rhythm-interp-2 ritm1 ritm2 step step-dur file) ;
(let* ((len-ritm1 (length ritm1))
(len-ritm2 (length ritm2))
(short (if (< len-ritm1 len-ritm2) ritm1 ritm2))
(long (if (< len-ritm1 len-ritm2) ritm2 ritm1))
(new (if (< len-ritm1 len-ritm2) (make-vector len-ritm2 0) (make-vector len-ritm1 0)))
(new-alt (if (< len-ritm1 len-ritm2) (make-vector len-ritm2 0) (make-vector len-ritm1 0)))
(output (list)))
(loop for i in (vector->list new)
for i-c from 0
for i-c2 = (rescale i-c 0 (- (length new) 1) 0 (- (length short) 1))
do
(vector-set! new i-c (vector-ref short (int i-c2))))
(if (< len-ritm1 len-ritm2)
(loop for ri from 0 to step by step-dur
for ri-nrmlzd = (/ ri step)
do
(set! output
(append output
(unique (loop for alt-i in (vector->list new)
for alt from 0
do
(vector-set! new alt (interp ri-nrmlzd `(0 ,(vector-ref new alt) 0.1 ,(vector-ref new alt) .9 ,(vector-ref ritm2 alt) 1 ,(vector-ref ritm2 alt)) 1))
collect (+ ri (rescale (vector-ref new alt) 0 1 0 step-dur)))))))
(loop for ri from 0 to step by step-dur
for ri-nrmlzd = (/ ri step)
do
(set! output
(append output (unique (loop for alt-i in (vector->list ritm1)
for alt from 0
do
(vector-set! new-alt alt (interp ri-nrmlzd `(0 ,(vector-ref ritm1 alt) 0.1 ,(vector-ref ritm1 alt) .9 ,(vector-ref new alt) 1 ,(vector-ref new alt)) 1))
collect (+ ri (rescale (vector-ref new-alt alt) 0 1 0 step-dur))))))))
(with-midi (file)
(loop for fi in output
do
(send "mp:midi" :time fi :key (between 40 67) :amp 60)))
output))
(rhythm-interp-2 #(0.0 0.0625 0.1875 0.25 0.3125 0.375 0.4375 0.5 0.5625 0.6875 0.75)
#(0 .33 .6) 40 2 "~/ritm.mid")
ritm-interp by Aykut Caglayan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
i am still working on continuous parameter spaces in music composition. yesterday i wrote a simple Scheme code, which calculates interpolated values between two rhythmic sets.
arguments are:
the rhythms,
the step quantity [which determines the extent of the evolution],
the step duration [that changes the actual tempo]
and the file name [since the code outputs the data by default as a midi file].
i uploaded a sound example and Scheme code, which unfolds the evolution between the rhythms shown below.
download the code via:
ritm-interp.scm
if you want to run/hack the code, install first the Grace
download the sound via:
ritm-interp.mp3
;;generates interpolated values between two rhythmic sets;
(define (rhythm-interp-2 ritm1 ritm2 step step-dur file) ;
(let* ((len-ritm1 (length ritm1))
(len-ritm2 (length ritm2))
(short (if (< len-ritm1 len-ritm2) ritm1 ritm2))
(long (if (< len-ritm1 len-ritm2) ritm2 ritm1))
(new (if (< len-ritm1 len-ritm2) (make-vector len-ritm2 0) (make-vector len-ritm1 0)))
(new-alt (if (< len-ritm1 len-ritm2) (make-vector len-ritm2 0) (make-vector len-ritm1 0)))
(output (list)))
(loop for i in (vector->list new)
for i-c from 0
for i-c2 = (rescale i-c 0 (- (length new) 1) 0 (- (length short) 1))
do
(vector-set! new i-c (vector-ref short (int i-c2))))
(if (< len-ritm1 len-ritm2)
(loop for ri from 0 to step by step-dur
for ri-nrmlzd = (/ ri step)
do
(set! output
(append output
(unique (loop for alt-i in (vector->list new)
for alt from 0
do
(vector-set! new alt (interp ri-nrmlzd `(0 ,(vector-ref new alt) 0.1 ,(vector-ref new alt) .9 ,(vector-ref ritm2 alt) 1 ,(vector-ref ritm2 alt)) 1))
collect (+ ri (rescale (vector-ref new alt) 0 1 0 step-dur)))))))
(loop for ri from 0 to step by step-dur
for ri-nrmlzd = (/ ri step)
do
(set! output
(append output (unique (loop for alt-i in (vector->list ritm1)
for alt from 0
do
(vector-set! new-alt alt (interp ri-nrmlzd `(0 ,(vector-ref ritm1 alt) 0.1 ,(vector-ref ritm1 alt) .9 ,(vector-ref new alt) 1 ,(vector-ref new alt)) 1))
collect (+ ri (rescale (vector-ref new-alt alt) 0 1 0 step-dur))))))))
(with-midi (file)
(loop for fi in output
do
(send "mp:midi" :time fi :key (between 40 67) :amp 60)))
output))
(rhythm-interp-2 #(0.0 0.0625 0.1875 0.25 0.3125 0.375 0.4375 0.5 0.5625 0.6875 0.75)
#(0 .33 .6) 40 2 "~/ritm.mid")
ritm-interp by Aykut Caglayan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Comments
Post a Comment