, _fade_in_active (Properties::fade_in_active, true) \
, _fade_out_active (Properties::fade_out_active, true) \
, _scale_amplitude (Properties::scale_amplitude, 1.0)
-
+
#define AUDIOREGION_COPY_STATE(other) \
_envelope_active (Properties::envelope_active, other->_envelope_active) \
, _default_fade_in (Properties::default_fade_in, other->_default_fade_in) \
if (_left_of_split) {
if (_fade_in->back()->when >= _length) {
set_default_fade_in ();
- }
+ }
set_default_fade_out ();
_left_of_split = false;
}
if (_right_of_split) {
if (_fade_out->back()->when >= _length) {
set_default_fade_out ();
- }
+ }
set_default_fade_in ();
_right_of_split = false;
AudioRegion::read (Sample* buf, framepos_t timeline_position, framecnt_t cnt, int channel) const
{
/* raw read, no fades, no gain, nada */
- return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, 0, 0, ReadOps (0));
+ return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, ReadOps (0));
}
framecnt_t
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- framepos_t file_position, framecnt_t cnt, uint32_t chan_n,
- framecnt_t read_frames, framecnt_t skip_frames) const
+ framepos_t file_position, framecnt_t cnt, uint32_t chan_n) const
{
/* regular diskstream/butler read complete with fades etc */
return _read_at (_sources, _length, buf, mixdown_buffer, gain_buffer,
- file_position, cnt, chan_n, read_frames, skip_frames, ReadOps (~0));
+ file_position, cnt, chan_n, ReadOps (~0));
}
framecnt_t
{
/* do not read gain/scaling/fades and do not count this disk i/o in statistics */
+ assert (cnt >= 0);
+
return _read_at (_master_sources, _master_sources.front()->length(_master_sources.front()->timeline_position()),
- buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0, ReadOps (0));
+ buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, ReadOps (0));
}
+/** @param position Position within the session */
framecnt_t
-AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
+AudioRegion::_read_at (const SourceList& srcs, framecnt_t limit,
Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
- framepos_t position,
+ framepos_t position,
framecnt_t cnt,
uint32_t chan_n,
- framecnt_t /*read_frames*/,
- framecnt_t /*skip_frames*/,
ReadOps rops) const
{
+ assert (cnt >= 0);
+
frameoffset_t internal_offset;
frameoffset_t buf_offset;
framecnt_t to_read;
if (position < _position) {
internal_offset = 0;
buf_offset = _position - position;
+ /* if this fails then the requested section is entirely
+ before the position of this region. An error in xfade
+ construction that was fixed in oct 2011 (rev 10259)
+ led to this being the case. We don't want to crash
+ when this error is encountered, so just settle
+ on displaying an error.
+ */
+ if (cnt < buf_offset) {
+ error << "trying to read region " << name() << " @ " << position << " which is outside region bounds "
+ << _position << " .. " << last_frame() << " (len = " << length() << ')'
+ << endmsg;
+ return 0; // read nothing
+ }
cnt -= buf_offset;
} else {
internal_offset = position - _position;
mixdown_buffer += buf_offset;
}
- if (rops & ReadOpsCount) {
- _read_data_count = 0;
- }
-
if (chan_n < n_channels()) {
- boost::shared_ptr<AudioSource> src = audio_source(chan_n);
+ boost::shared_ptr<AudioSource> src = boost::dynamic_pointer_cast<AudioSource> (srcs[chan_n]);
if (src->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
return 0; /* "read nothing" */
}
- if (rops & ReadOpsCount) {
- _read_data_count += src->read_data_count();
- }
-
} else {
/* track is N-channel, this region has less channels; silence the ones
if (Config->get_replicate_missing_region_channels()) {
/* track is N-channel, this region has less channels, so use a relevant channel
*/
-
+
uint32_t channel = n_channels() % chan_n;
- boost::shared_ptr<AudioSource> src = audio_source (channel);
+ boost::shared_ptr<AudioSource> src = boost::dynamic_pointer_cast<AudioSource> (srcs[channel]);
if (src->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
return 0; /* "read nothing" */
}
- /* adjust read data count appropriately since this was a duplicate read */
- src->dec_read_data_count (to_read);
} else {
memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
}
child = node.add_child ("Envelope");
bool default_env = false;
-
+
// If there are only two points, the points are in the start of the region and the end of the region
// so, if they are both at 1.0f, that means the default region.
-
+
if (_envelope->size() == 2 &&
_envelope->front()->value == 1.0f &&
_envelope->back()->value==1.0f) {
default_env = true;
}
}
-
+
if (default_env) {
child->add_property ("default", "yes");
} else {
const XMLNodeList& nlist = node.children();
const XMLProperty *prop;
LocaleGuard lg (X_("POSIX"));
- boost::shared_ptr<Playlist> the_playlist (_playlist.lock());
+ boost::shared_ptr<Playlist> the_playlist (_playlist.lock());
suspend_property_changes ();
_fade_in->freeze ();
*_fade_in = *f;
_fade_in->thaw ();
-
+
send_change (PropertyChange (Properties::fade_in));
}
_envelope->truncate_end (_length);
_envelope->set_max_xval (_length);
_envelope->thaw ();
-
+
suspend_property_changes();
if (_left_of_split) {
_fade_in->extend_to (_length);
send_change (PropertyChange (Properties::fade_in));
}
-
+
resume_property_changes();
}
/* as above, but the shift was from the front */
_envelope->truncate_start (_length);
-
+
suspend_property_changes();
if (_right_of_split) {
_fade_out->extend_to (_length);
send_change (PropertyChange (Properties::fade_out));
}
-
+
resume_property_changes();
}
*/
PropertyList plist;
-
+
plist.add (Properties::start, _start.val());
plist.add (Properties::length, _length.val());
plist.add (Properties::name, new_name);
framecnt_t
AudioRegion::read_raw_internal (Sample* buf, framepos_t pos, framecnt_t cnt, int channel) const
{
- return audio_source()->read (buf, pos, cnt, channel);
-}
-
-int
-AudioRegion::exportme (Session& /*session*/, ARDOUR::ExportSpecification& /*spec*/)
-{
- // TODO EXPORT
-// const framecnt_t blocksize = 4096;
-// framecnt_t to_read;
-// int status = -1;
-//
-// spec.channels = _sources.size();
-//
-// if (spec.prepare (blocksize, session.frame_rate())) {
-// goto out;
-// }
-//
-// spec.pos = 0;
-// spec.total_frames = _length;
-//
-// while (spec.pos < _length && !spec.stop) {
-//
-//
-// /* step 1: interleave */
-//
-// to_read = min (_length - spec.pos, blocksize);
-//
-// if (spec.channels == 1) {
-//
-// if (read_raw_internal (spec.dataF, _start + spec.pos, to_read) != to_read) {
-// goto out;
-// }
-//
-// } else {
-//
-// Sample buf[blocksize];
-//
-// for (uint32_t chan = 0; chan < spec.channels; ++chan) {
-//
-// if (audio_source(chan)->read (buf, _start + spec.pos, to_read) != to_read) {
-// goto out;
-// }
-//
-// for (framecnt_t x = 0; x < to_read; ++x) {
-// spec.dataF[chan+(x*spec.channels)] = buf[x];
-// }
-// }
-// }
-//
-// if (spec.process (to_read)) {
-// goto out;
-// }
-//
-// spec.pos += to_read;
-// spec.progress = (double) spec.pos /_length;
-//
-// }
-//
-// status = 0;
-//
-// out:
-// spec.running = false;
-// spec.status = status;
-// spec.clear();
-//
-// return status;
- return 0;
+ return audio_source(channel)->read (buf, pos, cnt);
}
void
framecnt_t const blocksize = 64 * 1024;
Sample buf[blocksize];
-
+
while (fpos < fend) {
uint32_t n;
/* read it in */
- if (read_raw_internal (buf, fpos, to_read, 0) != to_read) {
+ if (read_raw_internal (buf, fpos, to_read, n) != to_read) {
return 0;
}
if (afs && afs->destructive()) {
// set_start (source()->natural_position(), this);
- set_position (source()->natural_position(), this);
+ set_position (source()->natural_position());
}
}
return boost::dynamic_pointer_cast<AudioSource>(source(n));
}
-int
+int
AudioRegion::adjust_transients (frameoffset_t delta)
{
for (AnalysisFeatureList::iterator x = _transients.begin(); x != _transients.end(); ++x) {
(*x) = (*x) + delta;
}
-
+
send_change (PropertyChange (Properties::valid_transients));
-
- return 0;
-}
+
+ return 0;
+}
int
AudioRegion::update_transient (framepos_t old_position, framepos_t new_position)
if ((*x) == old_position) {
(*x) = new_position;
send_change (PropertyChange (Properties::valid_transients));
-
+
break;
}
}
-
+
return 0;
}
{
_transients.push_back(where);
_valid_transients = true;
-
+
send_change (PropertyChange (Properties::valid_transients));
}
{
_transients.remove(where);
_valid_transients = true;
-
+
send_change (PropertyChange (Properties::valid_transients));
}
_transients.clear();
_transients = results;
_valid_transients = true;
-
+
send_change (PropertyChange (Properties::valid_transients));
-
+
return 0;
}