Audacity 3.2.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExportAudioDialog Class Referencefinal

#include <ExportAudioDialog.h>

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

Classes

struct  ExportSetting
 A private class used to store the information needed to do an export. More...
 

Public Types

enum class  ExportMode { Auto , SelectedOnly }
 

Public Member Functions

 ExportAudioDialog (wxWindow *parent, AudacityProject &project, const wxString &defaultName, const wxString &defaultFormat, ExportMode mode=ExportMode::Auto)
 
 ~ExportAudioDialog () override
 
bool Show (bool show=true) override
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void PopulateOrExchange (ShuttleGui &S)
 
void OnExportRangeChange (wxCommandEvent &event)
 
void OnSplitModeChange (wxCommandEvent &event)
 
void OnSplitNamePolicyChange (wxCommandEvent &event)
 
void OnTrimBlankSpaceBeforeFirstClip (wxCommandEvent &)
 
void OnIncludeAudioBeforeFirstLabelChange (wxCommandEvent &)
 
void OnFileNamePrefixChange (wxCommandEvent &)
 
void OnEditMetadata (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnFormatChange (wxCommandEvent &event)
 
void UpdateExportSettings ()
 
void UpdateLabelExportSettings (const ExportPlugin &plugin, int formatIndex, bool byName, bool addNumber, const wxString &prefix)
 
void UpdateTrackExportSettings (const ExportPlugin &plugin, int formatIndex, bool byName, bool addNumber, const wxString &prefix)
 
ExportResult DoExportSplitByLabels (const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, FilePaths &exporterFiles)
 
ExportResult DoExportSplitByTracks (const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, FilePaths &exporterFiles)
 
ExportResult DoExport (const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, const wxFileName &filename, int channels, double t0, double t1, bool selectedOnly, const Tags &tags, FilePaths &exportedFiles)
 

Private Attributes

AudacityProjectmProject
 
ExportFilePanelmExportOptionsPanel {}
 
wxWindow * mSplitsPanel {}
 
wxCheckBox * mIncludeAudioBeforeFirstLabel {}
 
wxTextCtrl * mSplitFileNamePrefix {}
 
wxButton * mEditMetadata {}
 
wxRadioButton * mRangeProject
 
wxRadioButton * mRangeSelection {}
 
wxRadioButton * mRangeSplit {}
 
wxRadioButton * mSplitByLabels {}
 
wxRadioButton * mSplitByTracks {}
 
wxRadioButton * mExportRangeSelection {}
 
wxRadioButton * mSplitModeTracks {}
 
wxRadioButton * mSplitModeLabels {}
 
wxRadioButton * mSplitUseName {}
 
wxRadioButton * mSplitUseNumAndName {}
 
wxRadioButton * mSplitUseNumAndPrefix {}
 
wxCheckBox * mOverwriteExisting {}
 
wxCheckBox * mSkipSilenceAtBeginning {}
 
std::vector< ExportSettingmExportSettings
 
bool mExportSettingsDirty {true}
 

Detailed Description

Definition at line 42 of file ExportAudioDialog.h.

Member Enumeration Documentation

◆ ExportMode

enum class ExportAudioDialog::ExportMode
strong
Enumerator
Auto 
SelectedOnly 

Definition at line 55 of file ExportAudioDialog.h.

56 {
57 Auto,
58 SelectedOnly
59 };

Constructor & Destructor Documentation

◆ ExportAudioDialog()

ExportAudioDialog::ExportAudioDialog ( wxWindow *  parent,
AudacityProject project,
const wxString &  defaultName,
const wxString &  defaultFormat,
ExportMode  mode = ExportMode::Auto 
)

Definition at line 161 of file ExportAudioDialog.cpp.

166 : wxDialogWrapper(parent, wxID_ANY, XO("Export Audio"))
168{
170
173
174 SetMinSize({GetBestSize().GetWidth(), -1});
175
176 wxFileName filename;
177 auto exportPath = ExportAudioDefaultPath.Read();
178 if(exportPath.empty())
179 exportPath = FileNames::FindDefaultPath(FileNames::Operation::Export);
180 filename.SetPath(exportPath);
181
182 //extension will be set in `ChangeFormat`
183 filename.SetEmptyExt();
184 if(defaultName.empty())
185 //i18n-hint: default exported file name when exporting from unsaved project
186 filename.SetName(_("untitled"));
187 else
188 filename.SetName(defaultName);
189
192 {
194 for(const auto track : tracks.Any<WaveTrack>())
195 sampleRate = std::max(sampleRate, track->GetRate());
196 }
197
198 wxString format = defaultFormat;
199 if(format.empty())
201
203
205 const auto labelTracks = tracks.Any<LabelTrack>();
206 const auto hasLabels = !labelTracks.empty() &&
207 (*labelTracks.begin())->GetNumLabels() > 0;
208 const auto hasMultipleWaveTracks = tracks.Any<WaveTrack>().size() > 1;
209 const auto hasSelectedAudio = ExportUtils::HasSelectedAudio(mProject);
210
211 mRangeSelection->Enable(hasSelectedAudio);
212 mRangeSplit->Enable(hasLabels || hasMultipleWaveTracks);
213
214 mSplitByLabels->Enable(hasLabels);
215 mSplitByTracks->Enable(hasMultipleWaveTracks);
216
217 if(mRangeSelection->IsEnabled() && mode == ExportMode::SelectedOnly)
218 {
219 mRangeSelection->SetValue(true);
220 }
221 else
222 {
223 if(!mRangeSelection->IsEnabled() && ExportAudioExportRange.Read() == "selection")
224 mRangeProject->SetValue(true);
225
226 if(!mRangeSplit->IsEnabled() && ExportAudioExportRange.Read() == "split")
227 mRangeProject->SetValue(true);
228
229 if(!hasLabels && hasMultipleWaveTracks)
230 mSplitByTracks->SetValue(true);
231 if (!hasMultipleWaveTracks && hasLabels)
232 mSplitByLabels->SetValue(true);
233 }
234
235 if (mRangeSelection->IsEnabled() && !hasLabels && !hasMultipleWaveTracks)
236 mRangeSelection->MoveAfterInTabOrder(mRangeProject);
237
238 if (ExportAudioExportRange.Read() != "split" || (!hasLabels && !hasMultipleWaveTracks))
239 mSplitsPanel->Hide();
240
242 !mRangeSplit->GetValue() &&
243 //Custom channel export isn't available when master channel has effects assigned
245 );
246
248
249 if(ExportAudioSplitNamePolicy.Read() != "num_and_prefix")
250 mSplitFileNamePrefix->Disable();
251
252 Layout();
253 Fit();
254 Center();
255}
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
const auto tracks
const auto project
#define S(N)
Definition: ToChars.cpp:64
wxString Read() const
Definition: Prefs.cpp:388
wxRadioButton * mRangeSplit
wxRadioButton * mRangeSelection
void PopulateOrExchange(ShuttleGui &S)
wxRadioButton * mSplitByTracks
ExportFilePanel * mExportOptionsPanel
wxRadioButton * mSplitByLabels
wxTextCtrl * mSplitFileNamePrefix
AudacityProject & mProject
wxCheckBox * mIncludeAudioBeforeFirstLabel
wxRadioButton * mRangeProject
void SetCustomMappingEnabled(bool enabled)
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.
static TrackIterRange< const WaveTrack > FindExportWaveTracks(const TrackList &tracks, bool selectedOnly)
Definition: ExportUtils.cpp:23
static bool HasSelectedAudio(const AudacityProject &project)
Definition: ExportUtils.cpp:33
static ImportExport & Get(AudacityProject &project)
double GetPreferredExportRate() const
static constexpr double InvalidRate
Definition: ImportExport.h:21
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:98
static RealtimeEffectList & Get(AudacityProject &project)
size_t GetStatesCount() const noexcept
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
FILES_API FilePath FindDefaultPath(Operation op)

