Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
spectrum_analyzer.h
1// SPDX-FileCopyrightText: © 2023-2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __GUI_WIDGETS_SPECTRUM_ANALYZER_H__
5#define __GUI_WIDGETS_SPECTRUM_ANALYZER_H__
6
7#include "common/utils/types.h"
8#include "gui/backend/gtk_widgets/gtk_wrapper.h"
9
10#include "juce_wrapper.h"
11#include <kiss_fft.h>
12
13class Port;
14class PeakFallSmooth;
15
21
22#define SPECTRUM_ANALYZER_WIDGET_TYPE (spectrum_analyzer_widget_get_type ())
24 SpectrumAnalyzerWidget,
25 spectrum_analyzer_widget,
26 Z,
27 SPECTRUM_ANALYZER_WIDGET,
28 GtkWidget)
29
30#define SPECTRUM_ANALYZER_MAX_BLOCK_SIZE 32768
31#define SPECTRUM_ANALYZER_MIN_FREQ 20.f
32
36using SpectrumAnalyzerWidget = struct _SpectrumAnalyzerWidget
37{
38 GtkWidget parent_instance;
39
41 Port * port;
42
43 std::unique_ptr<juce::AudioSampleBuffer> buffer;
44
45 kiss_fft_cpx * fft_in;
46 kiss_fft_cpx * fft_out;
47
48 kiss_fft_cfg fft_config;
49 int last_block_size;
50
51 std::vector<PeakFallSmooth> bins;
52};
53
57void
58spectrum_analyzer_widget_setup_engine (SpectrumAnalyzerWidget * self);
59
60SpectrumAnalyzerWidget *
61spectrum_analyzer_widget_new_for_port (Port * port);
62
66
67#endif
void spectrum_analyzer_widget_setup_engine(SpectrumAnalyzerWidget *self)
Creates a spectrum analyzer for the AudioEngine.
G_DECLARE_FINAL_TYPE(SpectrumAnalyzerWidget, spectrum_analyzer_widget, Z, SPECTRUM_ANALYZER_WIDGET, GtkWidget) using SpectrumAnalyzerWidget
Spectrum analyzer.