]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/midi-chunk.hh
c87adf6491a91c8a8ccbc4a0b041a2f06ca6f808
[lilypond.git] / lily / include / midi-chunk.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2007--2012 Han-Wen Nienhuys <hanwen@lilypond.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_CHUNK_HH
21 #define MIDI_CHUNK_HH
22
23 #include "lily-proto.hh"
24 #include "virtual-methods.hh"
25 #include "std-vector.hh"
26
27 /**
28    timed MIDI event
29 */
30 class Midi_event
31 {
32 public:
33   Midi_event (int delta, Midi_item *midi);
34
35   int delta_ticks_;
36   Midi_item *midi_;
37   string to_string () const;
38 };
39
40 /**
41    variable sized MIDI data
42 */
43 class Midi_chunk
44 {
45 public:
46   void set (const string &header_string, const string &data_string, const string &footer_string);
47   virtual string to_string () const;
48   virtual string data_string () const;
49   DECLARE_CLASSNAME (Midi_chunk);
50   virtual ~Midi_chunk ();
51 private:
52   string data_string_;
53   string footer_string_;
54   string header_string_;
55 };
56
57 class Midi_header : public Midi_chunk
58 {
59 public:
60   DECLARE_CLASSNAME (Midi_header);
61
62   Midi_header (int format, int tracks, int clocks_per_4);
63 };
64
65 class Midi_track : public Midi_chunk
66 {
67 public:
68   int number_;
69   int port_;
70   DECLARE_CLASSNAME (Midi_track);
71
72   vector<Midi_event *> events_;
73
74   Midi_track (int number, bool port);
75   ~Midi_track ();
76
77   void add (int, Midi_item *midi);
78   virtual string data_string () const;
79 };
80
81 #endif /* MIDI_CHUNK_HH */
82