Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ExportFilePanel Class Referencefinal

#include <ExportFilePanel.h>

Inheritance diagram for ExportFilePanel:
[legend]
Collaboration diagram for ExportFilePanel:
[legend]

Public Member Functions

 ExportFilePanel (AudacityProject &project, bool monoStereoMode=false, wxWindow *parent=nullptr, wxWindowID winid=wxID_ANY)
 
 ~ExportFilePanel () override
 
void PopulateOrExchange (ShuttleGui &S)
 
void Init (const wxFileName &filename, int sampleRate, const wxString &format=wxEmptyString, int channels=0, const ExportProcessor::Parameters &parameters={}, const MixerOptions::Downmix *mixerSpec=nullptr)
 Initializes panel with export settings provided as arguments. Call is required. More...
 
void SetInitialFocus ()
 
void SetCustomMappingEnabled (bool enabled)
 
wxString GetPath () const
 
wxString GetFullName ()
 
const ExportPluginGetPlugin () const
 
int GetFormat () const
 
int GetSampleRate () const
 
std::optional< ExportProcessor::ParametersGetParameters () const
 
int GetChannels () const
 
MixerOptions::DownmixGetMixerSpec () const
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void ValidateAndFixExt ()
 
void OnFullNameFocusKill (wxFocusEvent &event)
 
void OnFormatChange (wxCommandEvent &event)
 
void OnSampleRateChange (wxCommandEvent &event)
 
void OnFolderBrowse (wxCommandEvent &event)
 
void OnChannelsChange (wxCommandEvent &event)
 
void OnChannelsConfigure (wxCommandEvent &event)
 
void ChangeFormat (int index)
 
void OnOptionsHandlerEvent (const ExportOptionsHandlerEvent &e)
 
void UpdateSampleRateList ()
 
void UpdateMaxChannels (unsigned maxChannels)
 

Private Attributes

AudacityProjectmProject
 
bool mMonoStereoMode {false}
 
wxChoice * mFormat {}
 
wxChoice * mRates {}
 
wxWindow * mAudioOptionsPanel {}
 
wxTextCtrl * mFolder {}
 
wxTextCtrl * mFullName {}
 
wxRadioButton * mMono {}
 
wxRadioButton * mStereo {}
 
wxRadioButton * mCustomMapping {}
 
wxButton * mCustomizeChannels {}
 
int mSampleRate {}
 
const ExportPluginmSelectedPlugin {}
 
int mSelectedFormatIndex {}
 
std::unique_ptr< ExportOptionsHandlermOptionsHandler
 
std::unique_ptr< MixerOptions::DownmixmMixerSpec
 
Observer::Subscription mOptionsChangeSubscription
 

Static Private Attributes

static constexpr auto MaxExportChannels = 32u
 

Detailed Description

Definition at line 27 of file ExportFilePanel.h.

Constructor & Destructor Documentation

◆ ExportFilePanel()

ExportFilePanel::ExportFilePanel ( AudacityProject project,
bool  monoStereoMode = false,
wxWindow *  parent = nullptr,
wxWindowID  winid = wxID_ANY 
)

Definition at line 132 of file ExportFilePanel.cpp.

136 : wxPanelWrapper(parent, winid)
137 , mMonoStereoMode(monoStereoMode)
139{
140 ShuttleGui S(this, eIsCreating);
142}
@ eIsCreating
Definition: ShuttleGui.h:37
const auto project
#define S(N)
Definition: ToChars.cpp:64
AudacityProject & mProject
void PopulateOrExchange(ShuttleGui &S)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640

References eIsCreating, and S.

◆ ~ExportFilePanel()

ExportFilePanel::~ExportFilePanel ( )
overridedefault

Member Function Documentation

◆ ChangeFormat()

void ExportFilePanel::ChangeFormat ( int  index)
private

Definition at line 496 of file ExportFilePanel.cpp.

497{
498 mSelectedPlugin = nullptr;
499
500 wxWindowUpdateLocker wndupdlck(mAudioOptionsPanel);
501
502 auto formatCounter = 0;
503
504 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
505 {
506 if(formatCounter != index)
507 {
508 ++formatCounter;
509 continue;
510 }
511
513
514 mSelectedPlugin = plugin;
515 mSelectedFormatIndex = formatIndex;
516
518
519 mAudioOptionsPanel->SetSizer(nullptr);
520 mAudioOptionsPanel->DestroyChildren();
521
523 mOptionsHandler = std::make_unique<ExportOptionsHandler>(S, *plugin, formatIndex);
525
526 const auto formatInfo = plugin->GetFormatInfo(formatIndex);
527 UpdateMaxChannels(formatInfo.maxChannels);
528
530
531 mAudioOptionsPanel->Layout();
532
533 wxPostEvent(GetParent(), wxCommandEvent { AUDACITY_EXPORT_FORMAT_CHANGE_EVENT, GetId() });
534
535 return;
536 }
537}
std::unique_ptr< ExportOptionsHandler > mOptionsHandler
const ExportPlugin * mSelectedPlugin
wxWindow * mAudioOptionsPanel
void OnOptionsHandlerEvent(const ExportOptionsHandlerEvent &e)
Observer::Subscription mOptionsChangeSubscription
void UpdateMaxChannels(unsigned maxChannels)
static ExportPluginRegistry & Get()
void Reset() noexcept
Breaks the connection (constant time)
Definition: Observer.cpp:101

References eIsCreating, ExportPluginRegistry::Get(), mAudioOptionsPanel, mOptionsChangeSubscription, mOptionsHandler, mSelectedFormatIndex, mSelectedPlugin, OnOptionsHandlerEvent(), Observer::Subscription::Reset(), S, UpdateMaxChannels(), UpdateSampleRateList(), and ValidateAndFixExt().

Referenced by Init(), OnFolderBrowse(), and OnFormatChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannels()

int ExportFilePanel::GetChannels ( ) const

Definition at line 352 of file ExportFilePanel.cpp.

353{
354 if(mCustomMapping != nullptr && mCustomMapping->GetValue())
355 return 0;
356 return mMono->GetValue() ? 1 : 2;
357}
wxRadioButton * mCustomMapping
wxRadioButton * mMono

References mCustomMapping, and mMono.

Referenced by ExportAudioDialog::OnExport(), TimerRecordExportDialog::OnOK(), ExportAudioDialog::UpdateLabelExportSettings(), and ExportAudioDialog::UpdateTrackExportSettings().

Here is the caller graph for this function:

◆ GetFormat()

int ExportFilePanel::GetFormat ( ) const

Definition at line 335 of file ExportFilePanel.cpp.

336{
338}

References mSelectedFormatIndex.

Referenced by ExportAudioDialog::OnExport(), ExportAudioDialog::OnFormatChange(), TimerRecordExportDialog::OnFormatChanged(), TimerRecordExportDialog::OnOK(), and ExportAudioDialog::UpdateExportSettings().

Here is the caller graph for this function:

◆ GetFullName()

wxString ExportFilePanel::GetFullName ( )

Definition at line 324 of file ExportFilePanel.cpp.

325{
327 return mFullName->GetValue();
328}
wxTextCtrl * mFullName

References mFullName, and ValidateAndFixExt().

Referenced by ExportAudioDialog::OnExport(), TimerRecordExportDialog::OnOK(), ExportAudioDialog::UpdateLabelExportSettings(), and ExportAudioDialog::UpdateTrackExportSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMixerSpec()

MixerOptions::Downmix * ExportFilePanel::GetMixerSpec ( ) const

Definition at line 359 of file ExportFilePanel.cpp.

360{
361 return mMixerSpec.get();
362}
std::unique_ptr< MixerOptions::Downmix > mMixerSpec

References mMixerSpec.

Referenced by ExportAudioDialog::OnExport().

Here is the caller graph for this function:

◆ GetParameters()

std::optional< ExportProcessor::Parameters > ExportFilePanel::GetParameters ( ) const
Returns
May return std::nullopt if plugin isn't properly configured

