/[svn]/linuxsampler/trunk/src/effects/Effect.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/effects/Effect.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2412 - (hide annotations) (download) (as text)
Mon Feb 4 21:52:56 2013 UTC (11 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5598 byte(s)
* Bugfix: update effects on sample rate & period size changes.
* JACK: allow to register jackd shutdown listeners.

1 schoenebeck 1722 /***************************************************************************
2     * *
3 schoenebeck 2412 * Copyright (C) 2008, 2010, 2013 Christian Schoenebeck *
4 schoenebeck 1722 * *
5     * This program is free software; you can redistribute it and/or modify *
6     * it under the terms of the GNU General Public License as published by *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This program is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this program; if not, write to the Free Software *
17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18     * MA 02111-1307 USA *
19     ***************************************************************************/
20    
21     #ifndef LS_EFFECT_H
22     #define LS_EFFECT_H
23    
24     #include <vector>
25     #include "../drivers/audio/AudioChannel.h"
26 schoenebeck 2124 #include "../common/Exception.h"
27     #include "EffectControl.h"
28 schoenebeck 1722
29     namespace LinuxSampler {
30    
31     // just symbol prototyping
32     class AudioOutputDevice;
33 schoenebeck 2135 class EffectInfo;
34 schoenebeck 1722
35     /**
36     * Abstract base class for sampler internal effects.
37     */
38     class Effect {
39     public:
40     /////////////////////////////////////////////////////////////////
41     // abstract methods
42     // (these have to be implemented by the descendant)
43    
44     /**
45 schoenebeck 2135 * General information about this effect type, that is independent of this
46     * instance of this effect type.
47     *
48     * @returns general effect information
49     */
50     virtual EffectInfo* GetEffectInfo() = 0;
51    
52     /**
53 schoenebeck 1722 * Use the input audio signal given with @a ppInputChannels, render the
54     * effect and mix the result into the effect's output channels.
55     *
56 schoenebeck 2124 * @param Samples - amount of sample points to process
57 schoenebeck 1722 */
58     virtual void RenderAudio(uint Samples) = 0;
59    
60     /**
61     * Will be called by the sampler before using the effect the first time.
62     * This method can be implemented by the effect to adjust itself to the
63     * requirements given by the audio output device.
64     *
65     * This is the perfect place to create the required audio input and
66     * output channels! ;-)
67     *
68 schoenebeck 2412 * CAUTION: InitEffect() might be called several times! For example it
69     * will be called again if some audio context parameter of the audio
70     * output driver in use, has been changed, like particulary sample rate
71     * changes and max. samples per cycle (period size) changes. So take
72     * care not to create memory leaks due to this circumstance.
73     *
74 schoenebeck 1722 * @param pDevice - audio output device which is going to play the signal
75 schoenebeck 2124 * @throws Exception - if effect could not be initialized successfully
76 schoenebeck 1722 */
77 schoenebeck 2124 virtual void InitEffect(AudioOutputDevice* pDevice) throw (Exception);
78 schoenebeck 1722
79     /**
80 schoenebeck 2135 * Constructor, initializes variables.
81     */
82     Effect();
83    
84     /**
85 schoenebeck 1722 * Destructor, deletes all audio input and output channels.
86     */
87     virtual ~Effect();
88    
89    
90    
91     /////////////////////////////////////////////////////////////////
92     // normal methods
93     // (usually not to be overriden by descendant)
94    
95     /**
96     * Returns audio input channel with index \a ChannelIndex or NULL if
97     * index out of bounds.
98     */
99     AudioChannel* InputChannel(uint ChannelIndex) const;
100    
101     /**
102     * Returns the amount of audio input channels the effect is currently
103     * providing.
104     */
105     uint InputChannelCount() const;
106    
107     /**
108     * Returns audio output channel with index \a ChannelIndex or NULL if
109     * index out of bounds.
110     */
111     AudioChannel* OutputChannel(uint ChannelIndex) const;
112    
113     /**
114     * Returns the amount of audio output channels the effect is currently
115     * providing.
116     */
117     uint OutputChannelCount() const;
118    
119 schoenebeck 2124 /**
120     * Returns effect parameter with index \a ControlIndex or NULL if index
121     * out of bounds.
122     */
123     EffectControl* InputControl(uint ControlIndex) const;
124    
125     /**
126     * Returns the amount of effect parameters the effect provides.
127     */
128     uint InputControlCount() const;
129    
130 schoenebeck 2135 /**
131     * Shall be called to set the object that uses this effect, e.g. to
132     * determine whether an effect is currently in use.
133     */
134     void SetParent(void* pParent);
135    
136     /**
137     * Returns object which currently uses this effect.
138     */
139     void* Parent() const;
140    
141     /**
142     * Sets the unique numerical ID of this effect within the sampler instance.
143     * This method is usually only called by the EffectFactory class.
144     */
145     void SetId(int id);
146    
147     /**
148     * Returns unique numerical ID of this effect within the sampler instance,
149     * as previously set by SetId() .
150     */
151     int ID() const;
152    
153 schoenebeck 1722 protected:
154     std::vector<AudioChannel*> vInputChannels;
155     std::vector<AudioChannel*> vOutputChannels;
156 schoenebeck 2124 std::vector<EffectControl*> vInputControls;
157     std::vector<EffectControl*> vOutputControls; ///< yet unused
158 schoenebeck 2135 void* pParent;
159     int iID;
160 schoenebeck 1722 };
161    
162     } // namespace LinuxSampler
163    
164     #endif // LS_EFFECT_H

  ViewVC Help
Powered by ViewVC