]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/midi-item.hh
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / lily / include / midi-item.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2010 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 MIDI_ITEM_HH
21 #define MIDI_ITEM_HH
22
23 #include "audio-item.hh"
24 #include "std-vector.hh"
25
26 string int2midi_varint_string (int i);
27   
28 /**
29    Any piece of midi information.
30
31    Maybe use base classes for RIFF files?
32 */
33 class Midi_item
34 {
35 public:
36   DECLARE_CLASSNAME(Midi_item);
37   Midi_item ();
38   virtual ~Midi_item ();
39   virtual char const *name () const;
40
41   static Midi_item *get_midi (Audio_item *a);
42
43
44   virtual string to_string () const = 0;
45 };
46
47 class Midi_channel_item : public Midi_item
48 {
49 public:
50   int channel_;
51   DECLARE_CLASSNAME(Midi_channel_item);
52   Midi_channel_item ();
53 };
54
55 class Midi_duration : public Midi_item
56 {
57 public:
58   Midi_duration (Real seconds_f);
59
60   virtual string to_string () const;
61   Real seconds_;
62 };
63
64
65 /**
66    Change instrument event
67 */
68 class Midi_instrument : public Midi_channel_item
69 {
70 public:
71   Midi_instrument (Audio_instrument *);
72
73   DECLARE_CLASSNAME(Midi_instrument);
74   virtual string to_string () const;
75
76   Audio_instrument *audio_;
77 };
78
79 class Midi_key : public Midi_item
80 {
81 public:
82   Midi_key (Audio_key *);
83   DECLARE_CLASSNAME(Midi_key);
84
85   virtual string to_string () const;
86
87   Audio_key *audio_;
88 };
89
90 class Midi_time_signature : public Midi_item
91 {
92 public:
93   Midi_time_signature (Audio_time_signature *);
94   DECLARE_CLASSNAME(Midi_time_signature);
95
96   virtual string to_string () const;
97
98   Audio_time_signature *audio_;
99   int clocks_per_1_;
100 };
101
102 class Midi_note : public Midi_channel_item
103 {
104 public:
105   Midi_note (Audio_note *);
106   DECLARE_CLASSNAME(Midi_note);
107
108   int get_semitone_pitch () const;
109   int get_fine_tuning () const;
110   virtual string to_string () const;
111
112   Audio_note *audio_;
113
114   
115   static int const c0_pitch_ = 60;
116   Byte dynamic_byte_;
117 };
118
119 class Midi_note_off : public Midi_note
120 {
121 public:
122   Midi_note_off (Midi_note *);
123   DECLARE_CLASSNAME(Midi_note_off);
124
125   virtual string to_string () const;
126
127   Midi_note *on_;
128   Byte aftertouch_byte_;
129 };
130
131 class Midi_text : public Midi_item
132 {
133 public:
134   enum Type
135     {
136       TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC,
137       MARKER, CUE_POINT
138     };
139   DECLARE_CLASSNAME(Midi_text);
140
141   Midi_text (Audio_text *);
142
143   virtual string to_string () const;
144
145   Audio_text *audio_;
146 };
147
148 class Midi_dynamic : public Midi_channel_item
149 {
150 public:
151   Midi_dynamic (Audio_dynamic *);
152   DECLARE_CLASSNAME(Midi_dynamic);
153
154   virtual string to_string () const;
155
156   Audio_dynamic *audio_;
157 };
158
159 class Midi_piano_pedal : public Midi_channel_item
160 {
161 public:
162   Midi_piano_pedal (Audio_piano_pedal *);
163   DECLARE_CLASSNAME(Midi_piano_pedal);
164
165   virtual string to_string () const;
166
167   Audio_piano_pedal *audio_;
168 };
169
170 class Midi_tempo : public Midi_item
171 {
172 public:
173   Midi_tempo (Audio_tempo *);
174   DECLARE_CLASSNAME(Midi_tempo);
175
176   virtual string to_string () const;
177
178   Audio_tempo *audio_;
179 };
180
181
182
183 #endif // MIDI_ITEM_HH