This file is indexed.

/usr/include/CLAM/SpectralPeakDescriptors.hxx is in libclam-dev 1.4.0-5.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
 *                         UNIVERSITAT POMPEU FABRA
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef __SpectralPeakDescriptors_H__
#define __SpectralPeakDescriptors_H__
#include <typeinfo>
#include "Descriptor.hxx"

/*
 * This class holds Descriptors computed from SpectralPeak data 
 * 
 *
 */

namespace CLAM {

	
	class SpectralPeakArray;


	class SpectralPeakDescriptors : public Descriptor {
	public:
		DYNAMIC_TYPE_USING_INTERFACE (SpectralPeakDescriptors, 10, Descriptor);
		/**
		* The average amplitude (arithmetic mean) of the spectral peaks.
		* It is computed on linear scale.
		* Range: [0, 100]
		*/
		DYN_ATTRIBUTE (0, public, TData, MagnitudeMean);
		/**
		* The center of gravity of the spectral peaks.
		* Only the frequency value (in Hz) of the centroid is computed.
		* Amplitude and frequency scale are linear for this operation.
		*
		* - Units: Hz
		* - Range: [0, Nyquist frequency]
		* - Singularities
		*   - Returns zero for empty peak array.
		* @todo Peaks at 0Hz are not counted
		*/
		DYN_ATTRIBUTE (1, public, TData, HarmonicCentroid);
		/**
		* Spectral deviation of magnitude components from spectral envelope.
		* Descriptor is a MPEG7 LLD (HarmonicSpectralDeviation), see 
		* ISO/IEC JTC 1/SC 29 N WXYZ from 2001-03-14.
		* 
		* The local spectral envelopes (SE) are computed on linear scale as
		* the mean of three consecutive peak amplitudes.
		* For the first and the last peak only two peak amplitudes are used. 
		*
		* The spectral HarmonicDeviation is then defined
		* as 
		* \f[ \sum_{i=1}^{Num. of Peaks} 
		* 	\left| PeakAmplitude(i) - SE(i)\right| 
		* 	\over
		* 	{\sum_{i=1}^{Num. of Peaks}PeakAmplitude(i)} \f]
		* ,where SE and PeakAmplitude were converted to logarithmic scale.
		* Returns zero for array with less than 4 peaks.
		*/
		DYN_ATTRIBUTE (2, public, TData, HarmonicDeviation);
		/**
		* Energy ratio of the first harmonic to the energy of all peaks.
		* 
		* Returns zero for empty peak array.
		*/
		DYN_ATTRIBUTE (3, public, TData, FirstTristimulus);
		/**
		* Energy ratio of the second, third and forth harmonic to the energy of all peaks.
		* Returns zero for array with less than 2 peaks.
		*/
		DYN_ATTRIBUTE (4, public, TData, SecondTristimulus);
		/**
		* Energy ratio of all the harmonics starting from the fifth to the energy of all peaks.
		* Returns zero for array with less than 5 peaks.
		*/
		DYN_ATTRIBUTE (5, public, TData, ThirdTristimulus);
		/**
		* Energy ratio of odd harmonics (excluding the fundamental) to 
		* the energy of all peaks.
		* 
		* Returns zero for array with less than 3 peaks.
		*/
		DYN_ATTRIBUTE (6, public, TData, OddHarmonics);
		/**
		* Energy ratio of even harmonics to the energy of all peaks.
		*
		* @pre The peaks represents an ordered list of harmonics starting 
		* at the fundamental.
		* 
		* Returns zero for array with less than 2 peaks.
		*/
		DYN_ATTRIBUTE (7, public, TData, EvenHarmonics);
		/**
		* Ratio of "OddHarmonics" to "EvenHarmonics".		
		* Returns zero if both values are zero.
		*
		* @pre The peaks represents an ordered list of harmonics starting 
		* at the fundamental.
		* 
		* Range: [0, 1]
		*
		* Formula: \f[ \frac{OddHarmonics}{EvenHarmonics+OddHarmonics} \f]
		* @see SpectralPeakDescriptors::DYN_ATTRIBUTE(OddHarmonics)
		* @see SpectralPeakDescriptors::DYN_ATTRIBUTE(EvenHarmonics)
		*/
		DYN_ATTRIBUTE (8, public, TData, OddToEvenRatio);
		DYN_ATTRIBUTE (9,public, Array<TData>, HPCP);  // Harmonic Pitch Class Profile

	public:
		SpectralPeakDescriptors(SpectralPeakArray* pSpectralPeakArray);
		SpectralPeakDescriptors(TData initVal);

		const SpectralPeakArray* GetpSpectralPeakArray() const;
		void SetpSpectralPeakArray(SpectralPeakArray* pSpectralPeakArray);
		void ConcreteCompute();

	private:
		void DefaultInit();
		void CopyInit(const SpectralPeakDescriptors & copied);
		
		TData ComputeCentroid();
		TData ComputeFirstTristimulus();
		TData ComputeSecondTristimulus();
		TData ComputeThirdTristimulus();
		TData ComputeHarmonicDeviation();
		TData ComputeOddHarmonics();
		TData ComputeEvenHarmonics();
		TData ComputeOddToEvenRatio();

	private:
		const SpectralPeakArray* mpSpectralPeakArray;
		CrossCenterOfGravity<1> mCentroid;

	};


SpectralPeakDescriptors operator / (const SpectralPeakDescriptors& a,TData div) ;
SpectralPeakDescriptors operator * (const SpectralPeakDescriptors& a,TData mult) ;
SpectralPeakDescriptors operator * (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b) ;
SpectralPeakDescriptors operator + (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b) ;

template<>
inline SpectralPeakDescriptors CLAM_max (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b)
{
	SpectralPeakDescriptors tmpD(a);

	if (a.HasMagnitudeMean() && b.HasMagnitudeMean())
	{
		if(b.GetMagnitudeMean()>a.GetMagnitudeMean())
			tmpD.SetMagnitudeMean(b.GetMagnitudeMean());
	}
	if (a.HasHarmonicCentroid() && b.HasHarmonicCentroid())
	{
		if(b.GetHarmonicCentroid()>a.GetHarmonicCentroid())
			tmpD.SetHarmonicCentroid(b.GetHarmonicCentroid());
	}
	if (a.HasFirstTristimulus() && b.HasFirstTristimulus())
	{
		if(b.GetFirstTristimulus()>a.GetFirstTristimulus())
			tmpD.SetFirstTristimulus(b.GetFirstTristimulus());
	}
	if (a.HasSecondTristimulus() && b.HasSecondTristimulus())
	{
		if(b.GetSecondTristimulus()>a.GetSecondTristimulus())
			tmpD.SetSecondTristimulus(b.GetSecondTristimulus());
	}
	if (a.HasThirdTristimulus() && b.HasThirdTristimulus())
	{
		if(b.GetThirdTristimulus()>a.GetThirdTristimulus())
			tmpD.SetThirdTristimulus(b.GetThirdTristimulus());
	}
	if (a.HasHarmonicDeviation() && b.HasHarmonicDeviation())
	{
		if(b.GetHarmonicDeviation()>a.GetHarmonicDeviation())
			tmpD.SetHarmonicDeviation(b.GetHarmonicDeviation());
	}
	if (a.HasOddHarmonics() && b.HasOddHarmonics())
	{
		if(b.GetOddHarmonics()>a.GetOddHarmonics())
			tmpD.SetOddHarmonics(b.GetOddHarmonics());
	}
	if (a.HasEvenHarmonics() && b.HasEvenHarmonics())
	{
		if(b.GetEvenHarmonics()>a.GetEvenHarmonics())
			tmpD.SetEvenHarmonics(b.GetEvenHarmonics());
	}
	if (a.HasOddToEvenRatio() && b.HasOddToEvenRatio())
	{
		if(b.GetOddToEvenRatio()>a.GetOddToEvenRatio())
			tmpD.SetOddToEvenRatio(b.GetOddToEvenRatio());
	}
	
	return tmpD;
}

template<>
inline SpectralPeakDescriptors CLAM_min (const SpectralPeakDescriptors& a,const SpectralPeakDescriptors& b)
{
	SpectralPeakDescriptors tmpD(a);

	if (a.HasMagnitudeMean() && b.HasMagnitudeMean())
	{
		if(b.GetMagnitudeMean()<a.GetMagnitudeMean())
			tmpD.SetMagnitudeMean(b.GetMagnitudeMean());
	}
	if (a.HasHarmonicCentroid() && b.HasHarmonicCentroid())
	{
		if(b.GetHarmonicCentroid()<a.GetHarmonicCentroid())
			tmpD.SetHarmonicCentroid(b.GetHarmonicCentroid());
	}
	if (a.HasFirstTristimulus() && b.HasFirstTristimulus())
	{
		if(b.GetFirstTristimulus()<a.GetFirstTristimulus())
			tmpD.SetFirstTristimulus(b.GetFirstTristimulus());
	}
	if (a.HasSecondTristimulus() && b.HasSecondTristimulus())
	{
		if(b.GetSecondTristimulus()<a.GetSecondTristimulus())
			tmpD.SetSecondTristimulus(b.GetSecondTristimulus());
	}
	if (a.HasThirdTristimulus() && b.HasThirdTristimulus())
	{
		if(b.GetThirdTristimulus()<a.GetThirdTristimulus())
			tmpD.SetThirdTristimulus(b.GetThirdTristimulus());
	}
	if (a.HasHarmonicDeviation() && b.HasHarmonicDeviation())
	{
		if(b.GetHarmonicDeviation()<a.GetHarmonicDeviation())
			tmpD.SetHarmonicDeviation(b.GetHarmonicDeviation());
	}
	if (a.HasOddHarmonics() && b.HasOddHarmonics())
	{
		if(b.GetOddHarmonics()<a.GetOddHarmonics())
			tmpD.SetOddHarmonics(b.GetOddHarmonics());
	}
	if (a.HasEvenHarmonics() && b.HasEvenHarmonics())
	{
		if(b.GetEvenHarmonics()<a.GetEvenHarmonics())
			tmpD.SetEvenHarmonics(b.GetEvenHarmonics());
	}
	if (a.HasOddToEvenRatio() && b.HasOddToEvenRatio())
	{
		if(b.GetOddToEvenRatio()<a.GetOddToEvenRatio())
			tmpD.SetOddToEvenRatio(b.GetOddToEvenRatio());
	}
	
	return tmpD;
}



}


#endif /* __SpectralPeakDescriptors_H__ */