00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #if !defined(Loudness_HEADER_INCLUDED__)
00026 #define Loudness_HEADER_INCLUDED__
00027
00028
00029 #include "FEAPIPluginBase.h"
00030
00031 template <class T> class CRingBuffer;
00032 class CzplfFFT_If;
00033
00034 #define FREQ_VALUES_FROM_TABLE
00035
00037 class CLoudness : public CFeatureExtractBase
00038 {
00039 public:
00040
00041 CLoudness ();
00042
00043 virtual ~CLoudness ();
00044
00045
00047
00048
00049
00050
00051 FEAPI_Error_t SetPluginParameter ( int iParameterIndex,
00052 float fValue);
00053
00054 float GetPluginParameter ( int iParameterIndex);
00055
00056
00057 int GetPluginResultLatency (int iResultIndex);
00058
00059 float GetPluginProperty ( FEAPI_PluginProperty_t ePluginProperty);
00060
00061 FEAPI_Error_t InitializePlugin ( float fInputSampleRate,
00062 int iNumberOfAudioChannels,
00063 int iHostApiMajorVersion,
00064 FEAPI_UserData_t *pstUserData);
00065
00066 FEAPI_Error_t ProcessPlugin ( const float **ppfInputBuffer,
00067 const FEAPI_TimeStamp_t *ptFEAPI_TimeStamp,
00068 int iNumberOfFrames);
00069
00070 FEAPI_Error_t ProcessPluginDone ();
00071
00072
00073 int GetPluginSizeOfResult (int iResultIndex);
00074
00075 FEAPI_Error_t GetPluginResult ( int iResultIndex,
00076 float *pfResult,
00077 FEAPI_TimeStamp_t *ptFEAPI_TimeStamp);
00078
00079
00080 FEAPI_Error_t ResetPlugin ();
00081
00082 private:
00083
00084 struct FrequencyBands_t
00085 {
00086 float fLowFreqBound,
00087 fUpFreqBound,
00088 fMidFreq;
00089 float fLowBarkBound,
00090 fUpBarkBound,
00091 fMidBark;
00092 };
00093
00094 struct InternalResults_t
00095 {
00096 bool bHoldsResult;
00097 float fResult;
00098 FEAPI_TimeStamp_t tTimeStamp;
00099 };
00100
00101 struct InternalHRTables_t
00102 {
00103 float *pfOuterEarTransferFunction,
00104 *pfSlopeSpread,
00105 *pfNormSpread,
00106 *pfATH,
00107 *pfThreshIdx;
00108 FrequencyBands_t *pstFrequencyBands;
00109 };
00110
00111 void WriteResult (int iResultIdx, float fValue, FEAPI_TimeStamp_t tTimStamp);
00112 void CalcFreqBounds ();
00113 FEAPI_Error_t GetBandLevels (FrequencyBands_t *m_pFrequencyValues, float *pfBandLevels, int iNumOfBands, bool bDezibel = true);
00114 float GetDinLoudness ();
00115 float GetHRLoudness ();
00116 FEAPI_Error_t AllocHRTables ();
00117 FEAPI_Error_t CalcSpreading (float *pfBandLevels, float *pfResult);
00118 float CalcSpecLoudness ();
00119
00120
00121 FEAPI_SignalDescription_t m_stResultDescription;
00122 FEAPI_TimeStamp_t *m_ptLocalTimeStamp;
00123
00124
00125 float *m_pfParameters,
00126 *m_pfProcessBuffer,
00127 *m_pfHelpBuffer;
00128
00129 CRingBuffer<float> **m_ppCRingBuffer;
00130
00131 InternalResults_t **m_ppResults;
00132
00133 CzplfFFT_If *m_pFFTInstance;
00134
00135 int m_iSizeOfResultBuffer;
00136
00137 float m_fNormFactor,
00138 m_fRMSFullScaleLevel;
00139
00140 FrequencyBands_t *m_pDINFreqBands;
00141
00142 int m_iNumOfDINThirdBands,
00143 m_iNumOfDINCritBands,
00144 m_iNumOfCritBands;
00145
00146 float *m_pfDINBandLevels,
00147 *m_pfHRBandLevels,
00148 *m_pfExcitationPatterns;
00149
00150 bool m_bDiffuseFieldCorrected;
00151
00152 InternalHRTables_t m_stInternalTables;
00153 };
00154
00155 #endif // #if !defined(Loudness_HEADER_INCLUDED__)
00156
00157
00158