]> git.donarmstrong.com Git - lilypond.git/blob - src/midi-output.cc
partial: 0.0.38.hanjan
[lilypond.git] / src / midi-output.cc
1 /*
2   midi-output.cc -- implement Midi_output
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwehuizen <jan@digicash.com> 
7 */
8
9 #include "plist.hh"
10 #include "debug.hh"
11 #include "score.hh"
12 #include "staff.hh"
13 #include "midi-stream.hh"
14 #include "midi-def.hh"
15 #include "midi-output.hh"
16 #include "midi-walker.hh"
17 #include "midi-item.hh"
18 #include "staff-column.hh"
19 #include "musicalrequest.hh"
20
21
22 Midi_output:: Midi_output(Score* score_l, Midi_def* midi_l )
23 {
24     midi_l_ = midi_l;
25
26     Midi_stream midi_stream(midi_l->outfile_str_,
27                             score_l->staffs_.size(),
28                             384 );
29 // oeps, not tempo, but clocks per 4 (384 convention)
30 // must set tempo in tempo request
31 //                          midi_l->get_tempo_i(Moment(1, 4)));
32
33     midi_stream_l_ = &midi_stream;
34     int track_i=0;
35
36     for (iter_top(score_l->staffs_,i); i.ok(); i++) {
37         do_staff(i, track_i++);
38     }
39
40 }
41
42 void
43 Midi_output::do_staff(Staff*st_l,int track_i)
44 {
45     Midi_track midi_track( track_i );
46     Midi_tempo midi_tempo( midi_l_->get_tempo_i( Moment( 1, 4 ) ) );
47     midi_track.add( Moment( 0.0 ), &midi_tempo );
48     for (Midi_walker w (st_l, &midi_track); w.ok(); w++)
49         w.process_requests();
50
51     *midi_stream_l_  << midi_track;
52 }