/[svn]/linuxsampler/trunk/src/engines/common/SignalUnitRack.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/SignalUnitRack.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2217 by iliev, Tue Jul 26 15:51:30 2011 UTC revision 2218 by iliev, Thu Jul 28 08:05:57 2011 UTC
# Line 29  Line 29 
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.

Legend:
Removed from v.2217  
changed lines
  Added in v.2218

  ViewVC Help
Powered by ViewVC