/* Copyright (C) 2000-2006 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $ */ #ifndef __ardour_midi_region_h__ #define __ardour_midi_region_h__ #include #include #include #include #include #include #include #include #include class XMLNode; using std::vector; namespace ARDOUR { class Route; class Playlist; class Session; class MidiFilter; class MidiSource; template class MidiRingBuffer; class MidiRegion : public Region { public: ~MidiRegion(); boost::shared_ptr midi_source (uint32_t n=0) const; /* Stub Readable interface */ virtual nframes_t read (Sample*, sframes_t pos, nframes_t cnt, int channel) const { return 0; } virtual sframes_t readable_length() const { return length(); } nframes_t read_at (MidiRingBuffer& dst, sframes_t position, nframes_t dur, uint32_t chan_n = 0, NoteMode mode = Sustained) const; nframes_t master_read_at (MidiRingBuffer& dst, sframes_t position, nframes_t dur, uint32_t chan_n = 0, NoteMode mode = Sustained) const; XMLNode& state (bool); int set_state (const XMLNode&); int separate_by_channel (ARDOUR::Session&, vector< boost::shared_ptr >&) const; /* automation */ boost::shared_ptr control(const Evoral::Parameter& id, bool create=false) { return model()->data().control(id, create); } virtual boost::shared_ptr control(const Evoral::Parameter& id) const { return model()->data().control(id); } /* export */ int exportme (ARDOUR::Session&, ARDOUR::ExportSpecification&); UndoAction get_memento() const; boost::shared_ptr model() { return midi_source()->model(); } boost::shared_ptr model() const { return midi_source()->model(); } private: friend class RegionFactory; MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length); MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); MidiRegion (const SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); MidiRegion (boost::shared_ptr, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags); MidiRegion (boost::shared_ptr); MidiRegion (boost::shared_ptr, const XMLNode&); MidiRegion (const SourceList &, const XMLNode&); private: nframes_t _read_at (const SourceList&, MidiRingBuffer& dst, nframes_t position, nframes_t dur, uint32_t chan_n = 0, NoteMode mode = Sustained) const; void recompute_at_start (); void recompute_at_end (); void switch_source(boost::shared_ptr source); protected: int set_live_state (const XMLNode&, Change&, bool send); }; } /* namespace ARDOUR */ #endif /* __ardour_midi_region_h__ */