Jump to content

Avner Dorman

Members
  • Posts

    45
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Avner Dorman got a reaction from hujairi in Negative Harmony Function   
    Hi Julio,
     
    The so called "negative harmony" is the same as "inversion and symmetrical axes" in set theory (which is the same as saying Neo-Riemannian theory - all transformations are In operations).
     
    An inversion of a pitch class is given by subtracting the pc from index of the inversion operation, n.
     
    In(pc1, pc2,pc3) = (n-pc1, n-pc2, n-pc3)
     
    If you want to think of it as an inversion around an axis, the axis would be n/2 (or 12-n/2 on the other side of the clock-face). 
     
    So the function could be written like this: 
     
    (defun axis-inversion (axis pitches) (integer-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-integer i))))) And if you want to use Eb-E as the axis it would be 3.5 (e is pc3 and eb is pc4)
     
    (axis-inversion 3.5 '(c4 e4 g4)) ;;; results in (g4 eb4 c4)  
    This doesn't account for octaves etc. - for that you'll need to use midi. Now the axis is given in midi number - so 63.5 would be Eb4:
     
    (defun midi-inversion (axis pitches) (midi-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-midi i))))) (midi-inversion 63.5 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 60 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 53.5 '(c4 e4 g4)) ;;; you get (b2 g2 e2)  
    If I missed any cases I am happy to check them out 🙂 
     
    All the best,
    Avner 
     
     
    p.s. - 
     
    (midi-inversion 63.5 '(a4 g4 fs4 a4 d5 a4 fs5 d5 a5 fs5 e5 d5)) ;;; results in (bb3 c4 cs4 bb3 f3 bb3 cs3 f3 bb2 cs3 eb3 f3) ;;; as you expected (I think? I only checked the first few notes :-)  
  2. Like
    Avner Dorman reacted to torstenanders in Opmo 1.3: Emacs interface (with SLIME) broken?   
    If your goal is for you as a teacher to create documents for your students to read containing Common Lisp and Opusmodus code, and where you want to evaluate the code directly from within that document, then Org mode with embedded Common Lisp + Slime is your friend. This is a very powerful combination, that can automatically create nice slides (with the LaTeX beamer interface), embed music notation (Lilypond) etc. I used this combination for years for teaching, had then all sessions of a course in a single document for easily moving content around etc.
     
    Nevertheless, you likely do not want to introduce your students to use Org mode... For that, Jupyter notebooks (or plain Opusmodus) will be more easy for the students.
     
    Org mode for Emacs – Your Life in Plain Text
    ORGMODE.ORG Org: an Emacs Mode for Notes, Planning, and Authoring  
    Babel: active code in Org-mode
    ORGMODE.ORG  
    However, I don't know of a way to automatically embed music notation output of Opusmodus in Emacs Org mode. What is missing for that, AFAIK, is some Opusmodus function that automatically creates a graphic file for a given snippet or score. If that would be there, that feature shouldn't be too hard to add (other Org mode babel programming language interfaces do already similar things, e.g., Lilypond, and the code for that is freely available).
  3. Thanks
    Avner Dorman got a reaction from JulioHerrlein in Negative Harmony Function   
    Dear Julio,
     
    I am very happy I could be of help! 🙂
     
    All the best,
    Avner 
  4. Like
    Avner Dorman got a reaction from lviklund in Negative Harmony Function   
    another p.s. - Ernst Levy's book is available on google play 
    A Theory of Harmony
    BOOKS.GOOGLE.DE In this introduction to natural-base music theory, Ernst Levy presents the essentials of a comprehensive, consistent theory of harmony developed from tone structure. A Theory of Harmony is a highly original explanation of the harmonic language of the last few centuries, showing the way toward an understanding of diverse styles of music. Basic harmony texts exist, but none supply help to students seeking threads of logic in the...  
    My favorite book on the subject is David Lewin's:
    Generalized Musical Intervals and Transformations. New Haven, CT, and London: Yale University Press, 1987. Reprinted, Oxford and New York: Oxford University Press, 2007.  
  5. Like
    Avner Dorman got a reaction from opmo in Negative Harmony Function   
    Hi Julio,
     
    The so called "negative harmony" is the same as "inversion and symmetrical axes" in set theory (which is the same as saying Neo-Riemannian theory - all transformations are In operations).
     
    An inversion of a pitch class is given by subtracting the pc from index of the inversion operation, n.
     
    In(pc1, pc2,pc3) = (n-pc1, n-pc2, n-pc3)
     
    If you want to think of it as an inversion around an axis, the axis would be n/2 (or 12-n/2 on the other side of the clock-face). 
     
    So the function could be written like this: 
     
    (defun axis-inversion (axis pitches) (integer-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-integer i))))) And if you want to use Eb-E as the axis it would be 3.5 (e is pc3 and eb is pc4)
     
    (axis-inversion 3.5 '(c4 e4 g4)) ;;; results in (g4 eb4 c4)  
    This doesn't account for octaves etc. - for that you'll need to use midi. Now the axis is given in midi number - so 63.5 would be Eb4:
     
    (defun midi-inversion (axis pitches) (midi-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-midi i))))) (midi-inversion 63.5 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 60 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 53.5 '(c4 e4 g4)) ;;; you get (b2 g2 e2)  
    If I missed any cases I am happy to check them out 🙂 
     
    All the best,
    Avner 
     
     
    p.s. - 
     
    (midi-inversion 63.5 '(a4 g4 fs4 a4 d5 a4 fs5 d5 a5 fs5 e5 d5)) ;;; results in (bb3 c4 cs4 bb3 f3 bb3 cs3 f3 bb2 cs3 eb3 f3) ;;; as you expected (I think? I only checked the first few notes :-)  
  6. Thanks
    Avner Dorman got a reaction from JulioHerrlein in Negative Harmony Function   
    another p.s. - Ernst Levy's book is available on google play 
    A Theory of Harmony
    BOOKS.GOOGLE.DE In this introduction to natural-base music theory, Ernst Levy presents the essentials of a comprehensive, consistent theory of harmony developed from tone structure. A Theory of Harmony is a highly original explanation of the harmonic language of the last few centuries, showing the way toward an understanding of diverse styles of music. Basic harmony texts exist, but none supply help to students seeking threads of logic in the...  
    My favorite book on the subject is David Lewin's:
    Generalized Musical Intervals and Transformations. New Haven, CT, and London: Yale University Press, 1987. Reprinted, Oxford and New York: Oxford University Press, 2007.  
  7. Thanks
    Avner Dorman got a reaction from JulioHerrlein in Negative Harmony Function   
    Hi Julio,
     
    The so called "negative harmony" is the same as "inversion and symmetrical axes" in set theory (which is the same as saying Neo-Riemannian theory - all transformations are In operations).
     
    An inversion of a pitch class is given by subtracting the pc from index of the inversion operation, n.
     
    In(pc1, pc2,pc3) = (n-pc1, n-pc2, n-pc3)
     
    If you want to think of it as an inversion around an axis, the axis would be n/2 (or 12-n/2 on the other side of the clock-face). 
     
    So the function could be written like this: 
     
    (defun axis-inversion (axis pitches) (integer-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-integer i))))) And if you want to use Eb-E as the axis it would be 3.5 (e is pc3 and eb is pc4)
     
    (axis-inversion 3.5 '(c4 e4 g4)) ;;; results in (g4 eb4 c4)  
    This doesn't account for octaves etc. - for that you'll need to use midi. Now the axis is given in midi number - so 63.5 would be Eb4:
     
    (defun midi-inversion (axis pitches) (midi-to-pitch (loop for i in pitches collect (- (* 2 axis) (pitch-to-midi i))))) (midi-inversion 63.5 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 60 '(c4 e4 g4)) ;;; you get (g4 eb4 c4) (midi-inversion 53.5 '(c4 e4 g4)) ;;; you get (b2 g2 e2)  
    If I missed any cases I am happy to check them out 🙂 
     
    All the best,
    Avner 
     
     
    p.s. - 
     
    (midi-inversion 63.5 '(a4 g4 fs4 a4 d5 a4 fs5 d5 a5 fs5 e5 d5)) ;;; results in (bb3 c4 cs4 bb3 f3 bb3 cs3 f3 bb2 cs3 eb3 f3) ;;; as you expected (I think? I only checked the first few notes :-)  
  8. Like
    Avner Dorman got a reaction from Stephane Boussuge in Negative Harmony Function   
    another p.s. - Ernst Levy's book is available on google play 
    A Theory of Harmony
    BOOKS.GOOGLE.DE In this introduction to natural-base music theory, Ernst Levy presents the essentials of a comprehensive, consistent theory of harmony developed from tone structure. A Theory of Harmony is a highly original explanation of the harmonic language of the last few centuries, showing the way toward an understanding of diverse styles of music. Basic harmony texts exist, but none supply help to students seeking threads of logic in the...  
    My favorite book on the subject is David Lewin's:
    Generalized Musical Intervals and Transformations. New Haven, CT, and London: Yale University Press, 1987. Reprinted, Oxford and New York: Oxford University Press, 2007.  
  9. Like
    Avner Dorman got a reaction from opmo in Harmonic-progression with steps   
    Thank you so much! Works great!
  10. Thanks
    Avner Dorman reacted to opmo in Harmonic-progression with steps   
    I will have a look.
     
  11. Thanks
    Avner Dorman got a reaction from opmo in Parsimonious Voice Leading (again): attempts to provide an algorithm   
    Yes - obviously you're right -  that one is the best.
     
    So is there a way to implement that? I actually appreciate that chord-closest-path gives different options on different runs (it's quite creative 🙂) but I would also like to have the option of a truly parsimonious voice leading function. 
     
    Julio's solution seems to work, but I can't quite manage to make it into a function....and I don't know enough Python (and maybe not enough lisp) to easily convert Tymoczko's code to lisp. 
     
    By the way - I love Opusmodus as well!
     
    Thanks 🙂
    Avner 
  12. Like
    Avner Dorman reacted to opmo in Opusmodus 1.2.22455   
    New:
    BLOCK-CHORD-REDUCE
     
    The function BLOCK-CHORD-REDUCE reduces (compress) every bar of every instrument into a single chord.
     
    (setf rh       '((-q. e gs3 f)         (-q e a4 p stacc -)         (-e q f5 f ten -e)         ((acc e g6 mf) e6 p stacc -q.)         (e cs4fs4c5 f marc -q e d3 p)         (-e gs3 f - g6 p stacc)         (-q. (acc e ds5 fff) e6 ff stacc)         (-q c5 f ten)         (-e (acc d6 mf) b5 p stacc - b3f5bb5 ff)         (-q e a4 p stacc -)         (-e cs4 f - c5 p stacc)         (-q. e gs3 f))) (setf lh       '((-q e bb5 f -)         (-e a4 p stacc -q)         (q cs4 f ten -e (acc b2 mf) d3 p stacc)         (-q. e fs4c5f5 f marc)         (-q e e6 p -)         (-q e bb5 f -)         (e b2 p stacc - (acc eb4 fff) d3 ff stacc -)         (-e q fs4 f ten -e)         ((acc e e3 mf) e g3 p stacc -q.)         (e gs3cs4g4 ff marc -q e a4 p stacc)         (-q e f5 f -)         (e fs4 p stacc -q.)))  
     
    In this example we use the time-signature from the sequence rh:
     
    (block-chord-reduce (list rh lh) :time rh) => ((1/2 gs3bb5) (1/2 a4) (1/2 f5cs4b2d3) (1/2 g6e6fs4c5f5)     (1/2 cs4fs4c5d3e6) (1/2 gs3g6bb5) (1/2 ds5e6b2eb4d3)     (1/2 c5fs4) (1/2 d6b5b3f5bb5e3g3) (1/2 gs3cs4g4a4)     (1/2 cs4c5f5) (1/2 gs3fs4))  
     

     
    Reduce with option :row t (modus 12):
    (block-chord-reduce (list rh lh) :time rh :row t)  

     
    Examples:
     
    Score: Howto Score/Chord Progression1.opmo
     
    (setf violin1       '(#|1|# (-t a3 f -s -t b3 -s -t b3 -s -t b3 -s -t b3 -s -t b3                -s -t b3 -s -t c4 -s)         #|2|# (t c4 f c4 -s. t c4 c4 c4 c4 c4 -s. t c4 -s. t c4 -s.                t d4 -s. t d4 -s. t d4 -s)         #|3|# (-t d4 f -s. t d4 -s. t e4 -s. t e4 -s. t e4 -s. t e4                -s. t e4 -s. t e4 -s)         #|4|# (-t e4 f -s. e e4 s s c4 c4 c4 c4 c4 c4 c4 t - - - d4                -s)         #|5|# (-t e4 f -s -t e4 -s -t e4 -s -t e4 -s -t e4 -s -t e4                -s -t e4 -s -t e4 -s)         #|6|# (-t a4 f -s -t a4 -s -t a4 -s -t a4 -s -t a4 -s -t a4                -s -t a4 -s -t a4 -s)         #|7|# (-t b4 f -s. t b4 -s. t b4 -s. t b4 b4 b4 - b4 -s                 -t b4 -s -t b4 -s -t b4 -s)         #|8|# (-t b4 f -s. t b4 -s. t b4 -s. t b4 b4 c5 - c5 -s                -t c5 -s -t d5 -s -t d5 -s)         #|9|# (e.. d5 f s s s q e5 s s s t - s e5 t)         #|10|# (-t s e5 f t - s e5 t - s e5 t - s e5 t - s e5 t                 - s e5 t - s a5 t - a5 -s)         #|11|# (-t b5 f -s. t b5 b5 c6 c6 c6 -q -s. t a3 b3 b3 b3                 e -s.)         #|12|# (-e -t b3 f b3 c4 c4 e -q t c4 c4 c4 c4 e s.)         #|13|# (s c4 f -s. s d4 -e. t d4 d4 - d4 d4 e4 - e4 e4 e4                 - e4 e4 e4 - e4 s -t)         #|14|# (-e -t s c4 f -e. t c4 c4 - c4 c4 c4 - c4 c4 d4                 - e4 e4 e4 - e4 -s.)         #|15|# (-e -t s e4 f -e. t e4 e4 - e4 a4 a4 - a4 a4 a4                 - a4 a4 a4 - b4 -s.)         #|16|# (s b4 f -s. s b4 -e. t b4 b4 - b4 b4 b4 - b4 b4 b4                 - b4 b4 b4 - b4 s c5 -t)         #|17|# (-e -t c5 f c5 d5 d5 e -q t d5 d5 d5 e5 e s.)         #|18|# (-t e5 f -s. t e5 e5 e5 e5 e5 -q -s. t e5 e5 e5 e5                 e -s.)         #|19|# (-t s e5 f t - s e5 t - s e5 t a5 - s a5 t - s b5 t                 - s b5 t c6 - s c6 t - a3 -s)         #|20|# (e.. b3 f s s s q s s c4 c4 t - s c4 t)         #|21|# (-t c4 f -s. t c4 -s. t c4 -s. t c4 c4 d4 - d4 -s                 -t d4 -s -t d4 -s -t d4 -s)         #|22|# (-t e4 f -s. t e4 -s. t e4 -s. t e4 e4 e4 - e4 -s                 -t e4 -s -t e4 -s -t c4 -s)         #|23|# (-t c4 f -s -t c4 -s -t c4 -s -t c4 -s -t c4 -s                 -t c4 -s -t c4 -s -t d4 -s)         #|24|# (-t e4 f -s -t e4 -s -t e4 -s -t e4 -s -t e4 -s                 -t e4 -s -t e4 -s -t e4 -s)         #|25|# (-t a4 f -s. e a4 s s s s s s s b4 b4 t - - - b4 -s)         #|26|# (-t b4 f -s. t b4 -s. t b4 -s. t b4 -s. t b4 -s.                 t b4 -s. t b4 -s. t b4 -s)         #|27|# (t b4 f b4 -s. t b4 c5 c5 c5 d5 -s. t d5 -s. t d5                 -s. t d5 -s. t d5 -s. t d5 -s)         #|28|# (-t e5 f -s -t e5 -s -t e5 -s -t e5 -s -t e5 -s                 -t e5 -s -t e5 -s -t e5 -s))) (setf violin2       '(#|1|# (-q... s e4 f fs4 fs4 t t t t t g3 -et t g3)         #|2|# (t g3 f s s t t t t t -e.. t a3 a3 a3 a3 e.. -e)         #|3|# (-t b3 f b3 b3 b3 e.. -s. s b3 b3 b3 t t g4 g4 g4 g4                -et t g4)         #|4|# (t g4 f s s t a4 b4 b4 b4 b4 - b4 -s. t b4 -s. t b4                -s. t b4 -q)         #|5|# (-t e5 f e5 e5 e5 e.. -et t e5 e5 e5 fs5 e.. -e)         #|6|# (-t fs5 f fs5 fs5 fs5 e.. -ht s. fs5)         #|7|# (s. fs5 f s e. s e. s e. t g5 - s g5 t)         #|8|# (-t s a5 f t - s a5 t - s a5 t - b5 b5 b5 b5 b5                b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5 b5)         #|9|# (-t e6 f -s. t e6 -s. t e6 -s t fs6 fs6 fs6 g6                - g6 -s. t g6 -s. t e4 -s. t fs4 -s)         #|10|# (t fs4 f fs4 -qs. t fs4 fs4 fs4 g3 g3 -qs. t g3 g3 g3)         #|11|# (t g3 f g3 -qs. t g3 g3 g3 a3 a3 -qs. t a3 a3 a3)         #|12|# (t b3 f b3 -qs. t b3 b3 b3 b3 b3 -qs. s. b3)         #|13|# (e.. b3 f s g4 g4 g4 q s s s t - s a4 t b4)         #|14|# (-t s b4 f t - s b4 t - s b4 t - s b4 t e5 - s e5 t                 - s e5 t - s e5 t - s. e5)         #|15|# (-t s fs5 f t - s fs5 t - s fs5 t - s fs5 t -                 s fs5 t - s fs5 t - s fs5 t - s. fs5)         #|16|# (e.. g5 f s s s a5 q s s s t - s b5 t)         #|17|# (t b5 f b5 -qs. t b5 b5 b5 b5 b5 -qs. s. b5)         #|18|# (t b5 f b5 -qs. t b5 b5 b5 b5 b5 -qs. t b5 b5 e6)         #|19|# (t e6 f e6 -qs. t fs6 fs6 fs6 g6 g6 -qs. t g6 e4 fs4)         #|20|# (-t fs4 f -s. t fs4 -s. t fs4 -s t fs4 fs4 g3 g3                 - g3 -s. t g3 -s. t g3 -s. t g3 -s)         #|21|# (-t s g3 f t - s g3 t - s a3 t - a3 a3 a3 b3 b3                 b3 b3 b3 b3 b3 b3 b3 g4 g4 g4 g4 g4 g4 g4)         #|22|# (s. g4 f s a4 e. b4 s e. s e. t - s b4 t)         #|23|# (-t e5 f e5 e5 e5 e.. -ht s. e5)         #|24|# (-t e5 f e5 fs5 fs5 e.. -et t fs5 fs5 fs5 fs5 e.. -e)         #|25|# (t fs5 f s s t t t t t g5 - g5 -s. t g5 -s. t a5                 -s. t a5 -q)         #|26|# (-t a5 f a5 a5 a5 e.. b5 -s. s b5 b5 b5 t t t t t                 -et t b5)         #|27|# (t b5 f s s t t t t t -e.. t b5 e6 e6 e6 e.. fs6 -e)         #|28|# (-q... s fs6 f fs6 g6 t t t e4 -q))) (setf viola       '(#|1|# (-w)         #|2|# (-w)         #|3|# (-w)         #|4|# (-w)         #|5|# (-h -e -t g5 f -s. t e4 -s. t g4 -s)         #|6|# (-t c6 f -s. e d5 s g3 e5 d5 fs3 d5 fs5 g4 e3 g3 c5 -s.)         #|7|# (-w)         #|8|# (-w)         #|9|# (-w)         #|10|# (-h -e -t d5 f g5 e4 g4 e3 -s. d3)         #|11|# (e.. fs3 f s g5 e6 g5 q c5 s d5 c5 d5 t g5 - s e3 t d3)         #|12|# (-t s fs5 f t g5 - s e5 t g5 - s e4 t g5 - s c5 t d5                 - s g5 t e6 - s d5 t fs5 - s g4 t fs3 - g5 -s)         #|13|# (-t e4 f -q -s. e g5 t c3 -s. s d3 -e. t g5 e3 d6)         #|14|# (t e4 f d5 fs3 g5 e4 g4 c5 d6 g4 d5 g4 e4 d3 s fs5 -e.                 s g3 -e. t e3 g3 c5)         #|15|# (t g3 f c5 d5 g5 e3 d5 fs3 g4 e3 g5 e3 g3 c6 s d3 -e.                 s g5 -e. t e6 d3 fs5)         #|16|# (-t d5 f -q -s. e fs5 t g5 -s. s e4 -e. t g5 c5 d6)         #|17|# (-t s g3 f t e3 - s g5 t e3 - s d5 t fs4 - s g3 t e5                 - s g3 t c6 - s d5 t g5 - s e4 t g4 - c6 -s)         #|18|# (e.. d5 f s g3 e5 d5 q fs3 s d5 fs5 g4 t e3 - s g3 t c5)         #|19|# (-h -e -t d5 f g5 e4 g4 e3 -s. d3)         #|20|# (-w)         #|21|# (-w)         #|22|# (-w)         #|23|# (-t fs3 f -s. e g5 s e6 g5 c5 d5 c5 d5 g5 e3 d3 fs5 -s.)         #|24|# (-h -e -t g5 f -s. t e5 -s. t g5 -s)         #|25|# (-w)         #|26|# (-w)         #|27|# (-w)         #|28|# (-w))) (setf cello       '(#|1|# (-w)         #|2|# (-w)         #|3|# (-w)         #|4|# (-w)         #|5|# (-w)         #|6|# (-w)         #|7|# (-w)         #|8|# (-w)         #|9|# (-w)         #|10|# (-q -e -t e4 f c3 e3 a4 b3 -q -s. t e2 c4 b3)         #|11|# (t d2 f b3 -q -s. t d4 e3 c2 e2 a3 -q -s. t b3 e4 c3)         #|12|# (t e3 f c2 -q -s. t b2 d2 e4 c5 e4 -q -s. a3)         #|13|# (e.. b3 f s a3 b3 e4 q c2 s b2 d4 e4 t c4 - s e4 t c3)         #|14|# (-t s e4 f t a3 - s b3 t e4 - s c5 t b3 - s d4 t e3                 - s d2 t e4 - s c3 t e4 - s a2 t b2 - s. e4)         #|15|# (-t s c2 f t b4 - s c3 t b3 - s d2 t e4 - s c3 t e3                 - s a3 t b4 - s e3 t b3 - s e3 t c3 - s. b2)         #|16|# (e.. d4 f s e2 c2 e2 q a3 s e2 a3 b3 t e4 - s c2 t b3)         #|17|# (t d2 f e3 -q -s. t c2 e4 c2 e2 a4 -q -s. b2)         #|18|# (t e4 f c5 -q -s. t b2 d4 b3 d4 e4 -q -s. t c3 e4 a3)         #|19|# (-q -e -t b4 f e2 c2 e4 c2 -q -s. t b3 d3 e2)         #|20|# (-w)         #|21|# (-w)         #|22|# (-w)         #|23|# (-w)         #|24|# (-w)         #|25|# (-w)         #|26|# (-w)         #|27|# (-w)         #|28|# (-w)))  
     
    (block-chord-reduce (list violin1 violin2 viola cello))
     
    (block-chord-reduce (list violin1 violin2 viola cello) :row t)
     
     
    The option :time allows to change the scope of the analysis:
    (block-chord-reduce (list violin1 violin2 viola cello) :time 4/8)
     
    (block-chord-reduce (list violin1 violin2 viola cello) :time 1/4)
     
     
    The option :bar allows to view a specified bar number only:
    (block-chord-reduce (list violin1 violin2 viola cello) :bar '(10 11))
     
    Best wishes,
    JP
  13. Like
    Avner Dorman reacted to torstenanders in Towards algorithmic orchestration (and customising sound playback with multiple sound libraries)   
    Dear Alain Jamot, 
     
    here is a function that may help you. This function is useful for customising sound playback with multiple sound libraries or for algorithmic orchestration. 
     
    The function expects an OMN expression and returns a list of multiple OMN sequences (multiple parts). It basically sorts notes from the OMN sequence into different parts, depending on the articulations of individual notes. All notes with certain articulations go in one resulting parts, and notes with other articulations in another part.
     
    Here is an example. It sorts all notes with pizz or arco articulations into one part, and notes with trem articulations into another part. Each time, notes are substituted by rests in other parts, so that timing relations of notes in different parts are preserved.  
    (separate-parts '((h c4 pizz q arco) (h trem q h pizz) (h arco+stacc -q fermata))                 '((pizz arco)                   (trem))) => ; part 1: pizz and arco    ((h c4 mf pizz q arco) (-h q c4 mf h pizz) (h c4 mf arco+stacc -q fermata))    ; part 2: trem    ((-h -q) (h c4 mf trem -q -h) (-h -q fermata)))  
    You can then assign your first part to on MIDI channel in your def-score call, and the next part to another MIDI channel, e.g., like so.
    (setf omn-expr '((h c4 pizz q arco) (h trem q h pizz) (h arco+stacc -q fermata))) (setf parts (separate-parts omn-expr                             '((pizz arco)                               (trem)))) (def-score two-violins            (:title "Title"             :composer "Composer"             :copyright "Copyright © "             :key-signature 'chromatic             :time-signature '((1 1 1 1) 4)             :tempo 100             :layout (bracket-group                      (violin1-layout 'violin1)                      (violin2-layout 'violin2)))      (violin1    :omn (nth 0 parts)    :channel 1    :sound 'gm    :program 'violin    :volume 100    :pan 54    :controllers (91 '(48))    )      (violin2    :omn (nth 1 parts)    :channel 2    :sound 'gm    :program 'violin    :volume 100    :pan 74    :controllers (91 '(60))    )   )  
    The function definition of separate-parts is below.
     
    Best,
    Torsten
     
    Janusz: This is another example of a function showing how processing polyphonic music with double-nested OMN expressions can be useful. Once we have a standard notation for polyphonic OMN expressions with multiple voices/parts in Opusmodus 2, as discussed earlier, then this function can easily be adapted to output that format. 
    (labels ((make-corresponding-rest (event) (let ((len (omn-encode (first event)))) (cons ;; rests should remain rests (if (> len 0) (* len -1) len) (omn :rest-articulation event)))) (push-event-and-rests (event matching-position result-omns articulation-sets-length) (push event (nth matching-position result-omns)) (loop for i in (remove matching-position (gen-integer 0 (1- articulation-sets-length))) do (push (make-corresponding-rest event) (nth i result-omns))))) (defun separate-parts (sequence articulation-sets) "The function `separate-parts' is useful for customising your sound playback with multiple sound libraries or for algorithmic orchestration. The function breaks an OMN sequence (a single part) into a list of multiple OMN sequences (multiple parts). It basically sorts notes from the OMN sequence into different parts, depending on the articulations of individual notes. All notes with certain articulations go in one resulting parts, and notes with other articulations in another part. In all other resulting parts, notes are substituted by rests, so that timing relations of notes in different parts are preserved. This function can be useful, when you have multiple sound libraries that support different articulations of the same instrument. You can then perform notes with certain articulations on one software instrument (on its own MIDI channel etc.), and notes with other articulations on another instrument. Alternatively, you can use the function for algorithmic orchestration, where you assign custom articulations (typically declared with add-text-attributes first) such as instrument labels with your custom algorithm, and then use this function in a second step to separate your instruments. Remember that the result of this function is a list of multiple OMN sequences (multiple parts). You have to split it into its individual parts for use in OMN. Args: - sequence: OMN sequence, can be nested - articulation-sets: list of list of articulations. All notes with articulations contained in the first articulation-set end up in the first resulting part, notes with articulations in the second set end up in the second part and so forth. The decision which part a note belongs to is always made based on the first articulation that matches an articulation-set. If a note contains no articulation, or an articulation contained in no set, then it is matched to the first articulation-set. If an articulation is contained in multiple articulation-sets, then the earlier match in articulation-sets is used. Examples: (separate-parts '(h c4 pizz q arco) '((pizz) (arco))) => ((h c4 mf pizz -q) ; part 1 with pizz articulations (-h q c4 mf arco)) ; part 2 with arco (separate-parts '((h c4 pizz q arco) (h trem q h pizz) (h arco+stacc -q fermata)) '((pizz arco) (trem))) => (((h c4 mf pizz q arco) (-h q c4 mf h pizz) (h c4 mf arco+stacc -q fermata)) ; part 1: pizz and arco ((-h -q) (h c4 mf trem -q -h) (-h -q fermata))) ; part 2: trem " (if (listp (first sequence)) ;; sequence is nested (matrix-transpose (mapcar #'(lambda (seq) (separate-parts seq articulation-sets)) sequence)) ;; sequence is flat list (let* ((articulation-sets-length (length articulation-sets)) (result-omns (make-list articulation-sets-length :initial-element nil))) (loop for event in (single-events sequence) do (let ((event-articulation (fourth event))) (if event-articulation (let ((matching-position (position-if #'(lambda (articulation-set) (some #'(lambda (art) (member art (disassemble-articulations event-articulation))) articulation-set)) articulation-sets))) (if matching-position (push-event-and-rests event matching-position result-omns articulation-sets-length) ;; if no match, then add event to first omn result (push-event-and-rests event 0 result-omns articulation-sets-length))) ;; if no articulation, then add event to first omn result (push-event-and-rests event 0 result-omns articulation-sets-length)))) (mapcar #'(lambda (result) (flatten-omn (reverse result))) result-omns))))) ;; for your convenience, I include the following definition already shared earlier (defun disassemble-articulations (art) "Splits a combined OMN articulations into a list of its individual attributes. Example: (disassemble-articulations 'leg+ponte) => (leg ponte)" (mapcar #'intern (split-string (symbol-name art) :separator "+")))
  14. Like
    Avner Dorman got a reaction from torstenanders in Opposite of chordize?   
    Hi Torsten,
     
    Would these work?
     
    (pitch-melodize '(c4e4g4))
    => (c4 e4 g4)
     
    And (pitch-to-midi '(c4e4g4))
    =>((60 64 67))
     
    or (flatten (pitch-to-midi '(c4e4g4)))
    => (60 64 67)
     
    All the best,
    Avner 
  15. Like
    Avner Dorman got a reaction from lviklund in Add pitch classes as text above notes?   
    Thanks so much!!! This is great!
     
    I wrote the following functions that automatically add the pitch class as text above each note. This is really useful for me when teaching set theory. I am sharing them in case anyone else needs something like this 🙂
     
    Also, I'd be curious to know how the text font might be modified. 
    ;; convert pitch-classes to nums (defun pc-to-num (pitches)   (substitute-map '(num0 num1 num2 num3 num4 num5 num6 num7 num8 num9 num10 num11) '(0 1 2 3 4 5 6 7 8 9 10 11) (modus (pitch-to-integer pitches)))) ;; interweave two lists (defun interweave (list1 list2)   (if (null list1)     list2      (cons (car list1) (interweave list2 (cdr list1))))) ;; add pcs as a num to each pitch (defun show-pcs (pitches) (interweave pitches (pc-to-num pitches))) ;; test (setf pitches '(c4 bb4 f4 eb4 fs4 d4 g4 b4 e4 a4 cs4 gs4)) (show-pcs pitches)  
    Pitches with PCS.pdf
    Pitches.pdf
  16. Like
    Avner Dorman reacted to opmo in Opusmodus 1.2.21935   
    Changes to TONALITY-MAP function:
     
    The map shift name is changed to step.
    The sort by default is nil.
     
    The function TONALITY-MAP can be used to map tonalities on to a chromatic pitch series. There are two types of map: step and NIL. The step map use the sequence interval steps to map the tonalities on to the sequence. The map NIL use the sequence integers to map the tonalities to the closest integer on to the sequence.
     
    In the following example we use the closest type map:
    (tonality-map '((0 2 4 7 9 11)) '(c4 cs4 d4 cs4 eb4 f4 e4)) => (c4 d4 d4 c4 e4 f4 e4)  
    Here we use the step map:
    (tonality-map '((0 2 4 7 9 11) :map step) '(c4 cs4 d4 cs4 eb4 f4 e4)) => (c4 d4 e4 d4 g4 b4 a4)  
    New keywords :extend and :end added to the GEN-DYNAMIC and VELOCITY-TO-DYNAMIC function:
     
    GEN-DYNAMIC
    Example with optional :end velocity value:
    (gen-dynamic '(3 5 4 4 5) '(pp f ff mf f) :end 'p) => (pp< < < f< < < < < ff> > > > mf< < < < f> > > > p) (gen-dynamic '(3 5 4 4 5) '(pp f ff mf f) :end '>) => (pp< < < f< < < < < ff> > > > mf< < < < f> > > > >) (gen-dynamic '(3 5 4 4 5) '(pp f ff mf f) :end '<) => (pp< < < f< < < < < ff> > > > mf< < < < f< < < < <) (gen-dynamic '((3 5) (4 4) (5 3)) '((pp f) (p mf) (f p)) :end 'f) => ((pp< < < f> > > > >) (p< < < < mf< < < <) (f> > > > > p< < f))  
     
    Setting the :extend to t will removes intermediate textual dynamic indicators and replace them with extended hairpins:
    (gen-dynamic '(3 5 4 4 5) '(pp f ff mf f) :end 'p :extend t) => (pp< < < < < < < < ff> > > > mf< < < < f> > > > p) (gen-dynamic '(3 5 4 4 5) '(pp f ff mf f) :end '< :extend t) => (pp< < < < < < < < ff> > > > mf< < < < < < < < <) (gen-dynamic '((3 5) (4 4) (5 3)) '((pp f) (p mf) (f p)) :end 'f :extend t) => ((pp< < < f> > > > >) (p< < < < < < < <) (f> > > > > p< < f))  
     
    VELOCITY-TO-DYNAMIC
    (velocity-to-dynamic '(p p mp mp f ff mp mp p f)) => (p< < mp< < f< ff> mp> > p< f) (velocity-to-dynamic '(p p mp mp f ff mp mp p f) :extend t) => (p< < < < < ff> > > p< f) (velocity-to-dynamic '(p p mp mp f ff mp mp p f) :end 'pp) => (p< < mp< < f< ff> mp> > p> pp) (velocity-to-dynamic  '((pppp ppp ppp pp ppp p p mp mf mf) (f ff mf mp p ppp pppp))) => ((pppp< ppp< < pp> ppp< p< < mp< mf< <) (f< ff> mf> mp> p> ppp> pppp))  
    Setting the :extend to t will removes intermediate textual dynamic indicators and replace them with extended hairpins:
    (velocity-to-dynamic '(p p mp mp f ff mp mp p f) :end 'pp :extend t) => (p< < < < < ff> > > > pp) (velocity-to-dynamic  '((pppp ppp ppp pp ppp p p mp mf mf) (f ff mf mp p ppp pppp)) :extend t) => ((pppp< < < pp> ppp< < < < < <) (f< ff> > > > > pppp)) Please check the documentation for more details.
     
    If you used the TONALITY-MAP with :map shift then you need to change the name shift to step.
    To make the changes to all of your scores you can use the 'Search Files...' tool.
     
    Minor fixes and code optimisation.
     
    Best wishes,
    JP
  17. Like
    Avner Dorman reacted to Stephane Boussuge in Song generation/construction example   
    Hi,
     
    i've made an example of song generator/constructor for one of my Opusmodus student.
     
    I share it here if it could be useful to somebody.
     
    SB.
    SongConstructExample.opmo
×
×
  • Create New...

Important Information

Terms of Use Privacy Policy