Jump to content

Add appoggiatura before length value


Recommended Posts

Hi everyone, I am having a hard time trying to add appoggiaturas to selected length values on an omn sequence. Let's say I want to search for all whole durations and add an appoggiatura before this event. I have been trying these kind of solutions using dictum

 

(setf mat '(w c4 stacc))

(dictum '(
	(:and w :apply (app e f4))
    )
    mat)
    
 (dictum '(
	(:and w :apply '(app e f4))
    )
    mat)
    
  (dictum '(
	(:and w :apply ((app e f4) w))
    )
    mat)   
    
   (dictum '(
	(:and w :apply (app e f4 w))
    )
    mat)      

 

All of these fail. I get some error saying the sequenced-event :type nil :phrase (nil nil) is not of type ?event when accessing slot attribute.

 

I don't think I understand how to use app or acc properly, at least in terms of dictum or patterns. I have also tried with length-map pattern-map with no luck.  

 

I have also tried to insert a ttrem between two half notes in an omn sequence for example and I encounter the same kind of errors. How can I search for a sequence of events inside dictum? I know how to use both app and ttrem when writing opusmodus expression manually, but not when replacing or finding patterns

 

I suspect there is some basic issue of the language that I still do not understand.

 

Many thanks for your help.

Link to comment
Share on other sites

Hi,

 

here#s some code I wrote long time ago, may be useful for you.

 

;;; UTILITY FUNCTION
(defun pitch-transpose-app-acc (trsp orn)
  " Definition d'un pitch-transpose qui supporte les symboles
  étrangers tels que app ou acc"
  (let* ((all-omn (disassemble-omn (cdr orn)))
        (pch (getf all-omn :pitch))
        (len (getf all-omn :length))
        (vel (getf all-omn :velocity))
        (art (getf all-omn :articulation))
        (apo (nth 0 orn))
        (res (cons apo
                   (make-omn
                    :pitch (pitch-transpose trsp pch)
                    :length len
                    :velocity vel
                    :articulation art
                    )))
        )
    res
    ))

