29 |
|
|
30 |
|
|
31 |
namespace LinuxSampler { |
namespace LinuxSampler { |
32 |
|
|
33 |
|
template<typename T> |
34 |
|
class FixedArray { |
35 |
|
public: |
36 |
|
FixedArray(int capacity) { |
37 |
|
iSize = 0; |
38 |
|
iCapacity = capacity; |
39 |
|
pData = new T[iCapacity]; |
40 |
|
} |
41 |
|
|
42 |
|
~FixedArray() { |
43 |
|
delete pData; |
44 |
|
pData = NULL; |
45 |
|
} |
46 |
|
|
47 |
|
inline int size() { return iSize; } |
48 |
|
inline int capacity() { return iCapacity; } |
49 |
|
|
50 |
|
void add(T element) { |
51 |
|
if (iSize >= iCapacity) throw Exception("Array out of bounds"); |
52 |
|
pData[iSize++] = element; |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
T increment() { |
57 |
|
if (iSize >= iCapacity) throw Exception("Array out of bounds"); |
58 |
|
return pData[iSize++]; |
59 |
|
} |
60 |
|
|
61 |
|
void clear() { iSize = 0; } |
62 |
|
|
63 |
|
inline T& operator[](int idx) { |
64 |
|
return pData[idx]; |
65 |
|
} |
66 |
|
|
67 |
|
private: |
68 |
|
T* pData; |
69 |
|
int iSize; |
70 |
|
int iCapacity; |
71 |
|
}; |
72 |
|
|
73 |
class SignalUnitRack { |
class SignalUnitRack { |
74 |
protected: |
protected: |
75 |
uint CurrentStep; // The current time step |
uint CurrentStep; // The current time step |
76 |
|
|
77 |
public: |
public: |
78 |
ArrayList<SignalUnit*> Units; // A list of all signal units in this rack |
FixedArray<SignalUnit*> Units; // A list of all signal units in this rack |
79 |
|
|
80 |
SignalUnitRack(): CurrentStep(0) { } |
/** |
81 |
|
* @param maxUnitCount We are using fixed size array because of the real-time safe requirements. |
82 |
|
*/ |
83 |
|
SignalUnitRack(int maxUnitCount): CurrentStep(0), Units(maxUnitCount) { } |
84 |
|
|
85 |
uint GetCurrentStep() { return CurrentStep; } |
uint GetCurrentStep() { return CurrentStep; } |
86 |
|
|
87 |
virtual EndpointSignalUnit* GetEndpointUnit() = 0; |
virtual EndpointSignalUnit* GetEndpointUnit() = 0; |
88 |
|
|
89 |
|
virtual void EnterFadeOutStage() = 0; |
90 |
|
|
91 |
/** |
/** |
92 |
* Will be called to increment the time with one sample point. |
* Will be called to increment the time with one sample point. |
93 |
* Each unit should recalculate its current level on every call of this function. |
* Each unit should recalculate its current level on every call of this function. |