Jump to content

pattern-match with overwrite -> question


Recommended Posts

hi all

 

i'm trying to code a PM-function with an OVERWRITE, so that the global-lengths stays correct... i'm working this evening with some ideas for that and this is only a first sketch of a basic idea, don't know if it will work later...

 

i have one little ordinary problem: to find/insert/overwrite i have to split the original sequence into small parts... that's the RESOLUTION, so i have a list with OMN-events in the span of the resolution. and a lot of TIEs -> at the end i would like to remove the tied-lengths by ordinary lengths? how? filter-tie works not with all insert-examples.... what can i do...?

 

thanx

andré

 

;;; --------------------------------------------------------------------------------------------
;;; OVERWRITE -> überschreibt eine sequenz bei PM -> resolution einstellbar
;;; --------------------------------------------------------------------------------------------

;;; ausgangs-sequenz
(setf seq '(q c4 d4 e. e4 s f4 h g4))

;;; inserts => test different INSERTS
(setf insert '(t gs5 g5 fs5 f5 e5))
;(setf insert '(q gs5 -e e gs5))
;(setf insert '(1/24 gs5 1/24 1/24))

;;; pattern => if such a pattern matched => now INSERT starting at PITCH f4
(setf pattern '(? f4))

;;; resolution of SCANNING/INSERTING
(setf resolution 1/16)

;;; --------------------------------------------------------------------------------------------
(setf omn-old seq)
(setf omn-new (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 (pattern-matchp (nth cnt new-seq) pattern) collect insert-rounded
                and do (incf cnt (/ (apply '+ (abs! (omn :length insert-rounded))) resolution))
                collect (nth cnt new-seq)))

(setf omn-new (flatten omn-new))

;;; --------------------------------------------------------------------------------------------
(def-score test
           (:title "test"
                   :key-signature 'atonal
                   :time-signature '(4 4)
                   :tempo 90
                   :layout (bracket-group 
                            (treble-layout 'new)
                            (treble-layout 'old)))
  (new 
   :omn omn-new
   :channel 1
   :port 1
   :sound 'gm
   :program 'acoustic-grand-piano)

  (old 
   :omn omn-old
   :channel 1
   :port 1
   :sound 'gm
   :program 'acoustic-grand-piano))

 

added 4 minutes later

some other ideas to the main problems or some great solutions are very welcome :-)

Link to post
Share on other sites

Hi,

 

i don't know if this could help you but just in case, here's how i use pattern-map inside some of my functions:

 

;;; =============================================
;;; ARTICULATION-MAP
;;; AJOUTE DES ARTICULATIONS SUR DES LISTES OMN
;;; BASÉES SUR DU PATTERN MATCHING.
;;; =============================================

(defun articulation-map (map omn &key (otherwise '-))
  (do-verbose
      ("articulation-map")
  (let* ((plist (disassemble-omn omn)))
         (setf (getf plist :articulation)
               (pattern-map map (getf plist :length) :otherwise otherwise :swallow t))
    (apply 'make-omn plist))))

#| USAGE
(setf mat '((q c4 p d4 e e4 f4 s g4 f a4 g4 f4 q e4)(e d4 mp c4 s d4 e4 f4 e4 q d4 e c4 b3)(h a3 f -h)))

(setf prules '(
               ((s s s) (leg leg leg))
               ((s s)(leg leg))
               ((s e)(- -))
               ((s q)(- stacc))
               ((q) (stacc))
               ((e) (-))
               ))

(setf out (articulation-map prules mat))
|#

Cheers.

 

Stéphane.

Link to post
Share on other sites

thanx...!!! the concrete question was... i could eliminate the TIEs in such a sequence... (and add the tied 1/16-lengths) -> simplify the notation

 

'(s c4 tie s c4 tie s c4 tie s c4 s d4 tie s d4 tie s d4 tie s d4 s e4 tie s e4 tie s e4 t gs5 g5 fs5 f5 e5 -1/32 s g4 tie s g4 tie s g4 tie s g4 tie s g4 tie s g4)

 

Link to post
Share on other sites

yes, but wrong with this...

 

'(s c4 tie s c4 tie s c4 tie s c4 s d4 tie s d4 tie s d4 tie s d4 s e4 tie s e4 tie s e4 1/24 gs5 1/24 1/24 s g4 tie s g4 tie s g4 tie s g4 tie s g4 tie s g4 tie s g4)

because of the 1/24... why?

Link to post
Share on other sites
(omn-merge-ties
'(s c4 tie s c4 tie s c4 tie s c4 s d4 tie s d4 tie s d4 tie
   s d4 s e4 tie s e4 tie s e4 t gs5 g5 fs5 f5 e5 -1/32
   s g4 tie s g4 tie s g4 tie s g4 tie s g4 tie s g4))
=> (q c4 d4 e. e4 t gs5 g5 fs5 f5 e5 - q. g4)

(omn-merge-ties
'(s c4 tie s c4 tie s c4 tie s c4 s d4 tie s d4 tie s d4 tie
    s d4 s e4 tie s e4 tie s e4 1/24 gs5 1/24 1/24 s g4 tie
    s g4 tie s g4 tie s g4 tie s g4 tie s g4 tie s g4))
=> (q c4 d4 e. e4 3e gs5 gs5 gs5 q.. g4)

I will make a doc for the function soon.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Topics

    • By PatrickMimran
      Hello 
       
      I would like to know what the more efficient way , when creating a lot of  custom function to be included in the Extension folder:
       
      to group all the function in the same file
       
      or to distribute them over several files .  Or one function by file or it doesn't matter 
       
      Thank you   Patrick
    • By NagyMusic
      I understand that the first argument value in the ambitus-chord function represents the outer-interval size measured by an integer or a list of integers. What does the second value in the size argument list affect when processing two [or more] chords, as illustrated in the example below? Is the second value affecting the second chord in the first list or both chords in the second list? Thank you!
       
      (ambitus-chord '(14 6) '((eb4c6 c4fs4 b4) (c4b4 b3eb5b3)))  
    • By NagyMusic
      After a short break, I'm slowly coming back to Opusmodus, mainly by working through functions examples. Looking at the gen-ambitus-series
      function example below, would someone be willing to explain why the ambitus function is not producing all diatonic pitches included in list_? I understand that I may want to use harmonic-path or similar instead, but I just wanted to ask for the learning experience. I feel like I might be missing something so I welcome the feedback!
       
      (setf range_ (gen-ambitus-series '(-10 30) (vector-smooth 0.2 (gen-white-noise 6 :seed 23)) (vector-smooth 0.2 (gen-white-noise 8 :seed 24)))) (integer-to-pitch range_) (setf list_ '((c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) (c4 d4 e4 f4 g4 a4 b4 c5) )) (ambitus range_ list_) Perhaps a different example may illustrate my question better. Below we have a series of transformation of the given harmonic sequence. The pitches (pitch classes) of the harmonic sequence are retained with each individual ambitus transformation, but not when gen-ambitus-series is used (see below). Thanks!
       
      (setf omn '((h e4f5 p c5a4) (h b3d3 gs4eb2fs3) (h bb2g5cs5 gs4d4eb2) (w bb2 mp) (h g3f4cs5 p c5) (h fs5a5b3 e4b3) (h bb2) (w e2eb4) (h c5cs6 a5) (h f4g3 gs4d3) (h fs5 bb2fs5g3) (h d3e5eb4 gs4) (h a2c6 f2) (h b0 cs6c5) (h gs4d3))) (ambitus '(-6 12) omn) (setf range (gen-ambitus-series '(-30 42) (vector-smooth 0.2 (gen-white-noise 15 :seed 23)) (vector-smooth 0.2 (gen-white-noise 15 :seed 24)))) (ambitus range omn)  
       
×
×
  • Create New...