- while (start < _region->start() + _region->length()) {
-
- framecnt_t interval_duration = end - start;
-
- if (interval_duration > 0) {
- if (in_silence) {
-
- ArdourCanvas::SimpleRect* cr = new ArdourCanvas::SimpleRect (*group);
- _silent_frames.push_back (cr);
-
- /* coordinates for the rect are relative to the regionview origin */
-
- cr->property_x1() = trackview.editor().frame_to_pixel (s->first - _region->start());
- cr->property_x2() = trackview.editor().frame_to_pixel (s->second - _region->start());
- cr->property_y1() = 1;
- cr->property_y2() = _height - 2;
- cr->property_outline_pixels() = 0;
- cr->property_fill_color_rgba () = color;
-
- if (interval_duration < shortest) {
- shortest = interval_duration;
- }
-
- } else if (interval_duration > 0) {
- seen_audible = true;
- if (interval_duration < shortest_audible) {
- shortest_audible = interval_duration;
- }
- }
-
- start = end;
- in_silence = !in_silence;
- ++s;
-
- if (s == silences.end()) {
- end = _region->start() + _region->length();
- } else {
- end = s->first;
- }
- }
- }
+ /* coordinates for the rect are relative to the regionview origin */
+
+ cr->property_x1() = trackview.editor().frame_to_pixel (i->first - _region->start());
+ cr->property_x2() = trackview.editor().frame_to_pixel (i->second - _region->start());
+ cr->property_y1() = 1;
+ cr->property_y2() = _height - 2;
+ cr->property_outline_pixels() = 0;
+ cr->property_fill_color_rgba () = color;
+
+ shortest = min (shortest, i->second - i->first);
+ }
+
+ /* Find shortest audible segment */
+ framecnt_t shortest_audible = max_framecnt;
+
+ framecnt_t s = _region->start();
+ for (AudioIntervalResult::const_iterator i = silences.begin(); i != silences.end(); ++i) {
+ framecnt_t const dur = i->first - s;
+ if (dur > 0) {
+ shortest_audible = min (shortest_audible, dur);
+ }
+
+ s = i->second;
+ }