128 lines
4.8 KiB
Common Lisp
128 lines
4.8 KiB
Common Lisp
|
|
(in-package #:cl-patterns)
|
|
|
|
(pb :notes
|
|
:degree (pseq (list 0 1 2 3) 1))
|
|
;; (play :notes)
|
|
;; (stop :notes)
|
|
|
|
(setq *notes* (pseq (list 0 1 2 3)))
|
|
(pb :just-*notes*
|
|
:degree *notes*)
|
|
;; (play :just-*notes*)
|
|
;; (stop :just-*notes*)
|
|
;;
|
|
;; but that would certainly not help with changing other params
|
|
;; "per phrase"
|
|
|
|
|
|
(pb :attempt-at-repeating-pattern
|
|
:degree (pseq (list 0 1 2 3) 2)
|
|
:octave (pr (pwhite 2 5))
|
|
)
|
|
;; (play :attempt-at-repeating-pattern)
|
|
;; (end :attempt-at-repeating-pattern)
|
|
;; (stop :attempt-at-repeating-pattern)
|
|
|
|
;; how does that work? why octave only changes after the degree pseq ends?
|
|
|
|
(in-package #:cl-patterns)
|
|
;; (next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2) 1)))
|
|
;; this started some computations in sbcl, which are in backgournd and I don't know how to stop
|
|
;; (defpattern pr (pattern)
|
|
;; (pattern
|
|
;; (repeats :initform :inf)
|
|
;; (current-value :state t :initform nil)
|
|
;; (current-repeats-remaining :state t))
|
|
;; :documentation "Repeat each value from PATTERN REPEATS times. If REPEATS is 0, the value is skipped.
|
|
|
|
;; Example:
|
|
|
|
;; (next-upto-n (pr (pseries) (pseq '(1 3 0 2) 1)))
|
|
;; ;=> (0 1 1 1 3 3)
|
|
|
|
;; See also: `pdurstutter', `pn', `pdrop', `parp'")
|
|
|
|
(in-package #:cl-patterns)
|
|
(next-upto-n (pseq '(1 2 3) 6) 4)
|
|
(next-upto-n (pwhite 2 7) 4)
|
|
(next-upto-n (pr (pwhite 2 7) 3) 7)
|
|
(next-upto-n (pr (pwhite 2 7) (list 1 2 3)) 7)
|
|
(next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2) 1)) 10) ; still not working?
|
|
(next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2) 1)) 6) ; for some reason works up to 6
|
|
(next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2) 1)) 7) ; for some reason works up to 6
|
|
;;; so, if I go into M-x sly-list-threads - I see worker threads,
|
|
;;; and I could kill them, but also could d for debug, and "return value from thread", then that value is appended as 7th iteam
|
|
;;; so the stream gets frozen, waiting for something to compute?
|
|
; well, I guess OBJECT is stream that always repeats itself
|
|
; so when I just put 3 or 4 - that's endless stream of 3s and 4s
|
|
;; and to have pseq work - I need to remove that "1" and pseq would repeat forever, and numbers from pseq would be "multipliers" for endless stream of random numbers
|
|
;; and random numbers would be new for second circle?
|
|
|
|
(next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2) 2)) 7) ; yep
|
|
(next-upto-n (pr (pwhite 2 7) (pseq '(1 3 0 2))) 17) ; yep
|
|
|
|
;; so when "automatic jazz" https://github.com/defaultxr/cl-patterns/blob/master/doc/cookbook.org#random-notes-from-a-scale
|
|
;; does :octave (pr (pwhite 2 7))
|
|
;; that means repeat (randomly selected from 2 to 7) "forever/until end of pattern"
|
|
;; and end of pattern doesn't come from the :octave or :root
|
|
;; but comes from the fact that #'PSHUF for :note has "end after 4"
|
|
;; cool
|
|
|
|
;; so to have sequence of parameters that apply for whole melody
|
|
;; I'd need "pr forever" and then take items from the list, so from pseq
|
|
|
|
(pb :at-repeating-pattern
|
|
;; :degree (pseq (list 0 1 2 3) 2)
|
|
:note (pshuf (scale-notes :minor) 1)
|
|
:octave (pr (pseq (list 3 4 5)))
|
|
)
|
|
;; (play :at-repeating-pattern)
|
|
;; (end :at-repeating-pattern)
|
|
;; (stop :at-repeating-pattern)
|
|
|
|
(next-upto-n (pdef :at-repeating-pattern) 20)
|
|
;; well, no, I don't understand after all!
|
|
;; the pattern ends when :degree or :note part ends, and not restarts
|
|
;; let's just copy "automatic jazz" and view it with #'NEXT-UPTO-N
|
|
|
|
(pb :automatic-jazz
|
|
:note (pshuf (scale-notes :minor) 4)
|
|
:octave (pr (pwhite 2 7))
|
|
:root (pr (pwhite 0 12))
|
|
:dur (pshuf (list 1/3 1/4)))
|
|
;; (play :automatic-jazz)
|
|
;; (end :automatic-jazz)
|
|
;; (stop :automatic-jazz)
|
|
|
|
(next-upto-n (pdef :automatic-jazz) 30)
|
|
;; well, maybe pr only doesn't work with pseq, since it always selects first from the stream?
|
|
|
|
(pb :at-with-random-repeating-pattern
|
|
:degree (pseq (list 0 1 2 3) 2)
|
|
:octave (pr (pwhite 3 5))
|
|
)
|
|
;; (play :at-with-random-repeating-pattern)
|
|
;; (end :at-with-random-repeating-pattern)
|
|
;; (stop :at-with-random-repeating-pattern)
|
|
|
|
;;; hm, not exactly what I imagined in a way of combining patterns
|
|
|
|
;; then I guess, I want the melody to repeat in pseq endlessly, and match pr repeat size to length of melody (in events, and not beats, alas!)
|
|
;; and use something like pxrand and end with end of pxrands
|
|
;; even though that is not yet satisfactory, let's try it
|
|
|
|
(pb :at-with-outside-pseq-repeating-pattern
|
|
:degree (pseq (list 0 1 2 3))
|
|
:octave (pr (pseq (list 3 4 5 4 3)) 4)
|
|
)
|
|
;; (play :at-with-outside-pseq-repeating-pattern)
|
|
;; (end :at-with-outside-pseq-repeating-pattern)
|
|
;; (stop :at-with-outside-pseq-repeating-pattern)
|
|
(next-upto-n (pdef :at-with-outside-pseq-repeating-pattern) 12)
|
|
|
|
;; so I guess when the pattern "repeats" it will be "exactly same" with randoms recalculated
|
|
;; also - can I save the seeds? in case I'd like to record a random sequence that I liked on the walkthough?
|
|
|
|
;; also - how would I specify "a multiplier" for durations? if the notes are not of the same duration
|