References _, eIsCreatingFromPrefs, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioDefaultFormat, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioDefaultPath, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioExportRange, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioSplitNamePolicy, FileNames::FindDefaultPath(), ExportUtils::FindExportWaveTracks(), anonymous_namespace{ExportPCM.cpp}::format, ImportExport::Get(), RealtimeEffectList::Get(), TrackList::Get(), ImportExport::GetPreferredExportRate(), RealtimeEffectList::GetStatesCount(), ExportUtils::HasSelectedAudio(), ImportExport::InvalidRate, project, ChoiceSetting::Read(), Setting< T >::Read(), S, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, size, and tracks.

Here is the call graph for this function:

◆ ~ExportAudioDialog()

ExportAudioDialog::~ExportAudioDialog ( )
overridedefault

Member Function Documentation

◆ DoExport()

ExportResult ExportAudioDialog::DoExport ( const ExportPlugin plugin,
int  formatIndex,
const ExportProcessor::Parameters parameters,
const wxFileName &  filename,
int  channels,
double  t0,
double  t1,
bool  selectedOnly,
const Tags tags,
FilePaths exportedFiles 
)
private

Definition at line 974 of file ExportAudioDialog.cpp.

982{
983 wxFileName name;
984
985 wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (filename.GetFullName()));
986 wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1);
987 if (selectedOnly)
988 wxLogDebug(wxT("Selected Region Only"));
989 else
990 wxLogDebug(wxT("Whole Project"));
991
992 wxFileName backup;
993 if (mOverwriteExisting->GetValue()) {
994 name = filename;
995 backup.Assign(name);
996
997 int suffix = 0;
998 do {
999 backup.SetName(name.GetName() +
1000 wxString::Format(wxT("%d"), suffix));
1001 ++suffix;
1002 }
1003 while (backup.FileExists());
1004 ::wxRenameFile(filename.GetFullPath(), backup.GetFullPath());
1005 }
1006 else {
1007 name = filename;
1008 int i = 2;
1009 wxString base(name.GetName());
1010 while (name.FileExists()) {
1011 name.SetName(wxString::Format(wxT("%s-%d"), base, i++));
1012 }
1013 }
1014
1015 bool success{false};
1016 const wxString fullPath{name.GetFullPath()};
1017
1018 auto cleanup = finally( [&] {
1019 if (backup.IsOk()) {
1020 if ( success )
1021 // Remove backup
1022 ::wxRemoveFile(backup.GetFullPath());
1023 else {
1024 // Restore original
1025 ::wxRemoveFile(fullPath);
1026 ::wxRenameFile(backup.GetFullPath(), fullPath);
1027 }
1028 }
1029 else {
1030 if ( ! success )
1031 // Remove any new, and only partially written, file.
1032 ::wxRemoveFile(fullPath);
1033 }
1034 } );
1035
1036 auto result = ExportResult::Error;
1038 {
1039 result = ExportProgressUI::Show(ExportTaskBuilder{}.SetPlugin(&plugin, formatIndex)
1040 .SetParameters(parameters)
1041 .SetRange(t0, t1, selectedOnly)
1042 .SetTags(&tags)
1043 .SetNumChannels(channels)
1044 .SetFileName(fullPath)
1045 .SetSampleRate(mExportOptionsPanel->GetSampleRate())
1046 .Build(mProject));
1047 });
1048
1049 success = result == ExportResult::Success || result == ExportResult::Stopped;
1050
1051 if(success)
1052 exportedFiles.push_back(fullPath);
1053
1054 return result;
1055}
wxT("CloseDown"))
wxString name
Definition: TagsEditor.cpp:166
wxCheckBox * mOverwriteExisting
int GetSampleRate() const
ExportTaskBuilder & SetPlugin(const ExportPlugin *plugin, int format=0) noexcept
Definition: Export.cpp:59
ExportTask Build(AudacityProject &project)
Definition: Export.cpp:84
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
void ExceptionWrappedCall(Callable callable)

References mOverwriteExisting, name, and wxT().

Referenced by DoExportSplitByLabels(), and DoExportSplitByTracks().

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

◆ DoExportSplitByLabels()

ExportResult ExportAudioDialog::DoExportSplitByLabels ( const ExportPlugin plugin,
int  formatIndex,
const ExportProcessor::Parameters parameters,
FilePaths exporterFiles 
)
private

Definition at line 872 of file ExportAudioDialog.cpp.

