Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13223

Modified Files:
        AudioIO.cpp AudioIO.h 
Log Message:
Moving Automatic Volume to Meter Update as Richard suggested.
This should avoid the crashes on OSX and Linux caused by GUI calls from 
portaudio callback function.

Index: AudioIO.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.cpp,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -d -r1.218 -r1.219
--- AudioIO.cpp 29 Jul 2009 22:31:06 -0000      1.218
+++ AudioIO.cpp 2 Aug 2009 18:47:16 -0000       1.219
@@ -250,6 +250,10 @@
    mSendMidiState = false;
 #endif
 
+#ifdef AUTOMATIC_VOLUME
+   mAVActive = false;
+#endif
+
    mStreamToken = 0;
    mStopStreamCount = 0;
    mTempFloats = new float[65536]; // TODO: out channels * PortAudio buffer 
size
@@ -2522,6 +2526,14 @@
    mAVAnalysisCounter = 0;
 }
 
+void AudioIO::AVDisable() {
+   mAVActive = false;
+}
+
+bool AudioIO::AVIsActive() {
+   return mAVActive;
+}
+
 void AudioIO::AVProcess() {
    AudacityProject *proj = GetActiveProject();
    if (proj && mAVActive) {
@@ -2537,19 +2549,15 @@
                //we can't improve it more now
                if (mAVTotalAnalysis != 0) {
                   mAVActive = false;
-                  #ifndef __WXMAC__
-                     proj->TP_DisplayStatusMessage(_("Automatic Volume 
stopped. It was not possible to optimize it more. Still too high."));
-                  #endif
+                  proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. 
It was not possible to optimize it more. Still too high."));
                }
             }
             else {
-               double vol = max(LOWER_BOUND, iv+mAVGoldPoint-mAVMax);
+               double vol = max(LOWER_BOUND, iv*mAVGoldPoint/mAVMax);
                Px_SetInputVolume(mPortMixer, vol);
-               #ifndef __WXMAC__
-                  wxString msg;
-                  msg.Printf(_("Automatic Volume decreased the volume to 
%f."), vol);
-                  proj->TP_DisplayStatusMessage(msg);
-               #endif
+               wxString msg;
+               msg.Printf(_("Automatic Volume decreased the volume to %f."), 
vol);
+               proj->TP_DisplayStatusMessage(msg);
             }
          }
          else if ( mAVMax < mAVGoldPoint - mAVGoldDelta ) {
@@ -2558,29 +2566,23 @@
                //we can't improve it more
                if (mAVTotalAnalysis != 0) {
                   mAVActive = false;
-                  #ifndef __WXMAC__
-                     proj->TP_DisplayStatusMessage(_("Automatic Volume 
stopped. It was not possible to optimize it more. Still too low."));
-                  #endif
+                  proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. 
It was not possible to optimize it more. Still too low."));
                }
             }
             else {
-               double vol = min(UPPER_BOUND, iv+mAVGoldPoint-mAVMax);
+               double vol = min(UPPER_BOUND, iv*mAVGoldPoint/mAVMax);
                Px_SetInputVolume(mPortMixer, vol);
-               #ifndef __WXMAC__
-                  wxString msg;
-                  msg.Printf(_("Automatic Volume increased the volume to 
%.2f."), vol);
-                  proj->TP_DisplayStatusMessage(msg);
-               #endif
+               wxString msg;
+               msg.Printf(_("Automatic Volume increased the volume to %.2f."), 
vol);
+               proj->TP_DisplayStatusMessage(msg);
             }
          }
          else if (mAVTotalAnalysis != 0) {
             //when we are satisfied with the current volume
             mAVActive = false;
-            #ifndef __WXMAC__
-               wxString msg;
-               msg.Printf(_("Automatic Volume stopped. %.2f seems an 
acceptable volume."), iv);
-               proj->TP_DisplayStatusMessage(msg);
-            #endif
+            wxString msg;
+            msg.Printf(_("Automatic Volume stopped. %.2f seems an acceptable 
volume."), iv);
+            proj->TP_DisplayStatusMessage(msg);
          }
 
          mAVAnalysisCounter++;
@@ -2591,12 +2593,10 @@
 
       if (mAVActive && mAVTotalAnalysis != 0 && mAVAnalysisCounter >= 
mAVTotalAnalysis) {
          mAVActive = false;
-         #ifndef __WXMAC__
-            if (mAVMax > mAVGoldPoint + mAVGoldDelta)
-               proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. The 
total number of analysis has been exceeded without finding an acceptable 
volume. Still too high."));
-            else
-               proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. The 
total number of analysis has been exceeded without finding an acceptable 
volume. Still too low."));
-         #endif
+         if (mAVMax > mAVGoldPoint + mAVGoldDelta)
+            proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. The 
total number of analysis has been exceeded without finding an acceptable 
volume. Still too high."));
+         else
+            proj->TP_DisplayStatusMessage(_("Automatic Volume stopped. The 
total number of analysis has been exceeded without finding an acceptable 
volume. Still too low."));
       }
    }
 }
@@ -2686,10 +2686,6 @@
       gAudioIO->mUpdatingMeters = false;
    }  // end recording VU meter update
 
-   #ifdef AUTOMATIC_VOLUME
-      gAudioIO->AVProcess();
-   #endif
-
    // Stop recording if 'silence' is detected
    if(gAudioIO->mPauseRec && inputBuffer) {
       if(gAudioIO->mInputMeter->GetMaxPeak() < gAudioIO->mSilenceLevel ) {

Index: AudioIO.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- AudioIO.h   25 Jul 2009 17:17:13 -0000      1.71
+++ AudioIO.h   2 Aug 2009 18:47:16 -0000       1.72
@@ -279,6 +279,8 @@
     */
    #ifdef AUTOMATIC_VOLUME
       void AVInitialize();
+      void AVDisable();
+      bool AVIsActive();
       void AVProcess();
    #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

Reply via email to