--- /dev/null
+#!/usr/bin/perl -w
+
+print "todo\n!";
% The purpose of this file is to demonstrate features of LilyPond.
% (there is an accompanying LaTeX file, scsii-menuetto.tex)
%
-
+\version "0.0.50";
%% Stuff from MPP version
% \lefttitle{Menuetto}
% \tempo{Moderato}
c'!4-. |
%%7
< a4-. f4>
- < d'4-.-upbow f4 'bes4 >
- < e'4-.-downbow g4 'g4 > |
+ < d'4-.-\upbow f4 'bes4 >
+ < e'4-.-\downbow g4 'g4 > |
%%8
- < cis'2.-upbow e2. 'a2. >
+ < cis'2.-\upbow e2. 'a2. >
\bar ":|:";
%%9
\clef "violin";
{ \stem -1; g4(\stem -1;) f4 e4 }% ugh
> |
%%14
- < [ a f > g a f ] < d'4-$upbow e4 'bes4 > |
+ < [ a f > g a f ] < d'4-\upbow e4 'bes4 > |
%%15
- < c'4-$downbow f4 'a4 > [ bes( )a g a ] |
+ < c'4-\downbow f4 'a4 > [ bes( )a g a ] |
%%16
[ f( e )f a-. g-. bes-. ] |
%%17
%%18
< { [ c'( )bes c' a ] } { [ es ] } > fis4 |
%%19
- < d'4-downbow g4 'bes4 > < c'4-upbow g4 c4 > < [ bes d > a ] |
+ < d'4-\downbow g4 'bes4 > < c'4-\upbow g4 c4 > < [ bes d > a ] |
%%20
< { [ c'( bes a )bes g( )bes ] } { [ d ] } { [ g ] } > |
%%21
}
\score{
- \staff{ melodicregs $ii_menuetto }
+ \staff{ melodicregs ii_menuetto }
\paper{
\width 195\mm
\unitspace 9\mm % to get lily to use only three lines
#include "lookup.hh"
#include "paper-def.hh"
#include "debug.hh"
-Crescendo::Crescendo(int s)
+
+Crescendo::Crescendo()
+ : Staff_side(this)
{
- staff_size_i_ = s;
grow_dir_i_ =0;
dir_i_ = -1 ;
left_dyn_b_ = right_dyn_b_ =false;
}
Symbol s( paper()->lookup_l()->hairpin(w_dim, grow_dir_i_ < 0) );
m_p->add(Atom(s));
- int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ;
- if(dir_i_<0 ) // should do something better anyway.
- m_p->translate(Offset(0, -m_p->extent().y.left ));
+ int pos = get_position_i();
m_p->translate(Offset(x_off_dim,pos * paper()->internote()));
}
--- /dev/null
+/*
+ staff-side.hh -- declare Staff_side
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef STAFF_SIDE_HH
+#define STAFF_SIDE_HH
+
+#include "staff-elem.hh"
+
+/// A symbol which sits along the staff
+class Staff_side {
+ Array<Staff_elem*> support_l_arr_;
+
+ Staff_symbol * staff_sym_l_;
+ Staff_elem * elem_l_;
+ Interval support_height()const;
+public:
+ /**
+ Vertical dir of symbol relative to staff. -1 = below staff?
+ */
+ int dir_i_;
+
+ /// follow the support inside the staff?
+ bool inside_staff_b_;
+
+ void set_staffsym(Staff_symbol*);
+
+ Staff_side(Staff_elem*);
+ void add_support(Staff_elem*);
+
+protected:
+ int get_position_i()const;
+};
+#endif // STAFF_SIDE_HH
#ifndef STAFFSYM_HH
#define STAFFSYM_HH
#include "spanner.hh"
+
/**
This spanner draws the lines of a pstaff.
The bottom line is position 0.
*/
class Staff_symbol : public Spanner
{
-public:
/// this many lines.
int no_lines_i_;
+public:
+ void set_extent(PCol* p1, PCol* p2);
NAME_MEMBERS(Staff_symbol);
Staff_symbol(int lines);
+ Real inter_note_f()const;
+ int steps_i()const;
+protected:
virtual Molecule* brew_molecule_p() const;
- void set_extent(PCol* p1, PCol* p2);
virtual void do_print()const;
virtual Spanner *do_break_at( PCol *c1, PCol *c2) const;
};
#include "text-def.hh"
#include "item.hh"
+#include "staff-side.hh"
/**
print a fixed width text above or below the staff.
*/
-class Text_item : public Item {
- void init(Text_def* tdef_l,int staffsize_i);
+class Text_item : public Item ,public Staff_side{
+ void init(Text_def* tdef_l);
Text_def* tdef_p_;
+
public:
Text_def * tdef_l();
int pos_i_;
- int staffsize_i_;
- int dir_i_;
/* ***************/
virtual void set_default_index();
Molecule* brew_molecule_p() const;
void do_pre_processing();
- Text_item(Text_def*,int);
- Text_item(Text_req*,int);
+ Text_item(Text_def*);
+ Text_item(Text_req*);
~Text_item();
};
#include "debug.hh"
Lyric_item::Lyric_item(Lyric_req* lreq_l, int voice_count_i)
- : Text_item(lreq_l,0)
+ : Text_item(lreq_l)
{
pos_i_ = -voice_count_i * 4 ; // 4 fontsize dependant. TODO
dir_i_ = -1;
void
Register_group_register::acknowledge_element(Staff_elem_info info)
{
- if (!contains_b(info.origin_reg_l_arr_[0]))
+ Request_register* origin = info.origin_reg_l_arr_[0];
+ if (!contains_b(origin) && !origin->contains_b(this))
return;
for (iter_top(reg_list_, i); i.ok(); i++)
+/*
+ script.cc -- implement Script
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "musical-request.hh"
#include "paper-def.hh"
#include "script.hh"
Script::set_stem(Stem*st_l)
{
stem_l_ = st_l;
- add_dependency(st_l);
+ add_support(st_l);
}
-void
-Script::set_support(Item*i)
-{
- support.push(i);
- add_dependency(i);
-}
-Script::Script(Script_req* rq, int staflen)
+Script::Script(Script_req* rq)
+ :Staff_side(this)
{
- staffsize =staflen;
specs_l_ = rq->scriptdef_p_;
+ inside_staff_b_ = specs_l_->inside_staff_b_;
stem_l_ = 0;
- pos = 0;
- symdir=1;
- dir =rq->dir_i_;
+ pos_i_ = 0;
+ symdir_i_=1;
+ dir_i_ =rq->dir_i_;
}
void
Script::set_symdir()
{
- if (specs_l_->invertsym)
- symdir = (dir < 0) ? -1:1;
+ if (specs_l_->invertsym_b_)
+ symdir_i_ = (dir_i_ < 0) ? -1:1;
}
void
Script::set_default_dir()
{
- if (specs_l_->stemdir) {
- if (!stem_l_)
- dir = 1;
- else
- dir = stem_l_->dir * specs_l_->stemdir;
+ int s_i=specs_l_->rel_stem_dir_i_;
+ if (s_i && stem_l_)
+ dir_i_ = stem_l_->dir_i_ * s_i;
+ else {
+ dir_i_ =specs_l_->staff_dir_i_;
}
}
-Interval
-Script::support_height() const return r;
-{
- for (int i=0; i < support.size(); i++)
- r.unite(support[i]->height());
-}
-
void
Script::set_default_index()
{
- Real inter_f= paper()->internote();
- Interval dy = symbol().dim.y;
-
- int d = specs_l_->staffdir;
- Real y ;
- if (!d) {
- Interval v= support_height();
- y = v[dir] -dy[-dir] + 2*dir*inter_f;
- } else {
- y = (d > 0) ? staffsize + 2: -2; // ug
- y *=inter_f;
- Interval v= support_height();
-
- if (d > 0) {
- y = y >? v.max();
- } else if (d < 0) {
- y = y <? v.min();
- }
- }
-
- if (stem_l_) {
- Interval v= stem_l_->height();
-
- if (d > 0 || (!d && dir > 0)) {
- y = y >? v.max();
- }else if (d < 0 || (!d && dir < 0)) {
- y = y <? v.min();
- }
- }
-
- pos = int(rint(Real(y)/inter_f));
+ pos_i_ = get_position_i();
}
Interval
-Script::width() const
+Script::do_width() const
{
return symbol().dim.x;
}
Symbol
Script::symbol()const
{
- String preidx_str = (symdir < 0) ?"-" :"";
+ String preidx_str = (symdir_i_ < 0) ?"-" :"";
return paper()->lookup_l()->script(preidx_str + specs_l_->symidx);
}
Real dy = paper()->internote();
Molecule*out = new Molecule(Atom(symbol()));
- out->translate(Offset(0,dy * pos));
+ out->translate(Offset(0,dy * pos_i_));
return out;
}
IMPLEMENT_STATIC_NAME(Script);
+
+int
+Script::compare(Script *const&l1, Script *const&l2)
+{
+ return l1->specs_l_->priority_i_ - l2->specs_l_->priority_i_;
+}
+
--- /dev/null
+/*
+ staff-side.cc -- implement Staff_side
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "staff-side.hh"
+#include "staff-sym.hh"
+
+void
+Staff_side::set_staffsym(Staff_symbol* s_l)
+{
+ staff_sym_l_ = s_l;
+}
+
+Staff_side::Staff_side(Staff_elem * elem_l)
+{
+ elem_l_ = elem_l;
+ dir_i_ =0;
+ staff_sym_l_ =0;
+ inside_staff_b_ =false;
+}
+
+
+Interval
+Staff_side::support_height() const return r;
+{
+ for (int i=0; i < support_l_arr_.size(); i++)
+ r.unite(support_l_arr_[i]->height());
+}
+
+void
+Staff_side::add_support(Staff_elem*i)
+{
+ support_l_arr_.push(i);
+ elem_l_->add_dependency(i);
+}
+
+int
+Staff_side::get_position_i()const
+{
+ if (!staff_sym_l_)
+ return 0;
+
+ Real inter_f = staff_sym_l_->inter_note_f();
+ int staff_size_i = staff_sym_l_->steps_i();
+ Real y=0;
+ if (!inside_staff_b_) {
+ y = (dir_i_ > 0) ? staff_size_i + 2: -2;
+ y *=inter_f;
+ Interval v= support_height();
+
+ if (dir_i_ > 0) {
+ y = y >? (v.max() + 2*inter_f);
+ } else if (dir_i_ < 0) {
+ y = y <? (v.min() - 2*inter_f);
+ }
+ } else {
+ Interval v= support_height();
+ y = v[dir_i_] + 2*dir_i_*inter_f; // ugh
+ }
+ return int(rint(Real(y)/inter_f));
+}
left_col_l_ = p1;
right_col_l_ = p2;
}
+
+Real
+Staff_symbol::inter_note_f()const
+{
+ return paper()->internote();
+}
+
+int
+Staff_symbol::steps_i() const
+{
+ return no_lines_i_*2;
+}