876{
877 auto ok = ExportResult::Success; // did it work?
878 /* Go round again and do the exporting (so this run is slow but
879 * non-interactive) */
880 for(auto& activeSetting : mExportSettings)
881 {
882 /* get the settings to use for the export from the array */
883 // Bug 1440 fix.
884 if( activeSetting.filename.GetName().empty() )
885 continue;
886
887 // Export it
888 ok = DoExport(plugin, formatIndex, parameters, activeSetting.filename, activeSetting.channels,
889 activeSetting.t0, activeSetting.t1, false, activeSetting.tags, exporterFiles);
890
891 if (ok == ExportResult::Stopped) {
892 AudacityMessageDialog dlgMessage(
893 nullptr,
894 XO("Continue to export remaining files?"),
895 XO("Export"),
896 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
897 if (dlgMessage.ShowModal() != wxID_YES ) {
898 // User decided not to continue - bail out!
899 break;
900 }
901 }
902 else if (ok != ExportResult::Success) {
903 break;
904 }
905 }
906
907 return ok;
908}
Wrap wxMessageDialog so that caption IS translatable.
ExportResult DoExport(const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, const wxFileName &filename, int channels, double t0, double t1, bool selectedOnly, const Tags &tags, FilePaths &exportedFiles)
std::vector< ExportSetting > mExportSettings

References DoExport(), mExportSettings, Stopped, Success, and XO().

Referenced by OnExport().

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

◆ DoExportSplitByTracks()

ExportResult ExportAudioDialog::DoExportSplitByTracks ( const ExportPlugin plugin,
int  formatIndex,
const ExportProcessor::Parameters parameters,
FilePaths exporterFiles 
)
private

Definition at line 910 of file ExportAudioDialog.cpp.

914{
916
917 bool anySolo =
918 !((tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo).empty());
919
920 auto waveTracks = tracks.Any<WaveTrack>() -
922
923 auto& selectionState = SelectionState::Get( mProject );
924
925 /* Remember which tracks were selected, and set them to deselected */
926 SelectionStateChanger changer{ selectionState, tracks };
927 for (auto tr : tracks.Selected<WaveTrack>())
928 tr->SetSelected(false);
929
930 auto ok = ExportResult::Success;
931
932 int count = 0;
933 for (auto tr : waveTracks) {
934
935 wxLogDebug( "Get setting %i", count );
936 /* get the settings to use for the export from the array */
937 auto& activeSetting = mExportSettings[count];
938 if( activeSetting.filename.GetName().empty() ){
939 count++;
940 continue;
941 }
942
943 /* Select the track */
944 SelectionStateChanger changer2{ selectionState, tracks };
945 tr->SetSelected(true);
946
947 // Export the data. "channels" are per track.
948 ok = DoExport(plugin, formatIndex, parameters, activeSetting.filename, activeSetting.channels,
949 activeSetting.t0, activeSetting.t1, true, activeSetting.tags, exporterFiles);
950
951 if (ok == ExportResult::Stopped) {
952 AudacityMessageDialog dlgMessage(
953 nullptr,
954 XO("Continue to export remaining files?"),
955 XO("Export"),
956 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
957 if (dlgMessage.ShowModal() != wxID_YES ) {
958 // User decided not to continue - bail out!
959 break;
960 }
961 }
962
963 else if (ok != ExportResult::Success) {
964 break;
965 }
966 // increment export counter
967 count++;
968 }
969
970
971 return ok ;
972}
bool GetNotSolo() const
Definition: PlayableTrack.h:50
static SelectionState & Get(AudacityProject &project)
bool GetMute() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2339
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2344

References DoExport(), SelectionState::Get(), TrackList::Get(), WaveTrack::GetMute(), PlayableTrack::GetNotSolo(), WaveTrack::GetSolo(), mExportSettings, mProject, Stopped, Success, tracks, and XO().

Referenced by OnExport().

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

◆ OnEditMetadata()

void ExportAudioDialog::OnEditMetadata ( wxCommandEvent &  event)
private

Definition at line 452 of file ExportAudioDialog.cpp.

453{
454 if(mRangeSplit->GetValue())
455 {
457
458 std::vector<Tags*> tags;
459 std::vector<wxString> names;
460 tags.reserve(mExportSettings.size());
461 names.reserve(mExportSettings.size());
462 for(auto& spec : mExportSettings)
463 {
464 tags.push_back(&spec.tags);
465 names.push_back(spec.filename.GetFullName());
466 }
467 TagsEditorDialog dialog(this, XO("Edit Metadata Tags"), tags, names, true, true);
468 dialog.ShowModal();
469 }
470 else
471 {
473 XO("Edit Metadata Tags"), XO("Exported Tags"));
474 }
475}
static TranslatableStrings names
Definition: TagsEditor.cpp:153
Derived from ExpandingToolBar, this dialog allows editing of Tags.
Definition: TagsEditor.h:22
static AUDACITY_DLL_API bool EditProjectMetadata(AudacityProject &project, const TranslatableString &title, const TranslatableString &shortUndoDescription)

References TagsEditorDialog::EditProjectMetadata(), mExportSettings, mProject, mRangeSplit, names, UpdateExportSettings(), and XO().

Here is the call graph for this function:

◆ OnExport()

void ExportAudioDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 482 of file ExportAudioDialog.cpp.

483{
484 auto selectedPlugin = mExportOptionsPanel->GetPlugin();
485 if(selectedPlugin == nullptr)
486 return;
487 auto selectedFormat = mExportOptionsPanel->GetFormat();
488 auto parameters = mExportOptionsPanel->GetParameters();
489 if(!parameters.has_value())
490 return;
491
492 const auto path = mExportOptionsPanel->GetPath();
493
494 if(!wxDirExists(path))
495 wxFileName::Mkdir(path, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
496
497 if(!wxDirExists(path))
498 {
499 AudacityMessageBox(XO("Unable to create destination folder"),
500 XO("Export Audio"),
501 wxOK | wxCENTER,
502 this);
503 return;
504 }
505
506 auto result = ExportResult::Error;
507
508 if(mRangeSplit->GetValue())
509 {
510 FilePaths exportedFiles;
511
513
514 if(mSplitByLabels->GetValue())
515 result = DoExportSplitByLabels(*selectedPlugin, selectedFormat, *parameters, exportedFiles);
516 else if(mSplitByTracks->GetValue())
517 result = DoExportSplitByTracks(*selectedPlugin, selectedFormat, *parameters, exportedFiles);
518
519 auto msg = (result == ExportResult::Success
520 ? XO("Successfully exported the following %lld file(s).")
521 : result == ExportResult::Error
522 ? XO("Something went wrong after exporting the following %lld file(s).")
523 : result == ExportResult::Cancelled
524 ? XO("Export canceled after exporting the following %lld file(s).")
525 : result == ExportResult::Stopped
526 ? XO("Export stopped after exporting the following %lld file(s).")
527 : XO("Something went really wrong after exporting the following %lld file(s).")
528 ).Format((long long) exportedFiles.size());
529
530 wxString fileList;
531 for (auto& path : exportedFiles)
532 fileList += path + '\n';
533
534 // TODO: give some warning dialog first, when only some files exported
535 // successfully.
536
538 XO("Export Audio"),
539 msg,
540 fileList,
541 450,400);
542 }
543 else
544 {
545 wxFileName filename(path, mExportOptionsPanel->GetFullName());
546
547 if (filename.FileExists()) {
548 auto result = AudacityMessageBox(
549 XO("A file named \"%s\" already exists. Replace?")
550 .Format( filename.GetFullPath() ),
551 XO("Export Audio"),
552 wxYES_NO | wxICON_EXCLAMATION);
553 if (result != wxYES) {
554 return;
555 }
556 }
557
558 ExportTaskBuilder builder;
559 builder.SetFileName(filename)
560 .SetPlugin(selectedPlugin, selectedFormat)
561 .SetParameters(*parameters)
563
564 const auto& viewInfo = ViewInfo::Get(mProject);
565
566 const auto selectedOnly = mRangeSelection->GetValue();
567
568 auto t0 = selectedOnly
569 ? std::max(.0, viewInfo.selectedRegion.t0())
570 : .0;
571
572 auto t1 = selectedOnly
573 ? std::min(TrackList::Get(mProject).GetEndTime(), viewInfo.selectedRegion.t1())
574 : TrackList::Get(mProject).GetEndTime();
575
576 auto exportedTracks = ExportUtils::FindExportWaveTracks(TrackList::Get(mProject), selectedOnly);
577 if(exportedTracks.empty())
578 {
580 selectedOnly ? XO("All selected audio is muted.") : XO("All audio is muted."), //":576"
581 XO("Warning"),
582 false);
583 return;
584 }
585
586 if(mSkipSilenceAtBeginning->GetValue())
587 t0 = std::max(t0, exportedTracks.min(&Track::GetStartTime));
588
589 builder.SetRange(t0, t1, selectedOnly);
590
591 std::unique_ptr<MixerOptions::Downmix> tempMixerSpec;
592 const auto channels = mExportOptionsPanel->GetChannels();
593 if(channels == 0)
594 {
595 //Figure out the final channel mapping: mixer dialog shows
596 //all tracks regardless of their mute/solo state, but
597 //muted channels should not be present in exported file -
598 //apply channel mask to exclude them
600 std::vector<bool> channelMask(
601 tracks.sum([](const auto track) { return track->NChannels(); }),
602 false);
603 unsigned trackIndex = 0;
604 for(const auto track : tracks)
605 {
606 if(track->GetSolo())
607 {
608 channelMask.assign(channelMask.size(), false);
609 for(unsigned i = 0; i < track->NChannels(); ++i)
610 channelMask[trackIndex++] = true;
611 break;
612 }
613 if(!track->GetMute() && (!selectedOnly || track->GetSelected()))
614 {
615 for(unsigned i = 0; i < track->NChannels(); ++i)
616 channelMask[trackIndex++] = true;
617 }
618 else
619 trackIndex += track->NChannels();
620 }
621
622 tempMixerSpec = std::make_unique<MixerOptions::Downmix>(*mExportOptionsPanel->GetMixerSpec(), channelMask);
623 builder.SetMixerSpec(tempMixerSpec.get());
624 }
625 else
626 builder.SetNumChannels(channels);
627
629 {
630 result = ExportProgressUI::Show(builder.Build(mProject));
631 });
632 }
633
634 if(result == ExportResult::Success || result == ExportResult::Stopped)
635 {
637
638 ExportAudioDefaultFormat.Write(selectedPlugin->GetFormatInfo(selectedFormat).format);
640
643 event.Skip();
644 }
645}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
int min(int a, int b)
void ShowExportErrorDialog(const TranslatableString &message, const TranslatableString &caption, bool allowReporting)
Definition: Export.cpp:144
ExportResult
Definition: ExportTypes.h:24
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
double GetStartTime() const
Get the minimum of Start() values of intervals, or 0 when none.
Definition: Channel.cpp:50
ExportResult DoExportSplitByTracks(const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, FilePaths &exporterFiles)
wxCheckBox * mSkipSilenceAtBeginning
ExportResult DoExportSplitByLabels(const ExportPlugin &plugin, int formatIndex, const ExportProcessor::Parameters &parameters, FilePaths &exporterFiles)
const ExportPlugin * GetPlugin() const
wxString GetPath() const
wxString GetFullName()
MixerOptions::Downmix * GetMixerSpec() const
int GetFormat() const
int GetChannels() const
std::optional< ExportProcessor::Parameters > GetParameters() const
ExportTaskBuilder & SetMixerSpec(MixerOptions::Downmix *mixerSpec) noexcept
Definition: Export.cpp:66
ExportTaskBuilder & SetParameters(ExportProcessor::Parameters parameters) noexcept
Definition: Export.cpp:47
ExportTaskBuilder & SetNumChannels(unsigned numChannels) noexcept
Definition: Export.cpp:53
ExportTaskBuilder & SetSampleRate(double sampleRate) noexcept
Definition: Export.cpp:72
ExportTaskBuilder & SetFileName(const wxFileName &filename)
Definition: Export.cpp:33
ExportTaskBuilder & SetRange(double t0, double t1, bool selectedOnly=false) noexcept
Definition: Export.cpp:39
Abstract base class used in importing a file.
static void ShowInfoDialog(wxWindow *parent, const TranslatableString &dlogTitle, const TranslatableString &shortMsg, const wxString &message, const int xSize, const int ySize)
Displays cuttable information in a text ctrl, with an OK button.
Definition: HelpSystem.cpp:81
void SetPreferredExportRate(double rate)
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202

References TrackList::Any(), AudacityMessageBox(), ExportTaskBuilder::Build(), Cancelled, DoExportSplitByLabels(), DoExportSplitByTracks(), eIsSavingToPrefs, Error, ExportProgressUI::ExceptionWrappedCall(), anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioDefaultFormat, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioDefaultPath, ExportUtils::FindExportWaveTracks(), ImportExport::Get(), ViewInfo::Get(), TrackList::Get(), ExportFilePanel::GetChannels(), TrackList::GetEndTime(), ExportFilePanel::GetFormat(), ExportFilePanel::GetFullName(), ExportFilePanel::GetMixerSpec(), ExportFilePanel::GetParameters(), ExportFilePanel::GetPath(), ExportFilePanel::GetPlugin(), ExportFilePanel::GetSampleRate(), ChannelGroup::GetStartTime(), mExportOptionsPanel, min(), mProject, mRangeSelection, mRangeSplit, mSkipSilenceAtBeginning, mSplitByLabels, mSplitByTracks, PopulateOrExchange(), S, ExportTaskBuilder::SetFileName(), ExportTaskBuilder::SetMixerSpec(), ExportTaskBuilder::SetNumChannels(), ExportTaskBuilder::SetParameters(), ExportTaskBuilder::SetPlugin(), ImportExport::SetPreferredExportRate(), ExportTaskBuilder::SetRange(), ExportTaskBuilder::SetSampleRate(), ExportProgressUI::Show(), ShowExportErrorDialog(), HelpSystem::ShowInfoDialog(), Stopped, Success, tracks, UpdateExportSettings(), Setting< T >::Write(), and XO().

