From 9f01899559843e90f0211d3f97d48ced74b6f006 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:32:32 +0000 Subject: [PATCH] lilypond-0.0.33 --- hdr/inputmusic.hh | 7 +++++++ hdr/inputscore.hh | 2 ++ hdr/lyricitem.hh | 4 ++-- hdr/lyricstaff.hh | 2 +- hdr/lyricwalker.hh | 10 ++++----- hdr/parseconstruct.hh | 1 + hdr/request.hh | 1 + hdr/score.hh | 7 +++++++ hdr/source.hh | 2 +- hdr/sourcefile.hh | 2 +- hdr/voice.hh | 14 ++++++++++--- input/Makefile | 3 ++- input/scales.ly | 28 +++++++++++++------------- input/standchen.tex | 6 ++---- src/inputmusic.cc | 47 +++++++++++++++++++++++++++++++++++++++++++ src/inputscore.cc | 12 +++++++++++ src/lexer.l | 8 ++++---- src/lyricwalker.cc | 2 +- src/note.cc | 14 ++++++++++++- src/slurreg.cc | 1 + src/source.cc | 8 ++++---- src/voice.cc | 21 +++++++++++++++++++ src/voiceelt.cc | 32 +++++++++++++++++++++++++++++ src/voicegroup.cc | 1 + src/voiceregs.cc | 1 + src/warn.cc | 7 ++++++- 26 files changed, 200 insertions(+), 43 deletions(-) diff --git a/hdr/inputmusic.hh b/hdr/inputmusic.hh index 13e8f4a365..da3030f11b 100644 --- a/hdr/inputmusic.hh +++ b/hdr/inputmusic.hh @@ -29,11 +29,14 @@ struct Voice_list : public PointerList { */ struct Input_music { virtual Voice_list convert()const=0; + void check_plet(Voice_element* velt_l); virtual Moment length()const=0; virtual void translate_time(Moment dt)=0; virtual ~Input_music(){} virtual void print() const =0; virtual void set_default_group(String)=0; + virtual bool find_plet_start_bo(char c, Moment& moment_r) = 0; + virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) = 0; // virtual void transpose(...) const =0; @@ -53,6 +56,8 @@ struct Simple_music : Input_music { virtual Voice_list convert()const; virtual void translate_time(Moment dt); virtual void print() const; + virtual bool find_plet_start_bo(char c, Moment& moment_r); + virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); virtual Input_music *clone() const { return new Simple_music(*this); } @@ -69,6 +74,8 @@ struct Complex_music : Input_music { Complex_music(Complex_music const &); virtual void print() const ; void concatenate(Complex_music*); + virtual bool find_plet_start_bo(char c, Moment& moment_r); + virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); }; diff --git a/hdr/inputscore.hh b/hdr/inputscore.hh index 024c6d132c..3b84d44fdb 100644 --- a/hdr/inputscore.hh +++ b/hdr/inputscore.hh @@ -24,6 +24,7 @@ struct Input_score { /// paper_, staffs_ and commands_ form the problem definition. Paperdef *paper_p_; + Mididef* midi_p_; IPointerList staffs_; Input_music * score_wide_music_p_; @@ -36,6 +37,7 @@ struct Input_score { ~Input_score(); /// construction void set(Paperdef*); + void set(Mididef* midi_p); void print() const; Score*parse(); void set(Input_music*); diff --git a/hdr/lyricitem.hh b/hdr/lyricitem.hh index 5dcd90c889..46873d8f51 100644 --- a/hdr/lyricitem.hh +++ b/hdr/lyricitem.hh @@ -1,7 +1,7 @@ // // lyricitem.hh -- part of LilyPond // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef LYRIC_ITEM_HH #define LYRIC_ITEM_HH @@ -15,5 +15,5 @@ struct Lyric_item : Text_item { }; -#endif // LYRICITEM_HH +#endif // LYRIC_ITEM_HH // diff --git a/hdr/lyricstaff.hh b/hdr/lyricstaff.hh index 31cc62caaa..f7166bfc99 100644 --- a/hdr/lyricstaff.hh +++ b/hdr/lyricstaff.hh @@ -1,7 +1,7 @@ /* lyricstaff.hh -- part of LilyPond - copyright 1997 Jan Nieuwenhuizen + copyright 1997 Jan Nieuwenhuizen */ #ifndef LYRICSTAFF_HH diff --git a/hdr/lyricwalker.hh b/hdr/lyricwalker.hh index 5f413f2ab9..f89be76249 100644 --- a/hdr/lyricwalker.hh +++ b/hdr/lyricwalker.hh @@ -1,8 +1,8 @@ -/* - lyricwalker.hh -- declare Lyric_walker - - (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen -*/ +// +// lyricwalker.hh -- declare Lyric_walker +// +// (c) 1996,97 Han-Wen Nienhuys, Jan Nieuwenhuizen +// #ifndef LYRICWALKER_HH #define LYRICWALKER_HH diff --git a/hdr/parseconstruct.hh b/hdr/parseconstruct.hh index 5ee82774c0..7b9e3e3ec2 100644 --- a/hdr/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -25,6 +25,7 @@ Request* get_request(char); void set_text_style(String); Script_def* get_scriptdef(char); Text_def*get_text(String s); +Request* get_plet_request( char c, int dur_i, int type_i ); Request*get_script_req(int d , Script_def*def); Request*get_text_req(int d , Text_def*def); Request* get_stemdir_req(int); diff --git a/hdr/request.hh b/hdr/request.hh index 56fc3e4ea5..bf94d1a02e 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -45,6 +45,7 @@ struct Request { virtual Rest_req *rest() { return 0; } virtual Span_req *span() { return 0; } virtual Beam_req *beam() { return 0 ; } + virtual Plet_req* plet() { return 0; } virtual Slur_req *slur() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0; } virtual Lyric_req* lreq_l() { return 0; } diff --git a/hdr/score.hh b/hdr/score.hh index f48ad356df..b9555b2036 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -21,6 +21,7 @@ struct Score { /// paper_, staffs_ and commands_ form the problem definition. Paperdef *paper_p_; + Mididef *midi_p_; IPointerList staffs_; /// "runtime" fields for setting up spacing @@ -43,6 +44,12 @@ struct Score { /// output to file void output(String fn); + /// do midi stuff + void midi(); + + /// + void set(Mididef* midi_p); + // standard void OK() const; void print() const; diff --git a/hdr/source.hh b/hdr/source.hh index 063905baaa..3bdbef721e 100644 --- a/hdr/source.hh +++ b/hdr/source.hh @@ -1,7 +1,7 @@ // // source.hh -- part of LilyPond // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef SOURCE_HH #define SOURCE_HH diff --git a/hdr/sourcefile.hh b/hdr/sourcefile.hh index a52e76f66a..36c7aaa575 100644 --- a/hdr/sourcefile.hh +++ b/hdr/sourcefile.hh @@ -1,7 +1,7 @@ // // sourcefile.hh -- declare Source_file // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #ifndef SOURCE_FILE_HH #define SOURCE_FILE_HH diff --git a/hdr/voice.hh b/hdr/voice.hh index 4d282ddea1..4b8e258c1f 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -17,13 +17,17 @@ struct Voice { Moment start; /* *************** */ - Moment when(const Voice_element*)const; - Moment last() const; Voice(); Voice(Voice const&); + + Moment when(const Voice_element*)const; + Moment last() const; + void add(Voice_element*); + bool find_plet_start_bo(char c, Moment& moment_r); void print() const; void set_default_group(String id); + void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); }; /** one horizontal bit. Apart from being a container for the requests, Voice_element is nothing @@ -36,10 +40,14 @@ struct Voice_element { /* *************** */ - void add(Request*); Voice_element(); Voice_element(Voice_element const & src ); + + void add(Request*); + bool find_plet_start_bo(char c, Moment& moment_r); void print ()const; void set_default_group(String id); + void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i); + /// return true when done }; #endif diff --git a/input/Makefile b/input/Makefile index 885dcf19a9..5e7ff85249 100644 --- a/input/Makefile +++ b/input/Makefile @@ -2,7 +2,8 @@ default: ; DISTFILES=Makefile kortjakje.ly pavane.ly maartje.ly\ cadenza.ly scales.ly standchen.ly twinkle.ly\ - wohltemperirt.ly error.ly\ + wohltemperirt.ly\ + error.ly midi.ly plet.ly\ martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\ coriolan-alto.ly rhythm.ly \ standchen.tex pavane.tex scsii-menuetto.tex scsii-menuetto.ly\ diff --git a/input/scales.ly b/input/scales.ly index fba2c9ff4d..d98c1bba43 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -4,25 +4,25 @@ staff {melodic music{ $ \duration { 8 } \octave{ } - \plet { 6/9 } |[ a a a a a a a a a ] \plet { 1/1 } + |[ a a a a a a a a a ] \octave{ ' } - \plet { 6/9 } |[ a a a a a a a a a ] \plet { 1/1 } + |[ a a a a a a a a a ] \octave { ` } - \plet { 6/9 } [ `c `g d a 'e 'b ''f '''c '''g ] \plet { 1/1 } - \plet { 6/9 } [ '''g '''c ''f 'b 'e a d `g `c ] \plet { 1/1 } + [ `c `g d a 'e 'b ''f '''c '''g ] + [ '''g '''c ''f 'b 'e a d `g `c ] \octave{ ' } - \plet { 6/9 } [ `c `g d a 'e 'b ''f '''c '''g ] \plet { 1/1 } - \plet { 6/9 } [ '''g '''c ''f 'b 'e a d `g `c ] \plet { 1/1 } + [ `c `g d a 'e 'b ''f '''c '''g ] + [ '''g '''c ''f 'b 'e a d `g `c ] \octave { } - \plet { 2/3 } [ c g 'd ] \plet { 1/1 } - \plet { 2/3 } [ 'd g c ] \plet { 1/1 } - \plet { 2/3 } [ f 'c 'g ] \plet { 1/1 } - \plet { 2/3 } [ 'g 'c f ] \plet { 1/1 } + [ c g 'd ]2/3 + [ 'd g c ]2/3 + [ f 'c 'g ]2/3 + [ 'g 'c f ]2/3 \octave{ ' } - \plet { 2/3 } [ c g 'd ] \plet { 1/1 } - \plet { 2/3 } [ 'd g c ] \plet { 1/1 } - \plet { 2/3 } [ f 'c 'g ] \plet { 1/1 } - \plet { 2/3 } [ 'g 'c f ] \plet { 1/1 } + [ c g 'd ]2/3 + [ 'd g c ]2/3 + [ f 'c 'g ]2/3 + [ 'g 'c f ]2/3 c1 \duration { 8} diff --git a/input/standchen.tex b/input/standchen.tex index 9c87c4cc90..4b19a6aef5 100644 --- a/input/standchen.tex +++ b/input/standchen.tex @@ -10,10 +10,8 @@ \begin{document} \input lilyponddefs \input titledefs -%\def\interstaffline{\vskip10pt} -%\def\interscoreline{\vskip12pt} -\def\interstaffline{\vskip1mm} -\def\interscoreline{\vskip2mm} +\def\interstaffline{\vskip2mm} +\def\interscoreline{\vskip3mm} \vbox to 10mm{\vss} \title{St\"andchen\normalsize\\[2ex](Serenade)} \composer{Franz Schubert (1797-1828)} diff --git a/src/inputmusic.cc b/src/inputmusic.cc index 05918a1a5f..8f3ca2cb93 100644 --- a/src/inputmusic.cc +++ b/src/inputmusic.cc @@ -3,6 +3,23 @@ #include "voice.hh" #include "musicalrequest.hh" +void +Input_music::check_plet(Voice_element* velt_l) +{ + for (iter_top(velt_l->reqs,i); i.ok(); i++) + if ( i->plet() ) { + Moment start_moment = 0.0; + if ( !find_plet_start_bo( i->plet()->type_c_, start_moment ) ) { + error( "begin of plet not found", i->defined_ch_c_l_ ); + break; + } + Moment moment = 0.0; + set_plet_backwards( moment, start_moment, i->plet()->dur_i_, i->plet()->type_i_ ); + i.del(); + break; + } +} + void Simple_music::add(Voice_element*v) { @@ -36,6 +53,16 @@ Simple_music::print() const voice_.print(); mtor << "}\n"; } +bool +Simple_music::find_plet_start_bo(char c, Moment& moment_r) +{ + return voice_.find_plet_start_bo(c, moment_r); +} +void +Simple_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +{ + voice_.set_plet_backwards(now_moment_r, until_moment, num_i, den_i); +} /* *************** */ @@ -74,6 +101,22 @@ Complex_music::set_default_group(String g) for (iter_top(elts,i); i.ok(); i++) i->set_default_group(g); } +bool +Complex_music::find_plet_start_bo(char c, Moment& moment_r) +{ + for (iter_bot(elts,i); i.ok(); i--) { + if ( i->find_plet_start_bo(c, moment_r) ) + return true; + } + return false; +} +void +Complex_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +{ + for (iter_bot(elts,i); i.ok(); i--) { + i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i); + } +} /* *************************************************************** */ void @@ -97,6 +140,8 @@ Music_voice::add_elt(Voice_element*v) c = elts.bottom(); Simple_music *s = c->simple(); s->add(v); + + check_plet(v); } Moment @@ -142,6 +187,8 @@ Music_general_chord::add_elt(Voice_element*v) Simple_music*vs = new Simple_music; vs->add(v); elts.bottom().add(vs); + + check_plet(v); } void diff --git a/src/inputscore.cc b/src/inputscore.cc index a8a653982c..82d7a6c96a 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -12,6 +12,7 @@ #include "inputmusic.hh" #include "score.hh" #include "paperdef.hh" +#include "mididef.hh" #include "staff.hh" @@ -28,6 +29,13 @@ Input_score::set(Paperdef*p) paper_p_ = p; } +void +Input_score::set(Mididef* midi_p) +{ + delete midi_p_; + midi_p_ = midi_p; +} + Input_score::Input_score(Input_score const&s) { paper_p_ = (s.paper_p_)? new Paperdef(*s.paper_p_) :0; @@ -44,6 +52,8 @@ Input_score::parse() Score *s_p = new Score(paper_p); s_p->defined_ch_c_l_= defined_ch_c_l_; s_p->errorlevel_i_ = errorlevel_i_; + s_p->set(midi_p_); + midi_p_ = 0; for (iter_top(staffs_,i); i.ok(); i++) { Staff* staf_p=i->parse(s_p, score_wide_music_p_); @@ -65,6 +75,7 @@ Input_score::~Input_score() { delete paper_p_; delete score_wide_music_p_; + delete midi_p_; } Input_score::Input_score() @@ -72,6 +83,7 @@ Input_score::Input_score() score_wide_music_p_ =0; defined_ch_c_l_=0; paper_p_= 0; + midi_p_ = 0; errorlevel_i_ = 0; } diff --git a/src/lexer.l b/src/lexer.l index f0652ac6c7..1e4e8488a5 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -179,11 +179,11 @@ COMMENT [%#].*\n {LYRICS} { String s (YYText()); int i = 0; - while ((i=s.pos("_")) != 0)// ugh. Whats this. - *((char*)s.cptr() + i - 1) = ' '; - if ((i=s.pos("\\,")) !=0) + while ((i=s.pos("_")) != 0) // change word binding "_" to " " + *(s.ch_l() + i - 1) = ' '; + if ((i=s.pos("\\,")) !=0) // change "\," to TeX's "\c " { - *((char*)s.cptr() + i) = 'c'; + *(s.ch_l() + i) = 'c'; s = s.left(i+1) + " " + s.right(s.len()-i-1); } yylval.string = new String(s); diff --git a/src/lyricwalker.cc b/src/lyricwalker.cc index 960c1e76e0..51a2b03594 100644 --- a/src/lyricwalker.cc +++ b/src/lyricwalker.cc @@ -3,7 +3,7 @@ source file of the LilyPond music typesetter - (c) 1997 Jan Nieuwenhuizen + (c) 1997 Jan Nieuwenhuizen */ #include "musicalrequest.hh" diff --git a/src/note.cc b/src/note.cc index 2a89743e95..95a7d8313d 100644 --- a/src/note.cc +++ b/src/note.cc @@ -14,6 +14,7 @@ #include "varray.hh" #include "textdef.hh" #include "parseconstruct.hh" +#include "inputmusic.hh" int default_duration = 4, default_dots=0, default_octave=0; int default_plet_type = 1, default_plet_dur = 1; @@ -36,7 +37,8 @@ last_duration(int n) } /* triplet is '2/3' */ -void set_plet(int num,int den) +void +set_plet(int num,int den) { assert(num >0&& den>0); default_plet_dur = num; @@ -193,6 +195,16 @@ set_default_octave(String d) parse_octave(d, i, default_octave); } +Request* +get_plet_request( char c, int dur_i, int type_i ) +{ + Plet_req* plet_req_p = new Plet_req; + plet_req_p->dur_i_ = dur_i; + plet_req_p->type_i_ = type_i; + plet_req_p->type_c_ = c; + return plet_req_p; +} + Request* get_request(char c) { diff --git a/src/slurreg.cc b/src/slurreg.cc index 48f60878be..d1eb312d85 100644 --- a/src/slurreg.cc +++ b/src/slurreg.cc @@ -4,6 +4,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "plist.hh" #include "musicalrequest.hh" #include "complexwalker.hh" #include "slurreg.hh" diff --git a/src/source.cc b/src/source.cc index 34f1a8808f..519a6fe96a 100644 --- a/src/source.cc +++ b/src/source.cc @@ -28,9 +28,9 @@ Source::add( Source_file* sourcefile_p ) Source_file* Source::sourcefile_l( char const* ch_c_l ) { - PCursor sourcefile_p_pcur( sourcefile_p_iplist_.top() ); - for ( ; sourcefile_p_pcur.ok(); sourcefile_p_pcur++ ) - if ( sourcefile_p_pcur->in_b( ch_c_l ) ) - return *sourcefile_p_pcur; + PCursor sourcefile_l_pcur( sourcefile_p_iplist_.top() ); + for ( ; sourcefile_l_pcur.ok(); sourcefile_l_pcur++ ) + if ( sourcefile_l_pcur->in_b( ch_c_l ) ) + return *sourcefile_l_pcur; return 0; } diff --git a/src/voice.cc b/src/voice.cc index 3dd4becf21..718e7cb6d1 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -10,6 +10,8 @@ #include "voice.hh" #include "musicalrequest.hh" #include "commandrequest.hh" +#include "midiitem.hh" +#include "midistream.hh" void Voice::set_default_group(String s) @@ -17,6 +19,25 @@ Voice::set_default_group(String s) elts.top()->set_default_group(s); } +bool +Voice::find_plet_start_bo(char c, Moment& moment_r) +{ + for (iter_bot(elts, i); i.ok(); i--) + if ( i->find_plet_start_bo(c, moment_r) ) + return true; + return false; +} + +void +Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +{ + for (iter_bot(elts, i); i.ok(); i--) + if ( now_moment_r <= until_moment ) + i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i); + else + return; +} + Voice::Voice(Voice const&src) { for (iter_top(src.elts, i); i.ok(); i++) diff --git a/src/voiceelt.cc b/src/voiceelt.cc index 72ba0a77d5..670dcdfaaa 100644 --- a/src/voiceelt.cc +++ b/src/voiceelt.cc @@ -53,6 +53,20 @@ Voice_element::Voice_element(Voice_element const&src) add(i->clone()); } +bool +Voice_element::find_plet_start_bo(char c, Moment& moment_r) +{ + assert( c == ']' ); + moment_r += duration; + for ( PCursor req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) { + if (req_l_pcur->melodic()) + mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n"; + if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START ) + return true; + } + return false; +} + void Voice_element::set_default_group(String s) { @@ -63,3 +77,21 @@ Voice_element::set_default_group(String s) greq->newgroup_str_ = s; add(greq); } + +void +Voice_element::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) +{ + now_moment_r += duration; + if ( now_moment_r > until_moment ) + return; + for ( PCursor req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) { + if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START ) + req_l_pcur->beam()->nplet = den_i; + if (req_l_pcur->rhythmic()) + req_l_pcur->rhythmic()->plet_factor = Moment(num_i, den_i); + if (req_l_pcur->stem()) + req_l_pcur->stem()->plet_factor = Moment(num_i, den_i); + if (req_l_pcur->melodic()) + mtor << (char)('c' + req_l_pcur->melodic()->height()) << "\n"; + } +} diff --git a/src/voicegroup.cc b/src/voicegroup.cc index 4f622c9384..0674ee08c8 100644 --- a/src/voicegroup.cc +++ b/src/voicegroup.cc @@ -6,6 +6,7 @@ (c) 1997 Han-Wen Nienhuys */ +#include "plist.hh" #include "musicalrequest.hh" #include "voicegroup.hh" #include "register.hh" diff --git a/src/voiceregs.cc b/src/voiceregs.cc index 4eba8c55f7..d6c24cd674 100644 --- a/src/voiceregs.cc +++ b/src/voiceregs.cc @@ -66,3 +66,4 @@ Voice_registers::set_dir(int i) head_reg_->set_dir(i); slur_reg_->set_dir(i); } + diff --git a/src/warn.cc b/src/warn.cc index 46d779e10f..63490de581 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -72,5 +72,10 @@ void error( String message_str, char const* context_ch_c_l ) { message( message_str, context_ch_c_l ); - exit( 1 ); + // since when exits error again? + // i-d say: error: errorlevel |= 1; -> no output upon error + // warning: recovery -> output (possibly wrong) + if ( lexer ) + lexer->errorlevel_i_ |= 1; +// exit( 1 ); } -- 2.39.5