new code style
This commit is contained in:
parent
56f6fee1e0
commit
d49a2b2731
30 changed files with 1109 additions and 912 deletions
src
audiocompr.cppaudiocompr.haudiomixerboard.cppaudiomixerboard.hbuffer.cppbuffer.hchannel.hclient.hclientsettingsdlg.cppclientsettingsdlg.hglobal.hllconclientdlg.cppllconclientdlg.hllconserverdlg.cppllconserverdlg.hmulticolorled.cppmulticolorled.hprotocol.cppprotocol.hresample.hserver.hsettings.cppsettings.hsocket.cppsocket.hutil.cpputil.h
windows
|
@ -52,16 +52,16 @@ int CAudioCompression::Init ( const int iNewAudioLen,
|
||||||
|
|
||||||
CVector<unsigned char> CAudioCompression::Encode ( const CVector<short>& vecsAudio )
|
CVector<unsigned char> CAudioCompression::Encode ( const CVector<short>& vecsAudio )
|
||||||
{
|
{
|
||||||
if (eAudComprType == CT_NONE)
|
if ( eAudComprType == CT_NONE )
|
||||||
{
|
{
|
||||||
/* no compression, simply ship pure samples */
|
/* no compression, simply ship pure samples */
|
||||||
CVector<unsigned char> vecbyOut(iCodeSize);
|
CVector<unsigned char> vecbyOut ( iCodeSize );
|
||||||
const int iAudSize = iCodeSize / 2;
|
const int iAudSize = iCodeSize / 2;
|
||||||
|
|
||||||
for (int i = 0; i < iAudSize; i++)
|
for ( int i = 0; i < iAudSize; i++ )
|
||||||
{
|
{
|
||||||
vecbyOut[2 * i] = vecsAudio[i] & 0xFF;
|
vecbyOut[2 * i] = vecsAudio[i] & 0xFF;
|
||||||
vecbyOut[2 * i + 1] = (vecsAudio[i] >> 8) & 0xFF;
|
vecbyOut[2 * i + 1] = ( vecsAudio[i] >> 8 ) & 0xFF;
|
||||||
}
|
}
|
||||||
return vecbyOut;
|
return vecbyOut;
|
||||||
}
|
}
|
||||||
|
@ -78,19 +78,21 @@ CVector<unsigned char> CAudioCompression::Encode ( const CVector<short>& vecsAud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CAudioCompression::Decode(const CVector<unsigned char>& vecbyAdpcm)
|
CVector<short> CAudioCompression::Decode ( const CVector<unsigned char>& vecbyAdpcm )
|
||||||
{
|
{
|
||||||
if (eAudComprType == CT_NONE)
|
if ( eAudComprType == CT_NONE )
|
||||||
{
|
{
|
||||||
/* no compression, reassemble pure samples */
|
/* no compression, reassemble pure samples */
|
||||||
const int iAudSize = iCodeSize / 2;
|
const int iAudSize = iCodeSize / 2;
|
||||||
CVector<short> vecsOut(iAudSize);
|
CVector<short> vecsOut ( iAudSize );
|
||||||
|
|
||||||
for (int i = 0; i < iAudSize; i++)
|
for ( int i = 0; i < iAudSize; i++ )
|
||||||
|
{
|
||||||
|
int current = vecbyAdpcm[2 * i] | ( vecbyAdpcm[2 * i + 1] << 8 );
|
||||||
|
if ( current & 0x8000 )
|
||||||
{
|
{
|
||||||
int current = vecbyAdpcm[2 * i] | (vecbyAdpcm[2 * i + 1] << 8);
|
|
||||||
if (current & 0x8000)
|
|
||||||
current -= 0x10000;
|
current -= 0x10000;
|
||||||
|
}
|
||||||
|
|
||||||
vecsOut[i] = (short) current;
|
vecsOut[i] = (short) current;
|
||||||
}
|
}
|
||||||
|
@ -111,38 +113,38 @@ CVector<short> CAudioCompression::Decode(const CVector<unsigned char>& vecbyAdpc
|
||||||
|
|
||||||
|
|
||||||
/* IMA-ADPCM implementation ------------------------------------------------- */
|
/* IMA-ADPCM implementation ------------------------------------------------- */
|
||||||
int CImaAdpcm::Init(const int iNewAudioLen)
|
int CImaAdpcm::Init ( const int iNewAudioLen )
|
||||||
{
|
{
|
||||||
/* set lengths for audio and compressed data */
|
/* set lengths for audio and compressed data */
|
||||||
iAudSize = iNewAudioLen;
|
iAudSize = iNewAudioLen;
|
||||||
iAdpcmSize = 4 /* bytes header */ + (int) ceil(
|
iAdpcmSize = 4 /* bytes header */ + (int) ceil (
|
||||||
(double) (iAudSize - 2 /* first two samples are in header */) / 2);
|
(double) ( iAudSize - 2 /* first two samples are in header */ ) / 2 );
|
||||||
|
|
||||||
iStepindEnc = 0;
|
iStepindEnc = 0;
|
||||||
|
|
||||||
return iAdpcmSize;
|
return iAdpcmSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<unsigned char> CImaAdpcm::Encode(const CVector<short>& vecsAudio)
|
CVector<unsigned char> CImaAdpcm::Encode ( const CVector<short>& vecsAudio )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CVector<unsigned char> vecbyAdpcm;
|
CVector<unsigned char> vecbyAdpcm;
|
||||||
CVector<unsigned char> vecbyAdpcmTemp;
|
CVector<unsigned char> vecbyAdpcmTemp;
|
||||||
|
|
||||||
/* init size */
|
/* init size */
|
||||||
vecbyAdpcm.Init(iAdpcmSize);
|
vecbyAdpcm.Init ( iAdpcmSize );
|
||||||
vecbyAdpcmTemp.Init(iAudSize);
|
vecbyAdpcmTemp.Init ( iAudSize );
|
||||||
|
|
||||||
/* encode the block header ----------------------------------------------- */
|
/* encode the block header ----------------------------------------------- */
|
||||||
vecbyAdpcm[0] = vecsAudio[0] & 0xFF;
|
vecbyAdpcm[0] = vecsAudio[0] & 0xFF;
|
||||||
vecbyAdpcm[1] = (vecsAudio[0] >> 8) & 0xFF;
|
vecbyAdpcm[1] = ( vecsAudio[0] >> 8 ) & 0xFF;
|
||||||
vecbyAdpcm[2] = iStepindEnc;
|
vecbyAdpcm[2] = iStepindEnc;
|
||||||
|
|
||||||
int iPrevAudio = vecsAudio[0];
|
int iPrevAudio = vecsAudio[0];
|
||||||
|
|
||||||
|
|
||||||
/* encode the samples as 4 bit ------------------------------------------- */
|
/* encode the samples as 4 bit ------------------------------------------- */
|
||||||
for (i = 1; i < iAudSize; i++)
|
for ( i = 1; i < iAudSize; i++ )
|
||||||
{
|
{
|
||||||
/* init diff and step */
|
/* init diff and step */
|
||||||
int diff = vecsAudio[i] - iPrevAudio;
|
int diff = vecsAudio[i] - iPrevAudio;
|
||||||
|
@ -151,15 +153,15 @@ CVector<unsigned char> CImaAdpcm::Encode(const CVector<short>& vecsAudio)
|
||||||
short bytecode = 0;
|
short bytecode = 0;
|
||||||
|
|
||||||
int vpdiff = step >> 3;
|
int vpdiff = step >> 3;
|
||||||
if (diff < 0)
|
if ( diff < 0 )
|
||||||
{
|
{
|
||||||
bytecode = 8;
|
bytecode = 8;
|
||||||
diff = -diff;
|
diff = -diff;
|
||||||
}
|
}
|
||||||
short mask = 4;
|
short mask = 4;
|
||||||
while (mask)
|
while ( mask )
|
||||||
{
|
{
|
||||||
if (diff >= step)
|
if ( diff >= step )
|
||||||
{
|
{
|
||||||
bytecode |= mask;
|
bytecode |= mask;
|
||||||
diff -= step;
|
diff -= step;
|
||||||
|
@ -169,17 +171,21 @@ CVector<unsigned char> CImaAdpcm::Encode(const CVector<short>& vecsAudio)
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytecode & 8)
|
if ( bytecode & 8 )
|
||||||
|
{
|
||||||
iPrevAudio -= vpdiff;
|
iPrevAudio -= vpdiff;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
iPrevAudio += vpdiff;
|
iPrevAudio += vpdiff;
|
||||||
|
}
|
||||||
|
|
||||||
/* adjust step size */
|
/* adjust step size */
|
||||||
iStepindEnc += ima_indx_adjust[bytecode];
|
iStepindEnc += ima_indx_adjust[bytecode];
|
||||||
|
|
||||||
/* check that values do not exceed the bounds */
|
/* check that values do not exceed the bounds */
|
||||||
iPrevAudio = CheckBounds(iPrevAudio, _MINSHORT, _MAXSHORT);
|
iPrevAudio = CheckBounds ( iPrevAudio, _MINSHORT, _MAXSHORT );
|
||||||
iStepindEnc = CheckBounds(iStepindEnc, 0, IMA_STEP_SIZE_TAB_LEN - 1);
|
iStepindEnc = CheckBounds ( iStepindEnc, 0, IMA_STEP_SIZE_TAB_LEN - 1 );
|
||||||
|
|
||||||
/* use the input buffer as an intermediate result buffer */
|
/* use the input buffer as an intermediate result buffer */
|
||||||
vecbyAdpcmTemp[i] = bytecode;
|
vecbyAdpcmTemp[i] = bytecode;
|
||||||
|
@ -190,30 +196,32 @@ CVector<unsigned char> CImaAdpcm::Encode(const CVector<short>& vecsAudio)
|
||||||
/* The first encoded audio sample is in header */
|
/* The first encoded audio sample is in header */
|
||||||
vecbyAdpcm[3] = vecbyAdpcmTemp[1] & 0x0F;
|
vecbyAdpcm[3] = vecbyAdpcmTemp[1] & 0x0F;
|
||||||
|
|
||||||
for (i = 4; i < iAdpcmSize; i++)
|
for ( i = 4; i < iAdpcmSize; i++ )
|
||||||
{
|
{
|
||||||
vecbyAdpcm[i] = vecbyAdpcmTemp[2 * i - 6] & 0x0F;
|
vecbyAdpcm[i] = vecbyAdpcmTemp[2 * i - 6] & 0x0F;
|
||||||
vecbyAdpcm[i] |= (vecbyAdpcmTemp[2 * i - 5] << 4) & 0xF0;
|
vecbyAdpcm[i] |= ( vecbyAdpcmTemp[2 * i - 5] << 4 ) & 0xF0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vecbyAdpcm;
|
return vecbyAdpcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CImaAdpcm::Decode(const CVector<unsigned char>& vecbyAdpcm)
|
CVector<short> CImaAdpcm::Decode ( const CVector<unsigned char>& vecbyAdpcm )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
CVector<short> vecsAudio;
|
CVector<short> vecsAudio;
|
||||||
|
|
||||||
vecsAudio.Init(iAudSize);
|
vecsAudio.Init ( iAudSize );
|
||||||
|
|
||||||
|
|
||||||
/* read and check the block header --------------------------------------- */
|
/* read and check the block header --------------------------------------- */
|
||||||
int current = vecbyAdpcm[0] | (vecbyAdpcm[1] << 8);
|
int current = vecbyAdpcm[0] | ( vecbyAdpcm[1] << 8 );
|
||||||
if (current & 0x8000)
|
if ( current & 0x8000 )
|
||||||
|
{
|
||||||
current -= 0x10000;
|
current -= 0x10000;
|
||||||
|
}
|
||||||
|
|
||||||
/* get and bound step index */
|
/* get and bound step index */
|
||||||
int iStepindDec = CheckBounds(vecbyAdpcm[2], 0, IMA_STEP_SIZE_TAB_LEN - 1);
|
int iStepindDec = CheckBounds ( vecbyAdpcm[2], 0, IMA_STEP_SIZE_TAB_LEN - 1 );
|
||||||
|
|
||||||
/* set first sample which was delivered in the header */
|
/* set first sample which was delivered in the header */
|
||||||
vecsAudio[0] = current;
|
vecsAudio[0] = current;
|
||||||
|
@ -225,16 +233,16 @@ CVector<short> CImaAdpcm::Decode(const CVector<unsigned char>& vecbyAdpcm)
|
||||||
/* The first encoded audio sample is in header */
|
/* The first encoded audio sample is in header */
|
||||||
vecsAudio[1] = vecbyAdpcm[3] & 0x0F;
|
vecsAudio[1] = vecbyAdpcm[3] & 0x0F;
|
||||||
|
|
||||||
for (i = 4; i < iAdpcmSize; i++)
|
for ( i = 4; i < iAdpcmSize; i++ )
|
||||||
{
|
{
|
||||||
const short bytecode = vecbyAdpcm[i];
|
const short bytecode = vecbyAdpcm[i];
|
||||||
vecsAudio[2 * i - 6] = bytecode & 0x0F;
|
vecsAudio[2 * i - 6] = bytecode & 0x0F;
|
||||||
vecsAudio[2 * i - 5] = (bytecode >> 4) & 0x0F;
|
vecsAudio[2 * i - 5] = ( bytecode >> 4 ) & 0x0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* decode the encoded 4 bit samples -------------------------------------- */
|
/* decode the encoded 4 bit samples -------------------------------------- */
|
||||||
for (i = 1; i < iAudSize; i++)
|
for ( i = 1; i < iAudSize; i++ )
|
||||||
{
|
{
|
||||||
const short bytecode = vecsAudio[i] & 0xF ;
|
const short bytecode = vecsAudio[i] & 0xF ;
|
||||||
|
|
||||||
|
@ -242,21 +250,29 @@ CVector<short> CImaAdpcm::Decode(const CVector<unsigned char>& vecbyAdpcm)
|
||||||
int current = vecsAudio[i - 1];
|
int current = vecsAudio[i - 1];
|
||||||
|
|
||||||
int diff = step >> 3;
|
int diff = step >> 3;
|
||||||
if (bytecode & 1)
|
if ( bytecode & 1 )
|
||||||
|
{
|
||||||
diff += step >> 2;
|
diff += step >> 2;
|
||||||
if (bytecode & 2)
|
}
|
||||||
|
if ( bytecode & 2 )
|
||||||
|
{
|
||||||
diff += step >> 1;
|
diff += step >> 1;
|
||||||
if (bytecode & 4)
|
}
|
||||||
|
if ( bytecode & 4 )
|
||||||
|
{
|
||||||
diff += step;
|
diff += step;
|
||||||
if (bytecode & 8)
|
}
|
||||||
|
if ( bytecode & 8 )
|
||||||
|
{
|
||||||
diff = -diff;
|
diff = -diff;
|
||||||
|
}
|
||||||
|
|
||||||
current += diff;
|
current += diff;
|
||||||
iStepindDec += ima_indx_adjust[bytecode];
|
iStepindDec += ima_indx_adjust[bytecode];
|
||||||
|
|
||||||
/* check that values do not exceed the bounds */
|
/* check that values do not exceed the bounds */
|
||||||
current = CheckBounds(current, _MINSHORT, _MAXSHORT);
|
current = CheckBounds ( current, _MINSHORT, _MAXSHORT );
|
||||||
iStepindDec = CheckBounds(iStepindDec, 0, IMA_STEP_SIZE_TAB_LEN - 1);
|
iStepindDec = CheckBounds ( iStepindDec, 0, IMA_STEP_SIZE_TAB_LEN - 1 );
|
||||||
|
|
||||||
vecsAudio[i] = current;
|
vecsAudio[i] = current;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_)
|
#if !defined ( AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_ )
|
||||||
#define AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_
|
#define AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -68,7 +68,7 @@ protected:
|
||||||
int iAdpcmSize;
|
int iAdpcmSize;
|
||||||
int iStepindEnc;
|
int iStepindEnc;
|
||||||
|
|
||||||
/* inline functions must be declared in the header */
|
// inline functions must be declared in the header
|
||||||
inline int CheckBounds ( const int iData, const int iMin, const int iMax )
|
inline int CheckBounds ( const int iData, const int iMin, const int iMax )
|
||||||
{
|
{
|
||||||
if ( iData > iMax )
|
if ( iData > iMax )
|
||||||
|
@ -107,4 +107,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_) */
|
#endif /* !defined ( AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_ ) */
|
||||||
|
|
|
@ -57,12 +57,12 @@ CChannelFader::CChannelFader ( QWidget* pNW,
|
||||||
pParentLayout->insertLayout ( 0, pMainGrid );
|
pParentLayout->insertLayout ( 0, pMainGrid );
|
||||||
|
|
||||||
// add help text to controls
|
// add help text to controls
|
||||||
QWhatsThis::add(pFader, "<b>Mixer Fader:</b> Adjusts the audio level of this "
|
QWhatsThis::add ( pFader, "<b>Mixer Fader:</b> Adjusts the audio level of this "
|
||||||
"channel. All connected clients at the server will be assigned an audio "
|
"channel. All connected clients at the server will be assigned an audio "
|
||||||
"fader at each client");
|
"fader at each client" );
|
||||||
|
|
||||||
QWhatsThis::add(pLabel, "<b>Mixer Fader Label:</b> Label (fader tag) identifying "
|
QWhatsThis::add ( pLabel, "<b>Mixer Fader Label:</b> Label (fader tag) identifying "
|
||||||
"the connected client. The tag name can be set in the clients main window.");
|
"the connected client. The tag name can be set in the clients main window." );
|
||||||
|
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// connections -------------------------------------------------------------
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_)
|
#if !defined ( MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_ )
|
||||||
#define MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_
|
#define MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_
|
||||||
|
|
||||||
#include <qframe.h>
|
#include <qframe.h>
|
||||||
|
|
156
src/buffer.cpp
156
src/buffer.cpp
|
@ -39,28 +39,36 @@ void CNetBuf::Init ( const int iNewBlockSize, const int iNewNumBlocks )
|
||||||
bFadeInNewPutData = true;
|
bFadeInNewPutData = true;
|
||||||
|
|
||||||
/* allocate and clear memory for actual data buffer */
|
/* allocate and clear memory for actual data buffer */
|
||||||
vecdMemory.Init(iMemSize);
|
vecdMemory.Init ( iMemSize );
|
||||||
|
|
||||||
/* use the "get" flag to make sure the buffer is cleared */
|
/* use the "get" flag to make sure the buffer is cleared */
|
||||||
Clear(CT_GET);
|
Clear ( CT_GET );
|
||||||
|
|
||||||
/* initialize number of samples for fading effect */
|
/* initialize number of samples for fading effect */
|
||||||
if (FADE_IN_OUT_NUM_SAM < iBlockSize)
|
if ( FADE_IN_OUT_NUM_SAM < iBlockSize )
|
||||||
|
{
|
||||||
iNumSamFading = iBlockSize;
|
iNumSamFading = iBlockSize;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
iNumSamFading = FADE_IN_OUT_NUM_SAM;
|
iNumSamFading = FADE_IN_OUT_NUM_SAM;
|
||||||
|
}
|
||||||
|
|
||||||
if (FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize)
|
if ( FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize )
|
||||||
|
{
|
||||||
iNumSamFadingExtra = iBlockSize;
|
iNumSamFadingExtra = iBlockSize;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM;
|
iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM;
|
||||||
|
}
|
||||||
|
|
||||||
/* init variables for extrapolation (in case a fade out is needed) */
|
/* init variables for extrapolation (in case a fade out is needed) */
|
||||||
dExPDiff = 0.0;
|
dExPDiff = 0.0;
|
||||||
dExPLastV = 0.0;
|
dExPLastV = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetBuf::Put(CVector<double>& vecdData)
|
bool CNetBuf::Put ( CVector<double>& vecdData )
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
static FILE* pFileBI = fopen("bufferin.dat", "w");
|
static FILE* pFileBI = fopen("bufferin.dat", "w");
|
||||||
|
@ -74,11 +82,11 @@ fflush(pFileBI);
|
||||||
const int iInSize = vecdData.Size();
|
const int iInSize = vecdData.Size();
|
||||||
|
|
||||||
/* Check if there is not enough space available -> correct */
|
/* Check if there is not enough space available -> correct */
|
||||||
if (GetAvailSpace() < iInSize)
|
if ( GetAvailSpace() < iInSize )
|
||||||
{
|
{
|
||||||
/* not enough space in buffer for put operation, correct buffer to
|
/* not enough space in buffer for put operation, correct buffer to
|
||||||
prepare for new data */
|
prepare for new data */
|
||||||
Clear(CT_PUT);
|
Clear ( CT_PUT );
|
||||||
|
|
||||||
/* set flag to fade in new block to avoid clicks */
|
/* set flag to fade in new block to avoid clicks */
|
||||||
bFadeInNewPutData = true;
|
bFadeInNewPutData = true;
|
||||||
|
@ -87,41 +95,53 @@ fflush(pFileBI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fade in new block if required */
|
/* fade in new block if required */
|
||||||
if (bFadeInNewPutData)
|
if ( bFadeInNewPutData )
|
||||||
FadeInAudioDataBlock(vecdData);
|
{
|
||||||
|
FadeInAudioDataBlock ( vecdData );
|
||||||
|
}
|
||||||
|
|
||||||
/* copy new data in internal buffer */
|
/* copy new data in internal buffer */
|
||||||
int iCurPos = 0;
|
int iCurPos = 0;
|
||||||
if (iPutPos + iInSize > iMemSize)
|
if ( iPutPos + iInSize > iMemSize )
|
||||||
{
|
{
|
||||||
/* remaining space size for second block */
|
/* remaining space size for second block */
|
||||||
const int iRemSpace = iPutPos + iInSize - iMemSize;
|
const int iRemSpace = iPutPos + iInSize - iMemSize;
|
||||||
|
|
||||||
/* data must be written in two steps because of wrap around */
|
/* data must be written in two steps because of wrap around */
|
||||||
while (iPutPos < iMemSize)
|
while (iPutPos < iMemSize)
|
||||||
|
{
|
||||||
vecdMemory[iPutPos++] = vecdData[iCurPos++];
|
vecdMemory[iPutPos++] = vecdData[iCurPos++];
|
||||||
|
}
|
||||||
|
|
||||||
for (iPutPos = 0; iPutPos < iRemSpace; iPutPos++)
|
for ( iPutPos = 0; iPutPos < iRemSpace; iPutPos++ )
|
||||||
|
{
|
||||||
vecdMemory[iPutPos] = vecdData[iCurPos++];
|
vecdMemory[iPutPos] = vecdData[iCurPos++];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* data can be written in one step */
|
/* data can be written in one step */
|
||||||
const int iEnd = iPutPos + iInSize;
|
const int iEnd = iPutPos + iInSize;
|
||||||
while (iPutPos < iEnd)
|
while ( iPutPos < iEnd )
|
||||||
|
{
|
||||||
vecdMemory[iPutPos++] = vecdData[iCurPos++];
|
vecdMemory[iPutPos++] = vecdData[iCurPos++];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set buffer state flag */
|
/* set buffer state flag */
|
||||||
if (iPutPos == iGetPos)
|
if ( iPutPos == iGetPos )
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_FULL;
|
eBufState = CNetBuf::BS_FULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_OK;
|
eBufState = CNetBuf::BS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
return bPutOK;
|
return bPutOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetBuf::Get(CVector<double>& vecdData)
|
bool CNetBuf::Get ( CVector<double>& vecdData )
|
||||||
{
|
{
|
||||||
bool bGetOK = true; /* init return value */
|
bool bGetOK = true; /* init return value */
|
||||||
bool bFadeOutExtrap = false;
|
bool bFadeOutExtrap = false;
|
||||||
|
@ -130,11 +150,11 @@ bool CNetBuf::Get(CVector<double>& vecdData)
|
||||||
const int iInSize = vecdData.Size();
|
const int iInSize = vecdData.Size();
|
||||||
|
|
||||||
/* Check if there is not enough data available -> correct */
|
/* Check if there is not enough data available -> correct */
|
||||||
if (GetAvailData() < iInSize)
|
if ( GetAvailData() < iInSize )
|
||||||
{
|
{
|
||||||
/* not enough data in buffer for get operation, correct buffer to
|
/* not enough data in buffer for get operation, correct buffer to
|
||||||
prepare for getting data */
|
prepare for getting data */
|
||||||
Clear(CT_GET);
|
Clear ( CT_GET );
|
||||||
|
|
||||||
/* set flag to fade in next new block in buffer and fade out last
|
/* set flag to fade in next new block in buffer and fade out last
|
||||||
block by extrapolation to avoid clicks */
|
block by extrapolation to avoid clicks */
|
||||||
|
@ -146,39 +166,51 @@ bool CNetBuf::Get(CVector<double>& vecdData)
|
||||||
|
|
||||||
/* copy data from internal buffer in output buffer */
|
/* copy data from internal buffer in output buffer */
|
||||||
int iCurPos = 0;
|
int iCurPos = 0;
|
||||||
if (iGetPos + iInSize > iMemSize)
|
if ( iGetPos + iInSize > iMemSize )
|
||||||
{
|
{
|
||||||
/* remaining data size for second block */
|
/* remaining data size for second block */
|
||||||
const int iRemData = iGetPos + iInSize - iMemSize;
|
const int iRemData = iGetPos + iInSize - iMemSize;
|
||||||
|
|
||||||
/* data must be read in two steps because of wrap around */
|
/* data must be read in two steps because of wrap around */
|
||||||
while (iGetPos < iMemSize)
|
while ( iGetPos < iMemSize )
|
||||||
|
{
|
||||||
vecdData[iCurPos++] = vecdMemory[iGetPos++];
|
vecdData[iCurPos++] = vecdMemory[iGetPos++];
|
||||||
|
}
|
||||||
|
|
||||||
for (iGetPos = 0; iGetPos < iRemData; iGetPos++)
|
for ( iGetPos = 0; iGetPos < iRemData; iGetPos++ )
|
||||||
|
{
|
||||||
vecdData[iCurPos++] = vecdMemory[iGetPos];
|
vecdData[iCurPos++] = vecdMemory[iGetPos];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* data can be read in one step */
|
/* data can be read in one step */
|
||||||
const int iEnd = iGetPos + iInSize;
|
const int iEnd = iGetPos + iInSize;
|
||||||
while (iGetPos < iEnd)
|
while ( iGetPos < iEnd )
|
||||||
|
{
|
||||||
vecdData[iCurPos++] = vecdMemory[iGetPos++];
|
vecdData[iCurPos++] = vecdMemory[iGetPos++];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set buffer state flag */
|
/* set buffer state flag */
|
||||||
if (iPutPos == iGetPos)
|
if ( iPutPos == iGetPos )
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_EMPTY;
|
eBufState = CNetBuf::BS_EMPTY;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_OK;
|
eBufState = CNetBuf::BS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* extrapolate data from old block to avoid "clicks"
|
/* extrapolate data from old block to avoid "clicks"
|
||||||
we have to do this method since we cannot fade out the old block
|
we have to do this method since we cannot fade out the old block
|
||||||
anymore since it is already gone (processed or send through the
|
anymore since it is already gone (processed or send through the
|
||||||
network) */
|
network) */
|
||||||
if (bFadeOutExtrap)
|
if ( bFadeOutExtrap )
|
||||||
FadeOutExtrapolateAudioDataBlock(vecdData, dExPDiff, dExPLastV);
|
{
|
||||||
|
FadeOutExtrapolateAudioDataBlock ( vecdData, dExPDiff, dExPLastV );
|
||||||
|
}
|
||||||
|
|
||||||
/* save some paramters from last block which is needed in case we do not
|
/* save some paramters from last block which is needed in case we do not
|
||||||
have enough data for next "get" operation and need to extrapolate the
|
have enough data for next "get" operation and need to extrapolate the
|
||||||
|
@ -196,10 +228,17 @@ int CNetBuf::GetAvailSpace() const
|
||||||
int iAvSpace = iGetPos - iPutPos;
|
int iAvSpace = iGetPos - iPutPos;
|
||||||
|
|
||||||
/* check for special case and wrap around */
|
/* check for special case and wrap around */
|
||||||
if (iAvSpace < 0)
|
if ( iAvSpace < 0 )
|
||||||
|
{
|
||||||
iAvSpace += iMemSize; /* wrap around */
|
iAvSpace += iMemSize; /* wrap around */
|
||||||
else if ((iAvSpace == 0) && (eBufState == BS_EMPTY))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) )
|
||||||
|
{
|
||||||
iAvSpace = iMemSize;
|
iAvSpace = iMemSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return iAvSpace;
|
return iAvSpace;
|
||||||
}
|
}
|
||||||
|
@ -210,15 +249,22 @@ int CNetBuf::GetAvailData() const
|
||||||
int iAvData = iPutPos - iGetPos;
|
int iAvData = iPutPos - iGetPos;
|
||||||
|
|
||||||
/* check for special case and wrap around */
|
/* check for special case and wrap around */
|
||||||
if (iAvData < 0)
|
if ( iAvData < 0 )
|
||||||
|
{
|
||||||
iAvData += iMemSize; /* wrap around */
|
iAvData += iMemSize; /* wrap around */
|
||||||
else if ((iAvData == 0) && (eBufState == BS_FULL))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) )
|
||||||
|
{
|
||||||
iAvData = iMemSize;
|
iAvData = iMemSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return iAvData;
|
return iAvData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetBuf::Clear(const EClearType eClearType)
|
void CNetBuf::Clear ( const EClearType eClearType )
|
||||||
{
|
{
|
||||||
|
|
||||||
int iMiddleOfBuffer;
|
int iMiddleOfBuffer;
|
||||||
|
@ -229,21 +275,21 @@ void CNetBuf::Clear(const EClearType eClearType)
|
||||||
number of blocks, e.g.:
|
number of blocks, e.g.:
|
||||||
[buffer size]: [get pos]
|
[buffer size]: [get pos]
|
||||||
1: 0 / 2: 0 / 3: 1 / 4: 1 / ... */
|
1: 0 / 2: 0 / 3: 1 / 4: 1 / ... */
|
||||||
iMiddleOfBuffer = (((iMemSize - iBlockSize) / 2) / iBlockSize) * iBlockSize;
|
iMiddleOfBuffer = ( ( ( iMemSize - iBlockSize) / 2 ) / iBlockSize ) * iBlockSize;
|
||||||
#else
|
#else
|
||||||
// old code
|
// old code
|
||||||
|
|
||||||
// somehow the old code seems to work better than the sophisticated new one....?
|
// somehow the old code seems to work better than the sophisticated new one....?
|
||||||
/* 1: 0 / 2: 1 / 3: 1 / 4: 2 / ... */
|
/* 1: 0 / 2: 1 / 3: 1 / 4: 2 / ... */
|
||||||
iMiddleOfBuffer = ((iMemSize / 2) / iBlockSize) * iBlockSize;
|
iMiddleOfBuffer = ( ( iMemSize / 2 ) / iBlockSize ) * iBlockSize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* different behaviour for get and put corrections */
|
/* different behaviour for get and put corrections */
|
||||||
if (eClearType == CT_GET)
|
if ( eClearType == CT_GET )
|
||||||
{
|
{
|
||||||
/* clear buffer */
|
/* clear buffer */
|
||||||
vecdMemory.Reset(0.0);
|
vecdMemory.Reset ( 0.0 );
|
||||||
|
|
||||||
/* correct buffer so that after the current get operation the pointer
|
/* correct buffer so that after the current get operation the pointer
|
||||||
are at maximum distance */
|
are at maximum distance */
|
||||||
|
@ -251,11 +297,15 @@ void CNetBuf::Clear(const EClearType eClearType)
|
||||||
iGetPos = iMiddleOfBuffer;
|
iGetPos = iMiddleOfBuffer;
|
||||||
|
|
||||||
/* check for special case */
|
/* check for special case */
|
||||||
if (iPutPos == iGetPos)
|
if ( iPutPos == iGetPos )
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_FULL;
|
eBufState = CNetBuf::BS_FULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
eBufState = CNetBuf::BS_OK;
|
eBufState = CNetBuf::BS_OK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* in case of "put" correction, do not delete old data but only shift
|
/* in case of "put" correction, do not delete old data but only shift
|
||||||
|
@ -265,43 +315,45 @@ void CNetBuf::Clear(const EClearType eClearType)
|
||||||
/* adjust put pointer relative to current get pointer, take care of
|
/* adjust put pointer relative to current get pointer, take care of
|
||||||
wrap around */
|
wrap around */
|
||||||
iPutPos += iGetPos;
|
iPutPos += iGetPos;
|
||||||
if (iPutPos > iMemSize)
|
if ( iPutPos > iMemSize )
|
||||||
|
{
|
||||||
iPutPos -= iMemSize;
|
iPutPos -= iMemSize;
|
||||||
|
}
|
||||||
|
|
||||||
/* fade out old data right before new put pointer */
|
/* fade out old data right before new put pointer */
|
||||||
int iCurPos = iPutPos - iNumSamFading;
|
int iCurPos = iPutPos - iNumSamFading;
|
||||||
int i = iNumSamFading;
|
int i = iNumSamFading;
|
||||||
|
|
||||||
if (iCurPos < 0)
|
if ( iCurPos < 0 )
|
||||||
{
|
{
|
||||||
/* wrap around */
|
/* wrap around */
|
||||||
iCurPos += iMemSize;
|
iCurPos += iMemSize;
|
||||||
|
|
||||||
/* data must be processed in two steps because of wrap around */
|
/* data must be processed in two steps because of wrap around */
|
||||||
while (iCurPos < iMemSize)
|
while ( iCurPos < iMemSize )
|
||||||
{
|
{
|
||||||
vecdMemory[iCurPos++] *= ((double) i / iNumSamFading);
|
vecdMemory[iCurPos++] *= ( (double) i / iNumSamFading );
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iCurPos = 0; iCurPos < iPutPos; iCurPos++)
|
for ( iCurPos = 0; iCurPos < iPutPos; iCurPos++ )
|
||||||
{
|
{
|
||||||
vecdMemory[iCurPos] *= ((double) i / iNumSamFading);
|
vecdMemory[iCurPos] *= ( (double) i / iNumSamFading );
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* data can be processed in one step */
|
/* data can be processed in one step */
|
||||||
while (iCurPos < iPutPos)
|
while ( iCurPos < iPutPos )
|
||||||
{
|
{
|
||||||
vecdMemory[iCurPos++] *= ((double) i / iNumSamFading);
|
vecdMemory[iCurPos++] *= ( (double) i / iNumSamFading );
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for special case */
|
/* check for special case */
|
||||||
if (iPutPos == iGetPos)
|
if ( iPutPos == iGetPos )
|
||||||
{
|
{
|
||||||
eBufState = CNetBuf::BS_EMPTY;
|
eBufState = CNetBuf::BS_EMPTY;
|
||||||
}
|
}
|
||||||
|
@ -312,30 +364,30 @@ void CNetBuf::Clear(const EClearType eClearType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetBuf::FadeInAudioDataBlock(CVector<double>& vecdData)
|
void CNetBuf::FadeInAudioDataBlock ( CVector<double>& vecdData )
|
||||||
{
|
{
|
||||||
/* apply linear fading */
|
/* apply linear fading */
|
||||||
for (int i = 0; i < iNumSamFading; i++)
|
for ( int i = 0; i < iNumSamFading; i++ )
|
||||||
{
|
{
|
||||||
vecdData[i] *= ((double) i / iNumSamFading);
|
vecdData[i] *= ( (double) i / iNumSamFading );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset flag */
|
/* reset flag */
|
||||||
bFadeInNewPutData = false;
|
bFadeInNewPutData = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetBuf::FadeOutExtrapolateAudioDataBlock(CVector<double>& vecdData,
|
void CNetBuf::FadeOutExtrapolateAudioDataBlock ( CVector<double>& vecdData,
|
||||||
const double dExPDiff,
|
const double dExPDiff,
|
||||||
const double dExPLastV)
|
const double dExPLastV )
|
||||||
{
|
{
|
||||||
/* apply linear extrapolation and linear fading */
|
/* apply linear extrapolation and linear fading */
|
||||||
for (int i = 0; i < iNumSamFadingExtra; i++)
|
for ( int i = 0; i < iNumSamFadingExtra; i++ )
|
||||||
{
|
{
|
||||||
/* calculate extrapolated value */
|
/* calculate extrapolated value */
|
||||||
vecdData[i] = ((i + 1) * dExPDiff + dExPLastV);
|
vecdData[i] = ( ( i + 1 ) * dExPDiff + dExPLastV );
|
||||||
|
|
||||||
/* linear fading */
|
/* linear fading */
|
||||||
vecdData[i] *= ((double) (iNumSamFadingExtra - i) / iNumSamFadingExtra);
|
vecdData[i] *= ( (double) ( iNumSamFadingExtra - i ) / iNumSamFadingExtra );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,12 +400,12 @@ void CConvBuf::Init ( const int iNewMemSize )
|
||||||
iMemSize = iNewMemSize;
|
iMemSize = iNewMemSize;
|
||||||
|
|
||||||
/* allocate and clear memory for actual data buffer */
|
/* allocate and clear memory for actual data buffer */
|
||||||
vecsMemory.Init(iMemSize);
|
vecsMemory.Init ( iMemSize );
|
||||||
|
|
||||||
iPutPos = 0;
|
iPutPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CConvBuf::Put ( const CVector<short>& vecsData)
|
bool CConvBuf::Put ( const CVector<short>& vecsData )
|
||||||
{
|
{
|
||||||
const int iVecSize = vecsData.Size();
|
const int iVecSize = vecsData.Size();
|
||||||
|
|
||||||
|
|
44
src/buffer.h
44
src/buffer.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_)
|
#if !defined ( BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_ )
|
||||||
#define BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_
|
#define BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -30,12 +30,12 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* time for fading effect for masking drop outs */
|
// time for fading effect for masking drop outs
|
||||||
#define FADE_IN_OUT_TIME ((double) 0.3) /* ms */
|
#define FADE_IN_OUT_TIME ( (double) 0.3 ) // ms
|
||||||
#define FADE_IN_OUT_NUM_SAM ((int) (SAMPLE_RATE * FADE_IN_OUT_TIME) / 1000)
|
#define FADE_IN_OUT_NUM_SAM ( (int) ( SAMPLE_RATE * FADE_IN_OUT_TIME ) / 1000 )
|
||||||
|
|
||||||
/* for extrapolation a shorter time for fading */
|
// for extrapolation a shorter time for fading
|
||||||
#define FADE_IN_OUT_NUM_SAM_EXTRA 5 /* samples */
|
#define FADE_IN_OUT_NUM_SAM_EXTRA 5 // samples
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
|
@ -45,21 +45,21 @@ public:
|
||||||
CNetBuf() {}
|
CNetBuf() {}
|
||||||
virtual ~CNetBuf() {}
|
virtual ~CNetBuf() {}
|
||||||
|
|
||||||
void Init(const int iNewBlockSize, const int iNewNumBlocks);
|
void Init ( const int iNewBlockSize, const int iNewNumBlocks );
|
||||||
int GetSize() {return iMemSize / iBlockSize;}
|
int GetSize() { return iMemSize / iBlockSize; }
|
||||||
|
|
||||||
bool Put(CVector<double>& vecdData);
|
bool Put ( CVector<double>& vecdData );
|
||||||
bool Get(CVector<double>& vecdData);
|
bool Get ( CVector<double>& vecdData );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum EBufState {BS_OK, BS_FULL, BS_EMPTY};
|
enum EBufState { BS_OK, BS_FULL, BS_EMPTY };
|
||||||
enum EClearType {CT_PUT, CT_GET};
|
enum EClearType { CT_PUT, CT_GET };
|
||||||
void Clear(const EClearType eClearType);
|
void Clear ( const EClearType eClearType );
|
||||||
int GetAvailSpace() const;
|
int GetAvailSpace() const;
|
||||||
int GetAvailData() const;
|
int GetAvailData() const;
|
||||||
void FadeInAudioDataBlock(CVector<double>& vecdData);
|
void FadeInAudioDataBlock ( CVector<double>& vecdData );
|
||||||
void FadeOutExtrapolateAudioDataBlock(CVector<double>& vecdData,
|
void FadeOutExtrapolateAudioDataBlock ( CVector<double>& vecdData,
|
||||||
const double dExPDiff, const double dExPLastV);
|
const double dExPDiff, const double dExPLastV );
|
||||||
|
|
||||||
CVector<double> vecdMemory;
|
CVector<double> vecdMemory;
|
||||||
int iMemSize;
|
int iMemSize;
|
||||||
|
@ -70,24 +70,24 @@ protected:
|
||||||
int iNumSamFading;
|
int iNumSamFading;
|
||||||
int iNumSamFadingExtra;
|
int iNumSamFadingExtra;
|
||||||
|
|
||||||
/* extrapolation parameters */
|
// extrapolation parameters
|
||||||
double dExPDiff;
|
double dExPDiff;
|
||||||
double dExPLastV;
|
double dExPLastV;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* conversion buffer (very simple buffer) */
|
// conversion buffer (very simple buffer)
|
||||||
class CConvBuf
|
class CConvBuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CConvBuf () {}
|
CConvBuf() {}
|
||||||
virtual ~CConvBuf () {}
|
virtual ~CConvBuf() {}
|
||||||
|
|
||||||
void Init ( const int iNewMemSize );
|
void Init ( const int iNewMemSize );
|
||||||
int GetSize() { return iMemSize; }
|
int GetSize() { return iMemSize; }
|
||||||
|
|
||||||
bool Put ( const CVector<short>& vecsData );
|
bool Put ( const CVector<short>& vecsData );
|
||||||
CVector<short> Get ();
|
CVector<short> Get();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CVector<short> vecsMemory;
|
CVector<short> vecsMemory;
|
||||||
|
@ -97,4 +97,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_) */
|
#endif /* !defined ( BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_)
|
#if !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
|
||||||
#define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
#define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
||||||
|
|
||||||
// no valid channel number
|
// no valid channel number
|
||||||
#define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1)
|
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
|
||||||
|
|
||||||
enum EPutDataStat
|
enum EPutDataStat
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
||||||
bool GetAddress ( CHostAddress& RetAddr );
|
bool GetAddress ( CHostAddress& RetAddr );
|
||||||
CHostAddress GetAddress () { return InetAddr; }
|
CHostAddress GetAddress() { return InetAddr; }
|
||||||
|
|
||||||
void SetName ( const std::string sNNa ) { sName = sNNa; }
|
void SetName ( const std::string sNNa ) { sName = sNNa; }
|
||||||
std::string GetName() { return sName; }
|
std::string GetName() { return sName; }
|
||||||
|
@ -317,4 +317,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_) */
|
#endif /* !defined ( CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
|
||||||
|
|
22
src/client.h
22
src/client.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_)
|
#if !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
||||||
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
// tell the server that size has changed
|
// tell the server that size has changed
|
||||||
Channel.CreateJitBufMes ( iNumBlocks );
|
Channel.CreateJitBufMes ( iNumBlocks );
|
||||||
}
|
}
|
||||||
int GetSockBufSize() { return Channel.GetSockBufSize (); }
|
int GetSockBufSize() { return Channel.GetSockBufSize(); }
|
||||||
|
|
||||||
|
|
||||||
void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn )
|
void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn )
|
||||||
|
@ -126,9 +126,9 @@ public:
|
||||||
std::string strName;
|
std::string strName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void run ();
|
virtual void run();
|
||||||
|
|
||||||
/* only one channel is needed for client application */
|
// only one channel is needed for client application
|
||||||
CChannel Channel;
|
CChannel Channel;
|
||||||
|
|
||||||
CSocket Socket;
|
CSocket Socket;
|
||||||
|
@ -158,13 +158,13 @@ protected:
|
||||||
|
|
||||||
CVector<short> vecsNetwork;
|
CVector<short> vecsNetwork;
|
||||||
|
|
||||||
/* resample objects */
|
// resample objects
|
||||||
CAudioResample ResampleObjDownL; /* left channel */
|
CAudioResample ResampleObjDownL; // left channel
|
||||||
CAudioResample ResampleObjDownR; /* right channel */
|
CAudioResample ResampleObjDownR; // right channel
|
||||||
CAudioResample ResampleObjUpL; /* left channel */
|
CAudioResample ResampleObjUpL; // left channel
|
||||||
CAudioResample ResampleObjUpR; /* right channel */
|
CAudioResample ResampleObjUpR; // right channel
|
||||||
|
|
||||||
/* debugging, evaluating */
|
// debugging, evaluating
|
||||||
CMovingAv<double> RespTimeMoAvBuf;
|
CMovingAv<double> RespTimeMoAvBuf;
|
||||||
QTime TimeLastBlock;
|
QTime TimeLastBlock;
|
||||||
|
|
||||||
|
@ -179,4 +179,4 @@ signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_) */
|
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -35,133 +35,133 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
|
|
||||||
/* init slider controls --- */
|
/* init slider controls --- */
|
||||||
/* sound buffer in */
|
/* sound buffer in */
|
||||||
SliderSndBufIn->setRange(2, AUD_SLIDER_LENGTH);
|
SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||||
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
|
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
|
||||||
SliderSndBufIn->setValue(iCurNumInBuf);
|
SliderSndBufIn->setValue ( iCurNumInBuf );
|
||||||
TextSndBufIn->setText("In: " + QString().setNum(iCurNumInBuf));
|
TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) );
|
||||||
|
|
||||||
/* sound buffer out */
|
/* sound buffer out */
|
||||||
SliderSndBufOut->setRange(2, AUD_SLIDER_LENGTH);
|
SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||||
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
|
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
|
||||||
SliderSndBufOut->setValue(iCurNumOutBuf);
|
SliderSndBufOut->setValue ( iCurNumOutBuf );
|
||||||
TextSndBufOut->setText("Out: " + QString().setNum(iCurNumOutBuf));
|
TextSndBufOut->setText ( "Out: " + QString().setNum ( iCurNumOutBuf ) );
|
||||||
|
|
||||||
/* network buffer */
|
/* network buffer */
|
||||||
SliderNetBuf->setRange(0, MAX_NET_BUF_SIZE_NUM_BL);
|
SliderNetBuf->setRange ( 0, MAX_NET_BUF_SIZE_NUM_BL );
|
||||||
const int iCurNumNetBuf = pClient->GetSockBufSize();
|
const int iCurNumNetBuf = pClient->GetSockBufSize();
|
||||||
SliderNetBuf->setValue(iCurNumNetBuf);
|
SliderNetBuf->setValue ( iCurNumNetBuf );
|
||||||
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));
|
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
|
||||||
|
|
||||||
/* network buffer size factor in */
|
/* network buffer size factor in */
|
||||||
SliderNetBufSiFactIn->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
|
SliderNetBufSiFactIn->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR );
|
||||||
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
|
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
|
||||||
SliderNetBufSiFactIn->setValue(iCurNetBufSiFactIn);
|
SliderNetBufSiFactIn->setValue ( iCurNetBufSiFactIn );
|
||||||
TextNetBufSiFactIn->setText("In:\n" + QString().setNum(
|
TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum (
|
||||||
double(iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
double ( iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS ), 'f', 2 ) +
|
||||||
" ms");
|
" ms" );
|
||||||
|
|
||||||
/* network buffer size factor out */
|
/* network buffer size factor out */
|
||||||
SliderNetBufSiFactOut->setRange(1, MAX_NET_BLOCK_SIZE_FACTOR);
|
SliderNetBufSiFactOut->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR );
|
||||||
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
|
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
|
||||||
SliderNetBufSiFactOut->setValue(iCurNetBufSiFactOut);
|
SliderNetBufSiFactOut->setValue ( iCurNetBufSiFactOut );
|
||||||
TextNetBufSiFactOut->setText("Out:\n" + QString().setNum(
|
TextNetBufSiFactOut->setText ( "Out:\n" + QString().setNum (
|
||||||
double(iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
double ( iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2 ) +
|
||||||
" ms");
|
" ms" );
|
||||||
|
|
||||||
|
|
||||||
/* connections ---------------------------------------------------------- */
|
/* connections ---------------------------------------------------------- */
|
||||||
/* timers */
|
/* timers */
|
||||||
QObject::connect(&TimerStatus, SIGNAL(timeout()),
|
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerStatus()));
|
this, SLOT ( OnTimerStatus() ) );
|
||||||
|
|
||||||
/* sliders */
|
/* sliders */
|
||||||
QObject::connect(SliderSndBufIn, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderSndBufInChange(int)));
|
this, SLOT ( OnSliderSndBufInChange ( int ) ) );
|
||||||
QObject::connect(SliderSndBufOut, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderSndBufOut, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderSndBufOutChange(int)));
|
this, SLOT ( OnSliderSndBufOutChange ( int ) ) );
|
||||||
|
|
||||||
QObject::connect(SliderNetBuf, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderNetBuf(int)));
|
this, SLOT ( OnSliderNetBuf ( int ) ) );
|
||||||
|
|
||||||
QObject::connect(SliderNetBufSiFactIn, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderNetBufSiFactIn, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderNetBufSiFactIn(int)));
|
this, SLOT ( OnSliderNetBufSiFactIn ( int ) ) );
|
||||||
QObject::connect(SliderNetBufSiFactOut, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderNetBufSiFactOut, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderNetBufSiFactOut(int)));
|
this, SLOT ( OnSliderNetBufSiFactOut ( int ) ) );
|
||||||
|
|
||||||
|
|
||||||
/* timers --------------------------------------------------------------- */
|
/* timers --------------------------------------------------------------- */
|
||||||
/* start timer for status bar */
|
/* start timer for status bar */
|
||||||
TimerStatus.start(DISPLAY_UPDATE_TIME);
|
TimerStatus.start ( DISPLAY_UPDATE_TIME );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderSndBufInChange(int value)
|
void CClientSettingsDlg::OnSliderSndBufInChange ( int value )
|
||||||
{
|
{
|
||||||
pClient->GetSndInterface()->SetInNumBuf(value);
|
pClient->GetSndInterface()->SetInNumBuf ( value );
|
||||||
TextSndBufIn->setText("In: " + QString().setNum(value));
|
TextSndBufIn->setText ( "In: " + QString().setNum ( value ) );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderSndBufOutChange(int value)
|
void CClientSettingsDlg::OnSliderSndBufOutChange ( int value )
|
||||||
{
|
{
|
||||||
pClient->GetSndInterface()->SetOutNumBuf(value);
|
pClient->GetSndInterface()->SetOutNumBuf ( value );
|
||||||
TextSndBufOut->setText("Out: " + QString().setNum(value));
|
TextSndBufOut->setText ( "Out: " + QString().setNum ( value ) );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderNetBuf(int value)
|
void CClientSettingsDlg::OnSliderNetBuf ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetSockBufSize ( value );
|
pClient->SetSockBufSize ( value );
|
||||||
TextNetBuf->setText("Size: " + QString().setNum(value));
|
TextNetBuf->setText ( "Size: " + QString().setNum ( value ) );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderNetBufSiFactIn(int value)
|
void CClientSettingsDlg::OnSliderNetBufSiFactIn ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetNetwBufSizeFactIn ( value );
|
pClient->SetNetwBufSizeFactIn ( value );
|
||||||
TextNetBufSiFactIn->setText("In:\n" + QString().setNum(
|
TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum (
|
||||||
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
double ( value * MIN_BLOCK_DURATION_MS ), 'f', 2 ) +
|
||||||
" ms");
|
" ms" );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnSliderNetBufSiFactOut(int value)
|
void CClientSettingsDlg::OnSliderNetBufSiFactOut ( int value )
|
||||||
{
|
{
|
||||||
pClient->SetNetwBufSizeFactOut ( value );
|
pClient->SetNetwBufSizeFactOut ( value );
|
||||||
TextNetBufSiFactOut->setText("Out:\n" + QString().setNum(
|
TextNetBufSiFactOut->setText ( "Out:\n" + QString().setNum (
|
||||||
double(value * MIN_BLOCK_DURATION_MS), 'f', 2) +
|
double ( value * MIN_BLOCK_DURATION_MS ), 'f', 2 ) +
|
||||||
" ms");
|
" ms" );
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::UpdateDisplay()
|
void CClientSettingsDlg::UpdateDisplay()
|
||||||
{
|
{
|
||||||
/* response time */
|
/* response time */
|
||||||
TextLabelStdDevTimer->setText(QString().
|
TextLabelStdDevTimer->setText ( QString().
|
||||||
setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms");
|
setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
|
void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
|
||||||
{
|
{
|
||||||
switch(iMessType)
|
switch ( iMessType )
|
||||||
{
|
{
|
||||||
case MS_SOUND_IN:
|
case MS_SOUND_IN:
|
||||||
CLEDSoundIn->SetLight(iStatus);
|
CLEDSoundIn->SetLight ( iStatus );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MS_SOUND_OUT:
|
case MS_SOUND_OUT:
|
||||||
CLEDSoundOut->SetLight(iStatus);
|
CLEDSoundOut->SetLight ( iStatus );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MS_JIT_BUF_PUT:
|
case MS_JIT_BUF_PUT:
|
||||||
CLEDNetwPut->SetLight(iStatus);
|
CLEDNetwPut->SetLight ( iStatus );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MS_JIT_BUF_GET:
|
case MS_JIT_BUF_GET:
|
||||||
CLEDNetwGet->SetLight(iStatus);
|
CLEDNetwGet->SetLight ( iStatus );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MS_PROTOCOL:
|
case MS_PROTOCOL:
|
||||||
CLEDProtocolStatus->SetLight(iStatus);
|
CLEDProtocolStatus->SetLight ( iStatus );
|
||||||
|
|
||||||
case MS_RESET_ALL:
|
case MS_RESET_ALL:
|
||||||
CLEDSoundIn->Reset();
|
CLEDSoundIn->Reset();
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* update time for GUI controls */
|
// update time for GUI controls
|
||||||
#define DISPLAY_UPDATE_TIME 1000 /* ms */
|
#define DISPLAY_UPDATE_TIME 1000 // ms
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
|
|
56
src/global.h
56
src/global.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_)
|
#if !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ )
|
||||||
#define GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_
|
#define GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -36,11 +36,11 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* define this macro to get debug output */
|
// define this macro to get debug output
|
||||||
#define _DEBUG_
|
#define _DEBUG_
|
||||||
#undef _DEBUG_
|
#undef _DEBUG_
|
||||||
|
|
||||||
/* version and application name (always use this version) */
|
// version and application name (always use this version)
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
#define VERSION "1.0cvs"
|
#define VERSION "1.0cvs"
|
||||||
#define APP_NAME "llcon"
|
#define APP_NAME "llcon"
|
||||||
|
@ -68,14 +68,14 @@
|
||||||
// maximum value of factor for network block size
|
// maximum value of factor for network block size
|
||||||
#define MAX_NET_BLOCK_SIZE_FACTOR 8
|
#define MAX_NET_BLOCK_SIZE_FACTOR 8
|
||||||
|
|
||||||
/* default network block size factor */
|
// default network block size factor
|
||||||
#define DEF_NET_BLOCK_SIZE_FACTOR 3
|
#define DEF_NET_BLOCK_SIZE_FACTOR 3
|
||||||
|
|
||||||
/* maximum network buffer size (which can be chosen by slider) */
|
// maximum network buffer size (which can be chosen by slider)
|
||||||
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */
|
#define MAX_NET_BUF_SIZE_NUM_BL 10 // number of blocks
|
||||||
|
|
||||||
/* default network buffer size */
|
// default network buffer size
|
||||||
#define DEF_NET_BUF_SIZE_NUM_BL 5 /* number of blocks */
|
#define DEF_NET_BUF_SIZE_NUM_BL 5 // number of blocks
|
||||||
|
|
||||||
// number of ticks of audio in/out buffer sliders
|
// number of ticks of audio in/out buffer sliders
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -88,26 +88,26 @@
|
||||||
// if you want to change this paramter, there has to be done code modifications
|
// if you want to change this paramter, there has to be done code modifications
|
||||||
// on other places, too! The code tag "MAX_NUM_CHANNELS_TAG" shows these places
|
// on other places, too! The code tag "MAX_NUM_CHANNELS_TAG" shows these places
|
||||||
// (just search for the tag in the entire code)
|
// (just search for the tag in the entire code)
|
||||||
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
#define MAX_NUM_CHANNELS 10 // max number channels for server
|
||||||
|
|
||||||
/* sample rate offset estimation algorithm */
|
// sample rate offset estimation algorithm
|
||||||
/* time interval for sample rate offset estimation */
|
// time interval for sample rate offset estimation
|
||||||
#define TIME_INT_SAM_OFFS_EST 60 /* s */
|
#define TIME_INT_SAM_OFFS_EST 60 // s
|
||||||
|
|
||||||
/* time interval of taps for sample rate offset estimation (time stamps) */
|
// time interval of taps for sample rate offset estimation (time stamps)
|
||||||
#define INTVL_TAPS_SAM_OFF_SET 1 /* s */
|
#define INTVL_TAPS_SAM_OFF_SET 1 // s
|
||||||
|
|
||||||
#define NUM_BL_TIME_STAMPS ( ( INTVL_TAPS_SAM_OFF_SET * 1000 ) / MIN_BLOCK_DURATION_MS )
|
#define NUM_BL_TIME_STAMPS ( ( INTVL_TAPS_SAM_OFF_SET * 1000 ) / MIN_BLOCK_DURATION_MS )
|
||||||
#define VEC_LEN_SAM_OFFS_EST ( TIME_INT_SAM_OFFS_EST / INTVL_TAPS_SAM_OFF_SET )
|
#define VEC_LEN_SAM_OFFS_EST ( TIME_INT_SAM_OFFS_EST / INTVL_TAPS_SAM_OFF_SET )
|
||||||
|
|
||||||
/* length of the moving average buffer for response time measurement */
|
// length of the moving average buffer for response time measurement
|
||||||
#define TIME_MOV_AV_RESPONSE 30 /* seconds */
|
#define TIME_MOV_AV_RESPONSE 30 // seconds
|
||||||
#define LEN_MOV_AV_RESPONSE (TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS)
|
#define LEN_MOV_AV_RESPONSE ( TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS )
|
||||||
|
|
||||||
|
|
||||||
#define _MAXSHORT 32767
|
#define _MAXSHORT 32767
|
||||||
#define _MAXBYTE 255 /* binary: 11111111 */
|
#define _MAXBYTE 255 // binary: 11111111
|
||||||
#define _MINSHORT (-32768)
|
#define _MINSHORT ( -32768 )
|
||||||
|
|
||||||
#if HAVE_STDINT_H
|
#if HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
|
@ -126,7 +126,7 @@ typedef unsigned char uint8_t;
|
||||||
|
|
||||||
/* Definitions for window message system ------------------------------------ */
|
/* Definitions for window message system ------------------------------------ */
|
||||||
typedef unsigned int _MESSAGE_IDENT;
|
typedef unsigned int _MESSAGE_IDENT;
|
||||||
#define MS_RESET_ALL 0 /* MS: Message */
|
#define MS_RESET_ALL 0 // MS: Message
|
||||||
#define MS_SOUND_IN 1
|
#define MS_SOUND_IN 1
|
||||||
#define MS_SOUND_OUT 2
|
#define MS_SOUND_OUT 2
|
||||||
#define MS_JIT_BUF_PUT 3
|
#define MS_JIT_BUF_PUT 3
|
||||||
|
@ -143,16 +143,16 @@ typedef unsigned int _MESSAGE_IDENT;
|
||||||
class CGenErr
|
class CGenErr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CGenErr(QString strNE) : strError(strNE) {}
|
CGenErr ( QString strNE ) : strError ( strNE ) {}
|
||||||
QString strError;
|
QString strError;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CLlconEvent : public QCustomEvent
|
class CLlconEvent : public QCustomEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CLlconEvent(int iNewMeTy, int iNewSt, int iNewChN = 0) :
|
CLlconEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) :
|
||||||
QCustomEvent(QEvent::User + 11), iMessType(iNewMeTy), iStatus(iNewSt),
|
QCustomEvent ( QEvent::User + 11 ), iMessType ( iNewMeTy ), iStatus ( iNewSt ),
|
||||||
iChanNum(iNewChN) {}
|
iChanNum ( iNewChN ) {}
|
||||||
|
|
||||||
int iMessType;
|
int iMessType;
|
||||||
int iStatus;
|
int iStatus;
|
||||||
|
@ -161,9 +161,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes for global functions ********************************************/
|
/* Prototypes for global functions ********************************************/
|
||||||
/* Posting a window message */
|
// posting a window message
|
||||||
void PostWinMessage(const _MESSAGE_IDENT MessID, const int iMessageParam = 0,
|
void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam = 0,
|
||||||
const int iChanNum = 0);
|
const int iChanNum = 0 );
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_) */
|
#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */
|
||||||
|
|
|
@ -27,38 +27,38 @@
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
const char* name, bool modal, WFlags f) : pClient ( pNCliP ),
|
const char* name, bool modal, WFlags f ) : pClient ( pNCliP ),
|
||||||
CLlconClientDlgBase ( parent, name, modal, f ),
|
CLlconClientDlgBase ( parent, name, modal, f ),
|
||||||
ClientSettingsDlg ( pNCliP, 0, 0, FALSE, Qt::WStyle_MinMax )
|
ClientSettingsDlg ( pNCliP, 0, 0, FALSE, Qt::WStyle_MinMax )
|
||||||
{
|
{
|
||||||
/* add help text to controls */
|
/* add help text to controls */
|
||||||
QString strInpLevH = tr("<b>Input level meter:</b> Shows the level of the "
|
QString strInpLevH = tr ( "<b>Input level meter:</b> Shows the level of the "
|
||||||
"input audio signal of the sound card. The level is in dB. Overload "
|
"input audio signal of the sound card. The level is in dB. Overload "
|
||||||
"should be avoided.");
|
"should be avoided." );
|
||||||
QWhatsThis::add(TextLabelInputLevel, strInpLevH);
|
QWhatsThis::add ( TextLabelInputLevel, strInpLevH );
|
||||||
QWhatsThis::add(ProgressBarInputLevelL, strInpLevH);
|
QWhatsThis::add ( ProgressBarInputLevelL, strInpLevH );
|
||||||
QWhatsThis::add(ProgressBarInputLevelR, strInpLevH);
|
QWhatsThis::add ( ProgressBarInputLevelR, strInpLevH );
|
||||||
|
|
||||||
QWhatsThis::add(PushButtonConnect, tr("<b>Connect / Disconnect Button:"
|
QWhatsThis::add(PushButtonConnect, tr ( "<b>Connect / Disconnect Button:"
|
||||||
"</b> Push this button to connect the server. A valid IP address has "
|
"</b> Push this button to connect the server. A valid IP address has "
|
||||||
"to be specified before. If the client is connected, pressing this "
|
"to be specified before. If the client is connected, pressing this "
|
||||||
"button will disconnect the connection."));
|
"button will disconnect the connection." ) );
|
||||||
|
|
||||||
QWhatsThis::add(TextLabelStatus, tr("<b>Status Bar:</b> In the status bar "
|
QWhatsThis::add(TextLabelStatus, tr ( "<b>Status Bar:</b> In the status bar "
|
||||||
"different messages are displayed. E.g., if an error occurred or the "
|
"different messages are displayed. E.g., if an error occurred or the "
|
||||||
"status of the connection is shown."));
|
"status of the connection is shown." ) );
|
||||||
|
|
||||||
QString strServAddrH = tr("<b>Server Address:</b> In this edit control, "
|
QString strServAddrH = tr ( "<b>Server Address:</b> In this edit control, "
|
||||||
"the IP address of the server can be set. If an invalid address was "
|
"the IP address of the server can be set. If an invalid address was "
|
||||||
"chosen, an error message is shown in the status bar.");
|
"chosen, an error message is shown in the status bar." );
|
||||||
QWhatsThis::add(TextLabelServerAddr, strServAddrH);
|
QWhatsThis::add ( TextLabelServerAddr, strServAddrH );
|
||||||
QWhatsThis::add(LineEditServerAddr, strServAddrH);
|
QWhatsThis::add ( LineEditServerAddr, strServAddrH );
|
||||||
|
|
||||||
QString strFaderTag = tr("<b>Fader Tag:</b> In this edit control, "
|
QString strFaderTag = tr ( "<b>Fader Tag:</b> In this edit control, "
|
||||||
"the tag string of your fader can be set. This tag will appear "
|
"the tag string of your fader can be set. This tag will appear "
|
||||||
"at your fader on the mixer board when connected to the server.");
|
"at your fader on the mixer board when connected to the server.");
|
||||||
QWhatsThis::add(TextLabelServerTag, strFaderTag);
|
QWhatsThis::add ( TextLabelServerTag, strFaderTag );
|
||||||
QWhatsThis::add(LineEditFaderTag, strFaderTag);
|
QWhatsThis::add ( LineEditFaderTag, strFaderTag );
|
||||||
|
|
||||||
QString strAudFader = tr ( "<b>Audio Fader:</b> With the audio fader "
|
QString strAudFader = tr ( "<b>Audio Fader:</b> With the audio fader "
|
||||||
"control the level of left and right audio input channels can "
|
"control the level of left and right audio input channels can "
|
||||||
|
@ -160,26 +160,26 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
|
|
||||||
// connections -------------------------------------------------------------
|
// connections -------------------------------------------------------------
|
||||||
// push-buttons
|
// push-buttons
|
||||||
QObject::connect(PushButtonConnect, SIGNAL(clicked()),
|
QObject::connect ( PushButtonConnect, SIGNAL ( clicked() ),
|
||||||
this, SLOT(OnConnectDisconBut()));
|
this, SLOT ( OnConnectDisconBut() ) );
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
QObject::connect(&TimerSigMet, SIGNAL(timeout()),
|
QObject::connect ( &TimerSigMet, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerSigMet()));
|
this, SLOT ( OnTimerSigMet() ) );
|
||||||
QObject::connect(&TimerStatus, SIGNAL(timeout()),
|
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerStatus()));
|
this, SLOT ( OnTimerStatus() ) );
|
||||||
|
|
||||||
// sliders
|
// sliders
|
||||||
QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderAudInFader, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderAudInFader(int)));
|
this, SLOT ( OnSliderAudInFader ( int ) ) );
|
||||||
QObject::connect(SliderAudReverb, SIGNAL(valueChanged(int)),
|
QObject::connect ( SliderAudReverb, SIGNAL ( valueChanged ( int ) ),
|
||||||
this, SLOT(OnSliderAudReverb(int)));
|
this, SLOT ( OnSliderAudReverb ( int ) ) );
|
||||||
|
|
||||||
// radio buttons
|
// radio buttons
|
||||||
QObject::connect(RadioButtonRevSelL, SIGNAL(clicked()),
|
QObject::connect ( RadioButtonRevSelL, SIGNAL ( clicked() ),
|
||||||
this, SLOT(OnRevSelL()));
|
this, SLOT ( OnRevSelL() ) );
|
||||||
QObject::connect(RadioButtonRevSelR, SIGNAL(clicked()),
|
QObject::connect ( RadioButtonRevSelR, SIGNAL ( clicked() ),
|
||||||
this, SLOT(OnRevSelR()));
|
this, SLOT ( OnRevSelR() ) );
|
||||||
|
|
||||||
// line edits
|
// line edits
|
||||||
QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ),
|
QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ),
|
||||||
|
@ -195,13 +195,13 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
|
|
||||||
// timers ------------------------------------------------------------------
|
// timers ------------------------------------------------------------------
|
||||||
// start timer for status bar
|
// start timer for status bar
|
||||||
TimerStatus.start(STATUSBAR_UPDATE_TIME);
|
TimerStatus.start ( STATUSBAR_UPDATE_TIME );
|
||||||
}
|
}
|
||||||
|
|
||||||
CLlconClientDlg::~CLlconClientDlg()
|
CLlconClientDlg::~CLlconClientDlg()
|
||||||
{
|
{
|
||||||
/* if connected, terminate connection */
|
/* if connected, terminate connection */
|
||||||
if (pClient->IsRunning())
|
if ( pClient->IsRunning() )
|
||||||
{
|
{
|
||||||
pClient->Stop();
|
pClient->Stop();
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,8 @@ void CLlconClientDlg::customEvent ( QCustomEvent* Event )
|
||||||
{
|
{
|
||||||
if ( Event->type() == QEvent::User + 11 )
|
if ( Event->type() == QEvent::User + 11 )
|
||||||
{
|
{
|
||||||
const int iMessType = ( (CLlconEvent*) Event ) ->iMessType;
|
const int iMessType = ( (CLlconEvent*) Event )->iMessType;
|
||||||
const int iStatus = ( (CLlconEvent*) Event ) ->iStatus;
|
const int iStatus = ( (CLlconEvent*) Event )->iStatus;
|
||||||
|
|
||||||
switch ( iMessType )
|
switch ( iMessType )
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,20 +46,20 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* text strings for connection button for connect and disconnect */
|
// text strings for connection button for connect and disconnect
|
||||||
#define CON_BUT_CONNECTTEXT "C&onnect"
|
#define CON_BUT_CONNECTTEXT "C&onnect"
|
||||||
#define CON_BUT_DISCONNECTTEXT "D&isconnect"
|
#define CON_BUT_DISCONNECTTEXT "D&isconnect"
|
||||||
|
|
||||||
/* steps for input level meter */
|
// steps for input level meter
|
||||||
#define NUM_STEPS_INP_LEV_METER 100
|
#define NUM_STEPS_INP_LEV_METER 100
|
||||||
|
|
||||||
/* update time for GUI controls */
|
// update time for GUI controls
|
||||||
#define LEVELMETER_UPDATE_TIME 100 /* ms */
|
#define LEVELMETER_UPDATE_TIME 100 // ms
|
||||||
#define STATUSBAR_UPDATE_TIME 1000 /* ms */
|
#define STATUSBAR_UPDATE_TIME 1000 // ms
|
||||||
|
|
||||||
/* range for signal level meter */
|
// range for signal level meter
|
||||||
#define LOW_BOUND_SIG_METER ( -50.0 ) /* dB */
|
#define LOW_BOUND_SIG_METER ( -50.0 ) // dB
|
||||||
#define UPPER_BOUND_SIG_METER ( 0.0 ) /* dB */
|
#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
CLlconClientDlg ( CClient* pNCliP, QWidget* parent = 0,
|
CLlconClientDlg ( CClient* pNCliP, QWidget* parent = 0,
|
||||||
const char* name = 0, bool modal = FALSE, WFlags f = 0 );
|
const char* name = 0, bool modal = FALSE, WFlags f = 0 );
|
||||||
|
|
||||||
virtual ~CLlconClientDlg ();
|
virtual ~CLlconClientDlg();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CClient* pClient;
|
CClient* pClient;
|
||||||
|
|
|
@ -67,36 +67,36 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent,
|
||||||
/* insert items in reverse order because in Windows all of them are
|
/* insert items in reverse order because in Windows all of them are
|
||||||
always visible -> put first item on the top */
|
always visible -> put first item on the top */
|
||||||
vecpListViewItems.Init(MAX_NUM_CHANNELS);
|
vecpListViewItems.Init(MAX_NUM_CHANNELS);
|
||||||
for (int i = MAX_NUM_CHANNELS - 1; i >= 0; i--)
|
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
vecpListViewItems[i] = new CServerListViewItem(ListViewClients);
|
vecpListViewItems[i] = new CServerListViewItem ( ListViewClients );
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
vecpListViewItems[i]->setVisible(false);
|
vecpListViewItems[i]->setVisible ( false );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init timing jitter text label */
|
/* Init timing jitter text label */
|
||||||
TextLabelResponseTime->setText("");
|
TextLabelResponseTime->setText ( "" );
|
||||||
|
|
||||||
|
|
||||||
/* Main menu bar -------------------------------------------------------- */
|
/* Main menu bar -------------------------------------------------------- */
|
||||||
pMenu = new QMenuBar(this);
|
pMenu = new QMenuBar ( this );
|
||||||
CHECK_PTR(pMenu);
|
CHECK_PTR ( pMenu );
|
||||||
pMenu->insertItem(tr("&?"), new CLlconHelpMenu(this));
|
pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) );
|
||||||
pMenu->setSeparator(QMenuBar::InWindowsStyle);
|
pMenu->setSeparator ( QMenuBar::InWindowsStyle );
|
||||||
|
|
||||||
/* Now tell the layout about the menu */
|
/* Now tell the layout about the menu */
|
||||||
CLlconServerDlgBaseLayout->setMenuBar(pMenu);
|
CLlconServerDlgBaseLayout->setMenuBar ( pMenu );
|
||||||
|
|
||||||
|
|
||||||
/* connections ---------------------------------------------------------- */
|
/* connections ---------------------------------------------------------- */
|
||||||
/* timers */
|
/* timers */
|
||||||
QObject::connect(&Timer, SIGNAL(timeout()), this, SLOT(OnTimer()));
|
QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) );
|
||||||
|
|
||||||
|
|
||||||
/* timers --------------------------------------------------------------- */
|
/* timers --------------------------------------------------------------- */
|
||||||
/* start timer for GUI controls */
|
/* start timer for GUI controls */
|
||||||
Timer.start(GUI_CONTRL_UPDATE_TIME);
|
Timer.start ( GUI_CONTRL_UPDATE_TIME );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLlconServerDlg::OnTimer()
|
void CLlconServerDlg::OnTimer()
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* update time for GUI controls */
|
// update time for GUI controls
|
||||||
#define GUI_CONTRL_UPDATE_TIME 1000 /* ms */
|
#define GUI_CONTRL_UPDATE_TIME 1000 // ms
|
||||||
|
|
||||||
|
|
||||||
/* Classes ********************************************************************/
|
/* Classes ********************************************************************/
|
||||||
|
@ -54,7 +54,7 @@ public:
|
||||||
CLlconServerDlg ( CServer* pNServP, QWidget* parent = 0,
|
CLlconServerDlg ( CServer* pNServP, QWidget* parent = 0,
|
||||||
const char* name = 0, bool modal = FALSE, WFlags f = 0 );
|
const char* name = 0, bool modal = FALSE, WFlags f = 0 );
|
||||||
|
|
||||||
virtual ~CLlconServerDlg () {}
|
virtual ~CLlconServerDlg() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QTimer Timer;
|
QTimer Timer;
|
||||||
|
@ -69,7 +69,7 @@ protected:
|
||||||
|
|
||||||
QMenuBar* pMenu;
|
QMenuBar* pMenu;
|
||||||
|
|
||||||
virtual void customEvent(QCustomEvent* Event);
|
virtual void customEvent ( QCustomEvent* Event );
|
||||||
void UpdateSliderNetBuf();
|
void UpdateSliderNetBuf();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -37,32 +37,32 @@ CMultiColorLEDbase::CMultiColorLEDbase()
|
||||||
const int iYSize = 13;
|
const int iYSize = 13;
|
||||||
|
|
||||||
/* Create bitmaps */
|
/* Create bitmaps */
|
||||||
BitmCubeGreen.resize(iXSize, iYSize);
|
BitmCubeGreen.resize ( iXSize, iYSize );
|
||||||
BitmCubeGreen.fill(QColor(0, 255, 0));
|
BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) );
|
||||||
BitmCubeRed.resize(iXSize, iYSize);
|
BitmCubeRed.resize ( iXSize, iYSize );
|
||||||
BitmCubeRed.fill(QColor(255, 0, 0));
|
BitmCubeRed.fill ( QColor ( 255, 0, 0 ) );
|
||||||
BitmCubeGrey.resize(iXSize, iYSize);
|
BitmCubeGrey.resize ( iXSize, iYSize );
|
||||||
BitmCubeGrey.fill(QColor(192, 192, 192));
|
BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) );
|
||||||
BitmCubeYellow.resize(iXSize, iYSize);
|
BitmCubeYellow.resize ( iXSize, iYSize );
|
||||||
BitmCubeYellow.fill(QColor(255, 255, 0));
|
BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) );
|
||||||
|
|
||||||
/* Init color flags */
|
/* Init color flags */
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
/* Set init-bitmap */
|
/* Set init-bitmap */
|
||||||
SetPixmap(BitmCubeGrey);
|
SetPixmap ( BitmCubeGrey );
|
||||||
eColorFlag = RL_GREY;
|
eColorFlag = RL_GREY;
|
||||||
|
|
||||||
/* Init update time */
|
/* Init update time */
|
||||||
iUpdateTime = DEFAULT_UPDATE_TIME;
|
iUpdateTime = DEFAULT_UPDATE_TIME;
|
||||||
|
|
||||||
/* Connect timer events to the desired slots */
|
/* Connect timer events to the desired slots */
|
||||||
connect(&TimerRedLight, SIGNAL(timeout()),
|
connect ( &TimerRedLight, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerRedLight()));
|
this, SLOT ( OnTimerRedLight() ) );
|
||||||
connect(&TimerGreenLight, SIGNAL(timeout()),
|
connect ( &TimerGreenLight, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerGreenLight()));
|
this, SLOT ( OnTimerGreenLight() ) );
|
||||||
connect(&TimerYellowLight, SIGNAL(timeout()),
|
connect ( &TimerYellowLight, SIGNAL ( timeout() ),
|
||||||
this, SLOT(OnTimerYellowLight()));
|
this, SLOT ( OnTimerYellowLight() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiColorLEDbase::Reset()
|
void CMultiColorLEDbase::Reset()
|
||||||
|
@ -98,85 +98,89 @@ void CMultiColorLEDbase::UpdateColor()
|
||||||
/* Red light has highest priority, then comes yellow and at the end, we
|
/* Red light has highest priority, then comes yellow and at the end, we
|
||||||
decide to set green light. Allways check the current color of the
|
decide to set green light. Allways check the current color of the
|
||||||
control before setting the color to prevent flicking */
|
control before setting the color to prevent flicking */
|
||||||
if (bFlagRedLi)
|
if ( bFlagRedLi )
|
||||||
{
|
{
|
||||||
if (eColorFlag != RL_RED)
|
if ( eColorFlag != RL_RED )
|
||||||
{
|
{
|
||||||
SetPixmap(BitmCubeRed);
|
SetPixmap ( BitmCubeRed );
|
||||||
eColorFlag = RL_RED;
|
eColorFlag = RL_RED;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bFlagYellowLi)
|
if ( bFlagYellowLi )
|
||||||
{
|
{
|
||||||
if (eColorFlag != RL_YELLOW)
|
if ( eColorFlag != RL_YELLOW )
|
||||||
{
|
{
|
||||||
SetPixmap(BitmCubeYellow);
|
SetPixmap ( BitmCubeYellow );
|
||||||
eColorFlag = RL_YELLOW;
|
eColorFlag = RL_YELLOW;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bFlagGreenLi)
|
if ( bFlagGreenLi )
|
||||||
{
|
{
|
||||||
if (eColorFlag != RL_GREEN)
|
if ( eColorFlag != RL_GREEN )
|
||||||
{
|
{
|
||||||
SetPixmap(BitmCubeGreen);
|
SetPixmap ( BitmCubeGreen );
|
||||||
eColorFlag = RL_GREEN;
|
eColorFlag = RL_GREEN;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no color is active, set control to grey light */
|
/* If no color is active, set control to grey light */
|
||||||
if (eColorFlag != RL_GREY)
|
if ( eColorFlag != RL_GREY )
|
||||||
{
|
{
|
||||||
SetPixmap(BitmCubeGrey);
|
SetPixmap ( BitmCubeGrey );
|
||||||
eColorFlag = RL_GREY;
|
eColorFlag = RL_GREY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiColorLEDbase::SetLight(int iNewStatus)
|
void CMultiColorLEDbase::SetLight ( int iNewStatus )
|
||||||
{
|
{
|
||||||
switch (iNewStatus)
|
switch ( iNewStatus )
|
||||||
{
|
{
|
||||||
case MUL_COL_LED_GREEN:
|
case MUL_COL_LED_GREEN:
|
||||||
/* Green light */
|
/* Green light */
|
||||||
bFlagGreenLi = true;
|
bFlagGreenLi = true;
|
||||||
TimerGreenLight.changeInterval(iUpdateTime);
|
TimerGreenLight.changeInterval ( iUpdateTime );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MUL_COL_LED_YELLOW:
|
case MUL_COL_LED_YELLOW:
|
||||||
/* Yellow light */
|
/* Yellow light */
|
||||||
bFlagYellowLi = true;
|
bFlagYellowLi = true;
|
||||||
TimerYellowLight.changeInterval(iUpdateTime);
|
TimerYellowLight.changeInterval ( iUpdateTime );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MUL_COL_LED_RED:
|
case MUL_COL_LED_RED:
|
||||||
/* Red light */
|
/* Red light */
|
||||||
bFlagRedLi = true;
|
bFlagRedLi = true;
|
||||||
TimerRedLight.changeInterval(iUpdateTime);
|
TimerRedLight.changeInterval ( iUpdateTime );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateColor();
|
UpdateColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiColorLEDbase::SetUpdateTime(int iNUTi)
|
void CMultiColorLEDbase::SetUpdateTime ( int iNUTi )
|
||||||
{
|
{
|
||||||
/* Avoid too short intervals */
|
/* Avoid too short intervals */
|
||||||
if (iNUTi < MIN_TIME_FOR_RED_LIGHT)
|
if ( iNUTi < MIN_TIME_FOR_RED_LIGHT )
|
||||||
|
{
|
||||||
iUpdateTime = MIN_TIME_FOR_RED_LIGHT;
|
iUpdateTime = MIN_TIME_FOR_RED_LIGHT;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
iUpdateTime = iNUTi;
|
iUpdateTime = iNUTi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CMultiColorLED::CMultiColorLED(QWidget* parent, const char* name, WFlags f) :
|
CMultiColorLED::CMultiColorLED ( QWidget* parent, const char* name, WFlags f ) :
|
||||||
QLabel(parent, name, f)
|
QLabel ( parent, name, f )
|
||||||
{
|
{
|
||||||
// set modified style
|
// set modified style
|
||||||
setFrameShape(QFrame::Panel);
|
setFrameShape ( QFrame::Panel );
|
||||||
setFrameShadow(QFrame::Sunken);
|
setFrameShadow ( QFrame::Sunken );
|
||||||
setIndent(0);
|
setIndent ( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(AFX_MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_)
|
#if !defined ( AFX_MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_ )
|
||||||
#define AFX_MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_
|
#define AFX_MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_
|
||||||
|
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
#define DEFAULT_UPDATE_TIME 300
|
#define DEFAULT_UPDATE_TIME 300
|
||||||
|
|
||||||
/* The red and yellow light should be on at least this interval */
|
// the red and yellow light should be on at least this interval
|
||||||
#define MIN_TIME_FOR_RED_LIGHT 100
|
#define MIN_TIME_FOR_RED_LIGHT 100
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ public:
|
||||||
CMultiColorLEDbase();
|
CMultiColorLEDbase();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetUpdateTime(int iNUTi);
|
void SetUpdateTime ( int iNUTi );
|
||||||
void SetLight(int iNewStatus);
|
void SetLight ( int iNewStatus );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum ELightColor {RL_GREY, RL_RED, RL_GREEN, RL_YELLOW};
|
enum ELightColor { RL_GREY, RL_RED, RL_GREEN, RL_YELLOW };
|
||||||
ELightColor eColorFlag;
|
ELightColor eColorFlag;
|
||||||
|
|
||||||
virtual void SetPixmap(QPixmap& NewBitmap) {} /* must be implemented in derived class! */
|
virtual void SetPixmap ( QPixmap& NewBitmap ) {} // must be implemented in derived class!
|
||||||
void UpdateColor();
|
void UpdateColor();
|
||||||
|
|
||||||
QPixmap BitmCubeGreen;
|
QPixmap BitmCubeGreen;
|
||||||
|
@ -91,10 +91,10 @@ protected slots:
|
||||||
class CMultiColorLED : public QLabel, public CMultiColorLEDbase
|
class CMultiColorLED : public QLabel, public CMultiColorLEDbase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMultiColorLED(QWidget* parent, const char* name = 0, WFlags f = 0);
|
CMultiColorLED ( QWidget* parent, const char* name = 0, WFlags f = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void SetPixmap(QPixmap& NewBitmap) {setPixmap(NewBitmap);}
|
virtual void SetPixmap ( QPixmap& NewBitmap ) { setPixmap ( NewBitmap ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -729,7 +729,7 @@ void CProtocol::GenMessageFrame ( CVector<uint8_t>& vecOut,
|
||||||
const int iTotLenByte = MESS_LEN_WITHOUT_DATA_BYTE + iDataLenByte;
|
const int iTotLenByte = MESS_LEN_WITHOUT_DATA_BYTE + iDataLenByte;
|
||||||
|
|
||||||
// init message vector
|
// init message vector
|
||||||
vecOut.Init( iTotLenByte );
|
vecOut.Init ( iTotLenByte );
|
||||||
|
|
||||||
// encode header -----
|
// encode header -----
|
||||||
unsigned int iCurPos = 0; // init position pointer
|
unsigned int iCurPos = 0; // init position pointer
|
||||||
|
@ -769,7 +769,7 @@ void CProtocol::GenMessageFrame ( CVector<uint8_t>& vecOut,
|
||||||
}
|
}
|
||||||
|
|
||||||
PutValOnStream ( vecOut, iCurPos,
|
PutValOnStream ( vecOut, iCurPos,
|
||||||
static_cast<uint32_t> ( CRCObj.GetCRC () ), 2 );
|
static_cast<uint32_t> ( CRCObj.GetCRC() ), 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CProtocol::PutValOnStream ( CVector<uint8_t>& vecIn,
|
void CProtocol::PutValOnStream ( CVector<uint8_t>& vecIn,
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_)
|
#if !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ )
|
||||||
#define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_
|
#define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
#define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag
|
#define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag
|
||||||
|
|
||||||
// lengths of message as defined in protocol.cpp file
|
// lengths of message as defined in protocol.cpp file
|
||||||
#define MESS_HEADER_LENGTH_BYTE 7 /* TAG (2), ID (2), cnt (1), length (2) */
|
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
|
||||||
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ )
|
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC (2) */ )
|
||||||
|
|
||||||
// time out for message re-send if no acknowledgement was received
|
// time out for message re-send if no acknowledgement was received
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||||
const int iNumBytes );
|
const int iNumBytes );
|
||||||
|
|
||||||
void DeleteSendMessQueue ();
|
void DeleteSendMessQueue();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class CSendMessage
|
class CSendMessage
|
||||||
|
@ -168,4 +168,4 @@ signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_) */
|
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_)
|
#if !defined ( RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_ )
|
||||||
#define RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_
|
#define RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -37,9 +37,9 @@ public:
|
||||||
CResample() {}
|
CResample() {}
|
||||||
virtual ~CResample() {}
|
virtual ~CResample() {}
|
||||||
|
|
||||||
void Init(const int iNewInputBlockSize);
|
void Init ( const int iNewInputBlockSize );
|
||||||
int Resample(CVector<double>& vecdInput, CVector<double>& vecdOutput,
|
int Resample ( CVector<double>& vecdInput, CVector<double>& vecdOutput,
|
||||||
const double dRation);
|
const double dRation );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double dTStep;
|
double dTStep;
|
||||||
|
@ -58,8 +58,8 @@ public:
|
||||||
CAudioResample() {}
|
CAudioResample() {}
|
||||||
virtual ~CAudioResample() {}
|
virtual ~CAudioResample() {}
|
||||||
|
|
||||||
void Init(const int iNewInputBlockSize, const int iFrom, const int iTo);
|
void Init ( const int iNewInputBlockSize, const int iFrom, const int iTo );
|
||||||
void Resample(CVector<double>& vecdInput, CVector<double>& vecdOutput);
|
void Resample ( CVector<double>& vecdInput, CVector<double>& vecdOutput );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double dRation;
|
double dRation;
|
||||||
|
@ -76,4 +76,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_)
|
#endif // !defined ( RESAMPLE_H__3B0FEUFE7876F_FE8FE_CA63_4344_1912__INCLUDED_ )
|
||||||
|
|
14
src/server.h
14
src/server.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_)
|
#if !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ )
|
||||||
#define SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_
|
#define SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
@ -45,14 +45,14 @@ public:
|
||||||
CServer ( const bool bUseLogging );
|
CServer ( const bool bUseLogging );
|
||||||
virtual ~CServer() {}
|
virtual ~CServer() {}
|
||||||
|
|
||||||
void Start ();
|
void Start();
|
||||||
void Stop ();
|
void Stop();
|
||||||
bool IsRunning() { return Timer.isActive(); }
|
bool IsRunning() { return Timer.isActive(); }
|
||||||
|
|
||||||
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
CVector<std::string>& vecsName,
|
CVector<std::string>& vecsName,
|
||||||
CVector<int>& veciJitBufSize, CVector<int>& veciNetwOutBlSiFact,
|
CVector<int>& veciJitBufSize, CVector<int>& veciNetwOutBlSiFact,
|
||||||
CVector<int>& veciNetwInBlSiFact)
|
CVector<int>& veciNetwInBlSiFact )
|
||||||
{
|
{
|
||||||
ChannelSet.GetConCliParam ( vecHostAddresses, vecsName,
|
ChannelSet.GetConCliParam ( vecHostAddresses, vecsName,
|
||||||
veciJitBufSize, veciNetwOutBlSiFact, veciNetwInBlSiFact );
|
veciJitBufSize, veciNetwOutBlSiFact, veciNetwInBlSiFact );
|
||||||
|
@ -71,11 +71,11 @@ protected:
|
||||||
QTimer Timer;
|
QTimer Timer;
|
||||||
CVector<short> vecsSendData;
|
CVector<short> vecsSendData;
|
||||||
|
|
||||||
/* actual working objects */
|
// actual working objects
|
||||||
CChannelSet ChannelSet;
|
CChannelSet ChannelSet;
|
||||||
CSocket Socket;
|
CSocket Socket;
|
||||||
|
|
||||||
/* debugging, evaluating */
|
// debugging, evaluating
|
||||||
CMovingAv<double> RespTimeMoAvBuf;
|
CMovingAv<double> RespTimeMoAvBuf;
|
||||||
QTime TimeLastBlock;
|
QTime TimeLastBlock;
|
||||||
|
|
||||||
|
@ -88,4 +88,4 @@ public slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_) */
|
#endif /* !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
166
src/settings.cpp
166
src/settings.cpp
|
@ -56,42 +56,50 @@ void CSettings::ReadIniFile()
|
||||||
pClient->strName = GetIniSetting ( ini, "Client", "name" );
|
pClient->strName = GetIniSetting ( ini, "Client", "name" );
|
||||||
|
|
||||||
// audio fader
|
// audio fader
|
||||||
if ( GetNumericIniSet(ini, "Client", "audfad", 0, AUD_FADER_IN_MAX, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "audfad", 0, AUD_FADER_IN_MAX, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetAudioInFader ( iValue );
|
pClient->SetAudioInFader ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverberation level
|
// reverberation level
|
||||||
if ( GetNumericIniSet(ini, "Client", "revlev", 0, AUD_REVERB_MAX, iValue ) == TRUE ) {
|
if ( GetNumericIniSet(ini, "Client", "revlev", 0, AUD_REVERB_MAX, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetReverbLevel ( iValue );
|
pClient->SetReverbLevel ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverberation channel assignment
|
// reverberation channel assignment
|
||||||
if ( GetFlagIniSet(ini, "Client", "reverblchan", bValue ) == TRUE ) {
|
if ( GetFlagIniSet ( ini, "Client", "reverblchan", bValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetReverbOnLeftChan ( bValue );
|
pClient->SetReverbOnLeftChan ( bValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sound card in number of buffers
|
// sound card in number of buffers
|
||||||
if ( GetNumericIniSet(ini, "Client", "audinbuf", 0, AUD_SLIDER_LENGTH, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "audinbuf", 0, AUD_SLIDER_LENGTH, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->GetSndInterface()->SetInNumBuf( iValue );
|
pClient->GetSndInterface()->SetInNumBuf( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// sound card out number of buffers
|
// sound card out number of buffers
|
||||||
if ( GetNumericIniSet(ini, "Client", "audoutbuf", 0, AUD_SLIDER_LENGTH, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "audoutbuf", 0, AUD_SLIDER_LENGTH, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->GetSndInterface()->SetOutNumBuf ( iValue );
|
pClient->GetSndInterface()->SetOutNumBuf ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// network jitter buffer size
|
// network jitter buffer size
|
||||||
if ( GetNumericIniSet(ini, "Client", "jitbuf", 0, MAX_NET_BUF_SIZE_NUM_BL, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "jitbuf", 0, MAX_NET_BUF_SIZE_NUM_BL, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetSockBufSize ( iValue );
|
pClient->SetSockBufSize ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// network buffer size factor in
|
// network buffer size factor in
|
||||||
if ( GetNumericIniSet(ini, "Client", "netwbusifactin", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "netwbusifactin", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetNetwBufSizeFactIn ( iValue );
|
pClient->SetNetwBufSizeFactIn ( iValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
// network buffer size factor out
|
// network buffer size factor out
|
||||||
if ( GetNumericIniSet(ini, "Client", "netwbusifactout", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE ) {
|
if ( GetNumericIniSet ( ini, "Client", "netwbusifactout", 1, MAX_NET_BLOCK_SIZE_FACTOR, iValue ) == TRUE )
|
||||||
|
{
|
||||||
pClient->SetNetwBufSizeFactOut ( iValue );
|
pClient->SetNetwBufSizeFactOut ( iValue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,116 +228,136 @@ void CSettings::SetFlagIniSet ( INIFile& theINI, string strSection, string strKe
|
||||||
/* These pragmas are to quiet VC++ about the expanded template identifiers
|
/* These pragmas are to quiet VC++ about the expanded template identifiers
|
||||||
exceeding 255 chars. You won't be able to see those variables in a debug
|
exceeding 255 chars. You won't be able to see those variables in a debug
|
||||||
session, but the code will run normally */
|
session, but the code will run normally */
|
||||||
#pragma warning (push)
|
#pragma warning ( push )
|
||||||
#pragma warning (disable : 4786 4503)
|
#pragma warning ( disable : 4786 4503 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string CSettings::GetIniSetting(CSettings::INIFile& theINI, const char* section,
|
string CSettings::GetIniSetting ( CSettings::INIFile& theINI, const char* section,
|
||||||
const char* key, const char* defaultval)
|
const char* key, const char* defaultval )
|
||||||
{
|
{
|
||||||
string result(defaultval);
|
string result ( defaultval );
|
||||||
INIFile::iterator iSection = theINI.find(string(section));
|
INIFile::iterator iSection = theINI.find ( string ( section ) );
|
||||||
|
|
||||||
if (iSection != theINI.end())
|
if ( iSection != theINI.end() )
|
||||||
{
|
{
|
||||||
INISection::iterator apair = iSection->second.find(string(key));
|
INISection::iterator apair = iSection->second.find ( string ( key ) );
|
||||||
|
|
||||||
if (apair != iSection->second.end())
|
if ( apair != iSection->second.end() )
|
||||||
|
{
|
||||||
result = apair->second;
|
result = apair->second;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::PutIniSetting(CSettings::INIFile &theINI, const char *section,
|
void CSettings::PutIniSetting ( CSettings::INIFile &theINI, const char *section,
|
||||||
const char *key, const char *value)
|
const char *key, const char *value )
|
||||||
{
|
{
|
||||||
INIFile::iterator iniSection;
|
INIFile::iterator iniSection;
|
||||||
INISection::iterator apair;
|
INISection::iterator apair;
|
||||||
|
|
||||||
if ((iniSection = theINI.find(string(section))) == theINI.end())
|
if ( ( iniSection = theINI.find ( string ( section ) ) ) == theINI.end() )
|
||||||
{
|
{
|
||||||
/* No such section? Then add one */
|
/* No such section? Then add one */
|
||||||
INISection newsection;
|
INISection newsection;
|
||||||
if (key)
|
if (key)
|
||||||
{
|
{
|
||||||
newsection.insert(
|
newsection.insert (
|
||||||
std::pair<std::string, string>(string(key), string(value)));
|
std::pair<std::string, string> ( string ( key ), string ( value ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
theINI.insert(
|
theINI.insert (
|
||||||
std::pair<string, INISection>(string(section), newsection));
|
std::pair<string, INISection> ( string ( section ), newsection ) );
|
||||||
}
|
}
|
||||||
else if (key)
|
else
|
||||||
|
{
|
||||||
|
if ( key )
|
||||||
{
|
{
|
||||||
/* Found section, make sure key isn't in there already,
|
/* Found section, make sure key isn't in there already,
|
||||||
if it is, just drop and re-add */
|
if it is, just drop and re-add */
|
||||||
apair = iniSection->second.find(string(key));
|
apair = iniSection->second.find ( string ( key ) );
|
||||||
if (apair != iniSection->second.end())
|
if ( apair != iniSection->second.end() )
|
||||||
|
{
|
||||||
iniSection->second.erase(apair);
|
iniSection->second.erase(apair);
|
||||||
|
}
|
||||||
|
|
||||||
iniSection->second.insert(
|
iniSection->second.insert (
|
||||||
std::pair<string, string>(string(key), string(value)));
|
std::pair<string, string> ( string ( key ), string ( value ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettings::INIFile CSettings::LoadIni(const char* filename)
|
CSettings::INIFile CSettings::LoadIni ( const char* filename )
|
||||||
{
|
{
|
||||||
INIFile theINI;
|
INIFile theINI;
|
||||||
char *value, *temp;
|
char *value, *temp;
|
||||||
string section;
|
string section;
|
||||||
char buffer[MAX_INI_LINE];
|
char buffer[MAX_INI_LINE];
|
||||||
std::fstream file(filename, std::ios::in);
|
std::fstream file ( filename, std::ios::in );
|
||||||
|
|
||||||
while (file.good())
|
while ( file.good() )
|
||||||
{
|
{
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset ( buffer, 0, sizeof ( buffer ) );
|
||||||
file.getline(buffer, sizeof(buffer));
|
file.getline ( buffer, sizeof ( buffer ) );
|
||||||
|
|
||||||
if ((temp = strchr(buffer, '\n')))
|
if ( ( temp = strchr ( buffer, '\n' ) ) )
|
||||||
|
{
|
||||||
*temp = '\0'; /* Cut off at newline */
|
*temp = '\0'; /* Cut off at newline */
|
||||||
|
}
|
||||||
|
|
||||||
if ((temp = strchr(buffer, '\r')))
|
if ( ( temp = strchr ( buffer, '\r' ) ) )
|
||||||
|
{
|
||||||
*temp = '\0'; /* Cut off at linefeeds */
|
*temp = '\0'; /* Cut off at linefeeds */
|
||||||
|
}
|
||||||
|
|
||||||
if ((buffer[0] == '[') && (temp = strrchr(buffer, ']')))
|
if ( ( buffer[0] == '[' ) && ( temp = strrchr ( buffer, ']' ) ) )
|
||||||
{ /* if line is like --> [section name] */
|
{ /* if line is like --> [section name] */
|
||||||
*temp = '\0'; /* Chop off the trailing ']' */
|
*temp = '\0'; /* Chop off the trailing ']' */
|
||||||
section = &buffer[1];
|
section = &buffer[1];
|
||||||
PutIniSetting(theINI, &buffer[1]); /* Start new section */
|
PutIniSetting ( theINI, &buffer[1] ); /* Start new section */
|
||||||
}
|
}
|
||||||
else if (buffer[0] && (value = strchr(buffer, '=')))
|
else
|
||||||
|
{
|
||||||
|
if ( buffer[0] && ( value = strchr ( buffer, '=' ) ) )
|
||||||
{
|
{
|
||||||
/* Assign whatever follows = sign to value, chop at "=" */
|
/* Assign whatever follows = sign to value, chop at "=" */
|
||||||
*value++ = '\0';
|
*value++ = '\0';
|
||||||
|
|
||||||
/* And add both sides to INISection */
|
/* And add both sides to INISection */
|
||||||
PutIniSetting(theINI, section.c_str(), buffer, value);
|
PutIniSetting ( theINI, section.c_str(), buffer, value );
|
||||||
}
|
}
|
||||||
else if (buffer[0])
|
else
|
||||||
|
{
|
||||||
|
if ( buffer[0] )
|
||||||
{
|
{
|
||||||
/* Must be a comment or something */
|
/* Must be a comment or something */
|
||||||
PutIniSetting(theINI, section.c_str(), buffer, "");
|
PutIniSetting ( theINI, section.c_str(), buffer, "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return theINI;
|
return theINI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SaveIni(CSettings::INIFile &theINI, const char* filename)
|
void CSettings::SaveIni ( CSettings::INIFile &theINI, const char* filename )
|
||||||
{
|
{
|
||||||
bool bFirstSection = TRUE; /* Init flag */
|
bool bFirstSection = TRUE; /* Init flag */
|
||||||
|
|
||||||
std::fstream file(filename, std::ios::out);
|
std::fstream file ( filename, std::ios::out );
|
||||||
if(!file.good())
|
if ( !file.good() )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Just iterate the hashes and values and dump them to a file */
|
/* Just iterate the hashes and values and dump them to a file */
|
||||||
INIFile::iterator section = theINI.begin();
|
INIFile::iterator section = theINI.begin();
|
||||||
while (section != theINI.end())
|
while ( section != theINI.end() )
|
||||||
{
|
{
|
||||||
if (section->first > "")
|
if ( section->first > "" )
|
||||||
{
|
{
|
||||||
if (bFirstSection == TRUE)
|
if ( bFirstSection == TRUE )
|
||||||
{
|
{
|
||||||
/* Don't put a newline at the beginning of the first section */
|
/* Don't put a newline at the beginning of the first section */
|
||||||
file << "[" << section->first << "]" << std::endl;
|
file << "[" << section->first << "]" << std::endl;
|
||||||
|
@ -338,17 +366,23 @@ void CSettings::SaveIni(CSettings::INIFile &theINI, const char* filename)
|
||||||
bFirstSection = FALSE;
|
bFirstSection = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
file << std::endl << "[" << section->first << "]" << std::endl;
|
file << std::endl << "[" << section->first << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INISection::iterator pair = section->second.begin();
|
INISection::iterator pair = section->second.begin();
|
||||||
|
|
||||||
while (pair != section->second.end())
|
while ( pair != section->second.end() )
|
||||||
|
{
|
||||||
|
if ( pair->second > "" )
|
||||||
{
|
{
|
||||||
if (pair->second > "")
|
|
||||||
file << pair->first << "=" << pair->second << std::endl;
|
file << pair->first << "=" << pair->second << std::endl;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
file << pair->first << "=" << std::endl;
|
file << pair->first << "=" << std::endl;
|
||||||
|
}
|
||||||
pair++;
|
pair++;
|
||||||
}
|
}
|
||||||
section++;
|
section++;
|
||||||
|
@ -358,43 +392,51 @@ void CSettings::SaveIni(CSettings::INIFile &theINI, const char* filename)
|
||||||
|
|
||||||
/* Return true or false depending on whether the first string is less than the
|
/* Return true or false depending on whether the first string is less than the
|
||||||
second */
|
second */
|
||||||
bool CSettings::StlIniCompareStringNoCase::operator()(const string& x,
|
bool CSettings::StlIniCompareStringNoCase::operator() ( const string& x,
|
||||||
const string& y) const
|
const string& y ) const
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
return (stricmp(x.c_str(), y.c_str()) < 0) ? true : false;
|
return ( stricmp ( x.c_str(), y.c_str() ) < 0 ) ? true : false;
|
||||||
#else
|
#else
|
||||||
#ifdef strcasecmp
|
#ifdef strcasecmp
|
||||||
return (strcasecmp(x.c_str(), y.c_str()) < 0) ? true : false;
|
return ( strcasecmp ( x.c_str(), y.c_str() ) < 0 ) ? true : false;
|
||||||
#else
|
#else
|
||||||
unsigned nCount = 0;
|
unsigned nCount = 0;
|
||||||
int nResult = 0;
|
int nResult = 0;
|
||||||
const char *p1 = x.c_str();
|
const char *p1 = x.c_str();
|
||||||
const char *p2 = y.c_str();
|
const char *p2 = y.c_str();
|
||||||
|
|
||||||
while (*p1 && *p2)
|
while ( *p1 && *p2 )
|
||||||
|
{
|
||||||
|
nResult = toupper ( *p1 ) - toupper ( *p2 );
|
||||||
|
if ( nResult != 0 )
|
||||||
{
|
{
|
||||||
nResult = toupper(*p1) - toupper(*p2);
|
|
||||||
if (nResult != 0)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
p1++;
|
p1++;
|
||||||
p2++;
|
p2++;
|
||||||
nCount++;
|
nCount++;
|
||||||
}
|
}
|
||||||
if (nResult == 0)
|
if ( nResult == 0 )
|
||||||
|
{
|
||||||
|
if ( *p1 && !*p2 )
|
||||||
{
|
{
|
||||||
if (*p1 && !*p2)
|
|
||||||
nResult = -1;
|
nResult = -1;
|
||||||
if (!*p1 && *p2)
|
}
|
||||||
|
if ( !*p1 && *p2 )
|
||||||
|
{
|
||||||
nResult = 1;
|
nResult = 1;
|
||||||
}
|
}
|
||||||
if (nResult < 0)
|
}
|
||||||
|
if ( nResult < 0 )
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
#endif /* strcasecmp */
|
#endif /* strcasecmp */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning ( pop )
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_)
|
#if !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ )
|
||||||
#define SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_
|
#define SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
@ -47,20 +47,20 @@ class CSettings
|
||||||
public:
|
public:
|
||||||
CSettings ( CClient* pNCliP ) : pClient ( pNCliP ) {}
|
CSettings ( CClient* pNCliP ) : pClient ( pNCliP ) {}
|
||||||
|
|
||||||
void Load ();
|
void Load();
|
||||||
void Save ();
|
void Save();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ReadIniFile ();
|
void ReadIniFile();
|
||||||
void WriteIniFile ();
|
void WriteIniFile();
|
||||||
|
|
||||||
/* Function declarations for stlini code written by Robert Kesterson */
|
// function declarations for stlini code written by Robert Kesterson
|
||||||
struct StlIniCompareStringNoCase
|
struct StlIniCompareStringNoCase
|
||||||
{
|
{
|
||||||
bool operator () ( const std::string& x, const std::string& y ) const;
|
bool operator() ( const std::string& x, const std::string& y ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* These typedefs just make the code a bit more readable */
|
// these typedefs just make the code a bit more readable
|
||||||
typedef std::map<string, string, StlIniCompareStringNoCase > INISection;
|
typedef std::map<string, string, StlIniCompareStringNoCase > INISection;
|
||||||
typedef std::map<string, INISection , StlIniCompareStringNoCase > INIFile;
|
typedef std::map<string, INISection , StlIniCompareStringNoCase > INIFile;
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ protected:
|
||||||
bool GetFlagIniSet ( INIFile& theINI, string strSection, string strKey,
|
bool GetFlagIniSet ( INIFile& theINI, string strSection, string strKey,
|
||||||
bool& bValue );
|
bool& bValue );
|
||||||
|
|
||||||
/* Pointer to the client object needed for the various settings */
|
// pointer to the client object needed for the various settings
|
||||||
CClient* pClient;
|
CClient* pClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_)
|
#endif // !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ )
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
void CSocket::Init ()
|
void CSocket::Init()
|
||||||
{
|
{
|
||||||
/* allocate memory for network receive and send buffer in samples */
|
/* allocate memory for network receive and send buffer in samples */
|
||||||
vecbyRecBuf.Init ( MAX_SIZE_BYTES_NETW_BUF );
|
vecbyRecBuf.Init ( MAX_SIZE_BYTES_NETW_BUF );
|
||||||
|
@ -63,13 +63,13 @@ void CSocket::Init ()
|
||||||
|
|
||||||
/* connect the "activated" signal */
|
/* connect the "activated" signal */
|
||||||
QObject::connect ( pSocketNotivRead, SIGNAL ( activated ( int ) ),
|
QObject::connect ( pSocketNotivRead, SIGNAL ( activated ( int ) ),
|
||||||
this, SLOT ( OnDataReceived () ) );
|
this, SLOT ( OnDataReceived() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
||||||
const CHostAddress& HostAddr )
|
const CHostAddress& HostAddr )
|
||||||
{
|
{
|
||||||
const int iVecSizeOut = vecbySendBuf.Size ();
|
const int iVecSizeOut = vecbySendBuf.Size();
|
||||||
|
|
||||||
if ( iVecSizeOut != 0 )
|
if ( iVecSizeOut != 0 )
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSocket::OnDataReceived ()
|
void CSocket::OnDataReceived()
|
||||||
{
|
{
|
||||||
/* read block from network interface */
|
/* read block from network interface */
|
||||||
const int iNumBytesRead = SocketDevice.readBlock( (char*) &vecbyRecBuf[0],
|
const int iNumBytesRead = SocketDevice.readBlock( (char*) &vecbyRecBuf[0],
|
||||||
|
@ -93,14 +93,14 @@ void CSocket::OnDataReceived ()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get host address of client */
|
/* get host address of client */
|
||||||
CHostAddress RecHostAddr ( SocketDevice.peerAddress (),
|
CHostAddress RecHostAddr ( SocketDevice.peerAddress(),
|
||||||
SocketDevice.peerPort () );
|
SocketDevice.peerPort() );
|
||||||
|
|
||||||
if ( bIsClient )
|
if ( bIsClient )
|
||||||
{
|
{
|
||||||
/* client */
|
/* client */
|
||||||
/* check if packet comes from the server we want to connect */
|
/* check if packet comes from the server we want to connect */
|
||||||
if ( ! ( pChannel->GetAddress () == RecHostAddr ) )
|
if ( ! ( pChannel->GetAddress() == RecHostAddr ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
10
src/socket.h
10
src/socket.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_)
|
#if !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ )
|
||||||
#define SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
#define SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
/* maximum block size for network input buffer. Consider two bytes per sample */
|
// maximum block size for network input buffer. Consider two bytes per sample
|
||||||
#define MAX_SIZE_BYTES_NETW_BUF ( MAX_NET_BLOCK_SIZE_FACTOR * MIN_BLOCK_SIZE_SAMPLES * 2 )
|
#define MAX_SIZE_BYTES_NETW_BUF ( MAX_NET_BLOCK_SIZE_FACTOR * MIN_BLOCK_SIZE_SAMPLES * 2 )
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ protected:
|
||||||
CVector<unsigned char> vecbyRecBuf;
|
CVector<unsigned char> vecbyRecBuf;
|
||||||
CHostAddress RecHostAddr;
|
CHostAddress RecHostAddr;
|
||||||
|
|
||||||
CChannel* pChannel; /* for client */
|
CChannel* pChannel; // for client
|
||||||
CChannelSet* pChannelSet; /* for server */
|
CChannelSet* pChannelSet; // for server
|
||||||
|
|
||||||
QObject* pServer;
|
QObject* pServer;
|
||||||
bool bIsClient;
|
bool bIsClient;
|
||||||
|
@ -78,4 +78,4 @@ public slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_) */
|
#endif /* !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */
|
||||||
|
|
84
src/util.cpp
84
src/util.cpp
|
@ -29,16 +29,16 @@
|
||||||
/* Input level meter implementation ------------------------------------------ */
|
/* Input level meter implementation ------------------------------------------ */
|
||||||
void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
|
void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
|
||||||
{
|
{
|
||||||
/* Do the update for entire vector */
|
// do the update for entire vector
|
||||||
const int iVecSize = vecdAudio.Size ();
|
const int iVecSize = vecdAudio.Size();
|
||||||
|
|
||||||
for ( int i = 0; i < iVecSize; i++ )
|
for ( int i = 0; i < iVecSize; i++ )
|
||||||
{
|
{
|
||||||
/* norm of current audio sample */
|
// norm of current audio sample
|
||||||
const double dCurSig = fabs ( vecdAudio[i] );
|
const double dCurSig = fabs ( vecdAudio[i] );
|
||||||
|
|
||||||
/* search for maximum. Decrease this max with time */
|
// search for maximum. Decrease this max with time
|
||||||
/* decrease max with time */
|
// decrease max with time
|
||||||
if ( dCurLevel >= METER_FLY_BACK )
|
if ( dCurLevel >= METER_FLY_BACK )
|
||||||
{
|
{
|
||||||
dCurLevel *= 0.9999;
|
dCurLevel *= 0.9999;
|
||||||
|
@ -48,7 +48,7 @@ void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
|
||||||
dCurLevel = 0;
|
dCurLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search for max */
|
// search for max
|
||||||
if ( dCurSig > dCurLevel )
|
if ( dCurSig > dCurLevel )
|
||||||
{
|
{
|
||||||
dCurLevel = dCurSig;
|
dCurLevel = dCurSig;
|
||||||
|
@ -56,24 +56,24 @@ void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double CSignalLevelMeter::MicLevel ()
|
double CSignalLevelMeter::MicLevel()
|
||||||
{
|
{
|
||||||
const double dNormMicLevel = dCurLevel / _MAXSHORT;
|
const double dNormMicLevel = dCurLevel / _MAXSHORT;
|
||||||
|
|
||||||
/* logarithmic measure */
|
// logarithmic measure
|
||||||
if ( dNormMicLevel > 0 )
|
if ( dNormMicLevel > 0 )
|
||||||
{
|
{
|
||||||
return 20.0 * log10 ( dNormMicLevel );
|
return 20.0 * log10 ( dNormMicLevel );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -100000.0; /* large negative value */
|
return -100000.0; // large negative value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* CRC ---------------------------------------------------------------------- */
|
/* CRC ---------------------------------------------------------------------- */
|
||||||
void CCRC::Reset ()
|
void CCRC::Reset()
|
||||||
{
|
{
|
||||||
/* Init state shift-register with ones. Set all registers to "1" with
|
/* Init state shift-register with ones. Set all registers to "1" with
|
||||||
bit-wise not operation */
|
bit-wise not operation */
|
||||||
|
@ -84,7 +84,7 @@ void CCRC::AddByte ( const uint8_t byNewInput )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < 8; i++ )
|
for ( int i = 0; i < 8; i++ )
|
||||||
{
|
{
|
||||||
/* Shift bits in shift-register for transistion */
|
// shift bits in shift-register for transistion
|
||||||
iStateShiftReg <<= 1;
|
iStateShiftReg <<= 1;
|
||||||
|
|
||||||
/* Take bit, which was shifted out of the register-size and place it
|
/* Take bit, which was shifted out of the register-size and place it
|
||||||
|
@ -95,13 +95,13 @@ void CCRC::AddByte ( const uint8_t byNewInput )
|
||||||
iStateShiftReg |= 1;
|
iStateShiftReg |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add new data bit to the LSB */
|
// add new data bit to the LSB
|
||||||
if ( ( byNewInput & ( 1 << ( 8 - i - 1 ) ) ) > 0 )
|
if ( ( byNewInput & ( 1 << ( 8 - i - 1 ) ) ) > 0 )
|
||||||
{
|
{
|
||||||
iStateShiftReg ^= 1;
|
iStateShiftReg ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add mask to shift-register if first bit is true */
|
// add mask to shift-register if first bit is true
|
||||||
if ( iStateShiftReg & 1 )
|
if ( iStateShiftReg & 1 )
|
||||||
{
|
{
|
||||||
iStateShiftReg ^= iPoly;
|
iStateShiftReg ^= iPoly;
|
||||||
|
@ -111,10 +111,10 @@ void CCRC::AddByte ( const uint8_t byNewInput )
|
||||||
|
|
||||||
uint32_t CCRC::GetCRC()
|
uint32_t CCRC::GetCRC()
|
||||||
{
|
{
|
||||||
/* Return inverted shift-register (1's complement) */
|
// return inverted shift-register (1's complement)
|
||||||
iStateShiftReg = ~iStateShiftReg;
|
iStateShiftReg = ~iStateShiftReg;
|
||||||
|
|
||||||
/* Remove bit which where shifted out of the shift-register frame */
|
// remove bit which where shifted out of the shift-register frame
|
||||||
return iStateShiftReg & ( iBitOutMask - 1 );
|
return iStateShiftReg & ( iBitOutMask - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ CAudioReverb::CAudioReverb ( const double rT60 )
|
||||||
{
|
{
|
||||||
int delay, i;
|
int delay, i;
|
||||||
|
|
||||||
/* Delay lengths for 44100 Hz sample rate */
|
// delay lengths for 44100 Hz sample rate
|
||||||
int lengths[9] = { 1777, 1847, 1993, 2137, 389, 127, 43, 211, 179 };
|
int lengths[9] = { 1777, 1847, 1993, 2137, 389, 127, 43, 211, 179 };
|
||||||
const double scaler = (double) SAMPLE_RATE / 44100.0;
|
const double scaler = (double) SAMPLE_RATE / 44100.0;
|
||||||
|
|
||||||
|
@ -269,17 +269,17 @@ double CAudioReverb::ProcessSample ( const double input )
|
||||||
* GUI utilities *
|
* GUI utilities *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
/* About dialog ------------------------------------------------------------- */
|
/* About dialog ------------------------------------------------------------- */
|
||||||
CAboutDlg::CAboutDlg(QWidget* parent, const char* name, bool modal, WFlags f)
|
CAboutDlg::CAboutDlg ( QWidget* parent, const char* name, bool modal, WFlags f )
|
||||||
: CAboutDlgBase(parent, name, modal, f)
|
: CAboutDlgBase ( parent, name, modal, f )
|
||||||
{
|
{
|
||||||
/* Set the text for the about dialog html text control */
|
// set the text for the about dialog html text control
|
||||||
TextViewCredits->setText(
|
TextViewCredits->setText (
|
||||||
"<p>" /* General description of llcon software */
|
"<p>" // general description of llcon software
|
||||||
"<big><b>llcon</b> " + tr("Client/Server communication tool to enable "
|
"<big><b>llcon</b> " + tr("Client/Server communication tool to enable "
|
||||||
"musician to play together through a conventional broadband internet "
|
"musician to play together through a conventional broadband internet "
|
||||||
"connection (like DSL).") + "</big>"
|
"connection (like DSL).") + "</big>"
|
||||||
"</p><br>"
|
"</p><br>"
|
||||||
"<p><font face=\"courier\">" /* GPL header text */
|
"<p><font face=\"courier\">" // GPL header text
|
||||||
"This program is free software; you can redistribute it and/or modify "
|
"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 "
|
"it under the terms of the GNU General Public License as published by "
|
||||||
"the Free Software Foundation; either version 2 of the License, or "
|
"the Free Software Foundation; either version 2 of the License, or "
|
||||||
|
@ -292,7 +292,7 @@ CAboutDlg::CAboutDlg(QWidget* parent, const char* name, bool modal, WFlags f)
|
||||||
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 "
|
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 "
|
||||||
"USA"
|
"USA"
|
||||||
"</font></p><br>"
|
"</font></p><br>"
|
||||||
"<p>" /* Libraries used by this compilation of Dream */
|
"<p>" // libraries used by this compilation of Dream
|
||||||
"<b>" + tr("llcon uses the following libraries or code snippets:") +
|
"<b>" + tr("llcon uses the following libraries or code snippets:") +
|
||||||
"</b></p>"
|
"</b></p>"
|
||||||
"<ul>"
|
"<ul>"
|
||||||
|
@ -305,8 +305,8 @@ CAboutDlg::CAboutDlg(QWidget* parent, const char* name, bool modal, WFlags f)
|
||||||
"</ul>"
|
"</ul>"
|
||||||
"</center><br>");
|
"</center><br>");
|
||||||
|
|
||||||
/* Set version number in about dialog */
|
// set version number in about dialog
|
||||||
TextLabelVersion->setText(GetVersionAndNameStr());
|
TextLabelVersion->setText ( GetVersionAndNameStr() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
||||||
|
@ -319,7 +319,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
||||||
strVersionText += "<center><b>";
|
strVersionText += "<center><b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
strVersionText += tr("llcon, Version ") + VERSION;
|
strVersionText += tr ( "llcon, Version " ) + VERSION;
|
||||||
|
|
||||||
if ( bWithHtml )
|
if ( bWithHtml )
|
||||||
{
|
{
|
||||||
|
@ -330,7 +330,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
||||||
strVersionText += "\n";
|
strVersionText += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
strVersionText += tr("llcon, Low-Latency (internet) CONnection");
|
strVersionText += tr ( "llcon, Low-Latency (internet) CONnection" );
|
||||||
|
|
||||||
if ( bWithHtml )
|
if ( bWithHtml )
|
||||||
{
|
{
|
||||||
|
@ -341,7 +341,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
||||||
strVersionText += "\n";
|
strVersionText += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
strVersionText += tr("Under the GNU General Public License (GPL)");
|
strVersionText += tr ( "Under the GNU General Public License (GPL)" );
|
||||||
|
|
||||||
if ( bWithHtml )
|
if ( bWithHtml )
|
||||||
{
|
{
|
||||||
|
@ -355,28 +355,28 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
|
||||||
/* Help menu ---------------------------------------------------------------- */
|
/* Help menu ---------------------------------------------------------------- */
|
||||||
CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QPopupMenu ( parent )
|
CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QPopupMenu ( parent )
|
||||||
{
|
{
|
||||||
/* Standard help menu consists of about and what's this help */
|
// standard help menu consists of about and what's this help
|
||||||
insertItem ( tr ( "What's &This" ), this ,
|
insertItem ( tr ( "What's &This" ), this,
|
||||||
SLOT ( OnHelpWhatsThis () ), SHIFT+Key_F1 );
|
SLOT ( OnHelpWhatsThis () ), SHIFT+Key_F1 );
|
||||||
insertSeparator();
|
insertSeparator();
|
||||||
insertItem ( tr ( "&About..." ), this, SLOT ( OnHelpAbout () ) );
|
insertItem ( tr ( "&About..." ), this, SLOT ( OnHelpAbout() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Global functions implementation *
|
* Global functions implementation *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
void DebugError(const char* pchErDescr, const char* pchPar1Descr,
|
void DebugError ( const char* pchErDescr, const char* pchPar1Descr,
|
||||||
const double dPar1, const char* pchPar2Descr,
|
const double dPar1, const char* pchPar2Descr,
|
||||||
const double dPar2)
|
const double dPar2 )
|
||||||
{
|
{
|
||||||
FILE* pFile = fopen("DebugError.dat", "a");
|
FILE* pFile = fopen ( "DebugError.dat", "a" );
|
||||||
fprintf(pFile, pchErDescr); fprintf(pFile, " ### ");
|
fprintf ( pFile, pchErDescr ); fprintf ( pFile, " ### " );
|
||||||
fprintf(pFile, pchPar1Descr); fprintf(pFile, ": ");
|
fprintf ( pFile, pchPar1Descr ); fprintf ( pFile, ": " );
|
||||||
fprintf(pFile, "%e ### ", dPar1);
|
fprintf ( pFile, "%e ### ", dPar1);
|
||||||
fprintf(pFile, pchPar2Descr); fprintf(pFile, ": ");
|
fprintf ( pFile, pchPar2Descr ); fprintf ( pFile, ": " );
|
||||||
fprintf(pFile, "%e\n", dPar2);
|
fprintf ( pFile, "%e\n", dPar2 );
|
||||||
fclose(pFile);
|
fclose ( pFile );
|
||||||
printf("\nDebug error! For more information see test/DebugError.dat\n");
|
printf ( "\nDebug error! For more information see test/DebugError.dat\n" );
|
||||||
exit(1);
|
exit ( 1 );
|
||||||
}
|
}
|
||||||
|
|
262
src/util.h
262
src/util.h
|
@ -22,7 +22,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_)
|
#if !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
||||||
#define UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
#define UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
||||||
|
|
||||||
#include <qhostaddress.h>
|
#include <qhostaddress.h>
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
#include <qdatetime.h>
|
#include <qdatetime.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
using namespace std; /* Because of the library: "vector" */
|
using namespace std; // because of the library: "vector"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "../windows/moc/aboutdlgbase.h"
|
# include "../windows/moc/aboutdlgbase.h"
|
||||||
#else
|
#else
|
||||||
|
@ -46,24 +46,28 @@ using namespace std; /* Because of the library: "vector" */
|
||||||
|
|
||||||
|
|
||||||
/* Global functions ***********************************************************/
|
/* Global functions ***********************************************************/
|
||||||
/* Converting double to short */
|
// converting double to short
|
||||||
inline short Double2Short(const double dInput)
|
inline short Double2Short ( const double dInput )
|
||||||
{
|
{
|
||||||
/* Lower bound */
|
// lower bound
|
||||||
if (dInput < _MINSHORT)
|
if ( dInput < _MINSHORT )
|
||||||
|
{
|
||||||
return _MINSHORT;
|
return _MINSHORT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Upper bound */
|
// upper bound
|
||||||
if (dInput > _MAXSHORT)
|
if ( dInput > _MAXSHORT )
|
||||||
|
{
|
||||||
return _MAXSHORT;
|
return _MAXSHORT;
|
||||||
|
}
|
||||||
|
|
||||||
return (short) dInput;
|
return (short) dInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Debug error handling */
|
// debug error handling
|
||||||
void DebugError(const char* pchErDescr, const char* pchPar1Descr,
|
void DebugError ( const char* pchErDescr, const char* pchPar1Descr,
|
||||||
const double dPar1, const char* pchPar2Descr,
|
const double dPar1, const char* pchPar2Descr,
|
||||||
const double dPar2);
|
const double dPar2 );
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
|
@ -72,64 +76,64 @@ void DebugError(const char* pchErDescr, const char* pchPar1Descr,
|
||||||
template<class TData> class CVector : public std::vector<TData>
|
template<class TData> class CVector : public std::vector<TData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CVector() : iVectorSize(0) {pData = this->begin();}
|
CVector() : iVectorSize ( 0 ) { pData = this->begin(); }
|
||||||
CVector(const int iNeSi) {Init(iNeSi);}
|
CVector ( const int iNeSi ) { Init(iNeSi); }
|
||||||
CVector(const int iNeSi, const TData tInVa) {Init(iNeSi, tInVa);}
|
CVector ( const int iNeSi, const TData tInVa ) { Init ( iNeSi, tInVa ); }
|
||||||
virtual ~CVector() {}
|
virtual ~CVector() {}
|
||||||
|
|
||||||
/* Copy constructor: The order of the initialization list must not be
|
/* Copy constructor: The order of the initialization list must not be
|
||||||
changed. First, the base class must be initialized, then the pData
|
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
|
pointer must be set to the new data source. The bit access is, by
|
||||||
default, reset */
|
default, reset */
|
||||||
CVector(const CVector<TData>& vecI) :
|
CVector ( const CVector<TData>& vecI ) :
|
||||||
std::vector<TData>(static_cast<const std::vector<TData>&>(vecI)),
|
std::vector<TData> ( static_cast<const std::vector<TData>&> ( vecI ) ),
|
||||||
iVectorSize(vecI.Size()) { pData = this->begin(); }
|
iVectorSize ( vecI.Size() ) { pData = this->begin(); }
|
||||||
|
|
||||||
void Init(const int iNewSize);
|
void Init ( const int iNewSize );
|
||||||
|
|
||||||
/* Use this init to give all elements a defined value */
|
// use this init to give all elements a defined value
|
||||||
void Init(const int iNewSize, const TData tIniVal);
|
void Init ( const int iNewSize, const TData tIniVal );
|
||||||
void Reset(const TData tResetVal);
|
void Reset ( const TData tResetVal );
|
||||||
|
|
||||||
void Enlarge(const int iAddedSize);
|
void Enlarge ( const int iAddedSize );
|
||||||
void Add(const TData& tI) {Enlarge(1); pData[iVectorSize - 1] = tI;}
|
void Add ( const TData& tI ) { Enlarge ( 1 ); pData[iVectorSize - 1] = tI; }
|
||||||
|
|
||||||
inline int Size() const {return iVectorSize;}
|
inline int Size() const { return iVectorSize; }
|
||||||
|
|
||||||
/* This operator allows for a l-value assignment of this object:
|
/* This operator allows for a l-value assignment of this object:
|
||||||
CVector[x] = y is possible */
|
CVector[x] = y is possible */
|
||||||
inline TData& operator[](const int iPos) {
|
inline TData& operator[] ( const int iPos ) {
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
if ((iPos < 0) || (iPos > iVectorSize - 1))
|
if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) )
|
||||||
{
|
{
|
||||||
DebugError("Writing vector out of bounds", "Vector size",
|
DebugError ( "Writing vector out of bounds", "Vector size",
|
||||||
iVectorSize, "New parameter", iPos);
|
iVectorSize, "New parameter", iPos );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return pData[iPos];}
|
return pData[iPos]; }
|
||||||
|
|
||||||
inline TData operator[](const int iPos) const {
|
inline TData operator[] ( const int iPos ) const {
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
if ((iPos < 0) || (iPos > iVectorSize - 1))
|
if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) )
|
||||||
{
|
{
|
||||||
DebugError("Reading vector out of bounds", "Vector size",
|
DebugError ( "Reading vector out of bounds", "Vector size",
|
||||||
iVectorSize, "New parameter", iPos);
|
iVectorSize, "New parameter", iPos );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return pData[iPos];}
|
return pData[iPos]; }
|
||||||
|
|
||||||
inline CVector<TData>& operator=(const CVector<TData>& vecI) {
|
inline CVector<TData>& operator= ( const CVector<TData>& vecI ) {
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
/* Vectors which shall be copied MUST have same size! (If this is
|
/* Vectors which shall be copied MUST have same size! (If this is
|
||||||
satisfied, the parameter "iVectorSize" must not be adjusted as
|
satisfied, the parameter "iVectorSize" must not be adjusted as
|
||||||
a side effect) */
|
a side effect) */
|
||||||
if (vecI.Size() != iVectorSize)
|
if ( vecI.Size() != iVectorSize )
|
||||||
{
|
{
|
||||||
DebugError("Vector operator=() different size", "Vector size",
|
DebugError ( "Vector operator=() different size", "Vector size",
|
||||||
iVectorSize, "New parameter", vecI.Size());
|
iVectorSize, "New parameter", vecI.Size() );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
vector<TData>::operator=(vecI);
|
vector<TData>::operator= ( vecI );
|
||||||
|
|
||||||
/* Reset my data pointer in case, the operator=() of the base class
|
/* Reset my data pointer in case, the operator=() of the base class
|
||||||
did change the actual memory */
|
did change the actual memory */
|
||||||
|
@ -145,42 +149,44 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
/* Implementation *************************************************************/
|
/* Implementation *************************************************************/
|
||||||
template<class TData> void CVector<TData>::Init(const int iNewSize)
|
template<class TData> void CVector<TData>::Init ( const int iNewSize )
|
||||||
{
|
{
|
||||||
iVectorSize = iNewSize;
|
iVectorSize = iNewSize;
|
||||||
|
|
||||||
/* Clear old buffer and reserve memory for new buffer, get iterator
|
/* Clear old buffer and reserve memory for new buffer, get iterator
|
||||||
for pointer operations */
|
for pointer operations */
|
||||||
this->clear();
|
this->clear();
|
||||||
this->resize(iNewSize);
|
this->resize ( iNewSize );
|
||||||
pData = this->begin();
|
pData = this->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CVector<TData>::Init(const int iNewSize,
|
template<class TData> void CVector<TData>::Init ( const int iNewSize,
|
||||||
const TData tIniVal)
|
const TData tIniVal )
|
||||||
{
|
{
|
||||||
/* Call actual init routine */
|
// call actual init routine
|
||||||
Init(iNewSize);
|
Init ( iNewSize );
|
||||||
|
|
||||||
/* Set values */
|
// set values
|
||||||
Reset(tIniVal);
|
Reset ( tIniVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CVector<TData>::Enlarge(const int iAddedSize)
|
template<class TData> void CVector<TData>::Enlarge ( const int iAddedSize )
|
||||||
{
|
{
|
||||||
iVectorSize += iAddedSize;
|
iVectorSize += iAddedSize;
|
||||||
this->resize(iVectorSize);
|
this->resize ( iVectorSize );
|
||||||
|
|
||||||
/* We have to reset the pointer since it could be that the vector size was
|
/* We have to reset the pointer since it could be that the vector size was
|
||||||
zero before enlarging the vector */
|
zero before enlarging the vector */
|
||||||
pData = this->begin();
|
pData = this->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CVector<TData>::Reset(const TData tResetVal)
|
template<class TData> void CVector<TData>::Reset ( const TData tResetVal )
|
||||||
{
|
{
|
||||||
/* Set all values to reset value */
|
// set all values to reset value
|
||||||
for (int i = 0; i < iVectorSize; i++)
|
for ( int i = 0; i < iVectorSize; i++ )
|
||||||
|
{
|
||||||
pData[i] = tResetVal;
|
pData[i] = tResetVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,42 +196,44 @@ template<class TData> void CVector<TData>::Reset(const TData tResetVal)
|
||||||
template<class TData> class CFIFO : public CVector<TData>
|
template<class TData> class CFIFO : public CVector<TData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CFIFO() : CVector<TData>(), iCurIdx(0) {}
|
CFIFO() : CVector<TData>(), iCurIdx ( 0 ) {}
|
||||||
CFIFO(const int iNeSi) : CVector<TData>(iNeSi), iCurIdx(0) {}
|
CFIFO ( const int iNeSi ) : CVector<TData>(iNeSi), iCurIdx ( 0 ) {}
|
||||||
CFIFO(const int iNeSi, const TData tInVa) :
|
CFIFO ( const int iNeSi, const TData tInVa ) :
|
||||||
CVector<TData>(iNeSi, tInVa), iCurIdx(0) {}
|
CVector<TData> ( iNeSi, tInVa ), iCurIdx ( 0 ) {}
|
||||||
|
|
||||||
void Add(const TData tNewD);
|
void Add ( const TData tNewD );
|
||||||
inline TData Get() {return this->pData[iCurIdx];}
|
inline TData Get() { return this->pData[iCurIdx]; }
|
||||||
|
|
||||||
virtual void Init(const int iNewSize);
|
virtual void Init ( const int iNewSize );
|
||||||
virtual void Init(const int iNewSize, const TData tIniVal);
|
virtual void Init ( const int iNewSize, const TData tIniVal );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int iCurIdx;
|
int iCurIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class TData> void CFIFO<TData>::Init(const int iNewSize)
|
template<class TData> void CFIFO<TData>::Init ( const int iNewSize )
|
||||||
{
|
{
|
||||||
iCurIdx = 0;
|
iCurIdx = 0;
|
||||||
CVector<TData>::Init(iNewSize);
|
CVector<TData>::Init ( iNewSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CFIFO<TData>::Init(const int iNewSize,
|
template<class TData> void CFIFO<TData>::Init ( const int iNewSize,
|
||||||
const TData tIniVal)
|
const TData tIniVal )
|
||||||
{
|
{
|
||||||
iCurIdx = 0;
|
iCurIdx = 0;
|
||||||
CVector<TData>::Init(iNewSize, tIniVal);
|
CVector<TData>::Init ( iNewSize, tIniVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CFIFO<TData>::Add(const TData tNewD)
|
template<class TData> void CFIFO<TData>::Add ( const TData tNewD )
|
||||||
{
|
{
|
||||||
this->pData[iCurIdx] = tNewD;
|
this->pData[iCurIdx] = tNewD;
|
||||||
|
|
||||||
/* Increment index */
|
// increment index
|
||||||
iCurIdx++;
|
iCurIdx++;
|
||||||
if (iCurIdx >= this->iVectorSize)
|
if ( iCurIdx >= this->iVectorSize )
|
||||||
|
{
|
||||||
iCurIdx = 0;
|
iCurIdx = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,23 +243,29 @@ template<class TData> void CFIFO<TData>::Add(const TData tNewD)
|
||||||
template<class TData> class CMovingAv : public CVector<TData>
|
template<class TData> class CMovingAv : public CVector<TData>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CMovingAv() : CVector<TData>(), iCurIdx(0), iNorm(0),
|
CMovingAv() : CVector<TData>(), iCurIdx ( 0 ), iNorm ( 0 ),
|
||||||
tCurAvResult(TData(0)) {}
|
tCurAvResult ( TData ( 0 ) ) {}
|
||||||
CMovingAv(const int iNeSi) : CVector<TData>(iNeSi), iCurIdx(0), iNorm(0),
|
CMovingAv ( const int iNeSi ) : CVector<TData> ( iNeSi ), iCurIdx ( 0 ), iNorm ( 0 ),
|
||||||
tCurAvResult(TData(0)) {}
|
tCurAvResult ( TData ( 0 ) ) {}
|
||||||
CMovingAv(const int iNeSi, const TData tInVa) :
|
CMovingAv ( const int iNeSi, const TData tInVa ) :
|
||||||
CVector<TData>(iNeSi, tInVa), iCurIdx(0), iNorm(0),
|
CVector<TData> ( iNeSi, tInVa ), iCurIdx ( 0 ), iNorm ( 0 ),
|
||||||
tCurAvResult(TData(0)) {}
|
tCurAvResult ( TData ( 0 ) ) {}
|
||||||
|
|
||||||
void Add(const TData tNewD);
|
void Add ( const TData tNewD );
|
||||||
inline TData GetAverage()
|
inline TData GetAverage()
|
||||||
{
|
{
|
||||||
if (this->iNorm == 0) return TData(0);
|
if ( this->iNorm == 0 )
|
||||||
else return tCurAvResult / this->iNorm;
|
{
|
||||||
|
return TData ( 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return tCurAvResult / this->iNorm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Init(const int iNewSize);
|
virtual void Init ( const int iNewSize );
|
||||||
void InitVec(const int iNewSize, const int iNewVecSize);
|
void InitVec ( const int iNewSize, const int iNewVecSize );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int iCurIdx;
|
int iCurIdx;
|
||||||
|
@ -259,36 +273,40 @@ protected:
|
||||||
TData tCurAvResult;
|
TData tCurAvResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class TData> void CMovingAv<TData>::Init(const int iNewSize)
|
template<class TData> void CMovingAv<TData>::Init ( const int iNewSize )
|
||||||
{
|
{
|
||||||
iNorm = 0;
|
iNorm = 0;
|
||||||
iCurIdx = 0;
|
iCurIdx = 0;
|
||||||
tCurAvResult = TData(0); /* Only for scalars! */
|
tCurAvResult = TData ( 0 ); // only for scalars!
|
||||||
CVector<TData>::Init(iNewSize);
|
CVector<TData>::Init ( iNewSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class TData> void CMovingAv<TData>::Add(const TData tNewD)
|
template<class TData> void CMovingAv<TData>::Add ( const TData tNewD )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Optimized calculation of the moving average. We only add a new value and
|
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
|
subtract the old value from the result. We only need one addition and a
|
||||||
history buffer
|
history buffer
|
||||||
*/
|
*/
|
||||||
/* Subtract oldest value */
|
// subtract oldest value
|
||||||
tCurAvResult -= this->pData[iCurIdx];
|
tCurAvResult -= this->pData[iCurIdx];
|
||||||
|
|
||||||
/* Add new value and write in memory */
|
// add new value and write in memory
|
||||||
tCurAvResult += tNewD;
|
tCurAvResult += tNewD;
|
||||||
this->pData[iCurIdx] = tNewD;
|
this->pData[iCurIdx] = tNewD;
|
||||||
|
|
||||||
/* Increase position pointer and test if wrap */
|
// increase position pointer and test if wrap
|
||||||
iCurIdx++;
|
iCurIdx++;
|
||||||
if (iCurIdx >= this->iVectorSize)
|
if ( iCurIdx >= this->iVectorSize )
|
||||||
|
{
|
||||||
iCurIdx = 0;
|
iCurIdx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* take care of norm */
|
// take care of norm
|
||||||
if (this->iNorm < this->iVectorSize)
|
if ( this->iNorm < this->iVectorSize )
|
||||||
|
{
|
||||||
this->iNorm++;
|
this->iNorm++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -301,8 +319,8 @@ class CAboutDlg : public CAboutDlgBase
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAboutDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE,
|
CAboutDlg ( QWidget* parent = 0, const char* name = 0, bool modal = FALSE,
|
||||||
WFlags f = 0);
|
WFlags f = 0 );
|
||||||
|
|
||||||
static QString GetVersionAndNameStr ( const bool bWithHtml = true );
|
static QString GetVersionAndNameStr ( const bool bWithHtml = true );
|
||||||
};
|
};
|
||||||
|
@ -314,14 +332,14 @@ class CLlconHelpMenu : public QPopupMenu
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLlconHelpMenu(QWidget* parent = 0);
|
CLlconHelpMenu ( QWidget* parent = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CAboutDlg AboutDlg;
|
CAboutDlg AboutDlg;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnHelpWhatsThis () { QWhatsThis::enterWhatsThisMode (); }
|
void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); }
|
||||||
void OnHelpAbout () { AboutDlg.exec(); }
|
void OnHelpAbout() { AboutDlg.exec(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,12 +348,12 @@ public slots:
|
||||||
class CSignalLevelMeter
|
class CSignalLevelMeter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSignalLevelMeter() : dCurLevel(0.0) {}
|
CSignalLevelMeter() : dCurLevel ( 0.0 ) {}
|
||||||
virtual ~CSignalLevelMeter() {}
|
virtual ~CSignalLevelMeter() {}
|
||||||
|
|
||||||
void Update(CVector<double>& vecdAudio);
|
void Update ( CVector<double>& vecdAudio );
|
||||||
double MicLevel();
|
double MicLevel();
|
||||||
void Reset() {dCurLevel = 0.0;}
|
void Reset() { dCurLevel = 0.0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double dCurLevel;
|
double dCurLevel;
|
||||||
|
@ -344,17 +362,17 @@ protected:
|
||||||
class CHostAddress
|
class CHostAddress
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CHostAddress() : InetAddr((Q_UINT32) 0), iPort(0) {}
|
CHostAddress() : InetAddr ( (Q_UINT32) 0 ), iPort ( 0 ) {}
|
||||||
CHostAddress(const QHostAddress NInetAddr, const Q_UINT16 iNPort) :
|
CHostAddress ( const QHostAddress NInetAddr, const Q_UINT16 iNPort ) :
|
||||||
InetAddr(NInetAddr), iPort(iNPort) {}
|
InetAddr ( NInetAddr ), iPort ( iNPort ) {}
|
||||||
CHostAddress(const CHostAddress& NHAddr) :
|
CHostAddress ( const CHostAddress& NHAddr ) :
|
||||||
InetAddr(NHAddr.InetAddr), iPort(NHAddr.iPort) {}
|
InetAddr ( NHAddr.InetAddr ), iPort ( NHAddr.iPort ) {}
|
||||||
|
|
||||||
/* copy and compare operators */
|
// copy and compare operators
|
||||||
CHostAddress& operator=(const CHostAddress& NHAddr)
|
CHostAddress& operator= ( const CHostAddress& NHAddr )
|
||||||
{InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this;}
|
{ InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this; }
|
||||||
bool operator==(const CHostAddress& CompAddr) /* oompare operator */
|
bool operator== ( const CHostAddress& CompAddr ) // compare operator
|
||||||
{return ((CompAddr.InetAddr == InetAddr) && (CompAddr.iPort == iPort));}
|
{ return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); }
|
||||||
|
|
||||||
QHostAddress InetAddr;
|
QHostAddress InetAddr;
|
||||||
Q_UINT16 iPort;
|
Q_UINT16 iPort;
|
||||||
|
@ -377,14 +395,14 @@ public:
|
||||||
class CAudioReverb
|
class CAudioReverb
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAudioReverb(const double rT60 = (double) 5.0);
|
CAudioReverb ( const double rT60 = (double) 5.0 );
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
double ProcessSample(const double input);
|
double ProcessSample ( const double input );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setT60(const double rT60);
|
void setT60 ( const double rT60 );
|
||||||
bool isPrime(const int number);
|
bool isPrime ( const int number );
|
||||||
|
|
||||||
CFIFO<int> allpassDelays_[3];
|
CFIFO<int> allpassDelays_[3];
|
||||||
CFIFO<int> combDelays_[4];
|
CFIFO<int> combDelays_[4];
|
||||||
|
@ -397,14 +415,14 @@ protected:
|
||||||
class CCRC
|
class CCRC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCRC () : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 )
|
CCRC() : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 )
|
||||||
{ Reset (); }
|
{ Reset(); }
|
||||||
virtual ~CCRC () {}
|
virtual ~CCRC() {}
|
||||||
|
|
||||||
void Reset ();
|
void Reset();
|
||||||
void AddByte ( const uint8_t byNewInput );
|
void AddByte ( const uint8_t byNewInput );
|
||||||
bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); }
|
bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); }
|
||||||
uint32_t GetCRC ();
|
uint32_t GetCRC();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t iBitOutMask;
|
uint32_t iBitOutMask;
|
||||||
|
@ -424,11 +442,11 @@ public:
|
||||||
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
|
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
|
||||||
CVector<unsigned char> veccNetTi ( 5 );
|
CVector<unsigned char> veccNetTi ( 5 );
|
||||||
|
|
||||||
veccNetTi[0] = static_cast<unsigned char> ( qTiIn.hour () );
|
veccNetTi[0] = static_cast<unsigned char> ( qTiIn.hour() );
|
||||||
veccNetTi[1] = static_cast<unsigned char> ( qTiIn.minute () );
|
veccNetTi[1] = static_cast<unsigned char> ( qTiIn.minute() );
|
||||||
veccNetTi[2] = static_cast<unsigned char> ( qTiIn.second () );
|
veccNetTi[2] = static_cast<unsigned char> ( qTiIn.second() );
|
||||||
|
|
||||||
const int iMs = qTiIn.msec ();
|
const int iMs = qTiIn.msec();
|
||||||
veccNetTi[3] = static_cast<unsigned char> ( ( iMs >> 8 ) & 255 );
|
veccNetTi[3] = static_cast<unsigned char> ( ( iMs >> 8 ) & 255 );
|
||||||
veccNetTi[4] = static_cast<unsigned char> ( iMs & 255 );
|
veccNetTi[4] = static_cast<unsigned char> ( iMs & 255 );
|
||||||
|
|
||||||
|
@ -505,4 +523,4 @@ protected:
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !defined(UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_) */
|
#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|
||||||
|
|
|
@ -32,183 +32,203 @@
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Wave in *
|
* Wave in *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
bool CSound::Read(CVector<short>& psData)
|
bool CSound::Read ( CVector<short>& psData )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool bError;
|
bool bError;
|
||||||
|
|
||||||
/* Check if device must be opened or reinitialized */
|
// check if device must be opened or reinitialized
|
||||||
if (bChangParamIn == TRUE)
|
if ( bChangParamIn == TRUE )
|
||||||
{
|
{
|
||||||
OpenInDevice();
|
OpenInDevice();
|
||||||
|
|
||||||
/* Reinit sound interface */
|
// Reinit sound interface
|
||||||
InitRecording(iBufferSizeIn, bBlockingRec);
|
InitRecording ( iBufferSizeIn, bBlockingRec );
|
||||||
|
|
||||||
/* Reset flag */
|
// Reset flag
|
||||||
bChangParamIn = FALSE;
|
bChangParamIn = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until data is available */
|
// wait until data is available
|
||||||
if (!(m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE))
|
if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) )
|
||||||
{
|
{
|
||||||
if (bBlockingRec == TRUE)
|
if ( bBlockingRec == TRUE )
|
||||||
WaitForSingleObject(m_WaveInEvent, INFINITE);
|
{
|
||||||
|
WaitForSingleObject ( m_WaveInEvent, INFINITE );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if buffers got lost */
|
// check if buffers got lost
|
||||||
int iNumInBufDone = 0;
|
int iNumInBufDone = 0;
|
||||||
for (i = 0; i < iCurNumSndBufIn; i++)
|
for ( i = 0; i < iCurNumSndBufIn; i++ )
|
||||||
|
{
|
||||||
|
if ( m_WaveInHeader[i].dwFlags & WHDR_DONE )
|
||||||
{
|
{
|
||||||
if (m_WaveInHeader[i].dwFlags & WHDR_DONE)
|
|
||||||
iNumInBufDone++;
|
iNumInBufDone++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If the number of done buffers equals the total number of buffers, it is
|
/* If the number of done buffers equals the total number of buffers, it is
|
||||||
very likely that a buffer got lost -> set error flag */
|
very likely that a buffer got lost -> set error flag */
|
||||||
if (iNumInBufDone == iCurNumSndBufIn)
|
if ( iNumInBufDone == iCurNumSndBufIn )
|
||||||
|
{
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bError = FALSE;
|
bError = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy data from sound card in output buffer */
|
// copy data from sound card in output buffer
|
||||||
for (i = 0; i < iBufferSizeIn; i++)
|
for ( i = 0; i < iBufferSizeIn; i++ )
|
||||||
|
{
|
||||||
psData[i] = psSoundcardBuffer[iWhichBufferIn][i];
|
psData[i] = psSoundcardBuffer[iWhichBufferIn][i];
|
||||||
|
}
|
||||||
|
|
||||||
/* Add the buffer so that it can be filled with new samples */
|
// add the buffer so that it can be filled with new samples
|
||||||
AddInBuffer();
|
AddInBuffer();
|
||||||
|
|
||||||
/* In case more than one buffer was ready, reset event */
|
// in case more than one buffer was ready, reset event
|
||||||
ResetEvent(m_WaveInEvent);
|
ResetEvent ( m_WaveInEvent );
|
||||||
|
|
||||||
return bError;
|
return bError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::AddInBuffer()
|
void CSound::AddInBuffer()
|
||||||
{
|
{
|
||||||
/* Unprepare old wave-header */
|
// unprepare old wave-header
|
||||||
waveInUnprepareHeader(
|
waveInUnprepareHeader (
|
||||||
m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof(WAVEHDR));
|
m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
/* Prepare buffers for sending to sound interface */
|
// prepare buffers for sending to sound interface
|
||||||
PrepareInBuffer(iWhichBufferIn);
|
PrepareInBuffer ( iWhichBufferIn );
|
||||||
|
|
||||||
/* Send buffer to driver for filling with new data */
|
// send buffer to driver for filling with new data
|
||||||
waveInAddBuffer(m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof(WAVEHDR));
|
waveInAddBuffer ( m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
/* Toggle buffers */
|
// toggle buffers
|
||||||
iWhichBufferIn++;
|
iWhichBufferIn++;
|
||||||
if (iWhichBufferIn == iCurNumSndBufIn)
|
if ( iWhichBufferIn == iCurNumSndBufIn )
|
||||||
|
{
|
||||||
iWhichBufferIn = 0;
|
iWhichBufferIn = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::PrepareInBuffer(int iBufNum)
|
void CSound::PrepareInBuffer ( int iBufNum )
|
||||||
{
|
{
|
||||||
/* Set struct entries */
|
// set struct entries
|
||||||
m_WaveInHeader[iBufNum].lpData = (LPSTR) &psSoundcardBuffer[iBufNum][0];
|
m_WaveInHeader[iBufNum].lpData = (LPSTR) &psSoundcardBuffer[iBufNum][0];
|
||||||
m_WaveInHeader[iBufNum].dwBufferLength = iBufferSizeIn * BYTES_PER_SAMPLE;
|
m_WaveInHeader[iBufNum].dwBufferLength = iBufferSizeIn * BYTES_PER_SAMPLE;
|
||||||
m_WaveInHeader[iBufNum].dwFlags = 0;
|
m_WaveInHeader[iBufNum].dwFlags = 0;
|
||||||
|
|
||||||
/* Prepare wave-header */
|
// prepare wave-header
|
||||||
waveInPrepareHeader(m_WaveIn, &m_WaveInHeader[iBufNum], sizeof(WAVEHDR));
|
waveInPrepareHeader ( m_WaveIn, &m_WaveInHeader[iBufNum], sizeof ( WAVEHDR ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::InitRecording(int iNewBufferSize, bool bNewBlocking)
|
void CSound::InitRecording ( int iNewBufferSize, bool bNewBlocking )
|
||||||
{
|
{
|
||||||
/* Check if device must be opened or reinitialized */
|
// check if device must be opened or reinitialized
|
||||||
if (bChangParamIn == TRUE)
|
if ( bChangParamIn == TRUE )
|
||||||
{
|
{
|
||||||
OpenInDevice();
|
OpenInDevice();
|
||||||
|
|
||||||
/* Reset flag */
|
// reset flag
|
||||||
bChangParamIn = FALSE;
|
bChangParamIn = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set internal parameter */
|
// set internal parameter
|
||||||
iBufferSizeIn = iNewBufferSize;
|
iBufferSizeIn = iNewBufferSize;
|
||||||
bBlockingRec = bNewBlocking;
|
bBlockingRec = bNewBlocking;
|
||||||
|
|
||||||
/* Reset interface so that all buffers are returned from the interface */
|
// reset interface so that all buffers are returned from the interface
|
||||||
waveInReset(m_WaveIn);
|
waveInReset ( m_WaveIn );
|
||||||
waveInStop(m_WaveIn);
|
waveInStop ( m_WaveIn );
|
||||||
|
|
||||||
/* Reset current buffer ID (it is important to do this BEFORE calling
|
/* reset current buffer ID (it is important to do this BEFORE calling
|
||||||
"AddInBuffer()" */
|
"AddInBuffer()" */
|
||||||
iWhichBufferIn = 0;
|
iWhichBufferIn = 0;
|
||||||
|
|
||||||
/* Create memory for sound card buffer */
|
// create memory for sound card buffer
|
||||||
for (int i = 0; i < iCurNumSndBufIn; i++)
|
for ( int i = 0; i < iCurNumSndBufIn; i++ )
|
||||||
{
|
{
|
||||||
/* Unprepare old wave-header in case that we "re-initialized" this
|
/* Unprepare old wave-header in case that we "re-initialized" this
|
||||||
module. Calling "waveInUnprepareHeader()" with an unprepared
|
module. Calling "waveInUnprepareHeader()" with an unprepared
|
||||||
buffer (when the module is initialized for the first time) has
|
buffer (when the module is initialized for the first time) has
|
||||||
simply no effect */
|
simply no effect */
|
||||||
waveInUnprepareHeader(m_WaveIn, &m_WaveInHeader[i], sizeof(WAVEHDR));
|
waveInUnprepareHeader ( m_WaveIn, &m_WaveInHeader[i], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
if (psSoundcardBuffer[i] != NULL)
|
if ( psSoundcardBuffer[i] != NULL )
|
||||||
|
{
|
||||||
delete[] psSoundcardBuffer[i];
|
delete[] psSoundcardBuffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
psSoundcardBuffer[i] = new short[iBufferSizeIn];
|
psSoundcardBuffer[i] = new short[iBufferSizeIn];
|
||||||
|
|
||||||
|
|
||||||
/* Send all buffers to driver for filling the queue ----------------- */
|
/* Send all buffers to driver for filling the queue ----------------- */
|
||||||
/* Prepare buffers before sending them to the sound interface */
|
// prepare buffers before sending them to the sound interface
|
||||||
PrepareInBuffer(i);
|
PrepareInBuffer ( i );
|
||||||
|
|
||||||
AddInBuffer();
|
AddInBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify that sound capturing can start now */
|
// notify that sound capturing can start now
|
||||||
waveInStart(m_WaveIn);
|
waveInStart ( m_WaveIn );
|
||||||
|
|
||||||
/* This reset event is very important for initialization, otherwise we will
|
/* This reset event is very important for initialization, otherwise we will
|
||||||
get errors! */
|
get errors! */
|
||||||
ResetEvent(m_WaveInEvent);
|
ResetEvent ( m_WaveInEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::OpenInDevice()
|
void CSound::OpenInDevice()
|
||||||
{
|
{
|
||||||
/* Open wave-input and set call-back mechanism to event handle */
|
// open wave-input and set call-back mechanism to event handle
|
||||||
if (m_WaveIn != NULL)
|
if ( m_WaveIn != NULL )
|
||||||
{
|
{
|
||||||
waveInReset(m_WaveIn);
|
waveInReset ( m_WaveIn );
|
||||||
waveInClose(m_WaveIn);
|
waveInClose ( m_WaveIn );
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT result = waveInOpen(&m_WaveIn, iCurInDev, &sWaveFormatEx,
|
MMRESULT result = waveInOpen ( &m_WaveIn, iCurInDev, &sWaveFormatEx,
|
||||||
(DWORD) m_WaveInEvent, NULL, CALLBACK_EVENT);
|
(DWORD) m_WaveInEvent, NULL, CALLBACK_EVENT );
|
||||||
|
|
||||||
if (result != MMSYSERR_NOERROR)
|
if ( result != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
throw CGenErr("Sound Interface Start, waveInOpen() failed. This error "
|
throw CGenErr ( "Sound Interface Start, waveInOpen() failed. This error "
|
||||||
"usually occurs if another application blocks the sound in.");
|
"usually occurs if another application blocks the sound in." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::SetInDev(int iNewDev)
|
void CSound::SetInDev ( int iNewDev )
|
||||||
{
|
{
|
||||||
/* Set device to wave mapper if iNewDev is invalid */
|
// set device to wave mapper if iNewDev is invalid
|
||||||
if ((iNewDev >= iNumDevs) || (iNewDev < 0))
|
if ( ( iNewDev >= iNumDevs ) || ( iNewDev < 0 ) )
|
||||||
|
{
|
||||||
iNewDev = WAVE_MAPPER;
|
iNewDev = WAVE_MAPPER;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change only in case new device id is not already active */
|
// change only in case new device id is not already active
|
||||||
if (iNewDev != iCurInDev)
|
if ( iNewDev != iCurInDev )
|
||||||
{
|
{
|
||||||
iCurInDev = iNewDev;
|
iCurInDev = iNewDev;
|
||||||
bChangParamIn = TRUE;
|
bChangParamIn = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::SetInNumBuf(int iNewNum)
|
void CSound::SetInNumBuf ( int iNewNum )
|
||||||
{
|
{
|
||||||
/* check new parameter */
|
// check new parameter
|
||||||
if ((iNewNum >= MAX_SND_BUF_IN) || (iNewNum < 1))
|
if ( ( iNewNum >= MAX_SND_BUF_IN ) || ( iNewNum < 1 ) )
|
||||||
|
{
|
||||||
iNewNum = NUM_SOUND_BUFFERS_IN;
|
iNewNum = NUM_SOUND_BUFFERS_IN;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change only if parameter is different */
|
// change only if parameter is different
|
||||||
if (iNewNum != iCurNumSndBufIn)
|
if ( iNewNum != iCurNumSndBufIn )
|
||||||
{
|
{
|
||||||
iCurNumSndBufIn = iNewNum;
|
iCurNumSndBufIn = iNewNum;
|
||||||
bChangParamIn = TRUE;
|
bChangParamIn = TRUE;
|
||||||
|
@ -219,41 +239,41 @@ void CSound::SetInNumBuf(int iNewNum)
|
||||||
/******************************************************************************\
|
/******************************************************************************\
|
||||||
* Wave out *
|
* Wave out *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
bool CSound::Write(CVector<short>& psData)
|
bool CSound::Write ( CVector<short>& psData )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int iCntPrepBuf;
|
int iCntPrepBuf;
|
||||||
int iIndexDoneBuf;
|
int iIndexDoneBuf;
|
||||||
bool bError;
|
bool bError;
|
||||||
|
|
||||||
/* Check if device must be opened or reinitialized */
|
// check if device must be opened or reinitialized
|
||||||
if (bChangParamOut == TRUE)
|
if ( bChangParamOut == TRUE )
|
||||||
{
|
{
|
||||||
OpenOutDevice();
|
OpenOutDevice();
|
||||||
|
|
||||||
/* Reinit sound interface */
|
// reinit sound interface
|
||||||
InitPlayback(iBufferSizeOut, bBlockingPlay);
|
InitPlayback ( iBufferSizeOut, bBlockingPlay );
|
||||||
|
|
||||||
/* Reset flag */
|
// reset flag
|
||||||
bChangParamOut = FALSE;
|
bChangParamOut = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get number of "done"-buffers and position of one of them */
|
// get number of "done"-buffers and position of one of them
|
||||||
GetDoneBuffer(iCntPrepBuf, iIndexDoneBuf);
|
GetDoneBuffer ( iCntPrepBuf, iIndexDoneBuf );
|
||||||
|
|
||||||
/* Now check special cases (Buffer is full or empty) */
|
// now check special cases (Buffer is full or empty)
|
||||||
if (iCntPrepBuf == 0)
|
if ( iCntPrepBuf == 0 )
|
||||||
{
|
{
|
||||||
if (bBlockingPlay == TRUE)
|
if ( bBlockingPlay == TRUE )
|
||||||
{
|
{
|
||||||
/* Blocking wave out routine. Needed for transmitter. Always
|
/* Blocking wave out routine. Needed for transmitter. Always
|
||||||
ensure that the buffer is completely filled to avoid buffer
|
ensure that the buffer is completely filled to avoid buffer
|
||||||
underruns */
|
underruns */
|
||||||
while (iCntPrepBuf == 0)
|
while ( iCntPrepBuf == 0 )
|
||||||
{
|
{
|
||||||
WaitForSingleObject(m_WaveOutEvent, INFINITE);
|
WaitForSingleObject ( m_WaveOutEvent, INFINITE );
|
||||||
|
|
||||||
GetDoneBuffer(iCntPrepBuf, iIndexDoneBuf);
|
GetDoneBuffer ( iCntPrepBuf, iIndexDoneBuf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -261,50 +281,59 @@ bool CSound::Write(CVector<short>& psData)
|
||||||
/* All buffers are filled, dump new block ----------------------- */
|
/* All buffers are filled, dump new block ----------------------- */
|
||||||
// It would be better to kill half of the buffer blocks to set the start
|
// It would be better to kill half of the buffer blocks to set the start
|
||||||
// back to the middle: TODO
|
// back to the middle: TODO
|
||||||
return TRUE; /* An error occurred */
|
return TRUE; // an error occurred
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (iCntPrepBuf == iCurNumSndBufOut)
|
else
|
||||||
{
|
{
|
||||||
/* ---------------------------------------------------------------------
|
if ( iCntPrepBuf == iCurNumSndBufOut )
|
||||||
|
{
|
||||||
|
/* -----------------------------------------------------------------
|
||||||
Buffer is empty -> send as many cleared blocks to the sound-
|
Buffer is empty -> send as many cleared blocks to the sound-
|
||||||
interface until half of the buffer size is reached */
|
interface until half of the buffer size is reached */
|
||||||
/* Send half of the buffer size blocks to the sound-interface */
|
// send half of the buffer size blocks to the sound-interface
|
||||||
for (j = 0; j < iCurNumSndBufOut / 2; j++)
|
for ( j = 0; j < iCurNumSndBufOut / 2; j++ )
|
||||||
|
{
|
||||||
|
// first, clear these buffers
|
||||||
|
for ( i = 0; i < iBufferSizeOut; i++ )
|
||||||
{
|
{
|
||||||
/* First, clear these buffers */
|
|
||||||
for (i = 0; i < iBufferSizeOut; i++)
|
|
||||||
psPlaybackBuffer[j][i] = 0;
|
psPlaybackBuffer[j][i] = 0;
|
||||||
|
|
||||||
/* Then send them to the interface */
|
|
||||||
AddOutBuffer(j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set index for done buffer */
|
// then send them to the interface
|
||||||
|
AddOutBuffer ( j );
|
||||||
|
}
|
||||||
|
|
||||||
|
// set index for done buffer
|
||||||
iIndexDoneBuf = iCurNumSndBufOut / 2;
|
iIndexDoneBuf = iCurNumSndBufOut / 2;
|
||||||
|
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
bError = FALSE;
|
bError = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy stereo data from input in soundcard buffer */
|
// copy stereo data from input in soundcard buffer
|
||||||
for (i = 0; i < iBufferSizeOut; i++)
|
for ( i = 0; i < iBufferSizeOut; i++ )
|
||||||
|
{
|
||||||
psPlaybackBuffer[iIndexDoneBuf][i] = psData[i];
|
psPlaybackBuffer[iIndexDoneBuf][i] = psData[i];
|
||||||
|
}
|
||||||
|
|
||||||
/* Now, send the current block */
|
// now, send the current block
|
||||||
AddOutBuffer(iIndexDoneBuf);
|
AddOutBuffer ( iIndexDoneBuf );
|
||||||
|
|
||||||
return bError;
|
return bError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf)
|
void CSound::GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf )
|
||||||
{
|
{
|
||||||
/* Get number of "done"-buffers and position of one of them */
|
// get number of "done"-buffers and position of one of them
|
||||||
iCntPrepBuf = 0;
|
iCntPrepBuf = 0;
|
||||||
for (int i = 0; i < iCurNumSndBufOut; i++)
|
for ( int i = 0; i < iCurNumSndBufOut; i++ )
|
||||||
{
|
{
|
||||||
if (m_WaveOutHeader[i].dwFlags & WHDR_DONE)
|
if ( m_WaveOutHeader[i].dwFlags & WHDR_DONE )
|
||||||
{
|
{
|
||||||
iCntPrepBuf++;
|
iCntPrepBuf++;
|
||||||
iIndexDoneBuf = i;
|
iIndexDoneBuf = i;
|
||||||
|
@ -312,111 +341,121 @@ void CSound::GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::AddOutBuffer(int iBufNum)
|
void CSound::AddOutBuffer ( int iBufNum )
|
||||||
{
|
{
|
||||||
/* Unprepare old wave-header */
|
// Unprepare old wave-header
|
||||||
waveOutUnprepareHeader(
|
waveOutUnprepareHeader (
|
||||||
m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR));
|
m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
/* Prepare buffers for sending to sound interface */
|
// Prepare buffers for sending to sound interface
|
||||||
PrepareOutBuffer(iBufNum);
|
PrepareOutBuffer ( iBufNum );
|
||||||
|
|
||||||
/* Send buffer to driver for filling with new data */
|
// Send buffer to driver for filling with new data
|
||||||
waveOutWrite(m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR));
|
waveOutWrite ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::PrepareOutBuffer(int iBufNum)
|
void CSound::PrepareOutBuffer ( int iBufNum )
|
||||||
{
|
{
|
||||||
/* Set Header data */
|
// Set Header data
|
||||||
m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0];
|
m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0];
|
||||||
m_WaveOutHeader[iBufNum].dwBufferLength = iBufferSizeOut * BYTES_PER_SAMPLE;
|
m_WaveOutHeader[iBufNum].dwBufferLength = iBufferSizeOut * BYTES_PER_SAMPLE;
|
||||||
m_WaveOutHeader[iBufNum].dwFlags = 0;
|
m_WaveOutHeader[iBufNum].dwFlags = 0;
|
||||||
|
|
||||||
/* Prepare wave-header */
|
// Prepare wave-header
|
||||||
waveOutPrepareHeader(m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR));
|
waveOutPrepareHeader ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::InitPlayback(int iNewBufferSize, bool bNewBlocking)
|
void CSound::InitPlayback ( int iNewBufferSize, bool bNewBlocking )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
/* Check if device must be opened or reinitialized */
|
// check if device must be opened or reinitialized
|
||||||
if (bChangParamOut == TRUE)
|
if ( bChangParamOut == TRUE )
|
||||||
{
|
{
|
||||||
OpenOutDevice();
|
OpenOutDevice();
|
||||||
|
|
||||||
/* Reset flag */
|
// reset flag
|
||||||
bChangParamOut = FALSE;
|
bChangParamOut = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set internal parameters */
|
// set internal parameters
|
||||||
iBufferSizeOut = iNewBufferSize;
|
iBufferSizeOut = iNewBufferSize;
|
||||||
bBlockingPlay = bNewBlocking;
|
bBlockingPlay = bNewBlocking;
|
||||||
|
|
||||||
/* Reset interface */
|
// reset interface
|
||||||
waveOutReset(m_WaveOut);
|
waveOutReset ( m_WaveOut );
|
||||||
|
|
||||||
for (j = 0; j < iCurNumSndBufOut; j++)
|
for ( j = 0; j < iCurNumSndBufOut; j++ )
|
||||||
{
|
{
|
||||||
/* Unprepare old wave-header (in case header was not prepared before,
|
/* Unprepare old wave-header (in case header was not prepared before,
|
||||||
simply nothing happens with this function call */
|
simply nothing happens with this function call */
|
||||||
waveOutUnprepareHeader(m_WaveOut, &m_WaveOutHeader[j], sizeof(WAVEHDR));
|
waveOutUnprepareHeader ( m_WaveOut, &m_WaveOutHeader[j], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
/* Create memory for playback buffer */
|
// create memory for playback buffer
|
||||||
if (psPlaybackBuffer[j] != NULL)
|
if ( psPlaybackBuffer[j] != NULL )
|
||||||
|
{
|
||||||
delete[] psPlaybackBuffer[j];
|
delete[] psPlaybackBuffer[j];
|
||||||
|
}
|
||||||
|
|
||||||
psPlaybackBuffer[j] = new short[iBufferSizeOut];
|
psPlaybackBuffer[j] = new short[iBufferSizeOut];
|
||||||
|
|
||||||
/* Clear new buffer */
|
// clear new buffer
|
||||||
for (i = 0; i < iBufferSizeOut; i++)
|
for ( i = 0; i < iBufferSizeOut; i++ )
|
||||||
|
{
|
||||||
psPlaybackBuffer[j][i] = 0;
|
psPlaybackBuffer[j][i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Prepare buffer for sending to the sound interface */
|
// prepare buffer for sending to the sound interface
|
||||||
PrepareOutBuffer(j);
|
PrepareOutBuffer ( j );
|
||||||
|
|
||||||
/* Initially, send all buffers to the interface */
|
// initially, send all buffers to the interface
|
||||||
AddOutBuffer(j);
|
AddOutBuffer ( j );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::OpenOutDevice()
|
void CSound::OpenOutDevice()
|
||||||
{
|
{
|
||||||
if (m_WaveOut != NULL)
|
if ( m_WaveOut != NULL )
|
||||||
{
|
{
|
||||||
waveOutReset(m_WaveOut);
|
waveOutReset ( m_WaveOut );
|
||||||
waveOutClose(m_WaveOut);
|
waveOutClose ( m_WaveOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT result = waveOutOpen(&m_WaveOut, iCurOutDev, &sWaveFormatEx,
|
MMRESULT result = waveOutOpen ( &m_WaveOut, iCurOutDev, &sWaveFormatEx,
|
||||||
(DWORD) m_WaveOutEvent, NULL, CALLBACK_EVENT);
|
(DWORD) m_WaveOutEvent, NULL, CALLBACK_EVENT );
|
||||||
|
|
||||||
if (result != MMSYSERR_NOERROR)
|
if ( result != MMSYSERR_NOERROR )
|
||||||
throw CGenErr("Sound Interface Start, waveOutOpen() failed.");
|
{
|
||||||
|
throw CGenErr ( "Sound Interface Start, waveOutOpen() failed." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::SetOutDev(int iNewDev)
|
void CSound::SetOutDev ( int iNewDev )
|
||||||
{
|
{
|
||||||
/* Set device to wave mapper if iNewDev is invalid */
|
// set device to wave mapper if iNewDev is invalid
|
||||||
if ((iNewDev >= iNumDevs) || (iNewDev < 0))
|
if ( ( iNewDev >= iNumDevs ) || ( iNewDev < 0 ) )
|
||||||
|
{
|
||||||
iNewDev = WAVE_MAPPER;
|
iNewDev = WAVE_MAPPER;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change only in case new device id is not already active */
|
// change only in case new device id is not already active
|
||||||
if (iNewDev != iCurOutDev)
|
if ( iNewDev != iCurOutDev )
|
||||||
{
|
{
|
||||||
iCurOutDev = iNewDev;
|
iCurOutDev = iNewDev;
|
||||||
bChangParamOut = TRUE;
|
bChangParamOut = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSound::SetOutNumBuf(int iNewNum)
|
void CSound::SetOutNumBuf ( int iNewNum )
|
||||||
{
|
{
|
||||||
/* check new parameter */
|
// check new parameter
|
||||||
if ((iNewNum >= MAX_SND_BUF_OUT) || (iNewNum < 1))
|
if ( ( iNewNum >= MAX_SND_BUF_OUT ) || ( iNewNum < 1 ) )
|
||||||
|
{
|
||||||
iNewNum = NUM_SOUND_BUFFERS_OUT;
|
iNewNum = NUM_SOUND_BUFFERS_OUT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change only if parameter is different */
|
// change only if parameter is different
|
||||||
if (iNewNum != iCurNumSndBufOut)
|
if ( iNewNum != iCurNumSndBufOut )
|
||||||
{
|
{
|
||||||
iCurNumSndBufOut = iNewNum;
|
iCurNumSndBufOut = iNewNum;
|
||||||
bChangParamOut = TRUE;
|
bChangParamOut = TRUE;
|
||||||
|
@ -432,70 +471,82 @@ void CSound::Close()
|
||||||
int i;
|
int i;
|
||||||
MMRESULT result;
|
MMRESULT result;
|
||||||
|
|
||||||
/* Reset audio driver */
|
// reset audio driver
|
||||||
if (m_WaveOut != NULL)
|
if ( m_WaveOut != NULL )
|
||||||
{
|
{
|
||||||
result = waveOutReset(m_WaveOut);
|
result = waveOutReset ( m_WaveOut );
|
||||||
if (result != MMSYSERR_NOERROR)
|
|
||||||
throw CGenErr("Sound Interface, waveOutReset() failed.");
|
if ( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
|
throw CGenErr ( "Sound Interface, waveOutReset() failed." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_WaveIn != NULL)
|
if ( m_WaveIn != NULL )
|
||||||
{
|
{
|
||||||
result = waveInReset(m_WaveIn);
|
result = waveInReset ( m_WaveIn );
|
||||||
if (result != MMSYSERR_NOERROR)
|
|
||||||
throw CGenErr("Sound Interface, waveInReset() failed.");
|
if ( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
|
throw CGenErr ( "Sound Interface, waveInReset() failed." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set event to ensure that thread leaves the waiting function */
|
// set event to ensure that thread leaves the waiting function
|
||||||
if (m_WaveInEvent != NULL)
|
if ( m_WaveInEvent != NULL )
|
||||||
|
{
|
||||||
SetEvent(m_WaveInEvent);
|
SetEvent(m_WaveInEvent);
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for the thread to terminate */
|
// wait for the thread to terminate
|
||||||
Sleep(500);
|
Sleep ( 500 );
|
||||||
|
|
||||||
/* Unprepare wave-headers */
|
// unprepare wave-headers
|
||||||
if (m_WaveIn != NULL)
|
if ( m_WaveIn != NULL )
|
||||||
{
|
{
|
||||||
for (i = 0; i < iCurNumSndBufIn; i++)
|
for ( i = 0; i < iCurNumSndBufIn; i++ )
|
||||||
{
|
{
|
||||||
result = waveInUnprepareHeader(
|
result = waveInUnprepareHeader (
|
||||||
m_WaveIn, &m_WaveInHeader[i], sizeof(WAVEHDR));
|
m_WaveIn, &m_WaveInHeader[i], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
if (result != MMSYSERR_NOERROR)
|
if ( result != MMSYSERR_NOERROR )
|
||||||
{
|
{
|
||||||
throw CGenErr("Sound Interface, waveInUnprepareHeader()"
|
throw CGenErr ( "Sound Interface, waveInUnprepareHeader()"
|
||||||
" failed.");
|
" failed." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the sound in device */
|
// close the sound in device
|
||||||
result = waveInClose(m_WaveIn);
|
result = waveInClose ( m_WaveIn );
|
||||||
if (result != MMSYSERR_NOERROR)
|
if ( result != MMSYSERR_NOERROR )
|
||||||
throw CGenErr("Sound Interface, waveInClose() failed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_WaveOut != NULL)
|
|
||||||
{
|
{
|
||||||
for (i = 0; i < iCurNumSndBufOut; i++)
|
throw CGenErr ( "Sound Interface, waveInClose() failed." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_WaveOut != NULL )
|
||||||
{
|
{
|
||||||
result = waveOutUnprepareHeader(
|
for ( i = 0; i < iCurNumSndBufOut; i++ )
|
||||||
m_WaveOut, &m_WaveOutHeader[i], sizeof(WAVEHDR));
|
|
||||||
|
|
||||||
if (result != MMSYSERR_NOERROR)
|
|
||||||
{
|
{
|
||||||
throw CGenErr("Sound Interface, waveOutUnprepareHeader()"
|
result = waveOutUnprepareHeader (
|
||||||
" failed.");
|
m_WaveOut, &m_WaveOutHeader[i], sizeof ( WAVEHDR ) );
|
||||||
|
|
||||||
|
if ( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
|
throw CGenErr ( "Sound Interface, waveOutUnprepareHeader()"
|
||||||
|
" failed." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the sound out device */
|
// close the sound out device
|
||||||
result = waveOutClose(m_WaveOut);
|
result = waveOutClose ( m_WaveOut );
|
||||||
if (result != MMSYSERR_NOERROR)
|
if ( result != MMSYSERR_NOERROR )
|
||||||
throw CGenErr("Sound Interface, waveOutClose() failed.");
|
{
|
||||||
|
throw CGenErr ( "Sound Interface, waveOutClose() failed." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set flag to open devices the next time it is initialized */
|
// set flag to open devices the next time it is initialized
|
||||||
bChangParamIn = TRUE;
|
bChangParamIn = TRUE;
|
||||||
bChangParamOut = TRUE;
|
bChangParamOut = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -504,30 +555,30 @@ CSound::CSound()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* init number of sound buffers */
|
// init number of sound buffers
|
||||||
iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN;
|
iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN;
|
||||||
iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
||||||
|
|
||||||
/* Should be initialized because an error can occur during init */
|
// should be initialized because an error can occur during init
|
||||||
m_WaveInEvent = NULL;
|
m_WaveInEvent = NULL;
|
||||||
m_WaveOutEvent = NULL;
|
m_WaveOutEvent = NULL;
|
||||||
m_WaveIn = NULL;
|
m_WaveIn = NULL;
|
||||||
m_WaveOut = NULL;
|
m_WaveOut = NULL;
|
||||||
|
|
||||||
/* Init buffer pointer to zero */
|
// init buffer pointer to zero
|
||||||
for (i = 0; i < MAX_SND_BUF_IN; i++)
|
for ( i = 0; i < MAX_SND_BUF_IN; i++ )
|
||||||
{
|
{
|
||||||
memset(&m_WaveInHeader[i], 0, sizeof(WAVEHDR));
|
memset ( &m_WaveInHeader[i], 0, sizeof ( WAVEHDR ) );
|
||||||
psSoundcardBuffer[i] = NULL;
|
psSoundcardBuffer[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_SND_BUF_OUT; i++)
|
for ( i = 0; i < MAX_SND_BUF_OUT; i++ )
|
||||||
{
|
{
|
||||||
memset(&m_WaveOutHeader[i], 0, sizeof(WAVEHDR));
|
memset ( &m_WaveOutHeader[i], 0, sizeof ( WAVEHDR ) );
|
||||||
psPlaybackBuffer[i] = NULL;
|
psPlaybackBuffer[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init wave-format structure */
|
// init wave-format structure
|
||||||
sWaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
|
sWaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
sWaveFormatEx.nChannels = NUM_IN_OUT_CHANNELS;
|
sWaveFormatEx.nChannels = NUM_IN_OUT_CHANNELS;
|
||||||
sWaveFormatEx.wBitsPerSample = BITS_PER_SAMPLE;
|
sWaveFormatEx.wBitsPerSample = BITS_PER_SAMPLE;
|
||||||
|
@ -538,40 +589,46 @@ CSound::CSound()
|
||||||
sWaveFormatEx.nSamplesPerSec;
|
sWaveFormatEx.nSamplesPerSec;
|
||||||
sWaveFormatEx.cbSize = 0;
|
sWaveFormatEx.cbSize = 0;
|
||||||
|
|
||||||
/* Get the number of digital audio devices in this computer, check range */
|
// get the number of digital audio devices in this computer, check range
|
||||||
iNumDevs = waveInGetNumDevs();
|
iNumDevs = waveInGetNumDevs();
|
||||||
|
|
||||||
if (iNumDevs > MAX_NUMBER_SOUND_CARDS)
|
if ( iNumDevs > MAX_NUMBER_SOUND_CARDS )
|
||||||
iNumDevs = MAX_NUMBER_SOUND_CARDS;
|
|
||||||
|
|
||||||
/* At least one device must exist in the system */
|
|
||||||
if (iNumDevs == 0)
|
|
||||||
throw CGenErr("No audio device found.");
|
|
||||||
|
|
||||||
/* Get info about the devices and store the names */
|
|
||||||
for (i = 0; i < iNumDevs; i++)
|
|
||||||
{
|
{
|
||||||
if (!waveInGetDevCaps(i, &m_WaveInDevCaps, sizeof(WAVEINCAPS)))
|
iNumDevs = MAX_NUMBER_SOUND_CARDS;
|
||||||
pstrDevices[i] = m_WaveInDevCaps.szPname;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We use an event controlled wave-in (wave-out) structure */
|
// at least one device must exist in the system
|
||||||
/* Create events */
|
if ( iNumDevs == 0 )
|
||||||
m_WaveInEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
{
|
||||||
m_WaveOutEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
throw CGenErr ( "No audio device found." );
|
||||||
|
}
|
||||||
|
|
||||||
/* Set flag to open devices */
|
// get info about the devices and store the names
|
||||||
|
for ( i = 0; i < iNumDevs; i++ )
|
||||||
|
{
|
||||||
|
if ( !waveInGetDevCaps ( i, &m_WaveInDevCaps, sizeof ( WAVEINCAPS ) ) )
|
||||||
|
{
|
||||||
|
pstrDevices[i] = m_WaveInDevCaps.szPname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we use an event controlled wave-in (wave-out) structure
|
||||||
|
// create events
|
||||||
|
m_WaveInEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
||||||
|
m_WaveOutEvent = CreateEvent ( NULL, FALSE, FALSE, NULL );
|
||||||
|
|
||||||
|
// set flag to open devices
|
||||||
bChangParamIn = TRUE;
|
bChangParamIn = TRUE;
|
||||||
bChangParamOut = TRUE;
|
bChangParamOut = TRUE;
|
||||||
|
|
||||||
/* Default device number, "wave mapper" */
|
// default device number, "wave mapper"
|
||||||
iCurInDev = WAVE_MAPPER;
|
iCurInDev = WAVE_MAPPER;
|
||||||
iCurOutDev = WAVE_MAPPER;
|
iCurOutDev = WAVE_MAPPER;
|
||||||
|
|
||||||
/* Non-blocking wave out is default */
|
// non-blocking wave out is default
|
||||||
bBlockingPlay = FALSE;
|
bBlockingPlay = FALSE;
|
||||||
|
|
||||||
/* Blocking wave in is default */
|
// blocking wave in is default
|
||||||
bBlockingRec = TRUE;
|
bBlockingRec = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,23 +636,31 @@ CSound::~CSound()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Delete allocated memory */
|
// delete allocated memory
|
||||||
for (i = 0; i < iCurNumSndBufIn; i++)
|
for ( i = 0; i < iCurNumSndBufIn; i++ )
|
||||||
|
{
|
||||||
|
if ( psSoundcardBuffer[i] != NULL )
|
||||||
{
|
{
|
||||||
if (psSoundcardBuffer[i] != NULL)
|
|
||||||
delete[] psSoundcardBuffer[i];
|
delete[] psSoundcardBuffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < iCurNumSndBufOut; i++)
|
|
||||||
{
|
|
||||||
if (psPlaybackBuffer[i] != NULL)
|
|
||||||
delete[] psPlaybackBuffer[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the handle for the events */
|
for ( i = 0; i < iCurNumSndBufOut; i++ )
|
||||||
if (m_WaveInEvent != NULL)
|
{
|
||||||
CloseHandle(m_WaveInEvent);
|
if ( psPlaybackBuffer[i] != NULL )
|
||||||
|
{
|
||||||
|
delete[] psPlaybackBuffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_WaveOutEvent != NULL)
|
// close the handle for the events
|
||||||
CloseHandle(m_WaveOutEvent);
|
if ( m_WaveInEvent != NULL )
|
||||||
|
{
|
||||||
|
CloseHandle ( m_WaveInEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_WaveOutEvent != NULL )
|
||||||
|
{
|
||||||
|
CloseHandle ( m_WaveOutEvent );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*
|
*
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
|
|
||||||
#if !defined(AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_)
|
#if !defined ( AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ )
|
||||||
#define AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_
|
#define AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -36,16 +36,16 @@
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only
|
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only
|
||||||
use one channel for recording) */
|
use one channel for recording) */
|
||||||
#define BITS_PER_SAMPLE 16 /* Use all bits of the D/A-converter */
|
#define BITS_PER_SAMPLE 16 // use all bits of the D/A-converter
|
||||||
#define BYTES_PER_SAMPLE 2 /* Number of bytes per sample */
|
#define BYTES_PER_SAMPLE 2 // number of bytes per sample
|
||||||
|
|
||||||
#define MAX_SND_BUF_IN 200
|
#define MAX_SND_BUF_IN 200
|
||||||
#define MAX_SND_BUF_OUT 200
|
#define MAX_SND_BUF_OUT 200
|
||||||
|
|
||||||
#define NUM_SOUND_BUFFERS_IN (70 / MIN_BLOCK_DURATION_MS)
|
#define NUM_SOUND_BUFFERS_IN ( 70 / MIN_BLOCK_DURATION_MS )
|
||||||
#define NUM_SOUND_BUFFERS_OUT (80 / MIN_BLOCK_DURATION_MS)
|
#define NUM_SOUND_BUFFERS_OUT ( 80 / MIN_BLOCK_DURATION_MS )
|
||||||
|
|
||||||
/* Maximum number of recognized sound cards installed in the system */
|
// maximum number of recognized sound cards installed in the system
|
||||||
#define MAX_NUMBER_SOUND_CARDS 10
|
#define MAX_NUMBER_SOUND_CARDS 10
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,32 +56,32 @@ public:
|
||||||
CSound();
|
CSound();
|
||||||
virtual ~CSound();
|
virtual ~CSound();
|
||||||
|
|
||||||
void InitRecording(int iNewBufferSize, bool bNewBlocking = TRUE);
|
void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE );
|
||||||
void InitPlayback(int iNewBufferSize, bool bNewBlocking = FALSE);
|
void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE );
|
||||||
bool Read(CVector<short>& psData);
|
bool Read ( CVector<short>& psData );
|
||||||
bool Write(CVector<short>& psData);
|
bool Write ( CVector<short>& psData );
|
||||||
|
|
||||||
int GetNumDev() {return iNumDevs;}
|
int GetNumDev() { return iNumDevs; }
|
||||||
std::string GetDeviceName(int iDiD) {return pstrDevices[iDiD];}
|
std::string GetDeviceName ( int iDiD ) { return pstrDevices[iDiD]; }
|
||||||
void SetOutDev(int iNewDev);
|
void SetOutDev ( int iNewDev );
|
||||||
int GetOutDev() {return iCurOutDev;}
|
int GetOutDev() { return iCurOutDev; }
|
||||||
void SetInDev(int iNewDev);
|
void SetInDev ( int iNewDev );
|
||||||
int GetInDev() {return iCurInDev;}
|
int GetInDev() { return iCurInDev; }
|
||||||
void SetOutNumBuf(int iNewNum);
|
void SetOutNumBuf ( int iNewNum );
|
||||||
int GetOutNumBuf() {return iCurNumSndBufOut;}
|
int GetOutNumBuf() { return iCurNumSndBufOut; }
|
||||||
void SetInNumBuf(int iNewNum);
|
void SetInNumBuf ( int iNewNum );
|
||||||
int GetInNumBuf() {return iCurNumSndBufIn;}
|
int GetInNumBuf() { return iCurNumSndBufIn; }
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OpenInDevice();
|
void OpenInDevice();
|
||||||
void OpenOutDevice();
|
void OpenOutDevice();
|
||||||
void PrepareInBuffer(int iBufNum);
|
void PrepareInBuffer ( int iBufNum );
|
||||||
void PrepareOutBuffer(int iBufNum);
|
void PrepareOutBuffer ( int iBufNum );
|
||||||
void AddInBuffer();
|
void AddInBuffer();
|
||||||
void AddOutBuffer(int iBufNum);
|
void AddOutBuffer ( int iBufNum );
|
||||||
void GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf);
|
void GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf );
|
||||||
|
|
||||||
WAVEFORMATEX sWaveFormatEx;
|
WAVEFORMATEX sWaveFormatEx;
|
||||||
UINT iNumDevs;
|
UINT iNumDevs;
|
||||||
|
@ -93,7 +93,7 @@ protected:
|
||||||
int iCurNumSndBufIn;
|
int iCurNumSndBufIn;
|
||||||
int iCurNumSndBufOut;
|
int iCurNumSndBufOut;
|
||||||
|
|
||||||
/* Wave in */
|
// wave in
|
||||||
WAVEINCAPS m_WaveInDevCaps;
|
WAVEINCAPS m_WaveInDevCaps;
|
||||||
HWAVEIN m_WaveIn;
|
HWAVEIN m_WaveIn;
|
||||||
HANDLE m_WaveInEvent;
|
HANDLE m_WaveInEvent;
|
||||||
|
@ -103,7 +103,7 @@ protected:
|
||||||
short* psSoundcardBuffer[MAX_SND_BUF_IN];
|
short* psSoundcardBuffer[MAX_SND_BUF_IN];
|
||||||
bool bBlockingRec;
|
bool bBlockingRec;
|
||||||
|
|
||||||
/* Wave out */
|
// wave out
|
||||||
int iBufferSizeOut;
|
int iBufferSizeOut;
|
||||||
HWAVEOUT m_WaveOut;
|
HWAVEOUT m_WaveOut;
|
||||||
short* psPlaybackBuffer[MAX_SND_BUF_OUT];
|
short* psPlaybackBuffer[MAX_SND_BUF_OUT];
|
||||||
|
@ -113,4 +113,4 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_)
|
#endif // !defined ( AFX_SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ )
|
||||||
|
|
Loading…
Add table
Reference in a new issue