Here is the call graph for this function:

◆ OnExportRangeChange()

void ExportAudioDialog::OnExportRangeChange ( wxCommandEvent &  event)
private

Definition at line 412 of file ExportAudioDialog.cpp.

413{
414 const auto enableSplits = event.GetId() == ExportRangeSplitID;
416 if(mSplitsPanel->IsShown() != enableSplits)
417 {
419 mSplitsPanel->Show(enableSplits);
420
421 Layout();
422 Fit();
423 }
424}

References anonymous_namespace{ExportAudioDialog.cpp}::ExportRangeSplitID, mExportOptionsPanel, mExportSettingsDirty, mSplitsPanel, and ExportFilePanel::SetCustomMappingEnabled().

Here is the call graph for this function:

◆ OnFileNamePrefixChange()

void ExportAudioDialog::OnFileNamePrefixChange ( wxCommandEvent &  )
private

Definition at line 447 of file ExportAudioDialog.cpp.

448{
450}

References mExportSettingsDirty.

◆ OnFormatChange()

void ExportAudioDialog::OnFormatChange ( wxCommandEvent &  event)
private

Definition at line 647 of file ExportAudioDialog.cpp.

648{
649 Layout();
650 Fit();
651
652 auto enableMeta = false;
653 if(auto plugin = mExportOptionsPanel->GetPlugin())
654 enableMeta = plugin->GetFormatInfo(mExportOptionsPanel->GetFormat()).canMetaData;
655 mEditMetadata->Enable(enableMeta);
657}

References ExportFilePanel::GetFormat(), ExportFilePanel::GetPlugin(), mEditMetadata, mExportOptionsPanel, and mExportSettingsDirty.

Here is the call graph for this function:

◆ OnHelp()

void ExportAudioDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 477 of file ExportAudioDialog.cpp.

478{
479 HelpSystem::ShowHelp(wxGetTopLevelParent(this), L"File_Export_Dialog", true);
480}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnIncludeAudioBeforeFirstLabelChange()

void ExportAudioDialog::OnIncludeAudioBeforeFirstLabelChange ( wxCommandEvent &  event)
private

Definition at line 442 of file ExportAudioDialog.cpp.

443{
445}

References mExportSettingsDirty.

◆ OnSplitModeChange()

void ExportAudioDialog::OnSplitModeChange ( wxCommandEvent &  event)
private

◆ OnSplitNamePolicyChange()

void ExportAudioDialog::OnSplitNamePolicyChange ( wxCommandEvent &  event)
private

◆ OnTrimBlankSpaceBeforeFirstClip()

void ExportAudioDialog::OnTrimBlankSpaceBeforeFirstClip ( wxCommandEvent &  )
private

Definition at line 437 of file ExportAudioDialog.cpp.

438{
440}

References mExportSettingsDirty.

◆ PopulateOrExchange()

void ExportAudioDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 272 of file ExportAudioDialog.cpp.

273{
274 S.SetBorder(5);
275 S.StartVerticalLay();
276 {
277 if(S.GetMode() == eIsCreating)
278 {
280 S.Id(ExportFilePanelID).AddWindow(mExportOptionsPanel, wxEXPAND);
281 }
282
283 S.StartPanel();
284 {
285 S.SetBorder(5);
286 S.StartTwoColumn();
287 {
288 S.StartHorizontalLay(wxSHRINK | wxALIGN_TOP);
289 {
290 if(auto prompt = S.AddPrompt(XO("Export Range:")))
291 prompt->SetMinSize({145, -1});
292 }
293 S.EndHorizontalLay();
294
295 S.StartVerticalLay();
296 {
297 S.StartRadioButtonGroup(ExportAudioExportRange);
298 {
300 .Name(XO("Export entire project"))
301 .TieRadioButton();
303 .Name(XO("Export multiple files"))
304 .TieRadioButton();
306 .Name(XO("Export current selection"))
307 .TieRadioButton();
308#if wxUSE_ACCESSIBILITY
312#endif
313 }
314 S.EndRadioButtonGroup();
315 }
316 S.EndVerticalLay();
317 }
318 S.EndTwoColumn();
319
320 S.AddSpace(10);
321
322 S.StartTwoColumn();
323 {
324 S.AddSpace(155, 1);
327 .TieCheckBox(XO("Trim blank space before first clip"), ExportAudioSkipSilenceAtBeginning);
328 }
329 S.EndTwoColumn();
330 }
331 S.EndPanel();
332
333 S.SetBorder(5);
334 mSplitsPanel = S.StartPanel();
335 {
336 S.StartMultiColumn(2);
337 {
338 S.StartStatic(XO("Split files based on:"));
339 {
340 S.StartVerticalLay();
341 {
342 S.StartRadioButtonGroup(ExportAudioSplitMode);
343 {
344 mSplitByTracks = S.Id(ExportModeTracksID).TieRadioButton();
345 mSplitByLabels = S.Id(ExportModeLabelsID).TieRadioButton();
346 }
347 S.EndRadioButtonGroup();
348
349 S.StartHorizontalLay(wxALIGN_TOP);
350 {
351 S.AddSpace(10, 1);
354 .TieCheckBox(XO("Include audio before first label"), ExportAudioIncludeAudioBeforeFirstLabel);
355 }
356 S.EndHorizontalLay();
357 }
358 S.EndVerticalLay();
359 }
360 S.EndStatic();
361
362 S.StartStatic(XO("Name files:"));
363 {
364 S.StartVerticalLay();
365 {
366 S.StartRadioButtonGroup(ExportAudioSplitNamePolicy);
367 {
368 mSplitUseName = S.Id(ExportSplitNamePolicyTrackNameID).TieRadioButton();
371 }
372 S.EndRadioButtonGroup();
373 S.StartHorizontalLay(wxALIGN_TOP);
374 {
375 S.AddSpace(10, 1);
378 .AddTextBox(XO("File name prefix:"), {}, 0);
379 }
380 S.EndHorizontalLay();
381 }
382 S.EndVerticalLay();
383 }
384 S.EndStatic();
385 }
386 S.EndMultiColumn();
387
390 .TieCheckBox(XO("Overwrite existing files"), ExportAudioOverwriteExisting);
391 }
392 S.EndPanel();
393
394 S.AddSpace(1, 10);
395
396 S.SetBorder(5);
397
398 S.SetBorder(5);
399 S.StartHorizontalLay(wxEXPAND);
400 {
401 mEditMetadata = S.Id(EditMetadataID).AddButton(XO("Edit &Metadata..."), wxLEFT | wxBOTTOM);
402 S.AddSpace(1, 1, wxEXPAND);
403 S.Id(wxID_CANCEL).AddButton(XO("&Cancel"), wxBOTTOM);
404 S.Id(wxID_OK).AddButton(XO("&Export"), wxRIGHT | wxBOTTOM, true);
405 }
406 S.EndHorizontalLay();
407 }
408 S.EndVerticalLay();
409}
#define safenew
Definition: MemoryX.h:10
@ eIsCreating
Definition: ShuttleGui.h:37
wxRadioButton * mSplitUseName
wxRadioButton * mSplitUseNumAndName
wxRadioButton * mSplitUseNumAndPrefix
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References anonymous_namespace{ExportAudioDialog.cpp}::EditMetadataID, eIsCreating, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioExportRange, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioIncludeAudioBeforeFirstLabel, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioOverwriteExisting, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioSkipSilenceAtBeginning, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioSplitMode, anonymous_namespace{ExportAudioDialog.cpp}::ExportAudioSplitNamePolicy, anonymous_namespace{ExportAudioDialog.cpp}::ExportFilePanelID, anonymous_namespace{ExportAudioDialog.cpp}::ExportModeLabelsID, anonymous_namespace{ExportAudioDialog.cpp}::ExportModeTracksID, anonymous_namespace{ExportAudioDialog.cpp}::ExportRangeProjectID, anonymous_namespace{ExportAudioDialog.cpp}::ExportRangeSelectionID, anonymous_namespace{ExportAudioDialog.cpp}::ExportRangeSplitID, anonymous_namespace{ExportAudioDialog.cpp}::ExportSplitNamePolicyNumberingAfterPrefixID, anonymous_namespace{ExportAudioDialog.cpp}::ExportSplitNamePolicyNumberingBeforeNameID, anonymous_namespace{ExportAudioDialog.cpp}::ExportSplitNamePolicyTrackNameID, anonymous_namespace{ExportAudioDialog.cpp}::FileNamePrefixID, anonymous_namespace{ExportAudioDialog.cpp}::IncludeAudioBeforeFirstLabelID, mEditMetadata, mExportOptionsPanel, mIncludeAudioBeforeFirstLabel, mOverwriteExisting, mProject, mRangeProject, mRangeSelection, mRangeSplit, mSkipSilenceAtBeginning, mSplitByLabels, mSplitByTracks, mSplitFileNamePrefix, mSplitsPanel, mSplitUseName, mSplitUseNumAndName, mSplitUseNumAndPrefix, anonymous_namespace{ExportAudioDialog.cpp}::OverwriteExistingFilesID, S, safenew, anonymous_namespace{ExportAudioDialog.cpp}::TrimBlankSpaceBeforeFirstClipID, and XO().

Referenced by OnExport().

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

◆ Show()

bool ExportAudioDialog::Show ( bool  show = true)
override

Definition at line 260 of file ExportAudioDialog.cpp.

261{
262 bool ret = wxDialogWrapper::Show(show);
263
264#if defined(__WXMSW__)
265 if (show)
267#endif
268
269 return ret;
270}

References mExportOptionsPanel, ExportFilePanel::SetInitialFocus(), and ExportProgressUI::Show().

Here is the call graph for this function:

◆ UpdateExportSettings()

void ExportAudioDialog::UpdateExportSettings ( )
private

Definition at line 659 of file ExportAudioDialog.cpp.

660{
662 return;
663
664 const auto selectedPlugin = mExportOptionsPanel->GetPlugin();
665 if(selectedPlugin == nullptr)
666 return;
667
668 const auto selectedFormat = mExportOptionsPanel->GetFormat();
669
670 if(mRangeSplit->GetValue())
671 {
672 const auto byName = mSplitUseName->GetValue() || mSplitUseNumAndName->GetValue();
673 const auto addNumber = mSplitUseNumAndName->GetValue();
674 const auto prefix = mSplitFileNamePrefix->GetValue();
675
676 if(mSplitByLabels->GetValue())
677 UpdateLabelExportSettings(*selectedPlugin, selectedFormat, byName, addNumber, prefix);
678 else if(mSplitByTracks->GetValue())
679 UpdateTrackExportSettings(*selectedPlugin, selectedFormat, byName, addNumber, prefix);
680
681 mExportSettingsDirty = false;
682 }
683}
void UpdateLabelExportSettings(const ExportPlugin &plugin, int formatIndex, bool byName, bool addNumber, const wxString &prefix)
void UpdateTrackExportSettings(const ExportPlugin &plugin, int formatIndex, bool byName, bool addNumber, const wxString &prefix)

References ExportFilePanel::GetFormat(), ExportFilePanel::GetPlugin(), mExportOptionsPanel, mExportSettingsDirty, mRangeSplit, mSplitByLabels, mSplitByTracks, mSplitFileNamePrefix, mSplitUseName, mSplitUseNumAndName, UpdateLabelExportSettings(), and UpdateTrackExportSettings().

Referenced by OnEditMetadata(), and OnExport().

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

◆ UpdateLabelExportSettings()

void ExportAudioDialog::UpdateLabelExportSettings ( const ExportPlugin plugin,
int  formatIndex,
bool  byName,
bool  addNumber,
const wxString &  prefix 
)
private

Definition at line 685 of file ExportAudioDialog.cpp.

