Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/engine/engineclipping.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           engineclipping.cpp  -  description
00003                              -------------------
00004     copyright            : (C) 2002 by Tue and Ken Haste Andersen
00005     email                :
00006 ***************************************************************************/
00007 
00008 /***************************************************************************
00009 *                                                                         *
00010 *   This program is free software; you can redistribute it and/or modify  *
00011 *   it under the terms of the GNU General Public License as published by  *
00012 *   the Free Software Foundation; either version 2 of the License, or     *
00013 *   (at your option) any later version.                                   *
00014 *                                                                         *
00015 ***************************************************************************/
00016 
00017 #include "engineclipping.h"
00018 #include "controlpotmeter.h"
00019 #include "sampleutil.h"
00020 
00021 EngineClipping::EngineClipping(const char * group)
00022 {
00023     //Used controlpotmeter as the example used it :/ perhaps someone with more knowledge could use something more suitable...
00024     m_ctrlClipping = new ControlPotmeter(ConfigKey(group, "PeakIndicator"), 0., 1.);
00025     m_ctrlClipping->set(0);
00026 }
00027 
00028 EngineClipping::~EngineClipping()
00029 {
00030     delete m_ctrlClipping;
00031 }
00032 
00033 void EngineClipping::process(const CSAMPLE * pIn, const CSAMPLE * pOut, const int iBufferSize)
00034 {
00035     static const FLOAT_TYPE kfMaxAmp = 32767.;
00036     // static const FLOAT_TYPE kfClip = 0.8*kfMaxAmp;
00037 
00038     CSAMPLE * pOutput = (CSAMPLE *)pOut;
00039     // SampleUtil clamps the buffer and if pIn and pOut are aliased will not copy.
00040     clipped = SampleUtil::copyClampBuffer(kfMaxAmp, -kfMaxAmp,
00041                                           pOutput, pIn, iBufferSize);
00042 
00043     if (clipped)
00044         m_ctrlClipping->set(1.);
00045     else
00046         m_ctrlClipping->set(0);
00047 }
00048 
00049 //returns true if the last buffer processed clipped
00050 bool EngineClipping::hasClipped()
00051 {
00052     return clipped;
00053 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines