File: waterfall_plot.h

package info (click to toggle)
satdump 1.2.2%2Bgb79af48-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 81,648 kB
  • sloc: cpp: 276,768; ansic: 164,598; lisp: 1,219; sh: 283; xml: 106; makefile: 7
file content (60 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
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
#pragma once

#include "imgui/imgui.h"
#include <cstdint>
#include <vector>
#include <mutex>
#include "common/colormaps.h"

namespace widgets
{
    class WaterfallPlot
    {
    private:
        int fft_max_size;
        int fft_size;
        int fft_lines;
        const int resolution = 2000; // Number of colors
        unsigned int texture_id = 0;
        uint32_t *raw_img_buffer = nullptr;

        std::vector<uint32_t> palette;

        std::mutex work_mtx;

        int last_curr_width = 0;
        int last_curr_height = 0;

        int curr_width;
        int curr_height;

        bool need_update = false;

        int waterfall_i_mod = 0;
        int waterfall_i = 0;

        bool buffer_alloc(size_t size);

    public:
        float scale_min, scale_max;

    public:
        WaterfallPlot(int size, int lines);
        ~WaterfallPlot();
        void draw(ImVec2 size, bool active = true);

        void set_size(int size)
        {
            work_mtx.lock();
            if (size <= fft_max_size)
                fft_size = size;
            work_mtx.unlock();
        }

        void push_fft(float *values);

        void set_rate(int input_rate, int output_rate);

        void set_palette(colormaps::Map palette, bool mtx = true);
    };
}