This file is indexed.

/usr/include/CLAM/SpectralDescriptors.hxx is in libclam-dev 1.4.0-6.

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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
/*
 * 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 __SpectralDescriptors_H__
#define __SpectralDescriptors_H__


#include "Array.hxx"
#include "Descriptor.hxx"
#include "Spectrum.hxx"

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

namespace CLAM {

  	class SpectralDescriptors : public Descriptor {
	public:
		DYNAMIC_TYPE_USING_INTERFACE (SpectralDescriptors, 21, Descriptor);
		
		/** The spectral power mean value.
		 *  The unit of this measure can be dB
		 *  or none, depending on the scale set for the
		 *  measured Spectrum object.
		 *  @see Spectrum::SetScale
		 *  @see EScale
		 *  @see Stats::GetMean
		 */
		DYN_ATTRIBUTE (0, public, TData, Mean);
		/**
		 * The geometric mean for the spectral power values sequence.
		 * See <a href="http://mathworld.wolfram.com/GeometricMean.html">this</a> for a definition of
		 * this pythagorean mean. Note that computing this measurement over long sequences of
		 * small real numbers ( as the ones one usually founds in spectral power distributions derived
		 * of audio windowed with a normalized window function ) pose a numerical problem. To avoid
		 * this, computation of Geometric mean is restricted to Log scale Spectral Power Distributions 
		 * since this allows to change the product for a summation.
		 *
		 * This measure is expressed in dBs.
		 * @see Stats::GetGeometricMean
		 */
		DYN_ATTRIBUTE (1, public, TData, GeometricMean);
		/**
		 *  The squared sum of spectral power distribution values.
		 *  This measure comes in the same units as the distribution
		 *  values.
		 *  @see Stats::GetEnergy
		 */
		DYN_ATTRIBUTE (2, public, TData, Energy);
		/**
		 *  The frequency where the center of mass of the spectral power
		 *  distribution lies.
		 *  This measure is expressed in Hz.
		 * 
		 *  @see Stats::GetCentroid
		 */
		DYN_ATTRIBUTE (3, public, TData, Centroid);
		DYN_ATTRIBUTE (4, public, TData, Moment2);
		DYN_ATTRIBUTE (5, public, TData, Moment3);
		DYN_ATTRIBUTE (6, public, TData, Moment4);
		DYN_ATTRIBUTE (7, public, TData, Moment5);
		DYN_ATTRIBUTE (8, public, TData, Moment6);
		DYN_ATTRIBUTE (9, public, TData, Flatness);
		DYN_ATTRIBUTE (10,public, TData, MagnitudeKurtosis);
		DYN_ATTRIBUTE (11,public, Array<TData>, MFCC);
		/**
		 * Frequency of the maximum magnitude of the spectrum 
		 * normalized by the spectral range
		 */
		DYN_ATTRIBUTE (12,public, TData, MaxMagFreq); 
		/**
		 * The ratio between the energy over 0-100 Hz band and the whole spectrum energy.
		 * To avoid singularities while keeping descriptor continuity, 
		 * when the whole spectrum energy drops bellow $10^{-4}$, 
		 * such value is considered as whole spectrum energy.
		 */
		DYN_ATTRIBUTE (13,public, TData, LowFreqEnergyRelation); 
		/**
		 * The spectral spread is the variation of the spectrum
		 * around its mean value. It's computed from the second
		 * order moment.
		 */
		DYN_ATTRIBUTE (14,public, TData, Spread);
		DYN_ATTRIBUTE (15,public, TData, MagnitudeSkewness);
		/**
		 * The spectral roll-off point is the frequency value 
		 * so that the 85% of the spectral energy is contained below 
		 * it. For silences this is 0Hz. Measured in Hz.
		 *
		 * \f[
		 * Rolloff / \sum_{f=0}^{RollOff} {a_f^2} = 0.85 \times \sum_{f=0}^{SpectralRange} {a_f^2}
		 * \f]
		 */
		DYN_ATTRIBUTE (16,public, TData, Rolloff); 
		/**
		 * The spectral slope represents the amount of decreasing of
		 * the spectral magnitude. Measured in ??.
		 * @see Stats::Slope
		 */
		DYN_ATTRIBUTE (17,public, TData, Slope);
		/**
		 * Sum of the squared spectrum magnitude multiplied by the wave number of the bin.
		 * It could be considered the energy derivative, a high pass filter,
		 * which gives higher values for high frequency content.
		 *
		 * \f[
		 * HighFrequencyContent = \sum_{i=0}^{nBins} i magnitude_i^2
		 * \f]
		 */
		DYN_ATTRIBUTE (18,public, TData, HighFrequencyContent);
		DYN_ATTRIBUTE (19,public, Array<SpectralDescriptors>, BandDescriptors);

		DYN_ATTRIBUTE (20,public, Array<TData>,PCP);

	public:
		SpectralDescriptors(Spectrum* pSpectrum);
		SpectralDescriptors(TData initVal);

		const Spectrum* GetpSpectrum() const;
		void SetpSpectrum(Spectrum* pSpectrum);
		void ConcreteCompute();

