annotate FChTransformF0gram.h @ 11:36c99e4c7e94 perf

Remove unused
author Chris Cannam
date Tue, 02 Oct 2018 13:33:29 +0100
parents af59167b3d35
children fc8f351d2cd6
rev   line source
Chris@0 1 /*
Chris@0 2 copyright (C) 2011 I. Irigaray, M. Rocamora
Chris@0 3
Chris@0 4 This program is free software: you can redistribute it and/or modify
Chris@0 5 it under the terms of the GNU General Public License as published by
Chris@0 6 the Free Software Foundation, either version 3 of the License, or
Chris@0 7 (at your option) any later version.
Chris@0 8
Chris@0 9 This program is distributed in the hope that it will be useful,
Chris@0 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 GNU General Public License for more details.
Chris@0 13
Chris@0 14 You should have received a copy of the GNU General Public License
Chris@0 15 along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@7 16 */
Chris@0 17
Chris@0 18 // Remember to use a different guard symbol in each header!
Chris@0 19 #ifndef _FCHTRANSFORMF0GRAM_H_
Chris@0 20 #define _FCHTRANSFORMF0GRAM_H_
Chris@7 21
Chris@0 22 #define _USE_MATH_DEFINES
Chris@0 23 #include <cmath>
Chris@0 24 #include <vamp-sdk/Plugin.h>
Chris@0 25 #include <complex>
Chris@0 26 #include <fftw3.h>
Chris@0 27 #include <iostream>
Chris@0 28 #include <fstream>
Chris@0 29 #include <string.h>
Chris@0 30
Chris@0 31 using namespace std;
Chris@0 32 using std::string;
Chris@0 33
Chris@0 34 class FChTransformF0gram : public Vamp::Plugin {
Chris@0 35 public:
Chris@0 36 FChTransformF0gram(float inputSampleRate);
Chris@0 37 virtual ~FChTransformF0gram();
Chris@0 38
Chris@0 39 string getIdentifier() const;
Chris@0 40 string getName() const;
Chris@0 41 string getDescription() const;
Chris@0 42 string getMaker() const;
Chris@0 43 string getCopyright() const;
Chris@0 44 int getPluginVersion() const;
Chris@0 45
Chris@0 46 InputDomain getInputDomain() const;
Chris@0 47 size_t getMinChannelCount() const;
Chris@0 48 size_t getMaxChannelCount() const;
Chris@0 49 size_t getPreferredStepSize() const;
Chris@0 50 size_t getPreferredBlockSize() const;
Chris@0 51
Chris@0 52 ParameterList getParameterDescriptors() const;
Chris@0 53 float getParameter(string identifier) const;
Chris@0 54 void setParameter(string identifier, float value);
Chris@0 55
Chris@0 56 ProgramList getPrograms() const;
Chris@0 57 string getCurrentProgram() const;
Chris@0 58 void selectProgram(string name);
Chris@0 59
Chris@0 60 OutputList getOutputDescriptors() const;
Chris@0 61
Chris@0 62 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
Chris@0 63 void reset();
Chris@0 64
Chris@0 65 FeatureSet process(const float *const *inputBuffers,
Chris@7 66 Vamp::RealTime timestamp);
Chris@0 67
Chris@0 68 FeatureSet getRemainingFeatures();
Chris@0 69
Chris@0 70 protected:
Chris@0 71
Chris@0 72 string m_currentProgram;
Chris@10 73 int m_stepSize;
Chris@10 74 int m_blockSize;
Chris@0 75 float m_fs; // input sampling rate (inputSampleRate)
Chris@0 76
Chris@0 77 // plugin-specific data and methods go here
Chris@0 78
Chris@0 79 // ============= WARPING PARAMETERS =============
Chris@0 80
Chris@0 81 double m_fmax; // maximum frequency of interest (Hz)
Chris@10 82 int m_nfft; // number of fft points (controls zero-padding)
Chris@10 83 int m_hop; // hop in samples in the upsampled signal
Chris@10 84 int m_num_f0s; // number of f0 values in F0gram grid
Chris@0 85 //vector<float> m_f0s; // vector of f0 values
Chris@0 86 double *m_f0s; // vector of f0 values
Chris@0 87
Chris@0 88 typedef struct {
Chris@10 89 int nsamps_twarp; // number of samples of the warped signal frame
Chris@0 90 double alpha_max; // maximum value of normalized frequency deviation (alpha)
Chris@10 91 int num_warps; // number of warpings
Chris@10 92 int fact_over_samp; // oversampling factor
Chris@10 93 int alpha_dist; // distribution of alpha values, 'lin' or 'log' (0 - 1)
Chris@0 94 } warping_parameters;
Chris@0 95
Chris@0 96 warping_parameters m_warp_params;
Chris@0 97
Chris@0 98 // ============= F0-GRAM PARAMETERS =============
Chris@0 99
Chris@0 100 typedef struct {
Chris@0 101 double f0min; // minimun fundamental frequency
Chris@10 102 int num_octs; // number of octaves
Chris@10 103 int num_f0s_per_oct; // number of f0s per octave
Chris@10 104 int num_f0_hyps; // number of f0 hypotesis to extract
Chris@0 105 bool prefer; // whether to use a f0 preference guassian function
Chris@10 106 int prefer_mean; // mean of f0 preference function (MIDI number for C4)
Chris@10 107 int prefer_stdev; // stdev of f0 preference function (stdev in MIDI numbers)
Chris@0 108 } f0_parameters;
Chris@0 109
Chris@0 110 f0_parameters m_f0_params;
Chris@7 111 bool m_f0gram_mode;
Chris@0 112
Chris@0 113 // ======== GATHERED LOG SPECTRUM PARAMETERS =======
Chris@0 114
Chris@0 115 typedef struct {
Chris@0 116 bool HP_logS; //high-pass logS
Chris@0 117 int att_subharms; // whether to attenuate subharmonics
Chris@0 118 // model parameter variables (default values)
Chris@0 119 double median_poly_coefs[3];
Chris@0 120 double sigma_poly_coefs[3];
Chris@0 121 } glogs_parameters;
Chris@0 122
Chris@0 123 glogs_parameters m_glogs_params;
Chris@0 124
Chris@0 125 // ============= WARPING DESIGN =============
Chris@0 126
Chris@0 127 typedef struct {
Chris@0 128 double fs_orig; // sampling frequency after oversampling
Chris@0 129 double fs_warp; // sampling frequency of warped signal
Chris@0 130 double *chirp_rates; // chirp rates
Chris@10 131 int nsamps_torig; // number of samples of the original signal frame
Chris@10 132 int *pos_int; // index of previous sample to do the warping by interpolation efficiently
Chris@0 133 double *pos_frac; // fractional value to do the warping by interpolation efficiently
Chris@0 134 } warping_design;
Chris@0 135
Chris@0 136 warping_design m_warpings;
Chris@0 137 // LPFWindow
Chris@0 138 double *mp_LPFWindow;
Chris@0 139 double *LPF_time;
Chris@0 140 fftw_complex *LPF_frequency;
Chris@0 141 fftw_plan plan_backward_LPF;
Chris@0 142 fftw_plan plan_forward_LPF;
Chris@7 143 // timeWindow
Chris@7 144 double *m_timeWindow;
Chris@7 145 // Warpings
Chris@7 146 double *x_warping;
Chris@7 147 // Hanning window
Chris@7 148 double *mp_HanningWindow;
Chris@7 149 // FChT plan & transformed data structs
Chris@7 150 double *m_absFanChirpTransform;
Chris@7 151 fftw_complex *m_auxFanChirpTransform;
Chris@7 152 fftw_plan plan_forward_xwarping;
Chris@7 153 // GLogS
Chris@7 154 double *m_glogs_f0;
Chris@7 155 double *m_glogs;
Chris@10 156 int *m_glogs_n;
Chris@10 157 int *m_glogs_index;
Chris@10 158 int *m_glogs_posint;
Chris@7 159 double *m_glogs_posfrac;
Chris@7 160 double *m_glogs_interp;
Chris@10 161 int m_glogs_harmonic_count;
Chris@10 162 int m_glogs_num_f0s;
Chris@10 163 int m_glogs_init_f0s;
Chris@10 164 int *m_glogs_third_harmonic_posint;
Chris@7 165 double *m_glogs_third_harmonic_posfrac;
Chris@7 166 double *m_glogs_third_harmonic;
Chris@10 167 int *m_glogs_fifth_harmonic_posint;
Chris@7 168 double *m_glogs_fifth_harmonic_posfrac;
Chris@7 169 double *m_glogs_fifth_harmonic;
Chris@7 170 double *m_glogs_f0_preference_weights;
Chris@7 171 double *m_glogs_median_correction;
Chris@7 172 double *m_glogs_sigma_correction;
Chris@7 173 double *m_glogs_hf_smoothing_window;
Chris@0 174 // auxiliar methods
Chris@7 175 void design_GLogS();
Chris@0 176 void design_FChT();
Chris@0 177 void define_warps_linear_chirps(double *, double *);
Chris@0 178 void design_warps(double *, double *, double *);
Chris@0 179 void design_LPF();
Chris@0 180 void clean_LPF();
Chris@0 181 void apply_LPF();
Chris@7 182 void design_FFT();
Chris@7 183 void design_time_window();
Chris@0 184
Chris@7 185 // FFT variables
Chris@7 186 fftw_complex *in, *out;
Chris@7 187 //TODO verificar que el tipo de datos de in_window es del tipo double, era del tipo float.
Chris@7 188 double *in_window;
Chris@7 189 fftw_plan planFFT;
Chris@0 190 };
Chris@0 191
Chris@0 192
Chris@0 193 #endif