AM Posted December 24, 2016 Share Posted December 24, 2016 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 andré Quote Link to comment Share on other sites More sharing options...
opmo Posted December 24, 2016 Share Posted December 24, 2016 You could do that with PATTERN-MAP. Quote Link to comment Share on other sites More sharing options...
AM Posted December 25, 2016 Author Share Posted December 25, 2016 i tried, but it didn't work... why, where is my mistake? (pattern-map '((pppp tasto) (ff tasto)) '(e. c4 pppp tasto d4 ponte e4) :type :velocity) Quote Link to comment Share on other sites More sharing options...
opmo Posted December 25, 2016 Share Posted December 25, 2016 (pattern-map '(((pppp tasto) (ff tasto))) '(e. c4 pppp tasto d4 ponte e4)) => (e. c4 ff tasto d4 ponte e4) Quote Link to comment Share on other sites More sharing options...
AM Posted December 25, 2016 Author Share Posted December 25, 2016 thanx, but the rest of the sequence should be/stay "pppp" Quote Link to comment Share on other sites More sharing options...
AM Posted December 26, 2016 Author Share Posted December 26, 2016 here is a solution - because i didn't know how it works in pure OM/OMN greetings andré ;;; 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) event-cnt) and do (incf cnt1) and do (incf cnt2) else collect (list (nth cnt1 durations) nil nil nil nil nil nil event-cnt) 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) (gen-omn-from-events (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)))) ;;; EXAMPLE (replace-velocity-of-a-technique '(e. c4 pppp tasto d4 ponte e4) 'tasto 'fff) => (e. c4 fff tasto d4 pppp ponte e4 -) Quote Link to comment Share on other sites More sharing options...
torstenanders Posted December 26, 2016 Share Posted December 26, 2016 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. Best, Torsten ;;; ;;; 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) all) in-list)) (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) (mat-trans (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 p ;; replace tasto dynamics by fff (if (equal a 'tasto) 'fff v) a)) my-data) ; => (e. c4 fff tasto d4 pppp ponte e4) lviklund and AM 2 Quote Link to comment Share on other sites More sharing options...
AM Posted December 26, 2016 Author Share Posted December 26, 2016 thanx a lot for that "professional approach"! herzlichen dank für diese lösung, viel smarter :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.