]> git.donarmstrong.com Git - lilypond.git/blob - lily/midi-def.cc
release: 0.0.74pre
[lilypond.git] / lily / midi-def.cc
1 //
2 // midi-def.cc -- implement midi output
3 //
4 // source file of the GNU LilyPond music typesetter
5 //
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7
8 #include <math.h>
9 #include "misc.hh"
10 #include "midi-def.hh"
11 #include "debug.hh"
12
13 // classes, alphasorted
14 //     statics
15 //     constructors
16 //     destructor
17 //     routines, alphasorted
18
19 // statics Midi_def
20 // ugh
21 int Midi_def::den_i_s = 4;
22 int Midi_def::num_i_s = 4;
23
24 Midi_def::Midi_def()
25 {
26     set_tempo( Moment( 1, 4 ), 60 );
27     outfile_str_ = "lelie.midi"; 
28 }
29
30 Midi_def::Midi_def( Midi_def const& midi_c_r )
31 {
32     whole_seconds_f_ = midi_c_r.whole_seconds_f_;
33     outfile_str_ = midi_c_r.outfile_str_;
34 }
35
36 Midi_def::~Midi_def()
37 {
38 }
39
40 Real
41 Midi_def::duration_to_seconds_f( Moment moment )
42 {
43     if (!moment)
44         return 0;
45     
46     return Moment( whole_seconds_f_ ) * moment;
47 }
48
49 int
50 Midi_def::get_tempo_i( Moment moment )
51 {
52     return Moment( whole_seconds_f_ ) * Moment( 60 ) * moment;
53 }
54
55 void
56 Midi_def::print() const
57 {
58 #ifndef NPRINT
59     mtor << "Midi {4/min: " << Real( 60 ) / ( whole_seconds_f_ * 4 );
60     mtor << "out: " << outfile_str_;
61     mtor << "}\n";
62 #endif
63 }
64
65 void
66 Midi_def::set_tempo( Moment moment, int count_per_minute_i )
67 {
68     whole_seconds_f_ = Moment( count_per_minute_i ) / Moment( 60 ) / moment;
69 }