Definition at line 345 of file ExportFilePanel.cpp.

346{
347 if(mOptionsHandler->TransferDataFromEditor())
348 return { mOptionsHandler->GetParameters() };
349 return std::nullopt;
350}

References mOptionsHandler.

Referenced by ExportAudioDialog::OnExport(), and TimerRecordExportDialog::OnOK().

Here is the caller graph for this function:

◆ GetPath()

wxString ExportFilePanel::GetPath ( ) const

Definition at line 319 of file ExportFilePanel.cpp.

320{
321 return mFolder->GetValue();
322}
wxTextCtrl * mFolder

References mFolder.

Referenced by ExportAudioDialog::OnExport(), TimerRecordExportDialog::OnOK(), ExportAudioDialog::UpdateLabelExportSettings(), and ExportAudioDialog::UpdateTrackExportSettings().

Here is the caller graph for this function:

◆ GetPlugin()

const ExportPlugin * ExportFilePanel::GetPlugin ( ) const

Definition at line 330 of file ExportFilePanel.cpp.

331{
332 return mSelectedPlugin;
333}

References mSelectedPlugin.

Referenced by ExportAudioDialog::OnExport(), ExportAudioDialog::OnFormatChange(), TimerRecordExportDialog::OnFormatChanged(), TimerRecordExportDialog::OnOK(), and ExportAudioDialog::UpdateExportSettings().

Here is the caller graph for this function:

◆ GetSampleRate()

int ExportFilePanel::GetSampleRate ( ) const

Definition at line 340 of file ExportFilePanel.cpp.

341{
342 return mSampleRate;
343}

References mSampleRate.

Referenced by ExportAudioDialog::OnExport(), and TimerRecordExportDialog::OnOK().

Here is the caller graph for this function:

◆ Init()

void ExportFilePanel::Init ( const wxFileName &  filename,
int  sampleRate,
const wxString &  format = wxEmptyString,
int  channels = 0,
const ExportProcessor::Parameters parameters = {},
const MixerOptions::Downmix mixerSpec = nullptr 
)

Initializes panel with export settings provided as arguments. Call is required.

Parameters
filenameDefault output filename
sampleRateExport sample rate > 0
formatExport format string identifier (see FormatInfo::format)
channelsPass 0(default) to choose automatically depending on project tracks
parametersPass empty(default) array to initialize with plugin defaults
mixerSpecTry use custom channel mapping, channels argument will be igonred

Definition at line 228 of file ExportFilePanel.cpp.

234{
235 mFolder->SetValue(filename.GetPath());
236 mFullName->SetValue(filename.GetFullName());
238
239 auto selectedFormatIndex = 0;
240 if(!format.empty())
241 {
242 auto counter = 0;
243 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
244 {
245 if(plugin->GetFormatInfo(formatIndex).format.IsSameAs(format))
246 {
247 selectedFormatIndex = counter;
248 break;
249 }
250 ++counter;
251 }
252 }
253
254 if(mixerSpec != nullptr)
255 {
256 assert(!mMonoStereoMode);
257 *mMixerSpec = *mixerSpec;
258 mCustomMapping->SetValue(true);
259 }
260 else
261 {
262 int numChannels = channels;
263 if(numChannels == 0)
264 {
265 numChannels = 1;
266 const auto waveTracks =
269 false);
270 for(const auto track : waveTracks)
271 {
272 if(track->NChannels() >= 2 || track->GetPan() != .0f)
273 {
274 numChannels = 2;
275 break;
276 }
277 }
278 }
279 if(numChannels == 1)
280 mMono->SetValue(true);
281 else
282 mStereo->SetValue(true);
283 }
284
285 mFormat->SetSelection(selectedFormatIndex);
286
287 ChangeFormat(selectedFormatIndex);
288
289 if(!parameters.empty())
290 mOptionsHandler->SetParameters(parameters);
291
292 if(mCustomizeChannels != nullptr)
293 mCustomizeChannels->Enable(mCustomMapping->GetValue());
294}
wxChoice * mFormat
void ChangeFormat(int index)
wxRadioButton * mStereo
wxButton * mCustomizeChannels
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:23
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References ChangeFormat(), ExportUtils::FindExportWaveTracks(), anonymous_namespace{ExportPCM.cpp}::format, ExportPluginRegistry::Get(), TrackList::Get(), mCustomizeChannels, mCustomMapping, mFolder, mFormat, mFullName, mMixerSpec, mMono, mMonoStereoMode, mOptionsHandler, mProject, mSampleRate, mStereo, and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

Referenced by TimerRecordExportDialog::Bind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnChannelsChange()

void ExportFilePanel::OnChannelsChange ( wxCommandEvent &  event)
private

◆ OnChannelsConfigure()

void ExportFilePanel::OnChannelsConfigure ( wxCommandEvent &  event)
private

Definition at line 478 of file ExportFilePanel.cpp.

479{
480 //Configure for all tracks, but some channels may turn out to be silent
481 //if exported region does not contain audio samples
482 auto waveTracks = TrackList::Get(mProject).Any<const WaveTrack>();
483
484 auto mixerSpec = std::make_unique<MixerOptions::Downmix>(*mMixerSpec);
485
486 ExportMixerDialog md(waveTracks,
487 mixerSpec.get(),
488 nullptr,
489 1,
490 XO("Advanced Mixing Options"));
491 if(md.ShowModal() == wxID_OK)
492 mMixerSpec.swap(mixerSpec);
493}
XO("Cut/Copy/Paste")
Dialog for advanced mixing.
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

References TrackList::Any(), TrackList::Get(), mMixerSpec, mProject, and XO().

Here is the call graph for this function:

◆ OnFolderBrowse()

void ExportFilePanel::OnFolderBrowse ( wxCommandEvent &  event)
private

Definition at line 442 of file ExportFilePanel.cpp.

443{
444 FileNames::FileTypes fileTypes;
445
446 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
447 {
448 const auto formatInfo = plugin->GetFormatInfo(formatIndex);
449 fileTypes.emplace_back(formatInfo.description, formatInfo.extensions);
450 }
451 wxFileDialog fd(this, _("Choose a location to save the exported files"),
452 mFolder->GetValue(),
453 mFullName->GetValue(),
454 FileNames::FormatWildcard(fileTypes),
455 wxFD_SAVE);
456 fd.SetFilterIndex(mFormat->GetSelection());
457
458 if(fd.ShowModal() == wxID_OK)
459 {
460 wxFileName filepath (fd.GetPath());
461 mFolder->SetValue(filepath.GetPath());
462 mFullName->SetValue(filepath.GetFullName());
463 const auto selectedFormat = fd.GetFilterIndex();
464 if(selectedFormat != mFormat->GetSelection())
465 {
466 mFormat->SetSelection(selectedFormat);
467 ChangeFormat(selectedFormat);
468 }
469 }
470}
#define _(s)
Definition: Internat.h:73
std::vector< FileType > FileTypes
Definition: FileNames.h:75
FILES_API wxString FormatWildcard(const FileTypes &fileTypes)

References _, ChangeFormat(), FileNames::FormatWildcard(), ExportPluginRegistry::Get(), mFolder, mFormat, and mFullName.

Here is the call graph for this function:

◆ OnFormatChange()

void ExportFilePanel::OnFormatChange ( wxCommandEvent &  event)
private

Definition at line 419 of file ExportFilePanel.cpp.

420{
421 ChangeFormat(event.GetInt());
422 event.Skip();
423}

References ChangeFormat().

Here is the call graph for this function:

◆ OnFullNameFocusKill()

void ExportFilePanel::OnFullNameFocusKill ( wxFocusEvent &  event)
private

Definition at line 409 of file ExportFilePanel.cpp.

410{
411 //When user has finished typing make sure that file extension
412 //is one of extensions supplied by FormatInfo
413
414 event.Skip();
415
417}

References ValidateAndFixExt().

Referenced by PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnOptionsHandlerEvent()

