Jump to content

Search the Community

Showing results for tags 'pattern matching'.



More search options

  • 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
  • Question & Answer
    • Suggestions & Ideas
  • Sharing
    • Made In Opusmodus
    • User Extensions Source Code

Blogs

  • Stephane Boussuge
  • Didier Debril

Categories

  • OMN The Language
  • Tutorial Guide
  • CLM Examples

Categories

  • Getting Started
  • HowTo
  • Live Coding
  • Music Theory and Analysis

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

Found 3 results

  1. Sometimes we generate some flow of pitch and lengths that we assemble later into OMN material, It can be tiedous to add manually the articulations particularly the "leg" omn instruction, and it can sometimes be useful to have a technique for automated implementation of part of these task, who it will be always possible to edit more precisely thereafter. Below a possible technique based on the recognition and association of patterns of lengths values with articulation instructions. At first, we define a stream of lengths for our phrase: (setf len '(1/8 1/8 1/16 1/16 -1/16 1/8 1/8 1/8 1/8)) and we generate with the help of the function substitute-motif some articulations based on motivic lengths patterns. The substitute-motif will search for motives and will replace this motives by other (in that case, replace by motives of articulation instructions) If the function doesn't find some corresponding motives, it will use the :otherwise clause. (setf artic (substitute-motif '((1/8 1/8)(1/16)) '((leg -)(stacc)) len :otherwise '-)) ;=> (leg - stacc stacc - leg - leg -) We have to process this output now with the function gen-swallow for "swallow" the item corresponding to rest values. (setf artic.swallow (gen-swallow len artic)) => (leg - stacc stacc leg - leg -) Finally, we assemble all the parameters into an OMN stream with the make-omn function: (setf omn (make-omn :pitch '((c4 d4 e4 f4 g4)) :length len :velocity '((f)) :articulation artic.swallow)) Here's a complementary score example: ;;; Length defintion based on euclidean algorithm (setf basery (euclidean-rhythm (rnd-sample 16 '(16 18 24)) 4 16 '1/16 :type 2)) ;;; Apply the search and substitute process on each of the sublists ;;; with mapcar function (setf artic (mapcar (lambda(x) (substitute-motif '((1/16 1/16 1/16 1/16)(1/16 1/16 1/16)(1/16 1/16)(1/8 1/8) (1/4)(1/8) ) ;old '((leg leg leg -)(- - -)(leg -)(leg -) (stacc)(stacc) ) ;new x :otherwise '- )) basery)) ;;;Cleaning with gen-swallow (setf artic.swa (gen-swallow basery artic)) ;;; Pitch generation based on white noise (setf pch (vector-to-pitch '(g3 c5) (gen-white-noise 64))) ;;; Parameters assembly (setf p1.omn (make-omn :pitch pch :length basery :velocity '((f)) :articulation artic.swa )) ;;; Get the times signatures (setf ts (get-time-signature p1.omn)) ;;; Score definition (def-score solo ( :title "solo" :composer "S.Boussuge" :key-signature 'chromatic :time-signature ts :tempo 108 :layout (violin-layout 'violon) ) (violon :omn p1.omn :channel 1 :sound 'gm :program 'violin) ) SB.
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; WHEN PATTERN-MATCH => T ;;; THEN WEIGHETD RANDOM DECIDING THE NEXT VALUE ;;; with :gate/:keyword = extra AND-function ;;; with :evaluate => you could evaluate a function-output directly ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; subfunctions (defun pattern-match (liste pattern) (loop for z in liste with cnt = 0 with pattern_cnt = 0 when (or (equal (nth cnt pattern) z) (equal '? (nth cnt pattern))) do (incf pattern_cnt) and do (incf cnt) else do (setq cnt (setq pattern_cnt 0)) when (equal pattern_cnt (length pattern)) collect 't into bag and do (return (car bag)))) (defun test.pm.omn (seq pattern) (let ((seq (if (omn-formp seq) (cond ((lengthp (car pattern)) (omn :length seq)) ((pitchp (car pattern))(omn :pitch seq)) ((velocityp (car pattern)) (omn :velocity seq))) (append seq)))) (pattern-match seq pattern))) (defun weighted-random (list) (loop for item in list with rand-num = (random (loop for x in list sum (second x))) for add = (second item) then (+ add (second item)) when (< rand-num add) return (first item))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; mainfunction (defun test.pm+chance (test.seq pattern values/weights &key keyword gate (evaluate 'nil)) (let ((out)) (setf out (if (and (test.pm.omn test.seq pattern) (equal keyword gate)) (weighted-random values/weights) (append gate))) (if (equal evaluate 't) (eval out) (append out)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; example => works also with OMN etc... (test.pm+chance '(1 2 3 4 5 4 3 5 6 7 2) '(5 ? 3) '((a 0.5) (b 0.15) (c 0.375) (d 0.21))) ;; more examples (test.pm+chance '(1 2 3 4 5 4 3 5 6 7 2) '(5 ? 3) '((a 0.5) (b 0.25) (c 0.25)) :gate 'no-entry :keyword 'no-entry) ;; => key correct (test.pm+chance '(1 2 3 4 5 4 3 5 6 7 2) '(5 ? 3) '((a 0.5) (b 0.5)) :gate 'no-entry :keyword 'whatever) ;; key incorrect ;; example with :evaluate T (test.pm+chance '(1 2 3 4 5 4 3 5 6 7 2) '(5 ? 3) '(((cons 'a 'b) 0.5) ((cons 'c 'd) 0.5)) :evaluate t)
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; WHEN PATTERN-MATCH => T ;;; THEN MARKOV PRODUCES THE NEXT VALUES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; subfunctions (defun pattern-match (liste pattern) (loop for z in liste with cnt = 0 with pattern_cnt = 0 when (or (equal (nth cnt pattern) z) (equal '? (nth cnt pattern))) do (incf pattern_cnt) and do (incf cnt) else do (setq cnt (setq pattern_cnt 0)) when (equal pattern_cnt (length pattern)) collect 't into bag and do (return (car bag)))) (defun test.pm.omn (seq pattern) (let ((seq (if (omn-formp seq) (cond ((lengthp (car pattern)) (omn :length seq)) ((pitchp (car pattern))(omn :pitch seq)) ((velocityp (car pattern)) (omn :velocity seq))) (append seq)))) (pattern-match seq pattern))) ;; mainfuction (defun test.pm+markov (seq pattern start-slot transitions &key (size 1)) (if (test.pm.omn seq pattern) (if (= size 1) (car (rest (gen-markov-from-transitions transitions :size (1+ size) :start start-slot))) (rest (gen-markov-from-transitions transitions :size (1+ size) :start start-slot))) (append start-slot))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setf transitions '((a (a 2) (b 1)) (b (a 2) (b 1)))) (setq test-omn '(t fs4 pp tasto g4 ppp tasto -s. t e4 pppp tasto -s. t eb4 pp tasto -het - t)) ;; examples1 (test.pm+markov test-omn '(pp ppp) 'a transitions) ;; evaluate a few times (test.pm+markov test-omn '(fs4 g4) 'a transitions) ;; evaluate a few times (test.pm+markov test-omn '(g2) 'a transitions) ;; evaluate a few times => no match => no new value (test.pm+markov test-omn '(1/32 -3/32) 'a transitions) ;; evaluate a few times ;; examples2 (test.pm+markov test-omn '(pp) 'a transitions :size 5) ;; evaluate a few times (test.pm+markov test-omn '(g4 e4) 'a transitions :size 3) ;; evaluate a few times ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
×
×
  • Create New...