2 Copyright (C) 2006 Paul Davis
3 Written by Dave Robillard, 2006
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_midi_region_h__
21 #define __ardour_midi_region_h__
25 #include <pbd/fastlog.h>
28 #include <ardour/ardour.h>
29 #include <ardour/region.h>
30 #include <ardour/export.h>
42 struct MidiRegionState : public RegionState
44 MidiRegionState (std::string why);
48 class MidiRegion : public Region
51 typedef vector<MidiSource *> SourceList;
53 MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, bool announce = true);
54 MidiRegion (MidiSource&, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
55 MidiRegion (SourceList &, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags, bool announce = true);
56 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);
57 MidiRegion (const MidiRegion&);
58 MidiRegion (MidiSource&, const XMLNode&);
59 MidiRegion (SourceList &, const XMLNode&);
62 bool source_equivalent (const Region&) const;
64 bool speed_mismatch (float) const;
67 void unlock_sources ();
68 MidiSource& source (uint32_t n=0) const { if (n < sources.size()) return *sources[n]; else return *sources[0]; }
70 uint32_t n_channels() { return sources.size(); }
71 vector<string> master_source_names();
73 bool captured() const { return !(_flags & (Region::Flag (Region::Import|Region::External))); }
75 virtual jack_nframes_t read_at (unsigned char *buf, unsigned char *mixdown_buffer,
76 char * workbuf, jack_nframes_t position, jack_nframes_t cnt,
78 jack_nframes_t read_frames = 0,
79 jack_nframes_t skip_frames = 0) const;
81 jack_nframes_t master_read_at (unsigned char *buf, unsigned char *mixdown_buffer,
82 char * workbuf, jack_nframes_t position, jack_nframes_t cnt, uint32_t chan_n=0) const;
85 XMLNode& state (bool);
86 XMLNode& get_state ();
87 int set_state (const XMLNode&);
98 int separate_by_channel (ARDOUR::Session&, vector<MidiRegion*>&) const;
100 uint32_t read_data_count() const { return _read_data_count; }
102 ARDOUR::Playlist* playlist() const { return _playlist; }
104 UndoAction get_memento() const;
108 //int exportme (ARDOUR::Session&, ARDOUR::AudioExportSpecification&);
110 Region* get_parent();
113 friend class Playlist;
117 SourceList master_sources; /* used when timefx are applied, so
118 we can always use the original
121 StateManager::State* state_factory (std::string why) const;
122 Change restore_state (StateManager::State&);
124 jack_nframes_t _read_at (const SourceList&, unsigned char *buf, unsigned char *mixdown_buffer,
125 char * workbuf, jack_nframes_t position, jack_nframes_t cnt,
127 jack_nframes_t read_frames = 0,
128 jack_nframes_t skip_frames = 0) const;
130 bool verify_start (jack_nframes_t position);
131 bool verify_length (jack_nframes_t position);
132 bool verify_start_mutable (jack_nframes_t& start);
133 bool verify_start_and_length (jack_nframes_t start, jack_nframes_t length);
135 void recompute_at_start() {}
136 void recompute_at_end() {}
138 void source_deleted (Source*);
141 } /* namespace ARDOUR */
144 #endif /* __ardour_midi_region_h__ */