Jump to content

Search the Community

Showing results for tags 'code'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to Opusmodus
    • Announcements
    • Pre Sales Questions
  • Support Forum
    • Support & Troubleshooting
    • OMN Lingo
    • Function Examples
    • Score and Notation
    • Live Coding Instrument
    • Library Setup
    • MIDI Setup
    • SuperCollider
  • Question & Answer
    • Suggestions & Ideas
    • Zoom into Opusmodus
  • Sharing
    • Made In Opusmodus
    • User Extensions Source Code
  • Opusmodus Network
    • Meet, Compose, Collaborate
    • Strategies and Methods to Control Complexity
  • Opusmodus Workshops & Schools
    • Composer Workshop

Categories

  • Tutorials
  • How-to in 100 sec
  • Made in Opusmodus
  • How-To
  • Zoom into Opusmodus
  • SuperCollider
  • Workflow
  • Live Coding
  • Presentation
  • Analysis
  • Composer Workshop

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Gender


Location


Interests


About Me

  1. Hi, here's a function i've made for my own usage and i think could be useful for others. It is a split point function which divide an OMN flux according to a list of split points. Attached, you will find the French doc of the function ;;; SPLIT-POINT ;;; SB. 2020 ;;; Fonction utile pour séparer les 2 mains pour une partie de piano ;;; renvoie une liste de listes (defun split-point (split-points omn-seq) (do-verbose ("split-point") (let* ( (spltconvert (if (numberp (car split-points)) split-points (pitch-to-integer split-points))) (spltp (gen-trim (length omn-seq) spltconvert)) (p1 (loop for sp in spltp for l in omn-seq collect (ambitus-filter `(,sp 128) l) )) (p2 (loop for sp in spltp for l in omn-seq collect (ambitus-filter `(-128 ,(- sp 1)) l) )) ) (list p1 p2)))) #| (split-point '(c4 d4) '((e a3d4 c4e4 f4c5 q g3d4 e4)(e a3d4 c4e4 f4c5 q g3d4 e4))) => (((e d4 c4e4 f4c5 q d4 e4)(q d4 e4 f4c5 d4 e4)) ((e a3 - - q g3 -)(e a3 c4 - q g3 -))) ;;; Example (setf pmat (make-scale 'c2 32 :alt '(2 1 2 3))) (setf pch (rnd-sample 128 pmat)) (setf chrd (chordize-list (gen-divide (rnd-number 8 1 4) pch))) (setf mat (length-legato (gen-filter-euclidean 8 16 4 16 chrd 's '(mf)))) (setf split (split-point '(c4) mat)) (setf piano-rh (ambitus-chord 12 (first split))) (setf piano-lh (ambitus-chord 12 (second split))) (ps 'gm :p (list piano-rh piano-lh) ) |# SB. split-point.rtfd.zip
  2. Hello! The example below has been taking several minutes to compile, eventually crashing Opusmodus. Would someone be willing to look at the code and let me know what's causing this? Thank you so much! (setf pattern1 (length-augmentation 2'((-h. q g4) (q. g4 e e4 q e4 -q) (-h. q g4) (q. g4 e d4 q d4 -q) (-h. q e4) (q f4 g4 a4 b4) (h. g4 -q)))) (setf pattern1a (length-augmentation 3 '((-h. q g4) (q. g4 e e4 q e4 -q) (-h. q g4) (q. g4 e d4 q d4 -q)))) (setf scale '(c4 eb4 f4 g4 ab4)) (setf pattern1-scale (tonality-map '(scale :map octave :closest up) pattern1)) (setf pattern1a-scale (tonality-map '(scale :map octave :closest up) pattern1a)) (setf voicesA (counterpoint (list pattern1-scale pattern1-scale pattern1a-scale) '(((1 2 3) :methods ( (dl1) (r dl1 t-12 pr1) (d1 t-24 pr1) ) )))) (ps 'gm :hn (list (1~ voicesA)) :tbn (list (2~ voicesA)) :tbn (list (3~ voicesA)) :time-signature '(4 4) )
  3. Move-set is a function inspired by Mikael Kuhn's move-set function in PGen for Csound. https://mikelkuehn.com/index.php/ng It allows you to make random choices by moving progressively in a morphing from one set to another linearly or by following a convex or concave curve controlled by the parameter: curve. <1 = concave, 1 = linear,> 1 = convex. The norep option allows you to remove direct repeats in random choices. ;;;====================================== ;;; MOVE-SET ;;; SB. 01.11.2020 ;;;====================================== ;;; Move-set est une fonction inspirée de la fonction move-set de Mikael Kuhn dans PGen pour Csound. ;;; Elle permet de faire des choix aléatoire en passant progressivement d'un ensemble à un autre ;;; de manière linéaire ou alors en suivant une courbe convexe ou concave controlée par le ;;; parametre :curve. <1 = concave, 1 = lineaire, >1 = convexe. ;;; l'option norep permet d'éviter les répétitions directes dans les choix aléatoires. ;;; Parametres: ;;; set1 liste ;;; set2 liste ;;; nbsteps entier ;;; nbval entier ou liste d'entiers ;;; curve <1 = concave, 1 = lineaire, >1 = convexe. Par défaut 1 ;;; norep nil ou t. par défaut nil. ;;; seed un entier. Par défaut nil. ;;; Definition de la fonction MOVE-SET (defun move-set (set1 set2 nbsteps nbval &key (curve 1) (norep nil) seed) "Move-set est une fonction inspirée de la fonction move-set de Mikael Kuhn dans PGen pour Csound. Elle permet de faire des choix aléatoires en passant progressivement dans un morphing d'un ensemble à un autre de manière linéaire ou alors en suivant une courbe convexe ou concave controlée par le parametre :curve. <1 = concave, 1 = lineaire, >1 = convexe. L'option norep permet d'éviter les répétitions directes dans les choix aléatoires. Parametres: set1 liste set2 liste nbsteps entier nbval entier ou liste d'entiers curve <1 = concave, 1 = lineaire, >1 = convexe. Par défaut 1 norep nil ou t. par défaut nil. seed un entier." (setf seed (rnd-seed seed)) (do-verbose ("move-set :seed ~s" seed) (init-seed seed) (let ((idx (gen-transition 0 (- nbsteps 1) nbsteps curve :rounded t)) (bmat (gen-morph nbsteps set1 set2 :seed (seed))) ) (loop for i in idx for v in (gen-trim nbsteps (list! nbval)) collect (rnd-sample v (nth i bmat) :norep norep)) ))) ;;; Exemples d'utilisation: #| (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 8) (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 8 :norep t) (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 8 :curve 0.2 :seed 4) (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 8 :curve 0.2 :seed 4 :norep t) (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 8 :curve 1.5 :seed 4 :norep t) (move-set '(c4 d4 e4) '(fs4 as4 cs5) 12 '(8 4 12 5) :curve 1.5 :seed 4 :norep t) (move-set '(e e e e) '(s s s s) 12 8 :seed 7) (setf melo (filter-tie (make-omn :pitch (setf pch (move-set '(c4 d4 fs4 gs4 b4) '(e4 g4 a4 bb4 cs5) 12 (rnd-number 6 2 16))) :length (gen-tuplet 1 1 'm '? 'w (mapcar 'length pch)) ))) |# SB. move-set.lisp
  4. here is a sketch for an alternative "binary-(or element-)layer-FUNCTION (defun element-layer (lists &key (rnd nil)) (let ((lists (if (null rnd) lists (rnd-order lists :list t)))) (car (last (loop for x in (rest lists) with list = (car lists) collect (setf list (loop for i in list with cnt = 0 when (equal i 0) collect (nth cnt x) and do (incf cnt) else collect i))))))) (element-layer (list '(1 0 0 1 1 0 0 1 0 0 0 0) '(0 2 3 0 4 5 0 6 0 7 8 0) '(11 12 13 14 15 16 17)) :rnd nil) => (1 11 2 1 1 3 12 1 4 5 13 6) ;;; hierarchic: every 0's will be replaced by the values from the next/sub-list...
  5. testing videoplayer in OPMO.mov whitenoise.mov
  6. Hi, i've made this function for my own usage. Sharing here if it can be useful for some others. It is a function who replace articulation by a given one on repeated notes. Best SB. ;;; OMN-REPLACE-ARTICULATION-IF-REPEAT (defun omn-replace-articulation-if-repeat (new-art omn-sequence) (do-verbose ("omn-replace-articulation-if-repeat") (let ((spn '()) (res '()) ) (progn (setf spn (get-span omn-sequence)) (setf res (loop for i from 0 to (- (length (flatten-sublist (single-events omn-sequence))) 1) collect (if (or (eq (second (nth i (flatten-sublist (single-events omn-sequence)))) (second (nth (+ 1 i) (flatten-sublist (single-events omn-sequence))))) (if (> i 0) (eq (second (nth i (flatten-sublist (single-events omn-sequence)))) (second (nth (- i 1) (flatten-sublist (single-events omn-sequence))))) ) ) (omn-replace :articulation new-art (nth i (flatten-sublist (single-events omn-sequence)))) (nth i (flatten-sublist (single-events omn-sequence))) ))) (length-span spn (flatten res)))))) ;;; EXEMPLE #| (setf mat '((s c4 p leg d4 leg e4 leg f4 q g4 f marc)(s a4 mp leg g4 leg leg f4 leg e4 leg leg leg d4 q c4 mf marc))) (omn-replace-articulation-if-repeat '(stacc) mat) => '((s c4 p leg d4 leg e4 leg f4 q g4 f marc) (s a4 mp leg g4 stacc g4 stacc f4 leg e4 stacc e4 stacc e4 stacc d4 q c4 mf marc)) |#
  7. ;;; ADD-RND-DUST TO LENGTHS ;;; this function adding RANDOMLY some "dust" to the LENGTHS, so it will be like a little rubato, ;;; or "humanizing"-effect. the ADD-SPAN is in percent (0.1 = 10%) on each length-value. (defun add-rnd-dust (omnseq &key (span '(0.1)) (seed nil) (quantize '(1 2 3 4 5 6 7 8 9))) (let ((rhy (omn :length omnseq)) (sp)) (progn (setf rhy (loop with cnt = 0 for i in rhy do (setf sp (nth cnt span)) when (not (null seed)) do (incf seed) when (> i 0) collect (+ i (car (rnd-number 1 0.0 (* i sp) :seed seed))) else collect (- i (car (rnd-number 1 0.0 (* i sp) :seed seed))) when (< cnt (1- (length span))) do (incf cnt))) (make-omn :length (quantize (float-to-ratio rhy :ratio 1/1) quantize) :pitch (omn :pitch omnseq) :velocity (omn :velocity omnseq) :articulation (omn :articulation omnseq))))) ;;; EXAMPLE (add-rnd-dust '(h c3 h. d3 -h q. f3 q g3) :span '(0.5 0.3 0.2 0.1) :quantize '(1 2 3 4 8) :seed 123) => (ht c3 h.s. d3 -e -q -t e.._3h f3 3q_q g3) (add-rnd-dust '(q c3 q d3 q e3 q f3 q g3) ;;possible add-span per value (1 = 100% of the value, 0.5 = 50% etc.) ;;if it's a list, it will stay on the last value of the span-list :span '(0.4 0.3 0 0 2) ;;how to quantize new lengths :quantize '(1 2 4 8) :seed 123) => (q c3 qt d3 q e3 f3 hs. g3) (add-rnd-dust '(h c3 h. d3 h e3 q. f3 q g3) :span '(0.5) ;; = every value max-add 50% :quantize '(1 2 3 4 8) :seed 2999) => (hs. c3 wt d3 3w.e e3 3wq. f3 q g3) (add-rnd-dust '(q c3 q d3 q e3 q f3 q g3) :span '(0.4 0.3 0 0 2) :quantize '(1 2 4 8) :seed 1111) => (qt c3 qs d3 q e3 f3 q... g3) (add-rnd-dust '(h c3 h d3 h e3 h f3 h g3) :span '(0.3 0.2 0.1 0 0.2) :quantize '(1 2 4 3 5) :seed 2999) => (5dh. c3 5dhq. d3 h e3 f3 he g3)
  8. greetings andré ;;; MODIFY THE PITCH CONTOUR inside a pitchfield or tonality ;;; please evaluate the example and have a look to the contours ;;; subfunction (defun position-items (items alist) (loop for item in items append (position-item item alist))) ;;; function (defun compr/expand-melody (melody field &key (type 'add) (n 1) (shift 0)) (let* ((ints (loop for i in (difference (position-items (pitch-to-midi melody) (pitch-to-midi field))) collect (cond ((equal type 'add) (cond ((<= i -1) (- i n)) ((>= i 1) (+ i n)) (t i))) ((equal type 'fibonacci) (cond ((>= i 1) (+ i (fibonacci i))) ((<= i -1) (- i (fibonacci (abs i)))) (t i))) ((equal type 'summativ) (cond ((>= i 1) (+ i (+ i n))) ((<= i -1) (- i (+ (abs i) n))) (t i))))))) (position-filter (x+b (interval-to-integer ints :start (car (position-items melody field))) shift) field))) ;;; expand 1a (progn (setf seed (random 100)) (pitch-list-plot (list (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 1) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 2) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 3) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 5) (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed)) :join-points t)) ;;; expand 1b => using shift (changed startposition) (progn (setf seed (random 100)) (pitch-list-plot (list (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 1 :shift 1) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 2 :shift 2) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 3 :shift 3) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n 5 :shift 4) (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed)) :join-points t)) ;;; compress (progn (setf seed (random 100)) (pitch-list-plot (list (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n -1) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n -2) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'add :n -3) (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed)) :join-points t)) ;;; expand 2 with fibonacci (progn (setf seed (random 100)) (pitch-list-plot (list (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'fibonacci) (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed)) :join-points t)) ;;; expand 3 summativ (progn (setf seed (random 100)) (pitch-list-plot (list (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'summativ :n 1) (compr/expand-melody (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed) (gen-sieve '(c1 c9) '(2 1 1) :type :pitch) :type 'summativ :n 2) (rnd-sample 7 (gen-sieve '(c4 c5) '(2 1 1) :type :pitch) :seed seed)) :join-points t)) some evaluations -> different melodic contours (rnd / in a sieve) and its expansions Bildschirmaufnahme 2019-05-26 um 22.04.38.mov
  9. have fun... greetings andré ;;; here is a MULTI-GEN-SORT ------------------------- ;;; you could interlace different processes of SORTING (defun multi-gen-sort (lists &key (types nil) (sorts '>) (steps nil) (seed nil)) (let* ((sorted-lists (loop for i in lists for cnt = 0 then (incf cnt) collect (gen-sort i :type (if (listp types) (nth cnt types) types) :sort (if (listp sorts) (nth cnt sorts) sorts) :step (if (listp steps) (nth cnt steps) steps) :seed seed)))) (flatten (loop repeat (find-max (loop for i in sorted-lists collect (length i))) for cnt = 0 then (incf cnt) collect (loop for i in (reverse sorted-lists) collect (nth cnt i)))))) ;;; some examples (pitch-list-plot (flatten (multi-gen-sort (list (expand-tonality '(c5 'chromatic)) (expand-tonality '(c3 'chromatic)) (expand-tonality '(c4 'chromatic)) (expand-tonality '(c6 'chromatic))) :types '(selection insertion min-max selection) :sorts '(> > > >) :steps '(7 6 7 3))) :join-points t :point-radius 0 :style :fill) (pitch-list-plot (flatten (multi-gen-sort (list (rnd-order (expand-tonality '(c5 'chromatic))) (rnd-order (expand-tonality '(c3 'chromatic))) (rnd-order (expand-tonality '(c6 'chromatic))) (rnd-order (expand-tonality '(c4 'chromatic)))) :types '(insertion selection min-max selection) :sorts '(> < < >) :steps '(5 3 7 nil))) :join-points t :point-radius 0 :style :fill) (pitch-list-plot (flatten (multi-gen-sort (list (rnd-order (expand-tonality '(c6 'chromatic))) (rnd-order (expand-tonality '(c5 'chromatic))) (rnd-order (expand-tonality '(c4 'chromatic))) (rnd-order (expand-tonality '(c3 'chromatic)))) :types '(selection nil insertion min-max) :sorts '(< > < >) :steps '(4 4 4 4))) :join-points t :point-radius 0 :style :fill) (pitch-list-plot (filter-repeat 1 (flatten (multi-gen-sort (list (rnd-order (expand-tonality '(c4 'chromatic))) (rnd-order (expand-tonality '(cs4 'chromatic))) (rnd-order (expand-tonality '(d4 'chromatic))) (rnd-order (expand-tonality '(ds4 'chromatic)))) :types '(insertion selection min-max selection) :sorts '(> < > <) :steps '(5 5 5 5)))) :join-points t :point-radius 0 :style :fill) ;;; a SORT2 :-) (pitch-list-plot (flatten (gen-sort (flatten (multi-gen-sort (list (rnd-order (expand-tonality '(c6 'chromatic))) (rnd-order (expand-tonality '(c5 'chromatic))) (rnd-order (expand-tonality '(c4 'chromatic))) (rnd-order (expand-tonality '(c3 'chromatic)))) :types '(selection nil insertion min-max) :sorts '(< > > >) :steps '(3 3 3 3))) :type 'insertion :step 7 :sort '>)) :join-points t :point-radius 0 :style :fill) some examples: a sorted mulit-gen-sort:
  10. ;;; THIS FUNCTION DOING SYMM TRANSPOSITIONS TO CONRACT (OR EXPAND, depends on INTERVAL) A CHORD or PITCH-SEQ ;;; default setting: it changes in every generation the highest and lowest pitch by an OCTAVE ;;; by changing :position (see examples) you could change which position should be changed/transposed ;;; default interval is 12 ;;; FUNCTION (defun chord-contraction/expansion (n pitchlist &key (position nil) (interval 12) (chord nil)) (let* ((pitchlist (if (chordp (car pitchlist)) (melodize pitchlist) pitchlist)) (position (if (null position) (list 0 (1- (length pitchlist))) (if (listp position) position (list position (- (1- (length pitchlist)) position))))) (pitchlist (cons pitchlist (loop repeat n collect (setf pitchlist (sort-asc (flatten (position-replace position (list (pitch-transpose interval (list (nth (car position) pitchlist))) (pitch-transpose (neg! interval) (list (nth (cadr position) pitchlist)))) pitchlist)))))))) (if (null chord) pitchlist (chordize pitchlist)))) ;;; EXAMPLES: evaluate by cmd3 (setf 12-tone-field '(f3 fs3 gs3 c4 d4 e4 b4 cs5 eb5 g5 a5 bb5)) (chord-contraction/expansion 4 12-tone-field :chord t) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4d4e4f4bb4b4cs5eb5g5a5) (gs3c4d4e4f4fs4a4bb4b4cs5eb5g5) (c4d4e4f4fs4g4gs4a4bb4b4cs5eb5) (d4eb4e4f4fs4g4gs4a4bb4b4c5cs5)) (chord-contraction/expansion 4 12-tone-field :chord t :interval 48) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (bb1fs3gs3c4d4e4b4cs5eb5g5a5f7) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (bb1fs3gs3c4d4e4b4cs5eb5g5a5f7) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5)) ;;; with spezific positions (inner change) (chord-contraction/expansion 4 12-tone-field :chord t :position 3) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (f3fs3gs3d4eb4e4b4c5cs5g5a5bb5) (f3fs3gs3cs4eb4e4b4c5d5g5a5bb5) (f3fs3gs3d4eb4e4b4c5cs5g5a5bb5) (f3fs3gs3cs4eb4e4b4c5d5g5a5bb5)) (chord-contraction/expansion 4 12-tone-field :chord t :position '(0 5)) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (e3fs3gs3c4d4f4b4cs5eb5g5a5bb5) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (e3fs3gs3c4d4f4b4cs5eb5g5a5bb5) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5)) ;;;; with different intervals (chord-contraction/expansion 4 12-tone-field :chord t :interval 11) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4d4e4e4b4b4cs5eb5g5a5) (gs3c4d4e4e4f4bb4b4b4cs5eb5g5) (c4d4e4e4f4g4gs4bb4b4b4cs5eb5) (d4e4e4e4f4g4gs4bb4b4b4b4cs5)) (chord-contraction/expansion 4 12-tone-field :chord t :interval 7) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4c4d4e4b4cs5eb5eb5g5a5) (gs3c4c4cs4d4e4b4cs5d5eb5eb5g5) (c4c4cs4d4eb4e4b4c5cs5d5eb5eb5) (c4cs4d4eb4e4g4gs4b4c5cs5d5eb5))
  11. hi all i'm looking for different SORTING ALGORITHMS in LISP - no problem to find (different) in the WWW... but: i would like to have as OUTPUT-result ALL generations of the SORTING-process and not only the LAST one - i'm interested in the PROCESS!! thanks for some help or any idea? (for once i do not want to code it myself :-)) greetings andré
  12. to use the function which works on event-numbers, first you have to number it (the score), so that you could work with this afterwards... ;;; ADD numbers to text attributes (can do that in your setup), then ADD number to events ;;; have a look to the example. after that, easy to use REPLACE-ON-EVENT-NUMBER etc... (defun add-numbers-to-text-attributes (a b) (loop for i from a to b append (add-text-attributes (list (compress (list 'nr i)) (write-to-string i))))) (add-numbers-to-text-attributes 0 100) (defun add-num-to-events (omnlist) (loop for x in (single-events omnlist) for i from 0 to (length (single-events omnlist)) when (omn-formp x) collect (omn-replace :articulation (list (compress (list 'nr i))) x) else collect x)) ;;; evaluate cmd3 (setf seq (add-num-to-events '(-q q c4 mp -q -q e e e e e q c4 mp -q -q q c4 mp -q))) => ((-q) (q c4 mp nr1) (-q) (-q) (e c4 mp nr4) (e c4 mp nr5) (e c4 mp nr6) (e c4 mp nr7) (e c4 mp nr8) (q c4 mp nr9) (-q) (-q) (q c4 mp nr12) (-q))
  13. the same idea with INSERT/REPLACE (defun replace-on-event-number (omn-list &key position/list (type 'replace) (output nil)) (progn (setf omn-list (loop for i in (single-events omn-list) for cnt = 0 then (incf cnt) with position-list = (loop for x in position/list collect (car x)) with list = (loop for y in position/list collect (rest y)) with cnt2 = 0 when (= cnt (nth cnt2 position-list)) collect (cond ((equal type 'replace) (if (listp (nth cnt2 list)) (flatten (nth cnt2 list)) (nth cnt2 list))) ((equal type 'add) (list i (nth cnt2 list)))) else collect i when (and (= cnt (nth cnt2 position-list)) (< cnt (car (last position-list)))) do (incf cnt2))) (if (equal output 'flatten) (flatten omn-list) omn-list))) ;;; EXAMPLES REPLACE (replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4) :position/list '((1 (q g5d5)) (5 -q)) :type 'replace) => ((q g4 mf) (q g5d5) (q g4 mf) (q g4 mf) (q g4 mf) (-q) (q g4 mf) (q g4 mf) (q g4 mf) (q g4 mf)) (replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4) :position/list '((1 (q g5d5)) (5 -q)) :type 'replace :output 'flatten) => (q g4 mf q g5d5 q g4 mf q g4 mf q g4 mf -q q g4 mf q g4 mf q g4 mf q g4 mf) ;;; EXAMPLES ADD (replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4) :position/list '((1 -e.) (5 -w)) :type 'add :output nil) => ((q g4 mf) ((-q) (-e.)) (q g4 mf) (q g4 mf) (q g4 mf) ((-q) (-w)) (q g4 mf) (q g4 mf) (q g4 mf) (q g4 mf)) (replace-on-event-number '(q g4 -q q g4 g4 g4 -q g4 g4 g4 g4) :position/list '((1 (w g6 ffff)) (5 -w)) :type 'add :output 'flatten) => (q g4 mf -q w g6 ffff q g4 mf q g4 mf q g4 mf -q -w q g4 mf q g4 mf q g4 mf q g4 mf) ;;;;
  14. ;;; FUNCTION: for some coding-cases i needed THIS function, to keep the OMN-notation ;;; and not to change to RATIO (otherwise i got strange results in NOTATION because the "ties are gone") (defun length-invert** (length-val) (append (compress (list '- length-val)))) ;;; EXAMPLES ;;; new => keeps OMN (length-invert** (car '(q e4 mp))) => -q ; in this case i wanted to keep the format with tie (length-invert** (car '(3q_q e4 mp))) => -3q_q ;;; original => changes to ratio (length-invert (car '(q e4 mp))) => -1/4 ; no tie here! i was in trouble :-) (length-invert (car '(3q_q e4 mp))) => -1/3
  15. Here's a new function a bit similar to my old "add-interval-if-length" function but bit more sophisticated. It use gen-chord3 to create chord on defined length. ;;; ============================================== ;;; UTILITY FUNCTIONS ;;; (defun make-chord-if-length-aux (omn &key (test #'>) (length-val 1/8) (interval-list '((4 7)(7 12))) (cycle t)(relative nil) seed) (setf seed (rnd-seed seed)) (let ((s-events (single-events omn))) (loop for e in s-events for i in (gen-trim (length s-events) interval-list) when (funcall test (omn-encode (first e)) length-val) append (omn-replace :pitch (gen-chord3 (list (second e)) i :cycle cycle :relative relative :seed (seed)) e ) else append e))) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4)) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7)(3 10))) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :seed 4) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :relative t) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :relative t :seed 4) ;;; ============================= ;;; MAIN FUNCTION (defun make-chord-if-length (omn &key (test #'>) (length-val 1/8) (interval-list '((4 7)(7 12)))(cycle nil)(relative nil) seed) (setf seed (rnd-seed seed)) (do-verbose ("make-chord-if-length :seed ~s :length-val ~s :interval-list ~s :cycle ~s :relative ~s" seed length-val interval-list cycle relative) (let ((test-fn (case test (> #'>) (< #'<) (= #'=) (otherwise test)))) (if (listp (car omn)) (mapcar #'(lambda (x) (make-chord-if-length-aux x :test test-fn :length-val (omn-encode length-val) :interval-list interval-list :cycle cycle :relative relative :seed (seed))) omn) (make-chord-if-length-aux omn :test test-fn :length-val (omn-encode length-val) :interval-list interval-list :cycle cycle :relative relative :seed (seed)))))) ;;; Tests ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4))) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :seed 8) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :interval-list '((2 9)(7 11))) ;(make-chord-if-length '((q c4 d4 e4 f4 g4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle t) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle nil :relative t) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle nil :relative t :seed 8) i've also attached the original file to this post. SB. make-chord-if-length.lisp
  16. hi all the following function could be usefull, it's a first sketch, but it seems to work.... if you want to INSERT a new OMN-seq, perhaps in bar 2 on the 3/20 in your BASIC-OMN-sequence... with this function you can do this, it will overwrite your original phrase. test it or tell me whatelse would be better... greetings andré ;;; ------------------------------------------------------------------------ ;;; INSERTING SEQ BY OVERWRITING ;;; ------------------------------------------------------------------------ ;;; SUB (defun get-resolution2 (beat) (cond ((memberp (cadr beat) '(3 6 12 24 48)) 1/24) ((memberp (cadr beat) '(1 2 4 8 16 32)) 1/16) ((memberp (cadr beat) '(5 10 20 40)) 1/20) ((memberp (cadr beat) '(7 14 28 56)) 1/28))) ;;; MAIN: INSERTING SEQ BY OVERWRITING (defun inserting-on-bar/beat* (seq &key insert time-sign bar beat) (let ((resolution (get-resolution2 beat)) (ord-time-sign time-sign) (time-sign (if (listp (car time-sign)) (loop for i in time-sign when (> (caddr i) 1) append (loop repeat (caddr i) collect (list (car i) (cadr i))) else collect (list (car i) (cadr i))) (append time-sign))) (distance (if (listp (car time-sign)) (+ (car (loop repeat (- bar 1) for i in time-sign collect (/ (* (1- bar) (/ (car i) (cadr i))) (get-resolution2 beat)))) (/ (/ (1- (car beat)) (cadr beat)) (get-resolution2 beat))) (+ (/ (* (1- bar) (/ (car time-sign) (cadr time-sign))) (get-resolution2 beat)) (/ (/ (1- (car beat)) (cadr beat)) (get-resolution2 beat)))))) (omn-to-time-signature (omn-merge-ties (flatten (loop repeat (length (omn-to-time-signature seq (list (numerator resolution) (denominator resolution)))) for cnt = 0 then (incf cnt) with new-seq = (omn-to-time-signature seq (list (numerator resolution) (denominator resolution))) with insert-rounded = (append insert (rest (length-rational-quantize (list (apply '+ (omn :length insert))) :round resolution))) when (= cnt distance) collect insert-rounded and do (setf cnt (+ (/ (get-span (flatten insert-rounded)) resolution) cnt -1)) else collect (nth cnt new-seq)))) ord-time-sign))) ;;; EXAMPLES (inserting-on-bar/beat* '((e c6 a5 h b5 tie) (q b5 b5 a5 tie) (h a5 q a5) (h. g5)) :insert '(s f3 e3 eb3 d3) :time-sign '(3 4) :bar 2 :beat '(2 16)) (inserting-on-bar/beat* '((e c6 a5 h b5 tie) (q b5 b5 a5 tie) (h a5 q a5) (h. g5)) :insert '(3q c5 b4 bb4 a4) :time-sign '(3 4) :bar 1 :beat '(2 12)) ;;; EXAMPLE WITH different TIME-SIGNATURES (inserting-on-bar/beat* '(e c6 a5 h b5 tie q b5 b5 a5 tie h a5 q a5 h. g5) :insert '(5q c5 b4 bb4 a4) :time-sign '((2 4 1) (3 8 1) (5 8 1) (3 4 1)) :bar 3 :beat '(3 20))
  17. ;; a function which fills up a sequence randomly - max-length = length sequence ;; (regardless of the number of cycles) (defun rnd-complete-seq (n &key sequence (step 1) seed (sort '<) (exclude nil) (append-excluded nil)) (let* ((testseq) (sequence (if (null exclude) sequence (filter-remove exclude sequence))) (sequence (loop repeat (length sequence) with sequence = (loop repeat n with seq = '() do (setf seq (append (rnd-unique step sequence :seed seed) seq)) do (setf sequence (filter-remove seq sequence)) collect seq) for i in (if (equal sort '<) (sort-asc sequence) (sort-desc sequence)) collect i))) (if (null append-excluded) sequence (progn (cond ((pitchp (first (car (last sequence)))) (setf testseq (pitch-to-midi sequence))) ((velocityp (first (car (last sequence)))) (setf testseq (get-velocity sequence))) (t (setf testseq sequence))) (if (< (first (car (last testseq))) (second (car (last testseq)))) (list sequence (sort-asc (append exclude (car (last sequence))))) (list sequence (sort-desc (append exclude (car (last sequence)))))))))) ;;; EXAMPLES (rnd-complete-seq 8 :sequence (expand-tonality '(b3 messiaen-mode6))) => ((b3) (b3 a4) (b3 a4 as4) (b3 f4 a4 as4) (b3 e4 f4 a4 as4) (b3 cs4 e4 f4 a4 as4) (b3 cs4 ds4 e4 f4 a4 as4) (b3 cs4 ds4 e4 f4 g4 a4 as4)) ;or => ((as4) (e4 as4) (e4 f4 as4) (cs4 e4 f4 as4) (cs4 e4 f4 g4 as4) (b3 cs4 e4 f4 g4 as4) (b3 cs4 ds4 e4 f4 g4 as4) (b3 cs4 ds4 e4 f4 g4 a4 as4)) ;or .... (rnd-complete-seq 5 :sequence '(0 1 2 3 4 5 6 7 8 9 10 11 12)) => ((1) (1 7) (0 1 7) (0 1 7 9) (0 1 7 9 11)) ;or => ((0) (0 1) (0 1 11) (0 1 6 11) (0 1 6 11 12)) ;or .... (rnd-complete-seq 5 :step 2 :sequence '(0 1 2 3 4 5 6 7 8 9 10 11 12)) => ((1 7) (0 1 7 8) (0 1 5 7 8 12) (0 1 5 7 8 9 10 12) (0 1 2 5 7 8 9 10 11 12)) (rnd-complete-seq 5 :step 2 :sequence '(0 1 2 3 4 5 6 7 8 9 10 11 12) :seed 234) => ((4 12) (3 4 11 12) (2 3 4 10 11 12) (2 3 4 5 9 10 11 12) (1 2 3 4 5 8 9 10 11 12)) (rnd-complete-seq 5 :step 2 :sequence '(0 1 2 3 4 5 6 7 8 9 10 11 12) :sort '> :seed 234) => ((12 4) (12 11 4 3) (12 11 10 4 3 2) (12 11 10 9 5 4 3 2) (12 11 10 9 8 5 4 3 2 1)) (rnd-complete-seq 5 :step 2 :sequence '(pppp ppp pp p mp mf f ff fff ffff) :sort '> :seed 234) => ((ffff p) (ffff fff p pp) (ffff fff ff p pp ppp) (ffff fff ff f mp p pp ppp) (ffff fff ff f mf mp p pp ppp pppp)) ;;; examples with EXCLUDE (rnd-complete-seq 4 :sequence '(1 2 3 4 5 6 7 8) :exclude '(1 8)) => ((5) (4 5) (2 4 5) (2 4 5 6)) (rnd-complete-seq 4 :sequence '(1 2 3 4 5 6 7 8) :exclude '(1 8) :append-excluded t) => (((7) (4 7) (4 5 7) (4 5 6 7)) (1 4 5 6 7 8)) (rnd-complete-seq 4 :sequence '(pppp ppp pp p mp mf f ff fff ffff) :exclude '(pppp ffff) :append-excluded t) => (((mf) (p mf) (ppp p mf) (ppp p mf f)) (pppp ppp p mf f ffff))
  18. Hi, here are the two functions i use daily in my workflow. The first gen-pitch-line can be used as this but is also required for the second function svoice1. svoice1 is a generic omn generator i find useful for my work. ;;; ------------------------------------------------------------------------------ ;;; GEN-PITCH-LINE ;;; Fonction de génération de hauteurs basées sur une conversion de vecteur de bruit ;;; avec un grand choix de type de bruit, taux de compression du vecteur, filtrage des répétitions et ambitus. (defun gen-pitch-line (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat (type :white)) (setf seed (rnd-seed seed)) (let (pitches) (do-verbose ("gen-pitch-line :seed ~s" seed) (labels ((white-or-pink (nb-pitch seed type) (if (eq type ':pink) (gen-pink-noise nb-pitch :seed seed) (gen-white-noise nb-pitch :seed seed :type (if (eq type ':white) :normal type)))) (process (nb-pitch &key (compress 1) (ambitus '(c4 c6)) seed filter-repeat type) (setf pitches (vector-to-pitch ambitus (vector-smooth compress (white-or-pink nb-pitch seed type)))) (when filter-repeat (setf pitches (gen-trim nb-pitch (filter-repeat filter-repeat pitches)))) pitches) ) (process nb-pitch :compress compress :ambitus ambitus :filter-repeat filter-repeat :seed (seed) :type type))))) #| USAGE (gen-pitch-line 24 :compress 0.42 :type :white :filter-repeat 1) (gen-pitch-line 24 :compress 0.42 :type :pink :filter-repeat 1) (gen-pitch-line 24 :compress 0.42 :type :extreme :filter-repeat 1) (gen-eval 8 '(make-omn :pitch (gen-pitch-line 24 :compress 0.42 :type :white :filter-repeat 1) :length (euclidean-rhythm 16 1 16 's :type 2) ) :seed 33) |# ;;; ------------------------------------------------------------------------------ ;;; SVOICE1 ;;; VERSION 0.1 (defun svoice1 (nb-pitch &key (level 16) (low 1) (high 16) (ratio 1/16) (e-type 2)(e-rotate nil)(e-variant nil) (compress 1)(filter-repeat nil)(pline-type :white) (p-divide nil)(articulation nil) (length nil)(pitch nil)(velocity nil) (seed nil)(articulation-map nil) (add-interval-if-length nil) (i-length '1/16) (i-list '(-4 -5 -3 -7)) ) (setf seed (rnd-seed seed)) (do-verbose ("svoice1 :seed ~s" seed) (let* (( pitch (if pitch pitch (if p-divide (gen-divide p-divide (gen-pitch-line nb-pitch :compress compress :seed (seed) :filter-repeat filter-repeat :type pline-type)) (gen-pitch-line nb-pitch :compress compress :seed (seed) :filter-repeat filter-repeat :type pline-type)))) (len (if length length (euclidean-rhythm level low high ratio :type e-type :rotate e-rotate :variant e-variant :seed (seed)))) (art (if articulation articulation (if articulation-map (length-map articulation-map len :otherwise '(default)) ))) (velo (if velocity velocity '(mf))) ) (if add-interval-if-length (add-interval-if-length (make-omn :pitch pitch :length len :velocity velo :articulation art ) :length-val i-length :interval-list i-list ) (make-omn :pitch pitch :length len :velocity velo :articulation art ))))) #| USAGE (svoice1 32) (svoice1 32 :seed 1234) (svoice1 32 :pitch '(c4 d4 e4) :articulation '(marc)) (svoice1 32 :length '((h h)(q q e e e e))) (svoice1 32 :pitch '(c4 g4) :length '((h h)(q q e e e e)) :velocity '((f)(pp))) (svoice1 32 :i-list '(-7 -4 -5 -3) :low 1 :high 4) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :compress 0.16) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :compress 0.16 :articulation-map '((1/8 stacc)(1/16 leg))) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :low 8 :high 8 :compress 0.16 :articulation-map '((1/8 stacc)(1/16 leg))) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :low 8 :high 8 :compress 0.16 :articulation-map '((1/8 stacc)(1/16 leg)) :add-interval-if-length t) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :low 2 :high 16 :compress 0.16 :articulation-map '((1/8 stacc)(1/16 leg))) (tonality-map '(((0 2 4 6 8 10) :root d4)) (svoice1 128 :p-divide 8 :level (gen-repeat 12 '(16)) :low 2 :high 16 :compress 0.16 :articulation-map '((1/8 stacc)(1/16 leg))) ) |# S.
  19. works, but only for one-time-repetiton... could you use it? (defun merge-lengths-of-a-pitch-rep (omn-seq) (let* ((omn-seq (single-events omn-seq)) (l)) (flatten (loop repeat (length omn-seq) for cnt = 0 then (incf cnt) when (equal (omn :pitch (nth cnt omn-seq)) (omn :pitch (nth (1+ cnt) omn-seq))) do (progn (setf l (length-note-merge (append (omn :length (nth cnt omn-seq)) (omn :length (nth (1+ cnt) omn-seq))))) (incf cnt)) and collect (omn-replace :length l (nth cnt omn-seq)) else collect (nth cnt omn-seq))))) (merge-lengths-of-a-pitch-rep '(e c4 mf d4 d4 e4 f4 f4)) => (e c4 mf q d4 mf e e4 mf q f4 mf)
  20. ;;; removes pitches by its position-number, will be replaced by rests. (starts with 0) (defun omn-pitch-position-remove (positions omnseq) (length-rest-merge (loop for i in (single-events omnseq) with cnt = 0 when (and (pitchp (cadr i)) (not (equal 'nil (member cnt positions)))) append (make-omn :length (list (length-invert (car i)))) else append i when (pitchp (cadr i)) do (incf cnt)))) (omn-pitch-position-remove '(0 1) '(-q e c4 e d4 e e4 e e e e)) => (-h e e4 mf e4 e4 e4 e4) (omn-pitch-position-remove '(2 4) '(-q e c4 e d4 e e4 e e e e)) => (-q e c4 mf d4 - e4 - e4 e4) or more common (defun omn-position-remove (positions omnseq &key (type 'pitch)) (length-rest-merge (loop for i in (single-events omnseq) with cnt = 0 when (and (cond ((equal type 'pitch) (pitchp (cadr i))) ((equal type 'length) (lengthp (car i)))) (not (equal 'nil (member cnt positions)))) append (make-omn :length (list (length-invert (car i)))) else append i when (cond ((equal type 'pitch) (pitchp (cadr i))) ((equal type 'length) (lengthp (car i)))) do (incf cnt)))) (omn-position-remove '(2 4) '(-q e c4 e d4 e e4 e e e e) :type 'pitch) => (-q e c4 mf d4 - e4 - e4 e4) (omn-position-remove '(0 4) '(e c4 e d4 e e4 e e e e) :type 'length) => (-e d4 mf e4 e4 - e4 e4) could be also extended for articulation/velocity
  21. could be an interesting idea for OPMO? (or already existing?) greetings andré ;;; a function (a sketch - i needed it for my momentary work) which filters ;;; an OMN-sequence in a specific bar, from a specific beat, with a specific ;;; span. (in such a basic version all in quarters (bars/...)) (defun copy-omn-seq (omnseq bar/beat-list &key (measure '(4/4)) (span nil)) (loop for i in bar/beat-list collect (loop repeat (if (null span) (- (/ (car measure) 1/4) (1- (cadr i))) span) for x = (1- (cadr i)) then (incf x) append (nth x (omn-to-measure (nth (1- (car i)) (omn-to-measure omnseq measure)) '(1/4)))))) (setf mat '((e c4 cs4 d4 ds4 e4 f4 fs4 g4) (e c3 cs3 d3 ds3 e3 f3 fs3 g3) (e c6 cs6 d6 ds6 e6 f6 fs6 g6))) (copy-omn-seq mat '((2 3))) ;; bar 2 from beat 3 until end of bar => ((e e3 f3 e fs3 g3)) (copy-omn-seq mat '((1 1)) :span 2) ;; bar 1 from beat 1 for 2 quarters => ((e c4 cs4 e d4 ds4)) (copy-omn-seq mat '((1 2) (2 3) (3 4))) ;; same thing with more then ONE filterings => ((e d4 ds4 e e4 f4 e fs4 g4) (e e3 f3 e fs3 g3) (e fs6 g6)) (copy-omn-seq mat '((1 2) (2 3) (3 4)) :span 1) ;; same - every filtering with span 1 => ((e d4 ds4) (e e3 f3) (e fs6 g6))
  22. ;;; CHANGE-TIME-STRUCTURES ;;; works okay, but not exactly precise because of rhy-to-integer, which is not very easy in some cases ;;; this function changes basic-rhy-structures (if it's all the time perhaps in x/32) ;;; to other/changing sections. the lengths/rests will be rounded like in LENGTH-RATIONAL-QUANTIZE ;;; rhy+span => '((32 2) (44 7)) => means in 32 three values, in 44 seven values (defun change-time-structure (omnseq rhy+span &key (basic-rhy 32) (round 1/4)) (let* ((intseq (loop for i in (omn :length (flatten omnseq)) collect (* i basic-rhy))) (rhyseq (mapcar #'car rhy+span)) (spanseq (mapcar #'cadr rhy+span)) (divided-intseq (gen-divide spanseq intseq))) (length-rational-quantize (flatten (gen-length divided-intseq rhyseq)) :round round))) (change-time-structure '(2/44 -2/44 3/44 5/44 6/44) '((32 2) (20 2) (28 3)) :basic-rhy 44) => (1/16 -1/16 -1/8 3/20 1/4 -1/10 3/14 -1/28) (change-time-structure '(2/32 -2/32 3/32 5/32 6/32) '((20 2) (44 2) (28 3)) :basic-rhy 32) => (1/10 -1/10 -1/20 3/44 5/44 -3/44 3/14 -1/28) could be done better -> go for it greetings andré
  23. a sieve/filter-function - filters specific INTERVALS and replacing the others by rests. (don't work perfect, but as a sketch....) ;;; (defun equal/or (n alist) (car (loop for i in alist when (equal i n) collect 't))) ;;; FUNCTION (defun filter-omn-by-intervals (omn-seq intervals) (setf omn-seq (loop with omn-events = (single-events omn-seq) with i = 0 while (not (null (nth i omn-events))) when (equal/or (car (pitch-to-interval (append (omn :pitch (nth i omn-events)) (omn :pitch (nth (1+ i) omn-events))))) intervals) collect (list (nth i omn-events) (nth (1+ i) omn-events)) and do (incf i 2) else collect (neg! (car (omn :length (nth i omn-events)))) and do (incf i)))) ;;; EXAMPLE (setf basic-omn-seq (make-omn :pitch (vector-to-pitch '(c4 c6) (gen-white-noise 100 :type :logistic)) :length '(t) :span :pitch)) ;;; check out all these filter-tests (setf omn-seq (filter-omn-by-intervals basic-omn-seq '(1 2 3))) ;(setf omn-seq (filter-omn-by-intervals basic-omn-seq '(3 -3))) ;(setf omn-seq (filter-omn-by-intervals basic-omn-seq '(1 -1 5 -5 7 -7))) (def-score example (:title "example" :key-signature 'atonal :time-signature '(4 4) :tempo 90) (instrument1 :omn (flatten omn-seq) :channel 1 :sound 'gm-piano) (instrument2 :omn (flatten basic-omn-seq) :velocity 20 :channel 3 :sound 'gm-piano)) here is a more complex example (defvar library) (defvar abfolge) (defvar omn-seq) (defvar rhy) (defvar field) ;;;library + rhy -------------------------------------------------------------------------------- (setf rhy 44) ;;; LIBRARY MIRT RHY-PAAREN! (setf library (list '(eb5 5 p mute) '(e4 5 mf mute) '(gs4 3 f mute) '(g5 3 ppp mute) '(f6 2 p mute) '(cs4 1 f mute) '(d5 1 fff mute) '(b3 4 pppp mute) '(bb5 4 mp mute) '(a4 3 pp mute) '(fs3 (2 7) ppp mute) '(c6 (1 11) mp mute))) (setf library (loop for i in library collect (append (list (car i)) (if (listp (cadr i)) (gen-length (list (rnd-pick (cadr i))) rhy) (gen-length (list (cadr i)) rhy)) (filter-last 2 i)))) ;;; gen seq from library/abfolge--------------------------------------------------------------- (setf field '(eb5 e4 gs4 g5 f6 cs4 d5 b3 bb5 a4 fs3 c6)) (setf abfolge (pick-norepeat 500 field)) (setf omn-seq (loop for x in abfolge with y do (setf y (assoc x library)) append (append (reverse (filter-first 2 y)) (filter-last 2 y)))) (setf basic-omn-seq omn-seq) (setf omn-seq (filter-omn-by-intervals basic-omn-seq '(1 -1 11 -11 13 -13 4 -4 8 -8 16 -16 20 -20 28 -28 32 -32 7 -7 19 -19))) ;;;--------------------------------------------------------------------------------------------- (def-score example2 (:title "example2" :key-signature 'atonal :time-signature '(4 4) :tempo 90) (instrument :omn (flatten omn-seq) :channel 1 :sound 'gm-piano) (hidden-structure :omn (flatten basic-omn-seq) :channel 1 :velocity 0 :sound 'gm-piano)) ;;;--------------------------------------------------------------------------------------------- (omn-list-plot (flatten omn-seq) :join-points t)
  24. (defun replace-lengths-of-a-pitch-sequence (omn-list pitch-list length-list) (flatten (loop with cnt = 0 for i in (single-events omn-list) when (equal (cadr i) (nth cnt pitch-list)) collect (append (list (nth cnt length-list)) (rest i)) and do (incf cnt) else collect i when (= cnt (length pitch-list)) do (setf cnt 0)))) (setf white-series-l (vector-to-pitch '(c4 c5) (gen-white-noise 100 :type :logistic :seed 23))) (replace-lengths-of-a-pitch-sequence (cons 't white-series-l) '(e4 f4 a4 gs4 g4 b4 c5 bb4) '(2/16 3/16 4/16 5/16 6/16 7/16 8/16)) => '(t gs4 mf t g4 mf t g4 mf t c5 mf t g4 mf t gs4 mf 1/8 e4 mf 3/16 f4 mf t gs4 mf t gs4 mf t bb4 mf t gs4 mf t fs4 mf t fs4 mf t f4 mf t g4 mf t bb4 mf t b4 mf t b4 mf t g4 mf t e4 mf t g4 mf t fs4 mf t b4 mf 1/4 a4 mf t g4 mf t g4 mf t a4 mf t b4 mf t fs4 mf t bb4 mf t a4 mf 5/16 gs4 mf t a4 mf 3/8 g4 mf t a4 mf t a4 mf t a4 mf t a4 mf t a4 mf t f4 mf t bb4 mf t g4 mf t fs4 mf 7/16 b4 mf t a4 mf t g4 mf t bb4 mf t a4 mf t gs4 mf t a4 mf t gs4 mf t g4 mf t g4 mf t gs4 mf t a4 mf t f4 mf t f4 mf t bb4 mf t gs4 mf t fs4 mf t a4 mf t g4 mf t a4 mf t g4 mf t gs4 mf t bb4 mf t eb4 mf t bb4 mf t fs4 mf t fs4 mf t gs4 mf t g4 mf t gs4 mf t gs4 mf t c4 mf t gs4 mf t g4 mf t gs4 mf 1/2 c5 mf bb4 mf t gs4 mf t fs4 mf t fs4 mf t bb4 mf t a4 mf t g4 mf t g4 mf t b4 mf t g4 mf t f4 mf t g4 mf t gs4 mf t gs4 mf t gs4 mf t gs4 mf t fs4 mf t gs4 mf t eb4 mf t a4 mf)
  25. hi all i would like to code a NAND gate with more then two input-items (as extension to AND etc...). here is a simple version of the NAND function with two inputs, but i don't know how to exapnd it to n-inputs without putting the the inputs to in a list (like lisp-internal AND / OR)... https://en.wikipedia.org/wiki/NAND_gate i dont't want it: (nand '(t t t nil)) but like to have (nand t nil nil t t t) when i get a solution for that i will code an XOR, NOR etc.... so the "problem" is: how to manage in DEFUN more then two inputs (don't work with &optional, i think) i tried it and failed)... any ideas, lisp-nerds? thanx! andré ;;; easy with a specific number of input-items - that works! (defun nand (a b) (not (and a b))) (nand t t) => nil (nand nil nil) => t (nand nil t) => t ;;; i like to have an input perhaps like that - with any number of input-items, like lisp's AND / OR (nand t t t t) (nand nil t t t nil t t t nil) ...
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy