Fix InstrumentSwitch grob definition.
[lilypond.git] / flower / include / drul-array.hh
blob47c4847c4048825f0d65904a0431a2e861779410
1 /*
2 drul-array.hh -- declare Drul_array
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #ifndef DRUL_ARRAY_HH
10 #define DRUL_ARRAY_HH
12 #include "direction.hh"
13 #include "real.hh"
15 /**
16 Left/right or Up/down arrays. Drul is nicer sounding than udlr
18 template<class T>
19 struct Drul_array
21 T array_[2];
22 T &at (Direction d)
24 assert (d == 1 || d == -1);
25 return array_[ (d + 1) / 2];
27 T const &at (Direction d) const
29 assert (d == 1 || d == -1);
30 return array_[ (d + 1) / 2];
32 T &operator [] (Direction d)
34 return at (d);
36 T const& operator [] (Direction d) const
38 return at (d);
40 Drul_array ()
43 Drul_array (T const &t1, T const &t2)
45 set (t1, t2);
47 void set (T const &t1, T const &t2)
49 array_[0] = t1;
50 array_[1] = t2;
54 template<class T>
55 void
56 scale_drul (Drul_array<T> *dr, T x)
58 dr->at (LEFT) *= x;
59 dr->at (RIGHT) *= x;
62 inline Real
63 linear_combination (Drul_array<Real> const &d, Real x)
65 return ((1.0 - x) * Real (d.at (LEFT))
66 + (x + 1.0) * Real (d.at (RIGHT))) * 0.5;
69 #endif /* DRUL_ARRAY_HH */