]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.1.16
authorfred <fred>
Tue, 26 Mar 2002 21:45:30 +0000 (21:45 +0000)
committerfred <fred>
Tue, 26 Mar 2002 21:45:30 +0000 (21:45 +0000)
init/property.ly
input/test/chord-inversion.ly [new file with mode: 0644]
input/test/sleur.ly
lily/chord-name-engraver.cc
lily/parser.yy
mutopia/W.A.Mozart/cadenza.ly

index 3d098081576a1eac9c4ab0c426c1c5cb22fb5cc3..0c8cbb637b7ac2afa03c13d4d280bb551cc7da26 100644 (file)
@@ -57,10 +57,12 @@ timeSignatureStyle  Cn/m    Set symbol explicitly, n/m=2/2 or 4/4
 timeSignatureStyle     oldn/m  Set symbol explicitly,
                                n/m=2/2,3/2,3/4,4/4,6/4 or 9/4.
 
-
 [Staff?]
 instrument             ascii   midi instrument table lookup
 
+[Score]
+chordInversion         0/1     Find and display chord with inversion?
+
 
 1) after beam slope damping table suggested in [Wanske]
 2) [Wanske] as well as [Ross] suggests that beams sloped upward must not 
diff --git a/input/test/chord-inversion.ly b/input/test/chord-inversion.ly
new file mode 100644 (file)
index 0000000..686463e
--- /dev/null
@@ -0,0 +1,19 @@
+\header{
+enteredby =     "jcn";
+copyright =     "public domain";
+TestedFeatures =        "chord inversions";
+}
+
+inversions = \notes\transpose c''\chords{
+       c1 c-sus c-6 c/e c/g c/d
+       % now try to find chords with inversions
+       \property Score.chordInversion = 1 
+       c1 c-sus c-6 c/e c/g c/d
+}
+
+\score{
+       <
+               \type ChordNames \inversions
+               \type Staff \inversions
+       >
+}
index 112d7cc2c9590296bf529516cd9ae75adee5e974..0f0490c502649c03dcbfe1fdcba5de00779eb3fc 100644 (file)
@@ -1,6 +1,6 @@
 \header{
 enteredby =     "jcn";
-copyright =     "PD";
+copyright =     "public domain";
 TestedFeatures =        "This file tests Feta embedded slurs" +
         "(Feta definitively is not an abbreviation of Font-En-TjA)";
 }
index 46bee3b37c45217ea2abed73665012416cd58905..b9d87032e1043ac32a3d62bd2ed1c73c58a1c605 100644 (file)
@@ -52,7 +52,6 @@ Chord_name_engraver::do_process_requests ()
    TODO:
      - move this stuff to new Item class Chord_name
      - switch on property, add american (?) chordNameStyle
-     - jazz inversions
 
   Scalar chordNameStyle = get_property ("chordNameStyle");
   if (chordNameStyle == "Banter")
@@ -69,6 +68,73 @@ Chord_name_engraver::do_process_requests ()
   if (alignment.isnum_b())
     text_p->align_dir_= (Direction)(int)alignment;
 
+
+  /*
+    find tonic: after longest line of triads
+   */
+
+  int tonic_i = 0;
+  Scalar chord_inversions = get_property ("chordInversion");
+  if (chord_inversions.to_bool ())
+    {
+      int longest_i = 0;
+      for (int i = 0; i < pitch_arr_.size (); i++)
+       for (int j = 0; j < pitch_arr_.size (); j++)
+         {
+           int gap = pitch_arr_[(i + j + 1) % pitch_arr_.size ()].notename_i_
+             - pitch_arr_[(i + j) % pitch_arr_.size ()].notename_i_;
+           while (gap < 0)
+             gap += 7;
+           gap %= 7;
+           if (gap != 2)
+             {
+               if (j > longest_i)
+                 {
+                   longest_i = j;
+                   tonic_i = i;
+                 }
+               break;
+             }
+         }
+
+      int biggest_i = 0;
+      if (!longest_i)
+       for (int i = 0; i < pitch_arr_.size (); i++)
+         {
+           int gap = pitch_arr_[i].notename_i_
+             - pitch_arr_[(i - 1 + pitch_arr_.size ()) 
+             % pitch_arr_.size ()].notename_i_;
+           while (gap < 0)
+             gap += 7;
+           gap %= 7;
+           if (gap > biggest_i)
+             {
+               biggest_i = gap;
+               tonic_i = i;
+             }
+         }
+    }
+
+  Musical_pitch inversion = pitch_arr_[0];
+  if (tonic_i)
+    {
+      Musical_pitch last (0, 0, -5);
+      Array<Musical_pitch> pitches;
+      for (int i = 0; i < pitch_arr_.size (); i++)
+       {
+         Musical_pitch p = pitch_arr_[(tonic_i + i) % pitch_arr_.size ()];
+         if (p < last)
+           {
+             p.octave_i_ = last.octave_i_;
+             if (p < last)
+               p.octave_i_++;
+           }
+         pitches.push (p);
+         last = p;
+       }
+      pitch_arr_ = pitches;
+    }
+
   Musical_pitch tonic = pitch_arr_[0];
 
   Array<Musical_pitch> scale;
@@ -81,6 +147,7 @@ Chord_name_engraver::do_process_requests ()
   // 7 always means 7-...
   scale.push (Musical_pitch (6, -1)); // b
 
+
   for (int i = 0; i < scale.size (); i++)
     scale[i].transpose (tonic);
 
@@ -115,7 +182,15 @@ Chord_name_engraver::do_process_requests ()
        }
     }
 
-  text_p->text_str_ = tonic_str + "$^{" + add_str + "}$";
+  String inversion_str;
+  if (tonic_i)
+    {
+      inversion_str = inversion.str ();
+      inversion_str = "/" + inversion_str.left_str (1).upper_str ()
+       + acc[tonic.accidental_i_ + 2];
+
+    }
+  text_p->text_str_ = tonic_str + "$^{" + add_str + "}$" + inversion_str;
   Text_item* item_p =  new Text_item (text_p);
   item_p->dir_ = DOWN;
   item_p->fat_b_ = true;
index d41a1e499d2bdddfd0c2e3e9b17fea6bb29fae5e..319fddd88d35e18964ea0868ef6c7120dc77a8ff 100644 (file)
@@ -251,7 +251,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <pitch_arr>      pitch_list
 %type <music>  chord notemode_chord
 %type <pitch_arr>      chord_additions chord_subtractions
-%type <pitch>  chord_addsub chord_note
+%type <pitch>  chord_addsub chord_note chord_inversion notemode_chord_inversion
 %type <midi>   midi_block midi_body
 %type <duration>       duration_length
 
@@ -523,7 +523,6 @@ translator_spec_body:
 */
 score_block:
        SCORE { THIS->remember_spot ();
-               THIS->error_level_i_ =0;
        }
        /*cont*/ '{' score_body '}'     {
                $$ = $4;
@@ -531,9 +530,6 @@ score_block:
                if (!$$->def_p_arr_.size ())
                        $$->add_output (THIS->default_paper_p ());
 
-               /* handle error levels. */
-               $$->errorlevel_i_ = THIS->error_level_i_;
-               THIS->error_level_i_ = 0;
        }
        ;
 
@@ -1407,13 +1403,13 @@ simple_element:
        ;
 
 chord:
-       steno_tonic_pitch notemode_duration chord_additions chord_subtractions {
-                $$ = THIS->get_chord (*$1, $3, $4, *$2);
+       steno_tonic_pitch notemode_duration chord_additions chord_subtractions chord_inversion {
+                $$ = THIS->get_chord (*$1, $3, $4, $5, *$2);
         };
 
 notemode_chord:
-       steno_musical_pitch notemode_duration chord_additions chord_subtractions {
-                $$ = THIS->get_chord (*$1, $3, $4, *$2);
+       steno_musical_pitch notemode_duration chord_additions chord_subtractions notemode_chord_inversion {
+                $$ = THIS->get_chord (*$1, $3, $4, $5, *$2);
         };
 
 chord_additions: 
@@ -1434,6 +1430,24 @@ chord_addsub:
        | CHORDMODIFIER_PITCH optional_dot
        ;
 
+chord_inversion:
+       {
+               $$ = 0;
+       }
+       | '/' steno_tonic_pitch {
+               $$ = $2
+       }
+       ;
+
+notemode_chord_inversion:
+       {
+               $$ = 0;
+       }
+       | '/' steno_musical_pitch {
+               $$ = $2
+       }
+       ;
+
 chord_note:
        UNSIGNED {
                $$ = new Musical_pitch;
index 1d521bc14cb9d798d17592e0747179c32213118f..6f32f626cde784dd44890ea36220464badf18f03 100644 (file)
@@ -44,7 +44,7 @@ cad = \notes  \relative c' {
 
        r8 a [b cis]
        [d16 cis d e]
-       f4() [f16 e d c]
+       f4( [  )f16 e d c]
        b4-\turn
        \times 2/3 { [ d8 c8 a8] }
        g2