]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/quote-cyclic.ly (Module): new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Sep 2004 12:17:01 +0000 (12:17 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Sep 2004 12:17:01 +0000 (12:17 +0000)
* scm/lily.scm (print): add function.

* scm/music-functions.scm (quote-substitute): new
function. Substitute \quote when putting music into \score.

16 files changed:
ChangeLog
VERSION
input/regression/quote-cyclic.ly [new file with mode: 0644]
input/regression/quote.ly
lily/accidental.cc
lily/include/lily-guile.hh
lily/include/music.hh
lily/include/score.hh
lily/lily-parser.cc
lily/music.cc
lily/parser.yy
lily/quote-iterator.cc
lily/score.cc
scm/define-music-properties.scm
scm/lily.scm
scm/music-functions.scm

index 69102fd611350e73978fade16ef3222de2ecaf9a..d6b14869ae01793ff80092081ffdceb7f73c4bd9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-09-05  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * input/regression/quote-cyclic.ly (Module): new file.
+
+       * scm/lily.scm (print): add function.
+
+       * scm/music-functions.scm (quote-substitute): new
+       function. Substitute \quote when putting music into \score.
+
        * input/regression/key-signature-cancellation.ly (Module): new file.
 
        * lily/*.cc: more ly_scm2 -> scm_to converions.
diff --git a/VERSION b/VERSION
index d30d78ded793eb110780a08670bfe8afbc9f0b21..74a9994771dcabc43cd65464bad382e889f2484d 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=3
-PATCH_LEVEL=13
+PATCH_LEVEL=14
 MY_PATCH_LEVEL=
 
diff --git a/input/regression/quote-cyclic.ly b/input/regression/quote-cyclic.ly
new file mode 100644 (file)
index 0000000..2792ad5
--- /dev/null
@@ -0,0 +1,23 @@
+
+\header {
+
+    texidoc = "Two quoted voices may refer to each other. In this
+example, there are notes with each full-bar rest."
+         
+}
+
+A = \relative c' { c4 d e f | << R1            \\
+                                \quote "qB" 1 >> | }
+B = \relative c' { << R1            \\
+                     \quote "qA" 1 >> | f4 e d c | }
+
+\addquote "qA" \A
+\addquote "qB" \B
+
+\paper { raggedright = ##t }
+
+<<
+    \context Staff = "A" \A
+    \context Staff = "B" \B
+>>
index 6f175b4eb5efe5821d670cc3de84d3daeaf574b6..12c1e0cba54912da3b770c6600d22c8bd2cb89fc 100644 (file)
@@ -6,7 +6,9 @@ music may be quoted. "
 
 }
 \version "2.3.4"
-
+\paper {
+    raggedright = ##t
+}
 \addquote bla \relative c' {
     fis4 g a b }
 
index 2844973503097b77f92a0bc812d5c0ad4a627f96..8e00df9b66bd990ba64db93640f2cd8e4b4ee0e0 100644 (file)
@@ -196,6 +196,9 @@ Accidental_interface::print (SCM smob)
   if (smaller)
     {
       SCM ac = Font_interface::music_font_alist_chain (me);
+      /*
+       TODO: should calc font-size by adding -2 to current font-size
+      */
       ac = scm_cons (scm_list_1 (scm_cons
                                 (ly_symbol2scm ("font-size"),
                                  scm_int2num (-2))),
index c8185778f7984e436ed12226b2a9803c12acfed9..9a7ff0129ca51c357256fdeeff7ba5d47f60f94f 100644 (file)
@@ -33,7 +33,7 @@ inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
 inline bool ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
 #define scm_is_symbol(x) ly_c_symbol_p(x)
 inline bool ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
-#define scm_is_bool(x) ly_c_boolean_p(
+#define scm_is_bool(x) ly_c_boolean_p(x)
 inline bool ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
 #define scm_is_eq(x,y)  (SCM_EQ_P (x, y));
 
index 0b27e8c2c45bfad2a1d0a693c8bf148046a3cf0e..a28786ba6681f52466ee2c4659743f491f404409 100644 (file)
@@ -71,6 +71,6 @@ DECLARE_UNSMOB(Music,music);
 
 Music* make_music_by_name (SCM sym);
 SCM ly_deep_mus_copy (SCM);
-SCM ly_music_scorify (SCM);
+SCM ly_music_scorify (SCM, SCM);
 
 #endif /* MUSIC_HH */
index 0f015a0139fbba775cc9b5ee863869b8817b9cc7..31a2e1483dee932b08cb7af0485aa63a130eb650 100644 (file)
@@ -20,11 +20,13 @@ class Score : public Input
 {
   DECLARE_SMOBS (Score, foo);
 
+  SCM music_;
 public:
   Link_array<Output_def> defs_;
-  SCM music_;
   SCM header_;
-    
+
+  SCM get_music () const;
+  void set_music (SCM music, SCM parser);
   Score ();
   Score (Score const&);
   SCM book_rendering (String, Output_def*, Output_def*);
index 9d46014696a4e0b23afa44e70890d841eee6c439..8ad9b9c47e4224e9b6aac15e4ca2fc4565230ba0 100644 (file)
@@ -118,10 +118,6 @@ Lily_parser::parse_file (String init, String name, String out_name)
 void
 Lily_parser::parse_string (String ly_code)
 {
-#if 0
-  SCM parent_prot = lexer_ ? lexer_->self_scm () : SCM_EOL;
-#endif
-
   Lily_lexer * parent = lexer_;
   lexer_ = (parent == 0 ? new Lily_lexer (sources_)
            : new Lily_lexer (*parent));
@@ -150,24 +146,6 @@ Lily_parser::parse_string (String ly_code)
 
   error_level_ = error_level_ | lexer_->error_level_;
 
-#if 0
-  if (Lily_lexer::unsmob (parent_prot))
-    {
-      /*
-       what the fuck is this good for?
-       */
-      parent->encoding_ = lexer_->encoding_;
-      parent->chordmodifier_tab_ = lexer_->chordmodifier_tab_;
-      parent->pitchname_tab_stack_ = lexer_->pitchname_tab_stack_;
-      parent->sources_ = lexer_->sources_;
-      parent->scopes_ = lexer_->scopes_;
-      parent->error_level_ = lexer_->error_level_; 
-      parent->main_input_b_ = lexer_->main_input_b_;
-    }
-  
-  scm_remember_upto_here_1 (parent_prot);
-#endif
-  
   scm_set_current_module (oldmod);
   lexer_ = 0;
 }
@@ -456,14 +434,14 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
   SCM os = scm_makfrom0str (outname.to_string ().to_str0 ());
   SCM bookpaper = get_bookpaper (parser)->self_scm ();
   for (int i = 0; i < score->defs_.size (); i++)
-    default_rendering (score->music_, score->defs_[i]->self_scm (),
+    default_rendering (score->get_music (), score->defs_[i]->self_scm (),
                       bookpaper,
                       header, os);
 
   if (score->defs_.is_empty ())
     {
       Output_def *paper = get_paper (parser);
-      default_rendering (score->music_, paper->self_scm (),
+      default_rendering (score->get_music(), paper->self_scm (),
                         get_bookpaper (parser)->self_scm (),
                         header, os);
       scm_gc_unprotect_object (paper->self_scm ());
index 7ed8aacc9065cef914ad08ea295af01f31932f1f..a729802b6c0ce563f19eb2c497682ba9c981482e 100644 (file)
@@ -379,21 +379,17 @@ LY_DEFINE (ly_music_compress, "ly:music-compress",
 }
 
 LY_DEFINE (ly_music_scorify, "ly:music-scorify",
-          1, 0, 0,
-          (SCM music),
+          2, 0, 0,
+          (SCM music, SCM parser),
           "Return MUSIC encapsulated in SCORE.")
 {
 #if 0
   SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
 #endif
   Score *score = new Score;
-  
-  /* URG? */
-  SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
-  for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
-    music = scm_call_1 (ly_car (check_funcs), music);
-  
-  score->music_ = music;
+
+  score->set_music (music, parser);
+
   scm_gc_unprotect_object (score->self_scm ());
   return score->self_scm ();
 }
index 2dedb25e29363c9b8a67242a07c86de93b7c73dc..b77a0f7b73d24777c3967d7e959d2f00c0e32493 100644 (file)
@@ -680,19 +680,7 @@ score_body:
        | score_body Music {
                SCM m = $2->self_scm ();
                scm_gc_unprotect_object (m);
-       
-               /*
-                       guh.
-               */
-               SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
-               for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
-                       m = scm_call_1 (ly_car (check_funcs), m);
-               if (unsmob_music ($$->music_))
-               {
-                       THIS->parser_error (_("Already have music in score"));
-                       unsmob_music ($$->music_)->origin ()->error (_("This is the previous music"));
-               }
-               $$->music_ = m;
+               $$->set_music (m, THIS->self_scm ());
        }
        | score_body lilypond_header    {
                $$->header_ = $2;
@@ -1527,24 +1515,11 @@ command_element:
                $$ = skip;
        }
        | QUOTE STRING duration_length {
-               SCM tab = THIS->lexer_->lookup_identifier ("musicQuotes");
-               SCM evs = SCM_EOL;
-               if (scm_hash_table_p (tab) == SCM_BOOL_T)
-               {
-                       SCM key = $2; // use symbol?
-                       evs = scm_hash_ref (tab, key, SCM_BOOL_F);
-               }
-               Music *quote = 0;
-               if (ly_c_vector_p (evs))
-               {
-                       quote = MY_MAKE_MUSIC ("QuoteMusic");
-                       quote->set_property ("duration", $3);
-                       quote->set_property ("quoted-events", evs);
-               } else {
-                       THIS->here_input ().warning (_f ("Can\'t find music"));
-                       quote = MY_MAKE_MUSIC ("Event");
-               }
+               Music *quote = MY_MAKE_MUSIC ("QuoteMusic");
+               quote->set_property ("duration", $3);
+               quote->set_property ("quoted-music-name", $2);
                quote->set_spot (THIS->here_input ());
+
                $$ = quote;
        }
        | OCTAVE { THIS->push_spot (); }
index 158f271e909f2ee49ccdb3a72aa0ca5d875e61b2..307b860dc9674b504d4b9725bab4ee061b5bf39b 100644 (file)
@@ -103,13 +103,17 @@ Quote_iterator::construct_children ()
       event_idx_ = binsearch_scm_vector (event_vector_, now.smobbed_copy (), &moment_less);
       end_idx_ = binsearch_scm_vector (event_vector_, stop.smobbed_copy (), &moment_less);
     }
+  else
+    {
+      get_music ()->origin()->warning (_("No events found for \\quote"));
+    }
 }
 
 
 bool
 Quote_iterator::ok () const
 {
-  return (event_idx_ <= end_idx_);
+  return ly_c_vector_p (event_vector_) && (event_idx_ <= end_idx_);
 }
 
 
index 2dadb3f7f4eaf11b19c15b1888a345be4a0c4afa..ecdddb64a8d87851039f0e32c235bc52f5ba0c2f 100644 (file)
@@ -8,8 +8,8 @@
 
 #include <stdio.h>
 
+#include "lily-parser.hh"
 #include "book.hh"
-
 #include "cpu-timer.hh"
 #include "global-context.hh"
 #include "ly-module.hh"
@@ -292,9 +292,32 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
      itself. */
   score_def->parent_ = od;
   
-  SCM context = ly_run_translator (sc->music_, score_def->self_scm ());
+  SCM context = ly_run_translator (sc->get_music (), score_def->self_scm ());
   SCM lines = ly_format_output (context, scm_makfrom0str ("<embedded>"));
   
   scm_remember_upto_here_1 (prot);
   return lines;
 }
+
+void
+Score::set_music (SCM music, SCM parser)
+{
+  /* URG? */
+  SCM check_funcs = ly_scheme_function ("toplevel-music-functions");
+  for (; ly_c_pair_p (check_funcs); check_funcs = ly_cdr (check_funcs))
+    music = scm_call_2 (ly_car (check_funcs), music, parser);
+
+  if (unsmob_music (music_))
+    {
+      unsmob_music (music)->origin ()->error (_("Already have music in score"));
+      unsmob_music (music_)->origin ()->error (_("This is the previous music"));
+    }
+       
+  this->music_ = music;
+}
+
+SCM
+Score::get_music () const
+{
+  return music_;
+}
index 86f3f5cefc92c3391a09890d4b78e4cf72d79889..66977251db7fde7d0da8651e2faa587ef29ef25b 100644 (file)
@@ -84,6 +84,7 @@ For chord inversions, this is negative.")
                          "Do these operations for instantiating the context.")
      (predicate ,procedure? "the predicate of a \\outputproperty.")
      (quoted-events ,vector? "A vector of with moment/event-list entries.")
+     (quoted-music-name ,string? "The name of the voice to quote.")
      (type ,symbol? "The type of this music object. Determines iteration in some cases.")
      (types ,list? "The types of this music
 object; determines by what engraver this music expression is
index 8c680eeda9afa341b7f9811c6dd1c5a9274f6a6a..9e47a9208f882e2c94da2a7e3ce93c10afd000dd 100644 (file)
             (srfi srfi-1)  ; lists
             (srfi srfi-13)) ; strings
 
+; my display
+
 (define-public (myd k v) (display k) (display ": ") (display v) (display ", "))
 
+(define-public (print . args)
+  (apply format (cons (current-output-port) args)))
+  
+
 ;;; General settings
 ;;; debugging evaluator is slower.  This should
 ;;; have a more sensible default.
     ))
 
 (define-public (collect-music-for-book parser music)
-  (collect-scores-for-book parser (ly:music-scorify music)))
+  (collect-scores-for-book parser (ly:music-scorify music parser)))
 
 
   
