Compare commits
	
		
			2 Commits
		
	
	
		
			38eab3f355
			...
			6a9b9a88c4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					6a9b9a88c4 | ||
| 
						 | 
					0ae86a5f51 | 
@ -1,10 +1,6 @@
 | 
			
		||||
(in-package #:cl-collider)
 | 
			
		||||
;; https://github.com/SCLOrkHub/SCLOrkSynths
 | 
			
		||||
;; https://github.com/SCLOrkHub/SCLOrkSynths/blob/master/SynthDefs/strings/violin.scd
 | 
			
		||||
(freq 440) (gate 1) (amp 1) (pan 0) (out 0) (att 0.1) (dec 0.1) (sus 0.5) (rel 0.1)
 | 
			
		||||
(vRate 4.6) (vDepth 0.02) (vAtt 0.15) (vRateVar 0.25) (vDepthVar 0.05)
 | 
			
		||||
(pwmVarRate 2) (pwmMin 0.7) (pwmMax 0.8) (pwmRate 5)
 | 
			
		||||
(bridgeFreq 2500) (scratchDepth 0.15)
 | 
			
		||||
 | 
			
		||||
(defsynth violin ((freq 440) (gate 1) (amp 1) (pan 0) (out 0) (att 0.1) (dec 0.1) (sus 0.5) (rel 0.1)
 | 
			
		||||
                  (vRate 4.6) (vDepth 0.02) (vAtt 0.15) (vRateVar 0.25) (vDepthVar 0.05)
 | 
			
		||||
@ -20,8 +16,8 @@
 | 
			
		||||
                                          (range (lf-pulse.ar (* freq 1.5)) (/ 1 scratch) scratch))))
 | 
			
		||||
                 (snd-step-2 (+ (* snd-step-1 0.7)
 | 
			
		||||
                                (bpf.ar snd-step-1 bridgeFreq 2 2)))
 | 
			
		||||
                 (snd-step-3 (* snd-step-2 envelope)))
 | 
			
		||||
            (out.ar out (pan2.ar snd-step-3 pan)))))
 | 
			
		||||
                 (snd-step-3 (* snd-step-2 amp envelope)))
 | 
			
		||||
            (out.ar out (pan2.ar snd-step-3 pan))))
 | 
			
		||||
;; (synth :violin :freq 400)
 | 
			
		||||
;; (stop)
 | 
			
		||||
(in-package #:cl-patterns)
 | 
			
		||||
@ -31,9 +27,10 @@
 | 
			
		||||
:decay 2
 | 
			
		||||
:att 0.07
 | 
			
		||||
:sus 0.8
 | 
			
		||||
  :amp 0.1
 | 
			
		||||
:legato 1
 | 
			
		||||
:degree (pseq (list 0 1 2 3 4 5 6 7) 1)
 | 
			
		||||
:dur 2)
 | 
			
		||||
:dur 1)
 | 
			
		||||
;; (play :foo-with-pluck-synth)
 | 
			
		||||
;; (end :foo-with-pluck-synth)
 | 
			
		||||
;; (stop :foo-with-pluck-synth)
 | 
			
		||||
 | 
			
		||||
@ -236,9 +236,9 @@
 | 
			
		||||
  :instrument :fmrhodes1
 | 
			
		||||
  :octave 3
 | 
			
		||||
  :degree (pseq (list 0 1 4 8 (prest 0) 0 2 4 7 4 2) 1))
 | 
			
		||||
(play :hm-lallaa)
 | 
			
		||||
(end :hm-lallaa)
 | 
			
		||||
(stop :hm-lallaa)
 | 
			
		||||
;; (play :hm-lallaa)
 | 
			
		||||
;; (end :hm-lallaa)
 | 
			
		||||
;; (stop :hm-lallaa)
 | 
			
		||||
;; yup, that's a pause, cool
 | 
			
		||||
;; so, do I bring that stuff into a separate file?
 | 
			
		||||
 | 
			
		||||
@ -265,9 +265,9 @@
 | 
			
		||||
  :base 2
 | 
			
		||||
  :root 5
 | 
			
		||||
  )
 | 
			
		||||
(play :hm-chords-progression)
 | 
			
		||||
(end :hm-chords-progression)
 | 
			
		||||
(stop :hm-chords-progression)
 | 
			
		||||
;; (play :hm-chords-progression)
 | 
			
		||||
;; (end :hm-chords-progression)
 | 
			
		||||
;; (stop :hm-chords-progression)
 | 
			
		||||
 | 
			
		||||
;; so, what's a good way to use them? just wrap separately into #'CHORD-NOTES
 | 
			
		||||
;; maybe at least for now
 | 
			
		||||
@ -291,9 +291,9 @@
 | 
			
		||||
  :base 2
 | 
			
		||||
  :root 5
 | 
			
		||||
  )
 | 
			
		||||
(play :hm-chords-progress-em-g-am-c)
 | 
			
		||||
(end :hm-chords-progress-em-g-am-c)
 | 
			
		||||
(stop :hm-chords-progress-em-g-am-c)
 | 
			
		||||
;; (play :hm-chords-progress-em-g-am-c)
 | 
			
		||||
;; (end :hm-chords-progress-em-g-am-c)
 | 
			
		||||
;; (stop :hm-chords-progress-em-g-am-c)
 | 
			
		||||
 | 
			
		||||
;; Am – F – C – G (i – VI – III – VII)
 | 
			
		||||
(pb :hm-chords-progress-am-f-c-g
 | 
			
		||||
@ -306,24 +306,27 @@
 | 
			
		||||
  :base 2
 | 
			
		||||
  :root 5
 | 
			
		||||
  )
 | 
			
		||||
(play :hm-chords-progress-am-f-c-g)
 | 
			
		||||
(end :hm-chords-progress-am-f-c-g)
 | 
			
		||||
(stop :hm-chords-progress-am-f-c-g)
 | 
			
		||||
;; (play :hm-chords-progress-am-f-c-g)
 | 
			
		||||
;; (end :hm-chords-progress-am-f-c-g)
 | 
			
		||||
;; (stop :hm-chords-progress-am-f-c-g)
 | 
			
		||||
 | 
			
		||||
