Merge branch 'master' of https://github.com/calf-studio-gear/calf
[calf.git] / src / calf / modules_pitch.h
blob3cf4f8d2281d031b82edb584a2e7b78d882cced3
1 #ifndef CALF_MODULES_PITCH_H
2 #define CALF_MODULES_PITCH_H
4 #include <assert.h>
5 #include <limits.h>
6 #include "biquad.h"
7 #include "inertia.h"
8 #include "audio_fx.h"
9 #include "analyzer.h"
10 #include "giface.h"
11 #include "metadata.h"
12 #include "fft.h"
13 #include <math.h>
14 #include "bypass.h"
16 #if ENABLE_EXPERIMENTAL
18 namespace calf_plugins {
20 class pitch_audio_module: public audio_module<pitch_metadata>, public line_graph_iface
22 protected:
23 typedef dsp::fft<float, 12> pfft;
24 enum { BufferSize = 4096 };
25 uint32_t srate;
26 pfft transform;
27 float inputbuf[BufferSize];
28 pfft::complex waveform[2 * BufferSize], spectrum[2 * BufferSize], autocorr[2 * BufferSize];
29 float magarr[BufferSize / 2];
30 float sumsquares[BufferSize + 1], sumsquares_last;
31 uint32_t write_ptr;
33 void recompute();
34 public:
35 typedef pitch_audio_module AM;
37 pitch_audio_module();
38 ~pitch_audio_module();
39 void params_changed();
40 void activate();
41 void set_sample_rate(uint32_t sr);
42 void deactivate();
43 uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
45 bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const;
46 bool get_layers(int index, int generation, unsigned int &layers) const { layers = LG_REALTIME_GRAPH; return true; }
50 #endif
52 #endif