~AudioRegion();
+ void copy_settings (boost::shared_ptr<const AudioRegion>);
+
bool source_equivalent (boost::shared_ptr<const Region>) const;
bool speed_mismatch (float) const;
uint32_t chan_n=0, double samples_per_unit= 1.0) const;
/* Readable interface */
+
+ enum ReadOps {
+ ReadOpsNone = 0x0,
+ ReadOpsOwnAutomation = 0x1,
+ ReadOpsOwnScaling = 0x2,
+ ReadOpsCount = 0x4,
+ ReadOpsFades = 0x8
+ };
virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const;
+ virtual nframes64_t read_with_ops (Sample*, nframes64_t pos, nframes64_t cnt, int channel, ReadOps rops) const;
virtual nframes64_t readable_length() const { return length(); }
virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf,
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0,
- bool raw = false) const;
+ ReadOps readops = ReadOps (~0)) const;
bool verify_start (nframes_t position);
bool verify_length (nframes_t& length);
: Region (other),
_fade_in (other->_fade_in),
_fade_out (other->_fade_out),
- _envelope (other->_envelope)
+ _envelope (other->_envelope)
+
{
/* Pure copy constructor */
}
}
- _scale_amplitude = other->_scale_amplitude;
- _envelope = other->_envelope;
-
_fade_in_disabled = 0;
_fade_out_disabled = 0;
-
+
listen_to_my_curves ();
listen_to_my_sources ();
}
_fade_out.StateChanged.connect (mem_fun (*this, &AudioRegion::fade_out_changed));
}
+void
+AudioRegion::copy_settings (boost::shared_ptr<const AudioRegion> other)
+{
+ _fade_in = other->_fade_in;
+ _fade_out = other->_fade_out;
+ _envelope = other->_envelope;
+ _flags = other->_flags;
+ _scale_amplitude = other->_scale_amplitude;
+ _fade_in_disabled = other->_fade_in_disabled;
+ _fade_out_disabled = other->_fade_out_disabled;
+
+ if (_length != other->length()) {
+ _envelope.extend_to (_length);
+ }
+}
+
bool
AudioRegion::verify_length (nframes_t& len)
{
return true;
}
+
bool
AudioRegion::verify_start (nframes_t pos)
{
AudioRegion::read (Sample* buf, nframes64_t position, nframes64_t cnt, int channel) const
{
/* raw read, no fades, no gain, nada */
- return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, true);
+ return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, ReadOps (0));
+}
+
+nframes64_t
+AudioRegion::read_with_ops (Sample* buf, nframes64_t position, nframes64_t cnt, int channel, ReadOps rops) const
+{
+ return _read_at (sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, rops);
}
nframes_t
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
{
/* regular diskstream/butler read complete with fades etc */
- return _read_at (sources, _length, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames, false);
+ return _read_at (sources, _length, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
}
nframes_t
uint32_t chan_n,
nframes_t read_frames,
nframes_t skip_frames,
- bool raw) const
+ ReadOps rops) const
{
nframes_t internal_offset;
nframes_t buf_offset;
nframes_t to_read;
+ bool raw = (rops == ReadOpsNone);
if (muted() && !raw) {
return 0; /* read nothing */
mixdown_buffer += buf_offset;
}
- if (!raw) {
+ if (rops & ReadOpsCount) {
_read_data_count = 0;
}
return 0; /* "read nothing" */
}
- if (!raw) {
+ if (rops & ReadOpsCount) {
_read_data_count += srcs[chan_n]->read_data_count();
}
*/
memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
-
- /* no fades required */
-
- if (!raw) {
- goto merge;
- }
}
- /* fade in */
-
- if (!raw) {
+ if (rops & ReadOpsFades) {
+ /* fade in */
+
if ((_flags & FadeIn) && Config->get_use_region_fades()) {
nframes_t fade_in_length = (nframes_t) _fade_in.back()->when;
}
}
+ }
- /* Regular gain curves */
+ /* Regular gain curves and scaling */
+
+ if ((rops & ReadOpsOwnAutomation) && envelope_active()) {
+ _envelope.get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
- if (envelope_active()) {
- _envelope.get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
-
- if (_scale_amplitude != 1.0f) {
- for (nframes_t n = 0; n < to_read; ++n) {
- mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
- }
- } else {
- for (nframes_t n = 0; n < to_read; ++n) {
- mixdown_buffer[n] *= gain_buffer[n];
- }
+ if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
+ for (nframes_t n = 0; n < to_read; ++n) {
+ mixdown_buffer[n] *= gain_buffer[n] * _scale_amplitude;
+ }
+ } else {
+ for (nframes_t n = 0; n < to_read; ++n) {
+ mixdown_buffer[n] *= gain_buffer[n];
}
- } else if (_scale_amplitude != 1.0f) {
- Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
}
+ } else if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
+ Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
+ }
- merge:
+ if (!opaque()) {
- if (!opaque()) {
-
- /* gack. the things we do for users.
- */
-
- buf += buf_offset;
+ /* gack. the things we do for users.
+ */
+
+ buf += buf_offset;
- for (nframes_t n = 0; n < to_read; ++n) {
- buf[n] += mixdown_buffer[n];
- }
- }
- }
+ for (nframes_t n = 0; n < to_read; ++n) {
+ buf[n] += mixdown_buffer[n];
+ }
+ }
return to_read;
}