90 lines
4.3 KiB
Common Lisp
90 lines
4.3 KiB
Common Lisp
|
|
;; let's try the pfunc to create arpegio from the chord
|
|
(in-package :cl-patterns)
|
|
(next-upto-n (pbind :chord (pseq (list :major :minor :minor-triad :major))
|
|
:note (pfunc (lambda ()
|
|
(let* ((chord (event-value *event* :chord))
|
|
(notes (nchord chord)))
|
|
;; let's keep it simple for a moment
|
|
notes))
|
|
)) 10)
|
|
;; ((EVENT :CHORD :MAJOR :NOTE (0 4 7)) (EVENT :CHORD :MINOR :NOTE (0 3 7))
|
|
;; (EVENT :CHORD :MINOR-TRIAD :NOTE (0 3 7)) (EVENT :CHORD :MAJOR :NOTE (0 4 7))
|
|
;; (EVENT :CHORD :MAJOR :NOTE (0 4 7)) (EVENT :CHORD :MINOR :NOTE (0 3 7))
|
|
;; (EVENT :CHORD :MINOR-TRIAD :NOTE (0 3 7)) (EVENT :CHORD :MAJOR :NOTE (0 4 7))
|
|
;; (EVENT :CHORD :MAJOR :NOTE (0 4 7)) (EVENT :CHORD :MINOR :NOTE (0 3 7)))
|
|
|
|
;; And I'd still in parp generator
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (pfunc (lambda ()
|
|
(let* ((chord (event-value *event* :chord))
|
|
(notes (nchord chord)))
|
|
;; let's keep it simple for a moment
|
|
(pseq notes 1)))
|
|
))) 10)
|
|
;; for some reason this stays on first chord forever, but does arpegio
|
|
;; bit of something I don't understand
|
|
|
|
(next-upto-n (parp (pbind :ocatave (pseq (list 3 4 3 5)))
|
|
(pbind :note (pseq (list 0 1 2) 1))) 12) ; needed 1 repeat limit here
|
|
|
|
;; let's try with #'PK
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (let* ((chord (pk :chord))
|
|
(notes (nchord chord)))
|
|
;; let's keep it simple for a moment
|
|
(pseq notes 1)))) 10)
|
|
;; error, no applicable method
|
|
;; how does that work then?
|
|
|
|
(pdef :foo
|
|
(parp (pbind :note (pnary #'chord-notes (pseq (list :major :minor :maj7 :maj6 :major) 1))
|
|
:dur (pseq (list 1 1 2 1 1 2)))
|
|
(pbind :note (p+ (pk :note)
|
|
(pseq (list 0 2 3 1 3 0) 1)))))
|
|
(next-upto-n (pdef :foo) 10)
|
|
;; and what if I change :note to :chord here?
|
|
|
|
(next-upto-n (pdef :foo
|
|
(parp (pbind :chord (pnary #'chord-notes (pseq (list :major :minor :maj7 :maj6 :major) 1))
|
|
:dur (pseq (list 1 1 2 1 1 2)))
|
|
(pbind :note (p+ (pk :chord)
|
|
(pseq (list 0 2 3 1 3 0) 1))))) 10)
|
|
|
|
;; maybe difference is that #'LET* can't be directly in the place that defined :note?
|
|
;; and I should use #'PSEQ and move #'LET* into list definiton?
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (pseq (let* ((chord (pk :chord))
|
|
(notes (nchord chord)))
|
|
notes)
|
|
1)))
|
|
10)
|
|
;; or maybe (pk :chord) is a pattern and can't be used as "just function to get value"
|
|
;; seems true
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (pk :chord)))
|
|
10)
|
|
;; here pk :chord is object so, endless pattern and we never switch to :major
|
|
;; but that's ok,
|
|
;; main lesson I guess that I need to use pattern transformation functions,
|
|
;; and lisp transformations mainly on arguments
|
|
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (pfunc (lambda ()
|
|
(pseq (nchord (event-value *event* :chord)) 1)))))
|
|
10)
|
|
;; endless stream, inner :note doesn't end?
|
|
(next-upto-n (parp (pbind :chord (pseq (list :minor-triad :major)))
|
|
(pbind :note (pseq (pnary #'nchord (pk :chord)) 2)))
|
|
20)
|
|
;; not that seems to work?
|
|
(pdef :maybe-arpegio
|
|
(parp (pbind :chord (pseq (list :minor-triad :major) 2))
|
|
(pbind :note (pseq (pnary #'nchord (pk :chord)) 2))))
|
|
;; (play :maybe-arpegio)
|
|
;; (end :maybe-arpegio)
|
|
;; (stop :maybe-arpegio)
|
|
|
|
;; could I maybe now insert this into a pb
|
|
;; so that I could change speed and root for whole thing?
|