Jump to content

Recommended Posts

;;; ADD-RND-DUST TO LENGTHS
;;; this function adding RANDOMLY some "dust" to the LENGTHS, so it will be like a little rubato,
;;; or "humanizing"-effect. the ADD-SPAN is in percent (0.1 = 10%) on each length-value. 

(defun add-rnd-dust (omnseq &key (span '(0.1)) (seed nil) (quantize '(1 2 3 4 5 6 7 8 9)))
  (let ((rhy (omn :length omnseq))
        (sp))
    (progn 
      (setf rhy (loop 
                  with cnt = 0
                  for i in rhy

                  do (setf sp (nth cnt span))

                  when (not (null seed))
                  do (incf seed)
                  
                  when (> i 0) 
                  collect   (+ i (car (rnd-number 1 0.0 (* i sp) :seed seed)))
                  else collect (- i (car (rnd-number 1 0.0 (* i sp) :seed seed)))
                  
                  when (< cnt (1- (length span)))
                  do (incf cnt)))

      (make-omn :length (quantize (float-to-ratio  rhy :ratio 1/1) quantize)
                :pitch (omn :pitch omnseq)
                :velocity (omn :velocity omnseq)
                :articulation (omn :articulation omnseq)))))



;;; EXAMPLE

(add-rnd-dust '(h c3 h. d3 -h q. f3 q g3) 
              :span '(0.5 0.3 0.2 0.1) 
              :quantize '(1 2 3 4 8) 
              :seed 123)

=> (ht c3 h.s. d3 -e -q -t e.._3h f3 3q_q g3)
    
(add-rnd-dust '(q c3 q d3 q e3 q f3 q g3) 
              ;;possible add-span per value (1 = 100% of the value, 0.5 = 50% etc.) 
              ;;if it's a list, it will stay on the last value of the span-list
              :span '(0.4 0.3 0 0 2) 
              ;;how to quantize new lengths
              :quantize '(1 2 4 8) 
              :seed 123)

=> (q c3 qt d3 q e3 f3 hs. g3)


(add-rnd-dust '(h c3 h. d3 h e3 q. f3 q g3) 
              :span '(0.5) ;; = every value max-add 50%
              :quantize '(1 2 3 4 8) 
              :seed 2999)

=> (hs. c3 wt d3 3w.e e3 3wq. f3 q g3)


(add-rnd-dust '(q c3 q d3 q e3 q f3 q g3) 
              :span '(0.4 0.3 0 0 2) 
              :quantize '(1 2 4 8) 
              :seed 1111)

=> (qt c3 qs d3 q e3 f3 q... g3)


(add-rnd-dust '(h c3 h d3 h e3 h f3 h g3) 
              :span '(0.3 0.2 0.1 0 0.2) 
              :quantize '(1 2 4 3 5) 
              :seed 2999)

=> (5dh. c3 5dhq. d3 h e3 f3 he g3)

 

Edited by AM
bug by omn-replace (wrong rests), new solution with make-omn, works now
Link to post
Share on other sites

@janusz: if you try the function a few times (without seed) , you will see (by cmd1), that sometimes the last TIE isn't there. i think QUANTIZE is doing this little bug... (but perhaps only a xml-display-thing?)

 

Bildschirmfoto 2019-04-25 um 22.41.43.png

 

 

Link to post
Share on other sites

an example: 

 

this is the BASIC-version (without "dust"):

all mapped in 1/32 - retrograde sorting processes (with GEN-SORT):

pitch-process from chromatic to 12tone-row (by sort) and from sorted length-values (all 1/32,

then all 1/16 etc... to more complex/mixed pattern (by sort))

 

Bildschirmfoto 2019-04-26 um 10.49.17.png

 

 

with this setup:

 

Bildschirmfoto 2019-04-26 um 10.49.48.png

 

 

the result with some "dust":

if you you have a look to the span-list above (compare with the new score) you will see:

no change at the beginning, then more and more randomized (or made flexible).

 

Bildschirmfoto 2019-04-26 um 10.48.35.png

 

Link to post
Share on other sites
18 hours ago, AM said:

@janusz: if you try the function a few times (without seed) , you will see (by cmd1), that sometimes the last TIE isn't there. i think QUANTIZE is doing this little bug... (but perhaps only a xml-display-thing?)

 

Maybe tolerance in quantize function will fix the problem:

(defun add-rnd-dust (omnseq &key (span '(0.1)) (seed nil) (quantize '(1 2 3 4 5 6 7 8 9)) (tolerance 0.05))
...)
(add-rnd-dust '(h c3 h. d3 -h q. f3 q g3) 
              :span '(0.5 0.3 0.2 0.1) 
              :quantize '(1 2 3 4 8) 
              :seed nil
              :tolerance 0.03)

 

No quantiser can take care of all the small nuances 🙂 this is why we have the tolerance option in the function.

 

I like the function.

Link to post
Share on other sites

i already did that 🙂

(defun add-rnd-dust (omnseq &key (span '(0.1)) (seed nil) (quantize '(1 2 3 4 5 6 7 8 9)) (scale 1.0) (tolerance 0.05))
  (let ((rhy (omn :length omnseq))
        (sp))
    (progn 
      (setf rhy (loop 
                  with cnt = 0
                  for i in rhy

                  do (setf sp (nth cnt span))

                  when (not (null seed))
                  do (incf seed)
                  
                  when (> i 0) 
                  collect   (+ i (car (rnd-number 1 0.0 (* i sp) :seed seed)))
                  else collect (- i (car (rnd-number 1 0.0 (* i sp) :seed seed)))
                  
                  when (< cnt (1- (length span)))
                  do (incf cnt)))

      (make-omn :length (quantize (float-to-ratio  rhy :ratio 1/1) quantize :scale scale :tolerance tolerance)
                :pitch (omn :pitch omnseq)
                :velocity (omn :velocity omnseq)
                :articulation (omn :articulation omnseq)))))

 