;(pitch-transpose-app-acc 4 '(app s d4 e4 f4 g4))


;;; MAIN FUNCTION

(defun gen-ornament (orn omn &key (val '(q h))(cycle t) seed)
  (let (state)
    (setf state *init-seed*)
    (setf seed (rnd-seed seed))
    (do-verbose ("gen-ornament seed: ~s" seed)
  (let*  ((events (single-events omn))
          (tsig (get-time-signature omn))
          (posi (position-item 't (mapcar 'event-restp (flatten-sublist events))))
          (res (omn-to-time-signature
                (flatten-sublist
                 (loop
                   for e in (flatten-sublist events)
                   for o in (position-insert
                             posi 'nil
                             (gen-trim 
                              (length (flatten-sublist events)) 
                              (if cycle orn (rnd-order orn :list t :seed (seed))))
                             :type 'list)

                   collect
                             (if (member (1~ e) val)
                               (append  (list (pitch-transpose-app-acc (pitch-to-integer (nth 1 e))  o)) e)
                               e)))
                tsig)
               )
          )
    (init-state state)
    res))))


;;; USAGE
#|
(setf phrase '((h eb4 gs4)
               (s c4 e4 g4 a4 q eb4 - e. bb4 s cs4)
               (q. d4 s e4 eb4 q. g4 s e4 a4)
               (-q e. f4 s e4 e. g4 s q c4)
               (q a4 q. fs4 e c4 -q)
               (h g4)))

(setf phrase2
          '(#|1|# (q. d4 s leg s f4 def q cs4 e f4 stacc cs4 stacc)
            #|2|# (s eb4 p< leg e4 < leg d4 < leg cs4 < def h f4 f -q)
            #|3|# (q c4 f marc e d4 marc gs4 marc  q marc q c4 marc)
            #|4|# (h cs4 mp def q. g4 s fs4 p leg c4)
            #|5|# (q. eb4 mf s f4 a4 h e4)
            #|6|# (s c4 f> leg bb4 > leg f4 > leg e4 p def -q h b4 f tr1)
            ))

(gen-ornament '((app s c4 fs4 f4 e4)(acc e a3 d4)) phrase)
(gen-ornament '((acc s c4 fs4 f4 e4)) phrase :val '(q.))
(gen-ornament '((acc s c4 fs4 f4 e4)(acc s g4 f4 e4 d4)) phrase2 :val '(h q))
(setf test (gen-ornament '((acc t c4 fs4 f4 e4)(acc t g4 f4 e4 d4)) (pitch-transpose 12 phrase2) :val '(h q) :cycle nil))
(setf test2 (gen-ornament '((acc t c4 fs4 f4 e4)(acc t g4 f4 e4 d4))
                          (pitch-transpose 12 phrase2) :val '(h q) :cycle nil :seed 123))
(ps 'gm :fl (list test) :tempo 40)

|#


SB

Link to comment
Share on other sites

Thanks Stephane! Your function is exactly what I need but it does not work in all cases and I am not sure why.

 

I usually write materials this way, in a single list

(setf mat '(h eb4 gs4))
(gen-ornament '((acc e c4 fs4)) mat :val '(h))

 

Your code does not work because it expects a list inside a list, it says it can't take the car of h. It is better to always write material inside a list? Why?


Then I tried this

(setf mat '((h eb4 gs4)))
(gen-ornament '((acc e c4 fs4)) mat :val '(h))

 

But the code does not work either, I get this error: nil is illegal as a sequence start index.


Then I tried with a longer phrase and it works fine

(setf mat '((w d3 s eb3 w e3 s eb3 d f3 -h w fs3)))
(gen-ornament '((acc e c4 fs4)) mat :val '(w))


But if I try a much longer material, it works but I can't notate the snipet with cmd-1, I get an error about some 1147 midi value and TIME_SIGNATURE_EVENT

(setf mat '((w d3 s eb3 w e3 s eb3 d f3 -h w fs3 s e3 d3 f3 d e3 -h w d3 s fs3 w eb3 s e3 fs3 eb3 d3 f3 d fs3 -h w d3 s f3 w eb3 s e3 d d3 -h w eb3 s e3 f3 fs3 d g3 -h w e4 s f4 w gs3 s fs3 e4 gs3 fs3 f4 d g3 -h w gs3 s f4 w g3 s fs3 d e4 -h w f4 s fs3 e4 g3 d gs3 -h w fs3 s g3 w gs3 s e4 f4 f3 g3 eb4 d fs3 -h w e3 s g3 w fs3 s e3 d eb4 -h w f3 s fs3 eb4 f3 d e3 -h w g3 s eb4 w e3 s g3 f3 fs3 e3 f3 d fs3 -h w g3 s eb4 w a3 s fs4 d g4 -h w f4 s gs3 fs4 f4 d gs3 -h w g4 s a3 w f4 s g4 a3 gs3 fs4 g4 d gs3 -h w fs4 s a3 w f4 s gs3 d a3 -h w f4 s fs4 g4)))
(gen-ornament '((acc e c4 fs4)) mat :val '(w))

 

I need to be able to use cmd-1 to check the output, but I don't understand what the problem is. Any help is much appreciated!

 

Thanks!

Link to comment
Share on other sites

My function is made for normal measured material, it means you have to use parenthesis to separate bars and apply the function on it.

 

This works:

 

(setf mat '((w d3 mf) (s eb3 mf h... e3 tie) (s e3 mf eb3 h.. f3 tie) 
(w f3 mf tie) (e f3 mf -h q. fs3 tie) (he fs3 mf s e3 d3 f3 e. e3 tie)
(w e3 mf tie) (h.s e3 mf -e.) (-q -s he. d3 mf tie) (qs d3 mf s fs3 he eb3 tie)
(q. eb3 mf s e3 fs3 eb3 d3 f3 qs fs3 tie) (w fs3 mf tie) (he. fs3 mf -q -s)
(-e. h.s d3 mf tie) (e. d3 mf s f3 h. eb3 tie) (q eb3 mf s e3 he. d3 tie)
(w d3 mf tie) (qs d3 mf -h e. eb3 tie) (h.s eb3 mf s e3 f3 fs3) (w g3 mf tie)
(w g3 mf) (-h e4 mf tie) (h e4 mf s f4 q.. gs3 tie) (hs gs3 mf s fs3 e4 gs3 fs3 f4 e g3 tie)
(w g3 mf tie) (h.. g3 mf -e) (-q. he gs3 mf tie) (q. gs3 mf s f4 hs g3 tie)
(q.. g3 mf s fs3 h e4 tie) (w e4 mf tie) (h e4 mf -) (w f4 mf) (s fs3 mf e4 g3 h.s gs3 tie)
(w gs3 mf tie) (e. gs3 mf -h qs fs3 tie) (he. fs3 mf s g3 q gs3 tie) (h. gs3 mf s e4 f4 f3 g3)
(s eb4 mf h... fs3 tie) (w fs3 mf tie) (s fs3 mf -h q.. e3 tie) (hs e3 mf s g3 q. fs3 tie)
(he fs3 mf s e3 qs eb4 tie) (w eb4 mf tie) (he. eb4 mf -q -s) (-e. h.s f3 mf tie)
(e. f3 mf s fs3 eb4 f3 he e3 tie) (w e3 mf tie) (q. e3 mf -h e g3 tie) (h.. g3 mf s eb4 e3 tie)
(h... e3 mf s g3) (s f3 mf fs3 e3 f3 h. fs3 tie) (w fs3 mf tie) (q fs3 mf -h q g3 tie)
(h. g3 mf s eb4 e. a3 tie) (h.s a3 mf s fs4 e g4 tie) (w g4 mf tie) (h.. g4 mf -e)
(-q. he f4 mf tie) (q. f4 mf s gs3 fs4 f4 q.. gs3 tie) (w gs3 mf tie) (hs gs3 mf -q..)
(-s h... g4 mf tie) (s g4 mf a3 h.. f4 tie) (e f4 mf s g4 a3 gs3 fs4 g4 hs gs3 tie) 
(w gs3 mf tie) (q.. gs3 mf -h s fs4 tie) (h... fs4 mf s a3) (w f4 mf)
(s gs3 mf h... a3 tie) (w a3 mf tie) (s a3 mf -h q.. f4 tie) (hs f4 mf s fs4 g4)))

 
(gen-ornament '((acc e c4 fs4)) mat :val '(w))

 

 

Link to comment
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.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy