]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/lyric-phrasing-engraver.hh
release: 1.3.76
[lilypond.git] / lily / include / lyric-phrasing-engraver.hh
1 /*
2   lyric-phrasing-engraver.hh -- declare Lyric_phrasing_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  2000 Glen Prideaux <glenprideaux@iname.com>
7 */
8
9
10 #ifndef LYRIC_PHRASING_ENGRAVER_HH
11 #define LYRIC_PHRASING_ENGRAVER_HH
12
13 #include "lily-proto.hh"
14 #include "engraver.hh"
15 #include "item.hh"
16 #include "smobs.hh"
17
18 class Voice_alist_entry;
19
20
21 /**
22    Align lyrics with noteheads, left aligning beginning of phrases,
23    right aligning end of phrases, centering others under their notes.
24  */
25
26
27 /* 
28 * Build an engraver that catches noteheads and lyrics.
29
30 (It needs to be in a context above Staff and Lyrics, eg. in Score
31 context.)
32
33 * Determine which heads belong to which lyrics
34
35 (eg. by looking at the names of their originating contexts, or maybe
36 some \properties)
37
38 * Attach the lyrics to the appropriate heads
39
40 (by doing lyric->set_parent (head, X_AXIS), that will fix the current
41 noteheadwidth guessing kludge)
42
43 * Check if the lyric syllables end or start a phrase.
44
45 (eg. check if the syllable ends with punctuation, and remember that
46 fact for the next one.)
47
48 * Adjust their alignment accordingly. 
49
50 (eg. by doing lyric->add_offset_callback(centered_on_parent,X_AXIS)
51 and setting self-alignment-X)
52
53 * Add a property to switch on/off the engraver (for multi stanza
54   vs. single stanza music)
55
56 Maybe this engraver could also take care of correct lyric alignment
57 for melismas as well.
58
59
60  */
61
62
63 class Lyric_phrasing_engraver : public Engraver 
64 {
65 protected:
66   virtual void acknowledge_element(Score_element_info);
67   virtual void process_acknowledged ();
68   virtual void do_pre_move_processing();
69   
70 private:
71   void record_notehead(const String &context_id, Score_element * notehead);
72   void record_lyric(const String &context_id, Score_element * lyric);
73   void record_melisma(const String &context_id);
74   Voice_alist_entry * lookup_context_id(const String &context_id);
75
76 public:
77   Lyric_phrasing_engraver ();
78   ~Lyric_phrasing_engraver ();
79   VIRTUAL_COPY_CONS (Translator);
80
81 private:
82   /** association list of Voice_alist_entry smobs
83   */
84   Protected_scm voice_alist_;
85   Score_element * any_notehead_l_;
86 };
87
88
89 class Voice_alist_entry
90 {
91   bool first_in_phrase_b_;
92   Score_element * notehead_l_;
93   Link_array<Score_element> lyric_list_;
94   Score_element * longest_lyric_l_;
95   Score_element * shortest_lyric_l_;
96   int alignment_i_;
97   bool melisma_b_;
98 public:
99   static SCM make_entry();
100   void set_first_in_phrase(bool f);
101   void set_notehead(Score_element * notehead);
102   void add_lyric(Score_element * lyric);
103   void set_melisma();
104   bool get_melisma() { return melisma_b_; }
105   int lyric_count() { return lyric_list_.size(); }
106   void clear();
107   bool is_empty();
108   bool set_lyric_align(const char *punc, Score_element *default_notehead_l);
109   void adjust_melisma_align();
110   int appropriate_alignment(const char *punc);
111   Real amount_to_translate();
112   void next_lyric();
113   void copy(Voice_alist_entry *);
114 private:
115   Voice_alist_entry();
116   DECLARE_SIMPLE_SMOBS(Voice_alist_entry,);
117 } ;
118
119 Voice_alist_entry * unsmob_voice_entry (SCM);
120
121
122 #endif // LYRIC_PHRASING_ENGRAVER_HH