Link to post
Share on other sites
  • 1 month later...

With seed and will preserved all attributes:

(defun gen-rnd-dust (sequence &key (span '(0.1)) (quantize '(1 2 3 4 5 6 7 8)) (scale 1.0) (tolerance 0.05) seed)
  (let (state)
    (setf state *init-seed*)
    (setf seed (rnd-seed seed))
    (do-verbose ("gen-rnd-dust, span: ~s quantize: ~s scale: ~s tolerance: ~s seed: ~s"
                 span quantize scale tolerance seed)
      (disassembling-omn ((sequence plist) sequence :length)
        (let* ((length sequence)
               (sp)
               (out (float-to-ratio
                     (loop 
                       with cnt = 0
                       for i in length
                       do (setf sp (nth cnt span))
                       when (> i 0) 
                       collect (+ i (car (rnd-number 1 0.0 (* i sp) :seed (seed))))
                       else collect (- i (car (rnd-number 1 0.0 (* i sp) :seed (seed))))
                       when (< cnt (1- (length span)))
                       do (incf cnt))
                     :ratio 1)))
          (init-state state)
          (quantize out quantize :scale scale :tolerance tolerance))))))

or (with sublists):

(defun gen-rnd-dust (sequence &key (span '(0.1)) (quantize '(1 2 3 4 5 6 7 8)) (scale 1.0) (tolerance 0.05) seed)
  (let (state)
    (setf state *init-seed*)
    (setf seed (rnd-seed seed))
    (do-verbose ("gen-rnd-dust, span: ~s quantize: ~s scale: ~s tolerance: ~s seed: ~s"
                 span quantize scale tolerance seed)
      (let ((ts (get-time-signature sequence))
            (seq (flatten-omn sequence)))
        (omn-to-time-signature
         (disassembling-omn ((seq plist) seq :length)
           (let* ((length seq)
                  (sp)
                  (out (float-to-ratio
                        (loop 
                          with cnt = 0
                          for i in length
                          do (setf sp (nth cnt span))
                          when (> i 0) 
                          collect (+ i (car (rnd-number 1 0.0 (* i sp) :seed (seed))))
                          else collect (- i (car (rnd-number 1 0.0 (* i sp) :seed (seed))))
                          when (< cnt (1- (length span)))
                          do (incf cnt))
                        :ratio 1)))
             (init-state state)
             (quantize out quantize :scale scale :tolerance tolerance)))
         ts)))))

 

Best,

Janusz

Link to post
Share on other sites
  • 3 months later...

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.

  • Similar Topics

    • By etu
      Is there a way to reduce all of the note lengths equally, without editing each one individually in this snippet?  I suppose I could change the audition tempo to make it play faster, but I would really like to reduce the note lengths programmatically, if that's possible.
       
      (rnd-sample-seq 4 '( (h. b4 tie) (q b4 h a4 tie) (q a4 e b4 a4 q g4 tie) (h g4 e fs4 e4) (h fs4 -q) (-q h g4 tie) (q g4 e fs4 g4 q a4 tie) (h a4 e c5 b4) (h_e c5 e b4) (e c5 a4 h b4 tie) (q. b4 -e q g4 tie) (h. g4) (h. fs4) (e g4 a4 h b4 tie) (e b4 a4 b4 g4 q a4 tie) (h a4 q a4) (h. g4) (q g4 h fs4 tie) (q fs4 b4 e e4 fs4) (h. g4) (h. fs4 tie) (q fs4 h b4 tie) (h b4 q a4 tie) (h a4 e b4 a4) (h. g4) (e fs4 e4 h fs4) (-h q g4 tie) (h g4 e fs4 g4) (h. a4) (e c5 b4 h c5 tie) (e c5 b4 c5 a4 q b4 tie) (he b4 -e) (h. g4 tie) ))  
    • By Andy
      I am finding that if I have a score with two notes repeated the second note does not play when sending to my DAW. I am pretty sure this is because the notes are literally the length of the notation i.e a crotchet is exactly 480 ticks (or whatever it is in ticks) which causes the second note, not being a different pitch, to not play. Is there a way round this?
    • By AM
      works, but only for one-time-repetiton... could you use it?
       
      (defun merge-lengths-of-a-pitch-rep (omn-seq) (let* ((omn-seq (single-events omn-seq)) (l)) (flatten (loop repeat (length omn-seq) for cnt = 0 then (incf cnt) when (equal (omn :pitch (nth cnt omn-seq)) (omn :pitch (nth (1+ cnt) omn-seq))) do (progn (setf l (length-note-merge (append (omn :length (nth cnt omn-seq)) (omn :length (nth (1+ cnt) omn-seq))))) (incf cnt)) and collect (omn-replace :length l (nth cnt omn-seq)) else collect (nth cnt omn-seq))))) (merge-lengths-of-a-pitch-rep '(e c4 mf d4 d4 e4 f4 f4)) => (e c4 mf q d4 mf e e4 mf q f4 mf)  
×
×
  • Create New...