/usr/include/CLAM/Fundamental.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 | /*
* 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 _Fundamental_
#define _Fundamental_
#include <typeinfo>
#include "DynamicType.hxx"
#include "Array.hxx"
#include "DataTypes.hxx"
#include "OSDefines.hxx"
#include "Err.hxx"
#include "ProcessingData.hxx"
namespace CLAM
{
////////////////////////////////////////////////////////////////////////////////////////////////
// Class Fundamental:
//
/**
* Class Fundamental, used to manage the bins candidates to be fundamental frequencies, and their errors.
* There are getters and setters, but for efficiency work directly on the buffer.
* @see Frame
*/
class Fundamental : public ProcessingData
{
public:
DYNAMIC_TYPE_USING_INTERFACE (Fundamental, 2, ProcessingData);
/** Array with the candidate frequencies*/
DYN_ATTRIBUTE (0, public, DataArray, CandidatesFreq);
/** Array with the error of candidate frequencies*/
DYN_ATTRIBUTE (1, public, DataArray, CandidatesErr);
protected:
void DefaultInit();
public:
void SetnMaxCandidates(TSize nMaxCandidates)
{
if (HasCandidatesFreq())
GetCandidatesFreq().Resize(nMaxCandidates);
if (HasCandidatesErr())
GetCandidatesErr().Resize(nMaxCandidates);
}
TSize GetnMaxCandidates() const
{
if (HasCandidatesFreq())
return GetCandidatesFreq().AllocatedSize();
if (HasCandidatesErr())
return GetCandidatesErr().AllocatedSize();
return 0;
}
void SetnCandidates(int size)
{
if (HasCandidatesFreq())
GetCandidatesFreq().SetSize(size);
if (HasCandidatesErr())
GetCandidatesErr().SetSize(size);
}
int GetnCandidates() const
{
if (HasCandidatesFreq())
return GetCandidatesFreq().Size();
if (HasCandidatesErr())
return GetCandidatesErr().Size();
return 0;
}
/** Returns the Frequency of a given position in the candidate array
* @param pos Position we want to get frequency, 0 by default
* @return The frequency in the position indicated
*/
TData GetFreq(TIndex pos=0) const;
/** Returns the Error of a given position in the candidate array
* @param pos Position we want to get frequency, 0 by default
* @return The error estimated in this position
*/
TData GetErr(TIndex pos=0) const;
/** Changes the frequency of a candidate at a given index
* @param pos Position to change the frequency
* @param newFreq New value of this position
*/
void SetFreq(TIndex pos,TData newFreq);
/** Changes the error of a candidate at a given index
* @param pos Position to change the error
* @param newFreq New value of this position
*/
void SetErr(TIndex pos,TData newErr);
// Other functionality
/** Adds a candidate, in frequencies array and errors array
* @param freq The frequency value of new candidate, 0 by default
* @param err The estimated error of new candidate, 0 by default
*/
void AddElem (TData freq=0.f, TData err=0.f);
/** Adds a candidate, in frequencies array and errors array, and uses parameter pos to insert it in the arrays.
* @param pos Position where we want to insert the new element
* @param freq The frequency value of new candidate, 0 by default
* @param err The estimated error of new candidate, 0 by default
*/
void InsertElem (TIndex pos, TData freq=0.f, TData err=0.f);
/** Delete an element of both arrays (frequency and error) given its position
* @param Position that we wanto to eliminate
*/
void DeleteElem (TIndex pos);
// Ordering functions
/**
* Sort the arrays by frequency
* @todo It uses a bubble sort, not so efficient
**/
void SortByFrequency();
/**
* Sort the arrays by estimated error
* @todo It uses a bubble sort, not so efficient
**/
void SortByError();
/** Initializes data */
void Init()
{
GetCandidatesFreq().SetSize(0);
GetCandidatesErr().SetSize(0);
SetnCandidates(0);
}
};
} // namespace CLAM
#endif
|