lilypond-1.1.40
[lilypond.git] / src / mididef.cc
blob2c7bf7a7a794f8abb0c2fa1ea5e95371e009c7c6
1 //
2 // mididef.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 "mididef.hh"
11 #include "debug.hh"
13 // classes, alphasorted
14 // statics
15 // constructors
16 // destructor
17 // routines, alphasorted
19 Midi_def::Midi_def()
21 set_tempo( Moment( 1, 4 ), 60 );
22 outfile_str_ = "lelie.midi";
25 Midi_def::Midi_def( Midi_def const& midi_c_r )
27 whole_seconds_f_ = midi_c_r.whole_seconds_f_;
28 outfile_str_ = midi_c_r.outfile_str_;
31 Midi_def::~Midi_def()
35 Real
36 Midi_def::duration_to_seconds_f( Moment moment )
38 if (!moment)
39 return 0;
41 return whole_seconds_f_ * moment;
44 int
45 Midi_def::get_tempo_i( Moment moment )
47 return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment;
50 void
51 Midi_def::print() const
53 #ifndef NPRINT
54 mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
55 mtor << "out: " << outfile_str_;
56 mtor << "}\n";
57 #endif
60 void
61 Midi_def::set_tempo( Moment moment, int count_per_minute_i )
63 whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;