X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Fanalogsnapshot.h;h=b60c2ce72580c4fdf51d84940f0e836216759bae;hb=9df8453f6809f2ce038717111979474a60d5746a;hp=a45391849220332b892faa9ed3eaa79df30a4df6;hpb=d37583678256450d7eb646213d0b9e170a427933;p=pulseview.git diff --git a/pv/data/analogsnapshot.h b/pv/data/analogsnapshot.h index a4539184..b60c2ce7 100644 --- a/pv/data/analogsnapshot.h +++ b/pv/data/analogsnapshot.h @@ -26,18 +26,68 @@ #include #include +namespace AnalogSnapshotTest { +class Basic; +} + namespace pv { namespace data { class AnalogSnapshot : public Snapshot { public: - AnalogSnapshot(const sr_datafeed_analog &analog); + struct EnvelopeSample + { + float min; + float max; + }; + + struct EnvelopeSection + { + uint64_t start; + unsigned int scale; + uint64_t length; + EnvelopeSample *samples; + }; + +private: + struct Envelope + { + uint64_t length; + uint64_t data_length; + EnvelopeSample *samples; + }; + +private: + static const unsigned int ScaleStepCount = 10; + static const int EnvelopeScalePower; + static const int EnvelopeScaleFactor; + static const float LogEnvelopeScaleFactor; + static const uint64_t EnvelopeDataUnit; + +public: + AnalogSnapshot(uint64_t expected_num_samples = 0); - void append_payload(const sr_datafeed_analog &analog); + virtual ~AnalogSnapshot(); + + void append_interleaved_samples(const float *data, + size_t sample_count, size_t stride); const float* get_samples(int64_t start_sample, int64_t end_sample) const; + + void get_envelope_section(EnvelopeSection &s, + uint64_t start, uint64_t end, float min_length) const; + +private: + void reallocate_envelope(Envelope &l); + + void append_payload_to_envelope_levels(); + +private: + struct Envelope _envelope_levels[ScaleStepCount]; + + friend class AnalogSnapshotTest::Basic; }; } // namespace data