X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fanalogsegment.cpp;h=7a3d62d880ff912356f7daac4bf962af6d1611b5;hp=0860177e6d9f6139b1ad15053527feeff0ca877b;hb=ba5f21864c459a24f71ce3b0045805813c032134;hpb=b82243f74a175f621af26aabbc0f32e2ecb125fa diff --git a/pv/data/analogsegment.cpp b/pv/data/analogsegment.cpp index 0860177e..7a3d62d8 100644 --- a/pv/data/analogsegment.cpp +++ b/pv/data/analogsegment.cpp @@ -75,7 +75,7 @@ void AnalogSegment::append_interleaved_samples(const float *data, uint64_t prev_sample_count = sample_count_; // Deinterleave the samples and add them - unique_ptr deint_data(new float[sample_count]); + unique_ptr deint_data(new float[sample_count]); float *deint_data_ptr = deint_data.get(); for (uint32_t i = 0; i < sample_count; i++) { *deint_data_ptr = (float)(*data); @@ -102,7 +102,7 @@ void AnalogSegment::get_samples(int64_t start_sample, int64_t end_sample, assert(start_sample >= 0); assert(start_sample < (int64_t)sample_count_); assert(end_sample >= 0); - assert(end_sample < (int64_t)sample_count_); + assert(end_sample <= (int64_t)sample_count_); assert(start_sample <= end_sample); assert(dest != nullptr); @@ -178,6 +178,7 @@ void AnalogSegment::append_payload_to_envelope_levels() e0.length = sample_count_ / EnvelopeScaleFactor; // 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_raw_sample_iteration(0); for (uint64_t i = 0; i < sample_count_; i++) { @@ -257,6 +258,10 @@ void AnalogSegment::append_payload_to_envelope_levels() *dest_ptr = sub_sample; } } + + // Notify if the min or max value changed + if ((old_min_value != min_value_) || (old_max_value != max_value_)) + owner_.min_max_changed(min_value_, max_value_); } } // namespace data