ardour
audioregion.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 */
19 
20 #ifndef __ardour_audio_region_h__
21 #define __ardour_audio_region_h__
22 
23 #include <vector>
24 #include <list>
25 
26 #include "pbd/fastlog.h"
27 #include "pbd/undo.h"
28 
29 #include "ardour/ardour.h"
30 #include "ardour/automatable.h"
31 #include "ardour/automation_list.h"
33 #include "ardour/logcurve.h"
34 #include "ardour/region.h"
35 
36 class XMLNode;
38 class PlaylistReadTest;
39 
40 namespace ARDOUR {
41 
42 namespace Properties {
54 }
55 
56 class Playlist;
57 class Session;
58 class Filter;
59 class AudioSource;
60 
61 
63 {
64  public:
65  static void make_property_quarks ();
66 
67  ~AudioRegion();
68 
69  void copy_settings (boost::shared_ptr<const AudioRegion>);
70 
71  bool source_equivalent (boost::shared_ptr<const Region>) const;
72 
73  bool speed_mismatch (float) const;
74 
75  boost::shared_ptr<AudioSource> audio_source (uint32_t n=0) const;
76 
77  void set_scale_amplitude (gain_t);
78  gain_t scale_amplitude() const { return _scale_amplitude; }
79 
80  void normalize (float, float target_in_dB = 0.0f);
81  double maximum_amplitude (Progress* p = 0) const;
82 
83  bool envelope_active () const { return _envelope_active; }
84  bool fade_in_active () const { return _fade_in_active; }
85  bool fade_out_active () const { return _fade_out_active; }
86 
87  boost::shared_ptr<AutomationList> fade_in() { return _fade_in.val (); }
88  boost::shared_ptr<AutomationList> inverse_fade_in() { return _inverse_fade_in.val (); }
89  boost::shared_ptr<AutomationList> fade_out() { return _fade_out.val (); }
90  boost::shared_ptr<AutomationList> inverse_fade_out() { return _inverse_fade_out.val (); }
91  boost::shared_ptr<AutomationList> envelope() { return _envelope.val (); }
92 
93  Evoral::Range<framepos_t> body_range () const;
94 
95  virtual framecnt_t read_peaks (PeakData *buf, framecnt_t npeaks,
96  framecnt_t offset, framecnt_t cnt,
97  uint32_t chan_n=0, double frames_per_pixel = 1.0) const;
98 
99  /* Readable interface */
100 
101  virtual framecnt_t read (Sample*, framepos_t pos, framecnt_t cnt, int channel) const;
102  virtual framecnt_t readable_length() const { return length(); }
103 
104  virtual framecnt_t read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
106  framecnt_t cnt,
107  uint32_t chan_n = 0) const;
108 
109  virtual framecnt_t master_read_at (Sample *buf, Sample *mixdown_buf, float *gain_buf,
110  framepos_t position, framecnt_t cnt, uint32_t chan_n=0) const;
111 
112  virtual framecnt_t read_raw_internal (Sample*, framepos_t, framecnt_t, int channel) const;
113 
114  XMLNode& state ();
115  XMLNode& get_basic_state ();
116  int set_state (const XMLNode&, int version);
117 
118  void fade_range (framepos_t, framepos_t);
119 
120  bool fade_in_is_default () const;
121  bool fade_out_is_default () const;
122 
123  void set_fade_in_active (bool yn);
124  void set_fade_in_shape (FadeShape);
125  void set_fade_in_length (framecnt_t);
126  void set_fade_in (FadeShape, framecnt_t);
127  void set_fade_in (boost::shared_ptr<AutomationList>);
128 
129  void set_fade_out_active (bool yn);
130  void set_fade_out_shape (FadeShape);
131  void set_fade_out_length (framecnt_t);
132  void set_fade_out (FadeShape, framecnt_t);
133  void set_fade_out (boost::shared_ptr<AutomationList>);
134 
135  void set_default_fade_in ();
136  void set_default_fade_out ();
137 
138  framecnt_t verify_xfade_bounds (framecnt_t, bool start);
139 
140  void set_envelope_active (bool yn);
141  void set_default_envelope ();
142 
143  int separate_by_channel (ARDOUR::Session&, std::vector<boost::shared_ptr<Region> >&) const;
144 
145  /* automation */
146 
148  control(const Evoral::Parameter& id, bool create=false) {
149  return _automatable.control(id, create);
150  }
151 
153  control(const Evoral::Parameter& id) const {
154  return _automatable.control(id);
155  }
156 
157  /* xfade/fade interactions */
158 
159  void suspend_fade_in ();
160  void suspend_fade_out ();
161  void resume_fade_in ();
162  void resume_fade_out ();
163 
164  void add_transient (framepos_t where);
165  void remove_transient (framepos_t where);
166  int set_transients (AnalysisFeatureList&);
167  int get_transients (AnalysisFeatureList&, bool force_new = false);
168  int update_transient (framepos_t old_position, framepos_t new_position);
169  int adjust_transients (frameoffset_t delta);
170 
171  AudioIntervalResult find_silence (Sample, framecnt_t, InterThreadInfo&) const;
172 
173  private:
174  friend class RegionFactory;
175 
177  AudioRegion (const SourceList &);
182 
183  private:
184  friend class ::AudioRegionReadTest;
185  friend class ::PlaylistReadTest;
186 
194 
195  void register_properties ();
196  void post_set (const PBD::PropertyChange&);
197 
198  void init ();
199  void set_default_fades ();
200 
201  void recompute_gain_at_end ();
202  void recompute_gain_at_start ();
203 
204  framecnt_t read_from_sources (SourceList const &, framecnt_t, Sample *, framepos_t, framecnt_t, uint32_t) const;
205 
206  void recompute_at_start ();
207  void recompute_at_end ();
208 
209  void envelope_changed ();
210  void fade_in_changed ();
211  void fade_out_changed ();
212  void source_offset_changed ();
213  void listen_to_my_curves ();
214  void connect_to_analysis_changed ();
215  void connect_to_header_position_offset_changed ();
216 
217 
226 
227  boost::shared_ptr<ARDOUR::Region> get_single_other_xfade_region (bool start) const;
228 
229  protected:
230  /* default constructor for derived (compound) types */
231 
232  AudioRegion (Session& s, framepos_t, framecnt_t, std::string name);
233 
234  int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal);
235 };
236 
237 } /* namespace ARDOUR */
238 
239 /* access from C objects */
240 
241 extern "C" {
242  LIBARDOUR_API int region_read_peaks_from_c (void *arg, uint32_t npeaks, uint32_t start, uint32_t length, intptr_t data, uint32_t n_chan, double samples_per_unit);
243  LIBARDOUR_API uint32_t region_length_from_c (void *arg);
244  LIBARDOUR_API uint32_t sourcefile_length_from_c (void *arg, double);
245 }
246 
247 #endif /* __ardour_audio_region_h__ */
LIBARDOUR_API PBD::PropertyDescriptor< bool > default_fade_in
Definition: audioregion.cc:62
LIBARDOUR_API PBD::PropertyDescriptor< bool > fade_out_active
Definition: audioregion.cc:65
LIBARDOUR_API PBD::PropertyDescriptor< bool > default_fade_out
Definition: audioregion.cc:63
LIBARDOUR_API uint32_t sourcefile_length_from_c(void *arg, double)
boost::shared_ptr< Evoral::Control > control(const Evoral::Parameter &id, bool create=false)
Definition: audioregion.h:148
PBD::Property< bool > _default_fade_out
Definition: audioregion.h:189
PBD::Property< bool > _fade_out_active
Definition: audioregion.h:191
AutomationListProperty _inverse_fade_in
Definition: audioregion.h:219
PBD::Property< gain_t > _scale_amplitude
Definition: audioregion.h:193
boost::shared_ptr< AutomationList > fade_in()
Definition: audioregion.h:87
AutomationListProperty _envelope
Definition: audioregion.h:222
std::list< std::pair< frameoffset_t, frameoffset_t > > AudioIntervalResult
Definition: types.h:83
uint32_t _fade_out_suspended
Definition: audioregion.h:225
boost::shared_ptr< AutomationList > fade_out()
Definition: audioregion.h:89
PBD::Property< bool > _default_fade_in
Definition: audioregion.h:188
tuple f
Definition: signals.py:35
float gain_t
Definition: types.h:58
LIBARDOUR_API uint32_t region_length_from_c(void *arg)
LIBARDOUR_API int region_read_peaks_from_c(void *arg, uint32_t npeaks, uint32_t start, uint32_t length, intptr_t data, uint32_t n_chan, double samples_per_unit)
AutomationListProperty _inverse_fade_out
Definition: audioregion.h:221
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
Definition: region.cc:63
bool fade_in_active() const
Definition: audioregion.h:84
AutomationListProperty _fade_out
Definition: audioregion.h:220
boost::shared_ptr< AutomationList > envelope()
Definition: audioregion.h:91
virtual framecnt_t readable_length() const
Definition: audioregion.h:102
Automatable _automatable
Definition: audioregion.h:223
int64_t framecnt_t
Definition: types.h:76
float Sample
Definition: types.h:54
std::list< framepos_t > AnalysisFeatureList
Definition: types.h:530
bool fade_out_active() const
Definition: audioregion.h:85
PBD::Property< bool > _envelope_active
Definition: audioregion.h:187
Definition: amp.h:29
gain_t scale_amplitude() const
Definition: audioregion.h:78
std::vector< boost::shared_ptr< Source > > SourceList
Definition: region.h:91
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > fade_out
Definition: audioregion.cc:69
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > fade_in
Definition: audioregion.cc:67
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > inverse_fade_in
Definition: audioregion.cc:68
int intptr_t
Definition: types.h:46
LIBARDOUR_API void make_property_quarks()
int64_t framepos_t
Definition: types.h:66
uint32_t _fade_in_suspended
Definition: audioregion.h:224
FadeShape
Definition: types.h:592
int64_t frameoffset_t
Definition: types.h:71
#define LIBARDOUR_API
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > inverse_fade_out
Definition: audioregion.cc:70
const char * name
boost::shared_ptr< AutomationList > inverse_fade_in()
Definition: audioregion.h:88
Definition: xml++.h:95
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
Definition: region.cc:65
boost::shared_ptr< AutomationList > inverse_fade_out()
Definition: audioregion.h:90
virtual boost::shared_ptr< const Evoral::Control > control(const Evoral::Parameter &id) const
Definition: audioregion.h:153
LIBARDOUR_API PBD::PropertyDescriptor< float > scale_amplitude
Definition: audioregion.cc:66
LIBARDOUR_API bool init(bool with_vst, bool try_optimization, const char *localedir)
Definition: globals.cc:376
LIBARDOUR_API PBD::PropertyDescriptor< bool > envelope_active
Definition: audioregion.cc:61
LIBARDOUR_API PBD::PropertyDescriptor< bool > fade_in_active
Definition: audioregion.cc:64
PBD::Property< bool > _fade_in_active
Definition: audioregion.h:190
AutomationListProperty _fade_in
Definition: audioregion.h:218
LIBARDOUR_API PBD::PropertyDescriptor< boost::shared_ptr< AutomationList > > envelope
Definition: audioregion.cc:71
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
Definition: region.cc:64
bool envelope_active() const
Definition: audioregion.h:83