29 |
|
|
30 |
|
|
31 |
namespace LinuxSampler { |
namespace LinuxSampler { |
32 |
|
|
33 |
class SignalUnitRack { |
class SignalUnitRack { |
34 |
protected: |
protected: |
35 |
uint CurrentStep; // The current time step |
uint CurrentStep; // The current time step |
36 |
|
|
37 |
public: |
public: |
38 |
SignalUnitRack(): CurrentStep(0) { } |
FixedArray<SignalUnit*> Units; // A list of all signal units in this rack |
|
uint GetCurrentStep() { return CurrentStep; } |
|
39 |
|
|
40 |
/** |
/** |
41 |
* Will be called to increment the time with one sample point. |
* @param maxUnitCount We are using fixed size array because of the real-time safe requirements. |
|
* Each unit should recalculate its current level on every call of this function. |
|
|
*/ |
|
|
virtual void Increment() = 0; |
|
|
|
|
|
virtual void ProcessCCEvent(RTList<Event>::Iterator& itEvent) = 0; |
|
|
|
|
|
/** Initializes and triggers the rack. */ |
|
|
virtual void Trigger() = 0; |
|
|
|
|
|
/** |
|
|
* When the rack belongs to a voice, this method is |
|
|
* called when the voice enter the release stage. |
|
|
*/ |
|
|
virtual void EnterReleaseStage() = 0; |
|
|
|
|
|
/** |
|
|
* When the rack belongs to a voice, this method is |
|
|
* called when the voice is of type which ignore note off. |
|
42 |
*/ |
*/ |
43 |
virtual void CancelRelease() = 0; |
SignalUnitRack(int maxUnitCount): CurrentStep(0), Units(maxUnitCount) { } |
44 |
|
|
45 |
virtual EndpointSignalUnit* GetEndpointUnit() = 0; |
uint GetCurrentStep() { return CurrentStep; } |
|
}; |
|
|
|
|
|
template <class O /* The signal unit rack's owner */> |
|
|
class SignalUnitRackBase: public SignalUnitRack { |
|
|
protected: |
|
|
O* pOwner; // The owner to which this rack belongs. |
|
46 |
|
|
47 |
public: |
virtual EndpointSignalUnit* GetEndpointUnit() = 0; |
|
ArrayList<SignalUnitBase<O>*> Units; // A list of all signal units in this rack |
|
48 |
|
|
49 |
SignalUnitRackBase(O* Owner) { |
virtual void EnterFadeOutStage() = 0; |
|
pOwner = Owner; |
|
|
} |
|
50 |
|
|
51 |
/** |
/** |
52 |
* Will be called to increment the time with one sample point. |
* Will be called to increment the time with one sample point. |
71 |
virtual void Trigger() { |
virtual void Trigger() { |
72 |
CurrentStep = 0; |
CurrentStep = 0; |
73 |
for (int i = 0; i < Units.size(); i++) { |
for (int i = 0; i < Units.size(); i++) { |
|
Units[i]->SetOwner(pOwner); |
|
74 |
Units[i]->Trigger(); |
Units[i]->Trigger(); |
75 |
} |
} |
76 |
} |
} |
77 |
|
|
78 |
|
/** |
79 |
|
* When the rack belongs to a voice, this method is |
80 |
|
* called when the voice enter the release stage. |
81 |
|
*/ |
82 |
virtual void EnterReleaseStage() { |
virtual void EnterReleaseStage() { |
83 |
for (int i = 0; i < Units.size(); i++) { |
for (int i = 0; i < Units.size(); i++) { |
84 |
Units[i]->EnterReleaseStage(); |
Units[i]->EnterReleaseStage(); |
85 |
} |
} |
86 |
} |
} |
87 |
|
|
88 |
|
/** |
89 |
|
* When the rack belongs to a voice, this method is |
90 |
|
* called when the voice is of type which ignore note off. |
91 |
|
*/ |
92 |
virtual void CancelRelease() { |
virtual void CancelRelease() { |
93 |
for (int i = 0; i < Units.size(); i++) { |
for (int i = 0; i < Units.size(); i++) { |
94 |
Units[i]->CancelRelease(); |
Units[i]->CancelRelease(); |