;; IV V iii vi (from video on japan's favourite chord progression)
 | 
			
		||||
;; https://youtu.be/6aezSL_GvZA
 | 
			
		||||
(pb :hm-chords-progress-golden-road
 | 
			
		||||
  :instrument :strings
 | 
			
		||||
  ;; :instrument :violin
 | 
			
		||||
  :instrument :fmrhodes1
 | 
			
		||||
  :octave 4
 | 
			
		||||
  :amp 0.2
 | 
			
		||||
  :legato 1
 | 
			
		||||
  ;; :degree (pseq (mapcar #'chord-notes (list :major :minor  :maj7 :major)) 1) ; works, but can't insert (prest 0) among chords
 | 
			
		||||
  ;; :degree (pseq (list (chord :major) (chord :minor) (chord :maj7) (chord :major)) 1) ; doesn't seem to work
 | 
			
		||||
  :degree (pseq (list (nchord :major 3) (nchord :major 4) (nchord :minor 2) (nchord :minor 5) ) 1) ; doesn't seem to work
 | 
			
		||||
  ;; :degree (pseq (list 1 2 3) 1) ; doesn't seem to work
 | 
			
		||||
  :dur (pseq (list 4 4 4 4 ))
 | 
			
		||||
  :root 0)
 | 
			
		||||
(play :hm-chords-progress-golden-road)
 | 
			
		||||
(end :hm-chords-progress-golden-road)
 | 
			
		||||
(stop :hm-chords-progress-golden-road)
 | 
			
		||||
;; (play :hm-chords-progress-golden-road)
 | 
			
		||||
;; (end :hm-chords-progress-golden-road)
 | 
			
		||||
;; (stop :hm-chords-progress-golden-road)
 | 
			
		||||
 | 
			
		||||
;; does it sound like in the video then?
 | 
			
		||||
 | 
			
		||||
@ -332,3 +335,11 @@
 | 
			
		||||
;; - giving (note/chord) and rhythm to get form that single note
 | 
			
		||||
 | 
			
		||||
;; latter should be possible from defining a subpattern? with static note?
 | 
			
		||||
 | 
			
		||||
;;; now, I'd like to use (render (pdef :your-pattern) "/path/to/output.wav" :dur 4)
 | 
			
		||||
;; for that I'd need to use more recent version than I get from quicklisp, so clone repo
 | 
			
		||||
quicklisp:*local-project-directories*
 | 
			
		||||
(ql:register-local-projects)
 | 
			
		||||
(ql:where-is-system :cl-patterns) ;; #P"/home/efim/quicklisp/local-projects/cl-patterns/"
 | 
			
		||||
 | 
			
		||||
;; (render (pdef :hm-chords-progress-golden-road) "/tmp/chords-4.wav" :dur 16)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										127
									
								
								2022-09-05-maybe-sequences-from-chords.lisp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								2022-09-05-maybe-sequences-from-chords.lisp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,127 @@
 | 
			
		||||
 | 
			
		||||
(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
 | 
			
		||||
@ -8,6 +8,7 @@
 | 
			
		||||
(server-boot *s*)                       ; already in use
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(ql:quickload :cl-patterns)
 | 
			
		||||
(ql:quickload :cl-patterns/supercollider)
 | 
			
		||||
 | 
			
		||||
;; ...this will take care of loading cl-collider for you if it's not already loaded.
 | 
			
		||||
 | 
			
		||||
@ -290,10 +290,6 @@ with fixed synthdefs
 | 
			
		||||
** tried synths in a pattern and they work!
 | 
			
		||||
even though they don't stop on their own,
 | 
			
		||||
so maybe `gate` is a default argument that passes control from the pattern system, using `dur`
 | 
			
		||||
** NEXT - learn more about puttin melodies in, midinotes and stuff
 | 
			
		||||
what I want is "pitch model"
 | 
			
		||||
http://doc.sccode.org/Tutorials/Streams-Patterns-Events5.html
 | 
			
		||||
** NEXT - how to keep same note pattern repeating with different settings of legato \ duration
 | 
			
		||||
* [2022-09-04 Sun]
 | 
			
		||||
** evil marcro for wrapping consecutive values (or args) into pairwise brackets:
 | 
			
		||||
well, not being inserted due to backspace, sad
 | 
			
		||||
@ -318,3 +314,20 @@ Example:
 | 
			
		||||
 | 
			
		||||
is that pause?
 | 
			
		||||
but why would event then still have :DEGREE attribute?
 | 
			
		||||
* [2022-09-05 Mon]
 | 
			
		||||
** let's what? move instruments into separate organized files?
 | 
			
		||||
meh, let's try for arpeggio from chords?
 | 
			
		||||
or something
 | 
			
		||||
** DONE - learn more about puttin melodies in, midinotes and stuff
 | 
			
		||||
what I want is "pitch model"
 | 
			
		||||
http://doc.sccode.org/Tutorials/Streams-Patterns-Events5.html
 | 
			
		||||
:degree - is from an octave, and :octave 5 default and quite high, :root is which octave to take
 | 
			
		||||
** NEXT - how to keep same note pattern repeating with different settings of legato \ duration
 | 
			
		||||
I'll try to define notes separately with pdef and insert it? would then single length would be for all?
 | 
			
		||||
** so, I tried to figure out how to change parameters for whole "phrases"
 | 
			
		||||
"automatic jazz" does that with getting new random value, that gets repeated "forever" until the end of the pattern
 | 
			
		||||
 | 
			
		||||
if I try to use not random, but "from sequence", then on pattern restart I'd get first element of the sequence every time.
 | 
			
		||||
 | 
			
		||||
so then "kind of working" solution, is keep melogy repeating,
 | 
			
		||||
then - know what is the length of the melody and repeat for "amount of events" in the melody,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user