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 160 of file ExportAudioDialog.cpp.

165 : wxDialogWrapper(parent, wxID_ANY, XO("Export Audio"))
167{
169
172
173 SetMinSize({GetBestSize().GetWidth(), -1});
174
175 wxFileName filename;
176 auto exportPath = ExportAudioDefaultPath.Read();
177 if(exportPath.empty())
178 exportPath = FileNames::FindDefaultPath(FileNames::Operation::Export);
179 filename.SetPath(exportPath);
180
181 //extension will be set in `ChangeFormat`
182 filename.SetEmptyExt();
183 if(defaultName.empty())
184 //i18n-hint: default exported file name when exporting from unsaved project
185 filename.SetName(_("untitled"));
186 else
187 filename.SetName(defaultName);
188
191 {
193 for(const auto track : tracks.Any<WaveTrack>())
194 sampleRate = std::max(sampleRate, track->GetRate());
195 }
196
197 wxString format = defaultFormat;
198 if(format.empty())
200
202
204 const auto labelTracks = tracks.Any<LabelTrack>();
205 const auto hasLabels = !labelTracks.empty() &&
206 (*labelTracks.begin())->GetNumLabels() > 0;
207 const auto hasMultipleWaveTracks = tracks.Any<WaveTrack>().size() > 1;
208 const auto hasSelectedAudio = ExportUtils::HasSelectedAudio(mProject);
209
210 mRangeSelection->Enable(hasSelectedAudio);
211 mRangeSplit->Enable(hasLabels || hasMultipleWaveTracks);
212
213 mSplitByLabels->Enable(hasLabels);
214 mSplitByTracks->Enable(hasMultipleWaveTracks);
215
216 if(mRangeSelection->IsEnabled() && mode == ExportMode::SelectedOnly)
217 {
218 mRangeSelection->SetValue(true);
219 }
220 else
221 {
222 if(!mRangeSelection->IsEnabled() && ExportAudioExportRange.Read() == "selection")
223 mRangeProject->SetValue(true);
224
225 if(!mRangeSplit->IsEnabled() && ExportAudioExportRange.Read() == "split")
226 mRangeProject->SetValue(true);
227
228 if(!hasLabels && hasMultipleWaveTracks)
229 mSplitByTracks->SetValue(true);
230 if (!hasMultipleWaveTracks && hasLabels)
231 mSplitByLabels->SetValue(true);
232 }
233
234 if (mRangeSelection->IsEnabled() && !hasLabels && !hasMultipleWaveTracks)
235 mRangeSelection->MoveAfterInTabOrder(mRangeProject);
236
237 if (ExportAudioExportRange.Read() != "split" || (!hasLabels && !hasMultipleWaveTracks))
238 mSplitsPanel->Hide();
239
241
243
244 if(ExportAudioSplitNamePolicy.Read() != "num_and_prefix")
245 mSplitFileNamePrefix->Disable();
246
247 Layout();
248 Fit();
249 Center();
250}
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:95
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(), TrackList::Get(), ImportExport::GetPreferredExportRate(), 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 969 of file ExportAudioDialog.cpp.

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

871{
872 auto ok = ExportResult::Success; // did it work?
873 /* Go round again and do the exporting (so this run is slow but
874 * non-interactive) */
875 for(auto& activeSetting : mExportSettings)
876 {
877 /* get the settings to use for the export from the array */
878 // Bug 1440 fix.
879 if( activeSetting.filename.GetName().empty() )
880 continue;
881
882 // Export it
883 ok = DoExport(plugin, formatIndex, parameters, activeSetting.filename, activeSetting.channels,
884 activeSetting.t0, activeSetting.t1, false, activeSetting.tags, exporterFiles);
885
886 if (ok == ExportResult::Stopped) {
887 AudacityMessageDialog dlgMessage(
888 nullptr,
889 XO("Continue to export remaining files?"),
890 XO("Export"),
891 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
892 if (dlgMessage.ShowModal() != wxID_YES ) {
893 // User decided not to continue - bail out!
894 break;
895 }
896 }
897 else if (ok != ExportResult::Success) {
898 break;
899 }
900 }
901
902 return ok;
903}
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 905 of file ExportAudioDialog.cpp.

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

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 447 of file ExportAudioDialog.cpp.

448{
449 if(mRangeSplit->GetValue())
450 {
452
453 std::vector<Tags*> tags;
454 std::vector<wxString> names;
455 tags.reserve(mExportSettings.size());
456 names.reserve(mExportSettings.size());
457 for(auto& spec : mExportSettings)
458 {
459 tags.push_back(&spec.tags);
460 names.push_back(spec.filename.GetFullName());
461 }
462 TagsEditorDialog dialog(this, XO("Edit Metadata Tags"), tags, names, true, true);
463 dialog.ShowModal();
464 }
465 else
466 {
468 XO("Edit Metadata Tags"), XO("Exported Tags"));
469 }
470}
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 477 of file ExportAudioDialog.cpp.

