small refactor of old notes and more arpeggios
This commit is contained in:
204
dirty-journal/2022-08-28-trying-for-percussion-again.lisp
Normal file
204
dirty-journal/2022-08-28-trying-for-percussion-again.lisp
Normal file
@@ -0,0 +1,204 @@
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(in-package #:cl-patterns)
|
||||
|
||||
;;; so the copied from supercollider examples is
|
||||
;; {
|
||||
;; var snare, bdrum, hihat;
|
||||
;; var tempo = 4;
|
||||
;; tempo = Impulse.ar(tempo); // for a drunk drummer replace Impulse with Dust !!!
|
||||
;; snare = WhiteNoise.ar(Decay2.ar(PulseDivider.ar(tempo, 4, 2), 0.005, 0.5));
|
||||
;; bdrum = SinOsc.ar(Line.ar(120,60, 1), 0, Decay2.ar(PulseDivider.ar(tempo, 4, 0), 0.005, 0.5));
|
||||
;; hihat = HPF.ar(WhiteNoise.ar(1), 10000) * Decay2.ar(tempo, 0.005, 0.5);
|
||||
;; Out.ar(0, (snare + bdrum + hihat) * 0.4 ! 2)
|
||||
;; }.play
|
||||
|
||||
|
||||
;; and that didn't work
|
||||
;; (defsynth snare ()
|
||||
;; (out.ar 0 (decay2.ar (pulse-divider.ar 4 4 2) 0.005 0.5))
|
||||
;; ;; (white-noise.ar (decay2.ar (pulse-divider.ar 4 4 2) 0.005 0.5))
|
||||
;; )
|
||||
;; (synth :snare)
|
||||
;; (stop)
|
||||
|
||||
;;; advice I got:
|
||||
;; As for your question about the snare synthdef, pulse-divider doesn't actually generate any triggers on its own, it just outputs a trigger every div triggers. So instead you could try something like this:
|
||||
(in-package #:cl-collider)
|
||||
(defsynth snare ()
|
||||
(out.ar 0 (white-noise.ar (decay2.ar (pulse-divider.ar (impulse.ar 8) 4 2) 0.005 0.5))))
|
||||
;; (synth :snare)
|
||||
;; (stop)
|
||||
;;
|
||||
;; yup. that works (in a loop)
|
||||
;; now I want to figure out that :free thing
|
||||
|
||||
;;; continuation of advice
|
||||
;; But if you just want to use snare in a pattern, I would write it like this:
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth snare ((amp 0.5) (out 0))
|
||||
(out.ar out (* amp (white-noise.ar (env-gen.ar (env (list 0 1 0) (list 0.005 0.5)) :act :free)))))
|
||||
|
||||
;; (synth :snare)
|
||||
;; (stop)
|
||||
;; that's a bit longer that I'd like
|
||||
|
||||
|
||||
(in-package #:cl-patterns)
|
||||
(pb :test
|
||||
:instrument :snare
|
||||
:dur 1
|
||||
;; :amp (pwhite 0.0 0.5)
|
||||
:pfindur 4)
|
||||
;; (play :test)
|
||||
;; (end :test)
|
||||
;;
|
||||
;; ok, that works
|
||||
;;
|
||||
;; of the things I really should do, is go and read
|
||||
;; about Envelope generators, ones that have that :act :free thing
|
||||
;;
|
||||
;; one other thing - is to get one or two other drums and mock up a beat
|
||||
|
||||
;; well, if I'm doing this in small steps, let's read about envelope
|
||||
;; and make first snare synth usable in patterns
|
||||
;;
|
||||
;; tried to read just about EnvGen and Env
|
||||
;; https://doc.sccode.org/Classes/EnvGen.html
|
||||
;; https://doc.sccode.org/Classes/Env.html
|
||||
;;
|
||||
;; then got directed to the Tutorial, good idea to read it,
|
||||
;; if not previous "first tutorial", then on concepts:
|
||||
;; http://doc.sccode.org/Tutorials/Streams-Patterns-Events1.html
|
||||
|
||||
|
||||
;;; So, env-gen takes in lists for intensity and timings, from that builds output signal that can be used in other gens?
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth env-test-1 ((amp 0.5) (out 0))
|
||||
(out.ar out (* amp (sin-osc.ar 440.0 0.0 (env-gen.ar (env (list 0 1 0) (list 0.005 0.5)) :act :free)))))
|
||||
|
||||
;; (synth :env-test-1)
|
||||
;; (stop)
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth env-test-1-1 ((amp 0.5) (out 0))
|
||||
(out.ar out (* amp (sin-osc.ar 440.0 0.0 (env-gen.ar (env (list 0 1 0.1 0) (list 0.005 0.01 0.5)) :act :free)))))
|
||||
|
||||
;; (synth :env-test-1-1)
|
||||
;; (stop)
|
||||
(in-package #:cl-collider)
|
||||
(defsynth env-test-2 ((amp 0.5) (out 0) (start 100) (middle 400) (end 200))
|
||||
(out.ar out (* amp (sin-osc.ar (env-gen.ar (env (list start middle end) (list 0.5 1.0)) :act :free)))))
|
||||
|
||||
;; (synth :env-test-2)
|
||||
;; (synth :env-test-2 :start 200 :middle 200 :end 200)
|
||||
;; (synth :env-test-2 :start 200 :middle 300 :end 200)
|
||||
;; (synth :env-test-2 :start 100 :middle 400 :end 100)
|
||||
;; (stop)
|
||||
;;
|
||||
;; so, yes, env-gen can define stream of numbers by times, and the numbers can be used for example in sin-osc.ar frequency input
|
||||
|
||||
;; now, how could I make other percussions? attempting to look at the example from SC
|
||||
|
||||
;; {
|
||||
;; var snare, bdrum, hihat;
|
||||
;; var tempo = 4;
|
||||
;; tempo = Impulse.ar(tempo); // for a drunk drummer replace Impulse with Dust !!!
|
||||
;; snare = WhiteNoise.ar(Decay2.ar(PulseDivider.ar(tempo, 4, 2), 0.005, 0.5));
|
||||
;; bdrum = SinOsc.ar(Line.ar(120,60, 1), 0, Decay2.ar(PulseDivider.ar(tempo, 4, 0), 0.005, 0.5));
|
||||
;; hihat = HPF.ar(WhiteNoise.ar(1), 10000) * Decay2.ar(tempo, 0.005, 0.5);
|
||||
;; Out.ar(0, (snare + bdrum + hihat) * 0.4 ! 2)
|
||||
;; }.play
|
||||
;;
|
||||
;; so let's try bdrum?
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth bdrum ((amp 0.5) (out 0) )
|
||||
(out.ar out (* amp (sin-osc.ar (line.ar 120 60 1) 0 (env-gen.ar (env (list 0 1 0) (list 0.005 0.5)) :act :free)))))
|
||||
|
||||
;; (synth :bdrum :amp 1)
|
||||
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth snare ((amp 0.5) (out 0))
|
||||
(out.ar out (* amp (white-noise.ar (env-gen.ar (env (list 0 1 0.3 0) (list 0.005 0.01 0.5)) :act :free)))))
|
||||
|
||||
;; (synth :snare)
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth hihat ((amp 0.5) (out 0))
|
||||
(out.ar out (* amp (hpf.ar (white-noise.ar 1) 10000) (env-gen.ar (env (list 0 1 0) (list 0.005 0.5)) :act :free))))
|
||||
;; hihat = HPF.ar(WhiteNoise.ar(1), 10000) * Decay2.ar(tempo, 0.005, 0.5);
|
||||
;; (synth :hihat)
|
||||
|
||||
;;; whoa, now I can try to combine these in a pattern!
|
||||
;; let's just copy another pattern with my instruments maybe?
|
||||
|
||||
(in-package #:cl-patterns)
|
||||
(pb :foo ;; define a new pattern named :foo
|
||||
:instrument :bdrum ;; 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 2 ;; give each event a duration of 1 beat
|
||||
:pfin 2 ;; limit the length of the pattern to 4 events (the default is infinite events)
|
||||
)
|
||||
;; (play :foo)
|
||||
;; (end :foo)
|
||||
|
||||
(pb :fee ;; define a new pattern named :foo
|
||||
:instrument :hihat ;; 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 3 ;; give each event a duration of 1 beat
|
||||
:pfin 1 ;; limit the length of the pattern to 4 events (the default is infinite events)
|
||||
)
|
||||
;; (play :fee)
|
||||
;; (end :fee)
|
||||
|
||||
(pb :fum ;; define a new pattern named :foo
|
||||
:instrument :snare ;; 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 0.5 ;; give each event a duration of 1 beat
|
||||
:pfin 8 ;; limit the length of the pattern to 4 events (the default is infinite events)
|
||||
:amp 0.1
|
||||
)
|
||||
;; (play :fum)
|
||||
;; (end :fum)
|
||||
|
||||
(pdef :all-parallel (ppar (list (pdef :foo) (pdef :fee) (pdef :fum))))
|
||||
;; (play :all-parallel)
|
||||
;; (end :all-parallel)
|
||||
;;
|
||||
|
||||
;; (in-package #:cl-patterns)
|
||||
;; (render (pdef :all-parallel) "/tmp/perc-1.aiff" :dur 16)
|
||||
;; doesn't work for some reason
|
||||
;; let's write as I did previously, and maybe ask a question later
|
||||
|
||||
(in-package #:cl-collider)
|
||||
(defsynth disk_writer ((out_buf_num 99))
|
||||
(disk-out.ar out_buf_num (in.ar 0)))
|
||||
|
||||
(setf mybuffer (buffer-alloc (expt 2 17)))
|
||||
mybuffer
|
||||
|
||||
;; start a disk_writer synth
|
||||
(setf writer_0 (synth 'disk_writer))
|
||||
|
||||
;; make it output to buffer you allocated
|
||||
(ctrl writer_0 :out_buf_num (bufnum mybuffer))
|
||||
|
||||
;; continuously write the buffer contents to a file
|
||||
(buffer-write mybuffer "/tmp/foo.aiff" :leave-open-p t)
|
||||
|
||||
;; now play whatever sounds you like
|
||||
|
||||
;; stop the disk_writer synth
|
||||
(free writer_0)
|
||||
|
||||
;; close and free the buffer
|
||||
(buffer-close mybuffer)
|
||||
(buffer-free mybuffer)
|
||||
;; wow, now that's a success
|
||||
;; question on how to write
|
||||
;; and what else?
|
||||
Reference in New Issue
Block a user