OpenShot Library | libopenshot  0.4.0
STFT.h
Go to the documentation of this file.
1 // © OpenShot Studios, LLC
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4 
5 #pragma once
6 
7 #ifndef OPENSHOT_STFT_AUDIO_EFFECT_H
8 #define OPENSHOT_STFT_AUDIO_EFFECT_H
9 #define _USE_MATH_DEFINES
10 
11 #include "EffectBase.h"
12 #include "Enums.h"
13 
14 #include <AppConfig.h>
15 #include <juce_audio_basics/juce_audio_basics.h>
16 #include <juce_dsp/juce_dsp.h>
17 
18 namespace openshot
19 {
20 
21  class STFT
22  {
23  public:
24  STFT() : num_channels (1) { }
25 
26  virtual ~STFT() { }
27 
28  void setup(const int num_input_channels);
29 
30  void process(juce::AudioBuffer<float> &block);
31 
32  void updateParameters(const int new_fft_size, const int new_overlap, const int new_window_type);
33 
34  virtual void updateFftSize(const int new_fft_size);
35 
36  virtual void updateHopSize(const int new_overlap);
37 
38  virtual void updateWindow(const int new_window_type);
39 
40  private:
41 
42  virtual void modification(const int channel);
43 
44  virtual void analysis(const int channel);
45 
46  virtual void synthesis(const int channel);
47 
48  protected:
51 
52  int fft_size;
53  std::unique_ptr<juce::dsp::FFT> fft;
54 
57 
60 
61  juce::HeapBlock<float> fft_window;
62  juce::HeapBlock<juce::dsp::Complex<float>> time_domain_buffer;
63  juce::HeapBlock<juce::dsp::Complex<float>> frequency_domain_buffer;
64 
65  int overlap;
66  int hop_size;
69 
74 
79  };
80 }
81 
82 #endif
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::STFT::input_buffer_length
int input_buffer_length
Definition: STFT.h:55
juce::AudioBuffer< float >
openshot::STFT::current_output_buffer_write_position
int current_output_buffer_write_position
Definition: STFT.h:76
openshot::STFT::window_type
int window_type
Definition: STFT.h:67
openshot::STFT::STFT
STFT()
Definition: STFT.h:24
openshot::STFT::fft
std::unique_ptr< juce::dsp::FFT > fft
Definition: STFT.h:53
openshot::STFT::current_input_buffer_write_position
int current_input_buffer_write_position
Definition: STFT.h:75
openshot::STFT::num_samples
int num_samples
Definition: STFT.h:50
EffectBase.h
Header file for EffectBase class.
openshot::STFT::updateFftSize
virtual void updateFftSize(const int new_fft_size)
Definition: STFT.cpp:62
openshot::STFT::updateHopSize
virtual void updateHopSize(const int new_overlap)
Definition: STFT.cpp:93
openshot::STFT::frequency_domain_buffer
juce::HeapBlock< juce::dsp::Complex< float > > frequency_domain_buffer
Definition: STFT.h:63
openshot::STFT::output_buffer_length
int output_buffer_length
Definition: STFT.h:58
openshot::STFT::current_output_buffer_read_position
int current_output_buffer_read_position
Definition: STFT.h:77
openshot::STFT::samples_since_last_FFT
int samples_since_last_FFT
Definition: STFT.h:73
openshot::STFT::num_channels
int num_channels
Definition: STFT.h:49
openshot::STFT::process
void process(juce::AudioBuffer< float > &block)
Definition: STFT.cpp:21
openshot::STFT::window_scale_factor
float window_scale_factor
Definition: STFT.h:68
openshot::STFT::fft_size
int fft_size
Definition: STFT.h:52
openshot::STFT::input_buffer
juce::AudioBuffer< float > input_buffer
Definition: STFT.h:56
openshot::STFT::updateWindow
virtual void updateWindow(const int new_window_type)
Definition: STFT.cpp:107
openshot::STFT
Definition: STFT.h:21
openshot::STFT::hop_size
int hop_size
Definition: STFT.h:66
openshot::STFT::output_buffer_read_position
int output_buffer_read_position
Definition: STFT.h:72
Enums.h
Header file for TextReader class.
openshot::STFT::updateParameters
void updateParameters(const int new_fft_size, const int new_overlap, const int new_window_type)
Definition: STFT.cpp:14
openshot::STFT::time_domain_buffer
juce::HeapBlock< juce::dsp::Complex< float > > time_domain_buffer
Definition: STFT.h:62
openshot::STFT::output_buffer
juce::AudioBuffer< float > output_buffer
Definition: STFT.h:59
openshot::STFT::input_buffer_write_position
int input_buffer_write_position
Definition: STFT.h:70
openshot::STFT::output_buffer_write_position
int output_buffer_write_position
Definition: STFT.h:71
openshot::STFT::overlap
int overlap
Definition: STFT.h:65
openshot::STFT::setup
void setup(const int num_input_channels)
Definition: STFT.cpp:9
openshot::STFT::fft_window
juce::HeapBlock< float > fft_window
Definition: STFT.h:61
openshot::STFT::~STFT
virtual ~STFT()
Definition: STFT.h:26
openshot::STFT::current_samples_since_last_FFT
int current_samples_since_last_FFT
Definition: STFT.h:78