From d9562ea52531c4c044d0e4e401ed71e03e386948 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 13 Apr 2020 18:13:42 +0200 Subject: [PATCH] fixed audio fade-in counter for 64 samples frame size --- src/channel.cpp | 13 ++++++++++++- src/channel.h | 16 ++++++---------- src/global.h | 8 ++++---- src/util.h | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index d406b364..7e18d7f6 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -30,6 +30,7 @@ CChannel::CChannel ( const bool bNIsServer ) : vecdGains ( MAX_NUM_CHANNELS, 1.0 ), bDoAutoSockBufSize ( true ), iFadeInCnt ( 0 ), + iFadeInCntMax ( FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE ), bIsEnabled ( false ), bIsServer ( bNIsServer ) { @@ -365,6 +366,16 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor iNetwFrameSizeFact = NetworkTransportProps.iBlockSizeFact; iNetwFrameSize = static_cast ( NetworkTransportProps.iBaseNetworkPacketSize ); + // update maximum number of frames for fade in counter + if ( eAudioCompressionType == CT_OPUS ) + { + iFadeInCntMax = FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE; + } + else + { + iFadeInCntMax = FADE_IN_NUM_FRAMES; + } + MutexSocketBuf.lock(); { // update socket buffer (the network block size is a multiple of the @@ -463,7 +474,7 @@ EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, } // manage audio fade-in counter - if ( iFadeInCnt < FADE_IN_NUM_FRAMES ) + if ( iFadeInCnt < iFadeInCntMax ) { iFadeInCnt++; } diff --git a/src/channel.h b/src/channel.h index 2b3086f0..e83d5cf8 100755 --- a/src/channel.h +++ b/src/channel.h @@ -39,16 +39,11 @@ // set the time-out for the input buffer until the state changes from // connected to not connected (the actual time depends on the way the error // correction is implemented) -#define CON_TIME_OUT_SEC_MAX 30 // seconds +#define CON_TIME_OUT_SEC_MAX 30 // seconds -// number of frames for audio fade-in -#if ( SYSTEM_FRAME_SIZE_SAMPLES == 64 ) -// 48 kHz, 64 samples: 3 seconds / ( 64 samples / 48 kHz ) = 2250 -# define FADE_IN_NUM_FRAMES 2250 -#else -// 48 kHz, 128 samples: 3 seconds / ( 128 samples / 48 kHz ) = 1125 -# define FADE_IN_NUM_FRAMES 1125 -#endif +// number of frames for audio fade-in, 48 kHz, x samples: 3 sec / (x samples / 48 kHz) +#define FADE_IN_NUM_FRAMES 2250 +#define FADE_IN_NUM_FRAMES_DBLE_FRAMESIZE 1125 enum EPutDataStat @@ -113,7 +108,7 @@ public: void SetGain ( const int iChanID, const double dNewGain ); double GetGain ( const int iChanID ); - double GetFadeInGain() { return static_cast ( iFadeInCnt ) / FADE_IN_NUM_FRAMES; } + double GetFadeInGain() { return static_cast ( iFadeInCnt ) / iFadeInCntMax; } void SetRemoteChanGain ( const int iId, const double dGain ) { Protocol.CreateChanGainMes ( iId, dGain ); } @@ -210,6 +205,7 @@ protected: int iConTimeOut; int iConTimeOutStartVal; int iFadeInCnt; + int iFadeInCntMax; bool bIsEnabled; bool bIsServer; diff --git a/src/global.h b/src/global.h index 3bac8722..c509722b 100755 --- a/src/global.h +++ b/src/global.h @@ -107,13 +107,13 @@ LED bar: lbr #define DEFAULT_SERVER_NAME "Central Server" // download URL -#define JAMULUS_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files" +#define SOFTWARE_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files" // determining server internal address uses well-known host and port // (Google DNS, or something else reliable) -#define WELL_KNOWN_HOST "8.8.8.8" // Google -#define WELL_KNOWN_PORT 53 // DNS -#define IP_LOOKUP_TIMEOUT 500 // ms +#define WELL_KNOWN_HOST "8.8.8.8" // Google +#define WELL_KNOWN_PORT 53 // DNS +#define IP_LOOKUP_TIMEOUT 500 // ms // defined port numbers for client and server #define LLCON_DEFAULT_PORT_NUMBER 22124 diff --git a/src/util.h b/src/util.h index 39dacd47..ea060704 100755 --- a/src/util.h +++ b/src/util.h @@ -482,7 +482,7 @@ public slots: void OnHelpWhatsThis() { QWhatsThis::enterWhatsThisMode(); } void OnHelpAbout() { AboutDlg.exec(); } void OnHelpDownloadLink() - { QDesktopServices::openUrl ( QUrl ( JAMULUS_DOWNLOAD_URL ) ); } + { QDesktopServices::openUrl ( QUrl ( SOFTWARE_DOWNLOAD_URL ) ); } };