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 UpdateFileNameExt (const wxString &ext)
 
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 131 of file ExportFilePanel.cpp.

135 : wxPanelWrapper(parent, winid)
136 , mMonoStereoMode(monoStereoMode)
138{
139 ShuttleGui S(this, eIsCreating);
141}
@ 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:630

References eIsCreating, and S.

◆ ~ExportFilePanel()

ExportFilePanel::~ExportFilePanel ( )
overridedefault

Member Function Documentation

◆ ChangeFormat()

void ExportFilePanel::ChangeFormat ( int  index)
private

Definition at line 482 of file ExportFilePanel.cpp.

483{
484 mSelectedPlugin = nullptr;
485
486 wxWindowUpdateLocker wndupdlck(mAudioOptionsPanel);
487
488 auto formatCounter = 0;
489
490 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
491 {
492 if(formatCounter != index)
493 {
494 ++formatCounter;
495 continue;
496 }
497
499
500 mSelectedPlugin = plugin;
501 mSelectedFormatIndex = formatIndex;
502
503 auto formatInfo = plugin->GetFormatInfo(formatIndex);
504 UpdateFileNameExt(formatInfo.extensions[0]);
505
506 mAudioOptionsPanel->SetSizer(nullptr);
507 mAudioOptionsPanel->DestroyChildren();
508
510 mOptionsHandler = std::make_unique<ExportOptionsHandler>(S, *plugin, formatIndex);
512
513 UpdateMaxChannels(formatInfo.maxChannels);
514
516
517 mAudioOptionsPanel->Layout();
518
519 wxPostEvent(GetParent(), wxCommandEvent { AUDACITY_EXPORT_FORMAT_CHANGE_EVENT, GetId() });
520
521 return;
522 }
523}
std::unique_ptr< ExportOptionsHandler > mOptionsHandler
const ExportPlugin * mSelectedPlugin
wxWindow * mAudioOptionsPanel
void OnOptionsHandlerEvent(const ExportOptionsHandlerEvent &e)
Observer::Subscription mOptionsChangeSubscription
void UpdateMaxChannels(unsigned maxChannels)
void UpdateFileNameExt(const wxString &ext)
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, UpdateFileNameExt(), UpdateMaxChannels(), and UpdateSampleRateList().

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 351 of file ExportFilePanel.cpp.

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

References mCustomMapping, and mMono.

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

Here is the caller graph for this function:

◆ GetFormat()

int ExportFilePanel::GetFormat ( ) const

Definition at line 334 of file ExportFilePanel.cpp.

335{
337}

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 323 of file ExportFilePanel.cpp.

324{
326 return mFullName->GetValue();
327}
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 358 of file ExportFilePanel.cpp.

359{
360 return mMixerSpec.get();
361}
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 344 of file ExportFilePanel.cpp.

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

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 318 of file ExportFilePanel.cpp.

319{
320 return mFolder->GetValue();
321}
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 329 of file ExportFilePanel.cpp.

330{
331 return mSelectedPlugin;
332}

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 339 of file ExportFilePanel.cpp.

340{
341 return mSampleRate;
342}

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 227 of file ExportFilePanel.cpp.

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

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, TrackList::NChannels(), 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 464 of file ExportFilePanel.cpp.

465{
466 //Configure for all tracks, but some channels may turn out to be silent
467 //if exported region does not contain audio samples
468 auto waveTracks = TrackList::Get(mProject).Any<const WaveTrack>();
469
470 auto mixerSpec = std::make_unique<MixerOptions::Downmix>(*mMixerSpec);
471
472 ExportMixerDialog md(waveTracks,
473 mixerSpec.get(),
474 nullptr,
475 1,
476 XO("Advanced Mixing Options"));
477 if(md.ShowModal() == wxID_OK)
478 mMixerSpec.swap(mixerSpec);
479}
XO("Cut/Copy/Paste")
Dialog for advanced mixing.
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1097
A Track that contains audio waveform data.
Definition: WaveTrack.h:227

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 428 of file ExportFilePanel.cpp.

429{
430 FileNames::FileTypes fileTypes;
431
432 for(auto [plugin, formatIndex] : ExportPluginRegistry::Get())
433 {
434 const auto formatInfo = plugin->GetFormatInfo(formatIndex);
435 fileTypes.emplace_back(formatInfo.description, formatInfo.extensions);
436 }
437 wxFileDialog fd(this, _("Choose a location to save the exported files"),
438 mFolder->GetValue(),
439 mFullName->GetValue(),
440 FileNames::FormatWildcard(fileTypes),
441 wxFD_SAVE);
442 fd.SetFilterIndex(mFormat->GetSelection());
443
444 if(fd.ShowModal() == wxID_OK)
445 {
446 wxFileName filepath (fd.GetPath());
447 mFolder->SetValue(filepath.GetPath());
448 mFullName->SetValue(filepath.GetFullName());
449 const auto selectedFormat = fd.GetFilterIndex();
450 if(selectedFormat != mFormat->GetSelection())
451 {
452 mFormat->SetSelection(selectedFormat);
453 ChangeFormat(selectedFormat);
454 }
455 }
456}
#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 405 of file ExportFilePanel.cpp.

