]> git.donarmstrong.com Git - lilypond.git/blob - lily/midi-def.cc
patch::: 1.3.130.jcn3
[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--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7
8 */
9 #include <math.h>
10 #include "misc.hh"
11 #include "midi-def.hh"
12 #include "performance.hh"
13 #include "debug.hh"
14 #include "scope.hh"
15
16 Midi_def::Midi_def()
17 {
18   // ugh
19   set_tempo (Moment (1, 4), 60);
20 }
21
22 int
23 Midi_def::get_tempo_i (Moment one_beat_mom)
24 {
25   Moment w = *unsmob_moment (scope_p_->scm_elem ("whole-in-seconds"));
26   Moment wholes_per_min = Moment(60) /w;
27   int beats_per_min = wholes_per_min / one_beat_mom;
28   return int (beats_per_min);
29 }
30
31 void
32 Midi_def::set_tempo (Moment one_beat_mom, int beats_per_minute_i)
33 {
34   Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
35
36   Moment m = Moment(1)/Moment(beats_per_second * one_beat_mom);
37   scope_p_->set ("whole-in-seconds", m.smobbed_copy());
38 }
39
40
41 int Midi_def::score_count_i_=0;
42
43 int
44 Midi_def::get_next_score_count () const
45 {
46   return score_count_i_++;
47 }
48
49 void
50 Midi_def::reset_score_count ()
51 {
52   score_count_i_ = 0;
53 }