struct Key_change_req : Command_req {
Array<Melodic_req*> melodic_p_arr_;
-
+ virtual void transpose(Melodic_req const &)const;
Key_change_req();
Key_change_req(Key_change_req const&);
~Key_change_req();
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;
+ virtual void transpose(Melodic_req const&) const =0;
virtual Input_music *clone() const = 0;
Voice voice_;
/* *** */
+ virtual void transpose(Melodic_req const&) const ;
+
virtual Simple_music*simple() { return this; }
void add(Voice_element*);
virtual void set_default_group(String g) { voice_.set_default_group(g); }
struct Complex_music : Input_music {
IPointerList<Input_music*> elts;
/* *************** */
+ virtual void transpose(Melodic_req const&) const ;
virtual void set_default_group(String g);
void add(Input_music*);
Complex_music();
/// 0 natural, 1 sharp, etc
int accidental_i_;
- /// force/supress printing of accidental.
- bool forceacc_b_;
-
/// return height from central c (in halflines)
- int height()const;
+ int height()const;
+
+ /// transpose. #delta# is relative to central c.
+ void transpose(Melodic_req const &delta);
/// return pitch from central c (in halfnotes)
int pitch()const;
Melodic_req();
/// Put a note of specified type, height, and with accidental on the staff.
struct Note_req : Rhythmic_req, virtual Melodic_req {
-
+ /// force/supress printing of accidental.
+ bool forceacc_b_;
+ Note_req();
Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
REQUESTMETHODS(Note_req, note);
};
struct Dynamic_req : Subtle_req {
/// for absolute dynamics
enum Loudness {
- FFF, FF, F, MF, MP, P, PP, PPP
+ FFF, FF, F, MF, MP, P, PP, PPP
};
static String loudness_str(Loudness);
REQUESTMETHODS(Dynamic_req, dynamic);
virtual Request* clone() const { return new Request(*this); }
void print()const ;
+ virtual void transpose(Melodic_req const &){}
virtual Moment duration() const { return 0; }
/* accessors for children
struct Voice_element {
Moment duration;
char const* defined_ch_c_l_;
- const Voice *voice_l_;
+ Voice const *voice_l_;
IPointerList<Request*> reqs;
/* *************** */
-
+ void transpose(Melodic_req const &)const;
Voice_element();
Voice_element(Voice_element const & src );
Voice();
Voice(Voice const&);
- Moment when(const Voice_element*)const;
+ Moment when(Voice_element const *)const;
Moment last() const;
-
+ void transpose(Melodic_req const &)const;
void add(Voice_element*);
bool find_plet_start_bo(char c, Moment& moment_r);
void print() const;
void
Request::print() const
{
+#ifndef NPRINT
mtor << name() << " {";
do_print();
mtor << "}\n";
+#endif
}
notename_i_ = 0;
octave_i_ = 0;
accidental_i_ = 0;
- forceacc_b_ = false;
+}
+
+void
+Melodic_req::transpose(Melodic_req const & delta)
+{
+ octave_i_ += delta.octave_i_;
+ notename_i_ += delta.notename_i_;
+ while (notename_i_ >= 7 ) {
+ notename_i_ -= 7;
+ octave_i_ ++;
+ }
+ accidental_i_ += delta.accidental_i_;
+ if (abs(accidental_i_) > 2) {
+ warning("transposition makes accidental larger than 2",
+ delta.defined_ch_c_l_);
+ }
}
void
Melodic_req::do_print() const
{
- mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
+#ifndef NPRINT
+ mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
+#endif
}
int
void
Plet_req::do_print() const
{
+#ifndef NPRINT
mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
+#endif
}
/* *************** */
int
-Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2)
+Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
{
return sign(r1.duration() - r2.duration());
}
void
Rhythmic_req::do_print() const
{
+#ifndef NPRINT
mtor << "ball: " << balltype ;
int d =dots;
while (d--)
mtor << '.';
mtor<<", plet factor"<<plet_factor<<"\n";
+#endif
}
Rhythmic_req::do_print();
Text_req::do_print();
}
+
/* *************** */
+Note_req::Note_req()
+{
+ forceacc_b_ = false;
+}
void
Note_req::do_print() const
{
+#ifndef NPRINT
+ mtor << " forceacc_b_ " << forceacc_b_ << '\n';
Melodic_req::do_print();
Rhythmic_req::do_print();
+#endif
}
/* *************** */
void
void Slur_req::do_print()const{}
/* *************** */
int
-Span_req:: compare(const Span_req &r1, const Span_req &r2)
+Span_req:: compare(Span_req const &r1, Span_req const &r2)
{
return r1.spantype - r2.spantype;
}
}
int
-Script_req::compare(const Script_req &d1, const Script_req &d2)
+Script_req::compare(Script_req const &d1, Script_req const &d2)
{
return d1.dir_i_ == d2.dir_i_ &&
d1.scriptdef_p_->compare(*d2.scriptdef_p_);
}
/* *************** */
int
-Text_req:: compare(const Text_req &r1, const Text_req &r2)
+Text_req:: compare(Text_req const &r1, Text_req const &r2)
{
bool b1 = (r1.dir_i_ == r2.dir_i_);
bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_));
void
Text_req::do_print() const
{
+#ifndef NPRINT
+
mtor << " dir " << dir_i_ ;
tdef_p_->print();
+#endif
}
/* *************** */
void
Skip_req::do_print() const
{
+#ifndef NPRINT
+
mtor << "duration: " << duration();
+#endif
}
Voice *
void
Subtle_req::do_print() const
{
- mtor << " subtime " << subtime_;
+#ifndef NPRINT
+ mtor << " subtime " << subtime_;
+#endif
}
void