fix incorrect 3rd arg to AudioRegion::read_peaks() - was passing end, not cnt. Fixes waveforms at high zoom

This commit is contained in:
Paul Davis 2013-04-26 11:10:19 -04:00
parent 7de31d5a41
commit f9a46e78d6

View file

@ -160,6 +160,20 @@ WaveView::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
double const rend = _region->length() / _samples_per_pixel; double const rend = _region->length() / _samples_per_pixel;
list<CacheEntry*>::iterator cache = _cache.begin (); list<CacheEntry*>::iterator cache = _cache.begin ();
#if 0
cerr << name << " cache contains " << _cache.size() << endl;
while (cache != _cache.end()) {
cerr << "\tsamples " << (*cache)->start() << " .. " << (*cache)->end()
<< " pixels "
<< to_pixel_offset (_region_start, (*cache)->start(), _samples_per_pixel)
<< " .. "
<< to_pixel_offset (_region_start, (*cache)->end(), _samples_per_pixel)
<< endl;
++cache;
}
cache = _cache.begin();
#endif
while ((end - start) > 1.0) { while ((end - start) > 1.0) {
@ -250,6 +264,21 @@ WaveView::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
double this_end = min (end, to_pixel_offset (_region_start, image->end (), _samples_per_pixel)); double this_end = min (end, to_pixel_offset (_region_start, image->end (), _samples_per_pixel));
double const image_origin = to_pixel_offset (_region_start, image->start(), _samples_per_pixel); double const image_origin = to_pixel_offset (_region_start, image->start(), _samples_per_pixel);
#if 0
cerr << "\t\tDraw image between "
<< start
<< " .. "
<< this_end
<< " using image spanning "
<< image->start()
<< " .. "
<< image->end ()
<< " pixels "
<< to_pixel_offset (_region_start, image->start(), _samples_per_pixel)
<< " .. "
<< to_pixel_offset (_region_start, image->end(), _samples_per_pixel)
<< endl;
#endif
context->rectangle (start, area.y0, this_end - start, area.height()); context->rectangle (start, area.y0, this_end - start, area.height());
context->set_source (image->image(), image_origin, 0); context->set_source (image->image(), image_origin, 0);
@ -449,7 +478,7 @@ WaveView::CacheEntry::CacheEntry (WaveView const * wave_view, double start, doub
_wave_view->_region->read_peaks (_peaks.get(), _n_peaks, _wave_view->_region->read_peaks (_peaks.get(), _n_peaks,
(framecnt_t) floor (_start), (framecnt_t) floor (_start),
(framecnt_t) ceil (_end), (framecnt_t) ceil (_end - _start),
_wave_view->_channel, _wave_view->_samples_per_pixel); _wave_view->_channel, _wave_view->_samples_per_pixel);
} }
@ -503,13 +532,15 @@ WaveView::CacheEntry::image ()
if (_wave_view->_logscaled) { if (_wave_view->_logscaled) {
for (int i = 0; i < _n_peaks; ++i) { for (int i = 0; i < _n_peaks; ++i) {
Coord y = _peaks[i].max; Coord y = _peaks[i].max;
if (y > 0.0) { if (y > 0.0) {
context->line_to (i + 0.5, position (alt_log_meter (fast_coefficient_to_dB (y)))); y = position (alt_log_meter (fast_coefficient_to_dB (y)));
} else if (y < 0.0) { } else if (y < 0.0) {
context->line_to (i + 0.5, position (-alt_log_meter (fast_coefficient_to_dB (-y)))); y = position (-alt_log_meter (fast_coefficient_to_dB (-y)));
} else { } else {
context->line_to (i + 0.5, position (0.0)); y = position (0.0);
} }
context->line_to (i + 0.5, y);
} }
} else { } else {
for (int i = 0; i < _n_peaks; ++i) { for (int i = 0; i < _n_peaks; ++i) {
@ -522,7 +553,6 @@ WaveView::CacheEntry::image ()
context->line_to (_n_peaks + 10, position (0.0)); context->line_to (_n_peaks + 10, position (0.0));
/* bottom half, in reverse */ /* bottom half, in reverse */
if (_wave_view->_shape == WaveView::Rectified) { if (_wave_view->_shape == WaveView::Rectified) {