Posted August 24, 20168 yr ;;;function which replaces/rewrites the component in OMN-seq (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 (pitchp (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)))) (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))
August 27, 20168 yr Next week I will show you how to do all this in Opusmodus with build in functions especially for omn plists manipulation.
August 28, 20168 yr The function OMN-COMPONENT-REPLACE in a real OMN world will return errors with a complex attributes (articulations): ttrem, app, gliss etc... Anyway, bellow you will find few example how to manipulate algorithmically the OMN plists: (setf sequence '(q c4 pp e d4 mp e4 s f4 f> fs4 > g4 > gs4 pp)) (disassembling-omn ((pitch plist) sequence :pitch :flat nil :span :length) (let ((pitch (remove nil pitch))) (pitch-transpose -12 pitch))) (disassembling-omn ((length plist) sequence :length :flat nil :span :length) '(s s s s)) (disassembling-omn ((length plist) sequence :length :flat nil :span :pitch) '(s s s s)) (disassembling-omn ((velocity plist) sequence :velocity :flat nil :span :length) '(f f p p f f)) And now a complete function example with DISASSEMBLING-OMN macro: (defun length-rational-quantize (sequence &key (round 1/4) (type :extend) section exclude omn) (do-verbose ("length-rational-quantize") (labels ((length-rational-quantize-1 (length round) (let* ((sum (sum (abs! length))) (out (- (find-length-base sum round) sum))) (remove 0 (append length (list (neg! out)))))) (length-rational-quantize-l (list round &key (type :extend)) (let ((group (lists! (split-lengths list :type type)))) (flatten (loop for i in group collect (length-rational-quantize-1 i round))))) (length-rational-quantize-ls (list round &key (type :extend)) (let* ((len (length list)) (round (gen-trim* len (list! round)))) (loop for i in list for x in round collect (length-rational-quantize-l i x :type type)))) (length-rational-quantize* (list round &key (type :extend)) (if (listsp list) (length-rational-quantize-ls list round :type type) (length-rational-quantize-l list round :type type)))) (disassembling-omn ((sequence plist) sequence :length :span :length) (let ((len (length sequence))) (maybe-omn-decode omn (if exclude (maybe-section (lambda (x) (length-rational-quantize* x round :type type)) sequence (num-exclude len exclude)) (maybe-section (lambda (x) (length-rational-quantize* x round :type type)) sequence section)))))))) Note: Please don't distribute or share any of the code from the Source Code forum section.
August 28, 20168 yr Author thanx! i can modify my own function now, so that it will work properly :-)
December 6, 20168 yr Hi André, i would love to have the om-component-replace function if you have finished it and agree for share it here . Best wishes Stéphane
December 6, 20168 yr Author hi stephane i think it works fine, feel free to use & optimize it ( perhaps to replace more then ONE parameter in ONE function-call?)... for me the function is very useful... greetings andré (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 (pitchp (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)))) 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)) (omn-component-replace seq1 '(ponte)) (omn-component-replace seq1 '(c4 d4 e4 f4))
December 6, 20168 yr Author here is a version with MULTIPLE replacements... you have to write replacements different... a list in a list... have a look to the examples: (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)))))))) (omn-component-replace2 '(S C4 PPP TASTO Q.T D4 PPPP TASTO S E4 PPP TASTO) '((p))) (omn-component-replace2 '(S C4 PPP TASTO Q.T D4 PPPP TASTO S E4 PPP TASTO) '((p) (ponte) (e2 b2 d2)))
Create an account or sign in to comment