Browse Source

Remove AILA

Removes Experimental automated input level adjustment.
It uses PortMixer (hardware level adjustments) to try to adjust the input
level, which is a flawed concept. It also relies on PortMixer which is no
longer supported.

Signed-off-by: akleja <storspov@gmail.com>
pull/559/head
akleja 10 months ago
committed by Panagiotis Vasilopoulos
parent
commit
35d059c965
No known key found for this signature in database GPG Key ID: FD806FDB3B2C5270
  1. 182
      src/AudioIO.cpp
  2. 25
      src/AudioIO.h
  3. 9
      src/ProjectAudioManager.cpp
  4. 23
      src/menus/TransportMenus.cpp
  5. 63
      src/prefs/RecordingPrefs.cpp
  6. 7
      src/prefs/RecordingPrefs.h
  7. 21
      src/widgets/Meter.cpp

182
src/AudioIO.cpp

@ -491,11 +491,6 @@ time warp info and AudioIOListener and whether the playback is looped.
#include "NoteTrack.h"
#endif
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
#define LOWER_BOUND 0.0
#define UPPER_BOUND 1.0
#endif
using std::max;
using std::min;
@ -983,9 +978,6 @@ AudioIO::AudioIO()
mNumPauseFrames = 0;
#endif
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
mAILAActive = false;
#endif
mStreamToken = 0;
mLastPaError = paNoError;
@ -1541,10 +1533,6 @@ int AudioIO::StartStream(const TransportTracks &tracks,
}
}
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
AILASetStartTime();
#endif
if (options.pStartTime)
{
// Calculate the NEW time position
@ -3275,176 +3263,6 @@ void AudioIoCallback::AllNotesOff(bool looping)
#endif
// Automated Input Level Adjustment - Automatically tries to find an acceptable input volume
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
#include "ProjectStatus.h"
void AudioIO::AILAInitialize() {
gPrefs->Read(wxT("/AudioIO/AutomatedInputLevelAdjustment"), &mAILAActive, false);
gPrefs->Read(wxT("/AudioIO/TargetPeak"), &mAILAGoalPoint, AILA_DEF_TARGET_PEAK);
gPrefs->Read(wxT("/AudioIO/DeltaPeakVolume"), &mAILAGoalDelta, AILA_DEF_DELTA_PEAK);
gPrefs->Read(wxT("/AudioIO/AnalysisTime"), &mAILAAnalysisTime, AILA_DEF_ANALYSIS_TIME);
gPrefs->Read(wxT("/AudioIO/NumberAnalysis"), &mAILATotalAnalysis, AILA_DEF_NUMBER_ANALYSIS);
mAILAGoalDelta /= 100.0;
mAILAGoalPoint /= 100.0;
mAILAAnalysisTime /= 1000.0;
mAILAMax = 0.0;
mAILALastStartTime = max(0.0, mPlaybackSchedule.mT0);
mAILAClipped = false;
mAILAAnalysisCounter = 0;
mAILAChangeFactor = 1.0;
mAILALastChangeType = 0;
mAILATopLevel = 1.0;
mAILAAnalysisEndTime = -1.0;
}
void AudioIO::AILADisable() {
mAILAActive = false;
}
bool AudioIO::AILAIsActive() {
return mAILAActive;
}
void AudioIO::AILASetStartTime() {
mAILAAbsolutStartTime = Pa_GetStreamTime(mPortStreamV19);
wxPrintf("START TIME %f\n\n", mAILAAbsolutStartTime);
}
double AudioIO::AILAGetLastDecisionTime() {
return mAILAAnalysisEndTime;
}
void AudioIO::AILAProcess(double maxPeak) {
AudacityProject *const proj = mOwningProject;
if (proj && mAILAActive) {
if (mInputMeter && mInputMeter->IsClipping()) {
mAILAClipped = true;
wxPrintf("clipped");
}
mAILAMax = max(mAILAMax, maxPeak);
if ((mAILATotalAnalysis == 0 || mAILAAnalysisCounter < mAILATotalAnalysis) && mPlaybackSchedule.GetTrackTime() - mAILALastStartTime >= mAILAAnalysisTime) {
auto ToLinearIfDB = [](double value, int dbRange) {
if (dbRange >= 0)
value = pow(10.0, (-(1.0-value) * dbRange)/20.0);
return value;
};
putchar('\n');
mAILAMax = mInputMeter ? ToLinearIfDB(mAILAMax, mInputMeter->GetDBRange()) : 0.0;
double iv = (double) Px_GetInputVolume(mPortMixer);
unsigned short changetype = 0; //0 - no change, 1 - increase change, 2 - decrease change
wxPrintf("mAILAAnalysisCounter:%d\n", mAILAAnalysisCounter);
wxPrintf("\tmAILAClipped:%d\n", mAILAClipped);
wxPrintf("\tmAILAMax (linear):%f\n", mAILAMax);
wxPrintf("\tmAILAGoalPoint:%f\n", mAILAGoalPoint);
wxPrintf("\tmAILAGoalDelta:%f\n", mAILAGoalDelta);
wxPrintf("\tiv:%f\n", iv);
wxPrintf("\tmAILAChangeFactor:%f\n", mAILAChangeFactor);
if (mAILAClipped || mAILAMax > mAILAGoalPoint + mAILAGoalDelta) {
wxPrintf("too high:\n");
mAILATopLevel = min(mAILATopLevel, iv);
wxPrintf("\tmAILATopLevel:%f\n", mAILATopLevel);
//if clipped or too high
if (iv <= LOWER_BOUND) {
//we can't improve it more now
if (mAILATotalAnalysis != 0) {
mAILAActive = false;
ProjectStatus::Get( *proj ).Set(
XO(
"Automated Recording Level Adjustment stopped. It was not possible to optimize it more. Still too high.") );
}
wxPrintf("\talready min vol:%f\n", iv);
}
else {
float vol = (float) max(LOWER_BOUND, iv+(mAILAGoalPoint-mAILAMax)*mAILAChangeFactor);
Px_SetInputVolume(mPortMixer, vol);
auto msg = XO(
"Automated Recording Level Adjustment decreased the volume to %f.").Format( vol );
ProjectStatus::Get( *proj ).Set(msg);
changetype = 1;
wxPrintf("\tnew vol:%f\n", vol);
float check = Px_GetInputVolume(mPortMixer);
wxPrintf("\tverified %f\n", check);
}
}
else if ( mAILAMax < mAILAGoalPoint - mAILAGoalDelta ) {
//if too low
wxPrintf("too low:\n");
if (iv >= UPPER_BOUND || iv + 0.005 > mAILATopLevel) { //condition for too low volumes and/or variable volumes that cause mAILATopLevel to decrease too much
//we can't improve it more
if (mAILATotalAnalysis != 0) {
mAILAActive = false;
ProjectStatus::Get( *proj ).Set(
XO(
"Automated Recording Level Adjustment stopped. It was not possible to optimize it more. Still too low.") );
}
wxPrintf("\talready max vol:%f\n", iv);
}
else {
float vol = (float) min(UPPER_BOUND, iv+(mAILAGoalPoint-mAILAMax)*mAILAChangeFactor);
if (vol > mAILATopLevel) {
vol = (iv + mAILATopLevel)/2.0;
wxPrintf("\tTruncated vol:%f\n", vol);
}
Px_SetInputVolume(mPortMixer, vol);
auto msg = XO(
"Automated Recording Level Adjustment increased the volume to %.2f.")
.Format( vol );
ProjectStatus::Get( *proj ).Set(msg);
changetype = 2;
wxPrintf("\tnew vol:%f\n", vol);
float check = Px_GetInputVolume(mPortMixer);
wxPrintf("\tverified %f\n", check);
}
}
mAILAAnalysisCounter++;
//const PaStreamInfo* info = Pa_GetStreamInfo(mPortStreamV19);
//double latency = 0.0;
//if (info)
// latency = info->inputLatency;
//mAILAAnalysisEndTime = mTime+latency;
mAILAAnalysisEndTime = Pa_GetStreamTime(mPortStreamV19) - mAILAAbsolutStartTime;
mAILAMax = 0;
wxPrintf("\tA decision was made @ %f\n", mAILAAnalysisEndTime);
mAILAClipped = false;
mAILALastStartTime = mPlaybackSchedule.GetTrackTime();
if (changetype == 0)
mAILAChangeFactor *= 0.8; //time factor
else if (mAILALastChangeType == changetype)
mAILAChangeFactor *= 1.1; //concordance factor
else
mAILAChangeFactor *= 0.7; //discordance factor
mAILALastChangeType = changetype;
putchar('\n');
}
if (mAILAActive && mAILATotalAnalysis != 0 && mAILAAnalysisCounter >= mAILATotalAnalysis) {
mAILAActive = false;
if (mAILAMax > mAILAGoalPoint + mAILAGoalDelta)
ProjectStatus::Get( *proj ).Set(
XO(
"Automated Recording Level Adjustment stopped. The total number of analyses has been exceeded without finding an acceptable volume. Still too high.") );
else if (mAILAMax < mAILAGoalPoint - mAILAGoalDelta)
ProjectStatus::Get( *proj ).Set(
XO(
"Automated Recording Level Adjustment stopped. The total number of analyses has been exceeded without finding an acceptable volume. Still too low.") );
else {
auto msg = XO(
"Automated Recording Level Adjustment stopped. %.2f seems an acceptable volume.")
.Format( Px_GetInputVolume(mPortMixer) );
ProjectStatus::Get( *proj ).Set(msg);
}
}
}
}
#endif
//////////////////////////////////////////////////////////////////////
//
// PortAudio callback thread context

25
src/AudioIO.h

@ -428,23 +428,6 @@ public:
NoteTrackConstArray mMidiPlaybackTracks;
#endif
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
bool mAILAActive;
bool mAILAClipped;
int mAILATotalAnalysis;
int mAILAAnalysisCounter;
double mAILAMax;
double mAILAGoalPoint;
double mAILAGoalDelta;
double mAILAAnalysisTime;
double mAILALastStartTime;
double mAILAChangeFactor;
double mAILATopLevel;
double mAILAAnalysisEndTime;
double mAILAAbsolutStartTime;
unsigned short mAILALastChangeType; //0 - no change, 1 - increase change, 2 - decrease change
#endif
std::unique_ptr<AudioThread> mThread;
#ifdef EXPERIMENTAL_MIDI_OUT
#ifdef USE_MIDI_THREAD
@ -661,14 +644,6 @@ public:
/** \brief Function to automatically set an acceptable volume
*
*/
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
void AILAInitialize();
void AILADisable();
bool AILAIsActive();
void AILAProcess(double maxPeak);
void AILASetStartTime();
double AILAGetLastDecisionTime();
#endif
bool IsAvailable(AudacityProject *projecT) const;

9
src/ProjectAudioManager.cpp

@ -341,10 +341,6 @@ void ProjectAudioManager::Stop(bool stopStream /* = true*/)
projectAudioManager.SetLooping( false );
projectAudioManager.SetCutting( false );
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
gAudioIO->AILADisable();
#endif
projectAudioManager.SetPaused( false );
//Make sure you tell gAudioIO to unpause
gAudioIO->SetPaused( false );
@ -733,11 +729,6 @@ bool ProjectAudioManager::DoRecord(AudacityProject &project,
TrackList::Get(*p).back()->EnsureVisible();
}
//Automated Input Level Adjustment Initialization
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
gAudioIO->AILAInitialize();
#endif
int token = gAudioIO->StartStream(transportTracks, t0, t1, options);
success = (token != 0);

23
src/menus/TransportMenus.cpp

@ -700,19 +700,6 @@ void OnToggleSWPlaythrough(const CommandContext &WXUNUSED(context) )
MenuManager::ModifyAllProjectToolbarMenus();
}
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
void OnToggleAutomatedInputLevelAdjustment(
const CommandContext &WXUNUSED(context) )
{
bool AVEnabled;
gPrefs->Read(
wxT("/AudioIO/AutomatedInputLevelAdjustment"), &AVEnabled, false);
gPrefs->Write(wxT("/AudioIO/AutomatedInputLevelAdjustment"), !AVEnabled);
gPrefs->Flush();
MenuManager::ModifyAllProjectToolbarMenus();
}
#endif
void OnStop(const CommandContext &context)
{
ProjectAudioManager::Get( context.project ).Stop();
@ -1164,16 +1151,6 @@ BaseItemSharedPtr TransportMenu()
AudioIONotBusyFlag() | CanStopAudioStreamFlag(),
Options{}.CheckTest( wxT("/AudioIO/SWPlaythrough"), false ) )
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
,
Command( wxT("AutomatedInputLevelAdjustmentOnOff"),
XXO("A&utomated Recording Level Adjustment (on/off)"),
FN(OnToggleAutomatedInputLevelAdjustment),
AudioIONotBusyFlag() | CanStopAudioStreamFlag(),
Options{}.CheckTest(
wxT("/AudioIO/AutomatedInputLevelAdjustment"), false ) )
#endif
)
)
)

63
src/prefs/RecordingPrefs.cpp

@ -190,51 +190,6 @@ void RecordingPrefs::PopulateOrExchange(ShuttleGui & S)
}
S.EndStatic();
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
S.StartStatic(XO("Automated Recording Level Adjustment"));
{
S.TieCheckBox(XXO("Enable Automated Recording Level Adjustment."),
{wxT("/AudioIO/AutomatedInputLevelAdjustment"),
false});
S.StartMultiColumn(2, wxEXPAND);
{
S.SetStretchyCol(1);
/* i18n-hint: Desired maximum (peak) volume for sound */
S.TieSlider(XXO("Target Peak:"),
{wxT("/AudioIO/TargetPeak"),
AILA_DEF_TARGET_PEAK},
100,
0);
S.TieSlider(XXO("Within:"),
{wxT("/AudioIO/DeltaPeakVolume"),
AILA_DEF_DELTA_PEAK},
100,
0);
}
S.EndMultiColumn();
S.StartThreeColumn();
{
S.TieIntegerTextBox(XXO("Analysis Time:"),
{wxT("/AudioIO/AnalysisTime"),
AILA_DEF_ANALYSIS_TIME},
9);
S.AddUnits(XO("milliseconds (time of one analysis)"));
S.TieIntegerTextBox(XXO("Number of consecutive analysis:"),
{wxT("/AudioIO/NumberAnalysis"),
AILA_DEF_NUMBER_ANALYSIS},
2);
S.AddUnits(XO("0 means endless"));
}
S.EndThreeColumn();
}
S.EndStatic();
#endif
#ifdef EXPERIMENTAL_PUNCH_AND_ROLL
S.StartStatic(XO("Punch and Roll Recording"));
{
@ -273,24 +228,6 @@ bool RecordingPrefs::Commit()
if (AudioIOLatencyDuration.Read() < 0)
AudioIOLatencyDuration.Reset();
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
double targetpeak, deltapeak;
gPrefs->Read(wxT("/AudioIO/TargetPeak"), &targetpeak);
gPrefs->Read(wxT("/AudioIO/DeltaPeakVolume"), &deltapeak);
if (targetpeak + deltapeak > 100.0 || targetpeak - deltapeak < 0.0)
{
gPrefs->Write(wxT("/AudioIO/DeltaPeakVolume"), min(100.0 - targetpeak, targetpeak));
}
int value;
gPrefs->Read(wxT("/AudioIO/AnalysisTime"), &value);
if (value <= 0)
gPrefs->Write(wxT("/AudioIO/AnalysisTime"), AILA_DEF_ANALYSIS_TIME);
gPrefs->Read(wxT("/AudioIO/NumberAnalysis"), &value);
if (value < 0)
gPrefs->Write(wxT("/AudioIO/NumberAnalysis"), AILA_DEF_NUMBER_ANALYSIS);
#endif
return true;
}

7
src/prefs/RecordingPrefs.h

@ -21,13 +21,6 @@
class wxTextCtrl;
class ShuttleGui;
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
#define AILA_DEF_TARGET_PEAK 92
#define AILA_DEF_DELTA_PEAK 2
#define AILA_DEF_ANALYSIS_TIME 1000
#define AILA_DEF_NUMBER_ANALYSIS 5
#endif
#define RECORDING_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ \
L"Recording", \
XO("Recording") /* XC("Recording", "preference") */ \

21
src/widgets/Meter.cpp

@ -1081,10 +1081,6 @@ void MeterPanel::OnMeterUpdate(wxTimerEvent & WXUNUSED(event))
{
MeterUpdateMsg msg;
int numChanges = 0;
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
double maxPeak = 0.0;
bool discarded = false;
#endif
// We shouldn't receive any events if the meter is disabled, but clear it to be safe
if (mMeterDisabled) {
@ -1150,27 +1146,10 @@ void MeterPanel::OnMeterUpdate(wxTimerEvent & WXUNUSED(event))
}
mBar[j].tailPeakCount = msg.tailPeakCount[j];
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
if (mT > gAudioIO->AILAGetLastDecisionTime()) {
discarded = false;
maxPeak = msg.peak[j] > maxPeak ? msg.peak[j] : maxPeak;
wxPrintf("%f@%f ", msg.peak[j], mT);
}
else {
discarded = true;
wxPrintf("%f@%f discarded\n", msg.peak[j], mT);
}
#endif
}
} // while
if (numChanges > 0) {
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
if (gAudioIO->AILAIsActive() && mIsInput && !discarded) {
gAudioIO->AILAProcess(maxPeak);
putchar('\n');
}
#endif
RepaintBarsNow();
}
}

Loading…
Cancel
Save