lilypond-0.1.12
[lilypond.git] / m2m / midi-voice.cc
blob0d5b4b446c008816820edce3957262beba1a456b
1 //
2 // midi-voice.cc -- implement midi_voice
3 //
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
6 #include "m2m.hh"
8 Midi_voice::Midi_voice( Moment begin_mom )
10 begin_mom_ = begin_mom;
13 void
14 Midi_voice::add_event( Midi_event* midi_event_p )
16 midi_event_p_list_.bottom().add( midi_event_p );
19 Moment
20 Midi_voice::begin_mom()
22 return begin_mom_;
25 Moment
26 Midi_voice::end_mom()
28 Moment now_mom = begin_mom_;
29 dtor << now_mom << ", ";
30 for ( PCursor<Midi_event*> i( midi_event_p_list_.top() ); i.ok(); i++ ) {
31 dtor << now_mom << ", ";
32 now_mom += i->mom();
34 dtor << endl;
35 return now_mom;
38 String
39 Midi_voice::mudela_str( Moment from_mom, Moment to_mom, bool multiple_bo )
41 String str;
43 if ( begin_mom() >= to_mom )
44 return "";
45 if ( end_mom() <= from_mom )
46 return "";
48 Moment now_mom = begin_mom();
49 PCursor<Midi_event*> i( midi_event_p_list_.top() );
50 for ( ; i.ok() && now_mom < from_mom ; i++ )
51 now_mom += i->mom();
53 for ( ; i.ok() && now_mom < to_mom ; i++ ) {
54 now_mom += i->mom();
55 str += i->mudela_str( false ) + " ";
58 if ( str.length_i() && multiple_bo )
59 str = "\\music{ " + str + "} ";
60 return str;