lilypond-devel
[Top][All Lists]
Advanced

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

PATCH: new types of arpeggio


From: Chris Jackson
Subject: PATCH: new types of arpeggio
Date: Fri, 24 Aug 2001 14:12:13 +0100
User-agent: Mutt/1.2.5i

As Lilypond didn't have this feature, I finally decided to write it
myself! I've added support for arpeggios with arrows on the top or bottom
to indicate their direction. Also in this patch is the facility to add a 
square bracket to the left of a chord - I've seen this used in piano music 
to mean "don't do an arpeggio here". 

It's the first time I've done anything like this (hacking free software), so
I'd appreciate it if people tried this out to let me know what they think.
The arrowhead looks OK but I think it could be prettier. I don't yet fully
understand the positioning of objects on the staff within the C++, but this
seems to work without much verbosity.

I've added bits to the reference manual and the regression test at the
appropriate places. To use it, just do something like

\property Voice.Arpeggio \override #'arpeggio-type #'down

(or #'up, or #'bracket, or the default #'plain, or PianoStaff.Arpeggio)

I mainly use Lilypond to do piano music, so another thing on my to-do list is
the piano pedalling notation that looks like |_____/\____/\___| , unless 
anyone else is in the middle of doing this! 

cheers,
chris

-------------------------------------------------------------------

diff -urN lilypond-1.5.7/AUTHORS.txt lilypond-1.5.7-new/AUTHORS.txt
--- lilypond-1.5.7/AUTHORS.txt  Fri Aug 17 00:42:45 2001
+++ lilypond-1.5.7-new/AUTHORS.txt      Thu Aug 23 20:52:26 2001
@@ -27,6 +27,9 @@
 
    * Bjoern Jacke <address@hidden>     German glossary stuff.
 
+   * Chris Jackson <address@hidden> Directed
+     arpeggios and chord brackets
+
    * Neil Jerram <address@hidden>.      parts of
      Documentation/Vocab*
 
diff -urN lilypond-1.5.7/CHANGES lilypond-1.5.7-new/CHANGES
--- lilypond-1.5.7/CHANGES      Fri Aug 17 00:42:35 2001
+++ lilypond-1.5.7-new/CHANGES  Thu Aug 23 21:36:53 2001
@@ -1,3 +1,10 @@
+1.5.7
+=====
+
+* Arpeggios can now have arrows on the top or bottom to determine
+  their direction, and a chord can be bracketed to indicate no
+  arpeggio. (Chris Jackson)
+
 1.5.6.jcn2
 =========
  
diff -urN lilypond-1.5.7/Documentation/topdocs/AUTHORS.texi 
lilypond-1.5.7-new/Documentation/topdocs/AUTHORS.texi
--- lilypond-1.5.7/Documentation/topdocs/AUTHORS.texi   Thu May 17 10:34:59 2001
+++ lilypond-1.5.7-new/Documentation/topdocs/AUTHORS.texi       Thu Aug 23 
20:50:04 2001
@@ -33,6 +33,8 @@
     American chord names, gnu-windows testing
 @item @email{bjoern.jacke@@gmx.de, Bjoern Jacke}
     German glossary stuff.
address@hidden @email{chris-lilypond@@fluffhouse.org.uk, Chris Jackson}
+    Directed arpeggios and chord brackets.
 @item @email{nj104@@cus.cam.ac.uk, Neil Jerram}. 
     parts of Documentation/Vocab*
 @item Donald Ervin Knuth,  @uref{http://www-cs-staff.stanford.edu/~knuth/}
diff -urN lilypond-1.5.7/Documentation/user/refman.itely 
lilypond-1.5.7-new/Documentation/user/refman.itely
--- lilypond-1.5.7/Documentation/user/refman.itely      Tue Aug 14 12:29:40 2001
+++ lilypond-1.5.7-new/Documentation/user/refman.itely  Thu Aug 23 18:54:56 2001
@@ -1879,6 +1879,31 @@
 This command creates @code{Voice.Arpeggio} grobs.  Cross staff arpeggios
 are @code{PianoStaff.Arpeggio}.
 
+To add an arrow head to explicitly specify the direction of the
+arpeggio, you should set the arpeggio grob property
address@hidden
+
address@hidden,relative,verbatim]
+  \context Voice {
+     \property Voice.Arpeggio \override #'arpeggio-type = #'up
+     <c\arpeggio e g c>
+     \property Voice.Arpeggio \override #'arpeggio-type = #'down
+     <c\arpeggio e g c>
+  }
address@hidden lilypond
+
+A square bracket on the left indicates that the player should not
+arpeggiate the chord.
+
address@hidden,relative,verbatim]
+  \context PianoStaff <
+    \property PianoStaff.connectArpeggios = ##t
+    \property PianoStaff.Arpeggio \override #'arpeggio-type = #'bracket
+    \context Voice = one  { <c'\arpeggio e g c> }
+    \context Voice = other { \clef bass  <c,,\arpeggio e g>}
+  >  
address@hidden lilypond
+
 @refbugs
 
 It is not possible to mix connected arpeggios and unconnected arpeggios
diff -urN lilypond-1.5.7/input/regression/arpeggio.ly 
lilypond-1.5.7-new/input/regression/arpeggio.ly
--- lilypond-1.5.7/input/regression/arpeggio.ly Wed Apr  4 23:02:37 2001
+++ lilypond-1.5.7-new/input/regression/arpeggio.ly     Thu Aug 23 18:56:25 2001
@@ -2,23 +2,40 @@
 \header{
 texidoc="
 Arpeggios are supported, both cross-staff and broken single staff.
+Directed arpeggios are indicated by arrows, while a square bracket 
+to the left prevents arpeggiation. 
 "
 }
 
 
 
-\score{
-    \context PianoStaff < 
-        \context Staff=one \notes\relative c''{
-           \context Voice < fis,-\arpeggio  d a >
-            %%\property PianoStaff.SpanArpeggio \override #'connect = ##t
+\score {
+     \context PianoStaff < 
+        \context Staff=one \notes\relative c'{
+           \context Voice {
+            < a4 d fis-\arpeggio a >
+            \property Voice.Arpeggio \override #'arpeggio-type = #'bracket
+            < d fis-\arpeggio a d >
+     %%\property PianoStaff.SpanArpeggio \override #'connect = ##t
             \property PianoStaff.connectArpeggios = ##t
-            <fis,\arpeggio a c>
+            <b-\arpeggio d g b>
+            \property PianoStaff.Arpeggio \override #'arpeggio-type = #'bracket
+            <c-\arpeggio e g c>
+            \property PianoStaff.connectArpeggios = ##f
+            \property Voice.Arpeggio \override #'arpeggio-type = #'down
+            <a1-\arpeggio d fis a>
+
+           }
          }
-        \context Staff=two \notes\relative c{
+        \context Staff=two \notes\relative c {
             \clef bass
-           \context Voice < g b d-\arpeggio   >
-            <g\arpeggio b d>
-        }
+            \context Voice {
+            r4 r 
+            <d,\arpeggio a' d >
+            <d \arpeggio a' d >
+            \property Voice.Arpeggio \override #'arpeggio-type = #'up
+            <g1 \arpeggio b d g>
+           }
+         }
     >
 }
diff -urN lilypond-1.5.7/lily/arpeggio.cc lilypond-1.5.7-new/lily/arpeggio.cc
--- lilypond-1.5.7/lily/arpeggio.cc     Sun Mar 11 18:10:32 2001
+++ lilypond-1.5.7-new/lily/arpeggio.cc Thu Aug 23 19:06:31 2001
@@ -67,15 +67,40 @@
       return SCM_EOL;
     }
   
+  SCM s = me->get_grob_property ("arpeggio-type");
+  String arpegtype = ly_scm2string (scm_symbol_to_string (s));
+  Molecule arpegbottom = ( (arpegtype=="bracket") ? 
+                          Font_interface::get_default_font (me)->find_by_name 
("scripts-bracebottom") :
+                          ((arpegtype=="down") ? 
+                           Font_interface::get_default_font (me)->find_by_name 
("scripts-arrowdown") :
+                           Font_interface::get_default_font (me)->find_by_name 
("scripts-arpeggio"))
+                          );
+  Molecule arpegmiddle = ( (arpegtype=="bracket") ? 
+                          Font_interface::get_default_font (me)->find_by_name 
("scripts-braceseg") :
+                          Font_interface::get_default_font (me)->find_by_name 
("scripts-arpeggio") );
+  Molecule arpegtop = ( (arpegtype=="bracket") ? 
+                       Font_interface::get_default_font (me)->find_by_name 
("scripts-bracetop") :
+                       ((arpegtype=="up") ? 
+                        Font_interface::get_default_font (me)->find_by_name 
("scripts-arrowup") :
+                        Font_interface::get_default_font (me)->find_by_name 
("scripts-arpeggio"))
+                       );
+  
   Molecule mol;
-  Molecule arpeggio = Font_interface::get_default_font (me)->find_by_name 
("scripts-arpeggio");
-
   Real y = heads[LEFT];
-  while (y < heads[RIGHT])
+  
+  mol.add_at_edge (Y_AXIS, UP, arpegbottom, 0.0);
+  y+= arpegbottom. extent (Y_AXIS).length ();
+  
+  Grob * stem = unsmob_grob (gh_car ( me->get_grob_property ("stems") ));
+  Grob * ss = Staff_symbol_referencer::staff_symbol_l (stem);
+  
+  while (y < heads[RIGHT]  -  Staff_symbol::staff_space (ss))
     {
-      mol.add_at_edge (Y_AXIS, UP,arpeggio, 0.0);
-      y+= arpeggio. extent (Y_AXIS).length ();
+      mol.add_at_edge (Y_AXIS, UP, arpegmiddle, 0.0);
+      y+= arpegmiddle. extent (Y_AXIS).length ();
     }
+  mol.add_at_edge (Y_AXIS, UP, arpegtop, 0.0);
+  
   mol.translate_axis (heads[LEFT], Y_AXIS);
 
   return mol.smobbed_copy () ;
diff -urN lilypond-1.5.7/mf/feta-schrift.mf 
lilypond-1.5.7-new/mf/feta-schrift.mf
--- lilypond-1.5.7/mf/feta-schrift.mf   Tue Aug 14 12:32:15 2001
+++ lilypond-1.5.7-new/mf/feta-schrift.mf       Thu Aug 23 19:02:05 2001
@@ -766,6 +766,81 @@
        draw_arpeggio;
        fet_endchar;
 
+% Arrowhead nestles underneath / on top of the arpeggio symbol 
+
+def draw_arpeggio_arrow = 
+       save thinness, height, width, overshoot, se, sw, ne, nw, alpha;
+       pair ne, nw, se, sw;
+       height# = staff_space#;
+       width# = 0.8height#;
+        overshoot# = 0.25 staff_space#;
+       define_pixels (height,overshoot,width);
+       set_char_box(0, width#, 0, height#);
+       alpha := -40;
+       nw = dir (alpha+180);
+       sw = dir (alpha-90); se = dir alpha;      
+
+       penpos1(rthin,     alpha+90);
+       penpos2(5/4rthick, alpha);
+       penpos3(rthin,     alpha);
+
+       z1 = (width/2, height) - overshoot*se; % numbering is consistent with 
the arpeggio symbol
+       z2 = 2[z4,(width/2,height/2)];
+       z3 = (0.5 width, 0.5 height);
+       z4 = (0.25 staff_space, rthin);
+       z6 = z2l + 1/2rthin*sw;
+       z9 = (width/2, height) + overshoot*se;
+
+       z10 = (0.5w, -0.5h);
+       z11 = (0, 0);
+       z12 = (w, 0);
+       
+       fill z1l {se}..{se} z6 .. z3l .. z3r.. z9{nw} ..{nw} z1r.. cycle;
+
+       pickup pencircle scaled rthin;
+       draw z3 -- z10 -- z11;
+       draw z10 -- z12;
+      enddef;
+
+fet_beginchar("Arpeggio arrow down", "arrowdown", "arrowdown");
+       draw_arpeggio_arrow;
+fet_endchar;
+
+fet_beginchar("Arpeggio arrow up", "arrowup", "arrowup");
+       draw_arpeggio_arrow;
+       currentpicture := currentpicture scaled -1 shifted (0.8staff_space, 
staff_space);
+fet_endchar;
+
+
+def draw_chordbrace_end = 
+       save thinness;
+       set_char_box(0, staff_space#, 0, staff_space#);
+       pickup pencircle scaled stemthickness;
+       bot rt z1 = (w, -h);
+       bot lft z2 = (0, -h);
+       top lft z3 = (0, h);
+       draw z1 -- z2 -- z3;
+enddef;
+
+fet_beginchar("Bottom of chord brace", "bracebottom", "bracebottom");
+       draw_chordbrace_end;
+       labels (1, 2, 3);
+fet_endchar;
+
+fet_beginchar("Top of chord brace", "bracetop", "bracetop");
+       draw_chordbrace_end;
+       y_mirror_char;
+fet_endchar;
+
+%% Same as a note stem, but only a staff-space long. 
+fet_beginchar("chord brace segment (up)", "braceseg", "braceseg")
+       set_char_box(stemthickness#/2, stemthickness#/2, 0, staff_space#);
+       pickup pencircle scaled stemthickness;
+       bot lft z1 = (0, 0);
+       top lft z2 = (0, h);
+       draw z1 -- z2;
+fet_endchar;
+
 % Extendable Trill symbol.
 % Not yet used
 % Rename me to Trill, rename Trill to Tr?
diff -urN lilypond-1.5.7/scm/grob-description.scm 
lilypond-1.5.7-new/scm/grob-description.scm
--- lilypond-1.5.7/scm/grob-description.scm     Fri Aug 17 00:13:09 2001
+++ lilypond-1.5.7-new/scm/grob-description.scm Thu Aug 23 18:59:52 2001
@@ -28,6 +28,7 @@
               (X-offset-callbacks . (,Side_position_interface::aligned_side))
               (direction . -1)
               (staff-position . 0.0)
+              (arpeggio-type . plain)
               (meta . ,(grob-description "Arpeggio" arpeggio-interface 
side-position-interface font-interface))
               ))
 
diff -urN lilypond-1.5.7/scm/grob-property-description.scm 
lilypond-1.5.7-new/scm/grob-property-description.scm
--- lilypond-1.5.7/scm/grob-property-description.scm    Tue Aug 14 12:41:27 2001
+++ lilypond-1.5.7-new/scm/grob-property-description.scm        Thu Aug 23 
18:59:08 2001
@@ -41,6 +41,11 @@
 (grob-property-description 'arch-width number? "width of the hook of a system 
brace.")
 (grob-property-description 'arithmetic-basicspace number? "see 
@ref{spacing-spanner-interface}.")
 (grob-property-description 'arithmetic-multiplier number? "see 
@ref{spacing-spanner-interface}.")
+(grob-property-description 'arpeggio-type symbol? "Type of arpeggio. 
+up: a squiggly line with upward arrow, 
+down: a squiggly line with upward arrow, 
+bracket: a square bracket, 
+plain: a plain squiggly line (default)")
 (grob-property-description 'attachment pair? "cons of symbols, '(LEFT-TYPE . 
RIGHT-TYPE), where both types may be alongside-stem, stem, head or loose-end.")
 
 (grob-property-description 'stem-attachment-function procedure? "Where
diff -urN lilypond-1.5.7/scm/interface-description.scm 
lilypond-1.5.7-new/scm/interface-description.scm
--- lilypond-1.5.7/scm/interface-description.scm        Wed Jul 11 13:54:52 2001
+++ lilypond-1.5.7-new/scm/interface-description.scm    Thu Aug 23 18:57:58 2001
@@ -374,7 +374,10 @@
 (lily-interface
  'arpeggio-interface
  "Functions and settings for drawing an arpeggio symbol (a wavy line left to 
noteheads."
- '(stems))
+ '(
+   stems
+   arpeggio-type
+   ))



reply via email to

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