* scm/lily.scm (print): add function.
* scm/music-functions.scm (quote-substitute): new
function. Substitute \quote when putting music into \score.
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.
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=3
-PATCH_LEVEL=13
+PATCH_LEVEL=14
MY_PATCH_LEVEL=
--- /dev/null
+
+\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
+>>
}
\version "2.3.4"
-
+\paper {
+ raggedright = ##t
+}
\addquote bla \relative c' {
fis4 g a b }
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))),
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));
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 */
{
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*);
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));
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;
}
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 ());
}
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 ();
}
| 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;
$$ = 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 (); }
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_);
}
#include <stdio.h>
+#include "lily-parser.hh"
#include "book.hh"
-
#include "cpu-timer.hh"
#include "global-context.hh"
#include "ly-module.hh"
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_;
+}
"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
(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)))
(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!)
;;
(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
))