index 62832f29c3547a3f999cc3a1fde085e131ab1802..96f53bb28580f6c82f8969d7939e2b3cba56a8fa 100644 (file)
@@ -601,6 +601,26 @@ Syntax:
                           (lambda (,@args)
                             ,@body)))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-public ((quote-substitute quote-tab) music)
+  (let*
+      ((quoted-name (ly:music-property music 'quoted-music-name))
+       (quoted-vector (if (string? quoted-name)
+                         (hash-ref quote-tab quoted-name #f)
+                         #f
+                         ))
+
+       )
+    (if (string? quoted-name)
+       (if  (vector? quoted-vector)
+            (set! (ly:music-property music 'quoted-events) quoted-vector)
+            (ly:warn "Cannot find quoted music `~S'" quoted-name)))
+
+    music))
+    
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; switch it on here, so parsing and init isn't checked (too slow!)
 ;;
@@ -614,8 +634,11 @@ Syntax:
 (define-public toplevel-music-functions
   (list
    ;; check-start-chords ; ; no longer needed with chord syntax. 
-   voicify-music
-   (lambda (x) (music-map glue-mm-rest-texts x))
+   (lambda (music parser) (voicify-music music))
+   (lambda (x parser) (music-map glue-mm-rest-texts x))
+   (lambda (music parser)
+
+     (music-map (quote-substitute (ly:parser-lookup parser 'musicQuotes))  music))
    ;; switch-on-debugging
    ))