00001 /* 00002 * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #ifndef _AudioMixer_hxx__ 00023 #define _AudioMixer_hxx__ 00024 00025 #include "Processing.hxx" 00026 #include "AudioOutPort.hxx" 00027 #include "AudioInPort.hxx" 00028 #include "Audio.hxx" 00029 #include "InControl.hxx" 00030 00031 namespace CLAM 00032 { 00033 00034 class AudioMixerConfig: public ProcessingConfig 00035 { 00036 public: 00037 DYNAMIC_TYPE_USING_INTERFACE (AudioMixerConfig, 2, ProcessingConfig); 00038 DYN_ATTRIBUTE (0, public, int, NumberOfInPorts); 00039 DYN_ATTRIBUTE (1, public, CLAM::Array<TControlData>, DefaultGains); 00040 00041 protected: 00042 void DefaultInit(void) 00043 { 00044 AddAll(); 00045 UpdateData(); 00046 unsigned int numberOfInPorts=2; 00047 SetNumberOfInPorts(numberOfInPorts); 00048 CLAM::Array<TControlData> gains; 00049 gains.Resize(numberOfInPorts); 00050 gains.SetSize(numberOfInPorts); 00051 for (unsigned portNumber=0;portNumber<numberOfInPorts;portNumber++) 00052 { 00053 gains[portNumber]=1; 00054 } 00055 SetDefaultGains(gains); 00056 } 00057 00058 }; 00059 00060 class AudioMixer: public Processing 00061 { 00062 private: 00063 AudioMixerConfig mConfig; 00064 00065 std::vector< AudioInPort* > mInputPorts; 00066 AudioOutPort mOutputPort; 00067 std::vector< FloatInControl* > mInputControls; 00068 00069 void RemovePortsAndControls(); 00070 void CreatePortsAndControls(); 00071 00072 public: 00073 bool ConcreteConfigure(const ProcessingConfig& c); 00074 AudioMixer(); 00075 virtual ~AudioMixer() 00076 { 00077 RemovePortsAndControls(); 00078 } 00079 bool ModifiesPortsAndControlsAtConfiguration() 00080 { 00081 return true; 00082 } 00083 00084 const char * GetClassName() const {return "AudioMixer";} 00085 const ProcessingConfig &GetConfig() const { return mConfig;} 00086 bool Do(); 00087 }; 00088 00089 } // namespace CLAM 00090 00091 #endif // __AudioMixer_hxx__ 00092