From: fred Date: Wed, 4 Dec 1996 19:43:25 +0000 (+0000) Subject: lilypond-0.0.14 X-Git-Tag: release/1.5.59~6674 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0877af2b201f926077e46fcde3be98c7f08d2dca;p=lilypond.git lilypond-0.0.14 --- diff --git a/hdr/getcommand.hh b/hdr/getcommand.hh index b1af2699e2..eb6f624966 100644 --- a/hdr/getcommand.hh +++ b/hdr/getcommand.hh @@ -1,8 +1,16 @@ -Command*get_clef_interpret_command(String w); -Command *get_bar_command(Real); -Command* get_meterchange_command( int,int); +/* + getcommand.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef GETCOMMAND_HH +#define GETCOMMAND_HH +#include "proto.hh" + + Command* get_meter_command( Real,int,int); -Command* get_skip_command( int,Real); -Command* get_key_interpret_command(svec); -Command *get_reset_command(); -Command*get_partial_command(Real u); + + + +#endif // GETCOMMAND_HH diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh index 8222f9b74f..083c830aa9 100644 --- a/hdr/inputcommands.hh +++ b/hdr/inputcommands.hh @@ -11,7 +11,8 @@ #include "plist.hh" #include "real.hh" -struct Input_cursor : public PCursor + +struct Input_cursor : public PCursor { /// current measure info Real whole_per_measure; @@ -24,22 +25,22 @@ struct Input_cursor : public PCursor int bars; - Input_cursor(PCursor); + Input_cursor(PCursor); /// hmm. not safe. Should rethink cursor. void operator++(int); /** warning: no optor -- () defined.. */ void reset(); Real when()const; - void add(Command*); + void add(Input_command*); void setpartial(Real); - void addbot(Command*); + void addbot(Input_command*); void sync(); void print()const; void last_command_here(); }; /// the list of commands in Score -struct Input_commands : public IPointerList { +struct Input_commands : public IPointerList { Input_cursor ptr; /****************/ @@ -50,7 +51,7 @@ struct Input_commands : public IPointerList { Input_commands(); Input_commands(Input_commands const&); - void add(Command*); + void add(Input_command); void reset(); void print()const; Staff_commands *parse() const; @@ -58,7 +59,7 @@ struct Input_commands : public IPointerList { void -interpret_meter(Command *c, int &beats_per_meas, int& one_beat, +interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, Real& whole_per_measure); #endif // INPUTCOMMANDS_HH diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh new file mode 100644 index 0000000000..a34e6d9579 --- /dev/null +++ b/hdr/inputscore.hh @@ -0,0 +1,29 @@ +#ifndef ISCORE_HH +#define ISCORE_HH +#include "vray.hh" +#include "proto.hh" +#include "plist.hh" + + +/// the total music def of one movement +struct Input_score { + /// paper_, staffs_ and commands_ form the problem definition. + Paperdef *paper_; + IPointerList staffs_; + IPointerList commands_; + + /****************************************************************/ + Input_score(); + Input_score(Input_score&); + void add(svec &s); + void add(Input_staff*); + ~Input_score(); + /// construction + void set(Paperdef*); + void print() const; + Score*parse(); +}; +/** + + */ +#endif diff --git a/src/inputscore.cc b/src/inputscore.cc new file mode 100644 index 0000000000..89ec2bd4e9 --- /dev/null +++ b/src/inputscore.cc @@ -0,0 +1,61 @@ +#include "debug.hh" +#include "inputcommand.hh" +#include "inputscore.hh" +#include "inputstaff.hh" +#include "score.hh" +#include "paper.hh" + +void +Input_score::add(svec &s) +{ + commands_.bottom().add(get_reset_command()); + for (int i=0; i < s.sz(); i++) + commands_.bottom().add(s[i]); +} + +void +Input_score::add(Input_staff*s) +{ + staffs_.bottom().add(s); +} + +void +Input_score::set(Paperdef*p) +{ + delete paper_; + paper_ = p; +} + +Score* +Input_score::parse() +{ + Paperdef* p=new Paperdef(*paper_); + Score *s = new Score(p); + + for (PCursor i(staffs_); i.ok(); i++) { + Staff* staf=i->parse(commands_); + s->add(staf); + } + return s; +} + +Input_score::~Input_score() +{ + // should fix paper/symtabs to allow this deletion. +// delete paper_; +} + +Input_score::Input_score() +{ + paper_=new Paperdef; +} + +void +Input_score::print()const +{ + mtor << "Input_score {\n"; + for (PCursor i(staffs_); i.ok(); i++) { + i->print(); + } + mtor << "}\n"; +} diff --git a/src/inputstaff.cc b/src/inputstaff.cc new file mode 100644 index 0000000000..2337f6ae2d --- /dev/null +++ b/src/inputstaff.cc @@ -0,0 +1,79 @@ +#include "getcommand.hh" +#include "debug.hh" +#include "inputmusic.hh" +#include "inputstaff.hh" +#include "inputcommands.hh" +#include "inputcommand.hh" +#include "staffcommands.hh" +#include "melodicstaff.hh" +#include "rhythmstaff.hh" +#include "staff.hh" + +void +Input_staff::add(svec &s) +{ + commands_.bottom().add(get_reset_command()); + for (int i=0; i < s.sz(); i++) + commands_.bottom().add(s[i]); + s.set_size(0); +} + +Input_staff::Input_staff(String s) +{ + type= s; +} + +void +Input_staff::add(Horizontal_music*m) +{ + music_.bottom().add(m); +} + +Staff* +Input_staff::parse(PointerList score_wide) +{ + Staff *p=0; + + if (type == "melodic") + p = new Melodic_staff; + else if (type == "rhythmic") + p = new Rhythmic_staff; + + for (PCursor i(music_); i.ok(); i++) { + Voice_list vl = i->convert(); + p->add(vl); + } + + Input_commands commands; + for (PCursor i(score_wide); i.ok(); i++) + commands.add(**i); + for (PCursor i(commands_); i.ok(); i++) + commands.add(**i); + + p->staff_commands_ = commands.parse(); + + return p; +} + +Input_staff::Input_staff(Input_staff&s) +{ + for (PCursor i(s.commands_); i.ok(); i++) + commands_.bottom().add(new Input_command(**i)); + for (PCursor i(s.music_); i.ok(); i++) + add(i); + + type = s.type; +} + +void +Input_staff::print() const +{ +#ifndef NPRINT + mtor << "Input_staff {\n"; + for (PCursor i(commands_); i.ok(); i++) + i->print(); + for (PCursor i(music_); i.ok(); i++) + i->print(); + mtor << "}\n"; +#endif +} diff --git a/src/template3.cc b/src/template3.cc index 80921422fa..d9c85526d7 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -1,4 +1,8 @@ #include "command.hh" +#include "inputscore.hh" +#include "inputstaff.hh" +#include "inputmusic.hh" +#include "inputcommand.hh" #include "molecule.hh" #include "plist.cc"