source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "command-request.hh"
bool
Cadenza_req::do_equal_b (Request*r) const
{
- Cadenza_req*cad = r->command()->timing ()->cadenza ();
+ Cadenza_req*cad = r->access_Command_req ()->access_Timing_req ()->access_Cadenza_req ();
return cad->on_b_ == on_b_;
}
{
on_b_ =b;
}
-/* *************** */
+
bool
Bar_req::do_equal_b (Request*r) const
{
- Bar_req * b = r->command()->bar ();
+ Bar_req * b = r->access_Command_req ()->access_Bar_req ();
return type_str_ == b->type_str_;
}
bool
Partial_measure_req::do_equal_b (Request* r) const
{
- Partial_measure_req *p = r->command()->timing ()->partial ();
+ Partial_measure_req *p = r->access_Command_req ()->access_Timing_req ()->access_Partial_measure_req ();
return p->duration_ == duration_;
}
{
return true;
}
-/* *************** */
+
IMPLEMENT_IS_TYPE_B1(Clef_change_req,Command_req);
clef_str_ = s;
}
-/* *************** */
+
IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req);
}
-IMPLEMENT_IS_TYPE_B1(Meter_change_req,Timing_req);
+IMPLEMENT_IS_TYPE_B1(Time_signature_change_req,Timing_req);
void
-Meter_change_req::do_print() const
+Time_signature_change_req::do_print() const
{
#ifndef NPRINT
DOUT << beats_i_ << "/" << one_beat_i_;
}
bool
-Meter_change_req::do_equal_b (Request * r) const
+Time_signature_change_req::do_equal_b (Request * r) const
{
- Meter_change_req * m = r->command()->timing ()->meterchange ();
+ Time_signature_change_req * m = r->access_Command_req ()->access_Timing_req ()->access_Time_signature_change_req ();
return m->beats_i_ == beats_i_
&& one_beat_i_ == m->one_beat_i_;
}
-Meter_change_req::Meter_change_req()
+Time_signature_change_req::Time_signature_change_req()
{
beats_i_ = 0;
one_beat_i_ =0;
}
-void
-Meter_change_req::set (int b,int o)
-{
- beats_i_=b;
- one_beat_i_=o;
-}
-
Tempo_req::Tempo_req()
{
void
Tempo_req::do_print() const
{
- DOUT << dur_.str() << " = " <<metronome_i_ ;
+ DOUT << dur_.str() << " = " << metronome_i_;
}
IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
bool
Tempo_req::do_equal_b (Request *r) const
{
- Tempo_req *t = r->command()->timing ()->tempo ();
+ Tempo_req *t = r->access_Command_req ()->access_Timing_req ()->access_Tempo_req ();
return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
}
-/* *************** */
+
IMPLEMENT_IS_TYPE_B1(Measure_grouping_req,Timing_req);
{
for (int i=0; i < elt_length_arr_.size(); i++)
{
- DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
+ DOUT << beat_i_arr_[i] << "*" << elt_length_arr_[i].str () << " ";
}
}
return false; // todo
}
-/* *************** */
-
void
-Key_change_req::transpose (Musical_pitch d) const
+Key_change_req::transpose (Musical_pitch d)
{
- WARN << _("don't know how to transpose a key. \n"); // TODO!
+ if (ordinary_key_b_ )
+ {
+ if (pitch_arr_.size () > 0)
+ pitch_arr_[0].transpose(d);
+ else
+ {
+ warning(_ ("don't know how handle empty keys")); // TODO
+ }
+ }
+ else
+ {
+ Array<Musical_pitch> old_pitch_arr_;
+ for (int i = 0; i < pitch_arr_.size(); i++)
+ {
+ old_pitch_arr_.push(pitch_arr_[i]);
+ }
+ // set accidentals for \key d (as in Key_engraver::read_req)
+ // (later called "new accidentals")
+ int p = d.semitone_pitch ();
+ /* Solve the equation 7*no_of_acc mod 12 = p, -6 <= no_of_acc <= 5 */
+ int no_of_acc = (7*p) % 12;
+ no_of_acc = (no_of_acc + 18) % 12 -6;
+
+ /* Correct from flats to sharps or vice versa */
+ if (no_of_acc * d.accidental_i_ < 0)
+ no_of_acc += 12 * sign (d.accidental_i_);
+
+ pitch_arr_.clear ();
+ if (no_of_acc < 0)
+ {
+ int accidental = 6 ; // First accidental: bes
+ for ( ; no_of_acc < 0 ; no_of_acc++ )
+ {
+ Musical_pitch m;
+ m.accidental_i_ = -1;
+ m.notename_i_ = accidental;
+ pitch_arr_.push(m);
+
+ accidental = (accidental + 3) % 7 ;
+ }
+ }
+ else
+ {
+ int accidental = 3 ; // First accidental: fis
+ for ( ; no_of_acc > 0 ; no_of_acc-- )
+ {
+ Musical_pitch m;
+ m.accidental_i_ = 1;
+ m.notename_i_ = accidental;
+ pitch_arr_.push(m);
+
+ accidental = (accidental + 4) % 7 ;
+ }
+ }
+ // Check if transposed old accidentals and the new ones coincide
+ no_of_acc = pitch_arr_.size();
+ int acc_found;
+ Musical_pitch mm;
+ for (int i=0; i < old_pitch_arr_.size(); i++)
+ {
+ acc_found = 0;
+ mm = old_pitch_arr_[i];
+ mm.transpose(d);
+ for (int j=0; ((j < no_of_acc) && (acc_found == 0)); j++)
+ {
+ if (pitch_arr_[j].notename_i_ == mm.notename_i_)
+ {
+ if (mm.accidental_i_ == 0)
+ {
+ // remove new accidental
+ pitch_arr_.del(j);
+ no_of_acc--;
+ acc_found = 1;
+ }
+ else
+ {
+ // change new accidental
+ pitch_arr_[j].accidental_i_ = mm.accidental_i_;
+ acc_found = 1;
+ }
+ }
+ }
+ if (acc_found == 0)
+ {
+ // add transposed old accidental
+ pitch_arr_.push(mm);
+ }
+ }
+ }
}
-
IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req);
void
Key_change_req::squash_octaves()
Key_change_req::Key_change_req()
{
minor_b_ = false;
- multi_octave_b_= false;
+ ordinary_key_b_= false;
}
IMPLEMENT_IS_TYPE_B1(Break_req, Command_req);
{
}
+IMPLEMENT_IS_TYPE_B1 (Mark_req, Command_req);
+
+Mark_req::Mark_req (String s)
+{
+ str_ = s;
+}
+
+void
+Mark_req::do_print () const
+{
+ DOUT << str_;
+}
+
int
Key_change_req::flats_i()
{
return flats_i;
}
-int
-Key_change_req::minor_b()
+bool
+Key_change_req::minor_b() const
{
return minor_b_;
}
int sharps_i = 0;
for (int i = 0; i < pitch_arr_.size(); i++)
{
- if (pitch_arr_[i].accidental_i_ < 0)
+ if (pitch_arr_[i].accidental_i_ > 0)
sharps_i += pitch_arr_[i].accidental_i_;
}
return sharps_i;
source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#define COMMANDREQUEST_HH
#include "request.hh"
-#include "varray.hh"
+#include "array.hh"
#include "duration.hh"
#include "musical-pitch.hh"
musical requests. */
class Command_req : public virtual Request {
public:
- REQUESTMETHODS(Command_req, command);
- virtual Measure_grouping_req * measuregrouping() { return 0; }
- virtual Clef_change_req * clefchange() { return 0; }
- virtual Key_change_req * keychange() { return 0; }
- virtual Partial_measure_req * partial() { return 0; }
- virtual Meter_change_req * meterchange() { return 0; }
- virtual Bar_req *bar() { return 0; }
- virtual Cadenza_req *cadenza() { return 0; }
- virtual Timing_req*timing() { return 0; }
- virtual Command_script_req*commandscript() { return 0;}
- virtual Break_req *linebreak () { return 0; }
+ REQUESTMETHODS(Command_req);
+
+ DEFAULTACCESSOR(Measure_grouping_req)
+ DEFAULTACCESSOR(Clef_change_req)
+ DEFAULTACCESSOR(Key_change_req)
+ DEFAULTACCESSOR(Partial_measure_req)
+ DEFAULTACCESSOR(Time_signature_change_req)
+ DEFAULTACCESSOR(Bar_req)
+ DEFAULTACCESSOR(Cadenza_req)
+ DEFAULTACCESSOR(Timing_req)
+ DEFAULTACCESSOR(Command_script_req)
+ DEFAULTACCESSOR(Break_req)
+ DEFAULTACCESSOR(Mark_req)
};
enum { DISALLOW = -10000, FORCE = 10000 };
int penalty_i_;
Break_req ();
- REQUESTMETHODS (Break_req, linebreak);
+ REQUESTMETHODS (Break_req);
+};
+
+class Mark_req : public Command_req {
+public:
+ Mark_req (String);
+ String str_;
+ REQUESTMETHODS (Mark_req);
};
class Command_script_req : public Command_req, public Script_req {
// huh?
Command_script_req();
~Command_script_req();
- REQUESTMETHODS(Command_script_req, commandscript);
+ REQUESTMETHODS(Command_script_req);
};
-/** Baseclass for meter/partial req. It has to be handled by
+/** Baseclass for time_signature/partial req. It has to be handled by
Staff_{walker,column} baseclass. */
class Timing_req : public Command_req {
public:
- REQUESTMETHODS(Timing_req, timing);
- virtual Tempo_req * tempo(){return 0; }
+ REQUESTMETHODS(Timing_req);
+ DEFAULTACCESSOR(Tempo_req)
};
int metronome_i_;
Tempo_req();
- REQUESTMETHODS(Tempo_req, tempo);
+ REQUESTMETHODS(Tempo_req);
bool do_equal_b (Request *) const;
};
Moment duration_;
Partial_measure_req (Moment);
- REQUESTMETHODS(Partial_measure_req, partial);
+ REQUESTMETHODS(Partial_measure_req);
bool do_equal_b (Request*) const;
};
/**
- todo: allow C meter
+ todo: allow C time_signature
*/
-class Meter_change_req : public Timing_req {
+class Time_signature_change_req : public Timing_req {
public:
int beats_i_, one_beat_i_;
- Meter_change_req();
- void set (int,int);
+ Time_signature_change_req();
bool do_equal_b (Request*) const;
- REQUESTMETHODS(Meter_change_req, meterchange);
+ REQUESTMETHODS(Time_signature_change_req);
};
/// toggle Cadenza mode
bool on_b_;
bool do_equal_b (Request*) const;
Cadenza_req (bool);
- REQUESTMETHODS(Cadenza_req,cadenza);
+ REQUESTMETHODS(Cadenza_req);
};
/// check if we're at start of a measure.
class Barcheck_req : public Timing_req {
public:
bool do_equal_b (Request *) const;
- REQUESTMETHODS(Barcheck_req,barcheck);
+ REQUESTMETHODS(Barcheck_req);
};
class Measure_grouping_req : public Timing_req {
Array<int> beat_i_arr_;
Array<Moment> elt_length_arr_;
bool do_equal_b (Request *) const;
- REQUESTMETHODS(Measure_grouping_req, measuregrouping);
+ REQUESTMETHODS(Measure_grouping_req);
};
/** draw a (repeat)-bar. This something different than #Barcheck_req#,
Bar_req (String);
bool do_equal_b (Request*) const;
- REQUESTMETHODS(Bar_req,bar);
+ REQUESTMETHODS(Bar_req);
};
public:
Array<Musical_pitch> pitch_arr_;
bool minor_b_;
+ bool ordinary_key_b_;
- /// don't ignore the octaves in #melodic_p_arr_#?
- bool multi_octave_b_;
Key_change_req();
- REQUESTMETHODS(Key_change_req, keychange);
+ REQUESTMETHODS(Key_change_req);
/// squash the octaves to 1
void squash_octaves();
/// return number of sharps in key
int sharps_i();
- void transpose (Musical_pitch d) const;
+ void transpose (Musical_pitch d);
/// is minor key?
- int minor_b();
+ bool minor_b() const;
};
class Clef_change_req : public Command_req {
public:
String clef_str_;
Clef_change_req (String);
- REQUESTMETHODS(Clef_change_req, clefchange);
+ REQUESTMETHODS(Clef_change_req);
};
#endif // COMMANDREQUEST_HH
source file of the GNU LilyPond music typesetter
- (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "real.hh"
#include "moment.hh"
-#include "varray.hh"
+#include "array.hh"
#include "interval.hh"
#include "music-output-def.hh"
*/
class Paper_def : public Music_output_def
{
- Lookup *lookup_p_;
+ Assoc<int, Lookup *> *lookup_p_assoc_p_;
Scope* scope_p_;
static int default_count_i_;
Real get_var (String) const;
void reinit ();
Paper_def ();
- void set (Lookup*);
+ void set_lookup (int, Lookup*);
Paper_def (Paper_def const&);
/// The distance between beams of multiplicity_i
Real note_width () const;
void print () const;
- Lookup const * lookup_l (); // TODO naming
+ Lookup const * lookup_l (int sz) const; // TODO naming
/** convert a duration to an idealspacing
- influence using the geometric_ and parameters.
+ influence using the geometric_ and paratime_signatures.
*/
Real duration_to_dist (Moment, Real) const;
Real geometric_spacing (Moment) const;
source file of the LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#define TEX_HH
#include "string.hh"
-#include "boxes.hh"
+#include "box.hh"
#include "scalar.hh"
-/** parameter substitution in TeX_strings.
+/** paratime_signature substitution in TeX_strings.
this function provides a simple macro mechanism:
if source == "tex%bla%", then
String
substitute_args (String source, Array<String> args);
-/// parameter substitution in TeX_strings
+/// paratime_signature substitution in TeX_strings
String
substitute_args (String source, Array<Scalar> args);
source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
{
public:
TRANSLATOR_CLONE(Timing_translator);
- Meter_change_req * meter_req_l () const;
+ Time_signature_change_req * time_signature_req_l () const;
Timing_translator ();
DECLARE_MY_RUNTIME_TYPEINFO;
Time_description time_;