//XA_C2S	private:
		void DefaultInit();
		void CopyInit(const SpectralDescriptors & copied);
		
		TData ComputeSpectralFlatness();
		TData ComputeHighFrequencyContent();
		TData ComputeMaxMagFreq();
		TData ComputeLowFreqEnergyRelation();
		TData ComputeRolloff();
		TData ComputeSpread();
		TData ComputeSlope();

	private:
		const Spectrum* mpSpectrum;
		/** Conversion from index to frequency, needed for many descriptors */
		double mDeltaFreq; // double because a lot of computations depends on its precission
};

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

template<>
inline SpectralDescriptors CLAM_max (const SpectralDescriptors& a,const SpectralDescriptors& b)
{
	SpectralDescriptors  tmpD(a);
	if(a.HasMean() && b.HasMean() )
	{
		if(b.GetMean()>a.GetMean())
			tmpD.SetMean(b.GetMean());
	}
	if(a.HasGeometricMean() && b.HasGeometricMean() )
	{
		if(b.GetGeometricMean()>a.GetGeometricMean())
			tmpD.SetGeometricMean(b.GetGeometricMean());
	}
	if(a.HasEnergy() && b.HasEnergy() )
	{
		if(b.GetEnergy()>a.GetEnergy())
			tmpD.SetEnergy(b.GetEnergy());
	}
	if(a.HasCentroid() && b.HasCentroid() )
	{
		if(b.GetCentroid()>a.GetCentroid())
			tmpD.SetCentroid(b.GetCentroid());
	}
	if(a.HasMoment2() && b.HasMoment2() )
	{
		if(b.GetMoment2()>a.GetMoment2())
			tmpD.SetMoment2(b.GetMoment2());
	}
	if(a.HasMoment3() && b.HasMoment3() )
	{
		if(b.GetMoment3()>a.GetMoment3())
			tmpD.SetMoment3(b.GetMoment3());
	}
	if(a.HasMoment4() && b.HasMoment4() )
	{
		if(b.GetMoment4()>a.GetMoment4())
			tmpD.SetMoment4(b.GetMoment4());
	}
	if(a.HasMoment5() && b.HasMoment5())
	{
		if(b.GetMoment5()>a.GetMoment5())
			tmpD.SetMoment5(b.GetMoment5());
	}
	if(a.HasMoment6() && b.HasMoment6() )
	{
		if(b.GetMoment6()>a.GetMoment6())
			tmpD.SetMoment6(b.GetMoment6());
	}
	if(a.HasFlatness() && b.HasFlatness() )
	{
		if(b.GetFlatness()>a.GetFlatness())
			tmpD.SetFlatness(b.GetFlatness());
	}
	if(a.HasMagnitudeKurtosis() && b.HasMagnitudeKurtosis() )
	{
		if(b.GetMagnitudeKurtosis()>a.GetMagnitudeKurtosis())
			tmpD.SetMagnitudeKurtosis(b.GetMagnitudeKurtosis());
	}
	if(a.HasMaxMagFreq() && b.HasMaxMagFreq() )
	{
		if(b.GetMaxMagFreq()>a.GetMaxMagFreq())
			tmpD.SetMaxMagFreq(b.GetMaxMagFreq());
	}
	if(a.HasLowFreqEnergyRelation() && b.HasLowFreqEnergyRelation() )
	{
		if(b.GetLowFreqEnergyRelation()>a.GetLowFreqEnergyRelation())
			tmpD.SetLowFreqEnergyRelation(b.GetLowFreqEnergyRelation());
	}
	if(a.HasSpread() && b.HasSpread() )
	{
		if(b.GetSpread()>a.GetSpread())
			tmpD.SetSpread(b.GetSpread());
	}
	if(a.HasMagnitudeSkewness() && b.HasMagnitudeSkewness() )
	{
		if(b.GetMagnitudeSkewness()>a.GetMagnitudeSkewness())
			tmpD.SetMagnitudeSkewness(b.GetMagnitudeSkewness());
	}
	if(a.HasRolloff() && b.HasRolloff() )
	{
		if(b.GetRolloff()>a.GetRolloff())
			tmpD.SetRolloff(b.GetRolloff());
	}
	if(a.HasSlope() && b.HasSlope() )
	{
		if(b.GetSlope()>a.GetSlope())
			tmpD.SetSlope(b.GetSlope());
	}
	if(a.HasHighFrequencyContent() && b.HasHighFrequencyContent() )
	{
		if(b.GetHighFrequencyContent()>a.GetHighFrequencyContent())
			tmpD.SetHighFrequencyContent(b.GetHighFrequencyContent());
	}
	if(a.HasBandDescriptors() && b.HasBandDescriptors() )
	{
		/* Array does not have these operators
		
		  if(b.GetBandDescriptors()>a.GetBandDescriptors())
			tmpD.SetBandDescriptors(b.GetBandDescriptors() );*/
	}
	if(a.HasMFCC() && b.HasMFCC() )
	{
		/* Array does not have these operators
		if(b.GetMFCC()>a.GetMFCC())
			tmpD.SetMFCC(b.GetMFCC());*/
	}
	return tmpD;

}

