changes to help strp silence
git-svn-id: svn://localhost/ardour2/branches/3.0@6725 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a7eb8f4733
commit
c2c224727e
@ -178,7 +178,7 @@ class AudioRegion : public Region
|
||||
void resume_fade_out ();
|
||||
|
||||
int get_transients (AnalysisFeatureList&, bool force_new = false);
|
||||
std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t) const;
|
||||
std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t, InterThreadInfo&) const;
|
||||
|
||||
private:
|
||||
friend class RegionFactory;
|
||||
|
@ -1458,7 +1458,7 @@ then quit ardour and restart."));
|
||||
*/
|
||||
|
||||
std::list<std::pair<frameoffset_t, framecnt_t> >
|
||||
AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
|
||||
AudioRegion::find_silence (Sample threshold, framecnt_t min_length, InterThreadInfo& itt) const
|
||||
{
|
||||
framecnt_t const block_size = 64 * 1024;
|
||||
Sample loudest[block_size];
|
||||
@ -1473,7 +1473,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
|
||||
frameoffset_t silence_start = 0;
|
||||
bool silence;
|
||||
|
||||
while (pos < end) {
|
||||
while (pos < end && !itt.cancel) {
|
||||
|
||||
/* fill `loudest' with the loudest absolute sample at each instant, across all channels */
|
||||
memset (loudest, 0, sizeof (Sample) * block_size);
|
||||
@ -1502,6 +1502,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
|
||||
}
|
||||
|
||||
pos += block_size;
|
||||
itt.progress = (end-pos)/(double)_length;
|
||||
}
|
||||
|
||||
if (in_silence && end - 1 - silence_start >= min_length) {
|
||||
@ -1509,6 +1510,8 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
|
||||
silent_periods.push_back (std::make_pair (silence_start, end));
|
||||
}
|
||||
|
||||
itt.done = true;
|
||||
|
||||
return silent_periods;
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,25 @@ StripSilence::run (boost::shared_ptr<Region> r)
|
||||
/* we only operate on AudioRegions, for now, though this could be adapted to MIDI
|
||||
as well I guess */
|
||||
boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
|
||||
InterThreadInfo itt;
|
||||
|
||||
if (!region) {
|
||||
results.push_back (r);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we don't care about this but we need to fill out the fields
|
||||
anyway. XXX should really be a default constructor for ITT
|
||||
*/
|
||||
|
||||
itt.done = false;
|
||||
itt.cancel = false;
|
||||
itt.progress = 0.0;
|
||||
itt.thread = 0;
|
||||
|
||||
/* find periods of silence in the region */
|
||||
std::list<std::pair<frameoffset_t, framecnt_t> > const silence =
|
||||
region->find_silence (dB_to_coefficient (_threshold), _minimum_length);
|
||||
region->find_silence (dB_to_coefficient (_threshold), _minimum_length, itt);
|
||||
|
||||
if (silence.size () == 1 && silence.front().first == 0 && silence.front().second == region->length() - 1) {
|
||||
/* the region is all silence, so just return with nothing */
|
||||
|
Loading…
Reference in New Issue
Block a user