intelligent Noise & Silence dialogues
Posted: Wed Oct 09, 2013 4:12 am
All the other built-in generators are well behaved and honor the user's Selection Format but these two always default to Seconds (when no selection has been made i.e. inserting) which I find annoying. It is only a couple of lines of code in three files. In srcTimeDialog.cpp:
near the very top add one additional include to pick up Preferences:
In the function void TimeDialog::PopulateOrExchange(ShuttleGui &S) around line 63 comment out one line and add one line:
In srceffectsNoise.cpp in the function void NoiseDialog::PopulateOrExchange( ShuttleGui & S ) at or near line 222 add two lines and comment out one:
In srceffectsSilence.cpp:
near the very top add one additional include to pick up Preferences:
In the function bool EffectSilence::PromptUser() at or near line 41 comments out two lines:
Of course each place I have commented out an original line in production code these lines would just be eliminated; likewise the trailing comments://comment out… &//Add this… would be removed.
With even a cursory examination of Noise.cpp and Silence.cpp one can see that, although these two dialogues are virtually identical, the code implementing each is quite different. From what I understand the Developers would like to re-factor this code to get rid of all the duplicated functionality and make source code uniform. My understanding is that this is why they have not bothered to make this change yet. My contention is that we might as well make these little tiny changes now so that users are accommodated and when the Developers get around to modifying the code the improvements will already be there to be picked up regardless of which method is chosen. Although the Silence Dialog's solution is more elegant I have not examined all the code from both dialogues to see which would be best to use to represent both Silence and Noise as a dialog.
near the very top add one additional include to pick up Preferences:
Code: Select all
#include "Audacity.h"
#include "../Prefs.h"//add this line
#include <wx/defs.h>Code: Select all
//mTimeCtrl->SetFormatString(mTimeCtrl->GetBuiltinFormat(mFormat));//comment out
mFormat = gPrefs->Read(wxT("/SelectionFormat"), _("Seconds"));//add this lineCode: Select all
mNoiseDurationT->SetName(_("Duration"));
wxString formatSelection = gPrefs->Read(wxT("/SelectionFormat"), _("Seconds"));//add this line
mNoiseDurationT->SetFormatString(mNoiseDurationT->GetBuiltinFormat(formatSelection));//add this line
//mNoiseDurationT->SetFormatString(mNoiseDurationT->GetBuiltinFormat(nIsSelection==true?(_("hh:mm:ss + samples")):(_("seconds"))));near the very top add one additional include to pick up Preferences:
Code: Select all
#include "Audacity.h"
#include "../Prefs.h"//add this line
#include <wx/defs.h>Code: Select all
mDuration = mT1 - mT0;
//dlog.SetFormatString(_("hh:mm:ss + samples"));//comment out this line
} else {
// Retrieve last used values
gPrefs->Read(wxT("/Effects/SilenceGen/Duration"), &mDuration, 30L);
//dlog.SetFormatString(_("seconds"));//comment out this line
}
dlog.SetTimeValue(mDuration);With even a cursory examination of Noise.cpp and Silence.cpp one can see that, although these two dialogues are virtually identical, the code implementing each is quite different. From what I understand the Developers would like to re-factor this code to get rid of all the duplicated functionality and make source code uniform. My understanding is that this is why they have not bothered to make this change yet. My contention is that we might as well make these little tiny changes now so that users are accommodated and when the Developers get around to modifying the code the improvements will already be there to be picked up regardless of which method is chosen. Although the Silence Dialog's solution is more elegant I have not examined all the code from both dialogues to see which would be best to use to represent both Silence and Noise as a dialog.