summaryrefslogtreecommitdiff
path: root/libs/ardour/audioregion.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/audioregion.cc')
-rw-r--r--libs/ardour/audioregion.cc48
1 files changed, 24 insertions, 24 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 5e0cd136ff..7c0893f288 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -291,7 +291,7 @@ nframes64_t
AudioRegion::read (Sample* buf, nframes64_t position, nframes64_t cnt, int channel) const
{
/* raw read, no fades, no gain, nada */
- return _read_at (_sources, buf, 0, 0, _position + position, cnt, channel, 0, 0, true);
+ return _read_at (_sources, _length, buf, 0, 0, _position + position, cnt, channel, 0, 0, true);
}
nframes_t
@@ -300,18 +300,19 @@ AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, n
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, 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, false);
}
nframes_t
AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position,
nframes_t cnt, uint32_t chan_n) const
{
- return _read_at (_master_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0);
+ return _read_at (_master_sources, _master_sources.front()->length(), buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0);
}
nframes_t
-AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
+AudioRegion::_read_at (const SourceList& srcs, nframes_t limit,
+ Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
nframes_t position, nframes_t cnt,
uint32_t chan_n,
nframes_t read_frames,
@@ -337,11 +338,11 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
buf_offset = 0;
}
- if (internal_offset >= _length) {
+ if (internal_offset >= limit) {
return 0; /* read nothing */
}
- if ((to_read = min (cnt, _length - internal_offset)) == 0) {
+ if ((to_read = min (cnt, limit - internal_offset)) == 0) {
return 0; /* read nothing */
}
@@ -394,13 +395,13 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
if (internal_offset < fade_in_length) {
- nframes_t limit;
+ nframes_t fi_limit;
- limit = min (to_read, fade_in_length - internal_offset);
+ fi_limit = min (to_read, fade_in_length - internal_offset);
- _fade_in->curve().get_vector (internal_offset, internal_offset+limit, gain_buffer, limit);
+ _fade_in->curve().get_vector (internal_offset, internal_offset+fi_limit, gain_buffer, fi_limit);
- for (nframes_t n = 0; n < limit; ++n) {
+ for (nframes_t n = 0; n < fi_limit; ++n) {
mixdown_buffer[n] *= gain_buffer[n];
}
}
@@ -409,40 +410,40 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
/* fade out */
if (_flags & FadeOut) {
-
+
/* see if some part of this read is within the fade out */
/* ................. >| REGION
- _length
+ limit
{ } FADE
fade_out_length
^
- _length - fade_out_length
+ limit - fade_out_length
|--------------|
^internal_offset
^internal_offset + to_read
we need the intersection of [internal_offset,internal_offset+to_read] with
- [_length - fade_out_length, _length]
+ [limit - fade_out_length, limit]
*/
nframes_t fade_out_length = (nframes_t) _fade_out->back()->when;
- nframes_t fade_interval_start = max(internal_offset, _length-fade_out_length);
- nframes_t fade_interval_end = min(internal_offset + to_read, _length);
-
+ nframes_t fade_interval_start = max(internal_offset, limit-fade_out_length);
+ nframes_t fade_interval_end = min(internal_offset + to_read, limit);
+
if (fade_interval_end > fade_interval_start) {
/* (part of the) the fade out is in this buffer */
-
- nframes_t limit = fade_interval_end - fade_interval_start;
- nframes_t curve_offset = fade_interval_start - (_length-fade_out_length);
+
+ nframes_t fo_limit = fade_interval_end - fade_interval_start;
+ nframes_t curve_offset = fade_interval_start - (limit-fade_out_length);
nframes_t fade_offset = fade_interval_start - internal_offset;
- _fade_out->curve().get_vector (curve_offset,curve_offset+limit, gain_buffer, limit);
-
- for (nframes_t n = 0, m = fade_offset; n < limit; ++n, ++m) {
+ _fade_out->curve().get_vector (curve_offset, curve_offset+fo_limit, gain_buffer, fo_limit);
+
+ for (nframes_t n = 0, m = fade_offset; n < fo_limit; ++n, ++m) {
mixdown_buffer[m] *= gain_buffer[n];
}
}
@@ -1020,7 +1021,6 @@ AudioRegion::read_raw_internal (Sample* buf, nframes_t pos, nframes_t cnt) const
return audio_source()->read (buf, pos, cnt);
}
-
int
AudioRegion::exportme (Session& session, ARDOUR::ExportSpecification& spec)
{