/[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 2295 by iliev, Mon Aug 1 19:08:09 2011 UTC revision 2296 by iliev, Thu Dec 8 20:03:47 2011 UTC
# Line 30  Line 30 
30    
31  namespace LinuxSampler {  namespace LinuxSampler {
32            
33        class EqSupport {
34            private:
35                int  BandCount;
36                int* GainIdxs; ///< the indices of the gain controls
37                int* FreqIdxs; ///< the indices of the frequency controls
38                int* BandwidthIdxs; ///< the indices of the bandwidth controls
39                Effect* pEffect;
40                Effect* pEffect2; // If the effect is mono we'll need two effects
41                
42                inline float check(optional<float> minimum, optional<float> maximum, float value) {
43                    if (minimum) {
44                        float min = *minimum;
45                        if (value < min) value = min;
46                    }
47                    if (maximum) {
48                        float max = *maximum;
49                        if (value > max) value = max;
50                    }
51                    
52                    return value;
53                }
54                
55            public:
56                EqSupport();
57                ~EqSupport();
58    
59                /**
60                 * Searches for know EQ effects and create one if the search succeed.
61                 * If the initialization is successful and EQ effect is selected,
62                 * HasSupport() returns true;
63                 */
64                void Install();
65    
66                void Uninstall();
67    
68                /** Returns true if an EQ is created and is ready for use. */
69                bool HasSupport() { return pEffect != NULL; }
70    
71                /** Reset the gains of all bands to 0dB. */
72                void Reset() {
73                    if (!HasSupport()) return;
74                    for (int i = 0; i < BandCount; i++) {
75                        pEffect->InputControl(GainIdxs[i])->SetValue(0); // 0dB
76                        if (pEffect2 != NULL) pEffect2->InputControl(GainIdxs[i])->SetValue(0); // 0dB
77                    }
78                }
79                
80                void InitEffect(AudioOutputDevice* pDevice) {
81                    if (pEffect != NULL) pEffect->InitEffect(pDevice);
82                    if (pEffect2 != NULL) pEffect2->InitEffect(pDevice);
83                }
84                    
85                int GetBandCount() { return BandCount; }
86    
87                void SetGain(int band, float gain);
88                void SetFreq(int band, float freq);
89                void SetBandwidth(int band, float octaves);
90                
91                AudioChannel* GetInChannelLeft() {
92                    return pEffect->InputChannel(0);
93                }
94                
95                AudioChannel* GetInChannelRight() {
96                    return pEffect2 != NULL ? pEffect2->InputChannel(0) : pEffect->InputChannel(1);
97                }
98                
99                AudioChannel* GetOutChannelLeft() {
100                    return pEffect->OutputChannel(0);
101                }
102                
103                AudioChannel* GetOutChannelRight() {
104                    return pEffect2 != NULL ? pEffect2->OutputChannel(0) : pEffect->OutputChannel(1);
105                }
106                
107                void RenderAudio(uint Samples) {
108                    pEffect->RenderAudio(Samples);
109                    if (pEffect2 != NULL) pEffect2->RenderAudio(Samples);
110                }
111        };
112                
113                
114        
115      class SignalUnitRack {      class SignalUnitRack {
116          protected:          protected:
117              uint CurrentStep; // The current time step              uint CurrentStep; // The current time step
118                bool bHasEq;
119    
120          public:          public:
121              FixedArray<SignalUnit*> Units; // A list of all signal units in this rack              FixedArray<SignalUnit*> Units; // A list of all signal units in this rack
# Line 40  namespace LinuxSampler { Line 123  namespace LinuxSampler {
123              /**              /**
124               * @param maxUnitCount We are using fixed size array because of the real-time safe requirements.               * @param maxUnitCount We are using fixed size array because of the real-time safe requirements.
125               */               */
126              SignalUnitRack(int maxUnitCount): CurrentStep(0), Units(maxUnitCount) { }              SignalUnitRack(int maxUnitCount): CurrentStep(0), bHasEq(false), Units(maxUnitCount) { }
127                            
128              uint GetCurrentStep() { return CurrentStep; }              uint GetCurrentStep() { return CurrentStep; }
129    
# Line 94  namespace LinuxSampler { Line 177  namespace LinuxSampler {
177                      Units[i]->CancelRelease();                      Units[i]->CancelRelease();
178                  }                  }
179              }              }
180                
181                /**
182                 * Determines whether an equalization is applied to the voice.
183                 * Used for optimization.
184                 */
185                bool HasEq() { return bHasEq; }
186                
187                virtual void UpdateEqSettings(EqSupport* pEqSupport) = 0;
188      };      };
189  } // namespace LinuxSampler  } // namespace LinuxSampler
190    

Legend:
Removed from v.2295  
changed lines
  Added in v.2296

  ViewVC Help
Powered by ViewVC