lilypond-0.0.62
[lilypond.git] / lily / midi-def.cc
blob163105ab3c3906952420337cf2add5198a948056
1 //
2 // midi-def.cc -- implement midi output
3 //
4 // source file of the LilyPond music typesetter
5 //
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
8 #include <math.h>
9 #include "misc.hh"
10 #include "midi-def.hh"
11 #include "debug.hh"
13 // classes, alphasorted
14 // statics
15 // constructors
16 // destructor
17 // routines, alphasorted
19 // statics Midi_def
20 // ugh
21 int Midi_def::den_i_s = 4;
22 int Midi_def::num_i_s = 4;
24 Midi_def::Midi_def()
26 set_tempo( Moment( 1, 4 ), 60 );
27 outfile_str_ = "lelie.midi";
30 Midi_def::Midi_def( Midi_def const& midi_c_r )
32 whole_seconds_f_ = midi_c_r.whole_seconds_f_;
33 outfile_str_ = midi_c_r.outfile_str_;
36 Midi_def::~Midi_def()
40 Real
41 Midi_def::duration_to_seconds_f( Moment moment )
43 if (!moment)
44 return 0;
46 return Moment( whole_seconds_f_ ) * moment;
49 int
50 Midi_def::get_tempo_i( Moment moment )
52 return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment;
55 void
56 Midi_def::print() const
58 #ifndef NPRINT
59 mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
60 mtor << "out: " << outfile_str_;
61 mtor << "}\n";
62 #endif
65 void
66 Midi_def::set_tempo( Moment moment, int count_per_minute_i )
68 whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;