2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
|
|
|
* Copyright (c) 2004-2006
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#if !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qhostaddress.h>
|
|
|
|
#include <qmenu.h>
|
|
|
|
#include <qwhatsthis.h>
|
|
|
|
#include <qtextbrowser.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qdatetime.h>
|
2008-01-26 15:55:38 +01:00
|
|
|
#include <qfile.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include <vector>
|
|
|
|
#include "global.h"
|
2007-09-08 12:45:14 +02:00
|
|
|
using namespace std; // because of the library: "vector"
|
2006-01-28 12:29:22 +01:00
|
|
|
#ifdef _WIN32
|
|
|
|
# include "../windows/moc/aboutdlgbase.h"
|
|
|
|
#else
|
|
|
|
# include "moc/aboutdlgbase.h"
|
2006-12-18 15:39:33 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
|
|
|
#define METER_FLY_BACK 2
|
|
|
|
|
|
|
|
|
|
|
|
/* Global functions ***********************************************************/
|
2007-09-08 12:45:14 +02:00
|
|
|
// converting double to short
|
|
|
|
inline short Double2Short ( const double dInput )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
// lower bound
|
|
|
|
if ( dInput < _MINSHORT )
|
|
|
|
{
|
2006-12-18 15:39:33 +01:00
|
|
|
return _MINSHORT;
|
2007-09-08 12:45:14 +02:00
|
|
|
}
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// upper bound
|
|
|
|
if ( dInput > _MAXSHORT )
|
|
|
|
{
|
2006-12-18 15:39:33 +01:00
|
|
|
return _MAXSHORT;
|
2007-09-08 12:45:14 +02:00
|
|
|
}
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
return (short) dInput;
|
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// debug error handling
|
2008-01-26 15:55:38 +01:00
|
|
|
void DebugError ( const QString& pchErDescr, const QString& pchPar1Descr,
|
|
|
|
const double dPar1, const QString& pchPar2Descr,
|
2007-09-08 12:45:14 +02:00
|
|
|
const double dPar2 );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************\
|
|
|
|
* CVector base class *
|
|
|
|
\******************************************************************************/
|
|
|
|
template<class TData> class CVector : public std::vector<TData>
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CVector() : iVectorSize ( 0 ) { pData = this->begin(); }
|
|
|
|
CVector ( const int iNeSi ) { Init(iNeSi); }
|
|
|
|
CVector ( const int iNeSi, const TData tInVa ) { Init ( iNeSi, tInVa ); }
|
2006-12-18 15:39:33 +01:00
|
|
|
virtual ~CVector() {}
|
|
|
|
|
|
|
|
/* Copy constructor: The order of the initialization list must not be
|
|
|
|
changed. First, the base class must be initialized, then the pData
|
|
|
|
pointer must be set to the new data source. The bit access is, by
|
|
|
|
default, reset */
|
2007-09-08 12:45:14 +02:00
|
|
|
CVector ( const CVector<TData>& vecI ) :
|
|
|
|
std::vector<TData> ( static_cast<const std::vector<TData>&> ( vecI ) ),
|
|
|
|
iVectorSize ( vecI.Size() ) { pData = this->begin(); }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Init ( const int iNewSize );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// use this init to give all elements a defined value
|
|
|
|
void Init ( const int iNewSize, const TData tIniVal );
|
|
|
|
void Reset ( const TData tResetVal );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Enlarge ( const int iAddedSize );
|
|
|
|
void Add ( const TData& tI ) { Enlarge ( 1 ); pData[iVectorSize - 1] = tI; }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
inline int Size() const { return iVectorSize; }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* This operator allows for a l-value assignment of this object:
|
|
|
|
CVector[x] = y is possible */
|
2007-09-08 12:45:14 +02:00
|
|
|
inline TData& operator[] ( const int iPos ) {
|
2006-12-18 15:39:33 +01:00
|
|
|
#ifdef _DEBUG_
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
DebugError ( "Writing vector out of bounds", "Vector size",
|
|
|
|
iVectorSize, "New parameter", iPos );
|
2006-12-18 15:39:33 +01:00
|
|
|
}
|
2008-03-28 22:46:13 +01:00
|
|
|
#endif
|
2007-09-08 12:45:14 +02:00
|
|
|
return pData[iPos]; }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
inline TData operator[] ( const int iPos ) const {
|
2006-12-18 15:39:33 +01:00
|
|
|
#ifdef _DEBUG_
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
DebugError ( "Reading vector out of bounds", "Vector size",
|
|
|
|
iVectorSize, "New parameter", iPos );
|
2006-12-18 15:39:33 +01:00
|
|
|
}
|
|
|
|
#endif
|
2007-09-08 12:45:14 +02:00
|
|
|
return pData[iPos]; }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
inline CVector<TData>& operator= ( const CVector<TData>& vecI ) {
|
2006-12-18 15:39:33 +01:00
|
|
|
#ifdef _DEBUG_
|
|
|
|
/* Vectors which shall be copied MUST have same size! (If this is
|
|
|
|
satisfied, the parameter "iVectorSize" must not be adjusted as
|
|
|
|
a side effect) */
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( vecI.Size() != iVectorSize )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
DebugError ( "Vector operator=() different size", "Vector size",
|
|
|
|
iVectorSize, "New parameter", vecI.Size() );
|
2006-12-18 15:39:33 +01:00
|
|
|
}
|
|
|
|
#endif
|
2007-09-08 12:45:14 +02:00
|
|
|
vector<TData>::operator= ( vecI );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* Reset my data pointer in case, the operator=() of the base class
|
|
|
|
did change the actual memory */
|
|
|
|
pData = this->begin();
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typename std::vector<TData>::iterator pData;
|
|
|
|
int iVectorSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Implementation *************************************************************/
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CVector<TData>::Init ( const int iNewSize )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
|
|
|
iVectorSize = iNewSize;
|
|
|
|
|
|
|
|
/* Clear old buffer and reserve memory for new buffer, get iterator
|
|
|
|
for pointer operations */
|
|
|
|
this->clear();
|
2007-09-08 12:45:14 +02:00
|
|
|
this->resize ( iNewSize );
|
2006-12-18 15:39:33 +01:00
|
|
|
pData = this->begin();
|
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CVector<TData>::Init ( const int iNewSize,
|
|
|
|
const TData tIniVal )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
// call actual init routine
|
|
|
|
Init ( iNewSize );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// set values
|
|
|
|
Reset ( tIniVal );
|
2006-12-18 15:39:33 +01:00
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CVector<TData>::Enlarge ( const int iAddedSize )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
|
|
|
iVectorSize += iAddedSize;
|
2007-09-08 12:45:14 +02:00
|
|
|
this->resize ( iVectorSize );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* We have to reset the pointer since it could be that the vector size was
|
|
|
|
zero before enlarging the vector */
|
|
|
|
pData = this->begin();
|
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CVector<TData>::Reset ( const TData tResetVal )
|
2006-12-18 15:39:33 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
// set all values to reset value
|
|
|
|
for ( int i = 0; i < iVectorSize; i++ )
|
|
|
|
{
|
2006-12-18 15:39:33 +01:00
|
|
|
pData[i] = tResetVal;
|
2007-09-08 12:45:14 +02:00
|
|
|
}
|
2006-12-18 15:39:33 +01:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************\
|
|
|
|
* CFIFO class (first in, first out) *
|
|
|
|
\******************************************************************************/
|
|
|
|
template<class TData> class CFIFO : public CVector<TData>
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CFIFO() : CVector<TData>(), iCurIdx ( 0 ) {}
|
|
|
|
CFIFO ( const int iNeSi ) : CVector<TData>(iNeSi), iCurIdx ( 0 ) {}
|
|
|
|
CFIFO ( const int iNeSi, const TData tInVa ) :
|
|
|
|
CVector<TData> ( iNeSi, tInVa ), iCurIdx ( 0 ) {}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Add ( const TData tNewD );
|
|
|
|
inline TData Get() { return this->pData[iCurIdx]; }
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
virtual void Init ( const int iNewSize );
|
|
|
|
virtual void Init ( const int iNewSize, const TData tIniVal );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
protected:
|
2006-11-25 15:46:57 +01:00
|
|
|
int iCurIdx;
|
2006-01-28 12:29:22 +01:00
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CFIFO<TData>::Init ( const int iNewSize )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx = 0;
|
2007-09-08 12:45:14 +02:00
|
|
|
CVector<TData>::Init ( iNewSize );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CFIFO<TData>::Init ( const int iNewSize,
|
|
|
|
const TData tIniVal )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx = 0;
|
2007-09-08 12:45:14 +02:00
|
|
|
CVector<TData>::Init ( iNewSize, tIniVal );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CFIFO<TData>::Add ( const TData tNewD )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
this->pData[iCurIdx] = tNewD;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// increment index
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx++;
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( iCurIdx >= this->iVectorSize )
|
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx = 0;
|
2007-09-08 12:45:14 +02:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************\
|
|
|
|
* CMovingAv class (moving average) *
|
|
|
|
\******************************************************************************/
|
|
|
|
template<class TData> class CMovingAv : public CVector<TData>
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CMovingAv() : CVector<TData>(), iCurIdx ( 0 ), iNorm ( 0 ),
|
|
|
|
tCurAvResult ( TData ( 0 ) ) {}
|
2008-01-26 15:55:38 +01:00
|
|
|
CMovingAv ( const int iNeSi ) : CVector<TData> ( iNeSi ), iCurIdx ( 0 ),
|
|
|
|
iNorm ( 0 ), tCurAvResult ( TData ( 0 ) ) {}
|
2007-09-08 12:45:14 +02:00
|
|
|
CMovingAv ( const int iNeSi, const TData tInVa ) :
|
|
|
|
CVector<TData> ( iNeSi, tInVa ), iCurIdx ( 0 ), iNorm ( 0 ),
|
|
|
|
tCurAvResult ( TData ( 0 ) ) {}
|
|
|
|
|
|
|
|
void Add ( const TData tNewD );
|
2006-11-25 15:46:57 +01:00
|
|
|
inline TData GetAverage()
|
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( this->iNorm == 0 )
|
2008-03-28 22:46:13 +01:00
|
|
|
{
|
|
|
|
return TData ( 0 );
|
|
|
|
}
|
2007-09-08 12:45:14 +02:00
|
|
|
else
|
2008-03-28 22:46:13 +01:00
|
|
|
{
|
|
|
|
return tCurAvResult / this->iNorm;
|
|
|
|
}
|
2006-11-25 15:46:57 +01:00
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
virtual void Init ( const int iNewSize );
|
|
|
|
void InitVec ( const int iNewSize, const int iNewVecSize );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
protected:
|
2006-11-25 15:46:57 +01:00
|
|
|
int iCurIdx;
|
|
|
|
int iNorm;
|
|
|
|
TData tCurAvResult;
|
2006-01-28 12:29:22 +01:00
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CMovingAv<TData>::Init ( const int iNewSize )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2007-09-08 12:45:14 +02:00
|
|
|
iNorm = 0;
|
|
|
|
iCurIdx = 0;
|
|
|
|
tCurAvResult = TData ( 0 ); // only for scalars!
|
|
|
|
CVector<TData>::Init ( iNewSize );
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
template<class TData> void CMovingAv<TData>::Add ( const TData tNewD )
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
|
|
|
/*
|
2006-11-25 15:46:57 +01:00
|
|
|
Optimized calculation of the moving average. We only add a new value and
|
|
|
|
subtract the old value from the result. We only need one addition and a
|
|
|
|
history buffer
|
2006-01-28 12:29:22 +01:00
|
|
|
*/
|
2007-09-08 12:45:14 +02:00
|
|
|
// subtract oldest value
|
2006-11-25 15:46:57 +01:00
|
|
|
tCurAvResult -= this->pData[iCurIdx];
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// add new value and write in memory
|
2006-11-25 15:46:57 +01:00
|
|
|
tCurAvResult += tNewD;
|
|
|
|
this->pData[iCurIdx] = tNewD;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// increase position pointer and test if wrap
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx++;
|
2007-09-08 12:45:14 +02:00
|
|
|
if ( iCurIdx >= this->iVectorSize )
|
2008-03-28 22:46:13 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
iCurIdx = 0;
|
2008-03-28 22:46:13 +01:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// take care of norm
|
|
|
|
if ( this->iNorm < this->iVectorSize )
|
2008-03-28 22:46:13 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
this->iNorm++;
|
2008-03-28 22:46:13 +01:00
|
|
|
}
|
2006-01-28 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************\
|
|
|
|
* GUI utilities *
|
|
|
|
\******************************************************************************/
|
2008-01-26 15:55:38 +01:00
|
|
|
// About dialog ----------------------------------------------------------------
|
2008-01-14 23:14:17 +01:00
|
|
|
class CAboutDlg : public QDialog, private Ui_CAboutDlgBase
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
Q_OBJECT
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
public:
|
2008-01-14 23:14:17 +01:00
|
|
|
CAboutDlg ( QWidget* parent = 0 );
|
2006-02-18 13:19:27 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
static QString GetVersionAndNameStr ( const bool bWithHtml = true );
|
2006-01-28 12:29:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// Help menu -------------------------------------------------------------------
|
2008-01-14 23:14:17 +01:00
|
|
|
class CLlconHelpMenu : public QMenu
|
2006-01-28 12:29:22 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
Q_OBJECT
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CLlconHelpMenu ( QWidget* parent = 0 );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
protected:
|
2006-11-25 15:46:57 +01:00
|
|
|
CAboutDlg AboutDlg;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
public slots:
|
2007-09-08 12:45:14 +02:00
|
|
|
void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); }
|
|
|
|
void OnHelpAbout() { AboutDlg.exec(); }
|
2006-01-28 12:29:22 +01:00
|
|
|
};
|
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* Other Classes **************************************************************/
|
2008-01-26 15:55:38 +01:00
|
|
|
// Signal Level Meter ----------------------------------------------------------
|
2006-12-18 15:39:33 +01:00
|
|
|
class CSignalLevelMeter
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CSignalLevelMeter() : dCurLevel ( 0.0 ) {}
|
2006-12-18 15:39:33 +01:00
|
|
|
virtual ~CSignalLevelMeter() {}
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Update ( CVector<double>& vecdAudio );
|
2006-12-18 15:39:33 +01:00
|
|
|
double MicLevel();
|
2007-09-08 12:45:14 +02:00
|
|
|
void Reset() { dCurLevel = 0.0; }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
double dCurLevel;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CHostAddress
|
|
|
|
{
|
|
|
|
public:
|
2008-01-14 23:14:17 +01:00
|
|
|
CHostAddress() : InetAddr ( (quint32) 0 ), iPort ( 0 ) {}
|
|
|
|
CHostAddress ( const QHostAddress NInetAddr, const quint16 iNPort ) :
|
2007-09-08 12:45:14 +02:00
|
|
|
InetAddr ( NInetAddr ), iPort ( iNPort ) {}
|
|
|
|
CHostAddress ( const CHostAddress& NHAddr ) :
|
|
|
|
InetAddr ( NHAddr.InetAddr ), iPort ( NHAddr.iPort ) {}
|
|
|
|
|
|
|
|
// copy and compare operators
|
|
|
|
CHostAddress& operator= ( const CHostAddress& NHAddr )
|
|
|
|
{ InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this; }
|
|
|
|
bool operator== ( const CHostAddress& CompAddr ) // compare operator
|
|
|
|
{ return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
QHostAddress InetAddr;
|
2008-01-14 23:14:17 +01:00
|
|
|
quint16 iPort;
|
2006-11-26 22:25:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CChannelShortInfo
|
|
|
|
{
|
|
|
|
public:
|
2006-12-09 19:37:40 +01:00
|
|
|
CChannelShortInfo() : iChanID ( 0 ), iIpAddr ( 0 ), strName ( "" ) {}
|
2008-01-22 22:15:04 +01:00
|
|
|
CChannelShortInfo ( const int iNID, const quint32 nIP, const QString nN ) :
|
2006-12-09 19:37:40 +01:00
|
|
|
iChanID ( iNID ), iIpAddr ( nIP ), strName ( nN ) {}
|
2006-11-26 22:25:56 +01:00
|
|
|
|
2008-01-22 22:15:04 +01:00
|
|
|
int iChanID;
|
|
|
|
quint32 iIpAddr;
|
|
|
|
QString strName;
|
2006-11-26 22:25:56 +01:00
|
|
|
};
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// Audio Reverbration ----------------------------------------------------------
|
2006-01-28 12:29:22 +01:00
|
|
|
class CAudioReverb
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CAudioReverb ( const double rT60 = (double) 5.0 );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
void Clear();
|
2007-09-08 12:45:14 +02:00
|
|
|
double ProcessSample ( const double input );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
protected:
|
2007-09-08 12:45:14 +02:00
|
|
|
void setT60 ( const double rT60 );
|
|
|
|
bool isPrime ( const int number );
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
CFIFO<int> allpassDelays_[3];
|
|
|
|
CFIFO<int> combDelays_[4];
|
|
|
|
double allpassCoefficient_;
|
|
|
|
double combCoefficient_[4];
|
2006-01-28 12:29:22 +01:00
|
|
|
};
|
2006-02-12 15:26:46 +01:00
|
|
|
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// CRC -------------------------------------------------------------------------
|
2006-02-18 23:05:46 +01:00
|
|
|
class CCRC
|
|
|
|
{
|
|
|
|
public:
|
2007-09-08 12:45:14 +02:00
|
|
|
CCRC() : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 )
|
|
|
|
{ Reset(); }
|
|
|
|
virtual ~CCRC() {}
|
2006-02-18 23:05:46 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Reset();
|
2006-11-25 15:46:57 +01:00
|
|
|
void AddByte ( const uint8_t byNewInput );
|
|
|
|
bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); }
|
2007-09-08 12:45:14 +02:00
|
|
|
uint32_t GetCRC();
|
2006-02-18 23:05:46 +01:00
|
|
|
|
|
|
|
protected:
|
2006-11-25 15:46:57 +01:00
|
|
|
uint32_t iBitOutMask;
|
|
|
|
uint32_t iPoly;
|
|
|
|
uint32_t iStateShiftReg;
|
2006-02-18 23:05:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// Time conversion -------------------------------------------------------------
|
2006-02-12 15:26:46 +01:00
|
|
|
// needed for ping measurement
|
|
|
|
class CTimeConv
|
|
|
|
{
|
|
|
|
public:
|
2006-11-25 15:46:57 +01:00
|
|
|
// QTime to network time vector
|
|
|
|
static CVector<unsigned char> QTi2NetTi ( const QTime qTiIn )
|
|
|
|
{
|
|
|
|
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
|
|
|
|
CVector<unsigned char> veccNetTi ( 5 );
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
veccNetTi[0] = static_cast<unsigned char> ( qTiIn.hour() );
|
|
|
|
veccNetTi[1] = static_cast<unsigned char> ( qTiIn.minute() );
|
|
|
|
veccNetTi[2] = static_cast<unsigned char> ( qTiIn.second() );
|
2006-11-25 15:46:57 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
const int iMs = qTiIn.msec();
|
2006-11-25 15:46:57 +01:00
|
|
|
veccNetTi[3] = static_cast<unsigned char> ( ( iMs >> 8 ) & 255 );
|
|
|
|
veccNetTi[4] = static_cast<unsigned char> ( iMs & 255 );
|
|
|
|
|
|
|
|
return veccNetTi;
|
|
|
|
}
|
|
|
|
|
|
|
|
// network time vector to QTime
|
|
|
|
static QTime NetTi2QTi ( const CVector<unsigned char> netTiIn )
|
|
|
|
{
|
|
|
|
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
|
|
|
|
return QTime (
|
|
|
|
static_cast<int> ( netTiIn[0] ), // hour
|
|
|
|
static_cast<int> ( netTiIn[1] ), // minute
|
|
|
|
static_cast<int> ( netTiIn[2] ), // seconds
|
|
|
|
// msec
|
|
|
|
static_cast<int> ( ( netTiIn[3] << 8 ) | netTiIn[4] )
|
|
|
|
);
|
|
|
|
}
|
2006-02-12 15:26:46 +01:00
|
|
|
};
|
2006-09-03 11:49:15 +02:00
|
|
|
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// Time and Data to String conversion ------------------------------------------
|
2006-09-03 11:49:15 +02:00
|
|
|
class CLogTimeDate
|
|
|
|
{
|
|
|
|
public:
|
2006-11-25 15:46:57 +01:00
|
|
|
static QString toString()
|
|
|
|
{
|
|
|
|
const QDateTime curDateTime = QDateTime::currentDateTime();
|
|
|
|
|
|
|
|
// format date and time output according to "3.9.2006 11:38:08: "
|
2008-03-28 22:46:13 +01:00
|
|
|
return QString().setNum ( curDateTime.date().day() ) + "." +
|
2006-11-25 15:46:57 +01:00
|
|
|
QString().setNum ( curDateTime.date().month() ) + "." +
|
2008-03-28 22:46:13 +01:00
|
|
|
QString().setNum ( curDateTime.date().year() ) + " " +
|
2006-11-25 15:46:57 +01:00
|
|
|
curDateTime.time().toString() + ": ";
|
|
|
|
}
|
2006-09-03 11:49:15 +02:00
|
|
|
};
|
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
// Logging ---------------------------------------------------------------------
|
2007-05-06 14:27:41 +02:00
|
|
|
class CLogging
|
|
|
|
{
|
|
|
|
public:
|
2008-01-26 15:55:38 +01:00
|
|
|
CLogging() : bDoLogging ( false ), File ( LOG_FILE_NAME ) {}
|
2007-05-06 14:27:41 +02:00
|
|
|
virtual ~CLogging()
|
|
|
|
{
|
2008-01-26 15:55:38 +01:00
|
|
|
if ( File.isOpen() )
|
2007-05-06 14:27:41 +02:00
|
|
|
{
|
2008-01-26 15:55:38 +01:00
|
|
|
File.close();
|
2007-05-06 14:27:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
// open file
|
2008-01-26 15:55:38 +01:00
|
|
|
if ( File.open ( QIODevice::Append ) )
|
2007-06-17 14:31:20 +02:00
|
|
|
{
|
|
|
|
bDoLogging = true;
|
|
|
|
}
|
2007-05-06 14:27:41 +02:00
|
|
|
}
|
|
|
|
|
2008-01-26 15:55:38 +01:00
|
|
|
void operator<< ( const QString& sNewStr )
|
2007-05-06 14:27:41 +02:00
|
|
|
{
|
2007-06-17 14:31:20 +02:00
|
|
|
if ( bDoLogging )
|
|
|
|
{
|
2008-01-26 15:55:38 +01:00
|
|
|
// append new line in logging file
|
|
|
|
QTextStream out ( &File );
|
|
|
|
out << sNewStr << endl;
|
2007-06-17 14:31:20 +02:00
|
|
|
}
|
2007-05-06 14:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2008-01-26 15:55:38 +01:00
|
|
|
bool bDoLogging;
|
|
|
|
QFile File;
|
2007-05-06 14:27:41 +02:00
|
|
|
};
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|