406{
407 ChangeFormat(event.GetInt());
408 event.Skip();
409}

References ChangeFormat().

Here is the call graph for this function:

◆ OnFullNameFocusKill()

void ExportFilePanel::OnFullNameFocusKill ( wxFocusEvent &  event)
private

Definition at line 395 of file ExportFilePanel.cpp.

396{
397 //When user has finished typing make sure that file extension
398 //is one of extensions supplied by FormatInfo
399
400 event.Skip();
401
403}

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 525 of file ExportFilePanel.cpp.

526{
527 switch(e.type)
528 {
531 break;
533 {
535 UpdateFileNameExt(formatInfo.extensions[0]);
536 UpdateMaxChannels(formatInfo.maxChannels);
537 } break;
538 }
539
540}
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::@43 type

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

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 411 of file ExportFilePanel.cpp.

412{
413 const auto clientData = event.GetClientData();
414 if(clientData == nullptr)
415 {
416 CustomSampleRateDialog dialog(this, mSampleRate);
417 if(dialog.ShowModal() == wxID_OK &&
418 dialog.GetSampleRate() > 0)
419 {
420 mSampleRate = dialog.GetSampleRate();
421 }
423 }
424 else
425 mSampleRate = *reinterpret_cast<const int*>(&clientData);
426}

References mSampleRate, and UpdateSampleRateList().

Here is the call graph for this function:

◆ PopulateOrExchange()

void ExportFilePanel::PopulateOrExchange ( ShuttleGui S)

Definition at line 145 of file ExportFilePanel.cpp.

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

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

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 296 of file ExportFilePanel.cpp.

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

References mFullName.

Referenced by ExportAudioDialog::Show().

Here is the caller graph for this function:

◆ UpdateFileNameExt()

void ExportFilePanel::UpdateFileNameExt ( const wxString &  ext)
private

Definition at line 542 of file ExportFilePanel.cpp.

543{
544 if(!ext.empty())
545 {
546 wxFileName filename;
547 filename.SetFullName(mFullName->GetValue());
548 filename.SetExt(ext.BeforeFirst(' ').Lower());
549 mFullName->SetValue(filename.GetFullName());
550 }
551}

References mFullName.

Referenced by ChangeFormat(), and OnOptionsHandlerEvent().

Here is the caller graph for this function:

◆ UpdateMaxChannels()

void ExportFilePanel::UpdateMaxChannels ( unsigned  maxChannels)
private

Definition at line 553 of file ExportFilePanel.cpp.

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

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

364{
365 if(mSelectedPlugin == nullptr)
366 return;
367
368 const auto formatInfo = mSelectedPlugin->GetFormatInfo(mSelectedFormatIndex);
369 if(formatInfo.extensions.empty())
370 return;
371
372 wxFileName filename;
373 filename.SetFullName(mFullName->GetValue());
374
375 //Remove extra whitespaces
376 auto desiredExt = filename.GetExt().Trim().Trim(false);
377
378 auto it = std::find_if(
379 formatInfo.extensions.begin(),
380 formatInfo.extensions.end(),
381 // if typed extension uses different case (e.g. MP3 instead of mp3)
382 // we'll reset the file extension to one provided by FormatInfo
383 [&](const auto& ext) { return desiredExt.IsSameAs(ext, false); });
384
385 if(it == formatInfo.extensions.end())
386 it = formatInfo.extensions.begin();
387
388 if(!it->empty() && !it->IsSameAs(filename.GetExt()))
389 {
390 filename.SetExt(*it);
391 mFullName->SetValue(filename.GetFullName());
392 }
393}

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

Referenced by GetFullName(), and OnFullNameFocusKill().

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 100 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 107 of file ExportFilePanel.h.

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

◆ mFolder

wxTextCtrl* ExportFilePanel::mFolder {}
private

Definition at line 102 of file ExportFilePanel.h.

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

◆ mFormat

wxChoice* ExportFilePanel::mFormat {}
private

Definition at line 98 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 115 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 117 of file ExportFilePanel.h.

Referenced by ChangeFormat().

◆ mOptionsHandler

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

Definition at line 114 of file ExportFilePanel.h.

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

◆ mProject

AudacityProject& ExportFilePanel::mProject
private

Definition at line 94 of file ExportFilePanel.h.

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

◆ mRates

wxChoice* ExportFilePanel::mRates {}
private

Definition at line 99 of file ExportFilePanel.h.

Referenced by PopulateOrExchange(), and UpdateSampleRateList().

◆ mSampleRate

int ExportFilePanel::mSampleRate {}
private

Definition at line 110 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: