Jump to content

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)))

 

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))))

 

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.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy