Jump to content

ajf-

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Valparaiso, Chile
  • Interests
    Music, Lisp, Python, Ecmascript

Recent Profile Visitors

5,815 profile views
  1. Here is my study about the klangreihen: (defparameter tempo 60) (defparameter title "Klangreihen Study") ;;; This object takes care of setting and getting of parts (defclass study-score () ((instruments :initarg :instruments :initform 0) (duration :initarg :duration :initform 0) (parts))) ;;; When initializing, fill it with an empty model for parts (array of size N) (defmethod initialize-instance :after ((score study-score) &key) (let ((instruments (slot-value score 'instruments ))) (setf (slot-value score 'parts) (make-array instruments :initial-element '(-w)' :fill-pointer instruments)))) ;;; Getter and setter methods (defun get-part (score n) (elt (slot-value score 'parts) n )) (defun (setf part) (part score n) (let ((previous-value (elt (slot-value score 'parts) n))) (setf (elt (slot-value score 'parts) n) (concatenate 'list previous-value part)))) ;;; Instance of the object (defparameter study (make-instance 'study-score :instruments 16 :duration tempo)) ;;; Main procedure (let* ;; Main local variables ((12tone '(0 2 4 5 7 9 6 8 10 11 1 3)) (variants (list (row-variant 0 'r4 12tone) (row-variant 0 '4 12tone))) (total-parts (slot-value study 'instruments)) (bases (apply #'append (map 'list #'(lambda (v) (klangreihen 0 '(3 3 3 3) v)) variants))) (lengths (subseq (gen-divide total-parts (gen-length (distributive-cube (interference2 '(3 2 2))) 16)) 0 (length bases)))) (loop for base in bases for length in lengths do (labels ;; Local transformative functions ((amount-of (n) (/ 1 (nth n length))) (vel-scale (v) (+ 0.2 (* 0.6 v) )) (vel-format (v) (get-velocity (list v) :type :symbol)) (velocity-for (n) (vel-format (vel-scale (/ (amount-of n) 16)))) (length-for (n) (list (nth n length ))) (octave-of (n) (let ((low-bound (- 12 (* 12 (round (* (/ 1 total-parts) n 3.4) ))))) (list low-bound (+ low-bound 12)))) (pitch-for (n) (let* ((rolled (gen-surround base :size (amount-of n) :start n))) (ambitus (octave-of n) rolled)))) (loop for n from 0 to (- total-parts 1) do (destructuring-bind (&key length pitch velocity) ;; Example of handling on a case-by-case basis. No extra cases configured now. (case n (otherwise (list :length (length-for n) :velocity (velocity-for n) :pitch (pitch-for n) ))) (setf (part study n) (make-omn :length length :pitch pitch :velocity velocity :span :pitch))))))) ;;; Retrieve parts and save score (let ((partnum -1)) (def-score Study (:title title :composer "A. Jacomet" :key-signature 'atonal :time-signature '(4 4) :tempo tempo :layout (string-ensemble-layout '(vn11 vn12 vn13 vn14 vn21 vn22 vn23 vn24) '(vla1 vla2 vla3 vla4) '(vlc1 vlc2) '(ctb1 ctb2))) (vn11 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 1) (vn12 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 2) (vn13 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 3) (vn14 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 4) (vn21 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 5) (vn22 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 6) (vn23 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 7) (vn24 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 8) (vla1 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 9) (vla2 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 11) (vla3 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 12) (vla4 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 13) (vlc1 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 14) (vlc2 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 14) (ctb1 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 15) (ctb2 :omn (get-part study (incf partnum)) :sound 'gm :program 'Acoustic-Grand-Piano :channel 15))) (live-coding-midi (compile-score 'Study)) (display-musicxml 'Study) ;;;--------------------------------------------------------- ;;; ANNOTATION ;;;--------------------------------------------------------- #! This study is about the LISP languages and the possibilities of working with object oriented programming and loops. The first important part of this study is the 'study-score' class defined at the top of the file. (defclass study-score () ((instruments :initarg :instruments :initform 0) (duration :initarg :duration :initform 0) (parts))) On initialization, that object will create and save in one of it's properties, a model of the parts, which is an array of lists. (defmethod initialize-instance :after ((score study-score) &key) (let ((instruments (slot-value score 'instruments ))) (setf (slot-value score 'parts) (make-array instruments :initial-element '(-w)' :fill-pointer instruments)))) It is important to note that this can be extended to an N-dimensional array supporting Parts, Pitches, Velocities, Lengths, and more information. We then define trivial functions that are intended to help in adding and retrieving parts. (defun get-part (score n) (elt (slot-value score 'parts) n )) (defun (setf part) (part score n) (let ((previous-value (elt (slot-value score 'parts) n))) (setf (elt (slot-value score 'parts) n) (concatenate 'list previous-value part)))) This will eventually help keep our program free of code redundancy, and we can adapt the parts in any way we like in a global way. The rest is a simple example of utilizing a klangreihen base and looping over it. The loop starts with a LET clause that sets all the basic parameters: (let* ;; Main local variables ((12tone '(0 2 4 5 7 9 6 8 10 11 1 3)) (variants (list (row-variant 0 'r4 12tone) (row-variant 0 '4 12tone))) (total-parts (slot-value study 'instruments)) (bases (apply #'append (map 'list #'(lambda (v) (klangreihen 0 '(3 3 3 3) v)) variants))) (lengths (subseq (gen-divide total-parts (gen-length (distributive-cube (interference2 '(3 2 2))) 16)) 0 (length bases)))) ..... ) Looping over these global parameters, we start to build our theme sequentially, making all parts for each base. (loop for base in bases for length in lengths do (labels ... )) The LABELS special operator allows us to define local functions for our loop body, that will be helpful in transforming the data. Within it's function body, we have the actual loop that loops over the parts: (loop for n from 0 to (- total-parts 1) ...) The DESTRUCTURING-BIND macro allows us to keep our syntax clean and succint, because we can handle different cases using CASE, while setting Length, Velocity and Pitch, and then in a single line, retrieve those values and use them to set that particular omn in the parts array: (destructuring-bind (&key length pitch velocity) ;; Example of handling on a case-by-case basis. No extra cases configured now. (case n (otherwise (list :length (length-for n) :velocity (velocity-for n) :pitch (pitch-for n) ))) (setf (part study n) (make-omn :length length :pitch pitch :velocity velocity :span :pitch))) !#
  2. I'm making a score with 16 instruments. A metronome of drums and whistles (kind of conga rythm...) sounds. It does not sound when instrument count is low. Maybe it's a default MIDI setting? Note: This happens using: (live-coding-midi (compile-score 'score))
  3. Would anyone know how to disable the "Bells & Whistles" metronome while playing several instruments? Thank you
  4. I saw the update. This is great! I'm very glad I could contribute.
  5. "Dominik Šedivý: Serial Composition and Tonality" is mentioned several times in the function examples as further reading. I live in a place where books take 3 - 4 months to get here. Can I buy this book as an ebook? Thank you
  6. Here is a function that converts hertz to midi: (defun hertz-to-midi (frequency) "Gets the corresponding MIDI value from a Hertz frequency" (round ;; https://en.wikipedia.org/wiki/MIDI_Tuning_Standard#Frequency_values ;; d = 69 + 12*log2(f/440Hz) (+ 69 (* 12 (log (/ frequency 440) 2))))) This allows two more useful functions to be made: (defun hertz-to-integer (frequency) "Gets the corresponding pitch integer value from a Hertz frequency" (let ((*standard-output* (make-broadcast-stream))) ; Override function prints (midi-to-integer (hertz-to-midi frequency)))) (defun hertz-to-pitch (frequency) "Gets the corresponding pitch from a Hertz frequency" (midi-to-pitch (hertz-to-midi frequency))) This allows us to play with the harmonic series ( https://en.wikipedia.org/wiki/Harmonic_series_(music) ) ;;; Nth Harmonic (defun n-harmonic-hertz (note n) "Gets the n harmonic of a note as a hertz (Hz) value" ;; n * 440 * 2^( (m - 69) * (1/12) ) (let ((*standard-output* (make-broadcast-stream))) ; Override function prints (* n 440 (expt 2 (* (/ 1 12) (- (pitch-to-midi note) 69)))))) (defun n-harmonic-midi (note n) "Gets the n harmonic of a note as a midi value" (hertz-to-midi (n-harmonic-hertz note n))) (defun n-harmonic-pitch (note n) "Gets the n harmonic of a note as a pitch (tempered) value" (let ((*standard-output* (make-broadcast-stream))) ; Override function prints (midi-to-pitch (n-harmonic-midi note n)))) (defun n-harmonic-integer (note n) "Gets the n harmonic of a note as a pitch (tempered) value" (hertz-to-integer (n-harmonic-hertz note n))) ;;; Harmonic series (defun harmonic-series-pitch (fundamental number) "Gets 'number' amount of superior harmonics for a note as a list as pitches" (loop for i from 1 to number append (list (n-harmonic-pitch fundamental i)))) (defun harmonic-series-midi (fundamental number) "Gets 'number' amount of superior harmonics for a note as a list as MIDI values" (loop for i from 1 to number append (list (n-harmonic-midi fundamental i)))) (defun harmonic-series-hertz (fundamental number) "Gets 'number' amount of superior harmonics for a note as a list as Hertz frequencies" (loop for i from 1 to number append (list (n-harmonic-hertz fundamental i)))) (defun harmonic-series-integer (fundamental number) "Gets 'number' amount of superior harmonics for a note as a list as integer values" (loop for i from 1 to number append (list (n-harmonic-integer fundamental i)))) Examples: ;;; Examples (harmonic-series-hertz 'a4 8) => (440 880 1320 1760 2200 2640 3080 3520) (harmonic-series-midi 'a4 8) => (69 81 88 93 97 100 103 105) (harmonic-series-integer 'a4 8) => (9 21 28 33 37 40 43 45) (harmonic-series-pitch 'a4 8) => (a4 a5 e6 a6 cs7 e7 g7 a7)
  7. In all the examples, the score has the instruments readily defined by the programmer: (def-score (:score-prop score-val ...) (instrument-1 :instrument-prop instrument-val ...) (instrument-2 :instrument-prop instrument-val ...) ) What I have been wondering is can I dynamically create these instruments, allowing for proper reference in :layout afterwards, etc. For example, if I wanted 10 instruments: (defun my-generate-instrument ...) ;; something (def-score (:score-prop score-val ...) (loop for i from 1 to 10 collect (my-generate-instrument i))) Any tips for an scenario like this one?
  8. I am really sorry, I really don't want to oblige and your support has been great, but it seems I'm having more trouble. I hope this is not just me being a dummy and it helps in some way: 1- asdf:*central-registry* keeps pointing to /Users/opusmodus. No big deal, I added a setf in ~/.ccl-init.lisp that configures it. Manually downloaded the libraries that are referenced by it (cl-store, alexandria, xmls, cl-ppcre, cl-interval -- no idea about "quantizers"). 2- Installing drakma fails at usocket because Opmo can't find the CCL interfaces: https://gist.github.com/ajf-/8229a803a4717d589d59. (probe-file "ccl:") shows "/Applications/" which doesn't seem quite right. (#_getpid) shows more info: https://gist.github.com/ajf-/920d3be32f7e241c1b0d. I Manually installed ccl through brew install clozure-cl, and I tried to do: (ccl::replace-base-translation "ccl:" "/usr/local/Cellar/clozure-cl/1.10/libexec/") But I keep getting Error: Foreign function not found errors with (#_getpid) and (ql:quickload "usocket"). Trying the Apple Store version of CCL (at "/Applications/Clozure CL.app/Contents/Resources/ccl/") did not work either. A custom svn co from http://ccl.clozure.com/download.html did not do the trick either. 3- ~/.ccl-init.lisp doesn't seem to be loading on startup. I'll keep trying to sort this out tomorrow, but please let me know if there's something I am not doing right here and if there's any way I can help. Bests, Alain
  9. That, at least, doesn't give any errors: > (unless (find-package "QUICKLISP") (when (probe-file "~/quicklisp/setup.lisp") (load "~/quicklisp/setup"))) nil What should I do from here? Thank you!
  10. That gives the correct result: > (user-homedir-pathname) #P"/Users/ajf-/" Please don't hesitate to ask any sort of information from me to find a solution. I'll be happy to provide with whatever you need. Thank you
  11. Thank you for your ultra quick reply I really appreciate that. Doing that yields: > (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" "/Users/ajf-/"))) (when (probe-file quicklisp-init) (load quicklisp-init))) ; Warning: loading dependencies of #<system "quicklisp"> completed without its input file #P"/Users/opusmodus/quicklisp/quicklisp/quicklisp.asd" ; While executing: #<standard-method asdf/action:compute-action-stamp (t asdf/operation:operation asdf/component:component)>, in process Listener-1(7). > Error: File #P"/Users/opusmodus/quicklisp/quicklisp/package.lisp" not found > While executing: ccl::fcomp-find-file, in process Listener-1(7). > Type cmd-. to abort, cmd-\ for a list of available restarts. > Type :? for other options. Seems like it keeps referencing /Users/opusmodus regardless of that line. Maybe I should take further steps before this? Perhaps uninstall the quicklisp installation I did personally with SBCL? The second option you posted has the same effect. Again, thanks
  12. Following from this question, I want to use several different Lisp packages through quicklisp, but I can't get the installation to work correctly. After doing some digging, I found out that the path to quicklisp is not defined correctly. This is the content of the ql:*quicklisp-home* global: > ql:*quicklisp-home* #P"/Users/opusmodus/quicklisp/" I realised that changing this manually doesn't fix the issue, and because of this I can't install or use quicklisp correctly. Note that I do not have a user by the name opusmodus and creating that directory with my user's permission does not fix it. I managed to do something by using SBCL as my own user to load and install quicklisp, and then in opusmodus use the following: (load #p"/Users/ajf-/quicklisp/setup.lisp") But it's actually a workaround and it's not very reliable (also gives an error sometimes). Can you please point me in the right direction? Thank you very much
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy