]> git.donarmstrong.com Git - lilypond.git/blob - src/mididef.cc
release: 0.0.34
[lilypond.git] / src / mididef.cc
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>
7
8 #include <math.h>
9 #include "misc.hh"
10 #include "mididef.hh"
11 #include "debug.hh"
12
13 // classes, alphasorted
14 //     statics
15 //     constructors
16 //     destructor
17 //     routines, alphasorted
18
19 Midi_def::Midi_def()
20 {
21     set_tempo( Moment( 1, 4 ), 60 );
22     outfile_str_ = "lelie.midi"; 
23 }
24
25 Midi_def::Midi_def( Midi_def const& midi_c_r )
26 {
27     whole_seconds_f_ = midi_c_r.whole_seconds_f_;
28     outfile_str_ = midi_c_r.outfile_str_;
29 }
30
31 Midi_def::~Midi_def()
32 {
33 }
34
35 Real
36 Midi_def::duration_to_seconds_f( Moment moment )
37 {
38     if (!moment)
39         return 0;
40     
41     return whole_seconds_f_ * moment;
42 }
43
44 int
45 Midi_def::get_tempo_i( Moment moment )
46 {
47     return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment;
48 }
49
50 void
51 Midi_def::print() const
52 {
53 #ifndef NPRINT
54     mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
55     mtor << "out: " << outfile_str_;
56     mtor << "}\n";
57 #endif
58 }
59
60 void
61 Midi_def::set_tempo( Moment moment, int count_per_minute_i )
62 {
63     whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;
64 }