#include "debug.hh"
#include "inputmusic.hh"
#include "voice.hh"
-Input_music::~Input_music()
-{
-}
-Vertical_simple::Vertical_simple()
-{
- voice_ = new Voice;
-}
-Vertical_simple::Vertical_simple(Vertical_simple const&s)
-{
- voice_ = new Voice(*s.voice_);
+#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;
+ 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;
+ set_plet_backwards( moment, start_moment, i->plet()->dur_i_, i->plet()->type_i_ );
+ i.del();
+ break;
+ }
}
+
void
-Vertical_simple::add(Voice_element*v)
+Simple_music::add(Voice_element*v)
{
- voice_->add(v);
+ voice_.add(v);
}
-Real
-Vertical_simple::length()
+Moment
+Simple_music::length()const
{
- return voice_->last();
+ return voice_.last();
}
void
-Vertical_simple::translate_time(Real t)
+Simple_music::translate_time(Moment t)
{
- voice_->start += t;
+ voice_.start += t;
}
Voice_list
-Vertical_simple::convert()
+Simple_music::convert()const
{
Voice_list l;
- l.bottom().add(new Voice(*voice_));
+ l.bottom().add(new Voice(voice_));
return l;
}
-Vertical_simple::~Vertical_simple()
+
+void
+Simple_music::print() const
+{
+ mtor << "Simple_music {";
+ 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)
{
- delete voice_;
+ voice_.set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
}
+/* *************** */
+
void
-Vertical_simple::print() const
+Complex_music::add(Input_music*v)
{
- mtor << "Vertical_simple {";
- voice_->print();
- mtor << "}\n";
+ elts.bottom().add(v);
}
-/****************/
void
-Music_voice::print() const
+Complex_music::print() const
{
- mtor << "Music_voice {";
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
+ for (iter_top(elts,i); i.ok(); i++)
i->print();
- mtor << "}\n";
}
void
-Music_voice::concatenate(Music_voice*h)
+Complex_music::concatenate(Complex_music*h)
{
- for (PCursor<Vertical_music*> i(h->voice_); i.ok(); i++)
+ for (iter_top(h->elts,i); i.ok(); i++)
add(i->clone());
}
+Complex_music::Complex_music()
+{
+}
-Music_voice::Music_voice(Music_voice const&s)
+Complex_music::Complex_music(Complex_music const&s)
{
- for (PCursor<Vertical_music*> i(s.voice_); i.ok(); i++)
+ for (iter_top(s.elts,i); i.ok(); i++)
add(i->clone());
}
+void
+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
-Music_voice::add(Voice_element*v)
+Music_voice::print() const
{
- PCursor<Vertical_music*> c(voice_.bottom());
+ mtor << "Music_voice {";
+ Complex_music::print();
+ mtor << "}\n";
+}
+
+void
+Music_voice::add_elt(Voice_element*v)
+{
+ PCursor<Input_music*> c(elts.bottom());
if (!c.ok() || !c->simple()) {
- Vertical_simple*vs = new Vertical_simple;
+ Simple_music*vs = new Simple_music;
c.add(vs);
}
- c = voice_.bottom();
- Vertical_simple *s = c->simple();
+ c = elts.bottom();
+ Simple_music *s = c->simple();
s->add(v);
-}
-void
-Music_voice::add(Vertical_music*v)
-{
- voice_.bottom().add(v);
+ check_plet(v);
}
-Real
-Music_voice::length()
+Moment
+Music_voice::length()const
{
- Real l = 0.0;
+ Moment l = 0;
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
+ for (iter_top(elts,i); i.ok(); i++)
l += i->length();
return l;
}
Voice_list
-Music_voice::convert()
+Music_voice::convert()const
{
Voice_list l;
- Real here = 0.0;
+ Moment here = 0;
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++) {
- Real len = i->length();
+ for (iter_top(elts,i); i.ok(); i++) {
+ Moment len = i->length();
Voice_list k(i->convert());
k.translate_time(here);
l.concatenate(k);
- here +=len;
-
+ here +=len;
}
return l;
}
void
-Music_voice::translate_time(Real t)
+Music_voice::translate_time(Moment t)
{
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
- i->translate_time(t);
+ elts.bottom()->translate_time(t);
}
-/****************/
+/* *************** */
+
void
-Music_general_chord::print() const
+Music_general_chord::add_elt(Voice_element*v)
{
- mtor << "Music_general_chord {";
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
- i->print();
- mtor << "}\n";
+ Simple_music*vs = new Simple_music;
+ vs->add(v);
+ elts.bottom().add(vs);
+
+ check_plet(v);
}
void
-Music_general_chord::concatenate(Music_general_chord*v)
+Music_general_chord::print() const
{
- for (PCursor<Horizontal_music*> i(v->chord_); i.ok(); i++)
- add(i->clone());
+ mtor << "Music_general_chord {";
+ Complex_music::print();
+ mtor << "}\n";
}
void
-Music_general_chord::translate_time(Real t)
+Music_general_chord::translate_time(Moment t)
{
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
+ for (iter_top(elts,i); i.ok(); i++)
i->translate_time(t);
}
-
-
-Real
-Music_general_chord::length()
+Moment
+Music_general_chord::length()const
{
- Real l =0.0;
+ Moment l =0;
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
- l = MAX(l, i->length());
+ for (iter_top(elts,i); i.ok(); i++)
+ l = l >? i->length();
return l;
}
-void
-Music_general_chord::add(Horizontal_music*h)
-{
- chord_.bottom().add(h);
-}
-
Voice_list
-Music_general_chord::convert()
+Music_general_chord::convert()const
{
Voice_list l;
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++) {
+ for (iter_top(elts,i); i.ok(); i++) {
Voice_list k(i->convert());
l.concatenate(k);
}
return l;
}
+/* *************** */
-Music_general_chord::Music_general_chord(
- Music_general_chord const & s)
+void
+Multi_voice_chord::set_default_group(String g)
{
- for (PCursor<Horizontal_music*> i(s.chord_); i.ok(); i++) {
- add(i->clone());
+ int j=0;
+ for (iter_top(elts, i); i.ok(); i++) {
+ i->set_default_group(g + String(j));
+ j++;
}
}
-
-/****************/
+
+
+/* *************** */
void
-Voice_list::translate_time(Real x)
+Voice_list::translate_time(Moment x)
{
- for (PCursor<Voice*> i(*this); i.ok(); i++)
+ for (iter_top(*this,i); i.ok(); i++)
i->start += x;
}
-void
-Voice_list::junk()
-{
- for (PCursor<Voice*> i(*this); i.ok(); i++)
- delete i.ptr();
-}