lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add chord range to make-part-combine-music (issue 144170043 by address@h


From: nine . fierce . ballads
Subject: Add chord range to make-part-combine-music (issue 144170043 by address@hidden)
Date: Fri, 19 Sep 2014 02:38:12 +0000

Reviewers: ,

Message:
I hope this is acceptable for now without a music function.  I have
other partcombiner contributions planned and I think it makes sense to
work from the inside out.

https://code.google.com/p/lilypond/issues/detail?id=4112

Description:
Add chord range to make-part-combine-music

Please review this at https://codereview.appspot.com/144170043/

Affected files (+38, -10 lines):
  A input/regression/part-combine-chord-range.ly
  M ly/music-functions-init.ly
  M scm/part-combiner.scm


Index: input/regression/part-combine-chord-range.ly
diff --git a/input/regression/part-combine-chord-range.ly b/input/regression/part-combine-chord-range.ly
new file mode 100644
index 0000000000000000000000000000000000000000..3536ac3a22384e30d72015a382b6abe3a452c750
--- /dev/null
+++ b/input/regression/part-combine-chord-range.ly
@@ -0,0 +1,26 @@
+\header {
+  texidoc ="The part combiner chord range can be adjusted."
+}
+
+\version "2.19.15"
+
+\layout { ragged-right = ##t }
+
+vone = \relative e' {
+  d4 e f fisis | g geses b' bisis | b2 beses
+}
+
+vtwo = \relative e' {
+  e4 e e e | e eisis d deses | c2 cisis
+}
+
+comm = { s1_"apart" s1_"chords" s1_"apart" }
+
+customcombine =
+#(define-music-function (parser location part1 part2) (ly:music? ly:music?)
+   (make-part-combine-music parser (list part1 part2) #f '(2 . 12)))
+
+\new Staff <<
+  \customcombine \vone \vtwo
+  \comm
+>>
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index 6bb98c6c801f3c024eb3fce3c43755fd7376e5ab..daf2b93a6ff804443365b0a2b4e6c57cfe60da7f 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -1131,26 +1131,28 @@ parenthesize =
        (set! (ly:music-property arg 'parenthesize) #t))
    arg)

+#(define partcombine-chord-range '(0 . 8))
+
 partcombine =
 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
    (_i "Take the music in @var{part1} and @var{part2} and typeset so
 that they share a staff.")
    (make-part-combine-music parser
-                            (list part1 part2) #f))
+                            (list part1 part2) #f partcombine-chord-range))

 partcombineUp =
 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
    (_i "Take the music in @var{part1} and @var{part2} and typeset so
 that they share a staff with stems directed upward.")
    (make-part-combine-music parser
-                            (list part1 part2) UP))
+                            (list part1 part2) UP partcombine-chord-range))

 partcombineDown =
 #(define-music-function (parser location part1 part2) (ly:music? ly:music?)
    (_i "Take the music in @var{part1} and @var{part2} and typeset so
 that they share a staff with stems directed downward.")
    (make-part-combine-music parser
-                            (list part1 part2) DOWN))
+ (list part1 part2) DOWN partcombine-chord-range))

 partcombineForce =
#(define-music-function (location parser type once) (symbol-or-boolean? boolean?)
Index: scm/part-combiner.scm
diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm
index dd3152cbb7125bfd025e2a85cefdd95f4fa73b5f..6b1b5e1fbc48761b833b10e8cb46f5515f641f6b 100644
--- a/scm/part-combiner.scm
+++ b/scm/part-combiner.scm
@@ -253,7 +253,7 @@ LilyPond version 2.8 and earlier."
      global)
     context-list))

-(define-public (make-part-combine-music parser music-list direction)
+(define-public (make-part-combine-music parser music-list direction chord-range)
   (let* ((m (make-music 'PartCombineMusic))
(m1 (make-non-relative-music (context-spec-music (first music-list) 'Voice "one"))) (m2 (make-non-relative-music (context-spec-music (second music-list) 'Voice "two")))
@@ -266,14 +266,14 @@ LilyPond version 2.8 and earlier."
     (set! (ly:music-property m 'split-list)
           (if (and (assoc "one" evs1) (assoc "two" evs2))
               (determine-split-list (reverse! (assoc-get "one" evs1) '())
-                                    (reverse! (assoc-get "two" evs2) '()))
+                                    (reverse! (assoc-get "two" evs2) '())
+                                    chord-range)
               '()))
     m))

-(define-public (determine-split-list evl1 evl2)
-  "@var{evl1} and @var{evl2} should be ascending."
+(define-public (determine-split-list evl1 evl2 chord-range)
+ "@var{evl1} and @var{evl2} should be ascending. @var{chord-range} is a pair (min . max) defining the distance (in steps) between notes that may share a stem."
   (let* ((pc-debug #f)
-         (chord-threshold 8)
          (voice-state-vec1 (make-voice-states evl1))
          (voice-state-vec2 (make-voice-states evl2))
          (result (make-split-state voice-state-vec1 voice-state-vec2)))
@@ -379,12 +379,12 @@ Only set if not set previously.
                      (if (and (pair? pitches1)
                               (pair? pitches2)
                               (or
-                               (< chord-threshold (ly:pitch-steps
+                               (< (cdr chord-range) (ly:pitch-steps
(ly:pitch-diff (car pitches1) (car pitches2))))

                                ;; voice crossings:
- (> 0 (ly:pitch-steps (ly:pitch-diff (car pitches1) + (> (car chord-range) (ly:pitch-steps (ly:pitch-diff (car pitches1) (car pitches2))))
                                ))
                          (put 'apart)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]