2 // mudela-voice.cc -- implement Mudela_voice
4 // copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
6 #include "string-convert.hh"
7 #include "mi2mu-global.hh"
8 #include "mudela-column.hh"
9 #include "mudela-item.hh"
10 #include "mudela-staff.hh"
11 #include "mudela-stream.hh"
12 #include "mudela-voice.hh"
14 Mudela_voice::Mudela_voice (Mudela_staff* mudela_staff_l)
16 mudela_staff_l_ = mudela_staff_l;
20 Mudela_voice::add_item (Mudela_item* mudela_item_l)
22 mudela_item_l_list_.bottom().add (mudela_item_l);
26 Mudela_voice::begin_mom()
28 return mudela_item_l_list_.size() ?
29 mudela_item_l_list_.top()->at_mom() : Moment (0);
33 Mudela_voice::end_mom()
35 return mudela_item_l_list_.size() ?
36 mudela_item_l_list_.bottom()->at_mom() : Moment (0);
39 static int const FAIRLY_LONG_VOICE_i = 6;
42 Mudela_voice::output (Mudela_stream& mudela_stream_r)
44 if (!mudela_item_l_list_.size())
47 if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
48 mudela_stream_r << '\n';
50 int current_bar_i = 0;
51 Moment bar_mom = mudela_staff_l_->mudela_time_signature_l_->bar_mom();
53 for (PCursor<Mudela_item*> i (mudela_item_l_list_); i.ok(); i++)
55 Moment at_mom = i->mudela_column_l_->at_mom();
56 int bar_i = (int) (at_mom / bar_mom) + 1;
57 if (bar_i > current_bar_i)
61 if (at_mom == Moment (bar_i - 1) * bar_mom)
62 mudela_stream_r << "|";
63 mudela_stream_r << "\n% ";
64 mudela_stream_r << String_convert::i2dec_str (bar_i, 0, ' ');
65 mudela_stream_r << '\n';
67 LOGOUT(NORMAL_ver) << "[" << bar_i << "]" << flush;
68 current_bar_i = bar_i;
71 mudela_stream_r << **i;
74 if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i)
75 mudela_stream_r << '\n';