686{
687 const auto& tracks = TrackList::Get(mProject);
688 const auto& labels = (*tracks.Any<const LabelTrack>().begin());
689 const auto numLabels = labels->GetNumLabels();
690
691 auto numFiles = numLabels;
692 auto fileIndex = 0; // counter for files done
693 std::vector<ExportSetting> exportSettings; // dynamic array for settings.
694 exportSettings.reserve(numFiles); // Allocate some guessed space to use.
695
696 // Account for exporting before first label
697 if( mIncludeAudioBeforeFirstLabel->GetValue() ) {
698 fileIndex = -1;
699 numFiles++;
700 }
701
702 const auto formatInfo = plugin.GetFormatInfo(formatIndex);
703
704 FilePaths otherNames; // keep track of file names we will use, so we
705 // don't duplicate them
706 ExportSetting setting; // the current batch of settings
707 setting.filename.SetPath(mExportOptionsPanel->GetPath());
708 setting.channels = mExportOptionsPanel->GetChannels();
709 setting.filename.SetFullName(mExportOptionsPanel->GetFullName());
710
711 wxString name; // used to hold file name whilst we mess with it
712 wxString title; // un-messed-with title of file for tagging with
713
714 const LabelStruct *info = NULL;
715 /* Examine all labels a first time, sort out all data but don't do any
716 * exporting yet (so this run is quick but interactive) */
717 while( fileIndex < numLabels ) {
718
719 // Get file name and starting time
720 if( fileIndex < 0 ) {
721 // create wxFileName for output file
722 name = setting.filename.GetName();
723 setting.t0 = 0.0;
724 } else {
725 info = labels->GetLabel(fileIndex);
726 name = (info->title);
727 setting.t0 = info->selectedRegion.t0();
728 }
729
730 // Figure out the ending time
731 if( info && !info->selectedRegion.isPoint() ) {
732 setting.t1 = info->selectedRegion.t1();
733 } else if( fileIndex < numLabels - 1 ) {
734 // Use start of next label as end
735 const LabelStruct *info1 = labels->GetLabel(fileIndex+1);
736 setting.t1 = info1->selectedRegion.t0();
737 } else {
738 setting.t1 = tracks.GetEndTime();
739 }
740
741 if( name.empty() )
742 name = _("untitled");
743
744 // store title of label to use in tags
745 title = name;
746
747 // Numbering files...
748 if( !byName ) {
749 name.Printf(wxT("%s-%02d"), prefix, fileIndex + 1);
750 } else if( addNumber ) {
751 // Following discussion with GA, always have 2 digits
752 // for easy file-name sorting (on Windows)
753 name.Prepend(wxString::Format(wxT("%02d-"), fileIndex + 1));
754 }
756
757 setting.filename.SetName(name);
758 {
759 // FIXME: TRAP_ERR User could have given an illegal filename prefix.
760 // in that case we should tell them, not fail silently.
761 wxASSERT(setting.filename.IsOk()); // burp if file name is broke
762
763 // Make sure the (final) file name is unique within the set of exports
764 FileNames::MakeNameUnique(otherNames, setting.filename);
765
766 /* do the metadata for this file */
767 // copy project metadata to start with
768 if (exportSettings.empty())
769 {
770 setting.tags = Tags::Get( mProject );
771 setting.tags.LoadDefaults();
772 }
773 else
774 setting.tags = exportSettings.back().tags;
775 // over-ride with values
776 setting.tags.SetTag(TAG_TITLE, title);
777 setting.tags.SetTag(TAG_TRACK, fileIndex+1);
778 }
779
780 /* add the settings to the array of settings to be used for export */
781 exportSettings.push_back(setting);
782
783 fileIndex++; // next label, count up one
784 }
785 std::swap(mExportSettings, exportSettings);
786}
static const auto title
#define TAG_TRACK
Definition: Tags.h:61
#define TAG_TITLE
Definition: Tags.h:58
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 bool SanitiseFilename(wxString &name, const wxString &sub)
Check a proposed file name string for illegal characters and remove them return true iff name is "vis...
Definition: Internat.cpp:215
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:40
wxString title
Definition: LabelTrack.h:81
SelectedRegion selectedRegion
Definition: LabelTrack.h:80
double t1() const
bool isPoint() const
double t0() const
static Tags & Get(AudacityProject &project)
Definition: Tags.cpp:214
FILES_API void MakeNameUnique(FilePaths &otherNames, wxFileName &newName)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References _, details::begin(), ExportAudioDialog::ExportSetting::channels, ExportAudioDialog::ExportSetting::filename, Tags::Get(), TrackList::Get(), ExportFilePanel::GetChannels(), ExportPlugin::GetFormatInfo(), ExportFilePanel::GetFullName(), ExportFilePanel::GetPath(), SelectedRegion::isPoint(), Tags::LoadDefaults(), FileNames::MakeNameUnique(), mExportOptionsPanel, mExportSettings, mIncludeAudioBeforeFirstLabel, mProject, name, Internat::SanitiseFilename(), LabelStruct::selectedRegion, Tags::SetTag(), anonymous_namespace{NoteTrack.cpp}::swap(), SelectedRegion::t0(), ExportAudioDialog::ExportSetting::t0, SelectedRegion::t1(), ExportAudioDialog::ExportSetting::t1, TAG_TITLE, TAG_TRACK, ExportAudioDialog::ExportSetting::tags, LabelStruct::title, title, tracks, and wxT().

Referenced by UpdateExportSettings().

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

◆ UpdateTrackExportSettings()

void ExportAudioDialog::UpdateTrackExportSettings ( const ExportPlugin plugin,
int  formatIndex,
bool  byName,
bool  addNumber,
const wxString &  prefix 
)
private

Definition at line 788 of file ExportAudioDialog.cpp.

