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