Oops, fix build.
[ardour.git] / libs / ardour / audioregion.cc
index 9d94651eb05f2790775b9cb76708b9d1585d362b..5c213bfb7cacac75d7f7b7637c72378e02d21d2b 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <set>
 
+#include <boost/scoped_array.hpp>
 
 #include <glibmm/thread.h>
 
@@ -297,8 +298,8 @@ AudioRegion::set_envelope_active (bool yn)
        }
 }
 
-ARDOUR::nframes_t
-AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nframes_t cnt, uint32_t chan_n, double samples_per_unit) const
+ARDOUR::framecnt_t
+AudioRegion::read_peaks (PeakData *buf, framecnt_t npeaks, framecnt_t offset, framecnt_t cnt, uint32_t chan_n, double samples_per_unit) const
 {
        if (chan_n >= _sources.size()) {
                return 0;
@@ -308,7 +309,7 @@ AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nfra
                return 0;
        } else {
                if (_scale_amplitude != 1.0f) {
-                       for (nframes_t n = 0; n < npeaks; ++n) {
+                       for (framecnt_t n = 0; n < npeaks; ++n) {
                                buf[n].max *= _scale_amplitude;
                                buf[n].min *= _scale_amplitude;
                        }
@@ -438,20 +439,19 @@ AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
 
                if (_fade_in_active && _session.config.get_use_region_fades()) {
 
-                       nframes_t fade_in_length = (nframes_t) _fade_in->back()->when;
+                       framecnt_t fade_in_length = (framecnt_t) _fade_in->back()->when;
 
                        /* see if this read is within the fade in */
 
                        if (internal_offset < fade_in_length) {
 
-                               nframes_t fi_limit;
+                               framecnt_t fi_limit;
 
                                fi_limit = min (to_read, fade_in_length - internal_offset);
 
-
                                _fade_in->curve().get_vector (internal_offset, internal_offset+fi_limit, gain_buffer, fi_limit);
 
-                               for (nframes_t n = 0; n < fi_limit; ++n) {
+                               for (framecnt_t n = 0; n < fi_limit; ++n) {
                                        mixdown_buffer[n] *= gain_buffer[n];
                                }
                        }
@@ -480,20 +480,20 @@ AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
                */
 
 
-                       nframes_t fade_out_length = (nframes_t) _fade_out->back()->when;
-                       nframes_t fade_interval_start = max(internal_offset, limit-fade_out_length);
-                       nframes_t fade_interval_end   = min(internal_offset + to_read, limit);
+                       framecnt_t fade_out_length = (framecnt_t) _fade_out->back()->when;
+                       framecnt_t fade_interval_start = max(internal_offset, limit-fade_out_length);
+                       framecnt_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 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;
+                               framecnt_t fo_limit = fade_interval_end - fade_interval_start;
+                               framecnt_t curve_offset = fade_interval_start - (limit-fade_out_length);
+                               framecnt_t fade_offset = fade_interval_start - internal_offset;
 
                                _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) {
+                               for (framecnt_t n = 0, m = fade_offset; n < fo_limit; ++n, ++m) {
                                        mixdown_buffer[m] *= gain_buffer[n];
                                }
                        }
@@ -507,11 +507,11 @@ AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
                _envelope->curve().get_vector (internal_offset, internal_offset + to_read, gain_buffer, to_read);
 
                if ((rops & ReadOpsOwnScaling) && _scale_amplitude != 1.0f) {
-                       for (nframes_t n = 0; n < to_read; ++n) {
+                       for (framecnt_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) {
+                       for (framecnt_t n = 0; n < to_read; ++n) {
                                mixdown_buffer[n] *= gain_buffer[n];
                        }
                }
@@ -520,7 +520,7 @@ AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
                // XXX this should be using what in 2.0 would have been:
                // Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
 
-               for (nframes_t n = 0; n < to_read; ++n) {
+               for (framecnt_t n = 0; n < to_read; ++n) {
                        mixdown_buffer[n] *= _scale_amplitude;
                }
        }
@@ -532,7 +532,7 @@ AudioRegion::_read_at (const SourceList& /*srcs*/, framecnt_t limit,
 
                buf += buf_offset;
 
-               for (nframes_t n = 0; n < to_read; ++n) {
+               for (framecnt_t n = 0; n < to_read; ++n) {
                        buf[n] += mixdown_buffer[n];
                }
        }
@@ -713,13 +713,13 @@ AudioRegion::set_state (const XMLNode& node, int version)
 void
 AudioRegion::set_fade_in_shape (FadeShape shape)
 {
-       set_fade_in (shape, (nframes_t) _fade_in->back()->when);
+       set_fade_in (shape, (framecnt_t) _fade_in->back()->when);
 }
 
 void
 AudioRegion::set_fade_out_shape (FadeShape shape)
 {
-       set_fade_out (shape, (nframes_t) _fade_out->back()->when);
+       set_fade_out (shape, (framecnt_t) _fade_out->back()->when);
 }
 
 void
@@ -1063,8 +1063,8 @@ int
 AudioRegion::exportme (Session& /*session*/, ARDOUR::ExportSpecification& /*spec*/)
 {
        // TODO EXPORT
-//     const nframes_t blocksize = 4096;
-//     nframes_t to_read;
+//     const framecnt_t blocksize = 4096;
+//     framecnt_t to_read;
 //     int status = -1;
 //
 //     spec.channels = _sources.size();
@@ -1099,7 +1099,7 @@ AudioRegion::exportme (Session& /*session*/, ARDOUR::ExportSpecification& /*spec
 //                                     goto out;
 //                             }
 //
-//                             for (nframes_t x = 0; x < to_read; ++x) {
+//                             for (framecnt_t x = 0; x < to_read; ++x) {
 //                                     spec.dataF[chan+(x*spec.channels)] = buf[x];
 //                             }
 //                     }
@@ -1499,20 +1499,20 @@ in this and future transient-detection operations.\n\
  *
  *  @param threshold Threshold below which signal is considered silence (as a sample value)
  *  @param min_length Minimum length of silent period to be reported.
- *  @return Silent periods; first of pair is the offset within the region, second is the length of the period
+ *  @return Silent intervals, measured relative to the region start in the source
  */
 
-std::list<std::pair<frameoffset_t, framecnt_t> >
+AudioIntervalResult
 AudioRegion::find_silence (Sample threshold, framecnt_t min_length, InterThreadInfo& itt) const
 {
        framecnt_t const block_size = 64 * 1024;
-       Sample loudest[block_size];
-       Sample buf[block_size];
+       boost::scoped_array<Sample> loudest (new Sample[block_size]);
+        boost::scoped_array<Sample> buf (new Sample[block_size]);
 
        framepos_t pos = _start;
        framepos_t const end = _start + _length - 1;
-
-       std::list<std::pair<frameoffset_t, framecnt_t> > silent_periods;
+        
+       AudioIntervalResult silent_periods;
 
        bool in_silence = false;
        frameoffset_t silence_start = 0;
@@ -1521,10 +1521,10 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length, InterThreadI
        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);
+               memset (loudest.get(), 0, sizeof (Sample) * block_size);
                for (uint32_t n = 0; n < n_channels(); ++n) {
 
-                       read_raw_internal (buf, pos, block_size, n);
+                       read_raw_internal (buf.get(), pos, block_size, n);
                        for (framecnt_t i = 0; i < block_size; ++i) {
                                loudest[i] = max (loudest[i], abs (buf[i]));
                        }