Jump to content

AM

Members
  • Posts

    793
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    AM reacted to o_e in Length-Legato opposite function   
    Hi,
     
    Just a minor improvement, the function is now also working with sublists :-)
     
    best ole
     

    (defun length-staccato-lists (n alist)   (let ((newlengths (loop for i in (omn :length (flatten alist))                       when (> i 0)                       append (list n (* -1 (abs (- i n))))                       else collect i)))     (if (omn-formp alist)       (omn-to-time-signature        (make-omn :length newlengths                 :pitch (omn :pitch alist)                 :velocity (omn :velocity alist)                 :articulation (omn :articulation alist))        (get-time-signature alist))       newlengths))) (length-staccato-lists 1/16 '((q e4 mp q tasto q -q q q)(q e4 mp q tasto q -q q q))) -->((s e4 mp -e. s e4 tasto -e. s e4 -e. -q s e4 -e. s e4 -e.) (s e4 -e. s e4 tasto -e. s e4 -e. -q s e4 -e. s e4 -e.))
  2. Like
    AM got a reaction from JulioHerrlein in Length-Legato opposite function   
    dear julio
    i don't know if there is a solution in the om-library... coded quickly one for your problem...
    the basic-rhythms (denominator) should stay constant like in your examples, then it works...
     
    first value has to be your "stacc-length", second your omn-list or a length-list, have a look to the example...
    greetings
    andré
     
    (defun length-staccato (n alist) (let ((newlengths (loop for i in (omn :length alist) when (> i 0) append (list n (* -1 (abs (- i n)))) else collect i))) (if (omn-formp alist) (make-omn :length newlengths :pitch (omn :pitch alist) :velocity (omn :velocity alist) :articulation (omn :articulation alist)) newlengths))) (length-staccato 1/16 '(q e4 mp q tasto q -q q q))  
     
  3. Like
    AM got a reaction from Stephane Boussuge in [SOLVED] Midi In Collect (now Opusmodus have MIDI input)   
    to wishlist: xml-import
  4. Thanks
    AM reacted to opmo in [SOLVED] Midi In Collect (now Opusmodus have MIDI input)   
    Ver 2. will be able to import musicXML files and convert to omn.
  5. Thanks
    AM got a reaction from opmo in replace-articulation-of-a-pitch   
    i didn't find a OM-library-solution for this kind of thing, so i coded it...
     
    if you want to REPLACE the articulation of some specific pitches. perhaps all 'd4 sould be PONTE... you could use this.
    it was necessary to code it like that, because otherwise you get in trouble with the empty parameter-slots...
     
    should work fine
    greetings
    andré
     
    ;;; SUBFUNCTIONS (defun eliminate-nil (alist) (loop for i in alist when (not (null i)) collect i)) (defun complete-event-slots (omn-list) (let ((omn-art (omn :articulation (single-events (flatten omn-list))))) (single-events (omn-replace :articulation (flatten (eliminate-nil (loop for i in omn-art for cnt = 0 then (incf cnt) when (equal (car i) '-) collect (nth (1- cnt) omn-art) else collect i))) omn-list)))) ;(complete-event-slots '(5q a4 ff pizz 5q e3 -e 5q a4 f)) ;;; MAIN FUNCTION (defun replace-articulation-of-a-pitch (omn-list &key pitches articulation (chance 1.0)) (loop for i in (complete-event-slots (flatten omn-list)) when (and (member (car (omn :pitch i)) pitches) (prob? chance)) append (omn-component-replace i (list articulation)) else append i)) ;;; EXAMPLE (replace-articulation-of-a-pitch '(5q a4 ff pizz 5q e3 p -q 5q d4 pizz) :pitches '(a4 d4) :articulation 'ponte :chance 1.0) -> (5q a4 ff ponte 5q e3 p pizz -q 5q d4 p ponte)  
  6. Thanks
    AM reacted to opmo in Opusmodus 1.2.22733   
    Extended documentation and bug fix in do-timeline and do-timline2 functions if binary list.
     
  7. Like
    AM got a reaction from opmo in inserting   
    here is a function that can be used for "post-..." of an OMN score...
    you could INSERT a sequence by BAR/BEAT (a slightly modified variant of OVERWRITE), so you can 
    place your insert exactly!
     
    greetings
    andré
     
    ;;; INSERTING (defun get-resolution2 (be) (cond ((member (cadr be) '(3 6 12 24 48)) 1/24) ((member (cadr be) '(1 2 4 8 16 32)) 1/16) ((member (cadr be) '(5 10 20 40)) 1/20) ((member (cadr be) '(7 14 28 56 1)) 1/28))) (defun insert (seq &key insert bar/beat) (car (last (let ((bar) (beat) (resolution) (distance)) (progn (setf bar (loop for i in bar/beat collect (car i)) beat (loop for j in bar/beat collect (cadr j))) (loop for ba in bar for be in beat for ins in insert with time-sign = (get-time-signature seq) with ord-time-sign = (get-time-signature seq) ;with ins-rounded = '(0) with ins-add = '(0) do (setf resolution (get-resolution2 be) time-sign (if (listp (car time-sign)) (loop for i in time-sign when (> (caddr i) 1) append (loop repeat (caddr i) collect (list (car i) (cadr i))) else collect (list (car i) (cadr i))) (append time-sign)) distance (if (listp (car time-sign)) (+ (sum (loop repeat (- ba 1) for i in time-sign collect (/ (/ (car i) (cadr i)) (get-resolution2 be)))) (/ (/ (1- (car be)) (cadr be)) (get-resolution2 be)) ;;; ins-rounded add (/ (get-span (flatten ins-add)) (get-resolution2 be)) ) (+ (/ (* (1- ba) (/ (car time-sign) (cadr time-sign))) (get-resolution2 be)) (/ (/ (1- (car be)) (cadr be)) (get-resolution2 be)) ;;; ins-rounded add (/ (get-span (flatten ins-add)) (get-resolution2 be))) )) do (setf seq (omn-to-time-signature (length-rest-merge (flatten (loop repeat (length (omn-to-time-signature seq (list (numerator resolution) (denominator resolution)))) for cnt = 0 then (incf cnt) with new-seq = (omn-to-time-signature seq (list (numerator resolution) (denominator resolution))) with ins-rounded = (append ins (rest (length-rational-quantize (list (apply '+ (mapcar 'abs (omn :length ins)))) :round resolution))) when (= cnt distance) collect ins-rounded and do (setf ins-add (append ins-rounded ins-add)) else collect (nth cnt new-seq)))) ord-time-sign)) do (setf time-sign ord-time-sign) collect (omn-merge-ties seq))))))) ;;; EXAMPLES: ;;; with changing time-signatures (insert '((e c6 a5 h b5 q tie) (q b5 b5 a5 tie) (q a5 q a5) (h. g5)) :insert '((-3q 3q c5 b4 bb4 a4) (-3q 3q c4 b3 bb3 a3)) ;;; bar numbers has to be in ascending order! :bar/beat '((1 (1 12)) (3 (1 12)))) (insert '((e c6 a5 h b5 q tie) (q b5 b5 a5 tie) (q a5 q a5) (h. g5)) :insert '((-2/12)) :bar/beat '((2 (2 12)))) ;;; with constant time-signature (insert '((e c6 a5 h b5 tie) (q b5 b5 a5 tie) (h a5 q a5) (h. g5)) :insert '((3q c5 b4 bb4 a4) (-3q 3q c4 b3 bb3 a3)) ;;; bar numbers has to be in ascending order! :bar/beat '((1 (7 12)) (3 (2 12)))) (insert '((e c6 a5 h b5 tie) (q b5 b5 a5 tie) (h a5 q a5) (h. g5)) :insert '((-h.)) :bar/beat '((2 (1 4))))  
  8. Like
    AM got a reaction from JulioHerrlein in saving the output (omn) in a seperat file   
    yes, i know - i love to code a lot of things myself, and at the moment i'm not very virtuous in it. but I have found a solution - without rebuilding my big programs. with
    (pprint-last-score) i can read and save the OMN, after evaluating and exporting xml/midi. so you were right, janusz, the solution was in the SYSTEM FUNCTIONS 🙂
    thanx for help - torsten, stéphane & janusz
  9. Thanks
    AM reacted to opmo in [SOLVED] Midi In Collect (now Opusmodus have MIDI input)   
    Just import your midi file to Opusmodus (OMN) script and start transforming :-)
    added 1 minute later Direct midi input (keyboard) into OMN script will be introduce in version 2.0
  10. Thanks
    AM got a reaction from BrianCope in Infinity-series applied to scales/modes   
    hi brian,
     
    i modified shortly the code, now you could do what you want...
    "step-to-pitch" will test now what the tonality-input is ... if tonality = pitches -> then use this scale, othwerwise -> "expand the scale"
     
    (defun map-infinity-series (&key seq start tonality) (step-to-pitch :steps (integer-to-interval (reset-seq seq)) :pitches (if (pitchp (car tonality)) tonality (multiple-expand-tonality :startpitch 'c0 :octaves 7 :tonality tonality)) :start start)) (map-infinity-series :seq '(0 -1 3 2 1 2 -1) :start 'fs4 :tonality (make-scale 'c2 49 :alt '(1 2 1 1))) (map-infinity-series :seq '(0 -1 3 2 1 2 -1 2 2 3 3 1 -1 1 -1 2 2) :start 'g4 :tonality '(major)) (map-infinity-series :seq '(0 -1 3 2 1 2 -1 2 2 3 3 1 -1 1 -1 2 2) :start 'fs4 :tonality '(messiaen-mode1 messiaen-mode2 messiaen-mode3)) 1) do it with library... like '(major) or (messiaen-mode1) or what else
    2) do ith with a pitch-sequence like your '(make-scale 'c2 49  :alt '(1 2 1 1))
     
    -> just REPLACE map-infinity-series by the new function-version
    -> ...the only thing you have to look at it: your start-pitch has to be part of your scale!
  11. Like
    AM got a reaction from JulioHerrlein in Opusmodus on a Windows Machine (using VMWare)   
    evaluate this, and check out the midi-destinations-function -> shows you the ports
     
    (midi-destinations)  
  12. Like
    AM got a reaction from BrianCope in Infinity-series applied to scales/modes   
    violà... bit more organized...
     
    a) now you could copy the SUBFUNCTIONS+MAINFUNCTION into:  extensions -> user library. in that way all the functions will be loaded automatically, and it is not necessary to EVALUATE them before using... but it's useful to document it... 
     
    b) otherwise... all this functions in your workspace/opmo-file... (like you are donig it wright now)
     
    ;;; SUBFUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun step-to-pitch (&key steps pitches start) (let ((pos (car (position-item start pitches)))) (append (list (nth pos pitches)) (loop for i in steps ;; setting pos by add the step to pos do (setf pos (+ pos i)) ;; when pitch-range to small then reset to lowest pitch+step ;; could be a more intelligent solution when (or (>= pos (length pitches)) (< pos 0)) do (setf pos 0);(+ 0 i)) collect (nth pos pitches))))) (defun multiple-expand-tonality (&key startpitch octaves tonality) (remove-duplicates ;remove is for "cutting" if there are too much pitches (OMN loops last octave!) (loop repeat octaves with pitch = startpitch with cnt = 0 when (= cnt (length tonality)) do (setq cnt 0) append (expand-tonality (list pitch (nth cnt tonality))) do (incf cnt) do (setq pitch (car (pitch-transpose 12 (list pitch))))))) (defun reset-seq (seq) (let ((n (abs (find-min seq)))) (loop for i in seq collect (+ n i)))) ;;; MAINFUNCTION (defun map-infinity-series (&key seq start tonality) (step-to-pitch :steps (integer-to-interval (reset-seq seq)) :pitches (multiple-expand-tonality :startpitch 'c0 :octaves 7 :tonality tonality) :start start)) ;;; EXAMPLES OF USE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setf inf-list (infinity-series 128 '(1 0))) (map-infinity-series :seq inf-list :start 'g4 :tonality '(major)) (map-infinity-series :seq inf-list :start 'gs3 :tonality '(messiaen-mode6))  
  13. Like
    AM got a reaction from opmo in Infinity-series applied to scales/modes   
    violà... bit more organized...
     
    a) now you could copy the SUBFUNCTIONS+MAINFUNCTION into:  extensions -> user library. in that way all the functions will be loaded automatically, and it is not necessary to EVALUATE them before using... but it's useful to document it... 
     
    b) otherwise... all this functions in your workspace/opmo-file... (like you are donig it wright now)
     
    ;;; SUBFUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun step-to-pitch (&key steps pitches start) (let ((pos (car (position-item start pitches)))) (append (list (nth pos pitches)) (loop for i in steps ;; setting pos by add the step to pos do (setf pos (+ pos i)) ;; when pitch-range to small then reset to lowest pitch+step ;; could be a more intelligent solution when (or (>= pos (length pitches)) (< pos 0)) do (setf pos 0);(+ 0 i)) collect (nth pos pitches))))) (defun multiple-expand-tonality (&key startpitch octaves tonality) (remove-duplicates ;remove is for "cutting" if there are too much pitches (OMN loops last octave!) (loop repeat octaves with pitch = startpitch with cnt = 0 when (= cnt (length tonality)) do (setq cnt 0) append (expand-tonality (list pitch (nth cnt tonality))) do (incf cnt) do (setq pitch (car (pitch-transpose 12 (list pitch))))))) (defun reset-seq (seq) (let ((n (abs (find-min seq)))) (loop for i in seq collect (+ n i)))) ;;; MAINFUNCTION (defun map-infinity-series (&key seq start tonality) (step-to-pitch :steps (integer-to-interval (reset-seq seq)) :pitches (multiple-expand-tonality :startpitch 'c0 :octaves 7 :tonality tonality) :start start)) ;;; EXAMPLES OF USE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setf inf-list (infinity-series 128 '(1 0))) (map-infinity-series :seq inf-list :start 'g4 :tonality '(major)) (map-infinity-series :seq inf-list :start 'gs3 :tonality '(messiaen-mode6))  
  14. Thanks
    AM got a reaction from BrianCope in Infinity-series applied to scales/modes   
    i will write you a "merged"-function, takes not a lot of time, then it looks smarter :-)
    do you know how to use USER LIBRARY? very usefull - take a look... then you could import and use it like an ordinary OPMO-function
  15. Thanks
    AM got a reaction from BrianCope in Infinity-series applied to scales/modes   
    is this correct? i think it is - not smart-coded but it works - you could merge the functions into ONE (sorry for my english). perhaps there is an OPMO-library-solution, but i don't know it...
     
    greetings
     
    (defun step-to-pitch (&key steps pitches start) (let ((pos (car (position-item start pitches)))) (append (list (nth pos pitches)) (loop for i in steps ;; setting pos by add the step to pos do (setf pos (+ pos i)) ;; when pitch-range to small then reset to lowest pitch+step ;; could be a more intelligent solution when (or (>= pos (length pitches)) (< pos 0)) do (setf pos 0);(+ 0 i)) collect (nth pos pitches))))) (defun multiple-expand-tonality (&key startpitch octaves tonality) (remove-duplicates ;remove is for "cutting" if there are too much pitches (OMN loops last octave!) (loop repeat octaves with pitch = startpitch with cnt = 0 when (= cnt (length tonality)) do (setq cnt 0) append (expand-tonality (list pitch (nth cnt tonality))) do (incf cnt) do (setq pitch (car (pitch-transpose 12 (list pitch))))))) (defun reset-seq (seq) (let ((n (abs (find-min seq)))) (loop for i in seq collect (+ n i)))) (step-to-pitch :steps (integer-to-interval (reset-seq '(0 1 -1 2 1 0 -2 3 -1 2 0 1 2 -1 -3 4 1 0 -2 3 0 1 -1 2 -2 3 1 0 3 -2 -4 5 -1 2 0 1 2 -1 -3 4 0 1 -1 2 1 0 -2 3 2 -1 -3 4 -1 2 0 1 -3 4 2 -1 4 -3 -5 6))) :pitches (multiple-expand-tonality :startpitch 'c0 :octaves 7 :tonality '(major)) :start 'g4)  
  16. Like
    AM reacted to opmo in Opusmodus 1.2.22714   
    Fix to DO-TIMELINE and DO-TIMELINE2 functions when with T or NIL plus minor bug fixes.
  17. Thanks
    AM reacted to PatrickMimran in Argument Question (simple problem)   
    Hello Julio 
     
    if you are like me and you do not know lisp this is a very useful link where you can find the main lisp functions .
    I found it very useful.
     
    cl-reference-brian.pdf
    LispResumé.pdf
  18. Thanks
    AM got a reaction from JulioHerrlein in Argument Question (simple problem)   
    But in this way: (setf binrow '(0 2 5 7 8 11)) (gen-binary-row 12 '(binrow)) What am I missing ?  
    just do it like that:
    (setf binrow '(0 2 5 7 8 11)) (gen-binary-row 12 binrow) ;; your "binrow" is now a variable with a LIST as value ;; when you are writing '(binrow) it will be a LIST with the VALUE binrow (and not the values of "binrow")  
     
  19. Like
    AM got a reaction from loopyc in Looking for a function that could do that   
    ;;; in "pure lisp" with NIL when lists have not the same length (defun trans* (lists) (loop repeat (car (last (sort-asc (mapcar 'length lists)))) for cnt = 0 then (incf cnt) collect (loop for i in lists collect (nth cnt i)))) (trans* '((1 2 3 4) (a b c d) (11 12 13 14) (k l m n))) (trans* '((1 2 3 4) (a b c d e) (11 12 13 14 14 16) (k l m n o p q r s t))) (trans* '((1 2 3 4) (a b c d e) (11 12 13 14) (k l m n r s t)))  
  20. Like
    AM reacted to opmo in Opusmodus 1.2.22703   
    New function: TIME-SWALLOW and minor bug fixes.
     
    The function TIME-SWALLOW 'swallows' sequence of pitches derived from the divide of every length value of a sequence by a given time value: (/ 1/2 1/16) = 8. The rest-lengths are omitted.
    (setf length '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16 3/8)) (setf infinity (infinity-series 100 '(g4 gs4))) => (g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4     f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4     gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4     fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4     gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4     g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4) (time-swallow 1/16 1 length pitch) => (g4 fs4 a4 gs4 f4 f4 g4 fs4 a4 g4 g4 a4) Time 1/16 in each length: 8 1 7 2 6 3 5 4 4 5 3 6 8                           1   7                      2 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 6                    3          5                4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 4            5                 3         6 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4  
    Example with swallow :type 1 (default) and with chord-size (3 3 2 1):
    (make-omn  :length length  :pitch (time-swallow 1/16 '(3 3 2 1) length pitch)) => (h g4gs4fs4 s fs4a4g4 q.. a4g4 e gs4 q. f4bb4g4 e. f4bb4gs4       qs g4bb4 q fs4 a4fs4e4 qs g4gs4fs4 e. g4f4 q. a4) 8-3                         1-3 7-2                    2-1 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 6-3                  3-3        5-2              4-1 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 4-3          5-3               3-2       6-1 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4  
    Same as above but with swallow :type 2:
    (make-omn  :length length  :pitch (time-swallow 1/16 '(3 3 2 1) length pitch :type 2)) => (h g4gs4fs4 s g4gs4a4 q.. fs4e4 e gs4 q. a4f4bb4       e. c5fs4a4 qs a4fs4 q fs4 f4bb4a4 qs fs4a4g4 e. fs4b4 q. cs5) 8-3                                1-3       7-2 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 2-1     6-3                         3-3 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 5-2                 4-1           4-3 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 5-3                    3-2          6-1 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4  
    More examples:
    (make-omn  :length length  :pitch (time-swallow 'e '(3 3 2 1) length pitch)) => (h g4gs4fs4 s gs4g4f4 q.. gs4g4 e fs4 q. a4g4gs4 e. a4fs4e4       qs e4b4 q gs4 f4bb4g4 qs g4gs4fs4 e. fs4a4 q. f4) (make-omn  :length length  :pitch (time-swallow 'e '(3 3 2 1) length pitch :type 2)) => (h g4gs4fs4 s f4bb4fs4 q.. fs4a4 e fs4 q. e4b4gs4       e. bb4g4gs4 qs a4f4 q gs4 bb4f4eb4 qs fs4a4g4 e. a4fs4 q. b4) (setf length2 (gen-length                (distributive-cube                 (interference2 '(3 2))) '(1/16))) => ((1/2 1/4 1/4 1/2 1/4 1/8 1/8 1/4 1/4 1/8 1/8 1/4 1/2 1/4 1/4 1/2)     (1/4 1/8 1/8 1/4 1/8 1/16 1/16 1/8 1/8 1/16 1/16 1/8 1/4 1/8 1/8 1/4)     (1/4 1/8 1/8 1/4 1/8 1/16 1/16 1/8 1/8 1/16 1/16 1/8 1/4 1/8 1/8 1/4)     (1/2 1/4 1/4 1/2 1/4 1/8 1/8 1/4 1/4 1/8 1/8 1/4 1/2 1/4 1/4 1/2)) (make-omn  :length length2  :pitch (time-swallow '(3e e s)                       '((3 3 2 1) (2 3)) length2 pitch)) => ((h g4gs4fs4 q a4fs4e4 f4bb4 h f4 q a4fs4e4 e fs4a4gs4 g4f4        q a4 g4gs4e4 e b4e4d4 cs5gs4 q f4 h f4bb4gs4        q gs4g4f4 g4gs4 h f4)     (q g4gs4 e fs4a4gs4 a4gs4 q gs4g4f4 e f4bb4 s bb4fs4a4 bb4fs4        e bb4fs4a4 fs4a4 s a4g4gs4 a4g4 e a4g4gs4 q g4gs4        e a4fs4e4 fs4e4 q e4b4gs4)     (q g4gs4fs4 e gs4g4f4 f4bb4 q fs4 e a4fs4e4 s e4b4gs4 b4gs4        e gs4 f4bb4g4 s g4gs4fs4 gs4fs4 e fs4 q f4bb4gs4        e bb4f4eb4 eb4c5 q fs4)     (h g4gs4 q a4fs4e4 f4bb4 h f4bb4gs4 q a4fs4 e fs4a4gs4 g4f4        q a4fs4e4 g4gs4 e b4e4d4 cs5gs4 q f4bb4g4        h f4bb4 q gs4g4f4 g4gs4 h f4bb4gs4)) (make-omn  :length length2  :pitch (time-swallow '(3e e s)                       '((3 3 2 1) (2 3)) length2 pitch :type 2)) => ((h g4gs4fs4 q e4b4gs4 fs4a4 h f4 q gs4fs4a4 e fs4e4b4 g4gs4        q a4 gs4g4f4 e f4bb4gs4 f4eb4 q gs4 h bb4fs4a4        q gs4fs4a4 a4g4 h gs4)     (q g4gs4 e a4gs4g4 f4bb4 q fs4a4g4 e a4fs4 s e4b4gs4 gs4g4        e g4f4bb4 g4gs4 s fs4a4f4 f4bb4 e bb4gs4g4 q bb4f4        e c5fs4a4 g4gs4 q a4fs4e4)     (q g4gs4fs4 e f4bb4fs4 g4gs4 q fs4 e g4f4bb4 s gs4fs4a4 f4bb4        e gs4 bb4f4eb4 s fs4a4g4 gs4a4 e fs4 q b4g4gs4        e g4f4bb4 fs4e4 q fs4)     (h g4gs4 q fs4e4b4 gs4fs4 h bb4f4eb4 q fs4a4 e fs4e4b4 g4gs4        q a4fs4b4 f4bb4 e bb4gs4g4 eb4c5 q fs4a4gs4        h g4gs4 q a4gs4g4 gs4a4 h f4bb4g4)) JP
  21. Like
    AM reacted to torstenanders in edit-omn update: 'dynamic' arguments supported   
    Stephane Boussuge wrote on 23 October
    > your edit-omn function is definitively super-mega useful !!
     
    I updated my function edit-omn. Remember that this function is for turning relatively simple functions processing some OMN parameter sequence (e.g., pitch or length lists) quasi automatically into much more expressive functions processing arbitrary OMN expressions, including nested expressions, and automatically supporting typical Opusmodus arguments like section and flat.
     
    I now added support for creating functions with 'dynamic' arguments, i.e. arguments where different values are used for processing different sublists of OMN expressions. For example, again consider a generalisation of the builtin Opusmodus function gen-rotate,which represents a very useful compositional concept, but its current implementation is rather restricted. I already showed how the new and generalised function rotate-omn expands the existing gen-rotate by introducing arguments like flat and section as shown below.   
     
    (setf melody '((-h e c4 e4) (q. f4 e g4 q a4) (q g4 f4 e e4 d4)))
    ;; Rotate default parameter pitch of 2nd bar (section 1) to the right.
    ;; The link above shows how to alternatively rotate length values etc.
    (rotate-omn 1 melody :section '(1) :flat nil)
    ; => ((-h e c4 e4) (q. a4 e f4 q g4) (q g4 f4 e e4 d4)) 
     
    Using a new version of rotate-omn defined with the revised edit-omn we can now also specify different rotation amounts for different bars. The first argument of the function is given a list of rotation amounts (0 1 2), so the pitches of the first bar are not rotated at all, the pitches of the first bar are rotated 1 step to the right, and the pitches of the second bar 2 steps.
     
    (rotate-omn '(0 1 2) melody :flat nil)
    => ((-h e c4 e4) (q. a4 e f4 q g4) (q e4 d4 e g4 f4))
     
    Such 'dynamic' function arguments can be combined with the section argument to limit the processing of the input music to only certain bars. The following call rotates the bars 2 and 3 only (section is (1 2)), the first bar of this selection by 2 steps to the right, and the next by 1 step.
     
    (rotate-omn '(2 1) melody :section '(1 2) :flat nil)
    ; => ((-h e c4 e4) (q. g4 e a4 q f4) (q d4 g4 e f4 e4))
     
    Now, remember that this post is actually about simplifying the definition of functions like rotate-omn. The definition of this function is pretty short, as the actual rotation is already implemented by gen-rotate, and all support of arguments like section, flat and now also 'dynamic' arguments is automatically implemented by edit-omn. For getting dynamic arguments, all we need to do is the following. First, we test whether the argument we want to turn into a 'dynamic' argument is a list. If not, we want to use it as a static value. The result of that test (using listp) is bound to the local variable n-list-arg?, because we need to use this value at two places. The argument additional-args on the last line gets our argument n if it is a list.
     
    We tell edit-omn how to actually transform the input music (e.g., sublists) by handing it a function -- that is another program that does the actual transformation. In the case below this function is an anonymous function (it has no name). Such functions are defined with lambda, which is pretty much like defun but without expecting a function name. Our anonymous function basically just calls gen-rotate, but if n is a list, then we first need to extract the OMN data to rotate and the amount by which to rotate it from the single argument xs of our anonymous function.
     
    (defun rotate-omn (n sequence &key (parameter :pitch) (flat T) (section nil))
      (let ((n-list-arg? (listp n)))
        (edit-omn parameter sequence
                  #'(lambda (xs)
                     (if n-list-arg?
                         (gen-rotate (second xs) (first xs))
                         (gen-rotate n xs)))
                  :section section
                  :flat flat
                  :additional-args (when n-list-arg? n))))
     
    With this approach you can write relatively simply functions for processing individual parameters, and then turn that relatively simple function into a much more fancy function processing arbitrary OMN expressions, including nested expressions, and automatically supporting typical Opusmodus arguments like section and flat, and now also with dynamic arguments. 
     
    As mentioned in other posts, the function edit-omn can be found as part of my tot library at GitHub (and yes, that library has a buch of dependencies, and is therefore a bit tricky to install the first time; updates are a bit more easy).  I also cleaned up the definition of edit-omn and fixed some bug that way.  
     
    Best,
    Torsten
  22. Like
    AM got a reaction from JulioHerrlein in Help with combining lists   
    something like this? don't know if it's like this...
    you want to project a chord on these "filtered pitches"?
     
    (setf lengths '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16)) (setf pitches '(g5 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4)) (setf chord-intervals '(3 1 2 2)) (make-omn :length lengths :pitch (loop for i in (append (list 0) (cumulative-sums (loop for k in lengths collect (/ k 1/16)))) append (chordize (interval-to-pitch chord-intervals :start (nth i pitches)))))  
  23. Like
    AM got a reaction from opmo in Help with combining lists   
    like that?
     
    (setf lengths '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16)) (setf pitches '(g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4)) ;;; get the pitches (loop for i in (append (list 0) (cumulative-sums (loop for k in lengths collect (/ k 1/16)))) collect (nth i pitches)) ;;; a function which generates OMN-format (defun superimpose (lengths pitches) (make-omn :length lengths :pitch (loop for i in (append (list 0) (cumulative-sums (loop for k in lengths collect (/ k 1/16)))) collect (nth i pitches)))) ;;; evaluate -> OMN output (superimpose '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16) '(g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4))  
  24. Like
    AM got a reaction from JulioHerrlein in Help with combining lists   
    like that?
     
    (setf lengths '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16)) (setf pitches '(g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4)) ;;; get the pitches (loop for i in (append (list 0) (cumulative-sums (loop for k in lengths collect (/ k 1/16)))) collect (nth i pitches)) ;;; a function which generates OMN-format (defun superimpose (lengths pitches) (make-omn :length lengths :pitch (loop for i in (append (list 0) (cumulative-sums (loop for k in lengths collect (/ k 1/16)))) collect (nth i pitches)))) ;;; evaluate -> OMN output (superimpose '(1/2 1/16 7/16 1/8 3/8 3/16 5/16 1/4 1/4 5/16 3/16) '(g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 fs4 a4 g4 gs4 a4 fs4 e4 b4 g4 gs4 fs4 a4 gs4 g4 f4 bb4 a4 fs4 e4 b4 fs4 a4 g4 gs4 e4 b4 a4 fs4 b4 e4 d4 cs5 gs4 g4 f4 bb4 g4 gs4 fs4 a4 f4 bb4 gs4 g4 bb4 f4 eb4 c5 g4 gs4 fs4 a4 gs4 g4 f4 bb4 fs4 a4 g4 gs4 a4 fs4 e4 b4 f4 bb4 gs4 g4))  
  25. Thanks
    AM reacted to torstenanders in Improving length-rest-series   
    I sometimes like to turn certain notes into rests. The built-in function length-rest-series is great for that, but it only works with lengths, not full OMN expressions. So, I generalised that function. I can do now, e.g., the following. 
     
    (setf melody '((s eb6 < leg f5 < leg c5 < leg f5 < leg) (e e6 f - -q)))
    (note-rest-series '(1 1) melody :swallow T :section '(0))
    ; => ((-s - c5 < leg f5 < leg) (e e6 f - -q))
     
    Note that in contrast to the original function length-rest-series, the new function note-rest-series does not only support OMN expressions, but also extra arguments like swallow and section.
     
    The definition of this function uses length-rest-series and my function edit-omn for writing such generalisations, and it can therefore be rather short. In fact, the documentation string of the function is much longer than the definition itself :)  Please see below.
     
    The function edit-omn is part of my tot library, which is available at GitHub. You can see its definition at starting at (currently) line 24 at https://github.com/tanders/tot/blob/master/sources/OMN-utils.lisp. 
     
    Note that with edit-omn you can also easily turn other functions that expect just a single parameter list (e.g., pitches, or lengths) into functions for OMN expressions by automatically preserving the time signature and very conveniently adding standard arguments like flat or section. 
     
    Best,
    Torsten
     
    (defun note-rest-series (positions sequence &key (flat nil) (swallow nil) (section nil)) "This function is like the Opusmodus built-in length-rest-series, but supports arbitrary OMN expressions as input and additionally the arguments swallow and section. Args: - positions (list of ints): positions of notes to be turned into rests - sequence (list of lengths or OMN expression): music to process - flat (Boolean): whether positions count for sublists (nil) or the whole list (T) - swallow (Boolean): whether the pitches of notes turned into rests should be shifted to the next note or omitted (swallowed) - section (list of ints): positions of sublists to process. This argument is ignored if flat is T. Example: ;;; (setf melody '((s eb6 < leg f5 < leg c5 < leg f5 < leg) (e e6 f - -q))) ;;; (note-rest-series '(1 1) melody :swallow T :section '(0)) " (edit-omn :length sequence #'(lambda (ls) (length-rest-series positions ls)) :swallow swallow :section section :flat flat))  
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy