Update of /cvsroot/audacity/audacity-src/src In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19949
Modified Files: AudioIO.cpp AudioIO.h Log Message: Changing latency control from Portaudio's input latency to mT (OnMeterUpdate @ widgets/Meter.cpp) and Pa_GetStreamTime(mPortStreamV19) (AVProcess @ AudioIO.cpp). Portaudio's input latency is neither cross-plataform nor stable. Reported by Leland. Left uncommented printfs to help testing on different plataforms. Index: AudioIO.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.cpp,v retrieving revision 1.223 retrieving revision 1.224 diff -u -d -r1.223 -r1.224 --- AudioIO.cpp 10 Aug 2009 18:19:37 -0000 1.223 +++ AudioIO.cpp 15 Aug 2009 21:56:52 -0000 1.224 @@ -679,6 +679,7 @@ mRate, paFramesPerBufferUnspecified, paNoFlag, audacityAudioCallback, NULL ); + AVSetStartTime(); #if USE_PORTMIXER if (mPortStreamV19 != NULL && mLastPaError == paNoError) { @@ -2521,7 +2522,7 @@ mAVGoalPoint /= 100.0; mAVAnalysisTime /= 1000.0; mAVMax = 0.0; - mAVLastStartTime = max(0.0, mT0); + mAVLastStartTime = max(0.0, mT0); mAVClipped = false; mAVAnalysisCounter = 0; mAVChangeFactor = 1.0; @@ -2538,40 +2539,48 @@ return mAVActive; } +void AudioIO::AVSetStartTime() { + mAVAbsolutStartTime = Pa_GetStreamTime(mPortStreamV19); +} + +double AudioIO::AVGetLastDecisionTime() { + return mAVAnalysisEndTime; +} + void AudioIO::AVProcess(double maxPeak) { AudacityProject *proj = GetActiveProject(); if (proj && mAVActive) { if (mInputMeter->IsClipping()) mAVClipped = true; - if (mAVAnalysisEndTime >= 0.0) { - if (mAVAnalysisEndTime < GetStreamTime()) { // if we past it already start monitoring again - mAVMax = 0.0; //reset max - mAVAnalysisEndTime = -1.0; //disable latency protection - //printf("mMaxPeak resetted!"); - } - //printf("%f discarded\n", maxPeak); - return; - } + //if (mAVAnalysisEndTime >= 0.0) { + // if (mAVAnalysisEndTime < GetStreamTime()) { // if we past it already start monitoring again + // mAVMax = 0.0; //reset max + // mAVAnalysisEndTime = -1.0; //disable latency protection + // //printf("mMaxPeak resetted!"); + // } + // //printf("%f discarded\n", maxPeak); + // return; + //} //printf("%f\n", maxPeak); mAVMax = max(mAVMax, maxPeak); if ((mAVTotalAnalysis == 0 || mAVAnalysisCounter < mAVTotalAnalysis) && mTime - mAVLastStartTime >= mAVAnalysisTime) { - //putchar('\n'); + putchar('\n'); mAVMax = mInputMeter->ToLinearIfDB(mAVMax); double iv = (double) Px_GetInputVolume(mPortMixer); unsigned short changetype = 0; //0 - no change, 1 - increase change, 2 - decrease change - //printf("mAVAnalysisCounter:%d\n", mAVAnalysisCounter); - //printf("\tmAVClipped:%d\n", mAVClipped); - //printf("\tmAVMax:%f\n", mAVMax); - //printf("\tmAVGoalPoint:%f\n", mAVGoalPoint); - //printf("\tmAVGoalDelta:%f\n", mAVGoalDelta); - //printf("\tiv:%f\n", iv); - //printf("\tmAVChangeFactor:%f\n", mAVChangeFactor); + printf("mAVAnalysisCounter:%d\n", mAVAnalysisCounter); + printf("\tmAVClipped:%d\n", mAVClipped); + printf("\tmAVMax (linear):%f\n", mAVMax); + printf("\tmAVGoalPoint:%f\n", mAVGoalPoint); + printf("\tmAVGoalDelta:%f\n", mAVGoalDelta); + printf("\tiv:%f\n", iv); + printf("\tmAVChangeFactor:%f\n", mAVChangeFactor); if (mAVClipped || mAVMax > mAVGoalPoint + mAVGoalDelta) { - //printf("too high:\n"); + printf("too high:\n"); mAVTopLevel = min(mAVTopLevel, iv); - //printf("\tmAVTopLevel:%f\n", mAVTopLevel); + printf("\tmAVTopLevel:%f\n", mAVTopLevel); //if clipped or too high if (iv <= LOWER_BOUND) { //we can't improve it more now @@ -2579,7 +2588,7 @@ mAVActive = false; proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. It was not possible to optimize it more. Still too high.")); } - //printf("\talready min vol:%f\n", iv); + printf("\talready min vol:%f\n", iv); } else { double vol = max(LOWER_BOUND, iv+(mAVGoalPoint-mAVMax)*mAVChangeFactor); @@ -2588,43 +2597,44 @@ msg.Printf(_("Automatic Volume decreased the volume to %f."), vol); proj->TP_DisplayStatusMessage(msg); changetype = 1; - //printf("\tnew vol:%f\n", vol); + printf("\tnew vol:%f\n", vol); } } else if ( mAVMax < mAVGoalPoint - mAVGoalDelta ) { //if too low - //printf("too low:\n"); + printf("too low:\n"); if (iv >= UPPER_BOUND || iv + 0.005 > mAVTopLevel) { //condition for too low volumes and/or variable volumes that cause mAVTopLevel to decrease too much //we can't improve it more if (mAVTotalAnalysis != 0) { mAVActive = false; proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. It was not possible to optimize it more. Still too low.")); } - //printf("\talready max vol:%f\n", iv); + printf("\talready max vol:%f\n", iv); } else { double vol = min(UPPER_BOUND, iv+(mAVGoalPoint-mAVMax)*mAVChangeFactor); if (vol > mAVTopLevel) { vol = (iv + mAVTopLevel)/2.0; - //printf("\tTruncated vol:%f\n", vol); + printf("\tTruncated vol:%f\n", vol); } Px_SetInputVolume(mPortMixer, vol); wxString msg; msg.Printf(_("Automatic Volume increased the volume to %.2f."), vol); proj->TP_DisplayStatusMessage(msg); changetype = 2; - //printf("\tnew vol:%f\n", vol); + printf("\tnew vol:%f\n", vol); } } mAVAnalysisCounter++; - const PaStreamInfo* info = Pa_GetStreamInfo(mPortStreamV19); - double latency = 0.0; - if (info) - latency = info->inputLatency; - mAVAnalysisEndTime = mTime+latency; + //const PaStreamInfo* info = Pa_GetStreamInfo(mPortStreamV19); + //double latency = 0.0; + //if (info) + // latency = info->inputLatency; + //mAVAnalysisEndTime = mTime+latency; + mAVAnalysisEndTime = Pa_GetStreamTime(mPortStreamV19) - mAVAbsolutStartTime; mAVMax = 0; - //printf("\tmAVMax resetted:%f\n", mAVMax); + printf("\tA decision was made @ %f\n", mAVAnalysisEndTime); mAVClipped = false; mAVLastStartTime = mTime; Index: AudioIO.h =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.h,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- AudioIO.h 10 Aug 2009 18:19:37 -0000 1.75 +++ AudioIO.h 15 Aug 2009 21:56:52 -0000 1.76 @@ -282,6 +282,8 @@ void AVDisable(); bool AVIsActive(); void AVProcess(double maxPeak); + void AVSetStartTime(); + double AVGetLastDecisionTime(); #endif private: @@ -403,6 +405,7 @@ double mAVChangeFactor; double mAVTopLevel; double mAVAnalysisEndTime; + double mAVAbsolutStartTime; unsigned short mAVLastChangeType; //0 - no change, 1 - increase change, 2 - decrease change #endif ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs