--- /dev/null
+/*
+ staffsym.hh -- declare Staff_symbol
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#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_;
+
+ const char *name()const;
+ Staff_symbol(int lines);
+ 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;
+};
+#endif // STAFFSYM_HH
+/*
+ clef.cc -- implement Clef
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>,
+ Mats Bengtsson <matsb@s3.kth.se>
+*/
+
#include "clef.hh"
+#include "debug.hh"
Clef::Clef()
{
- clef_type= "violin";
- c0_pos = -2;
+ set_type("violin");
}
-void
-Clef::read(Array<Scalar>args)
+void
+Clef::set_type(String type_str)
{
- clef_type = args[0];
- if (clef_type == "violin") {
- c0_pos=-2;
- } else if (clef_type == "alto") {
- c0_pos = 4;
- } else if (clef_type == "tenor") {
- c0_pos = 6;
- } else if (clef_type == "bass") {
- c0_pos = 10;
+ clef_type_str_ = type_str;
+ if (clef_type_str_ == "violin") {
+ c0_position_i_= -2;
+ } else if (clef_type_str_ == "alto") {
+ c0_position_i_= 4;
+ } else if (clef_type_str_ == "tenor") {
+ c0_position_i_= 6;
+ } else if (clef_type_str_ == "bass") {
+ c0_position_i_= 10;
} else
- assert(false);
+ error("unknown clef type `"+clef_type_str_+"\'");
}
void
Clef_item::read(Clef k)
{
- read(k.clef_type);
+ read(k.clef_type_str_);
}
Molecule*
t += "_change";
Symbol s = paper()->lookup_p_->clef(t);
Molecule*output = new Molecule(Atom(s));
- output->translate(Offset(0, paper()->interline()/2 * y_off));
+ output->translate(Offset(0, paper()->internote() * y_off));
return output;
}
--- /dev/null
+/*
+ headreg.cc -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "rest.hh"
+#include "notehead.hh"
+#include "headreg.hh"
+#include "paper.hh"
+#include "complexwalker.hh"
+
+
+Notehead_register::Notehead_register(Complex_walker*w_l)
+ :Request_register(w_l)
+{
+ note_p_ = 0;
+ set_dir(0);
+}
+
+bool
+Notehead_register::try_request(Request *req_l)
+{
+ if (req_l->note() || req_l->rest())
+ accepted_req_arr_.push(req_l);
+ else
+ return false;
+
+ return true;
+}
+void
+Notehead_register::set_dir(int d)
+{
+ dir_i_ = d;
+}
+
+void
+Notehead_register::process_request()
+{
+ if (!accepted_req_arr_.size())
+ return;
+
+ Request* req_l = accepted_req_arr_.top();
+ if (req_l->note()) {
+ Notehead*n_p = new Notehead(8); // ugh
+ note_p_ = n_p;
+ n_p->set_rhythmic(req_l->rhythmic());
+ n_p->position = req_l->note()->height() +
+ walk_l_->clef_.c0_position_i_;
+ } else {
+ note_p_ = new Rest ( req_l->rhythmic()->balltype,
+ req_l->rhythmic()->dots);
+ if (req_l->rhythmic()->balltype <= 2)
+ note_p_->translate(
+ Offset(0,
+ 6 * paper()->internote()));
+ }
+ Staff_elem_info itinf(note_p_,req_l,this);
+ announce_element(itinf);
+}
+
+void
+Notehead_register::do_pre_move_process()
+{
+ if (note_p_) {
+ if (dir_i_ && note_p_->name() == String("Rest"))
+ note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
+ typeset_element(note_p_);
+ note_p_ = 0;
+ }
+}
Molecule*octmol = 0;
int lastoct = -100;
for (int i = 0; i < accs.size(); i++) {
+ // do one octave
if (accs[i].octave != lastoct) {
if (octmol){
- Real dy =lastoct*7*paper()->interline()/2;
+ Real dy =lastoct*7*paper()->internote();
octmol->translate(Offset(0, dy));
output->add(*octmol);
delete octmol;
lastoct = accs[i].octave;
Symbol s =paper()->lookup_p_->accidental(accs[i].acc);
Atom a(s);
- Real dy = (accs[i].name + c0_position) * paper()->interline()/2;
+ Real dy = (accs[i].name + c0_position) * paper()->internote();
a.translate(Offset(0,dy));
octmol->add_right(a);
}
if (octmol){
- Real dy =lastoct*7*paper()->interline()/2;
+ Real dy =lastoct*7*paper()->internote();
octmol->translate(Offset(0, dy));
output->add(*octmol);
delete octmol;
--- /dev/null
+/*
+ localkeyreg.cc -- implement Local_key_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "localkeyreg.hh"
+#include "localkeyitem.hh"
+#include "complexwalker.hh"
+
+Local_key_register::Local_key_register(Complex_walker*w)
+ : Request_register(w)
+{
+ key_item_p_ = 0;
+}
+bool
+Local_key_register::try_request(Request*)
+
+{
+ return false;
+}
+
+void
+Local_key_register::process_request()
+{
+}
+void
+Local_key_register::do_pre_move_process()
+{
+ if (key_item_p_) {
+ walk_l_->typeset_element(key_item_p_);
+ key_item_p_ = 0;
+ }
+}
+void
+Local_key_register::acknowledge_element(Staff_elem_info info)
+{
+ if (info.req_l_->melodic()) {
+ Melodic_req * melodic_l_ = info.req_l_->melodic();
+
+ if( melodic_l_->forceacc ||
+ walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename)
+ != melodic_l_->accidental) {
+ Item * support_l_ = info.elem_p_->item();
+
+
+ if (!key_item_p_) {
+ key_item_p_ = new Local_key_item(walk_l_->clef_.c0_position_i_);
+ key_item_p_->c0_position = walk_l_->clef_.c0_position_i_;
+ }
+
+ key_item_p_->add(melodic_l_);
+ key_item_p_->add(support_l_);
+ walk_l_->local_key_.oct(melodic_l_->octave)
+ .set(melodic_l_->notename, melodic_l_->accidental);
+ }
+ }
+}
#include "pcol.hh"
NAME_METHOD(Spanner);
+
void
Spanner::do_print()const
{