Jump to content

replace/map & datastructure


Recommended Posts

first question

i would like to replace the dynamics of all "tasto"-sounds in an OMN-sequence, is there a function for that?


for example 

'(e. c4 pppp tasto d4 ponte e4)  -> replace only the dynamic of the TASTO


result should be:

'(e. c4 f tasto d4 ppp ponte e4)



second question (if i want to code it for myself)

...is there always a constant dataset/stream (events) in the "background"? like : '((e. c4 pppp tasto) (e. d4 pppp ponte) (e. e4 pppp ponte))?

which function shows me this, so called, EVENTS. for some coding this format is a lot more usefull then seperat lists of each parameter


thanks for help and HAPPY CHRISTMAS




Link to comment
Share on other sites

here is a solution - because i didn't know how it works in pure OM/OMN



;;; SUB

(defun gen-events-from-lists (&key durations pitches  (velocities 'nil) (articulations 'nil) (optional_data1 'nil) (optional_data2 'nil) (optional_data3 'nil))
  (loop repeat (length durations)
    with cnt1 = 0
    with cnt2 = 0
    with event-cnt = 0

    when (> (nth cnt1 durations) 0)
    collect (list (nth cnt1 durations) 
                  (nth cnt2 pitches) 
                  (nth cnt2 velocities)
                  (nth cnt2 articulations) 
                  (nth cnt2 optional_data1)
                  (nth cnt2 optional_data2)
                  (nth cnt2 optional_data3)
    and do (incf cnt1)
    and do (incf cnt2)

    else collect (list (nth cnt1 durations)
    and do (incf cnt1)
    do (incf event-cnt)))

(defun gen-omn-from-events (event-stream)
  (length-rest-merge (loop for i in event-stream
                                      append (loop for j in (butlast i)
                                               when (not (equal j 'nil))
                                               collect j))))

;;; MAIN

(defun replace-velocity-of-a-technique (omn-list technique velocity)
   (loop for i in (gen-events-from-lists :durations (flatten (omn :length omn-list))
                                         :pitches (flatten  (omn :pitch omn-list))
                                         :velocities (flatten  (omn :velocity omn-list))
                                         :articulations (flatten  (omn :articulation omn-list)))
     collect (pattern-map (list (list (list '? technique) (list velocity technique))) i))))


(replace-velocity-of-a-technique  '(e. c4 pppp tasto d4 ponte e4) 'tasto 'fff)
 => (e. c4 fff tasto d4 pppp ponte e4 -)


Link to comment
Share on other sites

Dear André,


Below is an alternative approach to do the same. The actual user-level code is more concise here, so this might be preferable if you have lots of such variations that should be easy to comprehend later.





;;; Definition of map-omn

(defun mat-trans (in-list)
  "Quasi a matrix transformations: transforms a list of form ((a1 a2 a3) (b1 b2 b3) (c1 c2 c3) ...) 
into ((a1 b1 c1 ...) (a2 b2 c2 ...) (a3 b3 c3 ...))."
  (apply #'mapcar #'(lambda (&rest all)

(defun map-omn (fn omn-expr)
  "Variant of mapcar for omn expressions, intended for creating variations of these. 
Applies function fn to every note in omn-expr (a flat OMN list). fn must exect four 
arguments (a length, pitch, velocity and articution) and returns a list of four values 
(a length, pitch, velocity and articution)."
  (destructuring-bind (lengths pitches velocities articulations)
                       (funcall #'mapcar fn
                                (omn :length omn-expr)
                                (omn :pitch omn-expr)
                                (omn :velocity omn-expr)
                                (omn :articulation omn-expr)))
    (make-omn :length lengths
              :pitch pitches 
              :velocity velocities
              :articulation articulations)))


The user-level code starts here.

;;; Actual program

(setf my-data '(e. c4 pppp tasto d4 ponte e4))

(map-omn #'(lambda (l p v a)
             (list l 
                   ;; replace tasto dynamics by fff
                   (if (equal a 'tasto)
; => (e. c4 fff tasto d4 pppp ponte e4)


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.

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