Page 1 of 1

intelligent Noise & Silence dialogues

Posted: Wed Oct 09, 2013 4:12 am
by Edgar
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:

Code: Select all

#include "Audacity.h"
#include "../Prefs.h"//add this line

#include <wx/defs.h>
In the function void TimeDialog::PopulateOrExchange(ShuttleGui &S) around line 63 comment out one line and add one line:

Code: Select all

//mTimeCtrl->SetFormatString(mTimeCtrl->GetBuiltinFormat(mFormat));//comment out
mFormat = gPrefs->Read(wxT("/SelectionFormat"), _("Seconds"));//add this line
In srceffectsNoise.cpp in the function void NoiseDialog::PopulateOrExchange( ShuttleGui & S ) at or near line 222 add two lines and comment out one:

Code: 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"))));
In srceffectsSilence.cpp:
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>
In the function bool EffectSilence::PromptUser() at or near line 41 comments out two lines:

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);
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.

Re: intelligent Noise & Silence dialogues

Posted: Wed Oct 09, 2013 4:32 am
by steve
Edgar wrote:All the other built-in generators are well behaved and honor the user's Selection Format
ALL of the generators seem to show hh:mm:ss+samples when inserting into a selection, and hh:mm:ss+milliseconds when inserting at a point. :?

Re: intelligent Noise & Silence dialogues

Posted: Wed Oct 09, 2013 7:28 am
by Edgar
steve wrote:
Edgar wrote:All the other built-in generators are well behaved and honor the user's Selection Format
ALL of the generators seem to show hh:mm:ss+samples when inserting into a selection, and hh:mm:ss+milliseconds when inserting at a point. :?
Yep, I made a mistake there because my preferred Selection Format is hh:mm:ss+milliseconds and I never insert into a selection. I went back and "fixed" the other "three" (in reality Chirp and Tone are the same effect so it's really "two").

The changes to these two are identical to the changes for Noise.

Re: intelligent Noise & Silence dialogues

Posted: Tue Nov 12, 2013 3:31 am
by Gale Andrews
Edgar wrote: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.
Bug 547 http://bugzilla.audacityteam.org/show_bug.cgi?id=547 is intending to fix this issue by defaulting point generation to "last used" selection format in accordance with majority user wishes. Would that do for you? If not, have you had your vote counted that point generation should respect selection format? (Not that I think it will change the fix).


Gale