2 Copyright (C) 2000-2006 Paul Davis
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.
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.
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.
18 $Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $
21 #ifndef __ardour_midi_region_h__
22 #define __ardour_midi_region_h__
26 #include "ardour/ardour.h"
27 #include "ardour/region.h"
32 namespace Properties {
33 /* this is pseudo-property: nothing has this as an actual
34 property, but it allows us to signal changes to the
35 MidiModel used by the MidiRegion
37 LIBARDOUR_API extern PBD::PropertyDescriptor<void*> midi_data;
38 LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> start_beats;
39 LIBARDOUR_API extern PBD::PropertyDescriptor<Evoral::MusicalTime> length_beats;
44 template<typename Time> class EventSink;
55 class MidiStateTracker;
57 template<typename T> class MidiRingBuffer;
59 class LIBARDOUR_API MidiRegion : public Region
62 static void make_property_quarks ();
66 boost::shared_ptr<MidiRegion> clone (std::string path = std::string()) const;
68 boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
70 /* Stub Readable interface */
71 virtual framecnt_t read (Sample*, framepos_t /*pos*/, framecnt_t /*cnt*/, int /*channel*/) const { return 0; }
72 virtual framecnt_t readable_length() const { return length(); }
74 framecnt_t read_at (Evoral::EventSink<framepos_t>& dst,
78 NoteMode mode = Sustained,
79 MidiStateTracker* tracker = 0) const;
81 framecnt_t master_read_at (MidiRingBuffer<framepos_t>& dst,
85 NoteMode mode = Sustained) const;
88 int set_state (const XMLNode&, int version);
90 int separate_by_channel (ARDOUR::Session&, std::vector< boost::shared_ptr<Region> >&) const;
94 boost::shared_ptr<Evoral::Control> control(const Evoral::Parameter& id, bool create=false);
96 virtual boost::shared_ptr<const Evoral::Control> control(const Evoral::Parameter& id) const;
100 boost::shared_ptr<MidiModel> model();
101 boost::shared_ptr<const MidiModel> model() const;
103 void fix_negative_start ();
104 void transpose (int);
108 virtual bool can_trim_start_before_source_start () const {
113 friend class RegionFactory;
114 PBD::Property<Evoral::MusicalTime> _start_beats;
115 PBD::Property<Evoral::MusicalTime> _length_beats;
117 MidiRegion (const SourceList&);
118 MidiRegion (boost::shared_ptr<const MidiRegion>);
119 MidiRegion (boost::shared_ptr<const MidiRegion>, frameoffset_t offset);
121 framecnt_t _read_at (const SourceList&, Evoral::EventSink<framepos_t>& dst,
125 NoteMode mode = Sustained,
126 MidiStateTracker* tracker = 0) const;
128 void register_properties ();
129 void post_set (const PBD::PropertyChange&);
131 void recompute_at_start ();
132 void recompute_at_end ();
134 void set_position_internal (framepos_t pos, bool allow_bbt_recompute);
135 void set_length_internal (framecnt_t len);
136 void set_start_internal (framecnt_t);
137 void update_length_beats ();
139 void model_changed ();
140 void model_automation_state_changed (Evoral::Parameter const &);
141 void model_contents_changed ();
143 void set_start_beats_from_start_frames ();
144 void update_after_tempo_map_change ();
146 std::set<Evoral::Parameter> _filtered_parameters; ///< parameters that we ask our source not to return when reading
147 PBD::ScopedConnection _model_connection;
148 PBD::ScopedConnection _source_connection;
149 PBD::ScopedConnection _model_contents_connection;
151 double _last_length_beats;
154 } /* namespace ARDOUR */
157 #endif /* __ardour_midi_region_h__ */