Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/engine/enginemaster.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           enginemaster.h  -  description
00003                              -------------------
00004     begin                : Sun Apr 28 2002
00005     copyright            : (C) 2002 by
00006     email                :
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef ENGINEMASTER_H
00019 #define ENGINEMASTER_H
00020 
00021 #include <QMap>
00022 
00023 #include "controlobject.h"
00024 #include "engine/engineobject.h"
00025 #include "engine/enginechannel.h"
00026 #include "soundmanagerutil.h"
00027 #include "recording/recordingmanager.h"
00028 
00029 class EngineWorkerScheduler;
00030 class EngineBuffer;
00031 class EngineChannel;
00032 class EngineClipping;
00033 class EngineFlanger;
00034 #ifdef __LADSPA__
00035 class EngineLADSPA;
00036 #endif
00037 class EngineVuMeter;
00038 class ControlPotmeter;
00039 class ControlPushButton;
00040 class EngineVinylSoundEmu;
00041 class EngineSideChain;
00042 class SyncWorker;
00043 
00044 class EngineMaster : public EngineObject, public AudioSource {
00045     Q_OBJECT
00046   public:
00047     EngineMaster(ConfigObject<ConfigValue>* pConfig,
00048                  const char* pGroup);
00049     virtual ~EngineMaster();
00050 
00051     // Get access to the sample buffers. None of these are thread safe. Only to
00052     // be called by SoundManager.
00053     const CSAMPLE* buffer(AudioOutput output) const;
00054 
00055     void process(const CSAMPLE *, const CSAMPLE *pOut, const int iBufferSize);
00056 
00057     // Add an EngineChannel to the mixing engine. This is not thread safe --
00058     // only call it before the engine has started mixing.
00059     void addChannel(EngineChannel* pChannel);
00060     static inline double gainForOrientation(EngineChannel::ChannelOrientation orientation,
00061                                             double leftGain,
00062                                             double centerGain,
00063                                             double rightGain) {
00064         switch (orientation) {
00065             case EngineChannel::LEFT:
00066                 return leftGain;
00067             case EngineChannel::RIGHT:
00068                 return rightGain;
00069             case EngineChannel::CENTER:
00070             default:
00071                 return centerGain;
00072         }
00073     }
00074 
00075     // These are really only exposed for tests to use.
00076     const CSAMPLE* getMasterBuffer() const;
00077     const CSAMPLE* getHeadphoneBuffer() const;
00078     const CSAMPLE* getDeckBuffer(unsigned int i) const;
00079     const CSAMPLE* getChannelBuffer(QString name) const;
00080 
00081   signals:
00082     void bytesRecorded(int);
00083     void isRecording(bool);
00084 
00085   private:
00086     struct ChannelInfo {
00087         EngineChannel* m_pChannel;
00088         CSAMPLE* m_pBuffer;
00089         ControlObject* m_pVolumeControl;
00090     };
00091 
00092     class GainCalculator {
00093       public:
00094         virtual double getGain(ChannelInfo* pChannelInfo) = 0;
00095     };
00096     class ConstantGainCalculator : public GainCalculator {
00097       public:
00098         inline double getGain(ChannelInfo* pChannelInfo) {
00099             Q_UNUSED(pChannelInfo);
00100             return m_dGain;
00101         }
00102         inline void setGain(double dGain) {
00103             m_dGain = dGain;
00104         }
00105       private:
00106         double m_dGain;
00107     };
00108     class OrientationVolumeGainCalculator : public GainCalculator {
00109       public:
00110         inline double getGain(ChannelInfo* pChannelInfo) {
00111             double channelVolume = pChannelInfo->m_pVolumeControl->get();
00112             double orientationGain = EngineMaster::gainForOrientation(
00113                 pChannelInfo->m_pChannel->getOrientation(),
00114                 m_dLeftGain, m_dCenterGain, m_dRightGain);
00115             return m_dVolume * channelVolume * orientationGain;
00116         }
00117 
00118         inline void setGains(double dVolume, double leftGain, double centerGain, double rightGain) {
00119             m_dVolume = dVolume;
00120             m_dLeftGain = leftGain;
00121             m_dCenterGain = centerGain;
00122             m_dRightGain = rightGain;
00123         }
00124       private:
00125         double m_dVolume, m_dLeftGain, m_dCenterGain, m_dRightGain;
00126     };
00127 
00128     void mixChannels(unsigned int channelBitvector, unsigned int maxChannels,
00129                      CSAMPLE* pOutput, unsigned int iBufferSize, GainCalculator* pGainCalculator);
00130 
00131     QList<ChannelInfo*> m_channels;
00132 
00133     CSAMPLE *m_pMaster, *m_pHead;
00134 
00135     EngineWorkerScheduler *m_pWorkerScheduler;
00136     SyncWorker* m_pSyncWorker;
00137 
00138     ControlObject* m_pMasterVolume;
00139     ControlObject* m_pHeadVolume;
00140     ControlObject* m_pMasterSampleRate;
00141     ControlObject* m_pMasterLatency;
00142     ControlPotmeter* m_pMasterRate;
00143     EngineClipping *clipping, *head_clipping;
00144 
00145 #ifdef __LADSPA__
00146     EngineLADSPA *ladspa;
00147 #endif
00148     EngineVuMeter *vumeter;
00149     EngineSideChain *sidechain;
00150 
00151     ControlPotmeter *crossfader, *head_mix,
00152         *m_pBalance, *xFaderCurve, *xFaderCalibration;
00153 
00154     ConstantGainCalculator m_headphoneGain;
00155     OrientationVolumeGainCalculator m_masterGain;
00156 };
00157 
00158 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines