]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/midi-chunk.hh
Midi: set each track to its own port. Should fix instrument/volume problems.
[lilypond.git] / lily / include / midi-chunk.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2007--2011 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 /**
29    timed MIDI event
30 */
31 class Midi_event
32 {
33 public:
34   Midi_event (int delta, Midi_item *midi);
35
36   int delta_ticks_;
37   Midi_item *midi_;
38   string to_string () const;
39 };
40
41
42
43
44 /**
45    variable sized MIDI data
46 */
47 class Midi_chunk
48 {
49 public:
50   void set (string header_string, string data_string, string footer_string);
51   virtual string to_string () const;
52   virtual string data_string () const;
53   DECLARE_CLASSNAME (Midi_chunk);
54   virtual ~Midi_chunk ();
55 private:
56   string data_string_;
57   string footer_string_;
58   string header_string_;
59 };
60
61 class Midi_header : public Midi_chunk
62 {
63 public:
64   DECLARE_CLASSNAME (Midi_header);
65
66   Midi_header (int format, int tracks, int clocks_per_4);
67 };
68
69 class Midi_track : public Midi_chunk
70 {
71 public:
72   int number_;
73   DECLARE_CLASSNAME (Midi_track);
74
75   vector<Midi_event*> events_;
76
77   Midi_track (int number);
78   ~Midi_track ();
79
80   void add (int, Midi_item *midi);
81   virtual string data_string () const;
82 };
83
84 #endif /* MIDI_CHUNK_HH */
85