-pl 45 (may 28)
+pl 45.hwn1
+ - Audio broadcast & acknowledge.
+ - more advanced spacing for prefatory matter
+ - tuplet appearance tweaking
+
+
+pl 45.uu1
+ - glossary fixes (thanks Dirk).
+
+pl 44.jcn2
+ - bf: auto-beamer: long standing br form AM
+
+*********
+
+pl 45 (may 28)
+ - reinstalled Thread (there you are, John)
- german vocab.
void
Align_element::do_side_processing ()
{
- sort_elements ();
Array<Interval> dims;
Link_array<Score_element> elems;
{
extra_dims = SCM_CDR (extra_dims);
dims.top ()[LEFT] -= gh_scm2double (SCM_CAR (extra_dims));
- dims.top ()[RIGHT] += gh_scm2double (SCM_CAR (extra_dims));
+ dims.top ()[RIGHT] += gh_scm2double (SCM_CDR (extra_dims));
}
elems.push (e);
--- /dev/null
+/*
+ Audio-element-info.cc -- implement Audio_element_info
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "audio-element-info.hh"
+#include "request.hh"
+
+Audio_element_info::Audio_element_info (Audio_element*s_l, Music *r_l)
+{
+ elem_l_ = s_l;
+ req_l_ = r_l;
+}
+
+
+Audio_element_info::Audio_element_info()
+{
+ elem_l_ = 0;
+ req_l_ = 0;
+}
+
+
+
void
Bar_script_engraver::acknowledge_element (Score_element_info inf)
{
- if (inf.origin_grav_l_arr_.size () == 1)
+ if (inf.origin_trans_l_arr_.size () == 1)
{
Item *i=cast_to_interesting_item (inf.elem_l_);
if (!i)
/* Only put numbers on bars that are at our own level (don't put
numbers over the staffs of a GrandStaff, only over the GrandStaff
itself */
- if (inf.origin_grav_l_arr_.size () != 1)
+ if (inf.origin_trans_l_arr_.size () != 1)
return;
do_acknowledge_element (i);
void
Base_span_bar_engraver::acknowledge_element (Score_element_info i)
{
- int depth = i.origin_grav_l_arr_.size();
+ int depth = i.origin_trans_l_arr_.size();
if (depth > 1
&& dynamic_cast<Bar *> (i.elem_l_))
{
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "lily-guile.hh"
#include "break-align-item.hh"
#include "dimensions.hh"
#include "p-score.hh"
+#include "paper-def.hh"
void
Break_align_item::do_pre_processing()
{
align_dir_ = break_status_dir();
flip (&align_dir_);
+ sort_elements ();
+
+
+ Link_array<Score_element> elems;
+ for (int i=0; i < elem_l_arr_.size(); i++)
+ {
+ Interval y = elem_l_arr_[i]->extent(axis ());
+ if (!y.empty_b())
+ elems.push (dynamic_cast<Score_element*> (elem_l_arr_[i]));
+ }
+
+
+ if (elems.size ())
+ {
+ Score_element *current_elt =elems[0];
+ SCM current_origin = current_elt->get_elt_property (origin_scm_sym);
+
+ if (current_origin != SCM_BOOL_F)
+ current_origin = SCM_CDR (current_origin);
+
+ for (int i=1; i < elems.size (); i++)
+ {
+ Score_element *next_elt = elems[i];
+ SCM next_origin = next_elt->get_elt_property (origin_scm_sym);
+ if (next_origin != SCM_BOOL_F)
+ {
+ next_origin = SCM_CDR(next_origin);
+ SCM extra_space = scm_eval (scm_listify (ly_symbol ("break-align-spacer"),
+ current_origin,
+ next_origin,
+ SCM_UNDEFINED));
+
+
+ Real spc = gh_scm2double (extra_space);
+ spc *= paper_l ()->get_realvar (interline_scm_sym);
+
+ current_elt->set_elt_property (extra_space_scm_sym,
+ scm_cons (gh_double2scm (0.0),
+ gh_double2scm (spc)));
+
+ }
+ current_elt = next_elt;
+ current_origin = next_origin;
+ }
+
+ }
Axis_align_item::do_pre_processing();
}
warning bells about missing Y refpoints go off later on.
*/
hg->dim_cache_[Y_AXIS]->parent_l_ = dim_cache_[Y_AXIS];
- hg->set_elt_property (ly_symbol("origin"),
- SCM_EOL);
+ hg->set_elt_property (ly_symbol("origin"), gh_str02scm (it->name()));
pscore_l_->typeset_element (hg);
add_element_priority (hg, priority);
if (priority == 0)
center_l_ = hg;
}
-
+
+ /*
hg->set_elt_property (ly_symbol("origin"),
scm_cons (gh_str02scm (it->name()),
hg->get_elt_property (ly_symbol ("origin"))));
+ */
hg->add_element (it);
for (int i=0; i < nongroups.size(); i++)
{ // Is this good enough?
Engraver * eng = dynamic_cast<Engraver*> (nongroups[i]);
- if (eng && eng!= info.origin_grav_l_arr_[0])
+ if (eng && eng!= info.origin_trans_l_arr_[0])
eng->acknowledge_element (info);
}
}
-Engraver_group_engraver::~Engraver_group_engraver ()
-{
-}
-
-Engraver_group_engraver::Engraver_group_engraver ()
-{
-}
}
-
void
Engraver::announce_element (Score_element_info i)
{
- i.origin_grav_l_arr_.push (this);
+ i.origin_trans_l_arr_.push (this);
daddy_grav_l()->announce_element (i);
}
*/
class Align_element : public virtual Axis_group_element {
Hash_table<Score_element*,int> priority_i_hash_;
- void sort_elements ();
public:
Interval threshold_interval_ ;
Score_element *get_elt_by_priority (int) const;
int get_priority (Score_element*) const;
protected:
+ void sort_elements ();
virtual void do_print() const;
virtual void do_substitute_element_pointer (Score_element*,Score_element*);
virtual void do_post_processing() ;
--- /dev/null
+/*
+ audio-item-info.hh -- declare Audio_item_info
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef AUDIO_ITEM_INFO_HH
+#define AUDIO_ITEM_INFO_HH
+
+#include "lily-proto.hh"
+#include "parray.hh"
+
+/**
+ Data container for broadcasts
+ */
+struct Audio_element_info {
+ Audio_element * elem_l_;
+ Music *req_l_;
+ Link_array<Translator> origin_trans_l_arr_;
+
+ Audio_element_info (Audio_element*, Music*);
+ Audio_element_info();
+};
+
+
+#endif
Array<Score_element_info> announce_info_arr_;
public:
VIRTUAL_COPY_CONS(Translator);
- Engraver_group_engraver();
- ~Engraver_group_engraver();
virtual Staff_info get_staff_info() const;
virtual void do_announces();
void read_lily_scm_file (String);
-void init_symbols ();
+void init_lily_guile ();
+
#include "ly-symbols.hh"
/*
- DIY gc protection.
+ Do It Yourself GC protection.
*/
SCM ly_protect_scm (SCM s);
SCM ly_unprotect_scm (SCM s);
struct Articulation_req;
struct Atom;
struct Audio_element;
+struct Audio_element_info;
struct Audio_column;
struct Audio_item;
struct Audio_key;
DECLARE_LY_SYMBOL(notewidth);
DECLARE_LY_SYMBOL(non_default);
DECLARE_LY_SYMBOL(octave_dir);
+DECLARE_LY_SYMBOL(origin);
DECLARE_LY_SYMBOL(output);
DECLARE_LY_SYMBOL(padding);
DECLARE_LY_SYMBOL(pianobrace);
class Performer_group_performer : public Performer, public virtual Translator_group {
public:
VIRTUAL_COPY_CONS(Translator);
-
+
+ virtual void do_announces();
+ virtual void announce_element (Audio_element_info);
+protected:
+ Array<Audio_element_info> announce_info_arr_;
};
#endif // PERFORMER_GROUP_PERFORMER_HH
#ifndef PERFORMER_HH
#define PERFORMER_HH
-#include "lily-proto.hh"
+#include "audio-element-info.hh"
#include "array.hh"
#include "request.hh"
#include "score-element-info.hh"
class Performer : public virtual Translator{
public:
VIRTUAL_COPY_CONS(Translator);
-
+ friend class Performer_group_performer;
Performer_group_performer* daddy_perf_l() const;
protected:
+ virtual void announce_element (Audio_element_info);
+ virtual void acknowledge_element (Audio_element_info);
+ virtual void process_acknowledged ();
virtual int get_tempo_i() const;
virtual void play (Audio_element * elem_p );
};
#endif // PERFORMER_HH
+
#ifndef STAFFELEMINFO_HH
#define STAFFELEMINFO_HH
-#include "scalar.hh"
#include "lily-proto.hh"
#include "parray.hh"
struct Score_element_info {
Score_element * elem_l_;
Music *req_l_;
- Link_array<Engraver> origin_grav_l_arr_;
+ Link_array<Translator> origin_trans_l_arr_;
Score_element_info (Score_element*, Music*);
Score_element_info();
String id_str_;
-
VIRTUAL_COPY_CONS(Translator);
-
void set_acceptor (String accepts, bool add);
void set_element (String elt, bool add);
void add_last_element (String elt);
void check_removal ();
-
Translator *get_simple_translator (String) const;
Translator_group *find_existing_translator_l (String n, String id);
Translator_group *find_create_translator_l (String n, String id);
output->add_at_edge (X_AXIS, RIGHT, m, 0);
}
- if (pitch_arr_.size())
- {
- Molecule m (lookup_l ()->fill (Box (
- Interval (0, paper_l ()->note_width ()),
- Interval (0,0))));
-
- output->add_at_edge (X_AXIS, RIGHT, m,0 );
- }
return output;
}
return list;
}
+SCM
+ly_warning (SCM str)
+{
+ assert (gh_string_p (str));
+ warning ("scheme: " + ly_scm2string (str));
+ return SCM_BOOL_T;
+}
+
+void
+init_functions ()
+{
+ scm_make_gsubr ("ly-warn", 1, 0, 0, ly_warning);
+}
+
+
+extern void init_symbols ();
+
+void
+init_lily_guile ()
+{
+ init_symbols();
+ init_functions ();
+}
*/
extern void ly_init_protection();
ly_init_protection();
- init_symbols ();
+ init_lily_guile ();
read_lily_scm_file ( "lily.scm");
cout << endl;
ADD_THIS_TRANSLATOR(Performer_group_performer);
+
+void
+Performer_group_performer::announce_element (Audio_element_info info)
+{
+ announce_info_arr_.push (info);
+ Performer::announce_element (info);
+}
+
+void
+Performer_group_performer::do_announces()
+{
+ Link_array<Translator_group> groups = group_l_arr ();
+ for (int i=0; i < groups.size(); i++)
+ {
+ Performer_group_performer * group = dynamic_cast<Performer_group_performer*> (groups[i]);
+ if (group)
+ {
+ group->do_announces();
+ }
+ }
+
+ Request dummy_req;
+
+ Link_array<Translator> nongroups = nongroup_l_arr ();
+ while (announce_info_arr_.size ())
+ {
+ for (int j =0; j < announce_info_arr_.size(); j++)
+ {
+ Audio_element_info info = announce_info_arr_[j];
+
+ if (!info.req_l_)
+ info.req_l_ = &dummy_req;
+ for (int i=0; i < nongroups.size(); i++)
+ { // Is this good enough?
+ Performer * eng = dynamic_cast<Performer*> (nongroups[i]);
+ if (eng && eng!= info.origin_trans_l_arr_[0])
+ eng->acknowledge_element (info);
+ }
+ }
+ announce_info_arr_.clear ();
+ for (int i=0; i < nongroups.size(); i++)
+ {
+ Performer * eng = dynamic_cast<Performer*> (nongroups[i]);
+ if (eng)
+ eng->process_acknowledged ();
+ }
+
+ }
+}
+
#include "performer-group-performer.hh"
#include "debug.hh"
-
-
-
void
Performer::play (Audio_element* p)
{
?dynamic_cast<Performer_group_performer *> (daddy_trans_l_)
: 0;
}
+
+void
+Performer::acknowledge_element (Audio_element_info)
+{
+}
+
+void
+Performer::process_acknowledged ()
+{
+}
+
+
+void
+Performer::announce_element (Audio_element_info i)
+{
+ i.origin_trans_l_arr_.push (this);
+ daddy_perf_l()->announce_element (i);
+}
String reststyle = get_property ("restStyle", 0);
if (reststyle.length_i ())
rest_p_->set_elt_property (style_scm_sym,
- gh_str02scm (reststyle.ch_C()));
+ gh_str02scm (reststyle.ch_C()));
}
announce_element (Score_element_info (rest_p_, rest_req_l_));
}
{
#ifndef NPRINT
DOUT << classname(this) << "{\n";
+ if (check_debug && !monitor->silent_b ("Score_element"))
+ ly_display_scm (element_property_alist_);
DOUT << "dependencies: " << dependency_size();
if (original_l_)
DOUT << "Copy ";
Score_engraver::announce_element (Score_element_info info)
{
announce_info_arr_.push (info);
- info.origin_grav_l_arr_.push (this);
+ info.origin_trans_l_arr_.push (this);
if (Spanner *s = dynamic_cast <Spanner *> (info.elem_l_))
pscore_p_->typeset_unbroken_spanner (s);
Score_performer::process()
{
process_requests();
+ do_announces ();
pre_move_processing();
check_removal();
}
Staff_margin_engraver::acknowledge_element (Score_element_info inf)
{
Item *i = cast_to_interesting_item (inf.elem_l_);
- if (!i || inf.origin_grav_l_arr_.size() != 1)
+ if (!i || inf.origin_trans_l_arr_.size() != 1)
return;
Molecule num (lookup_l ()->text ("italic",
number_str_));
num.align_to (X_AXIS, CENTER);
- num.translate_axis (dir_ * paper_l ()->get_realvar (interline_scm_sym), Y_AXIS);
-
+ Real interline = paper_l ()->get_realvar (interline_scm_sym);
+
if (beam_l_arr_.size () == 1 && !bracket_visibility_b_)
{
Beam *beam_l = beam_l_arr_[0];
Directional_spanner* ds = dynamic_cast<Directional_spanner*>(beam_l);
+
+ num.translate_axis (dir_ * interline, Y_AXIS);
num.translate (ds->center ());
num.translate_axis (ncw, X_AXIS);
}
Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_]
- column_arr_[0]->extent (Y_AXIS) [dir_];
Real w = extent (X_AXIS).length () + ncw;
- // num.align_to (Y_AXIS, CENTER);
+ num.align_to (Y_AXIS, CENTER);
+ num.translate_axis (dir_ * interline, Y_AXIS);
+
num.translate (Offset (w/2, dy/2));
mol_p->add_molecule (lookup_l ()->plet (dy, w, dir_));
}
{
mol_p->add_molecule (num);
}
+ mol_p->translate_axis (dir_ * interline, Y_AXIS);
}
return mol_p;
}
bool
Vertical_align_engraver::qualifies_b (Score_element_info i) const
{
- Translator * t = i.origin_grav_l_arr_[0];
- int sz = i.origin_grav_l_arr_.size() ;
+ Translator * t = i.origin_trans_l_arr_[0];
+ int sz = i.origin_trans_l_arr_.size() ;
#if 0
return (sz == 1 && dynamic_cast<Translator_group*> (t))
{
valign_p_->add_element (i.elem_l_);
}
- else if (dynamic_cast<Span_bar*>(i.elem_l_) && i.origin_grav_l_arr_.size ())
+ else if (dynamic_cast<Span_bar*>(i.elem_l_) && i.origin_trans_l_arr_.size ())
{
i.elem_l_->add_dependency (valign_p_);
}
%
def set_horizontal_spacing =
save left_space ,right_space;
- left_space# = reduced_il#;
- right_space# = reduced_il#;
+ left_space# = 0;
+ right_space# = 0;
enddef;
0 0 moveto
- 0 tuplet_h lineto
+ 0 tuplet_h dir mul lineto
tuplet_dx tuplet_gapx sub 2 div
- tuplet_dy tuplet_gapy sub 2 div tuplet_h add lineto
+ tuplet_dy tuplet_gapy sub 2 div tuplet_h dir mul add lineto
tuplet_dx tuplet_gapx add 2 div
- tuplet_dy tuplet_gapy add 2 div tuplet_h add moveto
- tuplet_dx tuplet_dy tuplet_h add lineto
+ tuplet_dy tuplet_gapy add 2 div tuplet_h dir mul add moveto
+ tuplet_dx tuplet_dy tuplet_h dir mul add lineto
tuplet_dx tuplet_dy lineto
stroke
} bind def
(define Piano_bar_engraver_visibility postbreak_only_visibility)
(define Staff_group_bar_engraver_visibility postbreak_only_visibility)
-
-
+;; Spacing constants for prefatory matter.
+;;
+;; rules for this are complicated. See [Wanske] page 126 -- 134
+;;
+;;
+(define space-alist
+ '(
+ (("Clef_item" "Key_item") . 2.5)
+ (("Key_item" "Time_signature") . 2.5)
+ (("Clef_item" "Time_signature") . 2.75)
+ (("Staff_bar" "Clef_item") . 1.0)
+ (("Clef_item" "Staff_bar") . 3.7)
+ (("Time_signature" "Staff_bar") . 2.0)
+ (("Key_item" "Staff_bar") . 2.5)
+ (("Span_bar" "Clef_item") . 1.0)
+ (("Clef_item" "Span_bar") . 3.7)
+ (("Time_signature" "Span_bar") . 2.0)
+ (("Key_item" "Span_bar") . 2.5)
+ (("Staff_bar" "Time_signature") . 1.0)
+ )
+
+ )
+
+(define (break-align-spacer this next)
+ (let ((entry (assoc `(,this ,next) space-alist)))
+ (if entry
+ (cdr entry)
+ (begin (ly-warn (string-append "Unknown spacing pair " this ", " next))
+ 0.0))))
+
+
;;;;;;;; TeX
import sys
import re
import string
+import mpz
header = {}
global_voice_stuff = []
default_len = 4
global_key = [0] * 7 # UGH
+DIGITS='0123456789'
+def gcd (a, b):
+ while a % b:
+ a,b = b, a % b
+ return b
+
+class Rational:
+ def __init__ (self, n, d = 1):
+ self.num = n
+ self.den = d
+
+ def simplify (self):
+ g = gcd (self.num, self.den)
+ self.num = self.num / g
+ self.den = self.den /g
+ if self.den < 0:
+ self.den = - self.den
+ self.num = - self.num
+
+ def __sub__ (self, other):
+ pass
+
def dump_header (hdr):
def parse_num (str):
durstr = ''
- while str[0] in "1234567890":
+ while str[0] in DIGITS:
durstr = durstr + str[0]
str = str[1:]
return (str,n)
-def duration_to_mudela_duration (multiply_tup, defaultlen):
+def duration_to_mudela_duration (multiply_tup, defaultlen, dots):
base = 1
+ # (num / den) / defaultlen < 1/base
+ while base * multiply_tup[0] < defaultlen * multiply_tup[1]:
+ base = base * 2
+
+
+ return '%d%s' % ( base, '.'* dots)
+
+class Parser_state:
+ def __init__ (self):
+ self.next_dots = 0
+ self.next_den = 1
+
+
# WAT IS ABC EEN ONTZETTENDE PROGRAMMEERPOEP !
-def try_parse_note (str):
+def try_parse_note (str, parser_state):
mud = ''
slur_begin =0
str = str[1:]
num = 0
- den = 0
+ den = parser_state.next_den
+ parser_state.next_den = 1
(str, num) = parse_num (str)
if not num:
num = 1
if str[0] == '/':
- divide =1
- str = str[1:]
- (str, den) =parse_num (str)
-
- if not den: den = 1
+ while str[0] == '/':
+ str= str[1:]
+ d = 2
+ if str[0] in DIGITS:
+ (str, d) =parse_num (str)
+
+ den = den * d
+
+ current_dots = parser_state.next_dots
+ parser_state.next_dots = 0
+ while str[0] == '>':
+ str = str [1:]
+ current_dots = current_dots + 1;
+ parser_state.next_den = parser_state.next_den * 2
+
+ while str[0] == '<':
+ str = str [1:]
+ den = den * 2
+ parser_state.next_dots = parser_state.next_dots + 1
+
- print duration_to_mudela_duration ((num,den), default_len)
- print '%s%s%d' % (pitch_to_mudela_name(notename, acc + global_key[notename]) , octave_to_mudela_quotes (octave), duration_mult)
+
+ print '%s%s%s' % (pitch_to_mudela_name(notename, acc + global_key[notename]) , octave_to_mudela_quotes (octave),
+ duration_to_mudela_duration ((num,den), default_len, current_dots))
slur_end =0
if str[0] == ')':
return str
+def try_parse_escape (str):
+ if str [0] != '\\':
+ return str
+
+ str = str[1:]
+ if str[0] == 'K':
+ compute_key ()
+
+ return str
+
+
def try_parse_bar (str):
if str[0] == '|':
str = str[1:]
return str
-def try_parse_body_line (ln):
+
+
+def try_parse_body_line (ln, state):
prev_ln = ''
while ln and ln != prev_ln:
prev_ln = ln
- ln = try_parse_note (ln)
+ ln = try_parse_note (ln, state)
ln = try_parse_bar (ln)
ln = junk_space (ln)
+ ln = try_parse_escape (ln)
if ln:
print 'Huh %s' % ln
+
+
+
+
def parse_file (fn):
f = open (fn)
ls = f.readlines ()
head = 1
+ state = Parser_state ()
for l in ls:
if re.match ('^[\t ]*(%.*)?$', l):
continue
head = 0
if not head:
- m = try_parse_body_line (l)
+ m = try_parse_body_line (l,state)
def identify():