Jump to content
Sign in to follow this  
torstenanders

Varying dynamics

Recommended Posts

It is nice to have velocity transformation functions like velocity-variant and friends, but I would like to go further. How about being able to easily increasing or decreasing the overall volume (basically a dynamics/velocity transposition), or to smoothen dynamics differences in order to create dynamics variations in the composition process? Here are two examples.

 

(velocity-add 0.1 '(mf> > > > > pp))
 => (f> > > > > p)

 

(velocity-smooth 0.7 '((ppp p mf ff p< < <) (fff> > f><p ff mf p ppp)))
  => ((ppp< < < mp< < mp< <) (f< ff> > < ff> > mp))

 

Below is an implementation of these functions. Further functions like this can now easily be implemented with velocity-transform. The principle idea is to transform OMN velocities into a numeric OMN vector (list), and do whatever transformation you want to do on that vector, and finally to transform the result back into OMN velocities. The details are explained in the comment string of the functions below.

 

Note that these definitions depend on my function simplify-dynamics.

 

Best,

Torsten

 

(defun velocity-transform (fun args &key (simplify T))
  "Higher-order function for transforming velocities by processing them as an Openmodus vector in the background.
  
  Args
  fun: a function expecting a vector and possibly more arguments.
  args: the arguments for `fun'. Velocities should be explicitly transformed into numeric values. 
        Example: (get-velocity '(mf> > > > > pp)) 
  simplify (default T): whether or not to simplify cresc. and dim. in the result with simplify-dynamics.

  Example
  (velocity-transform #'vector-add (list (get-velocity '(mf> > > > > pp)) '(0.1)))"
  (let* ((vel-vector (apply fun args))
         (result (velocity-to-dynamic 
                  (vector-to-velocity (apply #'min vel-vector) (apply #'max vel-vector)
                                      vel-vector))))
    (if simplify
      (simplify-dynamics result)
      result)))


(defun velocity-add (offset velocities &key (simplify T))
  "Adds an offset to a list of OMN velocities. Quasi the dynamics equivalent of pitch transposition.

  Args
  offset: an offset added to `velocities', can be numeric (between 0 and 1) or a velocity symbol (e.g., pp), and also a list of either. 
  velocities: list of velocities, can be nested.

  Examples
  (velocity-add 0.1 '(mf> > > > > pp))
  => (f> > > > > p)
  (velocity-add 'pppp '(mf> > > > > pp))
  => (f> > > > > p)
  (velocity-add 0.1 '((mf> > >) (> > pp)))
  => ((f> > >) (> > p))
  (velocity-add '(0.1 0.2 0.3 0.4 0.5 0.6) '(mf> > > > > pp))
  => (f< < < < < ffff)
  "
  (span velocities
        (velocity-transform #'vector-add 
                            (list (get-velocity (flatten velocities))
                                  (if (listp offset)
                                    (mapcar #'get-velocity offset)
                                    (list (get-velocity offset))))
                            :simplify simplify)))


(defun velocity-smooth (alfa velocities &key (simplify T))
  "Smoothes velocity values.

  Args
  alfa: parameter controlling the degree of exponential smoothing (usually  0 < alpha < 1).
  velocities: list of velocities, can be nested.

  Example
  (velocity-smooth 0.7 '((ppp p mf ff p< < <) (fff> > f><p ff mf p ppp)))
  => ((ppp< < < mp< < mp< <) (f< ff> > < ff> > mp))
  (velocity-smooth 0.2 '((ppp p mf ff p< < <) (fff> > f><p ff mf p ppp)))
  => ((ppp< < < < < < <) (< mf mf mf mf mf mf))"
  (span velocities
        (velocity-transform #'vector-smooth 
                            (list alfa
                                  (get-velocity (flatten velocities)))
                            :simplify simplify)))

 

Share this post


Link to post
Share on other sites

Edit: Here are slight variations of these functions that now support arbitrary OMN input -- more useful for varying the dynamics in full snippets directly :)

 

Note that these definitions depend now also on my function edit-omn.

 

Best,

Torsten

 

(defun velocity-add-aux (offset velocities &key (simplify T))
  (velocity-transform #'vector-add 
                      (list (get-velocity velocities)
                            (if (listp offset)
                              (mapcar #'get-velocity offset)
                              (list (get-velocity offset))))
                      :simplify simplify))

(defun velocity-add (offset velocities &key (simplify T))
  "Adds an offset to a list of OMN velocities. Quasi the dynamics equivalent of pitch transposition.

  Args
  offset: an offset added to `velocities', can be numeric (between 0 and 1) or a velocity symbol (e.g., pp), and also a list of either. 
  velocities: list of velocities, can be nested.
  simplify (default T): whether or not to simplify cresc. and dim. in the result with simplify-dynamics.

  Examples
  (velocity-add 0.1 '(mf> > > > > pp))
  => (f> > > > > p)
  (velocity-add 'pppp '(mf> > > > > pp))
  => (f> > > > > p)
  (velocity-add 0.1 '((mf> > >) (> > pp)))
  => ((f> > >) (> > p))
  (velocity-add '(0.1 0.2 0.3 0.4 0.5 0.6) '(mf> > > > > pp))
  => (f< < < < < ffff)
  ; omn input
  (velocity-add 0.1 '((e c4 p< d4 < e4 mf< f4 < g4 f)))
  "
  (edit-omn :velocity velocities
            #'(lambda (vs) (velocity-add-aux offset vs :simplify simplify))))


(defun velocity-smooth-aux (alfa velocities &key (simplify T))
  (velocity-transform #'vector-smooth 
                      (list alfa (get-velocity velocities))
                      :simplify simplify))

(defun velocity-smooth (alfa velocities &key (simplify T))
  "Smoothes velocity values.
  
  Args
  alfa: parameter controlling the degree of exponential smoothing (usually  0 < alpha < 1).
  velocities: list of velocities, can be nested.
  simplify (default T): whether or not to simplify cresc. and dim. in the result with simplify-dynamics.
  
  Example
  (velocity-smooth 0.7 '((ppp p mf ff p< < <) (fff> > f><p ff mf p ppp)))
  => ((ppp< < < mp< < mp< <) (f< ff> > < ff> > mp))
  (velocity-smooth 0.2 '((ppp p mf ff p< < <) (fff> > f><p ff mf p ppp)))
  => ((ppp< < < < < < <) (< mf mf mf mf mf mf))
  "
  (edit-omn :velocity velocities
            #'(lambda (vs) (velocity-smooth-aux alfa vs :simplify simplify))))

 

Share this post


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.

Sign in to follow this  

  • Similar Topics

    • By JulioHerrlein
      Hello,
       
      Simple question:
       
      1) How to specify in the articulation list for no displaying any articulation in the note without using "ord" ?
      2) Is there some reset to "normal" articulation (without symbols) ?
       
      Best,
      Julio
       
    • By marqrdt
      Hi,
         Is there an OpusModus function (I'll bet there is) that can create lists (chords, etc) created from items selected from lists of varying lengths? Something like this:
      Source lists (3 lists): ( '(c4 d4 e4) '(f4 g4 a4 b4) '(cs4 ds4 fs4 gs4 as4) )
      Output, successive items from each list: (list '(c4 f4 cs4) '(d4 g4 ds4) '(e4 a4 fs4) '(c4 b4 gs4) '(d4 f4 as4) '(e4 g4 cs4) ...)
      I'm having a great time learning LISP and OM (I come from Python/Java background mostly). I looked through the gen- functions, but nothing seemed to match. I was going to try to write a LISP function, but I figure there was already something in OM, as it seems geared towards these types of transformations.
       
      Thanks!
    • By EAIP
      Hi,
      In the following code the mf of the first bar won't show up.
      Any other dynamic symbol in the first bar will work as expected.
      Are you able to reproduce this on your system?
      All the best,
      Erik
       
       
      (setf omn (make-omn :length '((1/8 1/8) (1/2 1/2) (1 1)) :pitch '((g4) (d5) (f5)) :velocity '((mf) (f) (mf)) ) ) => ((e g4 g4) (h d5 f d5) (w f5 mf f5)) ; no dynamic symb in first bar! (setf omn (make-omn :length '((1/8 1/8) (1/2 1/2) (1 1)) :pitch '((g4) (d5) (f5)) :velocity '((pp) (f) (mf)) ) ) => ((e g4 pp g4) (h d5 f d5) (w f5 mf f5)) ; now the dynamic symb shows up in the first bar!  
×
×
  • Create New...