diff --git a/2022-08-19-patterns-guide.lisp b/2022-08-19-patterns-guide.lisp index 5bddff5..186b968 100644 --- a/2022-08-19-patterns-guide.lisp +++ b/2022-08-19-patterns-guide.lisp @@ -181,7 +181,7 @@ (pb :what-note :note (pseq '(0 1 2 3 4 5 6 7 (0 7)) 1) - :octave 3 + :octave 5 :dur (pseq (concatenate 'list (make-list 7 :initial-element 1) '(2 4))) :play-quant 4 ) @@ -283,19 +283,24 @@ (all-scales) (all-tunings) +(defparameter *some-chord* (chord "Major Triad")) +(chord-notes *some-chord*) + ;;; can I just use chord as :note ? +(mapcar #'chord-notes (list (chord "Major Triad") (chord "Minor Triad"))) (pb :what-predef-chord - :note (pseq `((chord "Major Triad") (chord "Minor Triad"))) + :note (pseq (mapcar #'chord-notes (list (chord "Major Triad") (chord "Minor Triad") (chord "Minor 7th") (chord "Major 7th") (chord "Diminished Triad") (chord "Major Triad"))) 1) :octave 4 :root 2 - :dur (pseq '(2 2) 1) + :dur (pseq '(2 2 4)) ;; :play-quant 4 ) (play :what-predef-chord) (end :what-predef-chord) + (in-package #:cl-collider) (proxy :foo (sin-osc.ar 440 0 0.2)) diff --git a/2022-08-20-will-i-get-instruments.lisp b/2022-08-20-will-i-get-instruments.lisp new file mode 100644 index 0000000..7e1ea2c --- /dev/null +++ b/2022-08-20-will-i-get-instruments.lisp @@ -0,0 +1,268 @@ + +(setq *M1* '(0 2 4)) +(setq *Min1* '(0 1.5 4)) +(setq *M3* '(2 4 6)) + +(setq *chord* *Min1*) + +(in-package #:cl-patterns) +(start-clock-loop :tempo 110/60) +(pb :what-chord + :note (pseq `(,*m1* ,*min1*)) + :octave 4 + :root 2 + :dur (pseq '(2 2) 1) + ;; :play-quant 4 + ) + +;; (play :what-chord) +;; (end :what-chord) + +(in-package #:cl-collider) +(defsynth default ((gate 1) (freq 440) (out 0)) + (let* ((env (env-gen.kr (asr 0.01 1 0.1) :gate gate :act :free)) + (sig (sin-osc.ar freq 0 0.2))) + (out.ar out (pan2.ar sig 0 env)))) + +(server-query-all-nodes) ; not sure how to interpret, but all things submitted to servier to play? + + +;; ok, reading found article: https://nunotrocado.com/software/cl-collider-tutorial-1.html +(defsynth tone ((freq 440) (amp 0.2)) + (out.ar 0 (saw.ar freq amp))) +;; (synth 'tone) +;; (stop) + +(defparameter *tone* + (synth 'tone + :freq (midicps 42) + :amp 0.3)) +(free *tone*) + + +(defsynth tone-buzz ((freq 440) (amp 0.2)) + (out.ar 0 (saw.ar (let ((detune (* freq 0.01))) + (list (- freq detune) (+ freq detune))) + (/ amp 2)))) + +;; (let ((node (synth 'tone-buzz))) +;; (sleep 2) +;; (free node)) + +(defsynth tone-pluck ((freq 440) (amp 0.2)) + (out.ar 0 (* (saw.ar (let ((detune (* freq 0.01))) + (list (- freq detune) (+ freq detune)))) + (env-gen.kr (perc 0.1 1.8) + :level-scale amp + :act :free)))) + +;; (synth 'tone-pluck) + +;; (in-package #:cl-patterns) +(all-instruments) +(pb :what-instrumented + :intrument :tone-pluck + ;; :note (pseq `(,*m1* ,*min1*)) + :note (pseq '(0 3 7) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2) ) + ;; :play-quant 4 + ) + +;; (play :what-instrumented) +;; (stop :what-instrumented) + +;;; yo, I think I understood that predef chords stuff: + +(pb :what-predef-chord + :instrument :tone-buzz + :note (pseq (mapcar #'chord-notes (list (chord "Major Triad") (chord "Minor Triad") (chord "Minor 7th") (chord "Major 7th") (chord "Diminished Triad") (chord "Major Triad"))) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2 4)) + ;; :play-quant 4 + ) + + +;; (play :what-predef-chord) +;; (end :what-predef-chord) + +(pb :what-try-instrument + :instrument :tone-pluck + :note (pseq '(1 2 3 7) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2 4)) + ;; :play-quant 4 + ) + + +;; (play :what-try-instrument) +;; (stop :what-try-instrument) + +(pb :what-instrumented-2-maybe + :instrument :tone-pluck + ;; :note (pseq `(,*m1* ,*min1*)) + :note (pseq '(0 3 7) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2) ) + ;; :play-quant 4 + ) + +;; (play :what-instrumented-2-maybe) +;; (stop :what-instrumented-2-maybe) + + + +;;; now let's try to get some synths for percussions? + + + + +;; copied from https://github.com/defaultxr/cl-patterns/blob/master/doc/supercollider-example.lisp + +(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)))) +(synth :kik) + +(in-package #:cl-patterns) +(pb :what-percussion + :instrument :kik + ;; :note (pseq `(,*m1* ,*min1*)) + :note (pseq '(0 3 7) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2) ) + ;; :play-quant 4 + ) +;; (play :what-percussion) +;; (stop :what-percussion) + +;; well, I don't understand, do I go read supercollider docs? +;; about EnvGen SinOsc ? +;; woa, there's old archived https://github.com/madskjeldgaard/awesome-supercollider +;;; let's try to convert drum-kik https://github.com/everythingwillbetakenaway/Synthdefs/blob/master/drum_kick.scd +;; ( +;; SynthDef(\drum_kick, { +;; arg freq=440, gate=1, amp=0.5, source,pan = 0.0 ; +;; source = +;; Pan2.ar( +;; SinOsc.ar(EnvGen.kr(Env.perc(0.0001, 1.5, 1, -200), gate, 1000, 45, doneAction:2), 1, 1) + +;; ((BPF.ar([GrayNoise.ar(6),GrayNoise.ar(6)],EnvGen.kr(Env.perc(0.001, 0.3, 1, -200), gate, 6000, 70), 1.5)).distort * Line.kr(0.3,0,0.1)) +;; * +;; EnvGen.kr(Env.perc(0.0001, 0.09, amp, 8)),0); +;; Out.ar(0, source); +;; }).add; +;; ) +;; Synth(\drum_kick); + +(in-package #:cl-collider) + +(defsynth drum-kik ((freq 440) (out 0) (gate 1) (amp 0.5) (pan 0.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)) + (pan (pan2.ar sig 0 env))) + (out.ar out pan))) +(synth :drum-kik) +(cl-patterns::all-instruments) + +;;; ok, fuck that let's play +;; just do some percussion with existing kik and chord progressions, and maybe a melody + + +(in-package #:cl-patterns) + +(pb :what-predef-chord + :instrument :tone-pluck + :note (pseq (mapcar #'chord-notes (list (chord "Major Triad") (chord "Minor Triad") (chord "Minor 7th") (chord "Major 7th") (chord "Diminished Triad") (chord "Major Triad"))) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2 4)) + ;; :play-quant 4 + ) + +;; (play :what-predef-chord) +;; (end :what-predef-chord) + +(pb :what-basic-percussion + :instrument :kik + :note 0 + :dur (pseq '(1) 1) ; ok, too hard again, want to finish something and go on + :play-quant 4) + +;; (play :what-basic-percussion) +;; (stop :what-basic-percussion) + +;; how do I now join both of these? + +(pb :first-composition (ppar (list :what-predef-chord :what-basic-percussion))) ; bs, wtf + +(next-upto-n (ppar (list (pbind :dur (pn 1/2 4)) + (pbind :dur (pn 2/3 4))))) + +(next-upto-n (ppar (list :what-basic-percussion :what-predef-chord))) + +;; (play :first-composition) +;; (stop :first-composition) + +;; (next-upto-n (pmeta :pattern (pseq (list :what-basic-percussion :what-predef-chord) 1) :sync 2)) + +;; god, I have no idea how to have two patterns play at the same time =C + +;; (play (list :what-basic-percussion :what-predef-chord)) +;; (stop (list :what-basic-percussion :what-predef-chord)) +;; +;; welp that workds +;; bs, but maybe I'll put it into file and get a break already + +(in-package #:cl-collider) + +;; from https://github.com/byulparan/cl-collider +;;; write a single channel to disk + +;; we can write to buffer number out_buf_num by reading in from the 0 bus +(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 + +;; e.g. +(proxy :blah (sin-osc.ar 440)) +(free :blah) + + +;; then when you are done + +;; stop the disk_writer synth +(free writer_0) + +;; close and free the buffer +(buffer-close mybuffer) +(buffer-free mybuffer) + + +;; then you can play what you recorded with a utility like mpv: +;; mpv /tmp/foo.aiff + + + + +;; (cl-patterns:stop t) diff --git a/programming-music-journal.org b/programming-music-journal.org index 83c662d..f6f17c2 100644 --- a/programming-music-journal.org +++ b/programming-music-journal.org @@ -69,3 +69,54 @@ do I go to cl-collider package for explanation of synths and such? - some combined sounds, which don't sound nice - maybe reliant startup procedure - and attempting to run chords hangs it all +** cl-patterns docs: +https://github.com/defaultxr/cl-patterns/tree/master/doc +that's all files +* [2022-08-20 Sat] +** now I'd like to create an instrument for which chords would sound nice +and after than some kind of percussion things +** cool! that was just my type :instument instead of :instrument +and article on cl-collider now helps with some cool synhts, like chord strum +#+begin_src common-lisp +(defsynth tone-pluck ((freq 440) (amp 0.2)) + (out.ar 0 (* (saw.ar (let ((detune (* freq 0.01))) + (list (- freq detune) (+ freq detune)))) + (env-gen.kr (perc 0.1 1.8) + :level-scale amp + :act :free)))) + +;; (synth 'tone-pluck) + +(in-package #:cl-patterns) +(pb :what-predef-chord + :instrument :tone-pluck + :note (pseq (mapcar #'chord-notes (list (chord "Major Triad") (chord "Minor Triad") (chord "Minor 7th") (chord "Major 7th") (chord "Diminished Triad") (chord "Major Triad"))) 1) + :octave 4 + :root 2 + :dur (pseq '(2 2 4)) + ;; :play-quant 4 + ) + + +;; (play :what-predef-chord) +;; (stop :what-predef-chord) + +#+end_src + +yay. +** now let's figure out percussions? +** searching : "super collider percussion synth" +got all sorts of cool results: +*** main page of supercollider: https://supercollider.github.io/ +*** awesome list : https://github.com/madskjeldgaard/awesome-supercollider#synthdefs +and it has link to defs! +*** defs : https://github.com/everythingwillbetakenaway/Synthdefs +for example a drum kik which I'd try to convert? +https://github.com/everythingwillbetakenaway/Synthdefs/blob/master/drum_kick.scd +** to file https://github.com/byulparan/cl-collider#record-audio-output +whoh +** now for the well deserved fucking rest +** things I want to figure out in the future: +1. joining patterns in parallel - percussion + rythm + solo +2. having 3 beats in percussion but aligning to 4 beats +3. getting cool instruments from existing repos for supercollider