Mercurial > hg > beatroot-vamp
comparison Agent.h @ 8:f04f87b5e643
Add agent list class, and continue plodding through
author | Chris Cannam |
---|---|
date | Fri, 30 Sep 2011 11:37:25 +0100 |
parents | 02d388f98c23 |
children | 4f6626f9ffac |
comparison
equal
deleted
inserted
replaced
7:3c11becfc81a | 8:f04f87b5e643 |
---|---|
16 #ifndef _AGENT_H_ | 16 #ifndef _AGENT_H_ |
17 #define _AGENT_H_ | 17 #define _AGENT_H_ |
18 | 18 |
19 #include "Event.h" | 19 #include "Event.h" |
20 | 20 |
21 class AgentList; | |
22 | |
21 /** Agent is the central class for beat tracking. | 23 /** Agent is the central class for beat tracking. |
22 * Each Agent object has a tempo hypothesis, a history of tracked beats, and | 24 * Each Agent object has a tempo hypothesis, a history of tracked beats, and |
23 * a score evaluating the continuity, regularity and salience of its beat track. | 25 * a score evaluating the continuity, regularity and salience of its beat track. |
24 */ | 26 */ |
25 class Agent | 27 class Agent |
26 { | 28 { |
27 public: | 29 public: |
28 | |
29 typedef std::vector<Agent> AgentList; | |
30 | |
31 /** The maximum amount by which a beat can be later than the predicted beat time, | 30 /** The maximum amount by which a beat can be later than the predicted beat time, |
32 * expressed as a fraction of the beat period. */ | 31 * expressed as a fraction of the beat period. */ |
33 static double POST_MARGIN_FACTOR; | 32 static double POST_MARGIN_FACTOR; |
34 | 33 |
35 /** The maximum amount by which a beat can be earlier than the predicted beat time, | 34 /** The maximum amount by which a beat can be earlier than the predicted beat time, |
163 if (value > max) | 162 if (value > max) |
164 return max; | 163 return max; |
165 return value; | 164 return value; |
166 } | 165 } |
167 | 166 |
167 public: | |
168 /** Accept a new Event as a beat time, and update the state of the Agent accordingly. | 168 /** Accept a new Event as a beat time, and update the state of the Agent accordingly. |
169 * @param e The Event which is accepted as being on the beat. | 169 * @param e The Event which is accepted as being on the beat. |
170 * @param err The difference between the predicted and actual beat times. | 170 * @param err The difference between the predicted and actual beat times. |
171 * @param beats The number of beats since the last beat that matched an Event. | 171 * @param beats The number of beats since the last beat that matched an Event. |
172 */ | 172 */ |
196 * 5) The Event is ignored because it is outside the windows around the Agent's predicted beat time. | 196 * 5) The Event is ignored because it is outside the windows around the Agent's predicted beat time. |
197 * @param e The Event to be tested | 197 * @param e The Event to be tested |
198 * @param a The list of all agents, which is updated if a new agent is created. | 198 * @param a The list of all agents, which is updated if a new agent is created. |
199 * @return Indicate whether the given Event was accepted as a beat by this Agent. | 199 * @return Indicate whether the given Event was accepted as a beat by this Agent. |
200 */ | 200 */ |
201 bool considerAsBeat(Event e, const AgentList &a); | 201 bool considerAsBeat(Event e, AgentList &a); |
202 | 202 |
203 /** Interpolates missing beats in the Agent's beat track, starting from the beginning of the piece. */ | 203 /** Interpolates missing beats in the Agent's beat track, starting from the beginning of the piece. */ |
204 void fillBeats() { | 204 void fillBeats() { |
205 fillBeats(-1.0); | 205 fillBeats(-1.0); |
206 } // fillBeats()/0 | 206 } // fillBeats()/0 |
208 /** Interpolates missing beats in the Agent's beat track. | 208 /** Interpolates missing beats in the Agent's beat track. |
209 * @param start Ignore beats earlier than this start time | 209 * @param start Ignore beats earlier than this start time |
210 */ | 210 */ |
211 void fillBeats(double start); | 211 void fillBeats(double start); |
212 | 212 |
213 // for sorting AgentList | |
214 bool operator<(const Agent &a) const { | |
215 return beatInterval < a.beatInterval; | |
216 } | |
217 | |
213 }; // class Agent | 218 }; // class Agent |
214 | 219 |
215 typedef Agent::AgentList AgentList; | |
216 | |
217 #endif | 220 #endif |