]> git.donarmstrong.com Git - lilypond.git/blob - lily/midi-def.cc
* lily/tie-column.cc (set_manual_tie_configuration): new function.
[lilypond.git] / lily / midi-def.cc
1 /*
2   midi-def.cc -- implement midi output def functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include <cmath>
10 using namespace std;
11
12 #include "misc.hh"
13 #include "output-def.hh"
14 #include "moment.hh"
15 #include "warn.hh"
16 #include "scm-hash.hh"
17
18 int
19 get_tempo (Output_def *def,
20            Moment one_beat_mom)
21 {
22   SCM wis = ly_symbol2scm ("whole-in-seconds");
23   Moment *w = unsmob_moment (def->lookup_variable (wis));
24
25   Moment wholes_per_min = Moment (60);
26   if (!w)
27     {
28       programming_error ("wholes-in-seconds not set.");
29       wholes_per_min /= 4;
30     }
31   else
32     wholes_per_min /= *w;
33
34   Rational beats_per_min =  (wholes_per_min / one_beat_mom).main_part_;
35   return beats_per_min.to_int ();
36 }
37
38 void
39 set_tempo (Output_def *def,
40            Moment one_beat_mom,
41            int beats_per_minute_i)
42 {
43   Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
44
45   Moment m = Moment (1) / Moment (beats_per_second * one_beat_mom);
46   def->set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
47 }
48