- Changed IO's vector<Port*>'s to PortList
[ardour.git] / libs / ardour / ardour / midi_region.h
1 /*
2     Copyright (C) 2000-2006 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $
19 */
20
21 #ifndef __ardour_midi_region_h__
22 #define __ardour_midi_region_h__
23
24 #include <vector>
25
26 #include <pbd/fastlog.h>
27 #include <pbd/undo.h>
28
29 #include <ardour/ardour.h>
30 #include <ardour/region.h>
31 #include <ardour/gain.h>
32 #include <ardour/logcurve.h>
33 #include <ardour/export.h>
34
35 class XMLNode;
36
37 namespace ARDOUR {
38
39 class Route;
40 class Playlist;
41 class Session;
42 class MidiFilter;
43 class MidiSource;
44
45 class MidiRegion : public Region
46 {
47   public:
48         MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, bool announce = true);
49         MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
50         MidiRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
51         MidiRegion (const MidiRegion&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
52         MidiRegion (const MidiRegion&);
53         MidiRegion (MidiSource&, const XMLNode&);
54         MidiRegion (SourceList &, const XMLNode&);
55         ~MidiRegion();
56
57         MidiSource& midi_source (uint32_t n=0) const;
58
59         jack_nframes_t read_at (RawMidi* out, RawMidi* mix,
60                         jack_nframes_t position,
61                         jack_nframes_t cnt, 
62                         uint32_t       chan_n      = 0,
63                         jack_nframes_t read_frames = 0,
64                         jack_nframes_t skip_frames = 0) const;
65
66         jack_nframes_t master_read_at (RawMidi* buf, RawMidi* mix,
67                         jack_nframes_t position,
68                         jack_nframes_t cnt,
69                         uint32_t chan_n=0) const;
70
71         XMLNode& state (bool);
72         int      set_state (const XMLNode&);
73
74         int separate_by_channel (ARDOUR::Session&, vector<MidiRegion*>&) const;
75
76         UndoAction get_memento() const;
77
78   private:
79         friend class Playlist;
80
81   private:
82         StateManager::State* state_factory (std::string why) const;
83         Change restore_state (StateManager::State&);
84
85         jack_nframes_t _read_at (const SourceList&, RawMidi *buf,
86                 jack_nframes_t position,
87                 jack_nframes_t cnt, 
88                 uint32_t chan_n = 0,
89                 jack_nframes_t read_frames = 0,
90                 jack_nframes_t skip_frames = 0) const;
91
92         void recompute_at_start ();
93         void recompute_at_end ();
94 };
95
96 } /* namespace ARDOUR */
97
98
99 #endif /* __ardour_midi_region_h__ */