2 // midi-track.cc -- implement Midi_track
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
9 #include "source-file.hh"
11 #include "midi-main.hh" // *tors
14 #include "duration.hh"
15 #include "midi-event.hh"
16 #include "lily-stream.hh"
17 #include "track-column.hh"
18 #include "midi-track.hh"
20 Midi_track::Midi_track( int track_i
)
22 name_str_
= String( "track" ) + String( track_i
);
23 tcol_p_list_
.bottom().add( new Track_column( Moment( 0 ) ) );
26 Midi_track::~Midi_track()
31 Midi_track::add_event( Moment mom
, Midi_event
* midi_event_p
)
35 tcol_l( mom
- midi_event_p
->mom() )->add_event( midi_event_p
);
38 // too much red tape ?
40 Midi_track::name_str()
46 Midi_track::output_mudela( Lily_stream
& lily_stream_r
)
48 lily_stream_r
<< name_str_
<< " = music { $\n";
49 lily_stream_r
<< "\t";
52 for ( PCursor
<Track_column
*> tcol_l_pcur( tcol_p_list_
.top() ); tcol_l_pcur
.ok(); tcol_l_pcur
++ ) {
53 if ( tcol_l_pcur
->midi_event_p_list_
.size() > 1 )
54 warning( "oeps, chord: can-t do that yet", 0 );
55 if ( !tcol_l_pcur
->midi_event_p_list_
.size() )
57 lily_stream_r
<< **tcol_l_pcur
->midi_event_p_list_
.top();
58 column_i
+= tcol_l_pcur
->midi_event_p_list_
.top()->mudela_str().length_i();
59 if ( column_i
> 40 ) {
60 lily_stream_r
<< "\n\t";
64 lily_stream_r
<< "\n$} % " << name_str_
<< "\n";
68 Midi_track::tcol_l( Moment mom
)
70 for ( PCursor
<Track_column
*> tcol_l_pcur( tcol_p_list_
.top() ); tcol_l_pcur
.ok(); tcol_l_pcur
++ ) {
71 if ( tcol_l_pcur
->mom() == mom
)
73 if ( tcol_l_pcur
->mom() > mom
) {
74 Track_column
* tcol_p
= new Track_column( mom
);
75 tcol_l_pcur
.insert( tcol_p
);
80 Track_column
* tcol_p
= new Track_column( mom
);
81 tcol_p_list_
.bottom().add( tcol_p
);