117 lines
3.4 KiB
Common Lisp
117 lines
3.4 KiB
Common Lisp
;; https://github.com/defaultxr/cl-patterns/blob/master/doc/tutorial.org
|
|
;; https://github.com/defaultxr/cl-patterns/blob/master/doc/cookbook.org - other examples
|
|
(ql:quickload :cl-patterns/supercollider)
|
|
(cl-patterns:backend-start 'supercollider)
|
|
|
|
;; also launch QjackCTL and connect SuperCollider outputs 1 & 2 to headphones
|
|
;; to force restart, use killall scsynth
|
|
|
|
|
|
|
|
(in-package #:cl-patterns)
|
|
|
|
(start-clock-loop :tempo 136/60)
|
|
|
|
|
|
(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)
|
|
|
|
;; (tempo 136/60) ; this raises error
|
|
|
|
(pb :hat
|
|
:instrument :hat
|
|
:dur 1/2 ;; play the hihat every 1/2 beat
|
|
:pfindur 4 ;; limit the pattern to 4 beats in length (it loops automatically)
|
|
:quant 4 ;; ensure that the pattern starts on a beat that is divisible by 4
|
|
)
|
|
|
|
(pb :snare
|
|
:embed (pcycles "----o--o-o--o--o") ;; using the snare tab from the page linked above
|
|
:instrument :snare
|
|
:dur 1/4
|
|
:quant 4)
|
|
(play :snare)
|
|
(end :snare)
|
|
|
|
(pb :kick
|
|
:embed (pcycles "o-o-------oo----")
|
|
:instrument :kick
|
|
:dur 1/4
|
|
:quant 4)
|
|
|
|
;; play the patterns we've defined:
|
|
(play :hat) ; for some reason just NIL
|
|
(end :hat)
|
|
(play (list :hat :snare :kick)) ; hm
|
|
|
|
|
|
(pb :12-bar-blues
|
|
:scale :chromatic
|
|
:root 4 ;; E for all guitar lovers out there
|
|
:octave 4
|
|
:dur (pseq (list 2/3 1/3))
|
|
:amp (pseq (list 0.5 0.4))
|
|
:legato (pseq (list 0.7 0.2))
|
|
:degree (pr (pseq (list (pseq '((0 7) (0 9)) 8)
|
|
(pseq '((5 12) (5 14)) 4)
|
|
(pseq '((0 7) (0 9)) 4)
|
|
|
|
(pseq '((7 14) (7 16)) 2)
|
|
(pseq '((5 12) (5 14)) 2)
|
|
(pseq '((0 7) (0 9)) 2)
|
|
(pseq '((7 14) (7 16)) 2))
|
|
1)
|
|
2))
|
|
|
|
(play :12-bar-blues)
|
|
(end :12-bar-blues)
|
|
|
|
;; what do I want to learn though?
|
|
(pb :foo ;; define a new pattern named :foo
|
|
:instrument :kik ;; use the :kik synth we defined above
|
|
:play-quant 4 ;; make sure the pattern will only start on a beat that is divisible by 4, to stay in sync
|
|
:dur 1 ;; give each event a duration of 1 beat
|
|
:pfin 4 ;; limit the length of the pattern to 4 events (the default is infinite events)
|
|
)
|
|
|
|
(pb :bar
|
|
:instrument :default
|
|
:play-quant 4
|
|
:dur 1/2
|
|
:scale :major ;; select the major scale
|
|
:degree (pwhite 0 7) ;; pick a random note from the first 7 notes in the selected scale
|
|
:pfindur 4 ;; limit the length of the pattern to 4 beats. pfindur causes the pattern to be limited based on its duration in beats, rather than the number of events.
|
|
)
|
|
|
|
(play :foo)
|
|
(end :foo)
|
|
|
|
;; let's try to modify most basic ones? copy them again
|
|
|
|
(in-package #:cl-collider)
|
|
|
|
(defsynth kik ((freq 440) (out 0))
|
|
(let* ((env (env-gen.kr (env (list 0 1 0) (list 0.001 1)) :act :free))
|
|
(fenv (env-gen.kr (env (list 1 0) (list 0.25)) :level-scale freq))
|
|
(sig (sin-osc.ar fenv 0 0.2)))
|
|
(out.ar out (pan2.ar sig 0 env))))
|
|
|
|
(in-package #:cl-patterns)
|
|
|
|
(pb :foo ;; define a new pattern named :foo
|
|
:instrument :kik ;; use the :kik synth we defined above
|
|
:play-quant 4 ;; make sure the pattern will only start on a beat that is divisible by 4, to stay in sync
|
|
:dur 1 ;; give each event a duration of 1 beat
|
|
:pfin 4 ;; limit the length of the pattern to 4 events (the default is infinite events)
|
|
)
|
|
|
|
(play :foo)
|
|
(end :foo)
|