diff --git a/src/audiocompr.cpp b/src/audiocompr.cpp index cf52ca2d..132398c0 100755 --- a/src/audiocompr.cpp +++ b/src/audiocompr.cpp @@ -52,16 +52,16 @@ int CAudioCompression::Init ( const int iNewAudioLen, CVector CAudioCompression::Encode ( const CVector& vecsAudio ) { - if (eAudComprType == CT_NONE) + if ( eAudComprType == CT_NONE ) { /* no compression, simply ship pure samples */ - CVector vecbyOut(iCodeSize); + CVector vecbyOut ( iCodeSize ); 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 + 1] = (vecsAudio[i] >> 8) & 0xFF; + vecbyOut[2 * i + 1] = ( vecsAudio[i] >> 8 ) & 0xFF; } return vecbyOut; } @@ -78,19 +78,21 @@ CVector CAudioCompression::Encode ( const CVector& vecsAud } } -CVector CAudioCompression::Decode(const CVector& vecbyAdpcm) +CVector CAudioCompression::Decode ( const CVector& vecbyAdpcm ) { - if (eAudComprType == CT_NONE) + if ( eAudComprType == CT_NONE ) { /* no compression, reassemble pure samples */ const int iAudSize = iCodeSize / 2; - CVector vecsOut(iAudSize); + CVector 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; + } vecsOut[i] = (short) current; } @@ -111,38 +113,38 @@ CVector CAudioCompression::Decode(const CVector& vecbyAdpc /* IMA-ADPCM implementation ------------------------------------------------- */ -int CImaAdpcm::Init(const int iNewAudioLen) +int CImaAdpcm::Init ( const int iNewAudioLen ) { /* set lengths for audio and compressed data */ iAudSize = iNewAudioLen; - iAdpcmSize = 4 /* bytes header */ + (int) ceil( - (double) (iAudSize - 2 /* first two samples are in header */) / 2); + iAdpcmSize = 4 /* bytes header */ + (int) ceil ( + (double) ( iAudSize - 2 /* first two samples are in header */ ) / 2 ); iStepindEnc = 0; return iAdpcmSize; } -CVector CImaAdpcm::Encode(const CVector& vecsAudio) +CVector CImaAdpcm::Encode ( const CVector& vecsAudio ) { int i; CVector vecbyAdpcm; CVector vecbyAdpcmTemp; /* init size */ - vecbyAdpcm.Init(iAdpcmSize); - vecbyAdpcmTemp.Init(iAudSize); + vecbyAdpcm.Init ( iAdpcmSize ); + vecbyAdpcmTemp.Init ( iAudSize ); /* encode the block header ----------------------------------------------- */ vecbyAdpcm[0] = vecsAudio[0] & 0xFF; - vecbyAdpcm[1] = (vecsAudio[0] >> 8) & 0xFF; + vecbyAdpcm[1] = ( vecsAudio[0] >> 8 ) & 0xFF; vecbyAdpcm[2] = iStepindEnc; int iPrevAudio = vecsAudio[0]; /* encode the samples as 4 bit ------------------------------------------- */ - for (i = 1; i < iAudSize; i++) + for ( i = 1; i < iAudSize; i++ ) { /* init diff and step */ int diff = vecsAudio[i] - iPrevAudio; @@ -151,15 +153,15 @@ CVector CImaAdpcm::Encode(const CVector& vecsAudio) short bytecode = 0; int vpdiff = step >> 3; - if (diff < 0) + if ( diff < 0 ) { bytecode = 8; diff = -diff; } short mask = 4; - while (mask) + while ( mask ) { - if (diff >= step) + if ( diff >= step ) { bytecode |= mask; diff -= step; @@ -169,17 +171,21 @@ CVector CImaAdpcm::Encode(const CVector& vecsAudio) mask >>= 1; } - if (bytecode & 8) + if ( bytecode & 8 ) + { iPrevAudio -= vpdiff; + } else + { iPrevAudio += vpdiff; + } /* adjust step size */ iStepindEnc += ima_indx_adjust[bytecode]; /* check that values do not exceed the bounds */ - iPrevAudio = CheckBounds(iPrevAudio, _MINSHORT, _MAXSHORT); - iStepindEnc = CheckBounds(iStepindEnc, 0, IMA_STEP_SIZE_TAB_LEN - 1); + iPrevAudio = CheckBounds ( iPrevAudio, _MINSHORT, _MAXSHORT ); + iStepindEnc = CheckBounds ( iStepindEnc, 0, IMA_STEP_SIZE_TAB_LEN - 1 ); /* use the input buffer as an intermediate result buffer */ vecbyAdpcmTemp[i] = bytecode; @@ -190,30 +196,32 @@ CVector CImaAdpcm::Encode(const CVector& vecsAudio) /* The first encoded audio sample is in header */ 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 - 5] << 4) & 0xF0; + vecbyAdpcm[i] |= ( vecbyAdpcmTemp[2 * i - 5] << 4 ) & 0xF0; } return vecbyAdpcm; } -CVector CImaAdpcm::Decode(const CVector& vecbyAdpcm) +CVector CImaAdpcm::Decode ( const CVector& vecbyAdpcm ) { int i; CVector vecsAudio; - vecsAudio.Init(iAudSize); + vecsAudio.Init ( iAudSize ); /* read and check the block header --------------------------------------- */ - int current = vecbyAdpcm[0] | (vecbyAdpcm[1] << 8); - if (current & 0x8000) + int current = vecbyAdpcm[0] | ( vecbyAdpcm[1] << 8 ); + if ( current & 0x8000 ) + { current -= 0x10000; + } /* 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 */ vecsAudio[0] = current; @@ -225,16 +233,16 @@ CVector CImaAdpcm::Decode(const CVector& vecbyAdpcm) /* The first encoded audio sample is in header */ vecsAudio[1] = vecbyAdpcm[3] & 0x0F; - for (i = 4; i < iAdpcmSize; i++) + for ( i = 4; i < iAdpcmSize; i++ ) { const short bytecode = vecbyAdpcm[i]; 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 -------------------------------------- */ - for (i = 1; i < iAudSize; i++) + for ( i = 1; i < iAudSize; i++ ) { const short bytecode = vecsAudio[i] & 0xF ; @@ -242,21 +250,29 @@ CVector CImaAdpcm::Decode(const CVector& vecbyAdpcm) int current = vecsAudio[i - 1]; int diff = step >> 3; - if (bytecode & 1) + if ( bytecode & 1 ) + { diff += step >> 2; - if (bytecode & 2) + } + if ( bytecode & 2 ) + { diff += step >> 1; - if (bytecode & 4) + } + if ( bytecode & 4 ) + { diff += step; - if (bytecode & 8) + } + if ( bytecode & 8 ) + { diff = -diff; + } current += diff; iStepindDec += ima_indx_adjust[bytecode]; /* check that values do not exceed the bounds */ - current = CheckBounds(current, _MINSHORT, _MAXSHORT); - iStepindDec = CheckBounds(iStepindDec, 0, IMA_STEP_SIZE_TAB_LEN - 1); + current = CheckBounds ( current, _MINSHORT, _MAXSHORT ); + iStepindDec = CheckBounds ( iStepindDec, 0, IMA_STEP_SIZE_TAB_LEN - 1 ); vecsAudio[i] = current; } diff --git a/src/audiocompr.h b/src/audiocompr.h index 1edf8863..7f799833 100755 --- a/src/audiocompr.h +++ b/src/audiocompr.h @@ -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_ #include "util.h" @@ -68,7 +68,7 @@ protected: int iAdpcmSize; 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 ) { if ( iData > iMax ) @@ -107,4 +107,4 @@ protected: }; -#endif /* !defined(AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_) */ +#endif /* !defined ( AUDIOCOMPR_H_OIHGE76GEKJH3249_GEG98EG3_43441912__INCLUDED_ ) */ diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index c7bd6943..18292453 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -57,12 +57,12 @@ CChannelFader::CChannelFader ( QWidget* pNW, pParentLayout->insertLayout ( 0, pMainGrid ); // add help text to controls - QWhatsThis::add(pFader, "Mixer Fader: Adjusts the audio level of this " + QWhatsThis::add ( pFader, "Mixer Fader: Adjusts the audio level of this " "channel. All connected clients at the server will be assigned an audio " - "fader at each client"); + "fader at each client" ); - QWhatsThis::add(pLabel, "Mixer Fader Label: Label (fader tag) identifying " - "the connected client. The tag name can be set in the clients main window."); + QWhatsThis::add ( pLabel, "Mixer Fader Label: Label (fader tag) identifying " + "the connected client. The tag name can be set in the clients main window." ); // connections ------------------------------------------------------------- diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 55707643..7b752b6d 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -25,7 +25,7 @@ * \******************************************************************************/ -#if !defined(MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_) +#if !defined ( MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_ ) #define MIXERBOARD_H__FD6B49E1606C2AC__INCLUDED_ #include diff --git a/src/buffer.cpp b/src/buffer.cpp index 4da8da37..7aab545b 100755 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -39,28 +39,36 @@ void CNetBuf::Init ( const int iNewBlockSize, const int iNewNumBlocks ) bFadeInNewPutData = true; /* 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 */ - Clear(CT_GET); + Clear ( CT_GET ); /* initialize number of samples for fading effect */ - if (FADE_IN_OUT_NUM_SAM < iBlockSize) + if ( FADE_IN_OUT_NUM_SAM < iBlockSize ) + { iNumSamFading = iBlockSize; + } else + { iNumSamFading = FADE_IN_OUT_NUM_SAM; + } - if (FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize) + if ( FADE_IN_OUT_NUM_SAM_EXTRA > iBlockSize ) + { iNumSamFadingExtra = iBlockSize; + } else + { iNumSamFadingExtra = FADE_IN_OUT_NUM_SAM; + } /* init variables for extrapolation (in case a fade out is needed) */ dExPDiff = 0.0; dExPLastV = 0.0; } -bool CNetBuf::Put(CVector& vecdData) +bool CNetBuf::Put ( CVector& vecdData ) { #ifdef _DEBUG_ static FILE* pFileBI = fopen("bufferin.dat", "w"); @@ -74,11 +82,11 @@ fflush(pFileBI); const int iInSize = vecdData.Size(); /* 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 prepare for new data */ - Clear(CT_PUT); + Clear ( CT_PUT ); /* set flag to fade in new block to avoid clicks */ bFadeInNewPutData = true; @@ -87,41 +95,53 @@ fflush(pFileBI); } /* fade in new block if required */ - if (bFadeInNewPutData) - FadeInAudioDataBlock(vecdData); + if ( bFadeInNewPutData ) + { + FadeInAudioDataBlock ( vecdData ); + } /* copy new data in internal buffer */ int iCurPos = 0; - if (iPutPos + iInSize > iMemSize) + if ( iPutPos + iInSize > iMemSize ) { /* remaining space size for second block */ const int iRemSpace = iPutPos + iInSize - iMemSize; /* data must be written in two steps because of wrap around */ while (iPutPos < iMemSize) + { vecdMemory[iPutPos++] = vecdData[iCurPos++]; + } - for (iPutPos = 0; iPutPos < iRemSpace; iPutPos++) + for ( iPutPos = 0; iPutPos < iRemSpace; iPutPos++ ) + { vecdMemory[iPutPos] = vecdData[iCurPos++]; + } } else { /* data can be written in one step */ const int iEnd = iPutPos + iInSize; - while (iPutPos < iEnd) + while ( iPutPos < iEnd ) + { vecdMemory[iPutPos++] = vecdData[iCurPos++]; + } } /* set buffer state flag */ - if (iPutPos == iGetPos) + if ( iPutPos == iGetPos ) + { eBufState = CNetBuf::BS_FULL; + } else + { eBufState = CNetBuf::BS_OK; + } return bPutOK; } -bool CNetBuf::Get(CVector& vecdData) +bool CNetBuf::Get ( CVector& vecdData ) { bool bGetOK = true; /* init return value */ bool bFadeOutExtrap = false; @@ -130,11 +150,11 @@ bool CNetBuf::Get(CVector& vecdData) const int iInSize = vecdData.Size(); /* 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 prepare for getting data */ - Clear(CT_GET); + Clear ( CT_GET ); /* set flag to fade in next new block in buffer and fade out last block by extrapolation to avoid clicks */ @@ -146,45 +166,57 @@ bool CNetBuf::Get(CVector& vecdData) /* copy data from internal buffer in output buffer */ int iCurPos = 0; - if (iGetPos + iInSize > iMemSize) + if ( iGetPos + iInSize > iMemSize ) { /* remaining data size for second block */ const int iRemData = iGetPos + iInSize - iMemSize; /* data must be read in two steps because of wrap around */ - while (iGetPos < iMemSize) + while ( iGetPos < iMemSize ) + { vecdData[iCurPos++] = vecdMemory[iGetPos++]; + } - for (iGetPos = 0; iGetPos < iRemData; iGetPos++) + for ( iGetPos = 0; iGetPos < iRemData; iGetPos++ ) + { vecdData[iCurPos++] = vecdMemory[iGetPos]; + } } else { /* data can be read in one step */ const int iEnd = iGetPos + iInSize; - while (iGetPos < iEnd) + while ( iGetPos < iEnd ) + { vecdData[iCurPos++] = vecdMemory[iGetPos++]; + } } /* set buffer state flag */ - if (iPutPos == iGetPos) + if ( iPutPos == iGetPos ) + { eBufState = CNetBuf::BS_EMPTY; + } else + { eBufState = CNetBuf::BS_OK; + } /* extrapolate data from old block to avoid "clicks" 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 network) */ - if (bFadeOutExtrap) - FadeOutExtrapolateAudioDataBlock(vecdData, dExPDiff, dExPLastV); + if ( bFadeOutExtrap ) + { + FadeOutExtrapolateAudioDataBlock ( vecdData, dExPDiff, dExPLastV ); + } /* 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 signal to avoid "clicks" we assume here that "iBlockSize" is larger than 1! */ - dExPDiff = vecdData[iInSize - 1] - vecdData[iInSize - 2]; + dExPDiff = vecdData[iInSize - 1] - vecdData[iInSize - 2]; dExPLastV = vecdData[iInSize - 1]; return bGetOK; @@ -196,10 +228,17 @@ int CNetBuf::GetAvailSpace() const int iAvSpace = iGetPos - iPutPos; /* check for special case and wrap around */ - if (iAvSpace < 0) + if ( iAvSpace < 0 ) + { iAvSpace += iMemSize; /* wrap around */ - else if ((iAvSpace == 0) && (eBufState == BS_EMPTY)) - iAvSpace = iMemSize; + } + else + { + if ( ( iAvSpace == 0 ) && ( eBufState == BS_EMPTY ) ) + { + iAvSpace = iMemSize; + } + } return iAvSpace; } @@ -210,15 +249,22 @@ int CNetBuf::GetAvailData() const int iAvData = iPutPos - iGetPos; /* check for special case and wrap around */ - if (iAvData < 0) + if ( iAvData < 0 ) + { iAvData += iMemSize; /* wrap around */ - else if ((iAvData == 0) && (eBufState == BS_FULL)) - iAvData = iMemSize; + } + else + { + if ( ( iAvData == 0 ) && ( eBufState == BS_FULL ) ) + { + iAvData = iMemSize; + } + } return iAvData; } -void CNetBuf::Clear(const EClearType eClearType) +void CNetBuf::Clear ( const EClearType eClearType ) { int iMiddleOfBuffer; @@ -229,21 +275,21 @@ void CNetBuf::Clear(const EClearType eClearType) number of blocks, e.g.: [buffer size]: [get pos] 1: 0 / 2: 0 / 3: 1 / 4: 1 / ... */ - iMiddleOfBuffer = (((iMemSize - iBlockSize) / 2) / iBlockSize) * iBlockSize; + iMiddleOfBuffer = ( ( ( iMemSize - iBlockSize) / 2 ) / iBlockSize ) * iBlockSize; #else // old code // somehow the old code seems to work better than the sophisticated new one....? /* 1: 0 / 2: 1 / 3: 1 / 4: 2 / ... */ - iMiddleOfBuffer = ((iMemSize / 2) / iBlockSize) * iBlockSize; + iMiddleOfBuffer = ( ( iMemSize / 2 ) / iBlockSize ) * iBlockSize; #endif - - + + /* different behaviour for get and put corrections */ - if (eClearType == CT_GET) + if ( eClearType == CT_GET ) { /* clear buffer */ - vecdMemory.Reset(0.0); + vecdMemory.Reset ( 0.0 ); /* correct buffer so that after the current get operation the pointer are at maximum distance */ @@ -251,10 +297,14 @@ void CNetBuf::Clear(const EClearType eClearType) iGetPos = iMiddleOfBuffer; /* check for special case */ - if (iPutPos == iGetPos) + if ( iPutPos == iGetPos ) + { eBufState = CNetBuf::BS_FULL; + } else + { eBufState = CNetBuf::BS_OK; + } } else { @@ -265,43 +315,45 @@ void CNetBuf::Clear(const EClearType eClearType) /* adjust put pointer relative to current get pointer, take care of wrap around */ iPutPos += iGetPos; - if (iPutPos > iMemSize) + if ( iPutPos > iMemSize ) + { iPutPos -= iMemSize; + } /* fade out old data right before new put pointer */ int iCurPos = iPutPos - iNumSamFading; int i = iNumSamFading; - if (iCurPos < 0) + if ( iCurPos < 0 ) { /* wrap around */ iCurPos += iMemSize; /* 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--; } - for (iCurPos = 0; iCurPos < iPutPos; iCurPos++) + for ( iCurPos = 0; iCurPos < iPutPos; iCurPos++ ) { - vecdMemory[iCurPos] *= ((double) i / iNumSamFading); + vecdMemory[iCurPos] *= ( (double) i / iNumSamFading ); i--; } } else { /* data can be processed in one step */ - while (iCurPos < iPutPos) + while ( iCurPos < iPutPos ) { - vecdMemory[iCurPos++] *= ((double) i / iNumSamFading); + vecdMemory[iCurPos++] *= ( (double) i / iNumSamFading ); i--; } } /* check for special case */ - if (iPutPos == iGetPos) + if ( iPutPos == iGetPos ) { eBufState = CNetBuf::BS_EMPTY; } @@ -312,30 +364,30 @@ void CNetBuf::Clear(const EClearType eClearType) } } -void CNetBuf::FadeInAudioDataBlock(CVector& vecdData) +void CNetBuf::FadeInAudioDataBlock ( CVector& vecdData ) { /* 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 */ bFadeInNewPutData = false; } -void CNetBuf::FadeOutExtrapolateAudioDataBlock(CVector& vecdData, - const double dExPDiff, - const double dExPLastV) +void CNetBuf::FadeOutExtrapolateAudioDataBlock ( CVector& vecdData, + const double dExPDiff, + const double dExPLastV ) { /* apply linear extrapolation and linear fading */ - for (int i = 0; i < iNumSamFadingExtra; i++) + for ( int i = 0; i < iNumSamFadingExtra; i++ ) { /* calculate extrapolated value */ - vecdData[i] = ((i + 1) * dExPDiff + dExPLastV); + vecdData[i] = ( ( i + 1 ) * dExPDiff + dExPLastV ); /* 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; /* allocate and clear memory for actual data buffer */ - vecsMemory.Init(iMemSize); + vecsMemory.Init ( iMemSize ); iPutPos = 0; } -bool CConvBuf::Put ( const CVector& vecsData) +bool CConvBuf::Put ( const CVector& vecsData ) { const int iVecSize = vecsData.Size(); diff --git a/src/buffer.h b/src/buffer.h index eadb28f9..9ad8fd1f 100755 --- a/src/buffer.h +++ b/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_ #include "util.h" @@ -30,12 +30,12 @@ /* Definitions ****************************************************************/ -/* time for fading effect for masking drop outs */ -#define FADE_IN_OUT_TIME ((double) 0.3) /* ms */ -#define FADE_IN_OUT_NUM_SAM ((int) (SAMPLE_RATE * FADE_IN_OUT_TIME) / 1000) +// time for fading effect for masking drop outs +#define FADE_IN_OUT_TIME ( (double) 0.3 ) // ms +#define FADE_IN_OUT_NUM_SAM ( (int) ( SAMPLE_RATE * FADE_IN_OUT_TIME ) / 1000 ) -/* for extrapolation a shorter time for fading */ -#define FADE_IN_OUT_NUM_SAM_EXTRA 5 /* samples */ +// for extrapolation a shorter time for fading +#define FADE_IN_OUT_NUM_SAM_EXTRA 5 // samples /* Classes ********************************************************************/ @@ -45,21 +45,21 @@ public: CNetBuf() {} virtual ~CNetBuf() {} - void Init(const int iNewBlockSize, const int iNewNumBlocks); - int GetSize() {return iMemSize / iBlockSize;} + void Init ( const int iNewBlockSize, const int iNewNumBlocks ); + int GetSize() { return iMemSize / iBlockSize; } - bool Put(CVector& vecdData); - bool Get(CVector& vecdData); + bool Put ( CVector& vecdData ); + bool Get ( CVector& vecdData ); protected: - enum EBufState {BS_OK, BS_FULL, BS_EMPTY}; - enum EClearType {CT_PUT, CT_GET}; - void Clear(const EClearType eClearType); + enum EBufState { BS_OK, BS_FULL, BS_EMPTY }; + enum EClearType { CT_PUT, CT_GET }; + void Clear ( const EClearType eClearType ); int GetAvailSpace() const; int GetAvailData() const; - void FadeInAudioDataBlock(CVector& vecdData); - void FadeOutExtrapolateAudioDataBlock(CVector& vecdData, - const double dExPDiff, const double dExPLastV); + void FadeInAudioDataBlock ( CVector& vecdData ); + void FadeOutExtrapolateAudioDataBlock ( CVector& vecdData, + const double dExPDiff, const double dExPLastV ); CVector vecdMemory; int iMemSize; @@ -70,24 +70,24 @@ protected: int iNumSamFading; int iNumSamFadingExtra; - /* extrapolation parameters */ + // extrapolation parameters double dExPDiff; double dExPLastV; }; -/* conversion buffer (very simple buffer) */ +// conversion buffer (very simple buffer) class CConvBuf { public: - CConvBuf () {} - virtual ~CConvBuf () {} + CConvBuf() {} + virtual ~CConvBuf() {} void Init ( const int iNewMemSize ); int GetSize() { return iMemSize; } bool Put ( const CVector& vecsData ); - CVector Get (); + CVector Get(); protected: CVector vecsMemory; @@ -97,4 +97,4 @@ protected: }; -#endif /* !defined(BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_) */ +#endif /* !defined ( BUFFER_H__3B123453_4344_BB23945IUHF1912__INCLUDED_ ) */ diff --git a/src/channel.h b/src/channel.h index 5028c86e..31181af4 100755 --- a/src/channel.h +++ b/src/channel.h @@ -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_ #include @@ -42,7 +42,7 @@ #define CON_TIME_OUT_SEC_MAX 5 // seconds // no valid channel number -#define INVALID_CHANNEL_ID (MAX_NUM_CHANNELS + 1) +#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) enum EPutDataStat { @@ -85,7 +85,7 @@ public: void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; } bool GetAddress ( CHostAddress& RetAddr ); - CHostAddress GetAddress () { return InetAddr; } + CHostAddress GetAddress() { return InetAddr; } void SetName ( const std::string sNNa ) { sName = sNNa; } 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_ ) */ diff --git a/src/client.h b/src/client.h index ce70f0e1..3f3e37d8 100755 --- a/src/client.h +++ b/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_ #include @@ -94,7 +94,7 @@ public: // tell the server that size has changed Channel.CreateJitBufMes ( iNumBlocks ); } - int GetSockBufSize() { return Channel.GetSockBufSize (); } + int GetSockBufSize() { return Channel.GetSockBufSize(); } void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn ) @@ -126,9 +126,9 @@ public: std::string strName; 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; CSocket Socket; @@ -158,13 +158,13 @@ protected: CVector vecsNetwork; - /* resample objects */ - CAudioResample ResampleObjDownL; /* left channel */ - CAudioResample ResampleObjDownR; /* right channel */ - CAudioResample ResampleObjUpL; /* left channel */ - CAudioResample ResampleObjUpR; /* right channel */ + // resample objects + CAudioResample ResampleObjDownL; // left channel + CAudioResample ResampleObjDownR; // right channel + CAudioResample ResampleObjUpL; // left channel + CAudioResample ResampleObjUpR; // right channel - /* debugging, evaluating */ + // debugging, evaluating CMovingAv RespTimeMoAvBuf; QTime TimeLastBlock; @@ -179,4 +179,4 @@ signals: }; -#endif /* !defined(CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_) */ +#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */ diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 508a7f5d..d0a1f20f 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -35,133 +35,133 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, /* init slider controls --- */ /* sound buffer in */ - SliderSndBufIn->setRange(2, AUD_SLIDER_LENGTH); + SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH ); const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf(); - SliderSndBufIn->setValue(iCurNumInBuf); - TextSndBufIn->setText("In: " + QString().setNum(iCurNumInBuf)); + SliderSndBufIn->setValue ( iCurNumInBuf ); + TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) ); /* sound buffer out */ - SliderSndBufOut->setRange(2, AUD_SLIDER_LENGTH); + SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH ); const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf(); - SliderSndBufOut->setValue(iCurNumOutBuf); - TextSndBufOut->setText("Out: " + QString().setNum(iCurNumOutBuf)); + SliderSndBufOut->setValue ( iCurNumOutBuf ); + TextSndBufOut->setText ( "Out: " + QString().setNum ( iCurNumOutBuf ) ); /* 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(); - SliderNetBuf->setValue(iCurNumNetBuf); - TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf)); + SliderNetBuf->setValue ( iCurNumNetBuf ); + TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) ); /* 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(); - SliderNetBufSiFactIn->setValue(iCurNetBufSiFactIn); - TextNetBufSiFactIn->setText("In:\n" + QString().setNum( - double(iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS), 'f', 2) + - " ms"); + SliderNetBufSiFactIn->setValue ( iCurNetBufSiFactIn ); + TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum ( + double ( iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS ), 'f', 2 ) + + " ms" ); /* 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(); - SliderNetBufSiFactOut->setValue(iCurNetBufSiFactOut); - TextNetBufSiFactOut->setText("Out:\n" + QString().setNum( - double(iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2) + - " ms"); + SliderNetBufSiFactOut->setValue ( iCurNetBufSiFactOut ); + TextNetBufSiFactOut->setText ( "Out:\n" + QString().setNum ( + double ( iCurNetBufSiFactOut * MIN_BLOCK_DURATION_MS), 'f', 2 ) + + " ms" ); /* connections ---------------------------------------------------------- */ /* timers */ - QObject::connect(&TimerStatus, SIGNAL(timeout()), - this, SLOT(OnTimerStatus())); + QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), + this, SLOT ( OnTimerStatus() ) ); /* sliders */ - QObject::connect(SliderSndBufIn, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderSndBufInChange(int))); - QObject::connect(SliderSndBufOut, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderSndBufOutChange(int))); + QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderSndBufInChange ( int ) ) ); + QObject::connect ( SliderSndBufOut, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderSndBufOutChange ( int ) ) ); - QObject::connect(SliderNetBuf, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderNetBuf(int))); + QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderNetBuf ( int ) ) ); - QObject::connect(SliderNetBufSiFactIn, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderNetBufSiFactIn(int))); - QObject::connect(SliderNetBufSiFactOut, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderNetBufSiFactOut(int))); + QObject::connect ( SliderNetBufSiFactIn, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderNetBufSiFactIn ( int ) ) ); + QObject::connect ( SliderNetBufSiFactOut, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderNetBufSiFactOut ( int ) ) ); /* timers --------------------------------------------------------------- */ /* 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); - TextSndBufIn->setText("In: " + QString().setNum(value)); + pClient->GetSndInterface()->SetInNumBuf ( value ); + TextSndBufIn->setText ( "In: " + QString().setNum ( value ) ); UpdateDisplay(); } -void CClientSettingsDlg::OnSliderSndBufOutChange(int value) +void CClientSettingsDlg::OnSliderSndBufOutChange ( int value ) { - pClient->GetSndInterface()->SetOutNumBuf(value); - TextSndBufOut->setText("Out: " + QString().setNum(value)); + pClient->GetSndInterface()->SetOutNumBuf ( value ); + TextSndBufOut->setText ( "Out: " + QString().setNum ( value ) ); UpdateDisplay(); } -void CClientSettingsDlg::OnSliderNetBuf(int value) +void CClientSettingsDlg::OnSliderNetBuf ( int value ) { pClient->SetSockBufSize ( value ); - TextNetBuf->setText("Size: " + QString().setNum(value)); + TextNetBuf->setText ( "Size: " + QString().setNum ( value ) ); UpdateDisplay(); } -void CClientSettingsDlg::OnSliderNetBufSiFactIn(int value) +void CClientSettingsDlg::OnSliderNetBufSiFactIn ( int value ) { pClient->SetNetwBufSizeFactIn ( value ); - TextNetBufSiFactIn->setText("In:\n" + QString().setNum( - double(value * MIN_BLOCK_DURATION_MS), 'f', 2) + - " ms"); + TextNetBufSiFactIn->setText ( "In:\n" + QString().setNum ( + double ( value * MIN_BLOCK_DURATION_MS ), 'f', 2 ) + + " ms" ); UpdateDisplay(); } -void CClientSettingsDlg::OnSliderNetBufSiFactOut(int value) +void CClientSettingsDlg::OnSliderNetBufSiFactOut ( int value ) { pClient->SetNetwBufSizeFactOut ( value ); - TextNetBufSiFactOut->setText("Out:\n" + QString().setNum( - double(value * MIN_BLOCK_DURATION_MS), 'f', 2) + - " ms"); + TextNetBufSiFactOut->setText ( "Out:\n" + QString().setNum ( + double ( value * MIN_BLOCK_DURATION_MS ), 'f', 2 ) + + " ms" ); UpdateDisplay(); } void CClientSettingsDlg::UpdateDisplay() { /* response time */ - TextLabelStdDevTimer->setText(QString(). - setNum(pClient->GetTimingStdDev(), 'f', 2) + " ms"); + TextLabelStdDevTimer->setText ( QString(). + setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); } void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus ) { - switch(iMessType) + switch ( iMessType ) { case MS_SOUND_IN: - CLEDSoundIn->SetLight(iStatus); + CLEDSoundIn->SetLight ( iStatus ); break; case MS_SOUND_OUT: - CLEDSoundOut->SetLight(iStatus); + CLEDSoundOut->SetLight ( iStatus ); break; case MS_JIT_BUF_PUT: - CLEDNetwPut->SetLight(iStatus); + CLEDNetwPut->SetLight ( iStatus ); break; case MS_JIT_BUF_GET: - CLEDNetwGet->SetLight(iStatus); + CLEDNetwGet->SetLight ( iStatus ); break; case MS_PROTOCOL: - CLEDProtocolStatus->SetLight(iStatus); + CLEDProtocolStatus->SetLight ( iStatus ); case MS_RESET_ALL: CLEDSoundIn->Reset(); diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 7db085c4..ec18d305 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -44,8 +44,8 @@ /* Definitions ****************************************************************/ -/* update time for GUI controls */ -#define DISPLAY_UPDATE_TIME 1000 /* ms */ +// update time for GUI controls +#define DISPLAY_UPDATE_TIME 1000 // ms /* Classes ********************************************************************/ diff --git a/src/global.h b/src/global.h index a9a75b93..71506303 100755 --- a/src/global.h +++ b/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_ #include @@ -36,11 +36,11 @@ /* Definitions ****************************************************************/ -/* define this macro to get debug output */ +// define this macro to get debug output #define _DEBUG_ #undef _DEBUG_ -/* version and application name (always use this version) */ +// version and application name (always use this version) #undef VERSION #define VERSION "1.0cvs" #define APP_NAME "llcon" @@ -68,14 +68,14 @@ // maximum value of factor for network block size #define MAX_NET_BLOCK_SIZE_FACTOR 8 -/* default network block size factor */ +// default network block size factor #define DEF_NET_BLOCK_SIZE_FACTOR 3 -/* maximum network buffer size (which can be chosen by slider) */ -#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */ +// maximum network buffer size (which can be chosen by slider) +#define MAX_NET_BUF_SIZE_NUM_BL 10 // number of blocks -/* default network buffer size */ -#define DEF_NET_BUF_SIZE_NUM_BL 5 /* number of blocks */ +// default network buffer size +#define DEF_NET_BUF_SIZE_NUM_BL 5 // number of blocks // number of ticks of audio in/out buffer sliders #ifdef _WIN32 @@ -88,26 +88,26 @@ // 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 // (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 */ -/* time interval for sample rate offset estimation */ -#define TIME_INT_SAM_OFFS_EST 60 /* s */ +// sample rate offset estimation algorithm +// time interval for sample rate offset estimation +#define TIME_INT_SAM_OFFS_EST 60 // s -/* time interval of taps for sample rate offset estimation (time stamps) */ -#define INTVL_TAPS_SAM_OFF_SET 1 /* s */ +// time interval of taps for sample rate offset estimation (time stamps) +#define INTVL_TAPS_SAM_OFF_SET 1 // s #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 ) -/* length of the moving average buffer for response time measurement */ -#define TIME_MOV_AV_RESPONSE 30 /* seconds */ -#define LEN_MOV_AV_RESPONSE (TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS) +// length of the moving average buffer for response time measurement +#define TIME_MOV_AV_RESPONSE 30 // seconds +#define LEN_MOV_AV_RESPONSE ( TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS ) #define _MAXSHORT 32767 -#define _MAXBYTE 255 /* binary: 11111111 */ -#define _MINSHORT (-32768) +#define _MAXBYTE 255 // binary: 11111111 +#define _MINSHORT ( -32768 ) #if HAVE_STDINT_H # include @@ -126,7 +126,7 @@ typedef unsigned char uint8_t; /* Definitions for window message system ------------------------------------ */ 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_OUT 2 #define MS_JIT_BUF_PUT 3 @@ -143,16 +143,16 @@ typedef unsigned int _MESSAGE_IDENT; class CGenErr { public: - CGenErr(QString strNE) : strError(strNE) {} + CGenErr ( QString strNE ) : strError ( strNE ) {} QString strError; }; class CLlconEvent : public QCustomEvent { public: - CLlconEvent(int iNewMeTy, int iNewSt, int iNewChN = 0) : - QCustomEvent(QEvent::User + 11), iMessType(iNewMeTy), iStatus(iNewSt), - iChanNum(iNewChN) {} + CLlconEvent ( int iNewMeTy, int iNewSt, int iNewChN = 0 ) : + QCustomEvent ( QEvent::User + 11 ), iMessType ( iNewMeTy ), iStatus ( iNewSt ), + iChanNum ( iNewChN ) {} int iMessType; int iStatus; @@ -161,9 +161,9 @@ public: /* Prototypes for global functions ********************************************/ -/* Posting a window message */ -void PostWinMessage(const _MESSAGE_IDENT MessID, const int iMessageParam = 0, - const int iChanNum = 0); +// posting a window message +void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam = 0, + const int iChanNum = 0 ); -#endif /* !defined(GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_) */ +#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */ diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index f8ab3e61..89d54e5a 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -27,38 +27,38 @@ /* Implementation *************************************************************/ 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 ), ClientSettingsDlg ( pNCliP, 0, 0, FALSE, Qt::WStyle_MinMax ) { /* add help text to controls */ - QString strInpLevH = tr("Input level meter: Shows the level of the " + QString strInpLevH = tr ( "Input level meter: Shows the level of the " "input audio signal of the sound card. The level is in dB. Overload " - "should be avoided."); - QWhatsThis::add(TextLabelInputLevel, strInpLevH); - QWhatsThis::add(ProgressBarInputLevelL, strInpLevH); - QWhatsThis::add(ProgressBarInputLevelR, strInpLevH); + "should be avoided." ); + QWhatsThis::add ( TextLabelInputLevel, strInpLevH ); + QWhatsThis::add ( ProgressBarInputLevelL, strInpLevH ); + QWhatsThis::add ( ProgressBarInputLevelR, strInpLevH ); - QWhatsThis::add(PushButtonConnect, tr("Connect / Disconnect Button:" + QWhatsThis::add(PushButtonConnect, tr ( "Connect / Disconnect Button:" " Push this button to connect the server. A valid IP address has " "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("Status Bar: In the status bar " + QWhatsThis::add(TextLabelStatus, tr ( "Status Bar: In the status bar " "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("Server Address: In this edit control, " + QString strServAddrH = tr ( "Server Address: In this edit control, " "the IP address of the server can be set. If an invalid address was " - "chosen, an error message is shown in the status bar."); - QWhatsThis::add(TextLabelServerAddr, strServAddrH); - QWhatsThis::add(LineEditServerAddr, strServAddrH); + "chosen, an error message is shown in the status bar." ); + QWhatsThis::add ( TextLabelServerAddr, strServAddrH ); + QWhatsThis::add ( LineEditServerAddr, strServAddrH ); - QString strFaderTag = tr("Fader Tag: In this edit control, " + QString strFaderTag = tr ( "Fader Tag: In this edit control, " "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."); - QWhatsThis::add(TextLabelServerTag, strFaderTag); - QWhatsThis::add(LineEditFaderTag, strFaderTag); + QWhatsThis::add ( TextLabelServerTag, strFaderTag ); + QWhatsThis::add ( LineEditFaderTag, strFaderTag ); QString strAudFader = tr ( "Audio Fader: With the audio fader " "control the level of left and right audio input channels can " @@ -160,26 +160,26 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, // connections ------------------------------------------------------------- // push-buttons - QObject::connect(PushButtonConnect, SIGNAL(clicked()), - this, SLOT(OnConnectDisconBut())); + QObject::connect ( PushButtonConnect, SIGNAL ( clicked() ), + this, SLOT ( OnConnectDisconBut() ) ); // timers - QObject::connect(&TimerSigMet, SIGNAL(timeout()), - this, SLOT(OnTimerSigMet())); - QObject::connect(&TimerStatus, SIGNAL(timeout()), - this, SLOT(OnTimerStatus())); + QObject::connect ( &TimerSigMet, SIGNAL ( timeout() ), + this, SLOT ( OnTimerSigMet() ) ); + QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), + this, SLOT ( OnTimerStatus() ) ); // sliders - QObject::connect(SliderAudInFader, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderAudInFader(int))); - QObject::connect(SliderAudReverb, SIGNAL(valueChanged(int)), - this, SLOT(OnSliderAudReverb(int))); + QObject::connect ( SliderAudInFader, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderAudInFader ( int ) ) ); + QObject::connect ( SliderAudReverb, SIGNAL ( valueChanged ( int ) ), + this, SLOT ( OnSliderAudReverb ( int ) ) ); // radio buttons - QObject::connect(RadioButtonRevSelL, SIGNAL(clicked()), - this, SLOT(OnRevSelL())); - QObject::connect(RadioButtonRevSelR, SIGNAL(clicked()), - this, SLOT(OnRevSelR())); + QObject::connect ( RadioButtonRevSelL, SIGNAL ( clicked() ), + this, SLOT ( OnRevSelL() ) ); + QObject::connect ( RadioButtonRevSelR, SIGNAL ( clicked() ), + this, SLOT ( OnRevSelR() ) ); // line edits QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ), @@ -195,13 +195,13 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, // timers ------------------------------------------------------------------ // start timer for status bar - TimerStatus.start(STATUSBAR_UPDATE_TIME); + TimerStatus.start ( STATUSBAR_UPDATE_TIME ); } CLlconClientDlg::~CLlconClientDlg() { /* if connected, terminate connection */ - if (pClient->IsRunning()) + if ( pClient->IsRunning() ) { pClient->Stop(); } @@ -272,7 +272,7 @@ void CLlconClientDlg::OnOpenGeneralSettings() // make sure dialog is upfront and has focus ClientSettingsDlg.raise(); - ClientSettingsDlg.setActiveWindow(); + ClientSettingsDlg.setActiveWindow(); } @@ -335,8 +335,8 @@ void CLlconClientDlg::customEvent ( QCustomEvent* Event ) { if ( Event->type() == QEvent::User + 11 ) { - const int iMessType = ( (CLlconEvent*) Event ) ->iMessType; - const int iStatus = ( (CLlconEvent*) Event ) ->iStatus; + const int iMessType = ( (CLlconEvent*) Event )->iMessType; + const int iStatus = ( (CLlconEvent*) Event )->iStatus; switch ( iMessType ) { diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index e3fef318..3baf1d59 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -46,20 +46,20 @@ /* 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_DISCONNECTTEXT "D&isconnect" -/* steps for input level meter */ +// steps for input level meter #define NUM_STEPS_INP_LEV_METER 100 -/* update time for GUI controls */ -#define LEVELMETER_UPDATE_TIME 100 /* ms */ -#define STATUSBAR_UPDATE_TIME 1000 /* ms */ +// update time for GUI controls +#define LEVELMETER_UPDATE_TIME 100 // ms +#define STATUSBAR_UPDATE_TIME 1000 // ms -/* range for signal level meter */ -#define LOW_BOUND_SIG_METER ( -50.0 ) /* dB */ -#define UPPER_BOUND_SIG_METER ( 0.0 ) /* dB */ +// range for signal level meter +#define LOW_BOUND_SIG_METER ( -50.0 ) // dB +#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB /* Classes ********************************************************************/ @@ -71,7 +71,7 @@ public: CLlconClientDlg ( CClient* pNCliP, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0 ); - virtual ~CLlconClientDlg (); + virtual ~CLlconClientDlg(); protected: CClient* pClient; diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index d72e2e92..5d1b4eb6 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -67,36 +67,36 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent, /* insert items in reverse order because in Windows all of them are always visible -> put first item on the top */ 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 - vecpListViewItems[i]->setVisible(false); + vecpListViewItems[i]->setVisible ( false ); #endif } /* Init timing jitter text label */ - TextLabelResponseTime->setText(""); + TextLabelResponseTime->setText ( "" ); /* Main menu bar -------------------------------------------------------- */ - pMenu = new QMenuBar(this); - CHECK_PTR(pMenu); - pMenu->insertItem(tr("&?"), new CLlconHelpMenu(this)); - pMenu->setSeparator(QMenuBar::InWindowsStyle); + pMenu = new QMenuBar ( this ); + CHECK_PTR ( pMenu ); + pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) ); + pMenu->setSeparator ( QMenuBar::InWindowsStyle ); /* Now tell the layout about the menu */ - CLlconServerDlgBaseLayout->setMenuBar(pMenu); + CLlconServerDlgBaseLayout->setMenuBar ( pMenu ); /* connections ---------------------------------------------------------- */ /* timers */ - QObject::connect(&Timer, SIGNAL(timeout()), this, SLOT(OnTimer())); + QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); /* timers --------------------------------------------------------------- */ /* start timer for GUI controls */ - Timer.start(GUI_CONTRL_UPDATE_TIME); + Timer.start ( GUI_CONTRL_UPDATE_TIME ); } void CLlconServerDlg::OnTimer() diff --git a/src/llconserverdlg.h b/src/llconserverdlg.h index 0edfa1c9..4ff0dd77 100755 --- a/src/llconserverdlg.h +++ b/src/llconserverdlg.h @@ -41,8 +41,8 @@ /* Definitions ****************************************************************/ -/* update time for GUI controls */ -#define GUI_CONTRL_UPDATE_TIME 1000 /* ms */ +// update time for GUI controls +#define GUI_CONTRL_UPDATE_TIME 1000 // ms /* Classes ********************************************************************/ @@ -54,7 +54,7 @@ public: CLlconServerDlg ( CServer* pNServP, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0 ); - virtual ~CLlconServerDlg () {} + virtual ~CLlconServerDlg() {} protected: QTimer Timer; @@ -69,7 +69,7 @@ protected: QMenuBar* pMenu; - virtual void customEvent(QCustomEvent* Event); + virtual void customEvent ( QCustomEvent* Event ); void UpdateSliderNetBuf(); public slots: diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index 08c0ee8b..afcd37c3 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -37,32 +37,32 @@ CMultiColorLEDbase::CMultiColorLEDbase() const int iYSize = 13; /* Create bitmaps */ - BitmCubeGreen.resize(iXSize, iYSize); - BitmCubeGreen.fill(QColor(0, 255, 0)); - BitmCubeRed.resize(iXSize, iYSize); - BitmCubeRed.fill(QColor(255, 0, 0)); - BitmCubeGrey.resize(iXSize, iYSize); - BitmCubeGrey.fill(QColor(192, 192, 192)); - BitmCubeYellow.resize(iXSize, iYSize); - BitmCubeYellow.fill(QColor(255, 255, 0)); + BitmCubeGreen.resize ( iXSize, iYSize ); + BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); + BitmCubeRed.resize ( iXSize, iYSize ); + BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); + BitmCubeGrey.resize ( iXSize, iYSize ); + BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) ); + BitmCubeYellow.resize ( iXSize, iYSize ); + BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); /* Init color flags */ Reset(); /* Set init-bitmap */ - SetPixmap(BitmCubeGrey); + SetPixmap ( BitmCubeGrey ); eColorFlag = RL_GREY; /* Init update time */ iUpdateTime = DEFAULT_UPDATE_TIME; /* Connect timer events to the desired slots */ - connect(&TimerRedLight, SIGNAL(timeout()), - this, SLOT(OnTimerRedLight())); - connect(&TimerGreenLight, SIGNAL(timeout()), - this, SLOT(OnTimerGreenLight())); - connect(&TimerYellowLight, SIGNAL(timeout()), - this, SLOT(OnTimerYellowLight())); + connect ( &TimerRedLight, SIGNAL ( timeout() ), + this, SLOT ( OnTimerRedLight() ) ); + connect ( &TimerGreenLight, SIGNAL ( timeout() ), + this, SLOT ( OnTimerGreenLight() ) ); + connect ( &TimerYellowLight, SIGNAL ( timeout() ), + this, SLOT ( OnTimerYellowLight() ) ); } void CMultiColorLEDbase::Reset() @@ -98,85 +98,89 @@ void CMultiColorLEDbase::UpdateColor() /* 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 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; } return; } - if (bFlagYellowLi) + if ( bFlagYellowLi ) { - if (eColorFlag != RL_YELLOW) + if ( eColorFlag != RL_YELLOW ) { - SetPixmap(BitmCubeYellow); + SetPixmap ( BitmCubeYellow ); eColorFlag = RL_YELLOW; } return; } - if (bFlagGreenLi) + if ( bFlagGreenLi ) { - if (eColorFlag != RL_GREEN) + if ( eColorFlag != RL_GREEN ) { - SetPixmap(BitmCubeGreen); + SetPixmap ( BitmCubeGreen ); eColorFlag = RL_GREEN; } return; } /* 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; } } -void CMultiColorLEDbase::SetLight(int iNewStatus) +void CMultiColorLEDbase::SetLight ( int iNewStatus ) { - switch (iNewStatus) + switch ( iNewStatus ) { case MUL_COL_LED_GREEN: /* Green light */ bFlagGreenLi = true; - TimerGreenLight.changeInterval(iUpdateTime); + TimerGreenLight.changeInterval ( iUpdateTime ); break; case MUL_COL_LED_YELLOW: /* Yellow light */ bFlagYellowLi = true; - TimerYellowLight.changeInterval(iUpdateTime); + TimerYellowLight.changeInterval ( iUpdateTime ); break; case MUL_COL_LED_RED: /* Red light */ bFlagRedLi = true; - TimerRedLight.changeInterval(iUpdateTime); + TimerRedLight.changeInterval ( iUpdateTime ); break; } UpdateColor(); } -void CMultiColorLEDbase::SetUpdateTime(int iNUTi) +void CMultiColorLEDbase::SetUpdateTime ( int iNUTi ) { /* Avoid too short intervals */ - if (iNUTi < MIN_TIME_FOR_RED_LIGHT) + if ( iNUTi < MIN_TIME_FOR_RED_LIGHT ) + { iUpdateTime = MIN_TIME_FOR_RED_LIGHT; + } else + { iUpdateTime = iNUTi; + } } -CMultiColorLED::CMultiColorLED(QWidget* parent, const char* name, WFlags f) : - QLabel(parent, name, f) +CMultiColorLED::CMultiColorLED ( QWidget* parent, const char* name, WFlags f ) : + QLabel ( parent, name, f ) { // set modified style - setFrameShape(QFrame::Panel); - setFrameShadow(QFrame::Sunken); - setIndent(0); + setFrameShape ( QFrame::Panel ); + setFrameShadow ( QFrame::Sunken ); + setIndent ( 0 ); } diff --git a/src/multicolorled.h b/src/multicolorled.h index 92f2444b..dacfacbf 100755 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -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_ #include @@ -43,7 +43,7 @@ /* Definitions ****************************************************************/ #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 @@ -56,14 +56,14 @@ public: CMultiColorLEDbase(); void Reset(); - void SetUpdateTime(int iNUTi); - void SetLight(int iNewStatus); + void SetUpdateTime ( int iNUTi ); + void SetLight ( int iNewStatus ); protected: - enum ELightColor {RL_GREY, RL_RED, RL_GREEN, RL_YELLOW}; - ELightColor eColorFlag; + enum ELightColor { RL_GREY, RL_RED, RL_GREEN, RL_YELLOW }; + 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(); QPixmap BitmCubeGreen; @@ -91,10 +91,10 @@ protected slots: class CMultiColorLED : public QLabel, public CMultiColorLEDbase { public: - CMultiColorLED(QWidget* parent, const char* name = 0, WFlags f = 0); + CMultiColorLED ( QWidget* parent, const char* name = 0, WFlags f = 0 ); protected: - virtual void SetPixmap(QPixmap& NewBitmap) {setPixmap(NewBitmap);} + virtual void SetPixmap ( QPixmap& NewBitmap ) { setPixmap ( NewBitmap ); } }; diff --git a/src/protocol.cpp b/src/protocol.cpp index 92cbd44f..a0b80132 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -729,7 +729,7 @@ void CProtocol::GenMessageFrame ( CVector& vecOut, const int iTotLenByte = MESS_LEN_WITHOUT_DATA_BYTE + iDataLenByte; // init message vector - vecOut.Init( iTotLenByte ); + vecOut.Init ( iTotLenByte ); // encode header ----- unsigned int iCurPos = 0; // init position pointer @@ -769,7 +769,7 @@ void CProtocol::GenMessageFrame ( CVector& vecOut, } PutValOnStream ( vecOut, iCurPos, - static_cast ( CRCObj.GetCRC () ), 2 ); + static_cast ( CRCObj.GetCRC() ), 2 ); } void CProtocol::PutValOnStream ( CVector& vecIn, diff --git a/src/protocol.h b/src/protocol.h index a68dcc93..a4a4e367 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -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_ #include @@ -48,7 +48,7 @@ #define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag // 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) */ ) // time out for message re-send if no acknowledgement was received @@ -78,7 +78,7 @@ public: bool ParseMessage ( const CVector& vecbyData, const int iNumBytes ); - void DeleteSendMessQueue (); + void DeleteSendMessQueue(); protected: class CSendMessage @@ -95,7 +95,7 @@ protected: vecMessage.Init ( NewSendMess.vecMessage.Size() ); vecMessage = NewSendMess.vecMessage; - iID = NewSendMess.iID; + iID = NewSendMess.iID; iCnt = NewSendMess.iCnt; return *this; } @@ -168,4 +168,4 @@ signals: }; -#endif /* !defined(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_) */ +#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */ diff --git a/src/resample.cpp b/src/resample.cpp index 22d2274d..a839bc45 100755 --- a/src/resample.cpp +++ b/src/resample.cpp @@ -195,16 +195,16 @@ void CAudioResample::Init ( const int iNewInputBlockSize, switch ( iFrom / iTo ) { case 2: // 48 kHz to 24 kHz - pFiltTaps = fResTaps2; - iNumTaps = INTERP_I_2 * NUM_TAPS_PER_PHASE2; - iI = DECIM_D_2; + pFiltTaps = fResTaps2; + iNumTaps = INTERP_I_2 * NUM_TAPS_PER_PHASE2; + iI = DECIM_D_2; break; /* not yet supported case ( 2 / 3 ): // 48 kHz to 32 kHz - pFiltTaps = fResTaps3_2; - iNumTaps = INTERP_I_3_2 * NUM_TAPS_PER_PHASE3_2; - iI = DECIM_D_3_2; + pFiltTaps = fResTaps3_2; + iNumTaps = INTERP_I_3_2 * NUM_TAPS_PER_PHASE3_2; + iI = DECIM_D_3_2; break; */ @@ -223,16 +223,16 @@ case ( 2 / 3 ): // 48 kHz to 32 kHz switch ( iTo / iFrom ) { case 2: // 24 kHz to 48 kHz - pFiltTaps = fResTaps2; - iNumTaps = DECIM_D_2 * NUM_TAPS_PER_PHASE2; - iI = INTERP_I_2; + pFiltTaps = fResTaps2; + iNumTaps = DECIM_D_2 * NUM_TAPS_PER_PHASE2; + iI = INTERP_I_2; break; /* not yet supported case 1.5: // 32 kHz to 48 kHz - pFiltTaps = fResTaps3_2; - iNumTaps = DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2; - iI = INTERP_I_3_2; + pFiltTaps = fResTaps3_2; + iNumTaps = DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2; + iI = INTERP_I_3_2; break; */ diff --git a/src/resample.h b/src/resample.h index 57ee7f49..99281677 100755 --- a/src/resample.h +++ b/src/resample.h @@ -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_ #include "util.h" @@ -37,9 +37,9 @@ public: CResample() {} virtual ~CResample() {} - void Init(const int iNewInputBlockSize); - int Resample(CVector& vecdInput, CVector& vecdOutput, - const double dRation); + void Init ( const int iNewInputBlockSize ); + int Resample ( CVector& vecdInput, CVector& vecdOutput, + const double dRation ); protected: double dTStep; @@ -58,8 +58,8 @@ public: CAudioResample() {} virtual ~CAudioResample() {} - void Init(const int iNewInputBlockSize, const int iFrom, const int iTo); - void Resample(CVector& vecdInput, CVector& vecdOutput); + void Init ( const int iNewInputBlockSize, const int iFrom, const int iTo ); + void Resample ( CVector& vecdInput, CVector& vecdOutput ); protected: 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_ ) diff --git a/src/server.h b/src/server.h index fb909e2f..1ff695ba 100755 --- a/src/server.h +++ b/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_ #include @@ -45,14 +45,14 @@ public: CServer ( const bool bUseLogging ); virtual ~CServer() {} - void Start (); - void Stop (); + void Start(); + void Stop(); bool IsRunning() { return Timer.isActive(); } void GetConCliParam ( CVector& vecHostAddresses, CVector& vecsName, CVector& veciJitBufSize, CVector& veciNetwOutBlSiFact, - CVector& veciNetwInBlSiFact) + CVector& veciNetwInBlSiFact ) { ChannelSet.GetConCliParam ( vecHostAddresses, vecsName, veciJitBufSize, veciNetwOutBlSiFact, veciNetwInBlSiFact ); @@ -71,11 +71,11 @@ protected: QTimer Timer; CVector vecsSendData; - /* actual working objects */ + // actual working objects CChannelSet ChannelSet; CSocket Socket; - /* debugging, evaluating */ + // debugging, evaluating CMovingAv RespTimeMoAvBuf; QTime TimeLastBlock; @@ -88,4 +88,4 @@ public slots: }; -#endif /* !defined(SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_) */ +#endif /* !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */ diff --git a/src/settings.cpp b/src/settings.cpp index 1f3477a2..6cbbdad6 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -56,42 +56,50 @@ void CSettings::ReadIniFile() pClient->strName = GetIniSetting ( ini, "Client", "name" ); // 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 ); } // 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 ); } // reverberation channel assignment - if ( GetFlagIniSet(ini, "Client", "reverblchan", bValue ) == TRUE ) { + if ( GetFlagIniSet ( ini, "Client", "reverblchan", bValue ) == TRUE ) + { pClient->SetReverbOnLeftChan ( bValue ); } // 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 ); } // 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 ); } // 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 ); } // 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 ); } // 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 ); } } @@ -136,8 +144,8 @@ void CSettings::WriteIniFile() } bool CSettings::GetNumericIniSet ( INIFile& theINI, string strSection, - string strKey, int iRangeStart, - int iRangeStop, int& iValue ) + string strKey, int iRangeStart, + int iRangeStop, int& iValue ) { /* Init return value */ bool bReturn = FALSE; @@ -220,116 +228,136 @@ void CSettings::SetFlagIniSet ( INIFile& theINI, string strSection, string strKe /* 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 session, but the code will run normally */ -#pragma warning (push) -#pragma warning (disable : 4786 4503) +#pragma warning ( push ) +#pragma warning ( disable : 4786 4503 ) #endif -string CSettings::GetIniSetting(CSettings::INIFile& theINI, const char* section, - const char* key, const char* defaultval) +string CSettings::GetIniSetting ( CSettings::INIFile& theINI, const char* section, + const char* key, const char* defaultval ) { - string result(defaultval); - INIFile::iterator iSection = theINI.find(string(section)); + string result ( defaultval ); + 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; + } } return result; } -void CSettings::PutIniSetting(CSettings::INIFile &theINI, const char *section, - const char *key, const char *value) +void CSettings::PutIniSetting ( CSettings::INIFile &theINI, const char *section, + const char *key, const char *value ) { INIFile::iterator iniSection; 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 */ INISection newsection; if (key) { - newsection.insert( - std::pair(string(key), string(value))); + newsection.insert ( + std::pair ( string ( key ), string ( value ) ) ); } - theINI.insert( - std::pair(string(section), newsection)); + theINI.insert ( + std::pair ( string ( section ), newsection ) ); } - else if (key) - { - /* Found section, make sure key isn't in there already, - if it is, just drop and re-add */ - apair = iniSection->second.find(string(key)); - if (apair != iniSection->second.end()) - iniSection->second.erase(apair); + else + { + if ( key ) + { + /* Found section, make sure key isn't in there already, + if it is, just drop and re-add */ + apair = iniSection->second.find ( string ( key ) ); + if ( apair != iniSection->second.end() ) + { + iniSection->second.erase(apair); + } - iniSection->second.insert( - std::pair(string(key), string(value))); - } + iniSection->second.insert ( + std::pair ( string ( key ), string ( value ) ) ); + } + } } -CSettings::INIFile CSettings::LoadIni(const char* filename) +CSettings::INIFile CSettings::LoadIni ( const char* filename ) { INIFile theINI; char *value, *temp; string section; 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)); - file.getline(buffer, sizeof(buffer)); + memset ( buffer, 0, sizeof ( buffer ) ); + file.getline ( buffer, sizeof ( buffer ) ); - if ((temp = strchr(buffer, '\n'))) + if ( ( temp = strchr ( buffer, '\n' ) ) ) + { *temp = '\0'; /* Cut off at newline */ + } - if ((temp = strchr(buffer, '\r'))) + if ( ( temp = strchr ( buffer, '\r' ) ) ) + { *temp = '\0'; /* Cut off at linefeeds */ + } - if ((buffer[0] == '[') && (temp = strrchr(buffer, ']'))) + if ( ( buffer[0] == '[' ) && ( temp = strrchr ( buffer, ']' ) ) ) { /* if line is like --> [section name] */ *temp = '\0'; /* Chop off the trailing ']' */ section = &buffer[1]; - PutIniSetting(theINI, &buffer[1]); /* Start new section */ + PutIniSetting ( theINI, &buffer[1] ); /* Start new section */ } - else if (buffer[0] && (value = strchr(buffer, '='))) - { - /* Assign whatever follows = sign to value, chop at "=" */ - *value++ = '\0'; + else + { + if ( buffer[0] && ( value = strchr ( buffer, '=' ) ) ) + { + /* Assign whatever follows = sign to value, chop at "=" */ + *value++ = '\0'; - /* And add both sides to INISection */ - PutIniSetting(theINI, section.c_str(), buffer, value); - } - else if (buffer[0]) - { - /* Must be a comment or something */ - PutIniSetting(theINI, section.c_str(), buffer, ""); - } + /* And add both sides to INISection */ + PutIniSetting ( theINI, section.c_str(), buffer, value ); + } + else + { + if ( buffer[0] ) + { + /* Must be a comment or something */ + PutIniSetting ( theINI, section.c_str(), buffer, "" ); + } + } + } } + 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 */ - std::fstream file(filename, std::ios::out); - if(!file.good()) + std::fstream file ( filename, std::ios::out ); + if ( !file.good() ) + { return; + } /* Just iterate the hashes and values and dump them to a file */ 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 */ file << "[" << section->first << "]" << std::endl; @@ -338,17 +366,23 @@ void CSettings::SaveIni(CSettings::INIFile &theINI, const char* filename) bFirstSection = FALSE; } else + { file << std::endl << "[" << section->first << "]" << std::endl; + } } 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; + } else + { file << pair->first << "=" << std::endl; + } pair++; } 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 second */ -bool CSettings::StlIniCompareStringNoCase::operator()(const string& x, - const string& y) const +bool CSettings::StlIniCompareStringNoCase::operator() ( const string& x, + const string& y ) const { #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 #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 unsigned nCount = 0; int nResult = 0; const char *p1 = x.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; + } p1++; p2++; nCount++; } - if (nResult == 0) + if ( nResult == 0 ) { - if (*p1 && !*p2) + if ( *p1 && !*p2 ) + { nResult = -1; - if (!*p1 && *p2) + } + if ( !*p1 && *p2 ) + { nResult = 1; + } } - if (nResult < 0) + if ( nResult < 0 ) + { return true; + } return false; #endif /* strcasecmp */ #endif } #ifdef _MSC_VER -#pragma warning(pop) +#pragma warning ( pop ) #endif diff --git a/src/settings.h b/src/settings.h index c1c793f3..efc634f2 100755 --- a/src/settings.h +++ b/src/settings.h @@ -22,7 +22,7 @@ * \******************************************************************************/ -#if !defined(SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_) +#if !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ ) #define SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ #include "global.h" @@ -47,20 +47,20 @@ class CSettings public: CSettings ( CClient* pNCliP ) : pClient ( pNCliP ) {} - void Load (); - void Save (); + void Load(); + void Save(); protected: - void ReadIniFile (); - void WriteIniFile (); + void ReadIniFile(); + void WriteIniFile(); - /* Function declarations for stlini code written by Robert Kesterson */ + // function declarations for stlini code written by Robert Kesterson 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 INISection; typedef std::map INIFile; @@ -81,8 +81,8 @@ protected: bool GetFlagIniSet ( INIFile& theINI, string strSection, string strKey, bool& bValue ); - /* Pointer to the client object needed for the various settings */ + // pointer to the client object needed for the various settings CClient* pClient; }; -#endif // !defined(SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_) +#endif // !defined ( SETTINGS_H__3B0BA660_DGEG56G456G9876D31912__INCLUDED_ ) diff --git a/src/socket.cpp b/src/socket.cpp index 9d3b8c55..34f29832 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -26,7 +26,7 @@ /* Implementation *************************************************************/ -void CSocket::Init () +void CSocket::Init() { /* allocate memory for network receive and send buffer in samples */ vecbyRecBuf.Init ( MAX_SIZE_BYTES_NETW_BUF ); @@ -63,13 +63,13 @@ void CSocket::Init () /* connect the "activated" signal */ QObject::connect ( pSocketNotivRead, SIGNAL ( activated ( int ) ), - this, SLOT ( OnDataReceived () ) ); + this, SLOT ( OnDataReceived() ) ); } void CSocket::SendPacket ( const CVector& vecbySendBuf, const CHostAddress& HostAddr ) { - const int iVecSizeOut = vecbySendBuf.Size (); + const int iVecSizeOut = vecbySendBuf.Size(); if ( iVecSizeOut != 0 ) { @@ -80,7 +80,7 @@ void CSocket::SendPacket ( const CVector& vecbySendBuf, } } -void CSocket::OnDataReceived () +void CSocket::OnDataReceived() { /* read block from network interface */ const int iNumBytesRead = SocketDevice.readBlock( (char*) &vecbyRecBuf[0], @@ -93,14 +93,14 @@ void CSocket::OnDataReceived () } /* get host address of client */ - CHostAddress RecHostAddr ( SocketDevice.peerAddress (), - SocketDevice.peerPort () ); + CHostAddress RecHostAddr ( SocketDevice.peerAddress(), + SocketDevice.peerPort() ); if ( bIsClient ) { /* client */ /* check if packet comes from the server we want to connect */ - if ( ! ( pChannel->GetAddress () == RecHostAddr ) ) + if ( ! ( pChannel->GetAddress() == RecHostAddr ) ) { return; } diff --git a/src/socket.h b/src/socket.h index ee80efc2..428f6a6e 100755 --- a/src/socket.h +++ b/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_ #include @@ -37,7 +37,7 @@ /* 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 ) @@ -67,8 +67,8 @@ protected: CVector vecbyRecBuf; CHostAddress RecHostAddr; - CChannel* pChannel; /* for client */ - CChannelSet* pChannelSet; /* for server */ + CChannel* pChannel; // for client + CChannelSet* pChannelSet; // for server QObject* pServer; bool bIsClient; @@ -78,4 +78,4 @@ public slots: }; -#endif /* !defined(SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_) */ +#endif /* !defined ( SOCKET_HOIHGE76GEKJH98_3_4344_BB23945IUHF1912__INCLUDED_ ) */ diff --git a/src/util.cpp b/src/util.cpp index b96060c6..37267c92 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -29,16 +29,16 @@ /* Input level meter implementation ------------------------------------------ */ void CSignalLevelMeter::Update ( CVector& vecdAudio ) { - /* Do the update for entire vector */ - const int iVecSize = vecdAudio.Size (); + // do the update for entire vector + const int iVecSize = vecdAudio.Size(); for ( int i = 0; i < iVecSize; i++ ) { - /* norm of current audio sample */ + // norm of current audio sample const double dCurSig = fabs ( vecdAudio[i] ); - /* search for maximum. Decrease this max with time */ - /* decrease max with time */ + // search for maximum. Decrease this max with time + // decrease max with time if ( dCurLevel >= METER_FLY_BACK ) { dCurLevel *= 0.9999; @@ -48,7 +48,7 @@ void CSignalLevelMeter::Update ( CVector& vecdAudio ) dCurLevel = 0; } - /* search for max */ + // search for max if ( dCurSig > dCurLevel ) { dCurLevel = dCurSig; @@ -56,24 +56,24 @@ void CSignalLevelMeter::Update ( CVector& vecdAudio ) } } -double CSignalLevelMeter::MicLevel () +double CSignalLevelMeter::MicLevel() { const double dNormMicLevel = dCurLevel / _MAXSHORT; - /* logarithmic measure */ + // logarithmic measure if ( dNormMicLevel > 0 ) { return 20.0 * log10 ( dNormMicLevel ); } else { - return -100000.0; /* large negative value */ + return -100000.0; // large negative value } } /* CRC ---------------------------------------------------------------------- */ -void CCRC::Reset () +void CCRC::Reset() { /* Init state shift-register with ones. Set all registers to "1" with bit-wise not operation */ @@ -84,7 +84,7 @@ void CCRC::AddByte ( const uint8_t byNewInput ) { for ( int i = 0; i < 8; i++ ) { - /* Shift bits in shift-register for transistion */ + // shift bits in shift-register for transistion iStateShiftReg <<= 1; /* 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; } - /* Add new data bit to the LSB */ + // add new data bit to the LSB if ( ( byNewInput & ( 1 << ( 8 - i - 1 ) ) ) > 0 ) { 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 ) { iStateShiftReg ^= iPoly; @@ -111,10 +111,10 @@ void CCRC::AddByte ( const uint8_t byNewInput ) uint32_t CCRC::GetCRC() { - /* Return inverted shift-register (1's complement) */ + // return inverted shift-register (1's complement) 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 ); } @@ -138,7 +138,7 @@ CAudioReverb::CAudioReverb ( const double rT60 ) { 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 }; const double scaler = (double) SAMPLE_RATE / 44100.0; @@ -269,17 +269,17 @@ double CAudioReverb::ProcessSample ( const double input ) * GUI utilities * \******************************************************************************/ /* About dialog ------------------------------------------------------------- */ -CAboutDlg::CAboutDlg(QWidget* parent, const char* name, bool modal, WFlags f) - : CAboutDlgBase(parent, name, modal, f) +CAboutDlg::CAboutDlg ( QWidget* parent, const char* name, bool modal, WFlags f ) + : CAboutDlgBase ( parent, name, modal, f ) { - /* Set the text for the about dialog html text control */ - TextViewCredits->setText( - "

" /* General description of llcon software */ + // set the text for the about dialog html text control + TextViewCredits->setText ( + "

" // general description of llcon software "llcon " + tr("Client/Server communication tool to enable " "musician to play together through a conventional broadband internet " "connection (like DSL).") + "" "


" - "

" /* GPL header text */ + "

" // GPL header text "This program is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " @@ -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 " "USA" "


" - "

" /* Libraries used by this compilation of Dream */ + "

" // libraries used by this compilation of Dream "" + tr("llcon uses the following libraries or code snippets:") + "

" "
    " @@ -305,8 +305,8 @@ CAboutDlg::CAboutDlg(QWidget* parent, const char* name, bool modal, WFlags f) "
" "
"); - /* Set version number in about dialog */ - TextLabelVersion->setText(GetVersionAndNameStr()); + // set version number in about dialog + TextLabelVersion->setText ( GetVersionAndNameStr() ); } QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) @@ -319,7 +319,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) strVersionText += "
"; } - strVersionText += tr("llcon, Version ") + VERSION; + strVersionText += tr ( "llcon, Version " ) + VERSION; if ( bWithHtml ) { @@ -330,7 +330,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) strVersionText += "\n"; } - strVersionText += tr("llcon, Low-Latency (internet) CONnection"); + strVersionText += tr ( "llcon, Low-Latency (internet) CONnection" ); if ( bWithHtml ) { @@ -341,7 +341,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) strVersionText += "\n"; } - strVersionText += tr("Under the GNU General Public License (GPL)"); + strVersionText += tr ( "Under the GNU General Public License (GPL)" ); if ( bWithHtml ) { @@ -355,28 +355,28 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml ) /* Help menu ---------------------------------------------------------------- */ CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QPopupMenu ( parent ) { - /* Standard help menu consists of about and what's this help */ - insertItem ( tr ( "What's &This" ), this , + // standard help menu consists of about and what's this help + insertItem ( tr ( "What's &This" ), this, SLOT ( OnHelpWhatsThis () ), SHIFT+Key_F1 ); insertSeparator(); - insertItem ( tr ( "&About..." ), this, SLOT ( OnHelpAbout () ) ); + insertItem ( tr ( "&About..." ), this, SLOT ( OnHelpAbout() ) ); } /******************************************************************************\ * Global functions implementation * \******************************************************************************/ -void DebugError(const char* pchErDescr, const char* pchPar1Descr, - const double dPar1, const char* pchPar2Descr, - const double dPar2) +void DebugError ( const char* pchErDescr, const char* pchPar1Descr, + const double dPar1, const char* pchPar2Descr, + const double dPar2 ) { - FILE* pFile = fopen("DebugError.dat", "a"); - fprintf(pFile, pchErDescr); fprintf(pFile, " ### "); - fprintf(pFile, pchPar1Descr); fprintf(pFile, ": "); - fprintf(pFile, "%e ### ", dPar1); - fprintf(pFile, pchPar2Descr); fprintf(pFile, ": "); - fprintf(pFile, "%e\n", dPar2); - fclose(pFile); - printf("\nDebug error! For more information see test/DebugError.dat\n"); - exit(1); + FILE* pFile = fopen ( "DebugError.dat", "a" ); + fprintf ( pFile, pchErDescr ); fprintf ( pFile, " ### " ); + fprintf ( pFile, pchPar1Descr ); fprintf ( pFile, ": " ); + fprintf ( pFile, "%e ### ", dPar1); + fprintf ( pFile, pchPar2Descr ); fprintf ( pFile, ": " ); + fprintf ( pFile, "%e\n", dPar2 ); + fclose ( pFile ); + printf ( "\nDebug error! For more information see test/DebugError.dat\n" ); + exit ( 1 ); } diff --git a/src/util.h b/src/util.h index 02ef817d..0dfeb5b7 100755 --- a/src/util.h +++ b/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_ #include @@ -33,7 +33,7 @@ #include #include #include "global.h" -using namespace std; /* Because of the library: "vector" */ +using namespace std; // because of the library: "vector" #ifdef _WIN32 # include "../windows/moc/aboutdlgbase.h" #else @@ -46,24 +46,28 @@ using namespace std; /* Because of the library: "vector" */ /* Global functions ***********************************************************/ -/* Converting double to short */ -inline short Double2Short(const double dInput) +// converting double to short +inline short Double2Short ( const double dInput ) { - /* Lower bound */ - if (dInput < _MINSHORT) + // lower bound + if ( dInput < _MINSHORT ) + { return _MINSHORT; + } - /* Upper bound */ - if (dInput > _MAXSHORT) + // upper bound + if ( dInput > _MAXSHORT ) + { return _MAXSHORT; + } return (short) dInput; } -/* Debug error handling */ -void DebugError(const char* pchErDescr, const char* pchPar1Descr, - const double dPar1, const char* pchPar2Descr, - const double dPar2); +// debug error handling +void DebugError ( const char* pchErDescr, const char* pchPar1Descr, + const double dPar1, const char* pchPar2Descr, + const double dPar2 ); /******************************************************************************\ @@ -72,64 +76,64 @@ void DebugError(const char* pchErDescr, const char* pchPar1Descr, template class CVector : public std::vector { public: - CVector() : iVectorSize(0) {pData = this->begin();} - CVector(const int iNeSi) {Init(iNeSi);} - CVector(const int iNeSi, const TData tInVa) {Init(iNeSi, tInVa);} + CVector() : iVectorSize ( 0 ) { pData = this->begin(); } + CVector ( const int iNeSi ) { Init(iNeSi); } + CVector ( const int iNeSi, const TData tInVa ) { Init ( iNeSi, tInVa ); } virtual ~CVector() {} /* Copy constructor: The order of the initialization list must not be changed. First, the base class must be initialized, then the pData pointer must be set to the new data source. The bit access is, by default, reset */ - CVector(const CVector& vecI) : - std::vector(static_cast&>(vecI)), - iVectorSize(vecI.Size()) { pData = this->begin(); } + CVector ( const CVector& vecI ) : + std::vector ( static_cast&> ( vecI ) ), + 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 */ - void Init(const int iNewSize, const TData tIniVal); - void Reset(const TData tResetVal); + // use this init to give all elements a defined value + void Init ( const int iNewSize, const TData tIniVal ); + void Reset ( const TData tResetVal ); - void Enlarge(const int iAddedSize); - void Add(const TData& tI) {Enlarge(1); pData[iVectorSize - 1] = tI;} + void Enlarge ( const int iAddedSize ); + 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: CVector[x] = y is possible */ - inline TData& operator[](const int iPos) { + inline TData& operator[] ( const int iPos ) { #ifdef _DEBUG_ - if ((iPos < 0) || (iPos > iVectorSize - 1)) + if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) ) { - DebugError("Writing vector out of bounds", "Vector size", - iVectorSize, "New parameter", iPos); + DebugError ( "Writing vector out of bounds", "Vector size", + iVectorSize, "New parameter", iPos ); } #endif - return pData[iPos];} + return pData[iPos]; } - inline TData operator[](const int iPos) const { + inline TData operator[] ( const int iPos ) const { #ifdef _DEBUG_ - if ((iPos < 0) || (iPos > iVectorSize - 1)) + if ( ( iPos < 0 ) || ( iPos > iVectorSize - 1 ) ) { - DebugError("Reading vector out of bounds", "Vector size", - iVectorSize, "New parameter", iPos); + DebugError ( "Reading vector out of bounds", "Vector size", + iVectorSize, "New parameter", iPos ); } #endif - return pData[iPos];} + return pData[iPos]; } - inline CVector& operator=(const CVector& vecI) { + inline CVector& operator= ( const CVector& vecI ) { #ifdef _DEBUG_ /* Vectors which shall be copied MUST have same size! (If this is satisfied, the parameter "iVectorSize" must not be adjusted as a side effect) */ - if (vecI.Size() != iVectorSize) + if ( vecI.Size() != iVectorSize ) { - DebugError("Vector operator=() different size", "Vector size", - iVectorSize, "New parameter", vecI.Size()); + DebugError ( "Vector operator=() different size", "Vector size", + iVectorSize, "New parameter", vecI.Size() ); } #endif - vector::operator=(vecI); + vector::operator= ( vecI ); /* Reset my data pointer in case, the operator=() of the base class did change the actual memory */ @@ -145,42 +149,44 @@ protected: /* Implementation *************************************************************/ -template void CVector::Init(const int iNewSize) +template void CVector::Init ( const int iNewSize ) { iVectorSize = iNewSize; /* Clear old buffer and reserve memory for new buffer, get iterator for pointer operations */ this->clear(); - this->resize(iNewSize); + this->resize ( iNewSize ); pData = this->begin(); } -template void CVector::Init(const int iNewSize, - const TData tIniVal) +template void CVector::Init ( const int iNewSize, + const TData tIniVal ) { - /* Call actual init routine */ - Init(iNewSize); + // call actual init routine + Init ( iNewSize ); - /* Set values */ - Reset(tIniVal); + // set values + Reset ( tIniVal ); } -template void CVector::Enlarge(const int iAddedSize) +template void CVector::Enlarge ( const int iAddedSize ) { iVectorSize += iAddedSize; - this->resize(iVectorSize); + this->resize ( iVectorSize ); /* We have to reset the pointer since it could be that the vector size was zero before enlarging the vector */ pData = this->begin(); } -template void CVector::Reset(const TData tResetVal) +template void CVector::Reset ( const TData tResetVal ) { - /* Set all values to reset value */ - for (int i = 0; i < iVectorSize; i++) + // set all values to reset value + for ( int i = 0; i < iVectorSize; i++ ) + { pData[i] = tResetVal; + } } @@ -190,42 +196,44 @@ template void CVector::Reset(const TData tResetVal) template class CFIFO : public CVector { public: - CFIFO() : CVector(), iCurIdx(0) {} - CFIFO(const int iNeSi) : CVector(iNeSi), iCurIdx(0) {} - CFIFO(const int iNeSi, const TData tInVa) : - CVector(iNeSi, tInVa), iCurIdx(0) {} + CFIFO() : CVector(), iCurIdx ( 0 ) {} + CFIFO ( const int iNeSi ) : CVector(iNeSi), iCurIdx ( 0 ) {} + CFIFO ( const int iNeSi, const TData tInVa ) : + CVector ( iNeSi, tInVa ), iCurIdx ( 0 ) {} - void Add(const TData tNewD); - inline TData Get() {return this->pData[iCurIdx];} + void Add ( const TData tNewD ); + inline TData Get() { return this->pData[iCurIdx]; } - virtual void Init(const int iNewSize); - virtual void Init(const int iNewSize, const TData tIniVal); + virtual void Init ( const int iNewSize ); + virtual void Init ( const int iNewSize, const TData tIniVal ); protected: int iCurIdx; }; -template void CFIFO::Init(const int iNewSize) +template void CFIFO::Init ( const int iNewSize ) { iCurIdx = 0; - CVector::Init(iNewSize); + CVector::Init ( iNewSize ); } -template void CFIFO::Init(const int iNewSize, - const TData tIniVal) +template void CFIFO::Init ( const int iNewSize, + const TData tIniVal ) { iCurIdx = 0; - CVector::Init(iNewSize, tIniVal); + CVector::Init ( iNewSize, tIniVal ); } -template void CFIFO::Add(const TData tNewD) +template void CFIFO::Add ( const TData tNewD ) { this->pData[iCurIdx] = tNewD; - /* Increment index */ + // increment index iCurIdx++; - if (iCurIdx >= this->iVectorSize) + if ( iCurIdx >= this->iVectorSize ) + { iCurIdx = 0; + } } @@ -235,23 +243,29 @@ template void CFIFO::Add(const TData tNewD) template class CMovingAv : public CVector { public: - CMovingAv() : CVector(), iCurIdx(0), iNorm(0), - tCurAvResult(TData(0)) {} - CMovingAv(const int iNeSi) : CVector(iNeSi), iCurIdx(0), iNorm(0), - tCurAvResult(TData(0)) {} - CMovingAv(const int iNeSi, const TData tInVa) : - CVector(iNeSi, tInVa), iCurIdx(0), iNorm(0), - tCurAvResult(TData(0)) {} + CMovingAv() : CVector(), iCurIdx ( 0 ), iNorm ( 0 ), + tCurAvResult ( TData ( 0 ) ) {} + CMovingAv ( const int iNeSi ) : CVector ( iNeSi ), iCurIdx ( 0 ), iNorm ( 0 ), + tCurAvResult ( TData ( 0 ) ) {} + CMovingAv ( const int iNeSi, const TData tInVa ) : + CVector ( iNeSi, tInVa ), iCurIdx ( 0 ), iNorm ( 0 ), + tCurAvResult ( TData ( 0 ) ) {} - void Add(const TData tNewD); + void Add ( const TData tNewD ); inline TData GetAverage() { - if (this->iNorm == 0) return TData(0); - else return tCurAvResult / this->iNorm; + if ( this->iNorm == 0 ) + { + return TData ( 0 ); + } + else + { + return tCurAvResult / this->iNorm; + } } - virtual void Init(const int iNewSize); - void InitVec(const int iNewSize, const int iNewVecSize); + virtual void Init ( const int iNewSize ); + void InitVec ( const int iNewSize, const int iNewVecSize ); protected: int iCurIdx; @@ -259,36 +273,40 @@ protected: TData tCurAvResult; }; -template void CMovingAv::Init(const int iNewSize) +template void CMovingAv::Init ( const int iNewSize ) { - iNorm = 0; - iCurIdx = 0; - tCurAvResult = TData(0); /* Only for scalars! */ - CVector::Init(iNewSize); + iNorm = 0; + iCurIdx = 0; + tCurAvResult = TData ( 0 ); // only for scalars! + CVector::Init ( iNewSize ); } -template void CMovingAv::Add(const TData tNewD) +template void CMovingAv::Add ( const TData tNewD ) { /* Optimized calculation of the moving average. We only add a new value and subtract the old value from the result. We only need one addition and a history buffer */ - /* Subtract oldest value */ + // subtract oldest value tCurAvResult -= this->pData[iCurIdx]; - /* Add new value and write in memory */ + // add new value and write in memory tCurAvResult += tNewD; this->pData[iCurIdx] = tNewD; - /* Increase position pointer and test if wrap */ + // increase position pointer and test if wrap iCurIdx++; - if (iCurIdx >= this->iVectorSize) + if ( iCurIdx >= this->iVectorSize ) + { iCurIdx = 0; + } - /* take care of norm */ - if (this->iNorm < this->iVectorSize) + // take care of norm + if ( this->iNorm < this->iVectorSize ) + { this->iNorm++; + } } @@ -301,8 +319,8 @@ class CAboutDlg : public CAboutDlgBase Q_OBJECT public: - CAboutDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, - WFlags f = 0); + CAboutDlg ( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, + WFlags f = 0 ); static QString GetVersionAndNameStr ( const bool bWithHtml = true ); }; @@ -314,14 +332,14 @@ class CLlconHelpMenu : public QPopupMenu Q_OBJECT public: - CLlconHelpMenu(QWidget* parent = 0); + CLlconHelpMenu ( QWidget* parent = 0 ); protected: CAboutDlg AboutDlg; public slots: - void OnHelpWhatsThis () { QWhatsThis::enterWhatsThisMode (); } - void OnHelpAbout () { AboutDlg.exec(); } + void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); } + void OnHelpAbout() { AboutDlg.exec(); } }; @@ -330,12 +348,12 @@ public slots: class CSignalLevelMeter { public: - CSignalLevelMeter() : dCurLevel(0.0) {} + CSignalLevelMeter() : dCurLevel ( 0.0 ) {} virtual ~CSignalLevelMeter() {} - void Update(CVector& vecdAudio); + void Update ( CVector& vecdAudio ); double MicLevel(); - void Reset() {dCurLevel = 0.0;} + void Reset() { dCurLevel = 0.0; } protected: double dCurLevel; @@ -344,17 +362,17 @@ protected: class CHostAddress { public: - CHostAddress() : InetAddr((Q_UINT32) 0), iPort(0) {} - CHostAddress(const QHostAddress NInetAddr, const Q_UINT16 iNPort) : - InetAddr(NInetAddr), iPort(iNPort) {} - CHostAddress(const CHostAddress& NHAddr) : - InetAddr(NHAddr.InetAddr), iPort(NHAddr.iPort) {} + CHostAddress() : InetAddr ( (Q_UINT32) 0 ), iPort ( 0 ) {} + CHostAddress ( const QHostAddress NInetAddr, const Q_UINT16 iNPort ) : + InetAddr ( NInetAddr ), iPort ( iNPort ) {} + CHostAddress ( const CHostAddress& NHAddr ) : + InetAddr ( NHAddr.InetAddr ), iPort ( NHAddr.iPort ) {} - /* copy and compare operators */ - CHostAddress& operator=(const CHostAddress& NHAddr) - {InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this;} - bool operator==(const CHostAddress& CompAddr) /* oompare operator */ - {return ((CompAddr.InetAddr == InetAddr) && (CompAddr.iPort == iPort));} + // copy and compare operators + CHostAddress& operator= ( const CHostAddress& NHAddr ) + { InetAddr = NHAddr.InetAddr; iPort = NHAddr.iPort; return *this; } + bool operator== ( const CHostAddress& CompAddr ) // compare operator + { return ( ( CompAddr.InetAddr == InetAddr ) && ( CompAddr.iPort == iPort ) ); } QHostAddress InetAddr; Q_UINT16 iPort; @@ -377,14 +395,14 @@ public: class CAudioReverb { public: - CAudioReverb(const double rT60 = (double) 5.0); + CAudioReverb ( const double rT60 = (double) 5.0 ); void Clear(); - double ProcessSample(const double input); + double ProcessSample ( const double input ); protected: - void setT60(const double rT60); - bool isPrime(const int number); + void setT60 ( const double rT60 ); + bool isPrime ( const int number ); CFIFO allpassDelays_[3]; CFIFO combDelays_[4]; @@ -397,14 +415,14 @@ protected: class CCRC { public: - CCRC () : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 ) - { Reset (); } - virtual ~CCRC () {} + CCRC() : iPoly ( ( 1 << 5 ) | ( 1 << 12 ) ), iBitOutMask ( 1 << 16 ) + { Reset(); } + virtual ~CCRC() {} - void Reset (); + void Reset(); void AddByte ( const uint8_t byNewInput ); bool CheckCRC ( const uint32_t iCRC ) { return iCRC == GetCRC(); } - uint32_t GetCRC (); + uint32_t GetCRC(); protected: uint32_t iBitOutMask; @@ -424,11 +442,11 @@ public: // vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms CVector veccNetTi ( 5 ); - veccNetTi[0] = static_cast ( qTiIn.hour () ); - veccNetTi[1] = static_cast ( qTiIn.minute () ); - veccNetTi[2] = static_cast ( qTiIn.second () ); + veccNetTi[0] = static_cast ( qTiIn.hour() ); + veccNetTi[1] = static_cast ( qTiIn.minute() ); + veccNetTi[2] = static_cast ( qTiIn.second() ); - const int iMs = qTiIn.msec (); + const int iMs = qTiIn.msec(); veccNetTi[3] = static_cast ( ( iMs >> 8 ) & 255 ); veccNetTi[4] = static_cast ( iMs & 255 ); @@ -501,8 +519,8 @@ public: } protected: - bool bDoLogging; - FILE* pFile; + bool bDoLogging; + FILE* pFile; }; -#endif /* !defined(UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_) */ +#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */ diff --git a/windows/sound.cpp b/windows/sound.cpp index 3d63f7a4..36731d47 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -32,186 +32,206 @@ /******************************************************************************\ * Wave in * \******************************************************************************/ -bool CSound::Read(CVector& psData) +bool CSound::Read ( CVector& psData ) { int i; bool bError; - /* Check if device must be opened or reinitialized */ - if (bChangParamIn == TRUE) + // check if device must be opened or reinitialized + if ( bChangParamIn == TRUE ) { OpenInDevice(); - /* Reinit sound interface */ - InitRecording(iBufferSizeIn, bBlockingRec); + // Reinit sound interface + InitRecording ( iBufferSizeIn, bBlockingRec ); - /* Reset flag */ + // Reset flag bChangParamIn = FALSE; } - /* Wait until data is available */ - if (!(m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE)) + // wait until data is available + if ( ! ( m_WaveInHeader[iWhichBufferIn].dwFlags & WHDR_DONE ) ) { - if (bBlockingRec == TRUE) - WaitForSingleObject(m_WaveInEvent, INFINITE); + if ( bBlockingRec == TRUE ) + { + WaitForSingleObject ( m_WaveInEvent, INFINITE ); + } else + { return FALSE; + } } - /* Check if buffers got lost */ + // check if buffers got lost 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++; + } } /* If the number of done buffers equals the total number of buffers, it is very likely that a buffer got lost -> set error flag */ - if (iNumInBufDone == iCurNumSndBufIn) + if ( iNumInBufDone == iCurNumSndBufIn ) + { bError = TRUE; + } else + { bError = FALSE; + } - /* Copy data from sound card in output buffer */ - for (i = 0; i < iBufferSizeIn; i++) + // copy data from sound card in output buffer + for ( i = 0; i < iBufferSizeIn; 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(); - /* In case more than one buffer was ready, reset event */ - ResetEvent(m_WaveInEvent); + // in case more than one buffer was ready, reset event + ResetEvent ( m_WaveInEvent ); return bError; } void CSound::AddInBuffer() { - /* Unprepare old wave-header */ - waveInUnprepareHeader( - m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof(WAVEHDR)); + // unprepare old wave-header + waveInUnprepareHeader ( + m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof ( WAVEHDR ) ); - /* Prepare buffers for sending to sound interface */ - PrepareInBuffer(iWhichBufferIn); + // prepare buffers for sending to sound interface + PrepareInBuffer ( iWhichBufferIn ); - /* Send buffer to driver for filling with new data */ - waveInAddBuffer(m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof(WAVEHDR)); + // send buffer to driver for filling with new data + waveInAddBuffer ( m_WaveIn, &m_WaveInHeader[iWhichBufferIn], sizeof ( WAVEHDR ) ); - /* Toggle buffers */ + // toggle buffers iWhichBufferIn++; - if (iWhichBufferIn == iCurNumSndBufIn) + if ( iWhichBufferIn == iCurNumSndBufIn ) + { iWhichBufferIn = 0; + } } -void CSound::PrepareInBuffer(int iBufNum) +void CSound::PrepareInBuffer ( int iBufNum ) { - /* Set struct entries */ - m_WaveInHeader[iBufNum].lpData = (LPSTR) &psSoundcardBuffer[iBufNum][0]; + // set struct entries + m_WaveInHeader[iBufNum].lpData = (LPSTR) &psSoundcardBuffer[iBufNum][0]; m_WaveInHeader[iBufNum].dwBufferLength = iBufferSizeIn * BYTES_PER_SAMPLE; - m_WaveInHeader[iBufNum].dwFlags = 0; + m_WaveInHeader[iBufNum].dwFlags = 0; - /* Prepare wave-header */ - waveInPrepareHeader(m_WaveIn, &m_WaveInHeader[iBufNum], sizeof(WAVEHDR)); + // prepare wave-header + 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 */ - if (bChangParamIn == TRUE) + // check if device must be opened or reinitialized + if ( bChangParamIn == TRUE ) { OpenInDevice(); - /* Reset flag */ + // reset flag bChangParamIn = FALSE; } - /* Set internal parameter */ + // set internal parameter iBufferSizeIn = iNewBufferSize; bBlockingRec = bNewBlocking; - /* Reset interface so that all buffers are returned from the interface */ - waveInReset(m_WaveIn); - waveInStop(m_WaveIn); + // reset interface so that all buffers are returned from the interface + waveInReset ( 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()" */ iWhichBufferIn = 0; - /* Create memory for sound card buffer */ - for (int i = 0; i < iCurNumSndBufIn; i++) + // create memory for sound card buffer + for ( int i = 0; i < iCurNumSndBufIn; i++ ) { /* Unprepare old wave-header in case that we "re-initialized" this module. Calling "waveInUnprepareHeader()" with an unprepared buffer (when the module is initialized for the first time) has 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]; + } psSoundcardBuffer[i] = new short[iBufferSizeIn]; /* Send all buffers to driver for filling the queue ----------------- */ - /* Prepare buffers before sending them to the sound interface */ - PrepareInBuffer(i); + // prepare buffers before sending them to the sound interface + PrepareInBuffer ( i ); AddInBuffer(); } - /* Notify that sound capturing can start now */ - waveInStart(m_WaveIn); + // notify that sound capturing can start now + waveInStart ( m_WaveIn ); /* This reset event is very important for initialization, otherwise we will get errors! */ - ResetEvent(m_WaveInEvent); + ResetEvent ( m_WaveInEvent ); } void CSound::OpenInDevice() { - /* Open wave-input and set call-back mechanism to event handle */ - if (m_WaveIn != NULL) + // open wave-input and set call-back mechanism to event handle + if ( m_WaveIn != NULL ) { - waveInReset(m_WaveIn); - waveInClose(m_WaveIn); + waveInReset ( m_WaveIn ); + waveInClose ( m_WaveIn ); } - MMRESULT result = waveInOpen(&m_WaveIn, iCurInDev, &sWaveFormatEx, - (DWORD) m_WaveInEvent, NULL, CALLBACK_EVENT); + MMRESULT result = waveInOpen ( &m_WaveIn, iCurInDev, &sWaveFormatEx, + (DWORD) m_WaveInEvent, NULL, CALLBACK_EVENT ); - if (result != MMSYSERR_NOERROR) + if ( result != MMSYSERR_NOERROR ) { - throw CGenErr("Sound Interface Start, waveInOpen() failed. This error " - "usually occurs if another application blocks the sound in."); + throw CGenErr ( "Sound Interface Start, waveInOpen() failed. This error " + "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 */ - if ((iNewDev >= iNumDevs) || (iNewDev < 0)) + // set device to wave mapper if iNewDev is invalid + if ( ( iNewDev >= iNumDevs ) || ( iNewDev < 0 ) ) + { iNewDev = WAVE_MAPPER; + } - /* Change only in case new device id is not already active */ - if (iNewDev != iCurInDev) + // change only in case new device id is not already active + if ( iNewDev != iCurInDev ) { - iCurInDev = iNewDev; + iCurInDev = iNewDev; bChangParamIn = TRUE; } } -void CSound::SetInNumBuf(int iNewNum) +void CSound::SetInNumBuf ( int iNewNum ) { - /* check new parameter */ - if ((iNewNum >= MAX_SND_BUF_IN) || (iNewNum < 1)) + // check new parameter + if ( ( iNewNum >= MAX_SND_BUF_IN ) || ( iNewNum < 1 ) ) + { iNewNum = NUM_SOUND_BUFFERS_IN; + } - /* Change only if parameter is different */ - if (iNewNum != iCurNumSndBufIn) + // change only if parameter is different + if ( iNewNum != iCurNumSndBufIn ) { iCurNumSndBufIn = iNewNum; - bChangParamIn = TRUE; + bChangParamIn = TRUE; } } @@ -219,41 +239,41 @@ void CSound::SetInNumBuf(int iNewNum) /******************************************************************************\ * Wave out * \******************************************************************************/ -bool CSound::Write(CVector& psData) +bool CSound::Write ( CVector& psData ) { int i, j; int iCntPrepBuf; int iIndexDoneBuf; bool bError; - /* Check if device must be opened or reinitialized */ - if (bChangParamOut == TRUE) + // check if device must be opened or reinitialized + if ( bChangParamOut == TRUE ) { OpenOutDevice(); - /* Reinit sound interface */ - InitPlayback(iBufferSizeOut, bBlockingPlay); + // reinit sound interface + InitPlayback ( iBufferSizeOut, bBlockingPlay ); - /* Reset flag */ + // reset flag bChangParamOut = FALSE; } - /* Get number of "done"-buffers and position of one of them */ - GetDoneBuffer(iCntPrepBuf, iIndexDoneBuf); + // get number of "done"-buffers and position of one of them + GetDoneBuffer ( iCntPrepBuf, iIndexDoneBuf ); - /* Now check special cases (Buffer is full or empty) */ - if (iCntPrepBuf == 0) + // now check special cases (Buffer is full or empty) + if ( iCntPrepBuf == 0 ) { - if (bBlockingPlay == TRUE) + if ( bBlockingPlay == TRUE ) { /* Blocking wave out routine. Needed for transmitter. Always ensure that the buffer is completely filled to avoid buffer underruns */ - while (iCntPrepBuf == 0) + while ( iCntPrepBuf == 0 ) { - WaitForSingleObject(m_WaveOutEvent, INFINITE); + WaitForSingleObject ( m_WaveOutEvent, INFINITE ); - GetDoneBuffer(iCntPrepBuf, iIndexDoneBuf); + GetDoneBuffer ( iCntPrepBuf, iIndexDoneBuf ); } } else @@ -261,50 +281,59 @@ bool CSound::Write(CVector& psData) /* All buffers are filled, dump new block ----------------------- */ // It would be better to kill half of the buffer blocks to set the start // back to the middle: TODO - return TRUE; /* An error occurred */ + return TRUE; // an error occurred } } - else if (iCntPrepBuf == iCurNumSndBufOut) - { - /* --------------------------------------------------------------------- - Buffer is empty -> send as many cleared blocks to the sound- - interface until half of the buffer size is reached */ - /* Send half of the buffer size blocks to the sound-interface */ - for (j = 0; j < iCurNumSndBufOut / 2; j++) - { - /* First, clear these buffers */ - for (i = 0; i < iBufferSizeOut; i++) - psPlaybackBuffer[j][i] = 0; - - /* Then send them to the interface */ - AddOutBuffer(j); - } - - /* Set index for done buffer */ - iIndexDoneBuf = iCurNumSndBufOut / 2; - - bError = TRUE; - } else - bError = FALSE; + { + if ( iCntPrepBuf == iCurNumSndBufOut ) + { + /* ----------------------------------------------------------------- + Buffer is empty -> send as many cleared blocks to the sound- + interface until half of the buffer size is reached */ + // send half of the buffer size blocks to the sound-interface + for ( j = 0; j < iCurNumSndBufOut / 2; j++ ) + { + // first, clear these buffers + for ( i = 0; i < iBufferSizeOut; i++ ) + { + psPlaybackBuffer[j][i] = 0; + } - /* Copy stereo data from input in soundcard buffer */ - for (i = 0; i < iBufferSizeOut; i++) + // then send them to the interface + AddOutBuffer ( j ); + } + + // set index for done buffer + iIndexDoneBuf = iCurNumSndBufOut / 2; + + bError = TRUE; + } + else + { + bError = FALSE; + } + } + + // copy stereo data from input in soundcard buffer + for ( i = 0; i < iBufferSizeOut; i++ ) + { psPlaybackBuffer[iIndexDoneBuf][i] = psData[i]; + } - /* Now, send the current block */ - AddOutBuffer(iIndexDoneBuf); + // now, send the current block + AddOutBuffer ( iIndexDoneBuf ); 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; - 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++; iIndexDoneBuf = i; @@ -312,114 +341,124 @@ void CSound::GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf) } } -void CSound::AddOutBuffer(int iBufNum) +void CSound::AddOutBuffer ( int iBufNum ) { - /* Unprepare old wave-header */ - waveOutUnprepareHeader( - m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR)); + // Unprepare old wave-header + waveOutUnprepareHeader ( + m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) ); - /* Prepare buffers for sending to sound interface */ - PrepareOutBuffer(iBufNum); + // Prepare buffers for sending to sound interface + PrepareOutBuffer ( iBufNum ); - /* Send buffer to driver for filling with new data */ - waveOutWrite(m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR)); + // Send buffer to driver for filling with new data + waveOutWrite ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) ); } -void CSound::PrepareOutBuffer(int iBufNum) +void CSound::PrepareOutBuffer ( int iBufNum ) { - /* Set Header data */ - m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0]; + // Set Header data + m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0]; m_WaveOutHeader[iBufNum].dwBufferLength = iBufferSizeOut * BYTES_PER_SAMPLE; - m_WaveOutHeader[iBufNum].dwFlags = 0; + m_WaveOutHeader[iBufNum].dwFlags = 0; - /* Prepare wave-header */ - waveOutPrepareHeader(m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof(WAVEHDR)); + // Prepare wave-header + 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; - /* Check if device must be opened or reinitialized */ - if (bChangParamOut == TRUE) + // check if device must be opened or reinitialized + if ( bChangParamOut == TRUE ) { OpenOutDevice(); - /* Reset flag */ + // reset flag bChangParamOut = FALSE; } - /* Set internal parameters */ + // set internal parameters iBufferSizeOut = iNewBufferSize; - bBlockingPlay = bNewBlocking; + bBlockingPlay = bNewBlocking; - /* Reset interface */ - waveOutReset(m_WaveOut); + // reset interface + 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, 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 */ - if (psPlaybackBuffer[j] != NULL) + // create memory for playback buffer + if ( psPlaybackBuffer[j] != NULL ) + { delete[] psPlaybackBuffer[j]; + } psPlaybackBuffer[j] = new short[iBufferSizeOut]; - /* Clear new buffer */ - for (i = 0; i < iBufferSizeOut; i++) + // clear new buffer + for ( i = 0; i < iBufferSizeOut; i++ ) + { psPlaybackBuffer[j][i] = 0; + } - /* Prepare buffer for sending to the sound interface */ - PrepareOutBuffer(j); + // prepare buffer for sending to the sound interface + PrepareOutBuffer ( j ); - /* Initially, send all buffers to the interface */ - AddOutBuffer(j); + // initially, send all buffers to the interface + AddOutBuffer ( j ); } } void CSound::OpenOutDevice() { - if (m_WaveOut != NULL) + if ( m_WaveOut != NULL ) { - waveOutReset(m_WaveOut); - waveOutClose(m_WaveOut); + waveOutReset ( m_WaveOut ); + waveOutClose ( m_WaveOut ); } - MMRESULT result = waveOutOpen(&m_WaveOut, iCurOutDev, &sWaveFormatEx, - (DWORD) m_WaveOutEvent, NULL, CALLBACK_EVENT); + MMRESULT result = waveOutOpen ( &m_WaveOut, iCurOutDev, &sWaveFormatEx, + (DWORD) m_WaveOutEvent, NULL, CALLBACK_EVENT ); - if (result != MMSYSERR_NOERROR) - throw CGenErr("Sound Interface Start, waveOutOpen() failed."); + if ( result != MMSYSERR_NOERROR ) + { + 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 */ - if ((iNewDev >= iNumDevs) || (iNewDev < 0)) + // set device to wave mapper if iNewDev is invalid + if ( ( iNewDev >= iNumDevs ) || ( iNewDev < 0 ) ) + { iNewDev = WAVE_MAPPER; + } - /* Change only in case new device id is not already active */ - if (iNewDev != iCurOutDev) + // change only in case new device id is not already active + if ( iNewDev != iCurOutDev ) { - iCurOutDev = iNewDev; + iCurOutDev = iNewDev; bChangParamOut = TRUE; } } -void CSound::SetOutNumBuf(int iNewNum) +void CSound::SetOutNumBuf ( int iNewNum ) { - /* check new parameter */ - if ((iNewNum >= MAX_SND_BUF_OUT) || (iNewNum < 1)) + // check new parameter + if ( ( iNewNum >= MAX_SND_BUF_OUT ) || ( iNewNum < 1 ) ) + { iNewNum = NUM_SOUND_BUFFERS_OUT; + } - /* Change only if parameter is different */ - if (iNewNum != iCurNumSndBufOut) + // change only if parameter is different + if ( iNewNum != iCurNumSndBufOut ) { iCurNumSndBufOut = iNewNum; - bChangParamOut = TRUE; + bChangParamOut = TRUE; } } @@ -432,71 +471,83 @@ void CSound::Close() int i; MMRESULT result; - /* Reset audio driver */ - if (m_WaveOut != NULL) + // reset audio driver + if ( m_WaveOut != NULL ) { - result = waveOutReset(m_WaveOut); - if (result != MMSYSERR_NOERROR) - throw CGenErr("Sound Interface, waveOutReset() failed."); + result = waveOutReset ( m_WaveOut ); + + if ( result != MMSYSERR_NOERROR ) + { + throw CGenErr ( "Sound Interface, waveOutReset() failed." ); + } } - if (m_WaveIn != NULL) + if ( m_WaveIn != NULL ) { - result = waveInReset(m_WaveIn); - if (result != MMSYSERR_NOERROR) - throw CGenErr("Sound Interface, waveInReset() failed."); + result = waveInReset ( m_WaveIn ); + + if ( result != MMSYSERR_NOERROR ) + { + throw CGenErr ( "Sound Interface, waveInReset() failed." ); + } } - /* Set event to ensure that thread leaves the waiting function */ - if (m_WaveInEvent != NULL) + // set event to ensure that thread leaves the waiting function + if ( m_WaveInEvent != NULL ) + { SetEvent(m_WaveInEvent); + } - /* Wait for the thread to terminate */ - Sleep(500); + // wait for the thread to terminate + Sleep ( 500 ); - /* Unprepare wave-headers */ - if (m_WaveIn != NULL) + // unprepare wave-headers + if ( m_WaveIn != NULL ) { - for (i = 0; i < iCurNumSndBufIn; i++) + for ( i = 0; i < iCurNumSndBufIn; i++ ) { - result = waveInUnprepareHeader( - m_WaveIn, &m_WaveInHeader[i], sizeof(WAVEHDR)); + result = waveInUnprepareHeader ( + m_WaveIn, &m_WaveInHeader[i], sizeof ( WAVEHDR ) ); - if (result != MMSYSERR_NOERROR) + if ( result != MMSYSERR_NOERROR ) { - throw CGenErr("Sound Interface, waveInUnprepareHeader()" - " failed."); + throw CGenErr ( "Sound Interface, waveInUnprepareHeader()" + " failed." ); } } - /* Close the sound in device */ - result = waveInClose(m_WaveIn); - if (result != MMSYSERR_NOERROR) - throw CGenErr("Sound Interface, waveInClose() failed."); + // close the sound in device + result = waveInClose ( m_WaveIn ); + if ( result != MMSYSERR_NOERROR ) + { + throw CGenErr ( "Sound Interface, waveInClose() failed." ); + } } - if (m_WaveOut != NULL) + if ( m_WaveOut != NULL ) { - for (i = 0; i < iCurNumSndBufOut; i++) + for ( i = 0; i < iCurNumSndBufOut; i++ ) { - result = waveOutUnprepareHeader( - m_WaveOut, &m_WaveOutHeader[i], sizeof(WAVEHDR)); + result = waveOutUnprepareHeader ( + m_WaveOut, &m_WaveOutHeader[i], sizeof ( WAVEHDR ) ); - if (result != MMSYSERR_NOERROR) + if ( result != MMSYSERR_NOERROR ) { - throw CGenErr("Sound Interface, waveOutUnprepareHeader()" - " failed."); + throw CGenErr ( "Sound Interface, waveOutUnprepareHeader()" + " failed." ); } } - /* Close the sound out device */ - result = waveOutClose(m_WaveOut); - if (result != MMSYSERR_NOERROR) - throw CGenErr("Sound Interface, waveOutClose() failed."); + // close the sound out device + result = waveOutClose ( m_WaveOut ); + if ( result != MMSYSERR_NOERROR ) + { + throw CGenErr ( "Sound Interface, waveOutClose() failed." ); + } } - /* Set flag to open devices the next time it is initialized */ - bChangParamIn = TRUE; + // set flag to open devices the next time it is initialized + bChangParamIn = TRUE; bChangParamOut = TRUE; } @@ -504,30 +555,30 @@ CSound::CSound() { int i; - /* init number of sound buffers */ - iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN; + // init number of sound buffers + iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN; iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT; - /* Should be initialized because an error can occur during init */ - m_WaveInEvent = NULL; + // should be initialized because an error can occur during init + m_WaveInEvent = NULL; m_WaveOutEvent = NULL; - m_WaveIn = NULL; - m_WaveOut = NULL; + m_WaveIn = NULL; + m_WaveOut = NULL; - /* Init buffer pointer to zero */ - for (i = 0; i < MAX_SND_BUF_IN; i++) + // init buffer pointer to zero + 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; } - 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; } - /* Init wave-format structure */ + // init wave-format structure sWaveFormatEx.wFormatTag = WAVE_FORMAT_PCM; sWaveFormatEx.nChannels = NUM_IN_OUT_CHANNELS; sWaveFormatEx.wBitsPerSample = BITS_PER_SAMPLE; @@ -538,40 +589,46 @@ CSound::CSound() sWaveFormatEx.nSamplesPerSec; 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(); - 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."); + // 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++) + // get info about the devices and store the names + for ( i = 0; i < iNumDevs; i++ ) { - if (!waveInGetDevCaps(i, &m_WaveInDevCaps, sizeof(WAVEINCAPS))) + 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); + // 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; + // set flag to open devices + bChangParamIn = TRUE; bChangParamOut = TRUE; - /* Default device number, "wave mapper" */ - iCurInDev = WAVE_MAPPER; + // default device number, "wave mapper" + iCurInDev = WAVE_MAPPER; iCurOutDev = WAVE_MAPPER; - /* Non-blocking wave out is default */ + // non-blocking wave out is default bBlockingPlay = FALSE; - /* Blocking wave in is default */ + // blocking wave in is default bBlockingRec = TRUE; } @@ -579,23 +636,31 @@ CSound::~CSound() { int i; - /* Delete allocated memory */ - for (i = 0; i < iCurNumSndBufIn; i++) + // delete allocated memory + for ( i = 0; i < iCurNumSndBufIn; i++ ) { - if (psSoundcardBuffer[i] != NULL) + if ( psSoundcardBuffer[i] != NULL ) + { delete[] psSoundcardBuffer[i]; + } } - for (i = 0; i < iCurNumSndBufOut; i++) + for ( i = 0; i < iCurNumSndBufOut; i++ ) { - if (psPlaybackBuffer[i] != NULL) + if ( psPlaybackBuffer[i] != NULL ) + { delete[] psPlaybackBuffer[i]; + } } - /* Close the handle for the events */ - if (m_WaveInEvent != NULL) - CloseHandle(m_WaveInEvent); + // close the handle for the events + if ( m_WaveInEvent != NULL ) + { + CloseHandle ( m_WaveInEvent ); + } - if (m_WaveOutEvent != NULL) - CloseHandle(m_WaveOutEvent); + if ( m_WaveOutEvent != NULL ) + { + CloseHandle ( m_WaveOutEvent ); + } } diff --git a/windows/sound.h b/windows/sound.h index 276e02e7..04423a09 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -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_ #include @@ -36,16 +36,16 @@ /* Definitions ****************************************************************/ #define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only use one channel for recording) */ -#define BITS_PER_SAMPLE 16 /* Use all bits of the D/A-converter */ -#define BYTES_PER_SAMPLE 2 /* Number of bytes per sample */ +#define BITS_PER_SAMPLE 16 // use all bits of the D/A-converter +#define BYTES_PER_SAMPLE 2 // number of bytes per sample #define MAX_SND_BUF_IN 200 #define MAX_SND_BUF_OUT 200 -#define NUM_SOUND_BUFFERS_IN (70 / MIN_BLOCK_DURATION_MS) -#define NUM_SOUND_BUFFERS_OUT (80 / MIN_BLOCK_DURATION_MS) +#define NUM_SOUND_BUFFERS_IN ( 70 / 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 @@ -56,32 +56,32 @@ public: CSound(); virtual ~CSound(); - void InitRecording(int iNewBufferSize, bool bNewBlocking = TRUE); - void InitPlayback(int iNewBufferSize, bool bNewBlocking = FALSE); - bool Read(CVector& psData); - bool Write(CVector& psData); + void InitRecording ( int iNewBufferSize, bool bNewBlocking = TRUE ); + void InitPlayback ( int iNewBufferSize, bool bNewBlocking = FALSE ); + bool Read ( CVector& psData ); + bool Write ( CVector& psData ); - int GetNumDev() {return iNumDevs;} - std::string GetDeviceName(int iDiD) {return pstrDevices[iDiD];} - void SetOutDev(int iNewDev); - int GetOutDev() {return iCurOutDev;} - void SetInDev(int iNewDev); - int GetInDev() {return iCurInDev;} - void SetOutNumBuf(int iNewNum); - int GetOutNumBuf() {return iCurNumSndBufOut;} - void SetInNumBuf(int iNewNum); - int GetInNumBuf() {return iCurNumSndBufIn;} + int GetNumDev() { return iNumDevs; } + std::string GetDeviceName ( int iDiD ) { return pstrDevices[iDiD]; } + void SetOutDev ( int iNewDev ); + int GetOutDev() { return iCurOutDev; } + void SetInDev ( int iNewDev ); + int GetInDev() { return iCurInDev; } + void SetOutNumBuf ( int iNewNum ); + int GetOutNumBuf() { return iCurNumSndBufOut; } + void SetInNumBuf ( int iNewNum ); + int GetInNumBuf() { return iCurNumSndBufIn; } void Close(); protected: void OpenInDevice(); void OpenOutDevice(); - void PrepareInBuffer(int iBufNum); - void PrepareOutBuffer(int iBufNum); + void PrepareInBuffer ( int iBufNum ); + void PrepareOutBuffer ( int iBufNum ); void AddInBuffer(); - void AddOutBuffer(int iBufNum); - void GetDoneBuffer(int& iCntPrepBuf, int& iIndexDoneBuf); + void AddOutBuffer ( int iBufNum ); + void GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf ); WAVEFORMATEX sWaveFormatEx; UINT iNumDevs; @@ -93,7 +93,7 @@ protected: int iCurNumSndBufIn; int iCurNumSndBufOut; - /* Wave in */ + // wave in WAVEINCAPS m_WaveInDevCaps; HWAVEIN m_WaveIn; HANDLE m_WaveInEvent; @@ -103,7 +103,7 @@ protected: short* psSoundcardBuffer[MAX_SND_BUF_IN]; bool bBlockingRec; - /* Wave out */ + // wave out int iBufferSizeOut; HWAVEOUT m_WaveOut; 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_ )