]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/music.cc (var): add ly:music-transpose function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 21 Aug 2003 17:25:09 +0000 (17:25 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 21 Aug 2003 17:25:09 +0000 (17:25 +0000)
* Lily/parser.yy (pre_events): remove prefix articulations.

* lily/music-sequence.cc (do_relative_octave): change relative meaning.

ChangeLog
lily/music-sequence.cc
lily/music.cc
lily/parser.yy

index 81b3ba5b3b179cccd45f27ace023798067b5068c..e28a6f553b5f842a197c7d4d2afa11daf2fae33b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2003-08-21  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * lily/music.cc (var): add ly:music-transpose function.
+
+       * Lily/parser.yy (pre_events): remove prefix articulations.
+
+       * lily/music-sequence.cc (do_relative_octave): change relative meaning.
+
        * VERSION (MY_PATCH_LEVEL): open HEAD/1.9 branch.
 
        * Documentation/user/refman.itely (Text markup): add comment about
index 1c8e0a235299b297237ac0dc58381e778eacaeef..1d967a3dde51731c1480fe88e7d64418c80d2b3e 100644 (file)
@@ -9,7 +9,7 @@
 #include "music-list.hh"
 #include "warn.hh"
 #include "pitch.hh"
-
+#include "input.hh"
 
 SCM
 Music_sequence::music_list ()const
@@ -94,7 +94,7 @@ Music_sequence::maximum_length (SCM l)
 Pitch
 Music_sequence::do_relative_octave (Pitch p, bool ret_first)
 {
-  Pitch retval;
+  Pitch first;
   int count=0;
 
   Pitch last = p;
@@ -109,14 +109,19 @@ Music_sequence::do_relative_octave (Pitch p, bool ret_first)
        {
          last = m->to_relative_octave (last);
          if (!count ++)
-           retval = last;
+           first = last;
        }
     }
 
-  if (!ret_first)
-    retval = last;
-  
-  return retval;
+  if (ret_first && first != last)
+    {
+      String str = _("Changing relative definition causes pitch change.");
+      str += "\nWas: " +  first.to_string ()
+       + "Will be: " + last.to_string () + "\n";
+      
+      origin()->warning (str);
+    }
+  return last;
 }
 
 void
index 1866be33f4bfcfb054936bdd9d08b3afa4d4a34c..941ff2c67cc822e5c2cfc73ac9aba312dea7aae9 100644 (file)
 #include "ly-smobs.icc"
 
 
-LY_DEFINE(ly_deep_mus_copy,
-         "ly:music-deep-copy", 1,0,0, (SCM m),
-         "Copy @var{m} and all sub expressions of @var{m}")
-{
-  if (unsmob_music (m))
-    {
-      SCM ss =  unsmob_music (m)->clone ()->self_scm ();
-      scm_gc_unprotect_object (ss);
-      return ss;
-    }
-  else if (gh_pair_p (m))
-    {
-      return gh_cons (ly_deep_mus_copy (ly_car (m)), ly_deep_mus_copy (ly_cdr (m)));
-    }
-  else
-    return m;
-}
+SCM ly_deep_mus_copy (SCM);
 
 bool
 Music::internal_is_music_type (SCM k)const
@@ -338,6 +322,40 @@ LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0,
 ADD_MUSIC(Music);
 
 
+
+LY_DEFINE(ly_deep_mus_copy,
+         "ly:music-deep-copy", 1,0,0, (SCM m),
+         "Copy @var{m} and all sub expressions of @var{m}")
+{
+  if (unsmob_music (m))
+    {
+      SCM ss =  unsmob_music (m)->clone ()->self_scm ();
+      scm_gc_unprotect_object (ss);
+      return ss;
+    }
+  else if (gh_pair_p (m))
+    {
+      return gh_cons (ly_deep_mus_copy (ly_car (m)), ly_deep_mus_copy (ly_cdr (m)));
+    }
+  else
+    return m;
+}
+
+LY_DEFINE(ly_music_transpose,
+         "ly:music-transpose", 2,0,0, (SCM m, SCM p),
+         "Transpose @var{m} such that central C is mapped to @var{p}. "
+"Return @var{m}.")
+{
+  Music * sc = unsmob_music (m);
+  Pitch * sp = unsmob_pitch (p);
+  SCM_ASSERT_TYPE(sc, m, SCM_ARG1, __FUNCTION__, "music");
+  SCM_ASSERT_TYPE(sp, p, SCM_ARG2, __FUNCTION__, "pitch");
+
+  sc->transpose (*sp);
+  return sc->self_scm();       // SCM_UNDEFINED ? 
+}
+
+
 SCM make_music_proc;
 
 
index adfef0e213a6e785937dac96fb967ff097fd2dad..4fa67c105c3006a143b902baf3554410a193ee6e 100644 (file)
@@ -342,7 +342,7 @@ yylex (YYSTYPE *s,  void * v)
 %type <scm> steno_duration optional_notemode_duration multiplied_duration
 %type <scm>  verbose_duration
        
-%type <scm>  pre_events post_events
+%type <scm>   post_events
 %type <music> gen_text_def
 %type <scm>   steno_pitch pitch absolute_pitch pitch_also_in_chords
 %type <scm>   explicit_pitch steno_tonic_pitch
@@ -1226,17 +1226,36 @@ scalar:
         ;
 
 
+
+/*
+This is a trick:
+
+Adding pre_events to the simple_element
+makes the choice between
+
+  string:  STRING
+
+and
+
+  simple_element: STRING
+
+a single shift/reduction conflict.
+
+nevertheless, this is not very clean, and we should find a different
+solution.  
+
+*/
+pre_events:
+       ;
+
 event_chord:
-       pre_events {
-               THIS->push_spot ();
-       } /*cont */ simple_element post_events  {
-               SCM elts = $3-> get_mus_property ("elements");
+       pre_events simple_element post_events   {
+               SCM elts = $2-> get_mus_property ("elements");
 
-               elts = gh_append3 (elts, scm_reverse_x ($1, SCM_EOL),
-                                  scm_reverse_x ($4, SCM_EOL));
+               elts = gh_append2 (elts, scm_reverse_x ($3, SCM_EOL));
 
-               $3-> set_mus_property ("elements", elts);
-               $$ = $3;
+               $2->set_mus_property ("elements", elts);
+               $$ = $2;
        }
        | command_element
        | note_chord_element
@@ -1752,22 +1771,6 @@ script_dir:
        | '-'   { $$ = CENTER; }
        ;
 
-pre_events:
-       /* empty */ { 
-               $$ = SCM_EOL;
-       }
-       | pre_events open_event {
-               static int warn_count ;
-               if (warn_count < 10)
-                       {
-                       $2->origin ()->warning (_("Prefix articulations are deprecated. Use postfix notation instead."));
-                       warn_count ++;
-                       }
-
-               $$ = gh_cons ($2->self_scm(), $$);
-               scm_gc_unprotect_object ($2->self_scm());
-       }
-       ;
 
 absolute_pitch:
        steno_pitch     {