Debian Codegraph @

src/spectrogramplot.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2015, Mike Walters <[email protected]>
3 *
4 * This file is part of inspectrum.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "spectrogramplot.h"cxx . . $ `<file>/src/spectrogramplot.h`/
21
22 #include <QDebug>
23 #include <QElapsedTimer>
24 #include <QPainter>
25 #include <QPaintEvent>
26 #include <QPixmapCache>
27 #include <QRect>
28 #include <liquid/liquid.h>
29 #include <algorithm>
30 #include <functional>
31 #include <cstdlib>
32 #include <limits>
33 #include "util.h"cxx . . $ `<file>/src/util.h`/
34
35
36 SpectrogramPlotcxx . . $ SpectrogramPlot#::SpectrogramPlotcxx . . $ SpectrogramPlot#SpectrogramPlot(b44028109ee6b4a).(stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<SampleSourcecxx . . $ SampleSource#<stdcxx . . $ std/::complexcxx . . $ std/complex#<float>>> src) : Plotcxx . . $ Plot#(srccxx . . $ std/shared_ptr#shared_ptr(c412da0edac25070).), inputSourcecxx . . $ SpectrogramPlot#inputSource.(src), fftSizecxx . . $ SpectrogramPlot#fftSize.(512), tunercxx . . $ SpectrogramPlot#tuner.(fftSizecxx . . $ SpectrogramPlot#fftSize., this)
37 {
38 setFFTSizecxx . . $ SpectrogramPlot#setFFTSize(d4f767463ce0a6b3).(fftSizecxx . . $ SpectrogramPlot#fftSize.);
39 zoomLevelcxx . . $ SpectrogramPlot#zoomLevel. = 1;
40 powerMaxcxx . . $ SpectrogramPlot#powerMax. = 0.0f;
41 powerMincxx . . $ SpectrogramPlot#powerMin. = -50.0f;
42 sampleRatecxx . . $ SpectrogramPlot#sampleRate. = 0;
43 frequencyScaleEnabledcxx . . $ SpectrogramPlot#frequencyScaleEnabled. = false;
44 sigmfAnnotationsEnabledcxx . . $ SpectrogramPlot#sigmfAnnotationsEnabled. = true;
45
46 for (int i = 0; i < 256; i++) {
47 float p = (float)i / 256;
48 colormapcxx . . $ SpectrogramPlot#colormap.[i] = QColorcxx . . $ QColor#::fromHsvFcxx . . $ QColor#fromHsvF(6e3a34f04ae54266).(p * 0.83f, 1.0, 1.0 - p).rgbacxx . . $ QColor#rgba(ddd8539a2fcdd4ce).();
49 }
50
51 tunerTransformcxx . . $ SpectrogramPlot#tunerTransform. =cxx . . $ std/shared_ptr#`operator=`(4bbc5909aaa3f22). stdcxx . . $ std/::make_sharedcxx . . $ std/make_shared(ffca0f3977536948).<TunerTransformcxx . . $ TunerTransform#>(src);
52 connectcxx . . $ QObject#connect(835f87066c895669).(&tunercxx . . $ SpectrogramPlot#tuner., &Tunercxx . . $ Tuner#::tunerMovedcxx . . $ Tuner#tunerMoved(49f6e7a06ebc5aa8)., this, &SpectrogramPlotcxx . . $ SpectrogramPlot#::tunerMovedcxx . . $ SpectrogramPlot#tunerMoved(49f6e7a06ebc5aa8).);
53 }
54
55 void SpectrogramPlotcxx . . $ SpectrogramPlot#::invalidateEventcxx . . $ SpectrogramPlot#invalidateEvent(49f6e7a06ebc5aa8).()
56 {
57 // HACK: this makes sure we update the height for real signals (as InputSource is passed here before the file is opened)
58 setFFTSizecxx . . $ SpectrogramPlot#setFFTSize(d4f767463ce0a6b3).(fftSizecxx . . $ SpectrogramPlot#fftSize.);
59
60 pixmapCachecxx . . $ SpectrogramPlot#pixmapCache..clearcxx . . $ QCache#clear(49f6e7a06ebc5aa8).();
61 fftCachecxx . . $ SpectrogramPlot#fftCache..clearcxx . . $ QCache#clear(49f6e7a06ebc5aa8).();
62 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! repaintcxx . . $ Plot#repaint(49f6e7a06ebc5aa8).();
63 }
64
65 void SpectrogramPlotcxx . . $ SpectrogramPlot#::paintFrontcxx . . $ SpectrogramPlot#paintFront(dba2c6533854c69f).(QPaintercxx . . $ QPainter# &painter, QRectcxx . . $ QRect# &rect, range_tcxx . . $ range_t#<size_t> sampleRange)
66 {
67 if (tunerEnabledcxx . . $ SpectrogramPlot#tunerEnabled(c9857a73d68e59ba).())
68 tunercxx . . $ SpectrogramPlot#tuner..paintFrontcxx . . $ Tuner#paintFront(dba2c6533854c69f).(painter, rect, sampleRange);
69
70 if (frequencyScaleEnabledcxx . . $ SpectrogramPlot#frequencyScaleEnabled.)
71 paintFrequencyScalecxx . . $ SpectrogramPlot#paintFrequencyScale(c6340ed8e020fc53).(painter, rect);
72
73 if (sigmfAnnotationsEnabledcxx . . $ SpectrogramPlot#sigmfAnnotationsEnabled.)
74 paintAnnotationscxx . . $ SpectrogramPlot#paintAnnotations(dba2c6533854c69f).(painter, rect, sampleRange);
75 }
76
77 void SpectrogramPlotcxx . . $ SpectrogramPlot#::paintFrequencyScalecxx . . $ SpectrogramPlot#paintFrequencyScale(c6340ed8e020fc53).(QPaintercxx . . $ QPainter# &painter, QRectcxx . . $ QRect# &rect)
78 {
79 if (sampleRatecxx . . $ SpectrogramPlot#sampleRate. == 0) {
80 return;
81 }
82
83 if (sampleRatecxx . . $ SpectrogramPlot#sampleRate. / 2 > UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:125:10`!) {
84 return;
85 }
86
87 // At which pixel is F_+sampleRate/2
88 int y = rect.ycxx . . $ QRect#y(455f465bc33b4cdf).();
89
90 int plotHeight = rect.heightcxx . . $ QRect#height(455f465bc33b4cdf).();
91 if (inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).realSignalcxx . . $ SampleSource#realSignal(c9857a73d68e59ba).())
92 plotHeight *= 2;
93
94 double bwPerPixel = (double)sampleRatecxx . . $ SpectrogramPlot#sampleRate. / plotHeight;
95 int tickHeight = 50;
96
97 uint64_tcxx . . $ uint64_t# bwPerTick = 10 * pow(10, floor(log(bwPerPixel * tickHeight) / log(10)));
98
99 if (bwPerTick < 1) {
100 return;
101 }
102
103 painter.savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).();
104
105 QPencxx . . $ QPen# pencxx . . $ QPen#QPen(c1f9b1cc0228302b).(Qtcxx . . $ QBrush#QBrush(1975e3c608654284).::whitecxx . . $ Qt/white., 1, Qtcxx . . $ Qt/::SolidLinecxx . . $ Qt/SolidLine.);
106 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(pen);
107 QFontMetricscxx . . $ QFontMetrics# fmcxx . . $ QFontMetrics#QFontMetrics(d0a4bd0c8524b912).(painter.fontcxx . . $ QPainter#font(c5040538afc47120).());
108
109
110 uint64_tcxx . . $ uint64_t# tick = 0;
111
112 while (tick <= sampleRatecxx . . $ SpectrogramPlot#sampleRate. / 2) {
113
114 int tickpy = plotHeight / 2 - tick / bwPerPixel + y;
115 int tickny = plotHeight / 2 + tick / bwPerPixel + y;
116
117 if (!inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).realSignalcxx . . $ SampleSource#realSignal(c9857a73d68e59ba).())
118 painter.drawLinecxx . . $ QPainter#drawLine(748afa4755bc9595).(0, tickny, 30, tickny);
119 painter.drawLinecxx . . $ QPainter#drawLine(748afa4755bc9595).(0, tickpy, 30, tickpy);
120
121 if (tick != 0) {
122 char buf[128];
123
124 if (bwPerTick % 1000000000 == 0) {
125 snprintf(buf, sizeof(buf), "-%lu GHz", tick / 1000000000);
126 } else if (bwPerTick % 1000000 == 0) {
127 snprintf(buf, sizeof(buf), "-%lu MHz", tick / 1000000);
128 } else if(bwPerTick % 1000 == 0) {
129 snprintf(buf, sizeof(buf), "-%lu kHz", tick / 1000);
130 } else {
131 snprintf(buf, sizeof(buf), "-%lu Hz", tick);
132 }
133
134 if (!inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).realSignalcxx . . $ SampleSource#realSignal(c9857a73d68e59ba).())
135 painter.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(5, tickny - 5, bufcxx . . $ QString#QString(85c52e162fed56f9).);
136
137 buf[0] = ' ';
138 painter.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(5, tickpy + 15, bufcxx . . $ QString#QString(85c52e162fed56f9).);
139 }
140
141 tick += bwPerTick;
142 }
143
144 // Draw small ticks
145 bwPerTick /= 10;
146
147 if (bwPerTick >= 1 ) {
148 tick = 0;
149 while (tick <= sampleRatecxx . . $ SpectrogramPlot#sampleRate. / 2) {
150
151 int tickpy = plotHeight / 2 - tick / bwPerPixel + y;
152 int tickny = plotHeight / 2 + tick / bwPerPixel + y;
153
154 if (!inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).realSignalcxx . . $ SampleSource#realSignal(c9857a73d68e59ba).())
155 painter.drawLinecxx . . $ QPainter#drawLine(748afa4755bc9595).(0, tickny, 3, tickny);
156 painter.drawLinecxx . . $ QPainter#drawLine(748afa4755bc9595).(0, tickpy, 3, tickpy);
157
158 tick += bwPerTick;
159 }
160 }
161 painter.restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).();
162 }
163
164 void SpectrogramPlotcxx . . $ SpectrogramPlot#::paintAnnotationscxx . . $ SpectrogramPlot#paintAnnotations(dba2c6533854c69f).(QPaintercxx . . $ QPainter# &painter, QRectcxx . . $ QRect# &rect, range_tcxx . . $ range_t#<size_t> sampleRange)
165 {
166 // Pixel (from the top) at which 0 Hz sits
167 int zero = rect.ycxx . . $ QRect#y(455f465bc33b4cdf).() + rect.heightcxx . . $ QRect#height(455f465bc33b4cdf).() / 2;
168
169 painter.savecxx . . $ QPainter#save(49f6e7a06ebc5aa8).();
170 QPencxx . . $ QPen# pencxx . . $ QPen#QPen(c1f9b1cc0228302b).(Qtcxx . . $ QBrush#QBrush(1975e3c608654284).::whitecxx . . $ Qt/white., 1, Qtcxx . . $ Qt/::SolidLinecxx . . $ Qt/SolidLine.);
171 painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(pen);
172 QFontMetricscxx . . $ QFontMetrics# fmcxx . . $ QFontMetrics#QFontMetrics(d0a4bd0c8524b912).(painter.fontcxx . . $ QPainter#font(c5040538afc47120).());
173
174 visibleAnnotationLocationscxx . . $ SpectrogramPlot#visibleAnnotationLocations..clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).();
175
176 for (int i = 0; i < inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).annotationListcxx . . $ SampleSource#annotationList..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++) {
177 Annotationcxx . . $ Annotation# a = inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).annotationListcxx . . $ SampleSource#annotationList..atcxx . . $ std/vector#at(428bb168810b9e52).(i);
178
179 size_t labelLength = fm.boundingRectcxx . . $ QFontMetrics#boundingRect(d8b0a2d97d69e4b8).(a.labelcxx . . $ Annotation#label.).widthcxx . . $ QRect#width(455f465bc33b4cdf).() * getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).();
180
181 // Check if:
182 // (1) End of annotation (might be maximum, or end of label text) is still visible in time
183 // (2) Part of the annotation is already visible in time
184 //
185 // Currently there is no check if the annotation is visible in frequency. This is a
186 // possible performance improvement
187 //
188 size_t start = a.sampleRangecxx . . $ Annotation#sampleRange..minimumcxx . . $ range_t#minimum.;
189 size_t end = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(a.sampleRangecxx . . $ Annotation#sampleRange..minimumcxx . . $ range_t#minimum. + labelLength, a.sampleRangecxx . . $ Annotation#sampleRange..maximumcxx . . $ range_t#maximum.);
190
191 if(start <= sampleRange.maximumcxx . . $ range_t#maximum. && end >= sampleRange.minimumcxx . . $ range_t#minimum.) {
192
193 double frequency = a.frequencyRangecxx . . $ Annotation#frequencyRange..maximumcxx . . $ range_t#maximum. - inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).getFrequencycxx . . $ SampleSource#getFrequency(31fa7155c10fdd13).();
194 int x = (a.sampleRangecxx . . $ Annotation#sampleRange..minimumcxx . . $ range_t#minimum. - sampleRange.minimumcxx . . $ range_t#minimum.) / getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).();
195 int y = zero - frequency / sampleRatecxx . . $ SpectrogramPlot#sampleRate. * rect.heightcxx . . $ QRect#height(455f465bc33b4cdf).();
196 int height = (a.frequencyRangecxx . . $ Annotation#frequencyRange..maximumcxx . . $ range_t#maximum. - a.frequencyRangecxx . . $ Annotation#frequencyRange..minimumcxx . . $ range_t#minimum.) / sampleRatecxx . . $ SpectrogramPlot#sampleRate. * rect.heightcxx . . $ QRect#height(455f465bc33b4cdf).();
197 int width = (a.sampleRangecxx . . $ Annotation#sampleRange..maximumcxx . . $ range_t#maximum. - a.sampleRangecxx . . $ Annotation#sampleRange..minimumcxx . . $ range_t#minimum.) / getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).();
198
199 // Draw the label 2 pixels above the box
200 painter.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(x, y - 2, a.labelcxx . . $ Annotation#label.);
201 painter.drawRectcxx . . $ QPainter#drawRect(748afa4755bc9595).(x, y, width, height);
202
203 visibleAnnotationLocationscxx . . $ SpectrogramPlot#visibleAnnotationLocations..emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(a, x, y, width, height);
204 }
205 }
206
207 painter.restorecxx . . $ QPainter#restore(49f6e7a06ebc5aa8).();
208 }
209
210 QStringcxx . . $ QString# *SpectrogramPlotcxx . . $ SpectrogramPlot#::mouseAnnotationCommentcxx . . $ SpectrogramPlot#mouseAnnotationComment(4b6ae5eff941c8bb).(const QMouseEventcxx . . $ QMouseEvent# *event) {
211 auto pos = event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).();
212 int mouse_x = pos.xcxx . . $ QPoint#x(455f465bc33b4cdf).();
213 int mouse_y = pos.ycxx . . $ QPoint#y(455f465bc33b4cdf).();
214
215 for (auto& a : visibleAnnotationLocationscxx . . $ SpectrogramPlot#visibleAnnotationLocations.) {
216 if (!a.annotationcxx . . $ AnnotationLocation#annotation..commentcxx . . $ Annotation#comment..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).() && a.isInsidecxx . . $ AnnotationLocation#isInside(cf9ef193275fa6d8).(mouse_x, mouse_y)) {
217 return &a.annotationcxx . . $ AnnotationLocation#annotation..commentcxx . . $ Annotation#comment.;
218 }
219 }
220 return nullptr;
221 }
222
223 void SpectrogramPlotcxx . . $ SpectrogramPlot#::paintMidcxx . . $ SpectrogramPlot#paintMid(dba2c6533854c69f).(QPaintercxx . . $ QPainter# &painter, QRectcxx . . $ QRect# &rect, range_tcxx . . $ range_t#<size_t> sampleRange)
224 {
225 if (!inputSourcecxx . . $ SpectrogramPlot#inputSource. || inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).countcxx . . $ SampleSource#count(f708dce9a8856c70).() == 0)
226 return;
227
228 size_t sampleOffset = sampleRange.minimumcxx . . $ range_t#minimum. % (getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).() * linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).());
229 size_t tileID = sampleRange.minimumcxx . . $ range_t#minimum. - sampleOffset;
230 int xoffset = sampleOffset / getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).();
231
232 // Paint first (possibly partial) tile
233 painter.drawPixmapcxx . . $ QPainter#drawPixmap(583800ea2588537e).(QRectcxx . . $ QRect#QRect(748afa4755bc9595).(rect.leftcxx . . $ QRect#left(455f465bc33b4cdf).(), rect.ycxx . . $ QRect#y(455f465bc33b4cdf).(), linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).() - xoffset, heightcxx . . $ Plot#height(455f465bc33b4cdf).()), *getPixmapTilecxx . . $ SpectrogramPlot#getPixmapTile(5036922bdbcf2913).(tileID), QRectcxx . . $ QRect#QRect(748afa4755bc9595).(xoffset, 0, linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).() - xoffset, heightcxx . . $ Plot#height(455f465bc33b4cdf).()));
234 tileID += getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).() * linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).();
235
236 // Paint remaining tiles
237 for (int x = linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).() - xoffset; x < rect.rightcxx . . $ QRect#right(455f465bc33b4cdf).(); x += linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).()) {
238 // TODO: don't draw past rect.right()
239 // TODO: handle partial final tile
240 painter.drawPixmapcxx . . $ QPainter#drawPixmap(583800ea2588537e).(QRectcxx . . $ QRect#QRect(748afa4755bc9595).(x, rect.ycxx . . $ QRect#y(455f465bc33b4cdf).(), linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).(), heightcxx . . $ Plot#height(455f465bc33b4cdf).()), *getPixmapTilecxx . . $ SpectrogramPlot#getPixmapTile(5036922bdbcf2913).(tileID), QRectcxx . . $ QRect#QRect(748afa4755bc9595).(0, 0, linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).(), heightcxx . . $ Plot#height(455f465bc33b4cdf).()));
241 tileID += getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).() * linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).();
242 }
243 }
244
245 QPixmapcxx . . $ QPixmap#* SpectrogramPlotcxx . . $ SpectrogramPlot#::getPixmapTilecxx . . $ SpectrogramPlot#getPixmapTile(5036922bdbcf2913).(size_t tile)
246 {
247 QPixmapcxx . . $ QPixmap# *obj = pixmapCachecxx . . $ SpectrogramPlot#pixmapCache..objectcxx . . $ QCache#object(f647437f38df71bb).(TileCacheKeycxx . . $ TileCacheKey#TileCacheKey(6d6de46ed9adf1db).(fftSizecxx . . $ SpectrogramPlot#fftSize., zoomLevelcxx . . $ SpectrogramPlot#zoomLevel., tile));
248 if (obj != 0)
249 return obj;
250
251 float *fftTile = getFFTTilecxx . . $ SpectrogramPlot#getFFTTile(391776d68d171a3c).(tile);
252 obj = new QPixmapcxx . . $ QPixmap#QPixmap(3e454b8ccf442868).(linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).(), fftSizecxx . . $ SpectrogramPlot#fftSize.);
253 QImagecxx . . $ QImage# imagecxx . . $ QImage#QImage(bf9e47a5364bf007).(linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).(), fftSizecxx . . $ SpectrogramPlot#fftSize., QImagecxx . . $ QImage#::Format_RGB32cxx . . $ QImage#Format_RGB32.);
254 float powerRange = -1.0f / stdcxx . . $ std/::abs(int(powerMincxx . . $ SpectrogramPlot#powerMin. - powerMaxcxx . . $ SpectrogramPlot#powerMax.));
255 for (int y = 0; y < fftSizecxx . . $ SpectrogramPlot#fftSize.; y++) {
256 auto scanLine = (QRgbcxx . . $ QRgb#*)image.scanLinecxx . . $ QImage#scanLine(f18dc31a6ecbac56).(fftSizecxx . . $ SpectrogramPlot#fftSize. - y - 1);
257 for (int x = 0; x < linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).(); x++) {
258 float *fftLine = &fftTile[x * fftSizecxx . . $ SpectrogramPlot#fftSize.];
259 float normPower = (fftLine[y] - powerMaxcxx . . $ SpectrogramPlot#powerMax.) * powerRange;
260 normPower = clampcxx . . $ clamp(3dbe0c69cb86ae06).(normPower, 0.0f, 1.0f);
261
262 scanLine[x] = colormapcxx . . $ SpectrogramPlot#colormap.[(uint8_tcxx . . $ uint8_t#)(normPower * (256 - 1))];
263 }
264 }
265 obj->convertFromImagecxx . . $ QPixmap#convertFromImage(21c4dac662c114a3).(image);
266 pixmapCachecxx . . $ SpectrogramPlot#pixmapCache..insertcxx . . $ QCache#insert(9eb1d5083ed97f7b).(TileCacheKeycxx . . $ TileCacheKey#TileCacheKey(6d6de46ed9adf1db).(fftSizecxx . . $ SpectrogramPlot#fftSize., zoomLevelcxx . . $ SpectrogramPlot#zoomLevel., tile), obj);
267 return obj;
268 }
269
270 float* SpectrogramPlotcxx . . $ SpectrogramPlot#::getFFTTilecxx . . $ SpectrogramPlot#getFFTTile(391776d68d171a3c).(size_t tile)
271 {
272 stdcxx . . $ std/::arraycxx . . $ std/array#<float, tileSizecxx . . $ SpectrogramPlot#tileSize.>* obj = fftCachecxx . . $ SpectrogramPlot#fftCache..objectcxx . . $ QCache#object(f647437f38df71bb).(TileCacheKeycxx . . $ TileCacheKey#TileCacheKey(6d6de46ed9adf1db).(fftSizecxx . . $ SpectrogramPlot#fftSize., zoomLevelcxx . . $ SpectrogramPlot#zoomLevel., tile));
273 if (obj != nullptr)
274 return obj->datacxx . . $ std/array#data(155dc7f103cdb9db).();
275
276 stdcxx . . $ std/::arraycxx . . $ std/array#<float, tileSizecxx . . $ SpectrogramPlot#tileSize.>* destStorage = new stdcxx . . $ std/::arraycxx . . $ std/array#<float, tileSizecxx . . $ SpectrogramPlot#tileSize.>;
277 float *ptr = destStorage->datacxx . . $ std/array#data(155dc7f103cdb9db).();
278 size_t sample = tile;
279 while ((ptr - destStorage->datacxx . . $ std/array#data(155dc7f103cdb9db).()) < tileSizecxx . . $ SpectrogramPlot#tileSize.) {
280 getLinecxx . . $ SpectrogramPlot#getLine(1eb030330e199770).(ptr, sample);
281 sample += getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).();
282 ptr += fftSizecxx . . $ SpectrogramPlot#fftSize.;
283 }
284 fftCachecxx . . $ SpectrogramPlot#fftCache..insertcxx . . $ QCache#insert(9eb1d5083ed97f7b).(TileCacheKeycxx . . $ TileCacheKey#TileCacheKey(6d6de46ed9adf1db).(fftSizecxx . . $ SpectrogramPlot#fftSize., zoomLevelcxx . . $ SpectrogramPlot#zoomLevel., tile), destStorage);
285 return destStorage->datacxx . . $ std/array#data(155dc7f103cdb9db).();
286 }
287
288 void SpectrogramPlotcxx . . $ SpectrogramPlot#::getLinecxx . . $ SpectrogramPlot#getLine(1eb030330e199770).(float *dest, size_t sample)
289 {
290 if (inputSourcecxx . . $ SpectrogramPlot#inputSource. && fftcxx . . $ SpectrogramPlot#fft.) {
291 // Make sample be the midpoint of the FFT, unless this takes us
292 // past the beginning of the inputSource (if we remove the
293 // std::max(·, 0), then an ugly red bar appears at the beginning
294 // of the spectrogram with large zooms and FFT sizes).
295 const auto first_sample = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(static_cast<ssize_t>(sample) - fftSizecxx . . $ SpectrogramPlot#fftSize. / 2,
296 static_cast<ssize_t>(0));
297 auto buffer = inputSourcecxx . . $ std/unique_ptr#unique_ptr(c72f3246697f2f97).->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).getSamplescxx . . $ SampleSource#getSamples(beb84398f18d5b52).(first_sample, fftSizecxx . . $ SpectrogramPlot#fftSize.);
298 if (buffer ==cxx . . $ std/`operator==`(5e0825b51b28ca0b). nullptr) {
299 auto neg_infinity = -1 * stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<float>::infinitycxx . . $ std/numeric_limits#infinity(9b8c9e39889c762c).();
300 for (int i = 0; i < fftSizecxx . . $ SpectrogramPlot#fftSize.; i++, dest++)
301 *dest = neg_infinity;
302 return;
303 }
304
305 for (int i = 0; i < fftSizecxx . . $ SpectrogramPlot#fftSize.; i++) {
306 buffer[cxx . . $ std/unique_ptr#`operator[]`(d29315ade3bf818e).i] *=cxx . . $ std/complex#`operator*=`(f5fc9d521a3c0cfe). windowcxx . . $ SpectrogramPlot#window.[cxx . . $ std/unique_ptr#`operator[]`(d29315ade3bf818e).i];
307 }
308
309 fftcxx . . $ SpectrogramPlot#fft.->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).processcxx . . $ FFT#process(6c58c5e2437d25a2).(buffer.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).(), buffer.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).());
310 const float invFFTSize = 1.0f / fftSizecxx . . $ SpectrogramPlot#fftSize.;
311 const float logMultiplier = 10.0f / log2f(10.0f);
312 for (int i = 0; i < fftSizecxx . . $ SpectrogramPlot#fftSize.; i++) {
313 // Start from the middle of the FFTW array and wrap
314 // to rearrange the data
315 int k = i ^ (fftSizecxx . . $ SpectrogramPlot#fftSize. >> 1);
316 auto s = buffercxx . . $ std/complex#complex(4ec34615dfd009e6).[cxx . . $ std/unique_ptr#`operator[]`(d29315ade3bf818e).k] *cxx . . $ std/`operator*`(70c2920da18d026d). invFFTSize;
317 float power = s.realcxx . . $ std/complex#real(5036dfe8d4170af2).() * s.realcxx . . $ std/complex#real(5036dfe8d4170af2).() + s.imagcxx . . $ std/complex#imag(5036dfe8d4170af2).() * s.imagcxx . . $ std/complex#imag(5036dfe8d4170af2).();
318 float logPower = log2f(power) * logMultiplier;
319 *dest = logPower;
320 dest++;
321 }
322 }
323 }
324
325 int SpectrogramPlotcxx . . $ SpectrogramPlot#::getStridecxx . . $ SpectrogramPlot#getStride(b126dc7c1de90089).()
326 {
327 return fftSizecxx . . $ SpectrogramPlot#fftSize. / zoomLevelcxx . . $ SpectrogramPlot#zoomLevel.;
328 }
329
330 float SpectrogramPlotcxx . . $ SpectrogramPlot#::getTunerPhaseInccxx . . $ SpectrogramPlot#getTunerPhaseInc(9b8c9e39889c762c).()
331 {
332 auto freq = 0.5f - tunercxx . . $ SpectrogramPlot#tuner..centrecxx . . $ Tuner#centre(b126dc7c1de90089).() / (float)fftSizecxx . . $ SpectrogramPlot#fftSize.;
333 return freq * Taucxx . . $ Tau.;
334 }
335
336 stdcxx . . $ std/::vectorcxx . . $ std/vector#<float> SpectrogramPlotcxx . . $ SpectrogramPlot#::getTunerTapscxx . . $ SpectrogramPlot#getTunerTaps(78bf79a61abe343f).()
337 {
338 float cutoff = tunercxx . . $ SpectrogramPlot#tuner..deviationcxx . . $ Tuner#deviation(b126dc7c1de90089).() / (float)fftSizecxx . . $ SpectrogramPlot#fftSize.;
339 float gain = pow(10.0f, powerMaxcxx . . $ SpectrogramPlot#powerMax. / -10.0f);
340 auto atten = 60.0f;
341 auto len = estimate_req_filter_len(stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(cutoff, 0.05f), atten);
342 auto taps = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<float>(len);
343 liquid_firdes_kaiser(len, cutoff, atten, 0.0f, taps.datacxx . . $ std/vector#data(155dc7f103cdb9db).());
344 stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(taps.begincxx . . $ std/vector#begin(33b10a496a38335b).(), taps.endcxx . . $ std/vector#end(33b10a496a38335b).(), taps.begincxx . . $ std/vector#begin(33b10a496a38335b).(),
345 stdcxx . . $ std/_Bind#_Bind(2de50c68877ed2b5).::bindcxx . . $ std/bind(872fd79d47452673).(stdcxx . . $ std/::multipliescxx . . $ std/multiplies#<float>(), stdcxx . . $ std/::placeholderscxx . . $ std/placeholders/::_1cxx . . $ std/placeholders/_1., gain));
346 return tapscxx . . $ std/vector#vector(b1ea180184b47f03).;
347 }
348
349 int SpectrogramPlotcxx . . $ SpectrogramPlot#::linesPerTilecxx . . $ SpectrogramPlot#linesPerTile(b126dc7c1de90089).()
350 {
351 return tileSizecxx . . $ SpectrogramPlot#tileSize. / fftSizecxx . . $ SpectrogramPlot#fftSize.;
352 }
353
354 bool SpectrogramPlotcxx . . $ SpectrogramPlot#::mouseEventcxx . . $ SpectrogramPlot#mouseEvent(bf65bbe40893342c).(QEventcxx . . $ QEvent#::Typecxx . . $ QEvent#Type# type, QMouseEventcxx . . $ QMouseEvent# *event)
355 {
356 if (tunerEnabledcxx . . $ SpectrogramPlot#tunerEnabled(c9857a73d68e59ba).())
357 return tunercxx . . $ SpectrogramPlot#tuner..mouseEventcxx . . $ Tuner#mouseEvent(bf65bbe40893342c).(type, event);
358
359 return false;
360 }
361
362 void SpectrogramPlotcxx . . $ SpectrogramPlot#::leaveEventcxx . . $ SpectrogramPlot#leaveEvent(49f6e7a06ebc5aa8).()
363 {
364 if (tunerEnabledcxx . . $ SpectrogramPlot#tunerEnabled(c9857a73d68e59ba).())
365 tunercxx . . $ SpectrogramPlot#tuner..leaveEventcxx . . $ Tuner#leaveEvent(49f6e7a06ebc5aa8).();
366 }
367
368 stdcxx . . $ std/::shared_ptrcxx . . $ std/shared_ptr#<AbstractSampleSourcecxx . . $ AbstractSampleSource#> SpectrogramPlotcxx . . $ SpectrogramPlot#::outputcxx . . $ SpectrogramPlot#output(aad09d7b1d4b04e1).()
369 {
370 returncxx . . $ std/shared_ptr#shared_ptr(c412da0edac25070). tunerTransformcxx . . $ std/shared_ptr#shared_ptr(9f523ca754888fbf).;
371 }
372
373 void SpectrogramPlotcxx . . $ SpectrogramPlot#::setFFTSizecxx . . $ SpectrogramPlot#setFFTSize(d4f767463ce0a6b3).(int size)
374 {
375 float sizeScale = float(size) / float(fftSizecxx . . $ SpectrogramPlot#fftSize.);
376 fftSizecxx . . $ SpectrogramPlot#fftSize. = size;
377 fftcxx . . $ SpectrogramPlot#fft..resetcxx . . $ std/unique_ptr#reset(57bc6b0441bf5294).(new FFTcxx . . $ FFT#(fftSizecxx . . $ SpectrogramPlot#fftSize.));
378
379 windowcxx . . $ SpectrogramPlot#window..resetcxx . . $ std/unique_ptr#reset(b07662a27bd562f9).(new float[fftSizecxx . . $ SpectrogramPlot#fftSize.]);
380 for (int i = 0; i < fftSizecxx . . $ SpectrogramPlot#fftSize.; i++) {
381 windowcxx . . $ SpectrogramPlot#window.[cxx . . $ std/unique_ptr#`operator[]`(d29315ade3bf818e).i] = 0.5f * (1.0f - cos(Taucxx . . $ Tau. * i / (fftSizecxx . . $ SpectrogramPlot#fftSize. - 1)));
382 }
383
384 if (inputSourcecxx . . $ SpectrogramPlot#inputSource.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).realSignalcxx . . $ SampleSource#realSignal(c9857a73d68e59ba).()) {
385 setHeightcxx . . $ Plot#setHeight(d4f767463ce0a6b3).(fftSizecxx . . $ SpectrogramPlot#fftSize./2);
386 } else {
387 setHeightcxx . . $ Plot#setHeight(d4f767463ce0a6b3).(fftSizecxx . . $ SpectrogramPlot#fftSize.);
388 }
389 auto dev = tunercxx . . $ SpectrogramPlot#tuner..deviationcxx . . $ Tuner#deviation(b126dc7c1de90089).();
390 auto centre = tunercxx . . $ SpectrogramPlot#tuner..centrecxx . . $ Tuner#centre(b126dc7c1de90089).();
391 tunercxx . . $ SpectrogramPlot#tuner..setHeightcxx . . $ Tuner#setHeight(d4f767463ce0a6b3).(heightcxx . . $ Plot#height(455f465bc33b4cdf).());
392 tunercxx . . $ SpectrogramPlot#tuner..setDeviationcxx . . $ Tuner#setDeviation(d4f767463ce0a6b3).( dev * sizeScale );
393 tunercxx . . $ SpectrogramPlot#tuner..setCentrecxx . . $ Tuner#setCentre(d4f767463ce0a6b3).( centre * sizeScale );
394 }
395
396 void SpectrogramPlotcxx . . $ SpectrogramPlot#::setPowerMaxcxx . . $ SpectrogramPlot#setPowerMax(d4f767463ce0a6b3).(int power)
397 {
398 powerMaxcxx . . $ SpectrogramPlot#powerMax. = power;
399 pixmapCachecxx . . $ SpectrogramPlot#pixmapCache..clearcxx . . $ QCache#clear(49f6e7a06ebc5aa8).();
400 tunerMovedcxx . . $ SpectrogramPlot#tunerMoved(49f6e7a06ebc5aa8).();
401 }
402
403 void SpectrogramPlotcxx . . $ SpectrogramPlot#::setPowerMincxx . . $ SpectrogramPlot#setPowerMin(d4f767463ce0a6b3).(int power)
404 {
405 powerMincxx . . $ SpectrogramPlot#powerMin. = power;
406 pixmapCachecxx . . $ SpectrogramPlot#pixmapCache..clearcxx . . $ QCache#clear(49f6e7a06ebc5aa8).();
407 }
408
409 void SpectrogramPlotcxx . . $ SpectrogramPlot#::setZoomLevelcxx . . $ SpectrogramPlot#setZoomLevel(d4f767463ce0a6b3).(int zoom)
410 {
411 zoomLevelcxx . . $ SpectrogramPlot#zoomLevel. = zoom;
412 }
413
414 void SpectrogramPlotcxx . . $ SpectrogramPlot#::setSampleRatecxx . . $ SpectrogramPlot#setSampleRate(ba8836b59fb42830).(double rate)
415 {
416 sampleRatecxx . . $ SpectrogramPlot#sampleRate. = rate;
417 }
418
419 void SpectrogramPlotcxx . . $ SpectrogramPlot#::enableScalescxx . . $ SpectrogramPlot#enableScales(b45ddcbc8423892c).(bool enabled)
420 {
421 frequencyScaleEnabledcxx . . $ SpectrogramPlot#frequencyScaleEnabled. = enabled;
422 }
423
424 void SpectrogramPlotcxx . . $ SpectrogramPlot#::enableAnnotationscxx . . $ SpectrogramPlot#enableAnnotations(b45ddcbc8423892c).(bool enabled)
425 {
426 sigmfAnnotationsEnabledcxx . . $ SpectrogramPlot#sigmfAnnotationsEnabled. = enabled;
427 }
428
429 bool SpectrogramPlotcxx . . $ SpectrogramPlot#::isAnnotationsEnabledcxx . . $ SpectrogramPlot#isAnnotationsEnabled(c9857a73d68e59ba).(void)
430 {
431 return sigmfAnnotationsEnabledcxx . . $ SpectrogramPlot#sigmfAnnotationsEnabled.;
432 }
433
434 bool SpectrogramPlotcxx . . $ SpectrogramPlot#::tunerEnabledcxx . . $ SpectrogramPlot#tunerEnabled(c9857a73d68e59ba).()
435 {
436 return (tunerTransformcxx . . $ SpectrogramPlot#tunerTransform.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).subscriberCountcxx . . $ AbstractSampleSource#subscriberCount(b126dc7c1de90089).() > 0);
437 }
438
439 void SpectrogramPlotcxx . . $ SpectrogramPlot#::tunerMovedcxx . . $ SpectrogramPlot#tunerMoved(49f6e7a06ebc5aa8).()
440 {
441 tunerTransformcxx . . $ SpectrogramPlot#tunerTransform.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).setFrequencycxx . . $ TunerTransform#setFrequency(9364e6e7bff7660).(getTunerPhaseInccxx . . $ SpectrogramPlot#getTunerPhaseInc(9b8c9e39889c762c).());
442 tunerTransformcxx . . $ SpectrogramPlot#tunerTransform.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).setTapscxx . . $ TunerTransform#setTaps(1bcd582b5f19dd78).(getTunerTapscxx . . $ std/vector#vector(b1ea180184b47f03).());
443 tunerTransformcxx . . $ SpectrogramPlot#tunerTransform.->cxx . . $ std/__shared_ptr_access#`operator->`(5a2a78a048fb49a8).setRelativeBandwithcxx . . $ TunerTransform#setRelativeBandwith(9364e6e7bff7660).(tunercxx . . $ SpectrogramPlot#tuner..deviationcxx . . $ Tuner#deviation(b126dc7c1de90089).() * 2.0 / heightcxx . . $ Plot#height(455f465bc33b4cdf).());
444
445 // TODO: for invalidating traceplot cache, this shouldn't really go here
446 QPixmapCachecxx . . $ QPixmapCache#::clearcxx . . $ QPixmapCache#clear(49f6e7a06ebc5aa8).();
447
448 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! repaintcxx . . $ Plot#repaint(49f6e7a06ebc5aa8).();
449 }
450
451 uintcxx . . $ uint# qHashcxx . . $ qHash(5f0977a470aadea9).(const TileCacheKeycxx . . $ TileCacheKey# &key, uintcxx . . $ uint# seed)
452 {
453 return key.fftSizecxx . . $ TileCacheKey#fftSize. ^ key.zoomLevelcxx . . $ TileCacheKey#zoomLevel. ^ key.samplecxx . . $ TileCacheKey#sample. ^ seed;
454 }