+pl 38
+
+Internal
+ - great filename renaming operation with - convention.
+ - printing methods for paper_def/lookup/symtab(s)
+ - untied all registers from complexwalker. Now registers are
+intrinsically hierarchical. All walker communication is done via a
+"top level" register.
+
+******
pl 37
- language.pod as starting point for mudela devel.
- Jan's patches:
-(jan's pl 36-3)
-
+Features
+ - m2m patchy --no-triplet option;
+ lilypond accepts m2m's real midi output (hand-add red tape)
+ - m2m output only valid durations, resync option wip
- m2m produces .ly output
Internal
- simpler and better naming for Duration*
- the great String renaming / index to base=0 change
- Track_column, Lily_stream
-Features
- - m2m patchy --no-triplet option;
- lilypond accepts m2m's real midi output (hand-add red tape)
- - m2m output only valid durations, resync option wip
+ - Duration, Plet, Duration_convert taking load off duration calc.
Bugfix
- m2m duration calc
-Internal
- - Duration, Plet, Duration_convert taking load off duration calc.
+
+******
pl 36
- Jan's patches:
- do MIDI rests cleanly.
--- /dev/null
+/*
+ input-score.hh -- declare
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef INPUTSCORE_HH
+#define INPUTSCORE_HH
+
+#include "varray.hh"
+#include "proto.hh"
+#include "plist.hh"
+#include "string.hh"
+
+
+/// the total music def of one movement
+struct Input_score {
+ /// defined where?
+ const char* defined_ch_c_l_;
+ int errorlevel_i_;
+
+ /// paper_, staffs_ and commands_ form the problem definition.
+ Paper_def *paper_p_;
+ Midi_def* midi_p_;
+ IPointerList<Input_staff*> staffs_;
+
+ Input_music * score_wide_music_p_;
+
+ /* *************************************************************** */
+ Input_score();
+ Input_score(Input_score const&);
+
+ void add(Input_staff*);
+ ~Input_score();
+ /// construction
+ void set(Paper_def*);
+ void set(Midi_def* midi_p);
+ void print() const;
+ Score*parse();
+ void set(Input_music*);
+};
+
+#endif
String texsetting;
/* *************** */
void add(String, Symtable*);
-
+ void print()const;
Real internote();
Symbol linestaff(int n, Real w);
--- /dev/null
+/*
+ paper-def.hh -- declare
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef Paper_def_HH
+#define Paper_def_HH
+#include "proto.hh"
+#include "real.hh"
+#include "string.hh"
+#include "moment.hh"
+
+
+/** symbols, dimensions and constants
+
+ This struct takes care of all kinds of symbols, dimensions and
+ constants. Most of them are related to the point-size of the fonts,
+ so therefore, the lookup table for symbols is also in here.
+
+ see TODO
+ */
+struct Paper_def {
+ Lookup *lookup_p_;
+ String outfile;
+
+ Real linewidth;
+
+ /// how much space does a whole note take (ideally?)
+ Real whole_width;
+
+ /// ideal = geometric_ ^ log2(duration)
+ Real geometric_;
+
+ /* *************** */
+ void reinit();
+ Paper_def(Lookup*);
+ void set(Lookup*);
+ ~Paper_def();
+ Paper_def(Paper_def const&);
+ Real interline()const;
+ Real internote()const;
+ Real rule_thickness()const;
+ Real standard_height()const;
+ Real note_width() const;
+ void print() const;
+ Real duration_to_dist(Moment);
+};
+
+#endif // Paper_def_HH
+
*/
struct PScore {
- Paperdef *paper_l_;
+ Paper_def *paper_l_;
/// the columns, ordered left to right
IPointerList<PCol *> cols;
/* *************** */
/* CONSTRUCTION */
- PScore(Paperdef*);
+ PScore(Paper_def*);
/// add a line to the broken stuff. Positions given in #config#
void set_breaking(Array<Col_hpositions>);
/// the total music def of one movement
struct Score {
/// paper_, staffs_ and commands_ form the problem definition.
- Paperdef *paper_p_;
+ Paper_def *paper_p_;
Midi_def *midi_p_;
IPointerList<Staff*> staffs_;
///
void set(Midi_def* midi_p);
///
- void set(Paperdef* midi_p);
+ void set(Paper_def* midi_p);
// standard
void OK() const;
void add(const PointerList<Voice*> &s);
void add_voice(Voice *v);
- Paperdef*paper()const;
+ Paper_def*paper()const;
void setup_staffcols();
Symbol (String, Box);
Symbol();
+ String str()const; // for printing.
};
#endif
struct Symtable : public Assoc<String, Symbol> {
Symbol lookup(String)const;
-
+ void print()const;
};
Symtables();
Symtables(Symtables const&);
Assoc<String, Symtable*>::add;
+ void print()const;
};
--- /dev/null
+/*
+ text-def.hh -- part of LilyPond
+
+ (c) 1996,97 Han-Wen Nienhuys
+*/
+
+#ifndef TEXTDEF_HH
+#define TEXTDEF_HH
+
+#include "string.hh"
+#include "proto.hh"
+
+struct Text_def {
+ int align_i_;
+ String text_str_;
+ String style_str_;
+ char const* defined_ch_c_l_;
+
+
+ /* ****************/
+ virtual ~Text_def() {};
+ bool compare(const Text_def&);
+ Text_def();
+ virtual void print() const;
+ virtual Atom create_atom(Paper_def*) const;
+};
+
+#endif // TEXTDEF_HH
+
#include "bar.hh"
#include "string.hh"
#include "molecule.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "lookup.hh"
#include "debug.hh"
-NAME_METHOD(Bar);
+
Bar::Bar( String t)
{
do calculations for breaking problem
*/
#include "break.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "linespace.hh"
#include "debug.hh"
#include "scoreline.hh"
#include "idealspacing.hh"
#include "score.hh"
#include "pscore.hh"
-#include "paperdef.hh"
-#include "scorecolumn.hh"
+#include "paper-def.hh"
+#include "score-column.hh"
#include "dimen.hh"
--- /dev/null
+/*
+ clef-item.cc -- implement Clef_item
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "clef-item.hh"
+#include "string.hh"
+#include "molecule.hh"
+#include "paper-def.hh"
+#include "lookup.hh"
+#include "clef-reg.hh"
+
+
+
+Clef_item::Clef_item()
+{
+ change = true;
+ read("violin");
+}
+
+void
+Clef_item::read(String t)
+{
+ type = t;
+ if (type == "violin")
+ y_off = 2;
+ if (type == "alto")
+ y_off = 4;
+ if (type == "tenor")
+ y_off = 6;
+ if (type == "bass")
+ y_off = 6;
+}
+void
+Clef_item::read(Clef_register const &k)
+{
+ read(k.clef_type_str_);
+}
+
+Molecule*
+Clef_item::brew_molecule_p()const
+{
+ String t = type;
+ if (change)
+ t += "_change";
+ Symbol s = paper()->lookup_p_->clef(t);
+ Molecule*output = new Molecule(Atom(s));
+ output->translate(Offset(0, paper()->internote() * y_off));
+ return output;
+}
+
--- /dev/null
+/*
+ input-score.cc -- implement Input_score
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "debug.hh"
+#include "input-score.hh"
+#include "input-staff.hh"
+#include "input-music.hh"
+#include "score.hh"
+#include "paper-def.hh"
+#include "midi-def.hh"
+#include "staff.hh"
+
+
+void
+Input_score::add(Input_staff*s)
+{
+ staffs_.bottom().add(s);
+}
+
+void
+Input_score::set(Paper_def*p)
+{
+ delete paper_p_;
+ paper_p_ = p;
+}
+
+void
+Input_score::set(Midi_def* midi_p)
+{
+ delete midi_p_;
+ midi_p_ = midi_p;
+}
+
+Input_score::Input_score(Input_score const&s)
+{
+ paper_p_ = (s.paper_p_)? new Paper_def(*s.paper_p_) :0;
+ midi_p_ = (s.midi_p_)? new Midi_def(*s.midi_p_) : 0;
+ defined_ch_c_l_ = s.defined_ch_c_l_;
+ errorlevel_i_ = s.errorlevel_i_;
+ score_wide_music_p_ = (s.score_wide_music_p_) ?
+ s.score_wide_music_p_->clone():0;
+}
+
+Score*
+Input_score::parse()
+{
+ Score *s_p = new Score;
+ s_p->defined_ch_c_l_= defined_ch_c_l_;
+ s_p->errorlevel_i_ = errorlevel_i_;
+ if (midi_p_)
+ s_p->set(new Midi_def(*midi_p_));
+ if (paper_p_)
+ s_p->set( new Paper_def(*paper_p_));
+
+ for (iter_top(staffs_,i); i.ok(); i++) {
+ Staff* staf_p=i->parse(s_p, score_wide_music_p_);
+ s_p->add(staf_p);
+ }
+
+ return s_p;
+}
+
+void
+Input_score::set(Input_music *m_p)
+{
+ delete score_wide_music_p_;
+ score_wide_music_p_ =m_p;
+}
+
+
+Input_score::~Input_score()
+{
+ delete paper_p_;
+ delete score_wide_music_p_;
+ delete midi_p_;
+}
+
+Input_score::Input_score()
+{
+ score_wide_music_p_ =0;
+ defined_ch_c_l_=0;
+ paper_p_= 0;
+ midi_p_ = 0;
+ errorlevel_i_ = 0;
+}
+
+void
+Input_score::print()const
+{
+#ifndef NPRINT
+ mtor << "Input_score {\n";
+ for (iter_top(staffs_,i); i.ok(); i++) {
+ i->print();
+ }
+ mtor << "}\n";
+#endif
+}
--- /dev/null
+#include "key-item.hh"
+#include "key.hh"
+#include "debug.hh"
+#include "molecule.hh"
+#include "paper-def.hh"
+#include "lookup.hh"
+//#include "clef-reg.hh"
+#include "key-reg.hh"
+
+const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
+const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */
+
+
+
+Key_item::Key_item(int c)
+{
+ set_c_position(c);
+}
+
+void
+Key_item::read(const Key_register& key_reg_r)
+{
+ const Array<int> &idx_arr =key_reg_r.accidental_idx_arr_;
+ for (int i = 0 ; i< idx_arr.size(); i++) {
+ int note = idx_arr[i];
+ int acc = key_reg_r.key_.acc(note);
+
+ add(note, acc);
+ }
+}
+
+void
+Key_item::set_c_position(int c0)
+{
+ int octaves =(abs(c0) / 7) +1 ;
+ c_position=(c0 + 7*octaves)%7;
+}
+
+
+void
+Key_item::add(int p, int a)
+{
+ if ((a<0 && p>FLAT_TOP_PITCH) ||
+ (a>0 && p>SHARP_TOP_PITCH)) {
+ p -= 7; /* Typeset below c_position */
+ }
+ pitch.push(p);
+ acc.push(a);
+}
+
+
+Molecule*
+Key_item::brew_molecule_p()const
+{
+ Molecule*output = new Molecule;
+ Real inter = paper()->internote();
+
+ for (int i =0; i < pitch.size(); i++) {
+ Symbol s= paper()->lookup_p_->accidental(acc[i]);
+ Atom a(s);
+ a.translate(Offset(0,(c_position + pitch[i]) * inter));
+ Molecule m(a);
+ output->add_right(m);
+ }
+ Molecule m(paper()->lookup_p_->fill(Box(
+ Interval(0, paper()->note_width()),
+ Interval(0,0))));
+ output->add_right(m);
+ return output;
+}
+/*
+ lookup.cc -- implement simple Lookup methods.
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "lookup.hh"
#include "debug.hh"
#include "symtable.hh"
symtables_->add(s, p);
}
+void
+Lookup::print()const
+{
+ mtor << "Lookup: " << texsetting << " {\n";
+ symtables_->print();
+ mtor << "}\n";
+}
+
Symbol
Lookup::text(String style, String text, int dir)
{
return s;
}
-/* *************** */
Real
Lookup::internote()
#include "scalar.hh"
#include "molecule.hh"
#include "meter.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "lookup.hh"
-NAME_METHOD(Meter);
+
Meter::Meter(Array<Scalar>a)
:args(a)
{
#include "notehead.hh"
#include "dimen.hh"
#include "debug.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "lookup.hh"
#include "molecule.hh"
#include "musicalrequest.hh"
-NAME_METHOD(Notehead);
+
Notehead::Notehead(int ss)
{
int
-Notehead::compare(Notehead*&a, Notehead*&b)
+Notehead::compare(Notehead *const &a, Notehead * const &b)
{
return a->position - b->position;
}
Molecule*
Notehead::brew_molecule_p() const return out;
{
- Paperdef *p = paper();
+ Paper_def *p = paper();
Real dy = p->internote();
Symbol s = p->lookup_p_->ball(balltype);
--- /dev/null
+#include <math.h>
+#include "misc.hh"
+#include "paper-def.hh"
+#include "debug.hh"
+#include "lookup.hh"
+#include "dimen.hh"
+
+
+
+// golden ratio
+const Real PHI = (1+sqrt(5))/2;
+
+// see Roelofs, p. 57
+Real
+Paper_def::duration_to_dist(Moment d)
+{
+ if (!d)
+ return 0;
+
+ return whole_width * pow(geometric_, log_2(d));
+}
+
+Real
+Paper_def::rule_thickness()const
+{
+ return 0.4 PT;
+}
+
+Paper_def::Paper_def(Lookup *l)
+{
+ lookup_p_ = l;
+ linewidth = 15 *CM_TO_PT; // in cm for now
+ whole_width = 8 * note_width();
+ geometric_ = sqrt(2);
+ outfile = "lelie.out";
+}
+
+Paper_def::~Paper_def()
+{
+ delete lookup_p_;
+}
+Paper_def::Paper_def(Paper_def const&s)
+{
+ lookup_p_ = new Lookup(*s.lookup_p_);
+ geometric_ = s.geometric_;
+ whole_width = s.whole_width;
+ outfile = s.outfile;
+ linewidth = s.linewidth;
+}
+
+void
+Paper_def::set(Lookup*l)
+{
+ assert(l != lookup_p_);
+ delete lookup_p_;
+ lookup_p_ = l;
+}
+
+Real
+Paper_def::interline() const
+{
+ return lookup_p_->ball(4).dim.y.length();
+}
+
+Real
+Paper_def::internote() const
+{
+ return lookup_p_->internote();
+}
+Real
+Paper_def::note_width()const
+{
+ return lookup_p_->ball(4).dim.x.length( );
+}
+Real
+Paper_def::standard_height() const
+{
+ return 20 PT;
+}
+
+void
+Paper_def::print() const
+{
+#ifndef NPRINT
+ mtor << "Paper {width: " << print_dimen(linewidth);
+ mtor << "whole: " << print_dimen(whole_width);
+ mtor << "out: " <<outfile;
+ lookup_p_->print();
+ mtor << "}\n";
+#endif
+}
#include "debug.hh"
#include "lookup.hh"
#include "spanner.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "molecule.hh"
#include "dimen.hh"
#include "scoreline.hh"
#include "pscore.hh"
-#include "tstream.hh"
+#include "tex-stream.hh"
#include "item.hh"
#include "break.hh"
{
for (iter_top(cols,c); c.ok(); )
if (!c->used_b()) {
- delete c.get();
+ delete c.get_p();
} else
c++;
}
cols.bottom().add(p);
}
-PScore::PScore( Paperdef*p)
+PScore::PScore( Paper_def*p)
{
paper_l_ = p;
}
#include "rest.hh"
#include "dimen.hh"
#include "debug.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "lookup.hh"
#include "molecule.hh"
balltype = t;
dots = d;
}
-NAME_METHOD(Rest);
+
void
Rest::do_print()const
Molecule*
Rest::brew_molecule_p()const
{
- Paperdef *p =paper();
+ Paper_def *p =paper();
Symbol s;
s = p->lookup_p_->rest(balltype);
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-#include "tstream.hh"
+#include "tex-stream.hh"
#include "score.hh"
-#include "scorecolumn.hh"
+#include "score-column.hh"
#include "pscore.hh"
#include "staff.hh"
#include "debug.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "main.hh"
#include "source.hh"
-#include "sourcefile.hh"
-#include "scorewalker.hh"
-#include "midioutput.hh"
-#include "mididef.hh"
+#include "source-file.hh"
+#include "score-walker.hh"
+#include "midi-output.hh"
+#include "midi-def.hh"
extern String default_out_fn;
for (iter_top(cols_,c); c.ok(); ) {
if (!c->pcol_l_->used_b()) {
- delete c.get();
+ delete c.get_p();
} else {
c->preprocess();
c++;
}
void
-Score::set(Paperdef *pap_p)
+Score::set(Paper_def *pap_p)
{
delete paper_p_;
paper_p_ = pap_p;
#include "dimen.hh"
#include "spanner.hh"
#include "symbol.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "pcol.hh"
#include "pscore.hh"
#include "main.hh"
-#include "inputscore.hh"
+#include "input-score.hh"
#include "score.hh"
#include "string.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "debug.hh"
static Array<Input_score*> score_array_global;
#include "staff.hh"
#include "score.hh"
#include "voice.hh"
-#include "staffwalker.hh"
-#include "staffcolumn.hh"
-#include "scorecolumn.hh"
-
+#include "staff-walker.hh"
+#include "staff-column.hh"
+#include "score-column.hh"
+#include "voice-element.hh"
#include "debug.hh"
#include "musicalrequest.hh"
#include "commandrequest.hh" // todo
-#include "midistream.hh"
+#include "midi-stream.hh"
void
Staff::add(PointerList<Voice*> const &l)
voice_list_.bottom().add(i);
}
-Paperdef *
+Paper_def *
Staff::paper() const
{
return score_l_->paper_p_;
i->command_column_l_ =0;
if (!i->command_column_l_&& !i->musical_column_l_)
- delete i.get();
+ delete i.get_p();
else
i++;
}
#include "dimen.hh"
#include "spanner.hh"
#include "symbol.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "molecule.hh"
#include "pcol.hh"
#include "pscore.hh"
*/
#include "staffsym.hh"
#include "lookup.hh"
-#include "paperdef.hh"
+#include "paper-def.hh"
#include "debug.hh"
-NAME_METHOD(Staff_symbol);
+
Staff_symbol::Staff_symbol(int l)
{
--- /dev/null
+#include "debug.hh"
+#include "lookup.hh"
+#include "paper-def.hh"
+#include "molecule.hh"
+#include "text-def.hh"
+
+Text_def::Text_def()
+{
+ align_i_ = 1; // right
+ style_str_ = "roman";
+ defined_ch_c_l_ = 0;
+}
+bool
+Text_def::compare(const Text_def&def)
+{
+ return align_i_ == def.align_i_ && text_str_ == def.text_str_
+ && style_str_ == def.style_str_;
+}
+
+Atom
+Text_def::create_atom(Paper_def*p) const
+{
+ return p->lookup_p_->text(style_str_, text_str_, -align_i_);
+}
+
+void
+Text_def::print() const
+{
+ mtor << "Text `" << text_str_ << "\', style " <<
+ style_str_ << "align " << align_i_ << '\n';
+}