+ // Calculate min/max values in case we have too few samples for an envelope
+ const float old_min_value = min_value_, old_max_value = max_value_;
+ if (sample_count_ < EnvelopeScaleFactor) {
+ it = begin_sample_iteration(0);
+ for (uint64_t i = 0; i < sample_count_; i++) {
+ const float sample = *get_iterator_value_ptr(it);
+ if (sample < min_value_)
+ min_value_ = sample;
+ if (sample > max_value_)
+ max_value_ = sample;
+ continue_sample_iteration(it, 1);
+ }
+ end_sample_iteration(it);
+ }
+