ngscopeclient 0.1-dev+51fbda87c
SpectrogramFilter.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopeprotocols *
4* *
5* Copyright (c) 2012-2024 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
36#ifndef SpectrogramFilter_h
37#define SpectrogramFilter_h
38
39#include "VulkanFFTPlan.h"
40
41#include "../scopehal/DensityFunctionWaveform.h"
42
48{
49 uint32_t nblocks;
50 uint32_t nouts;
51 uint32_t ygrid;
52 float logscale;
53 float impscale;
54 float minscale;
55 float irange;
56};
57
63{
64public:
65 SpectrogramWaveform(size_t width, size_t height, double binsize, double bottomEdgeFrequency);
66 virtual ~SpectrogramWaveform();
67
68 //not copyable or assignable
70 SpectrogramWaveform& operator=(const SpectrogramWaveform&) =delete;
71
72 double GetBinSize()
73 { return m_binsize; }
74
75 double GetBottomEdgeFrequency()
76 { return m_bottomEdgeFrequency; }
77
78 virtual void FreeGpuMemory() override
79 {}
80
81 virtual bool HasGpuBuffer() override
82 { return false; }
83
84protected:
85 double m_binsize;
86 double m_bottomEdgeFrequency;
87};
88
94{
95public:
96 SpectrogramFilter(const std::string& color);
97 virtual ~SpectrogramFilter();
98
99 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue) override;
100
101 static std::string GetProtocolName();
102 virtual DataLocation GetInputLocation() override;
103
104 virtual float GetVoltageRange(size_t stream) override;
105 virtual float GetOffset(size_t stream) override;
106 virtual bool ValidateChannel(size_t i, StreamDescriptor stream) override;
107
108 virtual void SetVoltageRange(float range, size_t stream) override;
109 virtual void SetOffset(float offset, size_t stream) override;
110
111 PROTOCOL_DECODER_INITPROC(SpectrogramFilter)
112
113protected:
114 virtual void ReallocateBuffers(size_t fftlen, size_t nblocks);
115
116 AcceleratorBuffer<float> m_rdinbuf;
117 AcceleratorBuffer<float> m_rdoutbuf;
118
119 size_t m_cachedFFTLength;
120 size_t m_cachedFFTNumBlocks;
121
122 float m_range;
123 float m_offset;
124
125 std::string m_windowName;
126 std::string m_fftLengthName;
127 std::string m_rangeMinName;
128 std::string m_rangeMaxName;
129
130 std::unique_ptr<VulkanFFTPlan> m_vkPlan;
131
132 ComputePipeline m_blackmanHarrisComputePipeline;
133 ComputePipeline m_rectangularComputePipeline;
134 ComputePipeline m_cosineSumComputePipeline;
135
136 ComputePipeline m_postprocessComputePipeline;
137};
138
139#endif
Declaration of VulkanFFTPlan.
Encapsulates a Vulkan compute pipeline and all necessary resources to use it.
Definition: ComputePipeline.h:55
Base class for waveforms such as eye patterns, spectrograms, and waterfalls which are conceptually a ...
Definition: DensityFunctionWaveform.h:51
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition: Filter.h:95
virtual void Refresh() override
Evaluates a filter graph node.
Definition: Filter.cpp:816
Filter for displaying spectrogram of a real-valued signal.
Definition: SpectrogramFilter.h:94
virtual DataLocation GetInputLocation() override
Gets the desired location of the nodes's input data.
Definition: SpectrogramFilter.cpp:174
Waveform object for a spectrogram.
Definition: SpectrogramFilter.h:63
virtual void FreeGpuMemory() override
Free GPU-side memory if we are short on VRAM or do not anticipate using this waveform for a while.
Definition: SpectrogramFilter.h:78
virtual bool HasGpuBuffer() override
Returns true if we have at least one buffer resident on the GPU.
Definition: SpectrogramFilter.h:81
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
Arguments passed to the SpectrogramPostprocess shader.
Definition: SpectrogramFilter.h:48