MCPcopy Create free account
hub / github.com/audacity/audacity / AILAProcess

Method AILAProcess

libraries/lib-audio-io/AudioIO.cpp:2469–2595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2467}
2468
2469void AudioIO::AILAProcess(double maxPeak) {
2470 const auto proj = mOwningProject.lock();
2471 if (proj && mAILAActive) {
2472 if (mInputMeter && mInputMeter->IsClipping()) {
2473 mAILAClipped = true;
2474 wxPrintf("clipped");
2475 }
2476
2477 mAILAMax = max(mAILAMax, maxPeak);
2478
2479 if ((mAILATotalAnalysis == 0 || mAILAAnalysisCounter < mAILATotalAnalysis) && mPlaybackSchedule.GetSequenceTime() - mAILALastStartTime >= mAILAAnalysisTime) {
2480 auto ToLinearIfDB = [](double value, int dbRange) {
2481 if (dbRange >= 0)
2482 value = pow(10.0, (-(1.0-value) * dbRange)/20.0);
2483 return value;
2484 };
2485
2486 putchar('\n');
2487 mAILAMax = mInputMeter ? ToLinearIfDB(mAILAMax, mInputMeter->GetDBRange()) : 0.0;
2488 double iv = (double) Px_GetInputVolume(mPortMixer);
2489 unsigned short changetype = 0; //0 - no change, 1 - increase change, 2 - decrease change
2490 wxPrintf("mAILAAnalysisCounter:%d\n", mAILAAnalysisCounter);
2491 wxPrintf("\tmAILAClipped:%d\n", mAILAClipped);
2492 wxPrintf("\tmAILAMax (linear):%f\n", mAILAMax);
2493 wxPrintf("\tmAILAGoalPoint:%f\n", mAILAGoalPoint);
2494 wxPrintf("\tmAILAGoalDelta:%f\n", mAILAGoalDelta);
2495 wxPrintf("\tiv:%f\n", iv);
2496 wxPrintf("\tmAILAChangeFactor:%f\n", mAILAChangeFactor);
2497 if (mAILAClipped || mAILAMax > mAILAGoalPoint + mAILAGoalDelta) {
2498 wxPrintf("too high:\n");
2499 mAILATopLevel = min(mAILATopLevel, iv);
2500 wxPrintf("\tmAILATopLevel:%f\n", mAILATopLevel);
2501 //if clipped or too high
2502 if (iv <= LOWER_BOUND) {
2503 //we can't improve it more now
2504 if (mAILATotalAnalysis != 0) {
2505 mAILAActive = false;
2506 ProjectStatus::Get( *proj ).Set(
2507 XO(
2508"Automated Recording Level Adjustment stopped. It was not possible to optimize it more. Still too high.") );
2509 }
2510 wxPrintf("\talready min vol:%f\n", iv);
2511 }
2512 else {
2513 float vol = (float) max(LOWER_BOUND, iv+(mAILAGoalPoint-mAILAMax)*mAILAChangeFactor);
2514 Px_SetInputVolume(mPortMixer, vol);
2515 auto msg = XO(
2516"Automated Recording Level Adjustment decreased the volume to %f.").Format( vol );
2517 ProjectStatus::Get( *proj ).Set(msg);
2518 changetype = 1;
2519 wxPrintf("\tnew vol:%f\n", vol);
2520 float check = Px_GetInputVolume(mPortMixer);
2521 wxPrintf("\tverified %f\n", check);
2522 }
2523 }
2524 else if ( mAILAMax < mAILAGoalPoint - mAILAGoalDelta ) {
2525 //if too low
2526 wxPrintf("too low:\n");

Callers 1

OnMeterUpdateMethod · 0.80

Calls 9

maxFunction · 0.85
Px_GetInputVolumeFunction · 0.85
GetFunction · 0.85
Px_SetInputVolumeFunction · 0.85
minFunction · 0.50
lockMethod · 0.45
IsClippingMethod · 0.45
GetDBRangeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected