CLAM-Development
1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
Processing
Analysis
SinTracking.hxx
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3
* UNIVERSITAT POMPEU FABRA
4
*
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*
20
*/
21
22
#ifndef _SinTracking__
23
#define _SinTracking__
24
#include <typeinfo>
25
26
#include "
DataTypes.hxx
"
27
#include "
Processing.hxx
"
28
#include "
SpectralPeakArray.hxx
"
29
#include "
Array.hxx
"
30
#include "
SinTrackingConfig.hxx
"
31
#include "
InPort.hxx
"
32
#include "
OutPort.hxx
"
33
#include "
InControl.hxx
"
34
35
namespace
CLAM {
36
37
class
Fundamental;
38
class
SpectralPeak;
39
class
ProcessingConfig;
40
44
/* SinTrackingConfig moved to SinTrackingConfig.hxx */
45
46
typedef
struct
SGuide
47
{
48
TData
freq
;
49
TData
mag
;
50
int
trackId
;
51
bool
isDead
;
//true if track died in previous step, false else
52
}
TGuide
;
53
54
62
class
SinTracking
:
public
Processing
63
{
64
mutable
SinTrackingConfig
mConfig;
65
66
const
char
*GetClassName()
const
{
return
"SinTracking"
;}
67
71
virtual
bool
ConcreteConfigure(
const
ProcessingConfig
&);
72
73
InPort<SpectralPeakArray>
mInput;
74
OutPort<SpectralPeakArray>
mOutput;
75
FloatInControl
mFundFreqValue;
76
77
public
:
78
79
SinTracking
();
80
SinTracking
(
const
SinTrackingConfig
&c);
81
~SinTracking
();
82
83
//Configuration accessor
84
const
ProcessingConfig
&
GetConfig
()
const
{
return
mConfig;};
85
86
//Peak Continuation for one frame
87
bool
Do
(
const
SpectralPeakArray
& iPeakArray,
SpectralPeakArray
& oPeakArray);
88
bool
Do
(
void
);
89
90
int
GetnTracks
()
const
{
return
mNextTrackId;};
91
92
private
:
93
94
bool
DoHarmonic(
const
SpectralPeakArray
& in,
SpectralPeakArray
& out,
TData
funFreq);
95
bool
DoInharmonic(
const
SpectralPeakArray
& in,
SpectralPeakArray
& out);
96
97
99
void
Initialization(
const
SpectralPeakArray
& iPeakArray,
SpectralPeakArray
& oPeakArray);
100
101
void
InitHarmonicTracks(
SpectralPeakArray
& peaks,
TData
funFreq);
102
103
106
void
AddNewTrack(
int
trackPosition,
const
SpectralPeak
& currentPeak,
SpectralPeakArray
& oPeakArray)
const
;
107
109
void
Tracking(
const
SpectralPeakArray
& iPeakArray,
SpectralPeakArray
& oPeakArray,
TIndex
processedPeakPos)
const
;
110
111
void
HarmonicTracking(
const
SpectralPeakArray
& in,
SpectralPeakArray
& out,
TData
funFreq);
112
114
inline
bool
IsPeakAssigned(
const
SpectralPeakArray
&peakArray,
TIndex
peakIndex)
const
;
115
117
inline
bool
IsCandidate(
const
SpectralPeak
& fixedPeak,
const
SpectralPeak
& candidate)
const
;
118
120
inline
bool
ThereIsCandidate(
TData
currentFramePeakFreq,
121
const
SpectralPeakArray
& iPeakArray,
SpectralPeakArray
& oPeakArray)
const
;
122
124
inline
TIndex
GetCandidate(
TData
currentFramePeakFreq,
125
const
SpectralPeakArray
& nextFramePeakArray,
TData
& distance)
const
;
126
128
inline
bool
IsBestCandidate(
TData
candidateFreq,
TData
currentFreq)
const
;
129
130
133
inline
TIndex
GetFirstNonAssignedPeakPos(
const
SpectralPeakArray
& framePeakArray,
TIndex
beginAt)
const
;
134
136
inline
void
Match(
TIndex
trackId,
TIndex
peakIndex,
const
SpectralPeak
& currentPeak,
SpectralPeakArray
& oPeakArray)
const
;
137
140
inline
void
KillTrack(
int
trackPosition)
const
;
141
142
void
KillAll();
143
144
145
148
void
CheckForNewBornTracks(
const
SpectralPeakArray
& iPeakArray,
149
SpectralPeakArray
& oPeakArray)
const
;
150
153
TIndex
GetMatchedPeak(
const
SpectralPeakArray
&iPeakArray,
TIndex
peakIndex)
const
;
154
158
TIndex
GetFirstNonMatchedPeakPos(
const
SpectralPeakArray
& iPeakArray,
TIndex
beginAt)
const
;
159
160
161
162
//Member variables
163
TData
mThreshold;
164
mutable
bool
mInitialized;
165
SpectralPeakArray
mPreviousPeakArray;
166
mutable
Array<TGuide>
mGuideArray;
167
int
mnMaxSines;
168
mutable
int
mnActiveGuides;
169
mutable
int
mNextTrackId;
170
bool
mHarmonic;
//TODO: this should be a runtime modificable control
171
172
bool
mLastHarmonic;
173
174
};
175
176
};
//namespace
177
178
#endif
179
Generated by
1.8.1