478{
479 auto selectedPlugin = mExportOptionsPanel->GetPlugin();
480 if(selectedPlugin == nullptr)
481 return;
482 auto selectedFormat = mExportOptionsPanel->GetFormat();
483 auto parameters = mExportOptionsPanel->GetParameters();
484 if(!parameters.has_value())
485 return;
486
487 const auto path = mExportOptionsPanel->GetPath();
488
489 if(!wxDirExists(path))
490 wxFileName::Mkdir(path, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
491
492 if(!wxDirExists(path))
493 {
494 AudacityMessageBox(XO("Unable to create destination folder"),
495 XO("Export Audio"),
496 wxOK | wxCENTER,
497 this);
498 return;
499 }
500
501 auto result = ExportResult::Error;
502
503 if(mRangeSplit->GetValue())
504 {
505 FilePaths exportedFiles;
506
508
509 if(mSplitByLabels->GetValue())
510 result = DoExportSplitByLabels(*selectedPlugin, selectedFormat, *parameters, exportedFiles);
511 else if(mSplitByTracks->GetValue())
512 result = DoExportSplitByTracks(*selectedPlugin, selectedFormat, *parameters, exportedFiles);
513
514 auto msg = (result == ExportResult::Success
515 ? XO("Successfully exported the following %lld file(s).")
516 : result == ExportResult::Error
517 ? XO("Something went wrong after exporting the following %lld file(s).")
518 : result == ExportResult::Cancelled
519 ? XO("Export canceled after exporting the following %lld file(s).")
520 : result == ExportResult::Stopped
521 ? XO("Export stopped after exporting the following %lld file(s).")
522 : XO("Something went really wrong after exporting the following %lld file(s).")
523 ).Format((long long) exportedFiles.size());
524
525 wxString fileList;
526 for (auto& path : exportedFiles)
527 fileList += path + '\n';
528
529 // TODO: give some warning dialog first, when only some files exported
530 // successfully.
531
533 XO("Export Audio"),
534 msg,
535 fileList,
536 450,400);
537 }
538 else
539 {
540 wxFileName filename(path, mExportOptionsPanel->GetFullName());
541
542 if (filename.FileExists()) {
543 auto result = AudacityMessageBox(
544 XO("A file named \"%s\" already exists. Replace?")
545 .Format( filename.GetFullPath() ),
546 XO("Export Audio"),
547 wxYES_NO | wxICON_EXCLAMATION);
548 if (result != wxYES) {
549 return;
550 }
551 }
552
553 ExportTaskBuilder builder;
554 builder.SetFileName(filename)
555 .SetPlugin(selectedPlugin, selectedFormat)
556 .SetParameters(*parameters)
558
559 const auto& viewInfo = ViewInfo::Get(mProject);
560
561 const auto selectedOnly = mRangeSelection->GetValue();
562
563 auto t0 = selectedOnly
564 ? std::max(.0, viewInfo.selectedRegion.t0())
565 : .0;
566
567 auto t1 = selectedOnly
568 ? std::min(TrackList::Get(mProject).GetEndTime(), viewInfo.selectedRegion.t1())
569 : TrackList::Get(mProject).GetEndTime();
570
571 auto exportedTracks = ExportUtils::FindExportWaveTracks(TrackList::Get(mProject), selectedOnly);
572 if(exportedTracks.empty())
573 {
575 selectedOnly ? XO("All selected audio is muted.") : XO("All audio is muted."), //":576"
576 XO("Warning"),
577 false);
578 return;
579 }
580
581 if(mSkipSilenceAtBeginning->GetValue())
582 t0 = std::max(t0, exportedTracks.min(&Track::GetStartTime));
583
584 builder.SetRange(t0, t1, selectedOnly);
585
586 std::unique_ptr<MixerOptions::Downmix> tempMixerSpec;
587 const auto channels = mExportOptionsPanel->GetChannels();
588 if(channels == 0)
589 {
590 //Figure out the final channel mapping: mixer dialog shows
591 //all tracks regardless of their mute/solo state, but
592 //muted channels should not be present in exported file -
593 //apply channel mask to exclude them
595 std::vector<bool> channelMask(
596 tracks.sum([](const auto track) { return track->NChannels(); }),
597 false);
598 unsigned trackIndex = 0;
599 for(const auto track : tracks)
600 {
601 if(track->GetSolo())
602 {
603 channelMask.assign(channelMask.size(), false);
604 for(unsigned i = 0; i < track->NChannels(); ++i)
605 channelMask[trackIndex++] = true;
606 break;
607 }
608 if(!track->GetMute() && (!selectedOnly || track->GetSelected()))
609 {
610 for(unsigned i = 0; i < track->NChannels(); ++i)
611 channelMask[trackIndex++] = true;
612 }
613 else
614 trackIndex += track->NChannels();
615 }
616
617 tempMixerSpec = std::make_unique<MixerOptions::Downmix>(*mExportOptionsPanel->GetMixerSpec(), channelMask);
618 builder.SetMixerSpec(tempMixerSpec.get());
619 }
620 else
621 builder.SetNumChannels(channels);
622
624 {
625 result = ExportProgressUI::Show(builder.Build(mProject));
626 });
627 }
628
629 if(result == ExportResult::Success || result == ExportResult::Stopped)
630 {
632
633 ExportAudioDefaultFormat.Write(selectedPlugin->GetFormatInfo(selectedFormat).format);
635
638 event.Skip();
639 }
640}
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 407 of file ExportAudioDialog.cpp.

408{
409 const auto enableSplits = event.GetId() == ExportRangeSplitID;
411 if(mSplitsPanel->IsShown() != enableSplits)
412 {
414 mSplitsPanel->Show(enableSplits);
415
416 Layout();
417 Fit();
418 }
419}

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 442 of file ExportAudioDialog.cpp.

443{
445}

References mExportSettingsDirty.

◆ OnFormatChange()

void ExportAudioDialog::OnFormatChange ( wxCommandEvent &  event)
private

Definition at line 642 of file ExportAudioDialog.cpp.

643{
644 Layout();
645 Fit();
646
647 auto enableMeta = false;
648 if(auto plugin = mExportOptionsPanel->GetPlugin())
649 enableMeta = plugin->GetFormatInfo(mExportOptionsPanel->GetFormat()).canMetaData;
650 mEditMetadata->Enable(enableMeta);
652}

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 472 of file ExportAudioDialog.cpp.

473{
474 HelpSystem::ShowHelp(wxGetTopLevelParent(this), L"File_Export_Dialog", true);
475}
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 437 of file ExportAudioDialog.cpp.

438{
440}

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 432 of file ExportAudioDialog.cpp.

433{
435}

References mExportSettingsDirty.

◆ PopulateOrExchange()

void ExportAudioDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 267 of file ExportAudioDialog.cpp.

