4#include <wx/stattext.h>
7#include <wx/textctrl.h>
8#include <wx/radiobut.h>
9#include <wx/wupdlock.h>
23#if wxUSE_ACCESSIBILITY
67 CustomSampleRateID = wxID_HIGHEST
71 :
wxDialogWrapper(parent, wxID_ANY,
XO(
"Custom Sample Rate"), wxDefaultPosition, {-1, 160})
72 , mSampleRate(defaultSampleRate)
76 S.StartHorizontalLay(wxEXPAND);
78 S.StartMultiColumn(2, wxALIGN_CENTER_VERTICAL);
80 S.Id(CustomSampleRateID).AddNumericTextBox(
XO(
"New sample rate (Hz):"), wxString::Format(
"%d", mSampleRate), 0);
86 S.AddStandardButtons();
99 if(event.GetString().ToLong(&rate))
100 mSampleRate =
static_cast<int>(rate);
113 EVT_TEXT(CustomSampleRateID, CustomSampleRateDialog::OnSampleRateChange)
136 , mMonoStereoMode(monoStereoMode)
140 PopulateOrExchange(
S);
152 auto formatInfo = plugin->GetFormatInfo(formatIndex);
153 formats.push_back(formatInfo.description);
158 S.StartMultiColumn(3, wxEXPAND);
166 mFolder =
S.AddTextBox(
XO(
"Fo&lder:"), {}, 0);
175 S.StartStatic(
XO(
"Audio options"));
179 if(
auto prompt =
S.AddPrompt(
XO(
"Channels")))
180 prompt->SetMinSize({140, -1});
182 S.StartHorizontalLay(wxALIGN_LEFT);
186 const int channels = 2;
196 .Name(
XO(
"Configure custom mapping"))
197 .AddButton(
XO(
"Configure"));
198#if wxUSE_ACCESSIBILITY
203 S.EndHorizontalLay();
207 if(
auto prompt =
S.AddPrompt(
XO(
"Sample &Rate")))
208 prompt->SetMinSize({140, -1});
210 S.StartHorizontalLay(wxALIGN_LEFT);
214 S.EndHorizontalLay();
234 mFolder->SetValue(filename.GetPath());
235 mFullName->SetValue(filename.GetFullName());
238 auto selectedFormatIndex = 0;
244 if(plugin->GetFormatInfo(formatIndex).format.IsSameAs(
format))
246 selectedFormatIndex = counter;
253 if(mixerSpec !=
nullptr)
261 int numChannels = channels;
265 const auto waveTracks =
269 for(
const auto track : waveTracks)
279 mMono->SetValue(
true);
284 mFormat->SetSelection(selectedFormatIndex);
288 if(!parameters.empty())
312 mMono->SetValue(
true);
354 return mMono->GetValue() ? 1 : 2;
368 if(formatInfo.extensions.empty())
372 filename.SetFullName(
mFullName->GetValue());
375 auto desiredExt = filename.GetExt().Trim().Trim(
false);
377 auto it = std::find_if(
378 formatInfo.extensions.begin(),
379 formatInfo.extensions.end(),
382 [&](
const auto& ext) { return desiredExt.IsSameAs(ext, false); });
384 if(it == formatInfo.extensions.end())
385 it = formatInfo.extensions.begin();
387 if(!it->empty() && !it->IsSameAs(filename.GetExt()))
389 filename.SetExt(*it);
390 mFullName->SetValue(filename.GetFullName());
412 const auto clientData =
event.GetClientData();
413 if(clientData ==
nullptr)
416 if(dialog.ShowModal() == wxID_OK &&
417 dialog.GetSampleRate() > 0)
424 mSampleRate = *
reinterpret_cast<const int*
>(&clientData);
433 const auto formatInfo = plugin->GetFormatInfo(formatIndex);
434 fileTypes.emplace_back(formatInfo.description, formatInfo.extensions);
436 wxFileDialog fd(
this,
_(
"Choose a location to save the exported files"),
441 fd.SetFilterIndex(
mFormat->GetSelection());
443 if(fd.ShowModal() == wxID_OK)
445 wxFileName filepath (fd.GetPath());
446 mFolder->SetValue(filepath.GetPath());
447 mFullName->SetValue(filepath.GetFullName());
448 const auto selectedFormat = fd.GetFilterIndex();
449 if(selectedFormat !=
mFormat->GetSelection())
451 mFormat->SetSelection(selectedFormat);
469 auto mixerSpec = std::make_unique<MixerOptions::Downmix>(*
mMixerSpec);
475 XO(
"Advanced Mixing Options"));
476 if(md.ShowModal() == wxID_OK)
487 auto formatCounter = 0;
491 if(formatCounter != index)
502 auto formatInfo = plugin->GetFormatInfo(formatIndex);
509 mOptionsHandler = std::make_unique<ExportOptionsHandler>(
S, *plugin, formatIndex);
518 wxPostEvent(GetParent(), wxCommandEvent { AUDACITY_EXPORT_FORMAT_CHANGE_EVENT, GetId() });
546 filename.SetFullName(
mFullName->GetValue());
547 filename.SetExt(ext.BeforeFirst(
' ').Lower());
548 mFullName->SetValue(filename.GetFullName());
554 if(maxChannels < 2 && mStereo->GetValue())
555 mMono->SetValue(
true);
556 mStereo->Enable(maxChannels > 1);
559 const auto mixerMaxChannels = std::clamp(
572 mMixerSpec = std::make_unique<MixerOptions::Downmix>(
573 waveTracks.sum([](
const auto track) { return track->NChannels(); }),
582 std::sort(availableRates.begin(), availableRates.end());
584 const auto* rates = availableRates.empty() ? &
DefaultRates : &availableRates;
590 int selectedItemIndex = 0;
594 int preferredRate = rates->back();
595 int preferredItemIndex = rates->size() - 1;
596 for(
auto rate : *rates)
598 *
reinterpret_cast<int*
>(&clientData) = rate;
599 const auto itemIndex =
601 XO(
"%d Hz").Format(rate).Translation(),
606 selectedItemIndex = itemIndex;
610 preferredItemIndex = itemIndex;
611 preferredRate = rate;
619 *
reinterpret_cast<int*
>(&clientData) = customRate;
622 XO(
"%d Hz (custom)").Format(customRate).Translation(),
627 else if(customRate != 0)
629 auto selectedRate = (*rates)[preferredItemIndex];
631 selectedItemIndex = preferredItemIndex;
633 mRates->SetSelection(selectedItemIndex);
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
wxDEFINE_EVENT(AUDACITY_EXPORT_FORMAT_CHANGE_EVENT, wxCommandEvent)
an object holding per-project preferred sample rate
std::vector< TranslatableString > TranslatableStrings
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
const ExportPlugin * GetPlugin() const
std::unique_ptr< MixerOptions::Downmix > mMixerSpec
void UpdateSampleRateList()
void OnFullNameFocusKill(wxFocusEvent &event)
std::unique_ptr< ExportOptionsHandler > mOptionsHandler
void OnSampleRateChange(wxCommandEvent &event)
const ExportPlugin * mSelectedPlugin
int GetSampleRate() const
~ExportFilePanel() override
AudacityProject & mProject
void SetCustomMappingEnabled(bool enabled)
static constexpr auto MaxExportChannels
MixerOptions::Downmix * GetMixerSpec() const
void ChangeFormat(int index)
void OnFormatChange(wxCommandEvent &event)
wxWindow * mAudioOptionsPanel
wxRadioButton * mCustomMapping
void OnFolderBrowse(wxCommandEvent &event)
void OnChannelsConfigure(wxCommandEvent &event)
ExportProcessor::Parameters GetParameters() const
void OnOptionsHandlerEvent(const ExportOptionsHandlerEvent &e)
Observer::Subscription mOptionsChangeSubscription
void UpdateMaxChannels(unsigned maxChannels)
void Init(const wxFileName &filename, int sampleRate, const wxString &format=wxEmptyString, int channels=0, const ExportProcessor::Parameters ¶meters={}, const MixerOptions::Downmix *mixerSpec=nullptr)
Initializes panel with export settings provided as arguments. Call is required.
void PopulateOrExchange(ShuttleGui &S)
void UpdateFileNameExt(const wxString &ext)
void OnChannelsChange(wxCommandEvent &event)
wxButton * mCustomizeChannels
Dialog for advanced mixing.
std::vector< int > SampleRateList
virtual FormatInfo GetFormatInfo(int index) const =0
Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn'...
static ExportPluginRegistry & Get()
std::vector< std::tuple< ExportOptionID, ExportValue > > Parameters
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
std::vector< FileType > FileTypes
A matrix of booleans, one row per input channel, column per output.
void Reset() noexcept
Breaks the connection (constant time)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
auto Any() -> TrackIterRange< TrackType >
static TrackList & Get(AudacityProject &project)
A Track that contains audio waveform data.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
int GetSampleRate() const noexcept
CustomSampleRateDialog(wxWindow *parent, int defaultSampleRate=44100)
void OnSampleRateChange(wxCommandEvent &event)
FILES_API wxString FormatWildcard(const FileTypes &fileTypes)
constexpr auto sampleRate
@ AudioChannelsConfigureID
const ExportOptionsEditor::SampleRateList DefaultRates
enum ExportOptionsHandlerEvent::@43 type