FFT: Prevent user from attempting hops smaller than SC's block size
[supercollider.git] / server / plugins / ML.h
blob5b57fa2758de7be0f040267b9c1dbb68116597a6
1 /*
2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "SC_PlugIn.h"
23 //global data
25 //helpful constants
26 //#define PI 3.1415926535898f
27 //#define TWOPI 6.28318530717952646f
29 extern InterfaceTable *ft;
31 //shared data
32 extern int eqlbandbins[43];
33 extern int eqlbandsizes[42];
34 extern float contours[42][11];
35 extern double phons[11];
37 //#include "KeyTrack.h"
38 #include "BeatTrack.h"
39 //#include "Loudness.h"
40 #include "Onsets.h"
41 //#include "MFCC.h"
42 #include "BeatTrack2.h"
44 struct Loudness : Unit {
46 //FFT data
47 int m_numbands;
48 float * m_ERBbands;
50 //float m_phontotal;
51 //final output
52 float m_sones;
57 struct KeyTrack : Unit {
59 //FFT data
60 float * m_FFTBuf;
62 //coping with different sampling rates
63 float m_srate; //use as a flag to check sample rate is correct
64 float * m_weights; //will point to the sample rate specific data
65 int * m_bins;
66 float m_frameperiod;
68 //counter
69 //uint32 m_frame;
71 //experimental transient avoidance
72 //float m_prevphase[720]; //60*12
73 //float m_leaknote[60];
75 float m_chroma[12];
76 float m_key[24];
78 float m_histogram[24]; //key histogram
79 //float m_keyleak; //fade parameter for histogram
80 //int m_triggerid;
82 int m_currentKey;
86 struct MFCC : Unit {
88 //MFCC
89 int m_numcoefficients;
90 float * m_mfcc;
91 //ERB
92 int m_numbands;
93 float * m_bands;
95 //sampling rate specific data
96 float m_srate;
97 int * m_startbin;
98 int * m_endbin;
99 int * m_cumulindex;
100 float * m_bandweights;
104 //////////////////////////////////////////////////////////////////////////////////////////////////
106 struct FFTAnalyser_Unit : Unit
108 float outval;
110 // Not always used: multipliers which convert from bin indices to freq vals, and vice versa.
111 // See also the macros for deriving these.
112 float m_bintofreq /* , m_freqtobin */;
113 float m_halfnyq_over_numbinsp2;
116 struct FFTAnalyser_OutOfPlace : FFTAnalyser_Unit
118 int m_numbins;
119 float *m_tempbuf;
122 struct SpecFlatness : FFTAnalyser_Unit
124 double m_oneovern;
127 struct SpecPcile : FFTAnalyser_OutOfPlace
129 bool m_interpolate;
132 struct SpecCentroid : FFTAnalyser_Unit
138 extern "C"
140 //required interface functions
141 void Loudness_next(Loudness *unit, int wrongNumSamples);
142 void Loudness_Ctor(Loudness *unit);
143 void Loudness_Dtor(Loudness *unit);
145 void KeyTrack_next(KeyTrack *unit, int wrongNumSamples);
146 void KeyTrack_Ctor(KeyTrack *unit);
147 void KeyTrack_Dtor(KeyTrack *unit);
149 void MFCC_next(MFCC *unit, int wrongNumSamples);
150 void MFCC_Ctor(MFCC *unit);
151 void MFCC_Dtor(MFCC *unit);
153 void SpecFlatness_Ctor(SpecFlatness *unit);
154 void SpecFlatness_next(SpecFlatness *unit, int inNumSamples);
156 void SpecPcile_Ctor(SpecPcile *unit);
157 void SpecPcile_next(SpecPcile *unit, int inNumSamples);
158 void SpecPcile_Dtor(SpecPcile *unit);
160 void SpecCentroid_Ctor(SpecCentroid *unit);
161 void SpecCentroid_next(SpecCentroid *unit, int inNumSamples);