ardour
midi_region.h
Go to the documentation of this file.
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 "evoral/types.hpp"
27 
28 #include "ardour/ardour.h"
29 #include "ardour/region.h"
30 
31 class XMLNode;
32 
33 namespace ARDOUR {
34  namespace Properties {
37  }
38 }
39 
40 namespace Evoral {
41 template<typename Time> class EventSink;
42 }
43 
44 namespace ARDOUR {
45 
46 class MidiChannelFilter;
47 class MidiFilter;
48 class MidiModel;
49 class MidiSource;
50 class MidiStateTracker;
51 class Playlist;
52 class Route;
53 class Session;
54 
55 template<typename T> class MidiRingBuffer;
56 
58 {
59  public:
60  static void make_property_quarks ();
61 
62  ~MidiRegion();
63 
64  boost::shared_ptr<MidiRegion> clone (std::string path = std::string()) const;
66 
67  boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
68 
69  /* Stub Readable interface */
70  virtual framecnt_t read (Sample*, framepos_t /*pos*/, framecnt_t /*cnt*/, int /*channel*/) const { return 0; }
71  virtual framecnt_t readable_length() const { return length(); }
72 
75  framecnt_t dur,
76  uint32_t chan_n = 0,
77  NoteMode mode = Sustained,
78  MidiStateTracker* tracker = 0,
79  MidiChannelFilter* filter = 0) const;
80 
81  framecnt_t master_read_at (MidiRingBuffer<framepos_t>& dst,
83  framecnt_t dur,
84  uint32_t chan_n = 0,
85  NoteMode mode = Sustained) const;
86 
87  XMLNode& state ();
88  int set_state (const XMLNode&, int version);
89 
90  int separate_by_channel (ARDOUR::Session&, std::vector< boost::shared_ptr<Region> >&) const;
91 
92  /* automation */
93 
94  boost::shared_ptr<Evoral::Control> control(const Evoral::Parameter& id, bool create=false);
95 
96  virtual boost::shared_ptr<const Evoral::Control> control(const Evoral::Parameter& id) const;
97 
98  /* export */
99 
102 
103  void fix_negative_start ();
104  void transpose (int);
105 
106  protected:
107 
108  virtual bool can_trim_start_before_source_start () const {
109  return true;
110  }
111 
112  private:
113  friend class RegionFactory;
116 
117  MidiRegion (const SourceList&);
120 
121  framecnt_t _read_at (const SourceList&, Evoral::EventSink<framepos_t>& dst,
123  framecnt_t dur,
124  uint32_t chan_n = 0,
125  NoteMode mode = Sustained,
126  MidiStateTracker* tracker = 0,
127  MidiChannelFilter* filter = 0) const;
128 
129  void register_properties ();
130  void post_set (const PBD::PropertyChange&);
131 
132  void recompute_at_start ();
133  void recompute_at_end ();
134 
135  void set_position_internal (framepos_t pos, bool allow_bbt_recompute);
136  void set_length_internal (framecnt_t len);
137  void set_start_internal (framecnt_t);
138  void update_length_beats ();
139 
140  void model_changed ();
141  void model_automation_state_changed (Evoral::Parameter const &);
142 
143  void set_start_beats_from_start_frames ();
144  void update_after_tempo_map_change ();
145 
146  std::set<Evoral::Parameter> _filtered_parameters;
150 
152 };
153 
154 } /* namespace ARDOUR */
155 
156 
157 #endif /* __ardour_midi_region_h__ */
virtual framecnt_t readable_length() const
Definition: midi_region.h:71
NoteMode
Definition: types.h:204
virtual framecnt_t read(Sample *, framepos_t, framecnt_t, int) const
Definition: midi_region.h:70
virtual bool can_trim_start_before_source_start() const
Definition: midi_region.h:108
int64_t framecnt_t
Definition: types.h:76
float Sample
Definition: types.h:54
Definition: amp.h:29
std::set< Evoral::Parameter > _filtered_parameters
parameters that we ask our source not to return when reading
Definition: midi_region.h:146
std::vector< boost::shared_ptr< Source > > SourceList
Definition: region.h:91
LIBARDOUR_API PBD::PropertyDescriptor< Evoral::Beats > start_beats
Definition: midi_region.cc:56
LIBARDOUR_API void make_property_quarks()
int64_t framepos_t
Definition: types.h:66
int64_t frameoffset_t
Definition: types.h:71
PBD::ScopedConnection _model_connection
Definition: midi_region.h:147
double _last_length_beats
Definition: midi_region.h:151
#define LIBARDOUR_API
PBD::ScopedConnection _model_contents_connection
Definition: midi_region.h:149
PBD::ScopedConnection _source_connection
Definition: midi_region.h:148
Definition: xml++.h:95
LIBARDOUR_API PBD::PropertyDescriptor< Evoral::Beats > length_beats
Definition: midi_region.cc:57
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
Definition: region.cc:65
PBD::Property< Evoral::Beats > _length_beats
Definition: midi_region.h:115
PBD::Property< Evoral::Beats > _start_beats
Definition: midi_region.h:114
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
Definition: region.cc:64