2 // midi-voice.cc -- implement midi_voice
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
8 Midi_voice::Midi_voice( Moment begin_mom )
10 begin_mom_ = begin_mom;
16 Midi_voice::add_event( Midi_event* midi_event_p )
19 midi_event_p_list_.bottom().add( midi_event_p );
21 midi_event_p_array_.push( midi_event_p );
26 Midi_voice::begin_mom()
35 // if ( events_i_ == midi_event_p_list_.length_i() )
36 if ( events_i_ == midi_event_p_list_.size() )
38 Moment now_mom = begin_mom_;
39 tor( DEBUG_ver ) << now_mom << ", ";
40 for ( PCursor<Midi_event*> i( midi_event_p_list_.top() ); i.ok(); i++ ) {
41 tor( DEBUG_ver ) << now_mom << ", ";
44 tor( DEBUG_ver ) << endl;
46 // events_i_ = midi_event_p_list_.length_i();
47 events_i_ = midi_event_p_list_.size();
50 if ( events_i_ == midi_event_p_array_.size() )
52 Moment now_mom = begin_mom_;
53 tor( DEBUG_ver ) << now_mom << ", ";
54 for ( int i = 0; i < midi_event_p_array_.size(); i++ ) {
55 tor( DEBUG_ver ) << now_mom << ", ";
56 now_mom += midi_event_p_array_[ i ]->mom();
58 tor( DEBUG_ver ) << endl;
60 events_i_ = midi_event_p_array_.size();
66 Midi_voice::mudela_str( Moment from_mom, Moment to_mom, bool multiple_bo )
70 // if ( begin_mom() >= to_mom )
71 if ( begin_mom() > to_mom )
73 // if ( end_mom() <= from_mom )
74 if ( end_mom() < from_mom )
77 Moment now_mom = begin_mom();
79 PCursor<Midi_event*> i( midi_event_p_list_.top() );
80 for ( ; i.ok() && now_mom < from_mom ; i++ )
83 for ( ; i.ok() && now_mom < to_mom ; i++ ) {
85 str += i->mudela_str( false ) + " ";
89 for ( ; i < midi_event_p_array_.size() && now_mom < from_mom ; i++ )
90 now_mom += midi_event_p_array_[ i ]->mom();
92 for ( ; i < midi_event_p_array_.size() && now_mom < to_mom ; i++ ) {
93 now_mom += midi_event_p_array_[ i ]->mom();
94 str += midi_event_p_array_[ i ]->mudela_str( false ) + " ";
98 if ( str.length_i() && multiple_bo )
99 str = "{ " + str + "} ";