/usr/include/CLAM/SinTracking.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 | /*
* Copyright (c) 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 _SinTracking__
#define _SinTracking__
#include <typeinfo>
#include "DataTypes.hxx"
#include "Processing.hxx"
#include "SpectralPeakArray.hxx"
#include "Array.hxx"
#include "SinTrackingConfig.hxx"
#include "InPort.hxx"
#include "OutPort.hxx"
#include "InControl.hxx"
namespace CLAM {
class Fundamental;
class SpectralPeak;
class ProcessingConfig;
/**
* Config class for the SinTracking Processing.
*/
/* SinTrackingConfig moved to SinTrackingConfig.hxx */
typedef struct SGuide
{
TData freq;
TData mag;
int trackId;
bool isDead;//true if track died in previous step, false else
}TGuide;
/**
* Processing which does sinusoidal peak tracking (or continuation).
* In order for SinTracking to produce meaningful results, it must be called
* repeatively using SpectralPeakArrays generated from the different 'frames'
* of the same input material (ie, if you want to track two different sources,
* you must use two seperate SinTrackings).
*/
class SinTracking: public Processing
{
mutable SinTrackingConfig mConfig;
const char *GetClassName() const {return "SinTracking";}
/**
* Config change method
*/
virtual bool ConcreteConfigure(const ProcessingConfig&);
InPort<SpectralPeakArray> mInput;
OutPort<SpectralPeakArray> mOutput;
FloatInControl mFundFreqValue;
public:
SinTracking();
SinTracking(const SinTrackingConfig &c);
~SinTracking();
//Configuration accessor
const ProcessingConfig &GetConfig() const { return mConfig;};
//Peak Continuation for one frame
bool Do(const SpectralPeakArray& iPeakArray, SpectralPeakArray& oPeakArray);
bool Do(void);
int GetnTracks() const {return mNextTrackId;};
private:
bool DoHarmonic(const SpectralPeakArray& in, SpectralPeakArray& out,TData funFreq);
bool DoInharmonic(const SpectralPeakArray& in, SpectralPeakArray& out);
/** Initialization of the first output peak array=addtrack for each peak */
void Initialization(const SpectralPeakArray& iPeakArray, SpectralPeakArray& oPeakArray);
void InitHarmonicTracks(SpectralPeakArray& peaks, TData funFreq);
/** Adds a non existing track and assigns pPeakArray as its first peak array
* (spectral frame)*/
void AddNewTrack(int trackPosition, const SpectralPeak& currentPeak,SpectralPeakArray& oPeakArray) const;
/** Continue, kill or create track*/
void Tracking(const SpectralPeakArray& iPeakArray, SpectralPeakArray& oPeakArray, TIndex processedPeakPos) const;
void HarmonicTracking(const SpectralPeakArray& in,SpectralPeakArray& out,TData funFreq);
/** True if peakArray[peakIndex] is already assigned to a track*/
inline bool IsPeakAssigned(const SpectralPeakArray &peakArray, TIndex peakIndex) const;
/** True if candidate's distance to fixedPeak is less than threshold*/
inline bool IsCandidate(const SpectralPeak& fixedPeak,const SpectralPeak& candidate) const;
/** True if currentFramePeak has a candidate peak in nextFramePeakArray*/
inline bool ThereIsCandidate(TData currentFramePeakFreq,
const SpectralPeakArray& iPeakArray,SpectralPeakArray& oPeakArray) const;
/** Returns index of candidate and distance to currentFramePeak*/
inline TIndex GetCandidate(TData currentFramePeakFreq,
const SpectralPeakArray& nextFramePeakArray,TData& distance) const;
/** Makes sure that candidate does not match better another peak in currentFramePeakArray*/
inline bool IsBestCandidate(TData candidateFreq, TData currentFreq) const;
/** Returns index of first peak not assigned to a track in framePeakArray, beginning
* at beginAt index*/
inline TIndex GetFirstNonAssignedPeakPos(const SpectralPeakArray& framePeakArray, TIndex beginAt) const;
/** Assigns trackId to nextPeakArray[peakIndex]*/
inline void Match(TIndex trackId, TIndex peakIndex,const SpectralPeak& currentPeak, SpectralPeakArray& oPeakArray) const;
/** Kills track identified by trackId and assigns pPeakArray as its last peak array
* (spectral frame)*/
inline void KillTrack(int trackPosition) const;
void KillAll();
/** Finds newborn tracks in a peak array by finding those peaks not assigned to a
* track and assigning a new track to them.*/
void CheckForNewBornTracks(const SpectralPeakArray& iPeakArray,
SpectralPeakArray& oPeakArray) const;
/** Returns index of frame2PeakArray peak that is assigned to same track as
* frame1PeakArray[peakIndex]*/
TIndex GetMatchedPeak(const SpectralPeakArray &iPeakArray, TIndex peakIndex) const;
/** Returns index of first peak in frame2PeakArray that is not assigned to a track
* existing in frame1PeakArray (belongs to a newborn track or belongs to no track).
* Beginning at beginAt index.*/
TIndex GetFirstNonMatchedPeakPos(const SpectralPeakArray& iPeakArray, TIndex beginAt) const;
//Member variables
TData mThreshold;
mutable bool mInitialized;
SpectralPeakArray mPreviousPeakArray;
mutable Array<TGuide> mGuideArray;
int mnMaxSines;
mutable int mnActiveGuides;
mutable int mNextTrackId;
bool mHarmonic;//TODO: this should be a runtime modificable control
bool mLastHarmonic;
};
};//namespace
#endif
|