template<>
inline SpectralDescriptors CLAM_min (const SpectralDescriptors& a,const SpectralDescriptors& b)
{
	SpectralDescriptors  tmpD(a);
	if(a.HasMean() && b.HasMean() )
	{
		if(b.GetMean()<a.GetMean())
			tmpD.SetMean(b.GetMean());
	}
	if(a.HasGeometricMean() && b.HasGeometricMean() )
	{
		if(b.GetGeometricMean()<a.GetGeometricMean())
			tmpD.SetGeometricMean(b.GetGeometricMean());
	}
	if(a.HasEnergy() && b.HasEnergy() )
	{
		if(b.GetEnergy()<a.GetEnergy())
			tmpD.SetEnergy(b.GetEnergy());
	}
	if(a.HasCentroid() && b.HasCentroid() )
	{
		if(b.GetCentroid()<a.GetCentroid())
			tmpD.SetCentroid(b.GetCentroid());
	}
	if(a.HasMoment2() && b.HasMoment2() )
	{
		if(b.GetMoment2()<a.GetMoment2())
			tmpD.SetMoment2(b.GetMoment2());
	}
	if(a.HasMoment3() && b.HasMoment3() )
	{
		if(b.GetMoment3()<a.GetMoment3())
			tmpD.SetMoment3(b.GetMoment3());
	}
	if(a.HasMoment4() && b.HasMoment4() )
	{
		if(b.GetMoment4()<a.GetMoment4())
			tmpD.SetMoment4(b.GetMoment4());
	}
	if(a.HasMoment5() && b.HasMoment5())
	{
		if(b.GetMoment5()<a.GetMoment5())
			tmpD.SetMoment5(b.GetMoment5());
	}
	if(a.HasMoment6() && b.HasMoment6() )
	{
		if(b.GetMoment6()<a.GetMoment6())
			tmpD.SetMoment6(b.GetMoment6());
	}
	if(a.HasFlatness() && b.HasFlatness() )
	{
		if(b.GetFlatness()<a.GetFlatness())
			tmpD.SetFlatness(b.GetFlatness());
	}
	if(a.HasMagnitudeKurtosis() && b.HasMagnitudeKurtosis() )
	{
		if(b.GetMagnitudeKurtosis()<a.GetMagnitudeKurtosis())
			tmpD.SetMagnitudeKurtosis(b.GetMagnitudeKurtosis());
	}
	if(a.HasMaxMagFreq() && b.HasMaxMagFreq() )
	{
		if(b.GetMaxMagFreq()<a.GetMaxMagFreq())
			tmpD.SetMaxMagFreq(b.GetMaxMagFreq());
	}
	if(a.HasLowFreqEnergyRelation() && b.HasLowFreqEnergyRelation() )
	{
		if(b.GetLowFreqEnergyRelation()<a.GetLowFreqEnergyRelation())
			tmpD.SetLowFreqEnergyRelation(b.GetLowFreqEnergyRelation());
	}
	if(a.HasSpread() && b.HasSpread() )
	{
		if(b.GetSpread()<a.GetSpread())
			tmpD.SetSpread(b.GetSpread());
	}
	if(a.HasMagnitudeSkewness() && b.HasMagnitudeSkewness() )
	{
		if(b.GetMagnitudeSkewness()<a.GetMagnitudeSkewness())
			tmpD.SetMagnitudeSkewness(b.GetMagnitudeSkewness());
	}
	if(a.HasRolloff() && b.HasRolloff() )
	{
		if(b.GetRolloff()<a.GetRolloff())
			tmpD.SetRolloff(b.GetRolloff());
	}
	if(a.HasSlope() && b.HasSlope() )
	{
		if(b.GetSlope()<a.GetSlope())
			tmpD.SetSlope(b.GetSlope());
	}
	if(a.HasHighFrequencyContent() && b.HasHighFrequencyContent() )
	{
		if(b.GetHighFrequencyContent()<a.GetHighFrequencyContent())
			tmpD.SetHighFrequencyContent(b.GetHighFrequencyContent());
	}
	if(a.HasBandDescriptors() && b.HasBandDescriptors() )
	{
		/* Array does not have these operators
		if(b.GetBandDescriptors()<a.GetBandDescriptors())
			tmpD.SetBandDescriptors(b.GetBandDescriptors() );*/
	}
	if(a.HasMFCC() && b.HasMFCC() )
	{
		/* Array does not have these operators
		if(b.GetMFCC()<a.GetMFCC())
			tmpD.SetMFCC(b.GetMFCC());*/
	}

	return tmpD;

}

}

#endif /* __SpectralDescriptors_H__ */