X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fanalogsnapshot.h;h=74d26763825167a41c81390c08647ba0a3b03560;hp=9ca08f1e510d3d564bd5367c180a336edc2ae630;hb=b213ef0991a13af0c74ffe5c54382c5c455c5496;hpb=1b1ec774978b65209ce2b454cbf81da499b797d2 diff --git a/pv/data/analogsnapshot.h b/pv/data/analogsnapshot.h index 9ca08f1e..74d26763 100644 --- a/pv/data/analogsnapshot.h +++ b/pv/data/analogsnapshot.h @@ -26,17 +26,67 @@ #include #include +namespace AnalogSnapshotTest { +class Basic; +} + namespace pv { namespace data { class AnalogSnapshot : public Snapshot { +public: + 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(const sr_datafeed_analog &analog); + virtual ~AnalogSnapshot(); + void append_payload(const sr_datafeed_analog &analog); - const float* get_samples() const; + 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