790{
792
793 bool anySolo = !(( tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo ).empty());
794
795 auto waveTracks = tracks.Any<WaveTrack>() -
797
798 const auto numWaveTracks = waveTracks.size();
799
800 auto fileIndex = 0; // track counter
801 FilePaths otherNames;
802 auto formatInfo = plugin.GetFormatInfo(formatIndex);
803 std::vector<ExportSetting> exportSettings; // dynamic array we will use to store the
804 // settings needed to do the exports with in
805 exportSettings.reserve(numWaveTracks); // Allocate some guessed space to use.
806 ExportSetting setting; // the current batch of settings
807 setting.filename.SetPath(mExportOptionsPanel->GetPath());
808 setting.filename.SetExt(wxFileName{mExportOptionsPanel->GetFullName()}.GetExt());
809
810 wxString name; // used to hold file name whilst we mess with it
811 wxString title; // un-messed-with title of file for tagging with
812
813 const auto skipSilenceAtBeginning = mSkipSilenceAtBeginning->GetValue();
814
815 /* Examine all tracks in turn, collecting export information */
816 for (auto tr : waveTracks) {
817
818 // Get the times for the track
819 setting.t0 = skipSilenceAtBeginning ? tr->GetStartTime() : 0;
820 setting.t1 = tr->GetEndTime();
821
822 setting.channels = mExportOptionsPanel->GetChannels();
823 // Get name and title
824 title = tr->GetName();
825 if( title.empty() )
826 title = _("untitled");
827
828 if (byName) {
829 name = title;
830 if (addNumber) {
831 name.Prepend(
832 wxString::Format(wxT("%02d-"), fileIndex+1));
833 }
834 }
835 else {
836 name = (wxString::Format(wxT("%s-%02d"), prefix, fileIndex+1));
837 }
838
840 // store sanitised and user checked name in object
841 setting.filename.SetName(name);
842
843 // FIXME: TRAP_ERR User could have given an illegal track name.
844 // in that case we should tell them, not fail silently.
845 wxASSERT(setting.filename.IsOk()); // burp if file name is broke
846
847 // Make sure the (final) file name is unique within the set of exports
848 FileNames::MakeNameUnique(otherNames, setting.filename);
849
850 /* do the metadata for this file */
851 // copy project metadata to start with
852
853 if(exportSettings.empty())
854 {
855 setting.tags = Tags::Get( mProject );
856 setting.tags.LoadDefaults();
857 }
858 else
859 setting.tags = exportSettings.back().tags;
860
861 // over-ride with values
862 setting.tags.SetTag(TAG_TITLE, title);
863 setting.tags.SetTag(TAG_TRACK, fileIndex + 1);
864
865 exportSettings.push_back(setting);
866
867 fileIndex++; // next track, count up one
868 }
869 std::swap(mExportSettings, exportSettings);
870}

References _, ExportAudioDialog::ExportSetting::channels, ExportAudioDialog::ExportSetting::filename, Tags::Get(), TrackList::Get(), ExportFilePanel::GetChannels(), ExportPlugin::GetFormatInfo(), ExportFilePanel::GetFullName(), WaveTrack::GetMute(), PlayableTrack::GetNotSolo(), ExportFilePanel::GetPath(), WaveTrack::GetSolo(), Tags::LoadDefaults(), FileNames::MakeNameUnique(), mExportOptionsPanel, mExportSettings, mProject, mSkipSilenceAtBeginning, name, Internat::SanitiseFilename(), Tags::SetTag(), anonymous_namespace{NoteTrack.cpp}::swap(), ExportAudioDialog::ExportSetting::t0, ExportAudioDialog::ExportSetting::t1, TAG_TITLE, TAG_TRACK, ExportAudioDialog::ExportSetting::tags, title, tracks, and wxT().

Referenced by UpdateExportSettings().

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

Member Data Documentation

◆ mEditMetadata

wxButton* ExportAudioDialog::mEditMetadata {}
private

Definition at line 121 of file ExportAudioDialog.h.

Referenced by OnFormatChange(), and PopulateOrExchange().

◆ mExportOptionsPanel

ExportFilePanel* ExportAudioDialog::mExportOptionsPanel {}
private

◆ mExportRangeSelection

wxRadioButton* ExportAudioDialog::mExportRangeSelection {}
private

Definition at line 127 of file ExportAudioDialog.h.

◆ mExportSettings

std::vector<ExportSetting> ExportAudioDialog::mExportSettings
private

◆ mExportSettingsDirty

bool ExportAudioDialog::mExportSettingsDirty {true}
private

◆ mIncludeAudioBeforeFirstLabel

wxCheckBox* ExportAudioDialog::mIncludeAudioBeforeFirstLabel {}
private

◆ mOverwriteExisting

wxCheckBox* ExportAudioDialog::mOverwriteExisting {}
private

Definition at line 133 of file ExportAudioDialog.h.

Referenced by DoExport(), and PopulateOrExchange().

◆ mProject

AudacityProject& ExportAudioDialog::mProject
private

◆ mRangeProject

wxRadioButton* ExportAudioDialog::mRangeProject
private

Definition at line 122 of file ExportAudioDialog.h.

Referenced by PopulateOrExchange().

◆ mRangeSelection

wxRadioButton* ExportAudioDialog::mRangeSelection {}
private

Definition at line 123 of file ExportAudioDialog.h.

Referenced by OnExport(), and PopulateOrExchange().

◆ mRangeSplit

wxRadioButton* ExportAudioDialog::mRangeSplit {}
private

◆ mSkipSilenceAtBeginning

wxCheckBox* ExportAudioDialog::mSkipSilenceAtBeginning {}
private

Definition at line 134 of file ExportAudioDialog.h.

Referenced by OnExport(), PopulateOrExchange(), and UpdateTrackExportSettings().

◆ mSplitByLabels

wxRadioButton* ExportAudioDialog::mSplitByLabels {}
private

Definition at line 125 of file ExportAudioDialog.h.

Referenced by OnExport(), PopulateOrExchange(), and UpdateExportSettings().

◆ mSplitByTracks

wxRadioButton* ExportAudioDialog::mSplitByTracks {}
private

Definition at line 126 of file ExportAudioDialog.h.

Referenced by OnExport(), PopulateOrExchange(), and UpdateExportSettings().

◆ mSplitFileNamePrefix

wxTextCtrl* ExportAudioDialog::mSplitFileNamePrefix {}
private

◆ mSplitModeLabels

wxRadioButton* ExportAudioDialog::mSplitModeLabels {}
private

Definition at line 129 of file ExportAudioDialog.h.

◆ mSplitModeTracks

wxRadioButton* ExportAudioDialog::mSplitModeTracks {}
private

Definition at line 128 of file ExportAudioDialog.h.

◆ mSplitsPanel

wxWindow* ExportAudioDialog::mSplitsPanel {}
private

Definition at line 118 of file ExportAudioDialog.h.

Referenced by OnExportRangeChange(), and PopulateOrExchange().

◆ mSplitUseName

wxRadioButton* ExportAudioDialog::mSplitUseName {}
private

Definition at line 130 of file ExportAudioDialog.h.

Referenced by PopulateOrExchange(), and UpdateExportSettings().

◆ mSplitUseNumAndName

wxRadioButton* ExportAudioDialog::mSplitUseNumAndName {}
private

Definition at line 131 of file ExportAudioDialog.h.

Referenced by PopulateOrExchange(), and UpdateExportSettings().

◆ mSplitUseNumAndPrefix

wxRadioButton* ExportAudioDialog::mSplitUseNumAndPrefix {}
private

Definition at line 132 of file ExportAudioDialog.h.

Referenced by PopulateOrExchange().


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