ngscopeclient v0.2.2
Loading...
Searching...
No Matches
FFTFilter.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef FFTFilter_h
36#define FFTFilter_h
37
38#include "VulkanFFTPlan.h"
39
40class QueueHandle;
41
43{
44 uint32_t npoints;
45 float scale;
46};
47
49{
50public:
51 FFTFilter(const std::string& color);
52 virtual ~FFTFilter();
53
54 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
55 virtual uint32_t GetExecutionCapabilitiesMask() override;
56
57 static std::string GetProtocolName();
58
59 virtual float GetVoltageRange(size_t stream) override;
60 virtual float GetOffset(size_t stream) override;
61
62 virtual void SetVoltageRange(float range, size_t stream) override;
63 virtual void SetOffset(float offset, size_t stream) override;
64
65 enum WindowFunction
66 {
67 WINDOW_RECTANGULAR,
68 WINDOW_HANN,
69 WINDOW_HAMMING,
70 WINDOW_BLACKMAN_HARRIS
71 };
72
73 PROTOCOL_DECODER_INITPROC(FFTFilter)
74
75 void SetWindowFunction(WindowFunction f)
76 { m_parameters[m_windowName].SetIntVal(f); }
77
78 //Accessors for internal values only used by unit tests
79 //TODO: refactor this into a friend class or something?
80 size_t test_GetNumPoints()
81 { return m_cachedNumPointsFFT; }
82
83 size_t test_GetNumOuts()
84 { return m_cachedNumOuts; }
85
86protected:
87
88 void ReallocateBuffers(size_t npoints_raw, size_t npoints, size_t nouts);
89
90 void DoRefresh(
93 double fs_per_sample,
94 size_t npoints,
95 size_t nouts,
96 bool log_output,
97 vk::raii::CommandBuffer& cmdBuf,
98 std::shared_ptr<QueueHandle> queue
99 );
100
101 size_t m_cachedNumPoints;
102 size_t m_cachedNumPointsFFT;
103 size_t m_cachedNumOuts;
104 AcceleratorBuffer<float> m_rdinbuf;
105 AcceleratorBuffer<float> m_rdoutbuf;
106
107 float m_range;
108 float m_offset;
109
110 std::string m_windowName;
111
112 std::unique_ptr<VulkanFFTPlan> m_vkPlan;
113
114 ComputePipeline m_blackmanHarrisComputePipeline;
115 ComputePipeline m_rectangularComputePipeline;
116 ComputePipeline m_cosineSumComputePipeline;
117 ComputePipeline m_complexToMagnitudeComputePipeline;
118 ComputePipeline m_complexToLogMagnitudeComputePipeline;
119};
120
121#endif
Declaration of VulkanFFTPlan.
Definition AcceleratorBuffer.h:204
Encapsulates a Vulkan compute pipeline and all necessary resources to use it.
Definition ComputePipeline.h:55
Definition FFTFilter.h:49
virtual uint32_t GetExecutionCapabilitiesMask() override
Returns a bitmask of ExecutionCapabilities fields.
Definition FFTFilter.cpp:105
A filter that does peak detection.
Definition PeakDetectionFilter.h:210
Wrapper around a Vulkan Queue object.
Definition QueueHandle.h:65
Base class for all Waveform specializations.
Definition Waveform.h:59
Definition FFTFilter.h:43