PatrickMimran Posted April 28, 2017 Share Posted April 28, 2017 Hello i try to write a function who could directly apply to an omn list of that form : (set melo1 '(s bb5 f c6 mf bb5 f q mf s c6) (s c6 g5 g5 mp q c5 s bb5 f) (h. g5 f e. mp bb4 ff bb5 mf g5 f) ) How may i proceed to access independently pitch , length , velocity or articulation without having to disassemble it . Is there an existing helping function already made on which i could assign a new custom written function . Thanks Patrick Quote Link to comment Share on other sites More sharing options...
lviklund Posted April 28, 2017 Share Posted April 28, 2017 Yes Search for the function OMN. (setf notation '(s g4 pp == cs5 c4 -- fs5 g4 mf ==== gs5 mp == a3 f)) (omn :length notation) => (1/16 1/8 1/16 1/16 -1/8 1/16 1/16 1/4 1/16 1/8 1/16) Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 28, 2017 Author Share Posted April 28, 2017 Thank you but what i am looking for is to create a new function X which could apply his functionality directly in a omn function like ( rnd-order '(h. g3 mp e. bb4 mf q. c5 ff e. bb5 mf)) automatically render all omn component , but if i write a function x it will not automatically understand in the list what is pitch or length etc... I would like to find a way to have direct access without having to extract first length or pitch and to recombine it in omn later Thanks Patrick Quote Link to comment Share on other sites More sharing options...
AM Posted April 28, 2017 Share Posted April 28, 2017 you could work with omn-replace (from OM-library)? ...or some other code... have a look... greetings andré ;;; THREE SIMILAR FUNCTIONS FROM MY USER LIBRARY ;;; recognizes the parameter who has to be replaced (defun omn-component-replace (omn-sequence replace-component) (make-omn :length (if (lengthp (car replace-component)) (append replace-component) (omn :length omn-sequence)) :pitch (if (or (pitchp (car replace-component)) (chordp (car replace-component))) (append replace-component) (omn :pitch omn-sequence)) :velocity (if (velocityp (car replace-component)) (append replace-component) (omn :velocity omn-sequence)) :articulation (if (articulationp (car replace-component)) (append replace-component) (omn :articulation omn-sequence)))) ;;; the same with multiple inputs at once (defun omn-component-replace2 (omn-sequence replace-component) (car (last (loop for i in replace-component collect (setf omn-sequence (make-omn :length (if (lengthp (car i)) (append i) (omn :length omn-sequence)) :pitch (if (pitchp (car i)) (append i) (omn :pitch omn-sequence)) :velocity (if (velocityp (car i)) (append i) (omn :velocity omn-sequence)) :articulation (if (articulationp (car i)) (append i) (omn :articulation omn-sequence)))))))) ;;; replaces a single element (defun omn-single-element-replace (omn-list old new) (let ((new-list (loop for i in (cond ((lengthp old) (omn :length (flatten omn-list))) ((pitchp old) (omn :pitch (flatten omn-list))) ((velocityp old) (omn :velocity (flatten omn-list))) ((articulationp old) (omn :articulation (flatten omn-list)))) when (equal i old) collect new else collect i))) (omn-component-replace (flatten omn-list) new-list))) ;;;;;;;;;;;;;;;;;; ;;; EXAMPLES (setf seq1 '(s gs3 ppp tasto q.t cs4 pppp tasto s f4 ppp tasto)) (omn-component-replace seq1 '(5/16 7/16 3/32)) => (qs gs3 ppp tasto q.. cs4 pppp tasto s. f4 ppp tasto) (omn-component-replace2 '(S C4 PPP TASTO Q.T D4 PPPP TASTO S E4 PPP TASTO) '((p) (ponte) (e2 b2 d2))) => (S E2 P PONTE Q.T B2 PONTE S D2 PONTE) (omn-single-element-replace '(t gs4 pppp tasto a4 tasto bb4 tasto -t) 'bb4 'c4) => (t gs4 pppp tasto a4 tasto c4 tasto -) (omn-single-element-replace '(t gs4 pppp tasto a4 tasto bb4 tasto -t) 'pppp 'ff) => (t gs4 ff tasto a4 tasto bb4 tasto -) Stephane Boussuge and lviklund 2 Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 28, 2017 Author Share Posted April 28, 2017 Thank you Patrick Quote Link to comment Share on other sites More sharing options...
AM Posted April 28, 2017 Share Posted April 28, 2017 i'm interested to see YOUR code :-) greetings Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 28, 2017 Author Share Posted April 28, 2017 I'll post it when ready Thanks Quote Link to comment Share on other sites More sharing options...
torstenanders Posted April 28, 2017 Share Posted April 28, 2017 Below is a link another way to write functions that process OMN more easily by defining only a function processing the parameter you are interested in, and then turning that quasi-automatically into a function that supports arbitrary OMN expressions (including nested expressions, preserving the nesting, and rests). Best, Torsten AM and Stephane Boussuge 2 Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 29, 2017 Author Share Posted April 29, 2017 Thank you Torsten that's exactly what i was looking for , as i compose using Opusmodus first to generate several ideas which once in omn form i like to process again or edit afterwards with some home made functions and at the end manual edits . I will try it and come back to you if i have some questions . Patrick Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 29, 2017 Author Share Posted April 29, 2017 Hi torsten when i evaluate (defun edit-omn (type notation fun &key (flat T))) i gat this error message maybe i missed something ;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" : ; In edit-omn: Unused lexical variable flat ;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" : ; In edit-omn: Unused lexical variable fun ;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" : ; In edit-omn: Unused lexical variable notation ;Compiler warnings for "/Users/patrickmimran/Opusmodus/AllPat_Comp/Patrick_2/OMN_Translator.opmo" : ; In edit-omn: Unused lexical variable type Quote Link to comment Share on other sites More sharing options...
torstenanders Posted April 29, 2017 Share Posted April 29, 2017 Looks like you tried to evaluate only the first line of a function definition without any body. The compiler therefore helpfully tells you that you are not using the arguments of this function. What are you actually trying to do, evaluate the function edit-omn that I provided in my post linked above? Have you tried evaluating the content of the code whole box with both function definitions, remove-property and edit-omn. I should perhaps add that how to use the function edit-omn is best understood by Lisp programmers who already know what higher order functions are, which is a somewhat advanced, but very powerful programming concept. In my original post I provided a link to a textbook chapter on functions. The idea will also be discussed in many other Common Lisp text books. Best, Torsten Quote Link to comment Share on other sites More sharing options...
PatrickMimran Posted April 29, 2017 Author Share Posted April 29, 2017 I did something which seems easier for me (defun my-omn (lis &optional (nbr 0) ) (nth nbr (disassemble-omn lis ))) from there i mapcar any functions Ex: (setf lenomn (my-omn pianomain )) ;pianomain is a omn list or lists (setf newlen (mapcar 'anyfunction lenomn )) then : (omn-replace :pitch newlen pianomain ) Now if i would like to embed everything in one function with the options ? ( nbr 0 for length 3 for pitch 5 for velocity and 7 for articulation ) plus the omn options for :pitch :length :velocity and :art with anyfuntion as an additional argument That's what i would like to know how to do , now that i have the useful functions set , then i could concentrate everything in one function Thanks For any help Patrick Quote Link to comment Share on other sites More sharing options...
torstenanders Posted April 30, 2017 Share Posted April 30, 2017 Please see my response in the other thread. TA 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.