April 10Apr 10 Hello, OpusmodersSometime ago I was here searching for a function to displace rhtyhms by a length amount, not just like a list rotation.Now I did this prototype. I think that this can be very useful, specially inside counterpoint dictums where patterns can be displaced ( I did not tried inside the counterpoint function but seems like it will work).Hope it can be useful to you too.All the best,Julio(defun shift-rhythm (rhythm shift-length &key span);"Moves rhythmic material by inserting a pause at the beginning.;Use length-adjust to ensure the result fits within the span."(let* ((rhy (flatten rhythm));;;; Ensures a linear list for processing;; Adds the offset value as a negative pause at the beginning [5](with-offset (append (list (- (abs shift-length))) rhy));;Define the target span: either the requested one or the original rhythm.(target-span (or span (get-span rhythm))));; The length-adjust function adjusts the total to the desired span [1].;; With :position 'e (default), it removes or adds from the end of the list [6].(length-adjust target-span with-offset :omn t :type 'r)));;; USE;Exemplo 1: Span de 4/4 (1/1)(setf ideia '(e c5 e d4 q f4 -h)) ;; Span original de 1/1(shift-rhythm ideia 1/8 :span 3/4);; (-e e c5 d4 q f4 -e)(shift-rhythm ideia 3/8 :span 5/4);; (-q. e c5 d4 q f4 -q.)also with negative displacement(setf ideia '(-h e c5 e d4 q f4 -h))(shift-rhythm ideia -1/8 :span 7/4);;(-e -h e c5 d4 q f4 -h -e)It could be perfected to deal with nested sublists and with different displacements for each sublist, like(setf ideia '((-h e c5 e d4 q f4 -h)(-h e c5 e d4 q f4 -h.)(-h e c5 e d4 q f4 -q))(shift-rhythm ideia '((-1/8) (2/16) (3/8)) :span 7/4)etc
Create an account or sign in to comment