From: fred Date: Sun, 24 Mar 2002 19:54:17 +0000 (+0000) Subject: lilypond-0.1.9 X-Git-Tag: release/1.5.59~4088 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=34663f79896f995d1c16473b9cd8aeccedc48f77;p=lilypond.git lilypond-0.1.9 --- diff --git a/lib/duration.cc b/lib/duration.cc index fab55e756c..c26699c5bd 100644 --- a/lib/duration.cc +++ b/lib/duration.cc @@ -22,22 +22,25 @@ int Duration::division_1_i_s = 384 * 4; Duration::Duration() { - type_i_ = 1; - dots_i_ = 0; - ticks_i_ = 0; + durlog_i_ = 0; + dots_i_ = 0; + ticks_i_ = 0; +} + +Duration::Duration( int type_i, int dots_i = 0 ) +{ + durlog_i_ = type_i; + dots_i_ = dots_i; + ticks_i_ = 0; } bool Duration::duration_type_b(int t) { - int bit_i=0; - while (t > 0) - { - int rem = t % 2; - t /= 2; - bit_i += (rem == 1); - } - return bit_i == 1; + /* + ugh. Assuming behavior of conversion funcs on broken input. + */ + return t == Duration_convert::type2_i( Duration_convert::i2_type(t)); } // ugh, what's this? @@ -45,58 +48,40 @@ Duration::duration_type_b(int t) Moment Duration::length() const { - return Duration_convert::dur2_mom(*this); + return Duration_convert::dur2_mom(*this); } void Duration::set_plet(int i, int t) { - plet_.iso_i_ = i; - plet_.type_i_ = t; + plet_.iso_i_ = i; + plet_.type_i_ = t; } void Duration::set_plet(Duration d) { - plet_.iso_i_ = d.plet_.iso_i_; - plet_.type_i_ = d.plet_.type_i_; + plet_.iso_i_ = d.plet_.iso_i_; + plet_.type_i_ = d.plet_.type_i_; } void Duration::set_ticks( int ticks_i ) { - assert( !type_i_ ); - assert( !dots_i_ ); - ticks_i_ = ticks_i; + assert( durlog_i_ <10 ); + assert( !dots_i_ ); + ticks_i_ = ticks_i; } String Duration::str()const { - return Duration_convert::dur2_str(*this); + return Duration_convert::dur2_str(*this); } -Plet::Plet() -{ - type_i_ = 1; - iso_i_ = 1; -} - -Moment -Plet::mom()const -{ - return Moment( iso_i_, type_i_ ); -} bool Duration::plet_b() { - return !plet_.unit_b(); + return !plet_.unit_b(); } - -bool -Plet::unit_b()const -{ - return type_i_ == 1 && iso_i_ == 1; -} - diff --git a/lib/include/plet.hh b/lib/include/plet.hh new file mode 100644 index 0000000000..1f1033f87b --- /dev/null +++ b/lib/include/plet.hh @@ -0,0 +1,27 @@ +/* + plet.hh -- declare Plet + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + + +#ifndef PLET_HH +#define PLET_HH +#include "moment.hh" + +/** + The type and replacement value of a plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3. + + (plet) + */ +struct Plet { + Plet(); + Moment mom()const; + bool unit_b()const; + int iso_i_; // 2/3; 2 is not duration, maar of count! + int type_i_; +}; + +#endif // PLET_HH diff --git a/lib/plet.cc b/lib/plet.cc new file mode 100644 index 0000000000..73df524f7d --- /dev/null +++ b/lib/plet.cc @@ -0,0 +1,29 @@ +/* + plet.cc -- implement Plet + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "plet.hh" + + +Plet::Plet() +{ + type_i_ = 1; + iso_i_ = 1; +} + +Moment +Plet::mom()const +{ + return Moment( iso_i_, type_i_ ); +} + +bool +Plet::unit_b()const +{ + return type_i_ == 1 && iso_i_ == 1; +} + diff --git a/lily/command-request.cc b/lily/command-request.cc index 1c77d60f0f..051ce84465 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -24,21 +24,21 @@ void Cadenza_req::do_print()const { #ifndef NPRINT - DOUT << on_b_; + DOUT << on_b_; #endif } bool Cadenza_req::do_equal_b (Request*r)const { - Cadenza_req*cad = r->command()->timing ()->cadenza (); - - return cad->on_b_ == on_b_; + Cadenza_req*cad = r->command()->timing ()->cadenza (); + + return cad->on_b_ == on_b_; } Cadenza_req::Cadenza_req (bool b) { - on_b_ =b; + on_b_ =b; } /* *************** */ @@ -46,8 +46,8 @@ Cadenza_req::Cadenza_req (bool b) bool Bar_req::do_equal_b (Request*r)const { - Bar_req * b = r->command()->bar (); - return type_str_ == b->type_str_; + Bar_req * b = r->command()->bar (); + return type_str_ == b->type_str_; } @@ -56,25 +56,25 @@ IMPLEMENT_IS_TYPE_B1(Bar_req,Command_req); void Bar_req::do_print() const { - DOUT << type_str_; + DOUT << type_str_; } Bar_req::Bar_req (String s) { - type_str_ = s; + type_str_ = s; } Partial_measure_req::Partial_measure_req (Moment m) { - duration_ =m; + duration_ =m; } bool Partial_measure_req::do_equal_b (Request* r)const { - Partial_measure_req *p = r->command()->timing ()->partial (); + Partial_measure_req *p = r->command()->timing ()->partial (); - return p->duration_ == duration_; + return p->duration_ == duration_; } @@ -105,7 +105,7 @@ Barcheck_req::do_print() const{} bool Barcheck_req::do_equal_b (Request*)const { - return true; + return true; } /* *************** */ @@ -115,13 +115,13 @@ void Clef_change_req::do_print() const { #ifndef NPRINT - DOUT << clef_str_ ; + DOUT << clef_str_ ; #endif } Clef_change_req::Clef_change_req (String s) { - clef_str_ = s; + clef_str_ = s; } /* *************** */ @@ -131,7 +131,7 @@ void Group_feature_req::do_print() const { #ifndef NPRINT - DOUT << type_str_ << "=" << value_str_; + DOUT << type_str_ << "=" << value_str_; #endif } @@ -143,7 +143,7 @@ IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req); void Partial_measure_req::do_print() const { - DOUT << duration_; + DOUT << duration_; } @@ -153,52 +153,52 @@ void Meter_change_req::do_print() const { #ifndef NPRINT - DOUT << beats_i_ << "/" << one_beat_i_; + DOUT << beats_i_ << "/" << one_beat_i_; #endif } bool Meter_change_req::do_equal_b (Request * r)const { - Meter_change_req * m = r->command()->timing ()->meterchange (); - - return m->beats_i_ == beats_i_ + Meter_change_req * m = r->command()->timing ()->meterchange (); + + return m->beats_i_ == beats_i_ && one_beat_i_ == m->one_beat_i_; } Meter_change_req::Meter_change_req() { - beats_i_ = 0; - one_beat_i_ =0; + beats_i_ = 0; + one_beat_i_ =0; } void Meter_change_req::set (int b,int o) { - beats_i_=b; - one_beat_i_=o; + beats_i_=b; + one_beat_i_=o; } Tempo_req::Tempo_req() { - metronome_i_ = 60; - dur_. type_i_ = 4; + metronome_i_ = 60; + dur_. durlog_i_ = 2; } void Tempo_req::do_print()const { - DOUT << dur_.str() << " = " <transpose (d); } } @@ -237,7 +239,8 @@ IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req); void Key_change_req::squash_octaves() { - for (int i=0; i < melodic_p_arr_.size(); i++) { + for (int i=0; i < melodic_p_arr_.size(); i++) + { melodic_p_arr_[i]->octave_i_ = 0; } } @@ -246,7 +249,8 @@ void Key_change_req::do_print() const { #ifndef NPRINT - for (int i=0; i < melodic_p_arr_.size(); i++) { + for (int i=0; i < melodic_p_arr_.size(); i++) + { melodic_p_arr_[i]->print(); } #endif @@ -276,12 +280,13 @@ int Key_change_req::flats_i() { int flats_i = 0; - for ( int i = 0; i < melodic_p_arr_.size(); i++) { + for ( int i = 0; i < melodic_p_arr_.size(); i++) + { Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert (mel_l); if ( mel_l->accidental_i_ < 0) flats_i -= mel_l->accidental_i_; - } + } return flats_i; } @@ -295,12 +300,13 @@ int Key_change_req::sharps_i() { int sharps_i = 0; - for ( int i = 0; i < melodic_p_arr_.size(); i++) { + for ( int i = 0; i < melodic_p_arr_.size(); i++) + { Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert (mel_l); if ( mel_l->accidental_i_ > 0) sharps_i+= mel_l->accidental_i_; - } + } return sharps_i; } diff --git a/lily/identifier.cc b/lily/identifier.cc index ff75e93311..ad7f5de1f4 100644 --- a/lily/identifier.cc +++ b/lily/identifier.cc @@ -24,36 +24,36 @@ IMPLEMENT_IS_TYPE_B(Identifier); Identifier::~Identifier() { - if (!accessed_b_ && !init_b_) + if (!accessed_b_ && !init_b_) warning ("Variable not used"); } void Identifier::error (String expect) { - String e ("Wrong identifier type: "); - e += String (name()) + "(expected " + expect + ")"; - ::error (e); + String e ("Wrong identifier type: "); + e += String (name()) + "(expected " + expect + ")"; + ::error (e); } Identifier::Identifier ( int code) { - token_code_i_ = code; - accessed_b_ = 0; - init_b_ = 0; + token_code_i_ = code; + accessed_b_ = 0; + init_b_ = 0; } void Identifier::print()const { - DOUT << "identifier "; - do_print(); + DOUT << "identifier "; + do_print(); } /* ugh. */ #define DEFAULT_PRINT(Class, Content_type, accessor) \ void \ Class::do_print() const { \ - ((Class*)this)->accessor()->print(); \ + ((Class*)this)->accessor()->print(); \ } \ class Class @@ -68,24 +68,29 @@ DEFAULT_PRINT(Score_id, Score, score); DEFAULT_PRINT(Midi_def_id,Midi_def, mididef); DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef); + +void +Duration_id::do_print()const +{} + void Real_id::do_print() const { - DOUT << *data_p_<< "\n"; + DOUT << *data_p_<< "\n"; } void Int_id::do_print() const { - DOUT << *data_p_<< "\n"; + DOUT << *data_p_<< "\n"; } #define DEFAULT_ACCESSOR(Idclass, Class, accessor)\ Class*\ Idclass::accessor () {\ - accessed_b_ = true;\ - return new Class (*data_p_);\ + accessed_b_ = true;\ + return new Class (*data_p_);\ } #define VIRTUAL_ACCESSOR(Idclass, Class, accessor)\ @@ -100,7 +105,7 @@ Idclass::accessor () {\ Idclass::~Idclass() { delete data_p_; }\ Idclass::Idclass (Class*st, int code):Identifier (code) { data_p_ = st; }\ - +IMPLEMENT_ID_CLASS(Duration_id, Duration, duration); IMPLEMENT_ID_CLASS(Input_translator_id, Input_translator, input_translator); IMPLEMENT_ID_CLASS(Int_id, int, intid); IMPLEMENT_ID_CLASS(Real_id, Real, real); @@ -115,9 +120,10 @@ IMPLEMENT_ID_CLASS(Paper_def_id, Paper_def, paperdef); Identifier::Identifier (Identifier const&) { - assert (false); + assert (false); } +DEFAULT_ACCESSOR(Duration_id, Duration, duration); DEFAULT_ACCESSOR(Input_translator_id,Input_translator, input_translator); DEFAULT_ACCESSOR(Int_id, int, intid); DEFAULT_ACCESSOR(Real_id, Real, real); diff --git a/lily/include/identifier.hh b/lily/include/identifier.hh index 08e8346e80..dd4b8f75f8 100644 --- a/lily/include/identifier.hh +++ b/lily/include/identifier.hh @@ -42,6 +42,7 @@ struct Identifier : public Input { IDACCESSOR(Request, request) IDACCESSOR(Score, score) IDACCESSOR(int, intid) + IDACCESSOR(Duration, duration) protected: virtual void do_print()const=0; @@ -61,6 +62,7 @@ struct Idclass : Identifier {\ DECLARE_ID_CLASS(Input_translator_id, Input_translator, input_translator); +DECLARE_ID_CLASS(Duration_id, Duration, duration); DECLARE_ID_CLASS(Real_id, Real, real); DECLARE_ID_CLASS(Script_id, General_script_def, script); DECLARE_ID_CLASS(Lookup_id, Lookup, lookup);