lilypond-1.3.24
[lilypond.git] / mi2mu / midi-score.cc
blob7b3262045c37a84bfdbc256d2b241427a4b3747f
1 //
2 // midi-score.cc -- implement Midi_score
3 //
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
6 #include "mi2mu.hh"
8 Midi_score::Midi_score( int format_i, int tracks_i, int tempo_i )
10 format_i_ = format_i;
11 tracks_i_ = tracks_i;
12 tempo_i_ = tempo_i;
15 Midi_score::~Midi_score()
19 void
20 Midi_score::add_track( Midi_track* midi_track_p )
22 midi_track_p_list_.bottom().add( midi_track_p );
25 int
26 Midi_score::output_mudela( String filename_str )
28 tor( NORMAL_ver ) << "Lily output to " << filename_str << " ..." << endl;
30 // ugh, ugly midi type 1 fix
31 if ( ( midi_track_p_list_.size() == 1 ) && !midi_track_p_list_.top()->number_i_ )
32 midi_track_p_list_.top()->number_i_ = 1;
34 int track_i = 0;
35 Lily_stream lily_stream( filename_str );
36 for ( PCursor<Midi_track*> i( midi_track_p_list_.top() ); i.ok(); i++ ) {
37 tor( NORMAL_ver ) << "track " << track_i++ << ": " << flush;
38 i->output_mudela( lily_stream );
39 lily_stream << "\n";
40 tor( NORMAL_ver ) << endl;
43 lily_stream << "\\score{\n";
44 lily_stream << " < \\multi 3;\n";
45 for ( PCursor<Midi_track*> i( midi_track_p_list_.top() ); i.ok(); i++ ) {
46 if ( ( midi_track_p_list_.size() != 1 )
47 && ( i == midi_track_p_list_.top() ) )
48 continue;
49 lily_stream << "\\melodic{ ";
50 lily_stream << "\\$" << i->id_str();
51 lily_stream << " }\n";
53 lily_stream << ">\n";
55 lily_stream << "\\paper{";
56 lily_stream << "unitspace = 20.0\\mm;";
57 lily_stream << "}\n";
59 lily_stream << "\\midi{";
60 // not use silly 0 track
61 midi_track_p_list_.bottom()->midi_tempo_p_->output_mudela( lily_stream, true );
62 lily_stream << "}\n";
64 lily_stream << "}\n";
66 return 0;
69 void
70 Midi_score::process()
72 int track_i = 0;
73 for ( PCursor<Midi_track*> i( midi_track_p_list_.top() ); i.ok(); i++ ) {
74 tor( NORMAL_ver ) << "track " << track_i++ << ": " << flush;
75 i->process();
76 tor( NORMAL_ver ) << endl;