]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/audio-item.hh
Release: bump Welcome versions.
[lilypond.git] / lily / include / audio-item.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2015 Jan Nieuwenhuizen <janneke@gnu.org>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef AUDIO_ITEM_HH
21 #define AUDIO_ITEM_HH
22
23 #include "audio-element.hh"
24 #include "moment.hh"
25 #include "pitch.hh"
26
27 class Audio_item : public Audio_element
28 {
29 public:
30   Audio_column *audio_column_;
31   int channel_;
32
33   Audio_item ();
34   Audio_column *get_column () const;
35
36   virtual void render ();
37
38 private:
39   Audio_item (Audio_item const &);
40   Audio_item &operator = (Audio_item const &);
41 };
42
43 // Audio_span_dynamic is open at the end of the interval, so the volume
44 // grows/diminshes toward a target, but whether it reaches it depends on the
45 // next Audio_span_dynamic in the performance.  For example, a crescendo
46 // notated as mf < p is represented as [mf < x) [p ...) i.e. growth to some
47 // volume louder than mf followed by an abrupt change to p.
48 class Audio_span_dynamic : public Audio_element
49 {
50 public:
51   static const Real MINIMUM_VOLUME;
52   static const Real MAXIMUM_VOLUME;
53   static const Real DEFAULT_VOLUME;
54
55 private:
56   Moment start_moment_;
57   Real start_volume_;
58   Real duration_; // = target moment - start moment
59   Real gain_; // = target volume - start volume
60
61 public:
62   Moment get_start_moment () const { return start_moment_; }
63   Real get_start_volume () const { return start_volume_; }
64   Real get_duration () const { return duration_; }
65   void set_end_moment (Moment);
66   void set_volume (Real start, Real target);
67   Real get_volume (Moment) const;
68   Audio_span_dynamic (Moment mom, Real volume);
69 };
70
71 class Audio_key : public Audio_item
72 {
73 public:
74   Audio_key (int acc, bool major);
75
76   int accidentals_;
77   bool major_;
78 };
79
80 class Audio_instrument : public Audio_item
81 {
82 public:
83   Audio_instrument (string instrument_string);
84
85   string str_;
86 };
87
88 class Audio_note : public Audio_item
89 {
90 public:
91   Audio_note (Pitch p, Moment m, bool tie_event, Pitch transposition, int velocity);
92
93   // with tieWaitForNote, there might be a skip between the tied notes!
94   void tie_to (Audio_note *, Moment skip = 0);
95   Audio_note *tie_head ();
96   virtual string to_string () const;
97
98   Pitch pitch_;
99   Moment length_mom_;
100   Pitch transposing_;
101   Audio_span_dynamic *dynamic_;
102   int extra_velocity_;
103
104   Audio_note *tied_;
105   bool tie_event_;
106 };
107
108 class Audio_piano_pedal : public Audio_item
109 {
110 public:
111   string type_string_;
112   Direction dir_;
113 };
114
115 class Audio_text : public Audio_item
116 {
117 public:
118   enum Type
119   {
120     TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
121     MARKER, CUE_POINT
122   };
123
124   Audio_text (Audio_text::Type type, const string &text_string);
125
126   Type type_;
127   string text_string_;
128 };
129
130 class Audio_tempo : public Audio_item
131 {
132 public:
133   Audio_tempo (int per_minute_4);
134
135   int per_minute_4_;
136 };
137
138 class Audio_time_signature : public Audio_item
139 {
140 public:
141   Audio_time_signature (int beats, int one_beat);
142
143   int beats_;
144   int one_beat_;
145 };
146
147 class Audio_control_change : public Audio_item
148 {
149 public:
150   Audio_control_change (int control, int value);
151
152   int control_;
153   int value_;
154 };
155
156 int moment_to_ticks (Moment);
157 Real moment_to_real (Moment);
158 Moment remap_grace_duration (Moment);
159
160 #endif // AUDIO_ITEM_HH
161