268{
269 S.SetBorder(5);
270 S.StartVerticalLay();
271 {
272 if(S.GetMode() == eIsCreating)
273 {
275 S.Id(ExportFilePanelID).AddWindow(mExportOptionsPanel, wxEXPAND);
276 }
277
278 S.StartPanel();
279 {
280 S.SetBorder(5);
281 S.StartTwoColumn();
282 {
283 S.StartHorizontalLay(wxSHRINK | wxALIGN_TOP);
284 {
285 if(auto prompt = S.AddPrompt(XO("Export Range:")))
286 prompt->SetMinSize({145, -1});
287 }
288 S.EndHorizontalLay();
289
290 S.StartVerticalLay();
291 {
292 S.StartRadioButtonGroup(ExportAudioExportRange);
293 {
295 .Name(XO("Export entire project"))
296 .TieRadioButton();
298 .Name(XO("Export multiple files"))
299 .TieRadioButton();
301 .Name(XO("Export current selection"))
302 .TieRadioButton();
303#if wxUSE_ACCESSIBILITY
307#endif
308 }
309 S.EndRadioButtonGroup();
310 }
311 S.EndVerticalLay();
312 }
313 S.EndTwoColumn();
314
315 S.AddSpace(10);
316
317 S.StartTwoColumn();
318 {
319 S.AddSpace(155, 1);
322 .TieCheckBox(XO("Trim blank space before first clip"), ExportAudioSkipSilenceAtBeginning);
323 }
324 S.EndTwoColumn();
325 }
326 S.EndPanel();
327
328 S.SetBorder(5);
329 mSplitsPanel = S.StartPanel();
330 {
331 S.StartMultiColumn(2);
332 {
333 S.StartStatic(XO("Split files based on:"));
334 {
335 S.StartVerticalLay();
336 {
337 S.StartRadioButtonGroup(ExportAudioSplitMode);
338 {
339 mSplitByTracks = S.Id(ExportModeTracksID).TieRadioButton();
340 mSplitByLabels = S.Id(ExportModeLabelsID).TieRadioButton();
341 }
342 S.EndRadioButtonGroup();
343
344 S.StartHorizontalLay(wxALIGN_TOP);
345 {
346 S.AddSpace(10, 1);
349 .TieCheckBox(XO("Include audio before first label"), ExportAudioIncludeAudioBeforeFirstLabel);
350 }
351 S.EndHorizontalLay();
352 }
353 S.EndVerticalLay();
354 }
355 S.EndStatic();
356
357 S.StartStatic(XO("Name files:"));
358 {
359 S.StartVerticalLay();
360 {
361 S.StartRadioButtonGroup(ExportAudioSplitNamePolicy);
362 {
363 mSplitUseName = S.Id(ExportSplitNamePolicyTrackNameID).TieRadioButton();
366 }
367 S.EndRadioButtonGroup();
368 S.StartHorizontalLay(wxALIGN_TOP);
369 {
370 S.AddSpace(10, 1);
373 .AddTextBox(XO("File name prefix:"), {}, 0);
374 }
375 S.EndHorizontalLay();
376 }
377 S.EndVerticalLay();
378 }
379 S.EndStatic();
380 }
381 S.EndMultiColumn();
382
385 .TieCheckBox(XO("Overwrite existing files"), ExportAudioOverwriteExisting);
386 }
387 S.EndPanel();
388
389 S.AddSpace(1, 10);
390
391 S.SetBorder(5);
392
393 S.SetBorder(5);
394 S.StartHorizontalLay(wxEXPAND);
395 {
396 mEditMetadata = S.Id(EditMetadataID).AddButton(XO("Edit &Metadata..."), wxLEFT | wxBOTTOM);
397 S.AddSpace(1, 1, wxEXPAND);
398 S.Id(wxID_CANCEL).AddButton(XO("&Cancel"), wxBOTTOM);
399 S.Id(wxID_OK).AddButton(XO("&Export"), wxRIGHT | wxBOTTOM, true);
400 }
401 S.EndHorizontalLay();
402 }
403 S.EndVerticalLay();
404}
#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 255 of file ExportAudioDialog.cpp.

256{
257 bool ret = wxDialogWrapper::Show(show);
258
259#if defined(__WXMSW__)
260 if (show)
262#endif
263
264 return ret;
265}

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

Here is the call graph for this function:

◆ UpdateExportSettings()

void ExportAudioDialog::UpdateExportSettings ( )
private

Definition at line 654 of file ExportAudioDialog.cpp.

655{
657 return;
658
659 const auto selectedPlugin = mExportOptionsPanel->GetPlugin();
660 if(selectedPlugin == nullptr)
661 return;
662
663 const auto selectedFormat = mExportOptionsPanel->GetFormat();
664
665 if(mRangeSplit->GetValue())
666 {
667 const auto byName = mSplitUseName->GetValue() || mSplitUseNumAndName->GetValue();
668 const auto addNumber = mSplitUseNumAndName->GetValue();
669 const auto prefix = mSplitFileNamePrefix->GetValue();
670
671 if(mSplitByLabels->GetValue())
672 UpdateLabelExportSettings(*selectedPlugin, selectedFormat, byName, addNumber, prefix);
673 else if(mSplitByTracks->GetValue())
674 UpdateTrackExportSettings(*selectedPlugin, selectedFormat, byName, addNumber, prefix);
675
676 mExportSettingsDirty = false;
677 }
678}
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 680 of file ExportAudioDialog.cpp.

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

References _, details::begin(), ExportAudioDialog::ExportSetting::channels, TranslatableString::empty(), 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 783 of file ExportAudioDialog.cpp.

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

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: