2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
Silence.cpp
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class EffectSilence
|
|
|
|
\brief An Effect for the "Generator" menu to add silence.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "../Audacity.h"
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
#include <wx/defs.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/textctrl.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "Silence.h"
|
|
|
|
#include "../WaveTrack.h"
|
|
|
|
#include "../TimeDialog.h"
|
2011-12-20 00:05:54 +00:00
|
|
|
#include "../Prefs.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
bool EffectSilence::PromptUser()
|
|
|
|
{
|
2012-10-11 01:45:33 +00:00
|
|
|
wxString fmt;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
if (mT1 > mT0) {
|
|
|
|
// there is a selection: let's fit in there...
|
|
|
|
mDuration = mT1 - mT0;
|
2012-10-11 01:45:33 +00:00
|
|
|
fmt = _("hh:mm:ss + samples");
|
2010-01-23 19:44:49 +00:00
|
|
|
} else {
|
2011-12-20 00:05:54 +00:00
|
|
|
// Retrieve last used values
|
|
|
|
gPrefs->Read(wxT("/Effects/SilenceGen/Duration"), &mDuration, 30L);
|
2012-10-11 01:45:33 +00:00
|
|
|
fmt = _("hh:mm:ss + milliseconds");
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
2012-10-11 01:45:33 +00:00
|
|
|
|
|
|
|
TimeDialog dlog(mParent, _("Silence Generator"), fmt, mProjectRate,
|
|
|
|
mDuration );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
if (dlog.ShowModal() == wxID_CANCEL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
mDuration = dlog.GetTimeValue();
|
2011-12-20 00:05:54 +00:00
|
|
|
/* Save last used values.
|
|
|
|
Save duration unless value was got from selection, so we save only
|
|
|
|
when user explicitly set up a value */
|
|
|
|
if (mT1 == mT0)
|
2012-08-02 06:03:19 +00:00
|
|
|
{
|
2011-12-20 00:05:54 +00:00
|
|
|
gPrefs->Write(wxT("/Effects/SilenceGen/Duration"), mDuration);
|
2012-08-02 06:03:19 +00:00
|
|
|
gPrefs->Flush();
|
|
|
|
}
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectSilence::GenerateTrack(WaveTrack *tmp,
|
2013-08-25 21:51:26 +00:00
|
|
|
const WaveTrack & WXUNUSED(track),
|
|
|
|
int WXUNUSED(ntrack))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2011-11-16 05:59:48 +00:00
|
|
|
const bool bResult = tmp->InsertSilence(0.0, mDuration);
|
|
|
|
wxASSERT(bResult);
|
|
|
|
return bResult;
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|