-
Notifications
You must be signed in to change notification settings - Fork 1
/
AutoInfo.cpp
94 lines (86 loc) · 1.74 KB
/
AutoInfo.cpp
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
// Copyleft 2004 Chris Korda
// 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 any later version.
/*
chris korda
revision history:
rev date comments
00 12dec03 initial version
01 11jan04 add HasSelection, ClearSel
02 17jan04 increase default time to five seconds
03 29jan04 add WithinSelection
04 22mar04 in SetCourse, handle no selection
05 31dec04 make waveform variable
automation information package; atomic data only
*/
#include "stdafx.h"
#include "AutoInfo.h"
CAutoInfo::CAutoInfo() :
m_Pos(0),
m_StartPos(-1),
m_EndPos(-1),
m_Time(5000),
m_TimeUnit(0),
m_Reverse(0),
m_Transport(STOP),
m_Loop(0),
m_Waveform(TRIANGLE)
{
}
void CAutoInfo::Serialize(CArchive& ar, int Version)
{
if (ar.IsStoring()) {
ar
<< m_Pos
<< m_StartPos
<< m_EndPos
<< m_Time
<< m_TimeUnit
<< m_Reverse
<< m_Transport
<< m_Loop
<< m_Waveform
;
} else {
ar
>> m_Pos
>> m_StartPos
>> m_EndPos
>> m_Time
>> m_TimeUnit
>> m_Reverse
>> m_Transport
>> m_Loop
>> m_Waveform
;
}
}
void CAutoInfo::SetCourse()
{
// if no selection, use full range
float Start = GetStart();
float End = GetEnd();
switch (m_Waveform) {
case RAMP_UP:
m_Pos = Start;
m_Reverse = 0;
break;
case RAMP_DOWN:
m_Pos = End;
m_Reverse = 1;
break;
default:
// clamp position within limits
if (m_Pos < Start)
m_Pos = Start;
else if (m_Pos > End)
m_Pos = End;
// head for whichever limit is further away
m_Reverse = (End - m_Pos < m_Pos - Start);
}
}
void CAutoInfo::ClearSel()
{
m_EndPos = m_StartPos = -1;
}