File: trackdata_op.cpp

package info (click to toggle)
libofa 0.9.3-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,052 kB
  • ctags: 535
  • sloc: cpp: 24,480; sh: 8,366; makefile: 46; ansic: 14
file content (93 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download | duplicates (8)
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
/* ------------------------------------------------------------------

   libofa -- the Open Fingerprint Architecture library

   Copyright (C) 2006 MusicIP Corporation
   All rights reserved.

-------------------------------------------------------------------*/
// FILE: "trackdata_op.cpp"
// MODULE: Implementation for class TrackData
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06

#include "trackdata_op.h"

#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define min(a,b)    (((a) < (b)) ? (a) : (b))


// Constructor

TrackData_op::TrackData_op() { /* empty */ }

TrackData_op::TrackData_op(float aTime, float frequency, float amplitude, float frDur) 
{
	StartTime = aTime;
	EndTime = 0.0f;
	Pitch = AvgPitch = EndPitch = frequency;
	Amplitude = AvgAmplitude = amplitude;
	FrameDur = frDur;
	previous = 0;
	next = 0;
	higher = 0;
	InTrack = false;
}

TrackData_op::~TrackData_op() 
{
	previous = next = higher = 0;
}

float 
TrackData_op::getDuration() 
{
	if (isOrphan())
		return FrameDur;
	if ( ! (isHead()))
		return (StartTime);
	if (EndTime == 0.0f) {
		TrackData_op* trk = getTail();
		EndTime = trk->getTime() + FrameDur; 
	}
	return (EndTime - StartTime);
}


// Extend the receiver by the argument

void 
TrackData_op::linkTo(TrackData_op* tp) 
{
	tp->linkPrevious(this);
	linkNext(tp);
	InTrack = true;
	tp->SetInTrack(true);
}


// Walk the links back to the head of this track

TrackData_op* 
TrackData_op::getHead() 
{
	TrackData_op* trk;
	trk = this;
	while (trk->getPrev() != 0)
		trk = trk->getPrev();
	return trk;
}


// Walk the links forward to the tail of this track

TrackData_op* 
TrackData_op::getTail() 
{
	TrackData_op* trk;
	trk = this;
	while (trk->getNext() != 0)
		trk = trk->getNext();
	return trk;
}