void ExportFilePanel::OnOptionsHandlerEvent ( const ExportOptionsHandlerEvent e)
private

Definition at line 539 of file ExportFilePanel.cpp.

540{
541 switch(e.type)
542 {
545 break;
547 {
548 const auto formatInfo = mSelectedPlugin->GetFormatInfo(mSelectedFormatIndex);
550 UpdateMaxChannels(formatInfo.maxChannels);
551 } break;
552 }
553
554}
virtual FormatInfo GetFormatInfo(int index) const =0
Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn'...
enum ExportOptionsHandlerEvent::@34 type

References ExportOptionsHandlerEvent::FormatInfoChange, ExportPlugin::GetFormatInfo(), mSelectedFormatIndex, mSelectedPlugin, ExportOptionsHandlerEvent::SampleRateListChange, ExportOptionsHandlerEvent::type, UpdateMaxChannels(), UpdateSampleRateList(), and ValidateAndFixExt().

Referenced by ChangeFormat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSampleRateChange()

void ExportFilePanel::OnSampleRateChange ( wxCommandEvent &  event)
private

Definition at line 425 of file ExportFilePanel.cpp.

426{
427 const auto clientData = event.GetClientData();
428 if(clientData == nullptr)
429 {
430 CustomSampleRateDialog dialog(this, mSampleRate);
431 if(dialog.ShowModal() == wxID_OK &&
432 dialog.GetSampleRate() > 0)
433 {
434 mSampleRate = dialog.GetSampleRate();
435 }
437 }
438 else
439 mSampleRate = *reinterpret_cast<const int*>(&clientData);
440}

References mSampleRate, and UpdateSampleRateList().

Here is the call graph for this function:

◆ PopulateOrExchange()

void ExportFilePanel::PopulateOrExchange ( ShuttleGui S)

Definition at line 146 of file ExportFilePanel.cpp.

147{
148 TranslatableStrings formats;
149 if(S.GetMode() == eIsCreating)
150 {
151 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
152 {
153 auto formatInfo = plugin->GetFormatInfo(formatIndex);
154 formats.push_back(formatInfo.description);
155 }
156 }
157
158 S.SetBorder(5);
159 S.StartMultiColumn(3, wxEXPAND);
160 {
161 S.SetStretchyCol(1);
162
163 mFullName = S.AddTextBox(XO("File &Name:"), {}, 0);
164 mFullName->Bind(wxEVT_KILL_FOCUS, &ExportFilePanel::OnFullNameFocusKill, this);
165 S.AddSpace(1);
166
167 mFolder = S.AddTextBox(XO("Fo&lder:"), {}, 0);
168 S.Id(FolderBrowseID).AddButton(XO("&Browse..."));
169
170 mFormat = S.Id(FormatID).AddChoice(XO("&Format:"), formats);
171 S.AddSpace(1);
172 }
173 S.EndMultiColumn();
174
175 S.SetBorder(5);
176 S.StartStatic(XO("Audio options"));
177 {
178 S.StartTwoColumn();
179 {
180 if(auto prompt = S.AddPrompt(XO("Channels")))
181 prompt->SetMinSize({140, -1});
182
183 S.StartHorizontalLay(wxALIGN_LEFT);
184 {
185 S.SetBorder(2);
186
187 const int channels = 2;
188
189 mMono = S.Id(AudioMixModeMonoID).AddRadioButton(XO("M&ono"), 1, channels);
190 mStereo = S.Id(AudioMixModeStereoID).AddRadioButtonToGroup(XO("&Stereo"), 2, channels);
191 if(!mMonoStereoMode)
192 {
193 //i18n-hint refers to custom channel mapping configuration
194 mCustomMapping = S.Id(AudioMixModeCustomID).AddRadioButtonToGroup(XO("Custom mappin&g"), 0, true);
196 //i18n-hint accessibility hint, refers to export channel configuration
197 .Name(XO("Configure custom mapping"))
198 .AddButton(XO("Configure"));
199#if wxUSE_ACCESSIBILITY
201#endif
202 }
203 }
204 S.EndHorizontalLay();
205
206 S.SetBorder(5);
207
208 if(auto prompt = S.AddPrompt(XO("Sample &Rate")))
209 prompt->SetMinSize({140, -1});
210
211 S.StartHorizontalLay(wxALIGN_LEFT);
212 {
213 mRates = S.Id(SampleRateID).AddChoice({}, {});
214 }
215 S.EndHorizontalLay();
216 }
217 S.EndTwoColumn();
218
219 mAudioOptionsPanel = S.StartPanel();
220 {
221
222 }
223 S.EndPanel();
224 }
225 S.EndStatic();
226}
#define safenew
Definition: MemoryX.h:10
std::vector< TranslatableString > TranslatableStrings
void OnFullNameFocusKill(wxFocusEvent &event)
wxChoice * mRates
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References anonymous_namespace{ExportFilePanel.cpp}::AudioChannelsConfigureID, anonymous_namespace{ExportFilePanel.cpp}::AudioMixModeCustomID, anonymous_namespace{ExportFilePanel.cpp}::AudioMixModeMonoID, anonymous_namespace{ExportFilePanel.cpp}::AudioMixModeStereoID, eIsCreating, anonymous_namespace{ExportFilePanel.cpp}::FolderBrowseID, anonymous_namespace{ExportFilePanel.cpp}::FormatID, ExportPluginRegistry::Get(), mAudioOptionsPanel, mCustomizeChannels, mCustomMapping, mFolder, mFormat, mFullName, mMono, mMonoStereoMode, mRates, mStereo, OnFullNameFocusKill(), S, safenew, anonymous_namespace{ExportFilePanel.cpp}::SampleRateID, and XO().

Here is the call graph for this function:

◆ SetCustomMappingEnabled()

void ExportFilePanel::SetCustomMappingEnabled ( bool  enabled)

Definition at line 303 of file ExportFilePanel.cpp.

304{
306 return;
307
308 if(!enabled && mCustomMapping->GetValue())
309 {
310 if(mStereo->IsEnabled())
311 mStereo->SetValue(true);
312 else
313 mMono->SetValue(true);
314 }
315 mCustomMapping->Enable(enabled);
316 mCustomizeChannels->Enable(enabled);
317}

References mCustomizeChannels, mCustomMapping, mMono, mMonoStereoMode, and mStereo.

Referenced by ExportAudioDialog::OnExportRangeChange().

Here is the caller graph for this function:

◆ SetInitialFocus()

void ExportFilePanel::SetInitialFocus ( )

Definition at line 297 of file ExportFilePanel.cpp.

298{
299 mFullName->SetFocus();
300 mFullName->SelectAll();
301}

References mFullName.

Referenced by ExportAudioDialog::Show().

Here is the caller graph for this function:

◆ UpdateMaxChannels()

void ExportFilePanel::UpdateMaxChannels ( unsigned  maxChannels)
private

Definition at line 556 of file ExportFilePanel.cpp.

557{
558 if(maxChannels < 2 && mStereo->GetValue())
559 mMono->SetValue(true);
560 mStereo->Enable(maxChannels > 1);
561 if(!mMonoStereoMode)
562 {
563 const auto mixerMaxChannels = std::clamp(
564 maxChannels,
565 // JKC: This is an attempt to fix a 'watching brief' issue, where the slider is
566 // sometimes not slidable. My suspicion is that a mixer may incorrectly
567 // state the number of channels - so we assume there are always at least two.
568 // The downside is that if someone is exporting to a mono device, the dialog
569 // will allow them to output to two channels. Hmm. We may need to revisit this.
570 // STF (April 2016): AMR (narrowband) and MP3 may export 1 channel.
571 1u,
573 if(!mMixerSpec || mMixerSpec->GetMaxNumChannels() != mixerMaxChannels)
574 {
575 auto waveTracks = TrackList::Get(mProject).Any<const WaveTrack>();
576 mMixerSpec = std::make_unique<MixerOptions::Downmix>(
577 waveTracks.sum([](const auto track) { return track->NChannels(); }),
578 mixerMaxChannels);
579 }
580 }
581}
static constexpr auto MaxExportChannels

References TrackList::Any(), TrackList::Get(), MaxExportChannels, mMixerSpec, mMono, mMonoStereoMode, mProject, and mStereo.

Referenced by ChangeFormat(), and OnOptionsHandlerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateSampleRateList()

void ExportFilePanel::UpdateSampleRateList ( )
private

Definition at line 583 of file ExportFilePanel.cpp.

584{
585 auto availableRates = mOptionsHandler->GetSampleRateList();
586 std::sort(availableRates.begin(), availableRates.end());
587
588 const auto* rates = availableRates.empty() ? &DefaultRates : &availableRates;
589
590 mRates->Clear();
591
592 void* clientData;
593 int customRate = mSampleRate;
594 int selectedItemIndex = 0;
595 //Prefer lowest possible sample rate that is not less than mSampleRate.
596 //Initialize with highest value, so that if all available rates are less
597 //than mSampleRate then we will choose highest rate
598 int preferredRate = rates->back();
599 int preferredItemIndex = rates->size() - 1;
600 for(auto rate : *rates)
601 {
602 *reinterpret_cast<int*>(&clientData) = rate;
603 const auto itemIndex =
604 mRates->Append(
605 XO("%d Hz").Format(rate).Translation(),
606 clientData);
607 if(rate == mSampleRate)
608 {
609 customRate = 0;
610 selectedItemIndex = itemIndex;
611 }
612 if(rate >= mSampleRate && rate < preferredRate)
613 {
614 preferredItemIndex = itemIndex;
615 preferredRate = rate;
616 }
617 }
618
619 if(rates == &DefaultRates)
620 {
621 if(customRate != 0)
622 {
623 *reinterpret_cast<int*>(&clientData) = customRate;
624 selectedItemIndex =
625 mRates->Append(
626 XO("%d Hz (custom)").Format(customRate).Translation(),
627 clientData);
628 }
629 mRates->Append(_("Other..."));
630 }
631 else if(customRate != 0)//sample rate not in the list
632 {
633 auto selectedRate = (*rates)[preferredItemIndex];
634 mSampleRate = selectedRate;
635 selectedItemIndex = preferredItemIndex;
636 }
637 mRates->SetSelection(selectedItemIndex);
638}
const ExportOptionsEditor::SampleRateList DefaultRates

References _, anonymous_namespace{ExportFilePanel.cpp}::DefaultRates, mOptionsHandler, mRates, mSampleRate, and XO().

Referenced by ChangeFormat(), OnOptionsHandlerEvent(), and OnSampleRateChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ValidateAndFixExt()

void ExportFilePanel::ValidateAndFixExt ( )
private

Definition at line 364 of file ExportFilePanel.cpp.

365{
366 if(mSelectedPlugin == nullptr)
367 return;
368
369 const auto formatInfo = mSelectedPlugin->GetFormatInfo(mSelectedFormatIndex);
370 if(formatInfo.extensions.empty())
371 return;
372
373 wxFileName filename;
374 filename.SetFullName(mFullName->GetValue());
375 const auto desiredExt = filename.GetExt().Trim();
376
377 //See https://github.com/audacity/audacity/issues/5823
378 //check if extension is valid, i.e. does not contain whitespace characters.
379 //Otherwise everything after '.'(if present) is considered to be a part of name.
380 if(wxRegEx{R"(^[^ ]+$)"}.Matches(desiredExt))
381 {
382 auto it = std::find_if(
383 formatInfo.extensions.begin(),
384 formatInfo.extensions.end(),
385 // if typed extension uses different case (e.g. MP3 instead of mp3)
386 // we'll reset the file extension to one provided by FormatInfo
387 [&](const auto& ext) { return desiredExt.IsSameAs(ext, false); });
388
389 if(it == formatInfo.extensions.end())
390 it = formatInfo.extensions.begin();
391
392 if(!it->empty() && !it->IsSameAs(filename.GetExt()))
393 {
394 filename.SetExt(*it);
395 mFullName->SetValue(filename.GetFullName());
396 }
397 }
398 else if(!formatInfo.extensions.front().empty())
399 {
400 auto fullname = filename.GetFullName();
401 if(!fullname.EndsWith("."))
402 fullname.Append(".");
403 fullname.Append(formatInfo.extensions.front());
404 filename.SetFullName(fullname);
405 mFullName->SetValue(filename.GetFullName());
406 }
407}

References ExportPlugin::GetFormatInfo(), mFullName, mSelectedFormatIndex, and mSelectedPlugin.

Referenced by ChangeFormat(), GetFullName(), OnFullNameFocusKill(), and OnOptionsHandlerEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAudioOptionsPanel

wxWindow* ExportFilePanel::mAudioOptionsPanel {}
private

Definition at line 99 of file ExportFilePanel.h.

Referenced by ChangeFormat(), and PopulateOrExchange().

◆ MaxExportChannels

constexpr auto ExportFilePanel::MaxExportChannels = 32u
staticconstexprprivate

Definition at line 29 of file ExportFilePanel.h.

Referenced by UpdateMaxChannels().

◆ mCustomizeChannels

wxButton* ExportFilePanel::mCustomizeChannels {}
private

◆ mCustomMapping

wxRadioButton* ExportFilePanel::mCustomMapping {}
private

Definition at line 106 of file ExportFilePanel.h.

Referenced by GetChannels(), Init(), PopulateOrExchange(), and SetCustomMappingEnabled().

◆ mFolder

wxTextCtrl* ExportFilePanel::mFolder {}
private

Definition at line 101 of file ExportFilePanel.h.

Referenced by GetPath(), Init(), OnFolderBrowse(), and PopulateOrExchange().

◆ mFormat

wxChoice* ExportFilePanel::mFormat {}
private

Definition at line 97 of file ExportFilePanel.h.

Referenced by Init(), OnFolderBrowse(), and PopulateOrExchange().

◆ mFullName

wxTextCtrl* ExportFilePanel::mFullName {}
private

◆ mMixerSpec

std::unique_ptr<MixerOptions::Downmix> ExportFilePanel::mMixerSpec
private

Definition at line 114 of file ExportFilePanel.h.

Referenced by GetMixerSpec(), Init(), OnChannelsConfigure(), and UpdateMaxChannels().

◆ mMono

wxRadioButton* ExportFilePanel::mMono {}
private

◆ mMonoStereoMode

bool ExportFilePanel::mMonoStereoMode {false}
private

◆ mOptionsChangeSubscription

Observer::Subscription ExportFilePanel::mOptionsChangeSubscription
private

Definition at line 116 of file ExportFilePanel.h.

Referenced by ChangeFormat().

◆ mOptionsHandler

std::unique_ptr<ExportOptionsHandler> ExportFilePanel::mOptionsHandler
private

Definition at line 113 of file ExportFilePanel.h.

Referenced by ChangeFormat(), GetParameters(), Init(), and UpdateSampleRateList().

◆ mProject

AudacityProject& ExportFilePanel::mProject
private

Definition at line 93 of file ExportFilePanel.h.

Referenced by Init(), OnChannelsConfigure(), and UpdateMaxChannels().

◆ mRates

wxChoice* ExportFilePanel::mRates {}
private

Definition at line 98 of file ExportFilePanel.h.

Referenced by PopulateOrExchange(), and UpdateSampleRateList().

◆ mSampleRate

int ExportFilePanel::mSampleRate {}
private

Definition at line 109 of file ExportFilePanel.h.

Referenced by GetSampleRate(), Init(), OnSampleRateChange(), and UpdateSampleRateList().

◆ mSelectedFormatIndex

int ExportFilePanel::mSelectedFormatIndex {}
private

◆ mSelectedPlugin

const ExportPlugin* ExportFilePanel::mSelectedPlugin {}
private

◆ mStereo

wxRadioButton* ExportFilePanel::mStereo {}
private

The documentation for this class was generated from the following files: