-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathGLWaterfall.cpp
More file actions
792 lines (657 loc) · 19.8 KB
/
Copy pathGLWaterfall.cpp
File metadata and controls
792 lines (657 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
/* -*- c++ -*- */
/* + + + This Software is released under the "Simplified BSD License" + + +
* Copyright 2010 Moe Wheatley. All rights reserved.
* Copyright 2011-2013 Alexandru Csete OZ9AEC
* Copyright 2018 Gonzalo José Carracedo Carballal - Minimal modifications for integration
* Copyright 2024 Sultan Qasim Khan - Abstract class for OpenGL and QPainter waterfalls
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Moe Wheatley ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Moe Wheatley OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of Moe Wheatley.
*/
#include <cmath>
#include <QColor>
#include <QDateTime>
#include <QDebug>
#include <QFont>
#include <QPainter>
#include <QtGlobal>
#include <QToolTip>
#include <QDebug>
#include <QApplication>
#include <cstring>
// Apple deprecated OpenGL, I don't need to be warned, but for now it still works
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#endif
#include "SuWidgetsHelpers.h"
#include "GLWaterfall.h"
#include "gradient.h"
// Comment out to enable plotter debug messages
//#define PLOTTER_DEBUG
#define GL_WATERFALL_TEX_MIN_DB (-300.f)
#define GL_WATERFALL_TEX_MAX_DB (200.f)
#define GL_WATERFALL_TEX_DR (GL_WATERFALL_TEX_MAX_DB - GL_WATERFALL_TEX_MIN_DB)
#define GL_WATERFALL_MAX_LINE_POOL_SIZE 30
#define GL_WATERFALL_MIN_BULK_TRANSFER 10
struct vertex {
float vertex_coords[3];
float texture_coords[2];
};
static const vertex vertices[] =
{
{{1, 1, 0}, {1.0, 0.0}},
{{1, -1, 0}, {1.0, 1.0}},
{{-1, -1, 0}, {0.0, 1.0}},
{{-1, 1, 0}, {0.0, 0.0}}
};
static const unsigned short vertex_indices[] = {0, 1, 2, 2, 3, 0};
static const char *wfVertexShader = " \
attribute vec3 vertex_coords; \
attribute vec2 texture_coords; \
varying vec2 f_texture_coords; \
uniform mat4 ortho; \
\
void \
main() \
{ \
gl_Position = ortho * vec4(vertex_coords, 1.0); \
f_texture_coords = texture_coords; \
} \
";
static const char *wfFragmentShader = " \
varying vec2 f_texture_coords; \
uniform sampler2D m_texture; \
uniform sampler2D m_palette; \
uniform float t; \
uniform float x0; \
uniform float m; \
uniform float c_x0; \
uniform float c_m; \
\
void \
main() \
{ \
float x = f_texture_coords.x * c_m + c_x0; \
float y = f_texture_coords.y + t - floor(f_texture_coords.y + t); \
vec2 coord = vec2(x, y); \
\
vec4 psd = texture2D(m_texture, coord); \
float paletteIndex = (psd.r - x0) / m; \
vec4 palColor = texture2D(m_palette, vec2(paletteIndex, 0)); \
\
gl_FragColor = palColor; \
} \
";
///////////////////////////// GLLine //////////////////////////////////////////
void
GLLine::normalize()
{
int i;
int res = resolution();
float *data = this->data();
#pragma GCC ivdep
for (i = 0; i < res; ++i)
data[i] = (data[i] - GL_WATERFALL_TEX_MIN_DB) / GL_WATERFALL_TEX_DR;
}
void
GLLine::rescaleMean()
{
float *data = this->data();
int res = resolution();
int i = 0, q = 0, p = res;
int l = m_levels;
normalize();
while (l-- > 0) {
#pragma GCC unroll 4
for (i = 0; i < res; i += 2) {
data[p++] = .5f * (data[q] + data[q + 1]);
q += 2;
}
res >>= 1;
}
}
void
GLLine::rescaleMax()
{
float *data = this->data();
int res = resolution();
int i = 0, q = 0, p = res;
int l = m_levels;
normalize();
while (l-- > 0) {
#pragma GCC unroll 4
for (i = 0; i < res; i += 2) {
data[p++] = fmaxf(data[q], data[q + 1]);
q += 2;
}
res >>= 1;
}
}
void
GLLine::assignMean(const float *values)
{
float *data = this->data();
int res = resolution();
memcpy(data, values, sizeof(float) * res);
rescaleMean();
}
void
GLLine::assignMax(const float *values)
{
float *data = this->data();
int res = resolution();
memcpy(data, values, sizeof(float) * res);
rescaleMax();
}
void
GLLine::reduceMean(const float *values, int length)
{
int res = resolution();
int chunkSize = length / res;
float *data = this->data();
float k = 1. / chunkSize;
if (chunkSize > 0) {
int i, j, p = 0;
#pragma GCC unroll 4
for (i = 0; i < length; i += chunkSize) {
float val = 0;
for (j = 0; j < chunkSize; ++j)
val += k * values[i + j];
data[p++] = val;
}
rescaleMean();
}
}
void
GLLine::reduceMax(const float *values, int length)
{
int res = resolution();
int chunkSize = length / res;
float *data = this->data();
if (chunkSize > 0) {
int i, p = 0;
#pragma GCC unroll 4
for (i = 0; i < length; i += chunkSize) {
float max = -INFINITY;
int j;
for (j = 0; j < chunkSize; ++j)
if (values[i + j] > max)
max = values[i + j];
data[p++] = max;
}
rescaleMax();
}
}
/////////////////////// GLWaterfallOpenGLContext //////////////////////////////
GLWaterfallOpenGLContext::GLWaterfallOpenGLContext() :
m_vbo(QOpenGLBuffer::VertexBuffer),
m_ibo(QOpenGLBuffer::IndexBuffer)
{
auto screens = QGuiApplication::screens();
int maxHeight = 0;
for (auto p : screens) {
int h = p->geometry().height() * p->devicePixelRatio();
if (h > maxHeight)
maxHeight = h;
}
m_paletBuf.resize(256 * 4);
m_rowCount = maxHeight;
}
GLWaterfallOpenGLContext::~GLWaterfallOpenGLContext()
{
finalize();
delete m_vertexShader;
delete m_fragmentShader;
delete m_waterfall;
delete m_palette;
}
void
GLWaterfallOpenGLContext::initialize()
{
GLint texSize;
QImage firstPal = QImage(256, 1, QImage::Format_RGBX8888);
m_paletBuf.resize(256);
for (int i = 0; i < 256; ++i) {
firstPal.setPixel(
i,
0,
qRgba(
255 * wf_gradient[i][0],
255 * wf_gradient[i][1],
255 * wf_gradient[i][2],
255));
}
// Retrieve limits
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
m_maxRowSize = GLLine::resolutionFor(texSize);
if (m_rowCount > m_maxRowSize)
m_rowCount = m_maxRowSize;
if (m_rowSize > m_maxRowSize)
m_rowSize = m_maxRowSize;
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m_vao.create();
if (m_vao.isCreated())
m_vao.bind();
m_vbo.create();
m_vbo.bind();
m_vbo.allocate(vertices, sizeof(vertices));
m_ibo.create();
m_ibo.bind();
m_ibo.allocate(vertex_indices, sizeof(vertex_indices));
m_waterfall = new QOpenGLTexture(QOpenGLTexture::Target2D);
resetWaterfall();
m_palette = new QOpenGLTexture(QOpenGLTexture::Target2D);
m_palette->setWrapMode(QOpenGLTexture::ClampToEdge);
m_palette->setMinificationFilter(QOpenGLTexture::Linear);
m_palette->setMagnificationFilter(QOpenGLTexture::Linear);
m_palette->setSize(256, 1);
m_palette->setData(firstPal);
m_palette->create();
m_vertexShader = new QOpenGLShader(QOpenGLShader::Vertex);
m_vertexShader->compileSourceCode(wfVertexShader);
m_fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment);
m_fragmentShader->compileSourceCode(wfFragmentShader);
m_program.addShader(m_vertexShader);
m_program.addShader(m_fragmentShader);
m_program.link();
m_program.bind();
}
void
GLWaterfallOpenGLContext::resetWaterfall()
{
GLLine nullLine;
nullLine.setResolution(m_rowSize);
if (m_waterfall->isCreated())
m_waterfall->destroy();
m_waterfall->setAutoMipMapGenerationEnabled(true);
m_waterfall->setSize(nullLine.allocation(), m_rowCount);
m_waterfall->setFormat(QOpenGLTexture::TextureFormat::R16F);
m_waterfall->setMinificationFilter(QOpenGLTexture::Linear);
m_waterfall->setMagnificationFilter(QOpenGLTexture::Linear);
m_waterfall->allocateStorage(
QOpenGLTexture::PixelFormat::Red,
QOpenGLTexture::PixelType::UInt32);
m_waterfall->create();
m_waterfall->bind(0);
// Clear waterfall
for (int i = 0; i < m_rowCount; ++i)
glTexSubImage2D(
GL_TEXTURE_2D,
0,
0,
i,
nullLine.allocation(),
1,
GL_RED,
GL_FLOAT,
nullLine.data());
m_row = 0;
}
void
GLWaterfallOpenGLContext::flushPalette()
{
glTexSubImage2D(
GL_TEXTURE_2D,
0,
0,
0,
256,
1,
GL_RGBA,
GL_UNSIGNED_BYTE,
m_paletBuf.data());
}
void
GLWaterfallOpenGLContext::disposeLastLine()
{
if (!m_history.empty()) {
GLLine &line = m_history.back();
// Can we reuse it?
if (m_rowSize == line.resolution()
&& m_pool.size() < GL_WATERFALL_MAX_LINE_POOL_SIZE) {
auto last = m_history.end();
--last;
m_pool.splice(m_pool.begin(), m_history, last);
} else {
m_history.pop_back();
}
}
}
void
GLWaterfallOpenGLContext::flushOneLine()
{
GLLine &line = m_history.back();
int row = m_rowCount - (m_row % m_rowCount) - 1;
if (m_rowSize == line.resolution()) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
0,
row,
line.allocation(),
1,
GL_RED,
GL_FLOAT,
line.data());
disposeLastLine();
m_row = (m_row + 1) % m_rowCount;
} else {
// Wrong line size. Just discard.
disposeLastLine();
}
}
void
GLWaterfallOpenGLContext::flushLinesBulk()
{
int maxRows = m_rowCount - (m_row % m_rowCount);
int count = 0;
int alloc = GLLine::allocationFor(m_rowSize);
std::vector<float> bulkData;
bulkData.resize(maxRows * alloc);
for (int i = 0; i < maxRows && !m_history.empty(); ++i) {
GLLine &line = m_history.back();
if (m_rowSize != line.resolution()) {
disposeLastLine();
break;
}
memcpy(
bulkData.data() + (maxRows - i - 1) * alloc,
line.data(),
alloc * sizeof(float));
disposeLastLine();
++count;
}
if (count > 0) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
0,
maxRows - count,
alloc,
count,
GL_RED,
GL_FLOAT,
bulkData.data() + (maxRows - count) * alloc);
m_row = (m_row + count) % m_rowCount;
}
}
void
GLWaterfallOpenGLContext::flushLines()
{
while (!m_history.empty()) {
if (m_history.size() >= GL_WATERFALL_MIN_BULK_TRANSFER)
flushLinesBulk();
else
flushOneLine();
}
}
void
GLWaterfallOpenGLContext::flushLinePool()
{
m_pool.clear();
}
void
GLWaterfallOpenGLContext::setPalette(const QColor *table)
{
uint8_t *asBytes = reinterpret_cast<uint8_t *>(m_paletBuf.data());
for (int i = 0; i < 256; ++i) {
asBytes[4 * i + 0] = static_cast<uint8_t>(table[i].red());
asBytes[4 * i + 1] = static_cast<uint8_t>(table[i].green());
asBytes[4 * i + 2] = static_cast<uint8_t>(table[i].blue());
asBytes[4 * i + 3] = 255;
}
m_updatePalette = true;
}
void
GLWaterfallOpenGLContext::pushFFTData(
const float *__restrict__ fftData,
int size)
{
int dataSize = size;
if (dataSize > m_maxRowSize)
size = m_maxRowSize;
if (size != m_rowSize) {
flushLinePool();
m_rowSize = size;
resetWaterfall();
}
if (!m_pool.empty()) {
auto last = m_pool.end();
--last;
m_history.splice(m_history.begin(), m_pool, last);
} else {
m_history.push_front(GLLine());
}
// If there are more lines than the ones that fit into the screen, we
// simply discard the older ones
if (m_history.size() > SCAST(unsigned, m_rowCount))
m_history.pop_back();
GLLine &line = m_history.front();
line.setResolution(size);
/////////////////// Set line data ////////////////////
if (size == dataSize) {
if (m_useMaxBlending)
line.assignMax(fftData);
else
line.assignMean(fftData);
} else {
if (m_useMaxBlending)
line.reduceMax(fftData, dataSize);
else
line.reduceMean(fftData, dataSize);
}
}
void
GLWaterfallOpenGLContext::setDynamicRange(float mindB, float maxdB)
{
m_m = (maxdB - mindB) / GL_WATERFALL_TEX_DR;
m_x0 = (mindB - GL_WATERFALL_TEX_MIN_DB) / GL_WATERFALL_TEX_DR;
}
void
GLWaterfallOpenGLContext::finalize()
{
if (m_vao.isCreated())
m_vao.destroy();
m_vbo.destroy();
if (m_waterfall != nullptr && m_waterfall->isCreated())
m_waterfall->destroy();
if (m_palette != nullptr && m_palette->isCreated())
m_palette->destroy();
}
void
GLWaterfallOpenGLContext::recalcGeometric(int width, int height, float zoom)
{
int d = static_cast<int>(floor(log2(m_rowSize / (width * zoom))));
if (d < 0)
d = 0;
// Define the texture coordinates where the best mipmap can be found
m_c_x0 = 1.f - 1.f / static_cast<float>(1 << d);
m_c_x1 = 1.f - 1.f / static_cast<float>(1 << (d + 1));
m_width = width;
m_height = height;
m_zoom = zoom;
}
void
GLWaterfallOpenGLContext::render(
int x,
int y,
int width,
int height,
float left,
float right)
{
QMatrix4x4 ortho;
float zoom = right - left;
// We only care about horizontal zoom
if (width != m_width || fabsf(zoom - m_zoom) > 1e-6f)
recalcGeometric(width, height, zoom);
glPushAttrib(GL_ALL_ATTRIB_BITS); // IMPORTANT TO PREVENT CONFLICTS WITH QPAINTER
m_program.bind(); // Must be the first
glViewport(x, height - m_rowCount - y, width, m_rowCount);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_CULL_FACE);
ortho.translate(2 * left, 0);
ortho.scale(zoom, 1);
m_vbo.bind();
m_ibo.bind();
m_program.setAttributeBuffer(
"vertex_coords",
GL_FLOAT,
0,
3,
sizeof(vertex));
m_program.setAttributeBuffer(
"texture_coords",
GL_FLOAT,
sizeof(vertices[0].vertex_coords),
2,
sizeof(vertex));
m_program.enableAttributeArray("vertex_coords");
m_program.enableAttributeArray("texture_coords");
m_program.setUniformValue("ortho", ortho);
m_program.setUniformValue("t", -m_row / (float) m_rowCount);
m_program.setUniformValue("x0", m_x0);
m_program.setUniformValue("m", m_m);
m_program.setUniformValue("c_x0", m_c_x0);
m_program.setUniformValue("c_m", m_c_x1 - m_c_x0);
m_vao.release();
m_vao.bind();
// Add more lines (if necessary)
m_waterfall->bind(0);
flushLines();
// Update palette (if necessary)
m_palette->bind(1);
if (m_updatePalette) {
flushPalette();
m_updatePalette = false;
}
m_program.setUniformValue("m_texture", 0);
m_program.setUniformValue("m_palette", 1);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);
m_vao.release();
m_program.disableAttributeArray("vertexcoords");
m_program.disableAttributeArray("texture_coords");
// ALL THIS MUST BE RELEASED, OTHERWISE QPAINTER WILL NOT WORK
m_program.release();
m_waterfall->release();
m_palette->release();
m_vbo.release();
m_ibo.release();
glPopAttrib();
}
///////////////////////////// GLWaterfall ////////////////////////////////////////
GLWaterfall::GLWaterfall(QWidget *parent) : AbstractWaterfall(parent)
{
}
GLWaterfall::~GLWaterfall()
{
makeCurrent();
m_glCtx.finalize();
doneCurrent();
}
void
GLWaterfall::clearWaterfall()
{
}
/**
* @brief Save waterfall to a graphics file
* @param filename
* @return TRUE if the save successful, FALSE if an erorr occurred.
*
* We assume that frequency strings are up to date
*/
bool
GLWaterfall::saveWaterfall(const QString &) const
{
return false;
}
void
GLWaterfall::initializeGL()
{
m_glCtx.initialize();
connect(
context(),
SIGNAL(aboutToBeDestroyed()),
this,
SLOT(onContextBeingDestroyed()));
drawOverlay();
}
void
GLWaterfall::onContextBeingDestroyed()
{
makeCurrent();
m_glCtx.finalize();
doneCurrent();
}
void
GLWaterfall::setPalette(const QColor *table)
{
m_glCtx.setPalette(table);
update();
}
void
GLWaterfall::setMaxBlending(bool val)
{
m_glCtx.m_useMaxBlending = val;
}
void GLWaterfall::setWaterfallRange(float min, float max)
{
if (out_of_range(min, max))
return;
m_WfMindB = min;
m_WfMaxdB = max;
m_glCtx.setDynamicRange(min - m_gain, max - m_gain);
// no overlay change is necessary
}
//
// |---------f-------------------------|
// -fs/2 S fs/2
// |---------|
// f0 f1
//
void
GLWaterfall::paintGL()
{
int y = m_Percent2DScreen * m_Size.height() / 100;
qint64 f0 = m_FftCenter - m_Span / 2;
qreal left = (qreal) ( - f0) / (qreal) m_Span - .5f;
qreal right = (qreal) (+m_SampleFreq - f0) / (qreal) m_Span - .5f;
qreal dpi_factor = screen()->devicePixelRatio();
m_glCtx.render(0, y * dpi_factor, width() * dpi_factor,
height() * dpi_factor, left, right);
}
void GLWaterfall::addNewWfLine(const float* wfData, int size, int repeats)
{
makeCurrent();
for (int i = 0; i < repeats; i++)
m_glCtx.pushFFTData(wfData, size);
}