#+title: Programming Music Journal * [2022-08-19 Fri] ** past friday I've done some basic setup (painfully) and had simplest examples running [[file:supercollider-example.lisp::;; to use cl-patterns with its SuperCollider backend, you'll first need to load the cl-patterns/supercollider system with quicklisp:][setting up supercollider]] package - so this doesn't work for some reason ** here simplest things seem to work [[file:setting-up-cl-collider.lisp::;; https://defaultxr.github.io/cl-collider-tutorial/02-getting-started.html][cl-collider-tutorial-getting-started]] ** so, let's just go the site? nope, continue with the file that had some promise the one about cl-collider turorial ** also, let's make this a separate repo? oh, no, the 'supercollider-example' which is about cl-patterns started to work? how and why? maybe reinit of some shit, or what so, new file to hopefully learn something about cl-patterns *** what is it that I want o learn ideally? setting up drum sequences? doing chord things with synth? ** what's this thing about "FAILURE IN SERVER /n_set Node 1539 not found " ? ** this seems to be startup #+begin_src common-lisp (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) #+end_src but what's most basic pattern that would play then? ones in [[file:2022-08-12-supercollider-example.lisp::end :bar][supercollider example seem to work]] and example seem to require me to define synth, right? to set it into the :instrument key wtf am I to do. ** maybe let's try to do stuff inside of org file? ** how do I clear things, it seems that cl-patterns seems to send things to server? ** should I try a different backend? ** so, when SC returned lots of errors on pb what helped - starting syn wave from "setting-up" file ;;; https://defaultxr.github.io/cl-collider-tutorial/03-make-a-sound.html (setf *s* (make-external-server "localhost" :port 4444)) (server-boot *s*) ; already in use ;;; https://defaultxr.github.io/cl-collider-tutorial/03-make-a-sound.html (proxy :foo (sin-osc.ar 440 0 0.2)) ; no error, but hear no sound ;; opened QjackCtl, connected Graph SuperCollider to Air by Aftershokz left (proxy :foo (sin-osc.ar 300 0 0.2)) (proxy :foo (saw.ar 300 0.2)) ** how do I make sounds better? do I go to cl-collider package for explanation of synths and such? ** to stopp things that run amok: (cl-patterns:stop t) ** ugh. why doesn't it produce sounds? ** ok, what did I learn today? - some interaction with pseq having scales, root / ocave - intersecting with durations, also seq and not totally alighning - 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 * [2022-08-21 Sun] ** now, I got another response! Yes unfortunately it's not always easy to directly translate synthdefs from SC into cl-collider. Some of the UGens are named differently (i.e. SinOsc in SC is sin-osc in cl-collider). The UGens are defined in cl-collider with defugen though, so you could do a grep or similar on the library to get a list of the defined ugens. Regarding the "attributes" you mention, do you mean the arguments for each ugen? If so, are you using Emacs or another editor? I believe Emacs should show the function signature in the echo area at the bottom of the screen if you're in the right package (i.e. you need to have an in-package form in your file) If you have a specific synthdef you're having trouble translating, feel free to link me to it and I'll see if I can translate it for you as an example Oh I see you do have an in-package in the example you posted. It might not be showing the function signature since you're doing in-package cl-patterns but the cl-patterns package doesn't include the UGens. so you might have to make a new package that :uses cl-patterns and cl-collider, so it has all the ugens as well as all the patterns. efim Apart from guidance on how to better translate SC definition of sync into DEFSYNTH attributes to get other instruments could you help me understand how to join patterns? I created two (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 ) (pb :what-basic-percussion :instrument :kik :note 0 :dur (pseq '(1) 1) :play-quant 4) and wanted to join them to play in parallel as a pattern and I think I'm getting lost in understanding types, what is pattern, what isn't because there's an example for PPAR: (next-upto-n (ppar (list (pbind :dur (pn 1/2 4)) (pbind :dur (pn 2/3 4))))) but doing (next-upto-n (ppar (list :what-basic-percussion :what-predef-chord))) doesn't yield sound events so maybe I can't reference patterns by name they get in PB ? would I need to use PBIND to define both of previous patterns, set them to some variables, and then they could be used as subpatterns? For now I already got tired with how much there is to learn, I've set up "live recording" from (next-upto-n (ppar (list :what-basic-percussion :what-predef-chord))) and celebrate initial success, theres 9 second pause in the beginning, but that's my first composition with so much to learn next-upto-n won't play any sounds on its own, it's just used to get the resulting event objects from the patterns. You'd still need to call play on whatever pattern you define. So something like this could work: 1 2 3 4 (pdef :foo (ppar (list (pdef :what-predef-chord) (pdef :what-basic-percussion)))) (play (pdef :foo)) Oh, I see what you meant. Yeah, it looks like ppar doesn't accept just the pattern names, so you would have to do this instead: 1 (next-upto-n (ppar (list (pdef :what-basic-percussion) (pdef :what-predef-chord)))) It probably should accept the pattern names directly though, so I will see about fixing that soon. When you define a pattern like (pb :foo ...) it's basically the same as doing (pdef :foo (pbind ...)). So if you define a pattern with pb you can refer back to it with pdef later on. Today modula efim foo.aiff (4.74 MB) very nice! definite good first steps, glad to hear you're making progress :) it does take some learning but hopefully it will make more sense as you gain familiarity with it I'm trying to make cl-patterns as intuitive as possible, but there are definitely some rough edges i don't notice until they're pointed out. Oh, also, if you want to record a pattern, you might be interested in the render function. Basically you can do something like (render (pdef :your-pattern) "/path/to/output.wav" :dur 4) and it will save 4 beats of :your-pattern to /path/to/output.wav. I'm not sure if that's what you were using for that recording, but it may be more convenient if you were using something else. ** ok, so let's search github for synthdef ? ** now I want to do what? 1. try out parallel 2. try to get precussion 3. also let's try to get defpackage and stuff ** so, let's copy yesterdays instruments and patterns and try to join them in parallel