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

Presents a dialog box allowing the user to export multiple files either by exporting each track as a separate file, or by exporting each label as a separate file. More...

#include <ExportMultiple.h>

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

Public Types

using ProgressResult = BasicUI::ProgressResult
 

Public Member Functions

 ExportMultipleDialog (AudacityProject *parent)
 
virtual ~ExportMultipleDialog ()
 
int ShowModal ()
 
- 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 CanExport ()
 
void CountTracksAndLabels ()
 
bool DirOk ()
 
ProgressResult ExportMultipleByLabel (bool byName, const wxString &prefix, bool addNumber)
 Export multiple labeled regions of the project to separate files. More...
 
ProgressResult ExportMultipleByTrack (bool byName, const wxString &prefix, bool addNumber)
 Export each track in the project to a separate file. More...
 
ProgressResult DoExport (std::unique_ptr< BasicUI::ProgressDialog > &pDialog, unsigned channels, const wxFileName &name, bool selectedOnly, double t0, double t1, const Tags &tags)
 
wxString MakeFileName (const wxString &input)
 Takes an arbitrary text string and converts it to a form that can be used as a file name, if necessary prompting the user to edit the file name produced. More...
 
void PopulateOrExchange (ShuttleGui &S)
 
void EnableControls ()
 
void OnFormat (wxCommandEvent &event)
 
void OnOptions (wxCommandEvent &event)
 
void OnCreate (wxCommandEvent &event)
 
void OnChoose (wxCommandEvent &event)
 
void OnLabel (wxCommandEvent &event)
 
void OnFirst (wxCommandEvent &event)
 
void OnFirstFileName (wxCommandEvent &event)
 
void OnTrack (wxCommandEvent &event)
 
void OnByName (wxCommandEvent &event)
 
void OnByNumber (wxCommandEvent &event)
 
void OnPrefix (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 

Private Attributes

Exporter mExporter
 
std::vector< ExportPlugin * > mPlugins
 
AudacityProjectmProject
 
TrackListmTracks
 
const LabelTrackmLabels
 
int mNumLabels
 
int mNumWaveTracks
 
int mFilterIndex
 
int mPluginIndex
 
int mSubFormatIndex
 
bool mInitialized
 
FilePaths mExported
 
wxChoice * mFormat
 
wxButton * mOptions
 
wxTextCtrl * mDir
 
wxButton * mCreate
 
wxButton * mChoose
 
wxRadioButton * mLabel
 
wxStaticText * mLabelLabel
 
wxCheckBox * mFirst
 
wxStaticText * mFirstFileLabel
 
wxTextCtrl * mFirstFileName
 
wxRadioButton * mTrack
 
wxStaticText * mTrackLabel
 
wxRadioButton * mByNumberAndName
 
wxRadioButton * mByName
 
wxRadioButton * mByNumber
 
wxStaticText * mPrefixLabel
 
wxTextCtrl * mPrefix
 
wxCheckBox * mOverwrite
 
wxButton * mCancel
 
wxButton * mExport
 
wxSimplebook * mBook
 
SelectionStatemSelectionState
 

Detailed Description

Presents a dialog box allowing the user to export multiple files either by exporting each track as a separate file, or by exporting each label as a separate file.

Definition at line 32 of file ExportMultiple.h.

Member Typedef Documentation

◆ ProgressResult

Definition at line 35 of file ExportMultiple.h.

Constructor & Destructor Documentation

◆ ExportMultipleDialog()

ExportMultipleDialog::ExportMultipleDialog ( AudacityProject parent)

◆ ~ExportMultipleDialog()

ExportMultipleDialog::~ExportMultipleDialog ( )
virtual

Definition at line 162 of file ExportMultiple.cpp.

163{
164}

Member Function Documentation

◆ CanExport()

void ExportMultipleDialog::CanExport ( )
private

◆ CountTracksAndLabels()

void ExportMultipleDialog::CountTracksAndLabels ( )
private

Definition at line 166 of file ExportMultiple.cpp.

167{
168 bool anySolo =
169 !(mTracks->Leaders<const WaveTrack>() + &WaveTrack::GetSolo).empty();
170
172 (mTracks->Leaders< const WaveTrack >() -
174
175 // only the first label track
176 mLabels = *mTracks->Leaders<const LabelTrack>().begin();
178}
const LabelTrack * mLabels
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
int GetNumLabels() const
Definition: LabelTrack.cpp:945
bool GetNotSolo() const
Definition: PlayableTrack.h:50
auto Leaders() -> TrackIterRange< TrackType >
Definition: Track.h:1147
A Track that contains audio waveform data.
Definition: WaveTrack.h:59
bool GetMute() const override
May vary asynchronously.
Definition: WaveTrack.cpp:1930
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:1935
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), WaveTrack::GetMute(), PlayableTrack::GetNotSolo(), LabelTrack::GetNumLabels(), WaveTrack::GetSolo(), TrackList::Leaders(), mLabels, mNumLabels, mNumWaveTracks, mTracks, and size.

Here is the call graph for this function:

◆ DirOk()

bool ExportMultipleDialog::DirOk ( )
private

Definition at line 677 of file ExportMultiple.cpp.

678{
679 wxFileName fn;
680
681 fn.AssignDir(mDir->GetValue());
682
683 if (fn.DirExists()) {
684 return true;
685 }
686
687 auto prompt = XO("\"%s\" doesn't exist.\n\nWould you like to create it?")
688 .Format( fn.GetFullPath() );
689
690 int action = AudacityMessageBox(
691 prompt,
692 XO("Warning"),
693 wxYES_NO | wxICON_EXCLAMATION);
694 if (action != wxYES) {
695 return false;
696 }
697
698 return fn.Mkdir(0777, wxPATH_MKDIR_FULL);
699}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
static const auto fn

References AudacityMessageBox(), fn, mDir, and XO().

Referenced by OnExport().

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

◆ DoExport()

ProgressResult ExportMultipleDialog::DoExport ( std::unique_ptr< BasicUI::ProgressDialog > &  pDialog,
unsigned  channels,
const wxFileName &  name,
bool  selectedOnly,
double  t0,
double  t1,
const Tags tags 
)
private

Export one file of an export multiple set

Called once for each file in the list to do a (non-interactive) export

Parameters
channelsNumber of channels to export
nameThe file name (and path) to export to
selectedOnlyShould we export the selected tracks only?
t0Start time for export
t1End time for export
tagsMetadata to include in the file (if possible).

Definition at line 1024 of file ExportMultiple.cpp.

1031{
1032 wxFileName name;
1033
1034 wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (inName.GetFullName()));
1035 wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1);
1036 if (selectedOnly)
1037 wxLogDebug(wxT("Selected Region Only"));
1038 else
1039 wxLogDebug(wxT("Whole Project"));
1040
1041 wxFileName backup;
1042 if (mOverwrite->GetValue()) {
1043 name = inName;
1044 backup.Assign(name);
1045
1046 int suffix = 0;
1047 do {
1048 backup.SetName(name.GetName() +
1049 wxString::Format(wxT("%d"), suffix));
1050 ++suffix;
1051 }
1052 while (backup.FileExists());
1053 ::wxRenameFile(inName.GetFullPath(), backup.GetFullPath());
1054 }
1055 else {
1056 name = inName;
1057 int i = 2;
1058 wxString base(name.GetName());
1059 while (name.FileExists()) {
1060 name.SetName(wxString::Format(wxT("%s-%d"), base, i++));
1061 }
1062 }
1063
1065 const wxString fullPath{name.GetFullPath()};
1066
1067 auto cleanup = finally( [&] {
1068 bool ok =
1069 success == ProgressResult::Stopped ||
1070 success == ProgressResult::Success;
1071 if (backup.IsOk()) {
1072 if ( ok )
1073 // Remove backup
1074 ::wxRemoveFile(backup.GetFullPath());
1075 else {
1076 // Restore original
1077 ::wxRemoveFile(fullPath);
1078 ::wxRenameFile(backup.GetFullPath(), fullPath);
1079 }
1080 }
1081 else {
1082 if ( ! ok )
1083 // Remove any new, and only partially written, file.
1084 ::wxRemoveFile(fullPath);
1085 }
1086 } );
1087
1088 // Call the format export routine
1089 success = mPlugins[mPluginIndex]->Export(mProject,
1090 pDialog,
1091 channels,
1092 fullPath,
1093 selectedOnly,
1094 t0,
1095 t1,
1096 NULL,
1097 &tags,
1099
1100 if (success == ProgressResult::Success || success == ProgressResult::Stopped) {
1101 mExported.push_back(fullPath);
1102 }
1103
1104 Refresh();
1105 Update();
1106
1107 return success;
1108}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
std::vector< ExportPlugin * > mPlugins
wxCheckBox * mOverwrite
AudacityProject * mProject
ProgressResult
Definition: BasicUI.h:147

References RefreshCode::Cancelled, mOverwrite, name, BasicUI::Success, and wxT().

Referenced by ExportMultipleByLabel(), and ExportMultipleByTrack().

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

◆ EnableControls()

void ExportMultipleDialog::EnableControls ( )
private

Definition at line 449 of file ExportMultiple.cpp.

450{
451 bool enable;
452
453 if (!mInitialized) {
454 return;
455 }
456
457 mFirst->Enable(mLabel->GetValue());
458
459 enable = mLabel->GetValue() &&
460 (mByName->GetValue() || mByNumberAndName->GetValue()) &&
461 mFirst->GetValue();
462 mFirstFileLabel->Enable(enable);
463 mFirstFileName->Enable(enable);
464
465 enable = mByNumber->GetValue();
466 mPrefixLabel->Enable(enable);
467 mPrefix->Enable(enable);
468
469 bool ok = true;
470
471 if (mLabel->GetValue() && mFirst->GetValue() &&
472 mFirstFileName->GetValue().empty() &&
473 mPrefix->GetValue().empty())
474 ok = false;
475
476 if (mByNumber->GetValue() &&
477 mPrefix->GetValue().empty())
478 ok = false;
479
480 mExport->Enable(ok);
481}
wxTextCtrl * mFirstFileName
wxRadioButton * mByName
wxRadioButton * mLabel
wxStaticText * mFirstFileLabel
wxRadioButton * mByNumberAndName
wxStaticText * mPrefixLabel
wxRadioButton * mByNumber

References mByName, mByNumber, mByNumberAndName, mExport, mFirst, mFirstFileLabel, mFirstFileName, mInitialized, mLabel, mPrefix, and mPrefixLabel.

Referenced by OnByName(), OnByNumber(), OnFirst(), OnFirstFileName(), OnFormat(), OnLabel(), OnPrefix(), OnTrack(), and ShowModal().

Here is the caller graph for this function:

◆ ExportMultipleByLabel()

ProgressResult ExportMultipleDialog::ExportMultipleByLabel ( bool  byName,
const wxString &  prefix,
bool  addNumber 
)
private

Export multiple labeled regions of the project to separate files.

Uses a single label track in the project to split up the audio into a series of sections, each of which is exported to a separate file.

Parameters
byNameControls whether files are named after the text in the labels that define them (true), or just numbered (false).
prefixThe string used to prefix the file number if files are being numbered rather than named

Definition at line 718 of file ExportMultiple.cpp.

720{
721 wxASSERT(mProject);
722 int numFiles = mNumLabels;
723 int l = 0; // counter for files done
724 std::vector<ExportKit> exportSettings; // dynamic array for settings.
725 exportSettings.reserve(numFiles); // Allocate some guessed space to use.
726
727 // Account for exporting before first label
728 if( mFirst->GetValue() ) {
729 l--;
730 numFiles++;
731 }
732
733 // Figure out how many channels we should export.
734 auto channels = GetNumExportChannels( *mTracks );
735
736 FilePaths otherNames; // keep track of file names we will use, so we
737 // don't duplicate them
738 ExportKit setting; // the current batch of settings
739 setting.destfile.SetPath(mDir->GetValue());
740 setting.destfile.SetExt(mPlugins[mPluginIndex]->GetExtension(mSubFormatIndex));
741 wxLogDebug(wxT("Plug-in index = %d, Sub-format = %d"), mPluginIndex, mSubFormatIndex);
742 wxLogDebug(wxT("File extension is %s"), setting.destfile.GetExt());
743 wxString name; // used to hold file name whilst we mess with it
744 wxString title; // un-messed-with title of file for tagging with
745
746 const LabelStruct *info = NULL;
747 /* Examine all labels a first time, sort out all data but don't do any
748 * exporting yet (so this run is quick but interactive) */
749 while( l < mNumLabels ) {
750
751 // Get file name and starting time
752 if( l < 0 ) {
753 // create wxFileName for output file
754 name = (mFirstFileName->GetValue());
755 setting.t0 = 0.0;
756 } else {
757 info = mLabels->GetLabel(l);
758 name = (info->title);
759 setting.t0 = info->selectedRegion.t0();
760 }
761
762 // Figure out the ending time
763 if( info && !info->selectedRegion.isPoint() ) {
764 setting.t1 = info->selectedRegion.t1();
765 } else if( l < mNumLabels-1 ) {
766 // Use start of next label as end
767 const LabelStruct *info1 = mLabels->GetLabel(l+1);
768 setting.t1 = info1->selectedRegion.t0();
769 } else {
770 setting.t1 = mTracks->GetEndTime();
771 }
772
773 if( name.empty() )
774 name = _("untitled");
775
776 // store title of label to use in tags
777 title = name;
778
779 // Numbering files...
780 if( !byName ) {
781 name.Printf(wxT("%s-%02d"), prefix, l+1);
782 } else if( addNumber ) {
783 // Following discussion with GA, always have 2 digits
784 // for easy file-name sorting (on Windows)
785 name.Prepend(wxString::Format(wxT("%02d-"), l+1));
786 }
787
788 // store sanitised and user checked name in object
789 setting.destfile.SetName(MakeFileName(name));
790 if( setting.destfile.GetName().empty() )
791 { // user cancelled dialogue, or deleted everything in field.
792 // or maybe the label was empty??
793 // So we ignore this one and keep going.
794 }
795 else
796 {
797 // FIXME: TRAP_ERR User could have given an illegal filename prefix.
798 // in that case we should tell them, not fail silently.
799 wxASSERT(setting.destfile.IsOk()); // burp if file name is broke
800
801 // Make sure the (final) file name is unique within the set of exports
802 FileNames::MakeNameUnique(otherNames, setting.destfile);
803
804 /* do the metadata for this file */
805 // copy project metadata to start with
806 setting.filetags = Tags::Get( *mProject );
807 setting.filetags.LoadDefaults();
808 if (exportSettings.size()) {
809 setting.filetags = exportSettings.back().filetags;
810 }
811 // over-ride with values
812 setting.filetags.SetTag(TAG_TITLE, title);
813 setting.filetags.SetTag(TAG_TRACK, l+1);
814 // let the user have a crack at editing it, exit if cancelled
816 bool bShowTagsDialog = settings.GetShowId3Dialog();
817
818 bShowTagsDialog = bShowTagsDialog && mPlugins[mPluginIndex]->GetCanMetaData(mSubFormatIndex);
819
820 if( bShowTagsDialog ){
821 bool bCancelled = !TagsEditorDialog::ShowEditDialog(setting.filetags,
823 XO("Edit Metadata Tags"), bShowTagsDialog);
824 gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true);
825 settings.SetShowId3Dialog( bShowTagsDialog );
826 if( bCancelled )
828 }
829 }
830
831 /* add the settings to the array of settings to be used for export */
832 exportSettings.push_back(setting);
833
834 l++; // next label, count up one
835 }
836
837 auto ok = ProgressResult::Success; // did it work?
838 int count = 0; // count the number of successful runs
839 ExportKit activeSetting; // pointer to the settings in use for this export
840 /* Go round again and do the exporting (so this run is slow but
841 * non-interactive) */
842 std::unique_ptr<BasicUI::ProgressDialog> pDialog;
843 for (count = 0; count < numFiles; count++) {
844 /* get the settings to use for the export from the array */
845 activeSetting = exportSettings[count];
846 // Bug 1440 fix.
847 if( activeSetting.destfile.GetName().empty() )
848 continue;
849
850 // Export it
851 ok = DoExport(pDialog, channels, activeSetting.destfile, false,
852 activeSetting.t0, activeSetting.t1, activeSetting.filetags);
853 if (ok == ProgressResult::Stopped) {
854 AudacityMessageDialog dlgMessage(
855 nullptr,
856 XO("Continue to export remaining files?"),
857 XO("Export"),
858 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
859 if (dlgMessage.ShowModal() != wxID_YES ) {
860 // User decided not to continue - bail out!
861 break;
862 }
863 }
864 else if (ok != ProgressResult::Success) {
865 break;
866 }
867 }
868
869 return ok;
870}
static unsigned GetNumExportChannels(const TrackList &tracks)
#define _(s)
Definition: Internat.h:73
static const auto title
FileConfig * gPrefs
Definition: Prefs.cpp:70
#define TAG_TRACK
Definition: Tags.h:61
#define TAG_TITLE
Definition: Tags.h:58
static Settings & settings()
Definition: TrackInfo.cpp:83
Wrap wxMessageDialog so that caption IS translatable.
wxString MakeFileName(const wxString &input)
Takes an arbitrary text string and converts it to a form that can be used as a file name,...
ProgressResult DoExport(std::unique_ptr< BasicUI::ProgressDialog > &pDialog, unsigned channels, const wxFileName &name, bool selectedOnly, double t0, double t1, const Tags &tags)
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:29
wxString title
Definition: LabelTrack.h:70
SelectedRegion selectedRegion
Definition: LabelTrack.h:69
const LabelStruct * GetLabel(int index) const
Definition: LabelTrack.cpp:950
static ProjectSettings & Get(AudacityProject &project)
static ProjectWindow * Find(AudacityProject *pProject)
double t1() const
bool isPoint() const
double t0() const
static AUDACITY_DLL_API bool ShowEditDialog(Tags &tags, wxWindow *parent, const TranslatableString &title, bool force=false)
Definition: TagsEditor.cpp:24
static Tags & Get(AudacityProject &project)
Definition: Tags.cpp:214
double GetEndTime() const
Definition: Track.cpp:962
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
FILES_API void MakeNameUnique(FilePaths &otherNames, wxFileName &newName)

References _, RefreshCode::Cancelled, DoExport(), TranslatableString::empty(), ProjectWindow::Find(), Tags::Get(), ProjectSettings::Get(), TrackList::GetEndTime(), LabelTrack::GetLabel(), GetNumExportChannels(), gPrefs, SelectedRegion::isPoint(), MakeFileName(), FileNames::MakeNameUnique(), mDir, mFirst, mFirstFileName, mLabels, mNumLabels, mPluginIndex, mPlugins, mProject, mSubFormatIndex, mTracks, name, LabelStruct::selectedRegion, settings(), TagsEditorDialog::ShowEditDialog(), BasicUI::Success, SelectedRegion::t0(), SelectedRegion::t1(), TAG_TITLE, TAG_TRACK, LabelStruct::title, title, wxT(), and XO().

Referenced by OnExport().

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

◆ ExportMultipleByTrack()

ProgressResult ExportMultipleDialog::ExportMultipleByTrack ( bool  byName,
const wxString &  prefix,
bool  addNumber 
)
private

Export each track in the project to a separate file.

Parameters
byNameControls whether files are named after the track names (true), or just numbered (false).
prefixThe string used to prefix the file number if files are being numbered rather than named

Definition at line 872 of file ExportMultiple.cpp.

874{
875 wxASSERT(mProject);
876 int l = 0; // track counter
877 auto ok = ProgressResult::Success;
878 FilePaths otherNames;
879 std::vector<ExportKit> exportSettings; // dynamic array we will use to store the
880 // settings needed to do the exports with in
881 exportSettings.reserve(mNumWaveTracks); // Allocate some guessed space to use.
882 ExportKit setting; // the current batch of settings
883 setting.destfile.SetPath(mDir->GetValue());
884 setting.destfile.SetExt(mPlugins[mPluginIndex]->GetExtension(mSubFormatIndex));
885
886 wxString name; // used to hold file name whilst we mess with it
887 wxString title; // un-messed-with title of file for tagging with
888
889 /* Remember which tracks were selected, and set them to deselected */
891 for (auto tr : mTracks->SelectedLeaders<WaveTrack>())
892 tr->SetSelected(false);
893
894 bool anySolo =
896
897 bool skipSilenceAtBeginning;
898 gPrefs->Read(wxT("/AudioFiles/SkipSilenceAtBeginning"), &skipSilenceAtBeginning, false);
899
900 /* Examine all tracks in turn, collecting export information */
901 for (auto tr : mTracks->Leaders<WaveTrack>() -
903
904 // Get the times for the track
905 auto channels = TrackList::Channels(tr);
906 setting.t0 = skipSilenceAtBeginning ? channels.min(&Track::GetStartTime) : 0;
907 setting.t1 = channels.max( &Track::GetEndTime );
908
909 // number of export channels?
910 // It's 1 only for a center-panned mono track
911 setting.channels = (IsMono(*tr) && tr->GetPan() == 0.0) ? 1 : 2;
912
913 // Get name and title
914 title = tr->GetName();
915 if( title.empty() )
916 title = _("untitled");
917
918 if (byName) {
919 name = title;
920 if (addNumber) {
921 name.Prepend(
922 wxString::Format(wxT("%02d-"), l+1));
923 }
924 }
925 else {
926 name = (wxString::Format(wxT("%s-%02d"), prefix, l+1));
927 }
928
929 // store sanitised and user checked name in object
930 setting.destfile.SetName(MakeFileName(name));
931
932 if (setting.destfile.GetName().empty())
933 { // user cancelled dialogue, or deleted everything in field.
934 // So we ignore this one and keep going.
935 }
936 else
937 {
938
939 // FIXME: TRAP_ERR User could have given an illegal track name.
940 // in that case we should tell them, not fail silently.
941 wxASSERT(setting.destfile.IsOk()); // burp if file name is broke
942
943 // Make sure the (final) file name is unique within the set of exports
944 FileNames::MakeNameUnique(otherNames, setting.destfile);
945
946 /* do the metadata for this file */
947 // copy project metadata to start with
948 setting.filetags = Tags::Get( *mProject );
949 setting.filetags.LoadDefaults();
950 if (exportSettings.size()) {
951 setting.filetags = exportSettings.back().filetags;
952 }
953 // over-ride with values
954 setting.filetags.SetTag(TAG_TITLE, title);
955 setting.filetags.SetTag(TAG_TRACK, l+1);
956 // let the user have a crack at editing it, exit if cancelled
958 bool bShowTagsDialog = settings.GetShowId3Dialog();
959
960 bShowTagsDialog = bShowTagsDialog && mPlugins[mPluginIndex]->GetCanMetaData(mSubFormatIndex);
961
962 if( bShowTagsDialog ){
963 bool bCancelled = !TagsEditorDialog::ShowEditDialog(setting.filetags,
965 XO("Edit Metadata Tags"), bShowTagsDialog);
966 gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true);
967 settings.SetShowId3Dialog( bShowTagsDialog );
968 if( bCancelled )
970 }
971 }
972 /* add the settings to the array of settings to be used for export */
973 exportSettings.push_back(setting);
974
975 l++; // next track, count up one
976 }
977 // end of user-interactive data gathering loop, start of export processing
978 // loop
979 int count = 0; // count the number of successful runs
980 ExportKit activeSetting; // pointer to the settings in use for this export
981 std::unique_ptr<BasicUI::ProgressDialog> pDialog;
982
983 for (auto tr : mTracks->Leaders<WaveTrack>() -
985
986 wxLogDebug( "Get setting %i", count );
987 /* get the settings to use for the export from the array */
988 activeSetting = exportSettings[count];
989 if( activeSetting.destfile.GetName().empty() ){
990 count++;
991 continue;
992 }
993
994 /* Select the track */
996 tr->SetSelected(true);
997
998 // Export the data. "channels" are per track.
999 ok = DoExport(pDialog,
1000 activeSetting.channels, activeSetting.destfile, true,
1001 activeSetting.t0, activeSetting.t1, activeSetting.filetags);
1002 if (ok == ProgressResult::Stopped) {
1003 AudacityMessageDialog dlgMessage(
1004 nullptr,
1005 XO("Continue to export remaining files?"),
1006 XO("Export"),
1007 wxYES_NO | wxNO_DEFAULT | wxICON_WARNING);
1008 if (dlgMessage.ShowModal() != wxID_YES ) {
1009 // User decided not to continue - bail out!
1010 break;
1011 }
1012 }
1013 else if (ok != ProgressResult::Success) {
1014 break;
1015 }
1016 // increment export counter
1017 count++;
1018
1019 }
1020
1021 return ok ;
1022}
SelectionState & mSelectionState
virtual double GetStartTime() const =0
virtual double GetEndTime() const =0
bool empty() const
Definition: Track.cpp:919
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1164
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1217
bool IsMono(const Channel &channel)
Whether the channel is mono.

References _, RefreshCode::Cancelled, TrackList::Channels(), DoExport(), TrackList::empty(), ProjectWindow::Find(), Tags::Get(), ProjectSettings::Get(), Track::GetEndTime(), WaveTrack::GetMute(), PlayableTrack::GetNotSolo(), WaveTrack::GetSolo(), Track::GetStartTime(), gPrefs, AudioGraph::IsMono(), TrackList::Leaders(), MakeFileName(), FileNames::MakeNameUnique(), mDir, mNumWaveTracks, mPluginIndex, mPlugins, mProject, mSelectionState, mSubFormatIndex, mTracks, name, TrackList::SelectedLeaders(), settings(), TagsEditorDialog::ShowEditDialog(), BasicUI::Success, TAG_TITLE, TAG_TRACK, title, wxT(), and XO().

Referenced by OnExport().

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

◆ MakeFileName()

wxString ExportMultipleDialog::MakeFileName ( const wxString &  input)
private

Takes an arbitrary text string and converts it to a form that can be used as a file name, if necessary prompting the user to edit the file name produced.

Definition at line 1110 of file ExportMultiple.cpp.

1111{
1112 wxString newname = input; // name we are generating
1113
1114 // strip out anything that isn't allowed in file names on this platform
1115 auto changed = Internat::SanitiseFilename(newname, wxT("_"));
1116
1117 if(changed)
1118 { // need to get user to fix file name
1119 // build the dialog
1121 wxString excluded = ::wxJoin( Internat::GetExcludedCharacters(), wxT(' '), wxT('\0') );
1122 // TODO: For Russian language we should have separate cases for 2 and more than 2 letters.
1123 if( excluded.length() > 1 ){
1124 msg = XO(
1125// i18n-hint: The second %s gives some letters that can't be used.
1126"Label or track \"%s\" is not a legal file name.\nYou cannot use any of these characters:\n\n%s\n\nSuggested replacement:")
1127 .Format( input, excluded );
1128 } else {
1129 msg = XO(
1130// i18n-hint: The second %s gives a letter that can't be used.
1131"Label or track \"%s\" is not a legal file name. You cannot use \"%s\".\n\nSuggested replacement:")
1132 .Format( input, excluded );
1133 }
1134
1135 AudacityTextEntryDialog dlg( this, msg, XO("Save As..."), newname );
1136
1137
1138 // And tell the validator about excluded chars
1139 dlg.SetTextValidator( wxFILTER_EXCLUDE_CHAR_LIST );
1140 wxTextValidator *tv = dlg.GetTextValidator();
1141 tv->SetExcludes(Internat::GetExcludedCharacters());
1142
1143 // Show the dialog and bail if the user cancels
1144 if( dlg.ShowModal() == wxID_CANCEL )
1145 {
1146 return wxEmptyString;
1147 }
1148 // Extract the name from the dialog
1149 newname = dlg.GetValue();
1150 } // phew - end of file name sanitisation procedure
1151 return newname;
1152}
Wrap wxTextEntryDialog so that caption IS translatable.
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:239
static const wxArrayString & GetExcludedCharacters()
Definition: Internat.h:147
Holds a msgid for the translation catalog; may also bind format arguments.

References Internat::GetExcludedCharacters(), Internat::SanitiseFilename(), wxT(), and XO().

Referenced by ExportMultipleByLabel(), and ExportMultipleByTrack().

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

◆ OnByName()

void ExportMultipleDialog::OnByName ( wxCommandEvent &  event)
private

Definition at line 564 of file ExportMultiple.cpp.

565{
567}

References EnableControls().

Here is the call graph for this function:

◆ OnByNumber()

void ExportMultipleDialog::OnByNumber ( wxCommandEvent &  event)
private

Definition at line 569 of file ExportMultiple.cpp.

570{
572}

References EnableControls().

Here is the call graph for this function:

◆ OnCancel()

void ExportMultipleDialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 579 of file ExportMultiple.cpp.

580{
581 EndModal(0);
582}

◆ OnChoose()

void ExportMultipleDialog::OnChoose ( wxCommandEvent &  event)
private

Definition at line 534 of file ExportMultiple.cpp.

535{
536 wxDirDialogWrapper dlog(this,
537 XO("Choose a location to save the exported files"),
538 mDir->GetValue());
539 dlog.ShowModal();
540 if (!dlog.GetPath().empty())
541 mDir->SetValue(dlog.GetPath());
542}

References mDir, and XO().

Here is the call graph for this function:

◆ OnCreate()

void ExportMultipleDialog::OnCreate ( wxCommandEvent &  event)
private

Definition at line 514 of file ExportMultiple.cpp.

515{
516 wxFileName fn;
517
518 fn.AssignDir(mDir->GetValue());
519
520 bool ok = fn.Mkdir(0777, wxPATH_MKDIR_FULL);
521
522 if (!ok) {
523 // Mkdir will produce an error dialog
524 return;
525 }
526
528 XO("\"%s\" successfully created.").Format( fn.GetPath() ),
529 XO("Export Multiple"),
530 wxOK | wxCENTRE,
531 this);
532}
Abstract base class used in importing a file.

References AudacityMessageBox(), fn, mDir, and XO().

Here is the call graph for this function:

◆ OnExport()

void ExportMultipleDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 589 of file ExportMultiple.cpp.

590{
593
594 gPrefs->Flush();
595
596 FileNames::UpdateDefaultPath(FileNames::Operation::Export, mDir->GetValue());
597
598 // Make sure the output directory is in good shape
599 if (!DirOk()) {
600 return;
601 }
602
603 mFilterIndex = mFormat->GetSelection();
604 if (mFilterIndex != wxNOT_FOUND)
605 {
606 size_t c = 0;
607 int i = -1;
608 for (const auto &pPlugin : mPlugins)
609 {
610 ++i;
611 for (int j = 0; j < pPlugin->GetFormatCount(); j++, c++)
612 {
613 if ((size_t)mFilterIndex == c)
614 { // this is the selected format. Store the plug-in and sub-format
615 // needed to achieve it.
616 mPluginIndex = i;
617 mSubFormatIndex = j;
618 mBook->GetPage(mFilterIndex)->TransferDataFromWindow();
619 }
620 }
621 }
622 }
623
624// bool overwrite = mOverwrite->GetValue();
625 ProgressResult ok = ProgressResult::Failed;
626 mExported.clear();
627
628 // Give 'em the result
629 auto cleanup = finally( [&]
630 {
631 auto msg = (ok == ProgressResult::Success
632 ? XO("Successfully exported the following %lld file(s).")
633 : ok == ProgressResult::Failed
634 ? XO("Something went wrong after exporting the following %lld file(s).")
636 ? XO("Export canceled after exporting the following %lld file(s).")
637 : ok == ProgressResult::Stopped
638 ? XO("Export stopped after exporting the following %lld file(s).")
639 : XO("Something went really wrong after exporting the following %lld file(s).")
640 ).Format((long long) mExported.size());
641
642 wxString FileList;
643 for (size_t i = 0; i < mExported.size(); i++) {
644 FileList += mExported[i];
645 FileList += '\n';
646 }
647
648 // TODO: give some warning dialog first, when only some files exported
649 // successfully.
650
651 GuardedCall( [&] {
652 // This results dialog is a child of this dialog.
654 XO("Export Multiple"),
655 msg,
656 FileList,
657 450,400);
658 } );
659 } );
660
661 if (mLabel->GetValue()) {
662 ok = ExportMultipleByLabel(mByName->GetValue() || mByNumberAndName->GetValue(),
663 mPrefix->GetValue(),
664 mByNumberAndName->GetValue());
665 }
666 else {
667 ok = ExportMultipleByTrack(mByName->GetValue() || mByNumberAndName->GetValue(),
668 mPrefix->GetValue(),
669 mByNumberAndName->GetValue());
670 }
671
672 if (ok == ProgressResult::Success || ok == ProgressResult::Stopped) {
673 EndModal(1);
674 }
675}
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
ProgressResult ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber)
Export each track in the project to a separate file.
wxSimplebook * mBook
ProgressResult ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber)
Export multiple labeled regions of the project to separate files.
void PopulateOrExchange(ShuttleGui &S)
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
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:86
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)

References RefreshCode::Cancelled, DirOk(), eIsSavingToPrefs, ExportMultipleByLabel(), ExportMultipleByTrack(), FileConfig::Flush(), gPrefs, GuardedCall(), mBook, mByName, mByNumberAndName, mDir, mExported, mFilterIndex, mFormat, mLabel, mPluginIndex, mPlugins, mPrefix, mSubFormatIndex, PopulateOrExchange(), S, HelpSystem::ShowInfoDialog(), BasicUI::Success, FileNames::UpdateDefaultPath(), and XO().

Here is the call graph for this function:

◆ OnFirst()

void ExportMultipleDialog::OnFirst ( wxCommandEvent &  event)
private

Definition at line 549 of file ExportMultiple.cpp.

550{
552}

References EnableControls().

Here is the call graph for this function:

◆ OnFirstFileName()

void ExportMultipleDialog::OnFirstFileName ( wxCommandEvent &  event)
private

Definition at line 554 of file ExportMultiple.cpp.

555{
557}

References EnableControls().

Here is the call graph for this function:

◆ OnFormat()

void ExportMultipleDialog::OnFormat ( wxCommandEvent &  event)
private

Definition at line 483 of file ExportMultiple.cpp.

484{
485 mBook->ChangeSelection(mFormat->GetSelection());
486
488}

References EnableControls(), mBook, and mFormat.

Here is the call graph for this function:

◆ OnHelp()

void ExportMultipleDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 584 of file ExportMultiple.cpp.

585{
586 HelpSystem::ShowHelp(this, L"Export_Multiple", true);
587}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:233

References HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ OnLabel()

void ExportMultipleDialog::OnLabel ( wxCommandEvent &  event)
private

Definition at line 544 of file ExportMultiple.cpp.

545{
547}

References EnableControls().

Here is the call graph for this function:

◆ OnOptions()

void ExportMultipleDialog::OnOptions ( wxCommandEvent &  event)
private

Definition at line 490 of file ExportMultiple.cpp.

491{
492 const int sel = mFormat->GetSelection();
493 if (sel != wxNOT_FOUND)
494 {
495 size_t c = 0;
496 int i = -1;
497 for (const auto &pPlugin : mPlugins)
498 {
499 ++i;
500 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
501 {
502 if ((size_t)sel == c)
503 {
504 mPluginIndex = i;
505 mSubFormatIndex = j;
506 }
507 c++;
508 }
509 }
510 }
511 mPlugins[mPluginIndex]->DisplayOptions(this,mSubFormatIndex);
512}

References mFormat, mPluginIndex, mPlugins, and mSubFormatIndex.

◆ OnPrefix()

void ExportMultipleDialog::OnPrefix ( wxCommandEvent &  event)
private

Definition at line 574 of file ExportMultiple.cpp.

575{
577}

References EnableControls().

Here is the call graph for this function:

◆ OnTrack()

void ExportMultipleDialog::OnTrack ( wxCommandEvent &  event)
private

Definition at line 559 of file ExportMultiple.cpp.

560{
562}

References EnableControls().

Here is the call graph for this function:

◆ PopulateOrExchange()

void ExportMultipleDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 230 of file ExportMultiple.cpp.

231{
232 ChoiceSetting NumberingSetting{
233 wxT("/Export/TrackNameWithOrWithoutNumbers"),
234 {
235 { wxT("labelTrack"), XXO("Using Label/Track Name") },
236 { wxT("numberBefore"), XXO("Numbering before Label/Track Name") },
237 { wxT("numberAfter"), XXO("Numbering after File name prefix") },
238 },
239 0 // labelTrack
240 };
241
242 wxString name = mProject->GetProjectName();
243 wxString defaultFormat = gPrefs->Read(wxT("/Export/Format"), wxT("WAV"));
244
245 TranslatableStrings visibleFormats;
246 wxArrayStringEx formats;
247 mPluginIndex = -1;
248 mFilterIndex = 0;
249
250 {
251 int i = -1;
252 for (const auto &pPlugin : mPlugins)
253 {
254 ++i;
255 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
256 {
257 auto format = mPlugins[i]->GetDescription(j);
258 visibleFormats.push_back( format );
259 // use MSGID of description as a value too, written into config file
260 // This is questionable. A change in the msgid can make the
261 // preference stored in old config files inapplicable
262 formats.push_back( format.MSGID().GET() );
263 if (mPlugins[i]->GetFormat(j) == defaultFormat) {
264 mPluginIndex = i;
265 mSubFormatIndex = j;
266 }
267 if (mPluginIndex == -1) mFilterIndex++;
268 }
269 }
270 }
271
272 ChoiceSetting FormatSetting{ wxT("/Export/MultipleFormat"),
273 {
274 ByColumns,
275 visibleFormats,
276 formats
277 },
279 };
280
281 // Bug 1304: Set the default file path. It's used if none stored in config.
282 auto DefaultPath = FileNames::FindDefaultPath(FileNames::Operation::Export);
283
284 if (mPluginIndex == -1)
285 {
286 mPluginIndex = 0;
287 mFilterIndex = 0;
288 mSubFormatIndex = 0;
289 }
290
291 S.SetBorder(5);
292 S.StartHorizontalLay(wxEXPAND, true);
293 {
294 S.SetBorder(5);
295 S.StartStatic(XO("Export files to:"), true);
296 {
297 S.StartMultiColumn(4, true);
298 {
299 mDir = S.Id(DirID)
300 .AddTextBox(XXO("Folder:"),
301 DefaultPath,
302 64);
303 S.Id(ChooseID).AddButton(XXO("Choose..."));
304 S.Id(CreateID).AddButton(XXO("Create"));
305
306 mFormat = S.Id(FormatID)
307 .TieChoice( XXO("Format:"),
308 FormatSetting
309 );
310 S.AddVariableText( {}, false);
311 S.AddVariableText( {}, false);
312
313 S.AddPrompt(XXO("Options:"));
314
315 mBook = S.Id(OptionsID)
316 .Style(wxBORDER_STATIC)
317 .StartSimplebook();
318 if (S.GetMode() == eIsCreating)
319 {
320 for (const auto &pPlugin : mPlugins)
321 {
322 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
323 {
324 // Name of simple book page is not displayed
325 S.StartNotebookPage( {} );
326 pPlugin->OptionsCreate(S, j);
327 S.EndNotebookPage();
328 }
329 }
330 mBook->ChangeSelection(mFormat->GetSelection());
331 }
332 S.EndSimplebook();
333 S.AddVariableText( {}, false);
334 S.AddVariableText( {}, false);
335 }
336 S.EndMultiColumn();
337 }
338 S.EndStatic();
339 }
340 S.EndHorizontalLay();
341
342 S.StartHorizontalLay(wxEXPAND, false);
343 {
344 S.SetBorder(5);
345 S.StartStatic(XO("Split files based on:"), 1);
346 {
347 // Row 1
348 S.SetBorder(1);
349
350 // Bug 2692: Place button group in panel so tabbing will work and,
351 // on the Mac, VoiceOver will announce as radio buttons.
352 S.StartPanel();
353 {
354 mTrack = S.Id(TrackID)
355 .AddRadioButton(XXO("Tracks"));
356
357 // Row 2
358 S.SetBorder(1);
359 mLabel = S.Id(LabelID)
360 .AddRadioButtonToGroup(XXO("Labels"));
361 }
362 S.EndPanel();
363
364 S.SetBorder(3);
365 S.StartMultiColumn(2, wxEXPAND);
366 S.SetStretchyCol(1);
367 {
368 // Row 3 (indented)
369 S.AddVariableText(Verbatim(" "), false);
370 mFirst = S.Id(FirstID)
371 .AddCheckBox(XXO("Include audio before first label"), false);
372
373 // Row 4
374 S.AddVariableText( {}, false);
375 S.StartMultiColumn(2, wxEXPAND);
376 S.SetStretchyCol(1);
377 {
379 S.AddVariableText(XO("First file name:"), false);
381 .Prop(1)
382 .Name(XO("First file name"))
383 .TieTextBox( {},
384 name,
385 30);
386 }
387 S.EndMultiColumn();
388 }
389 S.EndMultiColumn();
390
391 S.SetBorder(3);
392 }
393 S.EndStatic();
394
395 S.SetBorder(5);
396 S.StartStatic(XO("Name files:"), 1);
397 {
398 S.SetBorder(2);
399
400 // Bug 2692: Place button group in panel so tabbing will work and,
401 // on the Mac, VoiceOver will announce as radio buttons.
402 S.StartPanel();
403 {
404 S.StartRadioButtonGroup(NumberingSetting);
405 {
406 mByName = S.Id(ByNameID).TieRadioButton();
407
408 mByNumberAndName = S.Id(ByNameAndNumberID).TieRadioButton();
409
410 mByNumber = S.Id(ByNumberID).TieRadioButton();
411 }
412 S.EndRadioButtonGroup();
413 }
414 S.EndPanel();
415
416 S.StartMultiColumn(3, wxEXPAND);
417 S.SetStretchyCol(2);
418 {
419 // Row 3 (indented)
420 S.AddVariableText(Verbatim(" "), false);
421 mPrefixLabel = S.AddVariableText(XO("File name prefix:"), false);
422 mPrefix = S.Id(PrefixID)
423 .Name(XO("File name prefix"))
424 .TieTextBox( {},
425 name,
426 30);
427 }
428 S.EndMultiColumn();
429 }
430 S.EndStatic();
431 }
432 S.EndHorizontalLay();
433
434 S.SetBorder(5);
435 S.StartHorizontalLay(wxEXPAND, false);
436 {
437 mOverwrite = S.Id(OverwriteID).TieCheckBox(XXO("Overwrite existing files"),
438 {wxT("/Export/OverwriteExisting"),
439 false});
440 }
441 S.EndHorizontalLay();
442
443 S.AddStandardButtons(eOkButton | eCancelButton | eHelpButton);
444 mExport = (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
445 mExport->SetLabel(_("Export"));
446
447}
@ LabelID
@ CreateID
@ TrackID
@ PrefixID
@ ByNumberID
@ ChooseID
@ OverwriteID
@ DirID
@ FormatID
@ ByNameAndNumberID
@ OptionsID
@ FirstFileNameID
@ ByNameID
@ FirstID
int format
Definition: ExportPCM.cpp:53
XXO("&Cut/Copy/Paste Toolbar")
ByColumns_t ByColumns
Definition: Prefs.cpp:474
@ eIsCreating
Definition: ShuttleGui.h:37
@ eOkButton
Definition: ShuttleGui.h:594
@ eCancelButton
Definition: ShuttleGui.h:595
@ eHelpButton
Definition: ShuttleGui.h:598
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
std::vector< TranslatableString > TranslatableStrings
const wxString & GetProjectName() const
Definition: Project.cpp:100
wxRadioButton * mTrack
FILES_API FilePath FindDefaultPath(Operation op)

References _, ByColumns, ByNameAndNumberID, ByNameID, ByNumberID, ChooseID, CreateID, DirID, eCancelButton, eHelpButton, eIsCreating, eOkButton, FileNames::FindDefaultPath(), FirstFileNameID, FirstID, format, FormatID, AudacityProject::GetProjectName(), gPrefs, LabelID, mBook, mByName, mByNumber, mByNumberAndName, mDir, mExport, mFilterIndex, mFirst, mFirstFileLabel, mFirstFileName, mFormat, mLabel, mOverwrite, mPluginIndex, mPlugins, mPrefix, mPrefixLabel, mProject, mSubFormatIndex, mTrack, name, OptionsID, OverwriteID, PrefixID, S, TrackID, Verbatim(), wxT(), XO(), and XXO().

Referenced by OnExport().

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

◆ ShowModal()

int ExportMultipleDialog::ShowModal ( )

Definition at line 180 of file ExportMultiple.cpp.

181{
182 // Cannot export if all audio tracks are muted.
183 if (mNumWaveTracks == 0)
184 {
186 XO("All audio is muted."),
187 XO("Cannot Export Multiple"),
188 wxOK | wxCENTRE,
189 this);
190 return wxID_CANCEL;
191 }
192
193 if ((mNumWaveTracks < 1) && (mNumLabels < 1))
194 {
196 XO(
197"You have no unmuted Audio Tracks and no applicable \
198\nlabels, so you cannot export to separate audio files."),
199 XO("Cannot Export Multiple"),
200 wxOK | wxCENTRE,
201 this);
202 return wxID_CANCEL;
203 }
204
205 bool bHasLabels = (mNumLabels > 0);
206 bool bHasTracks = (mNumWaveTracks > 0);
207
208 mLabel->Enable(bHasLabels && bHasTracks);
209 mTrack->Enable(bHasTracks);
210
211 // If you have 2 or more tracks, then it is export by tracks.
212 // If you have no labels, then it is export by tracks.
213 // Otherwise it is export by labels, by default.
214 bool bPreferByLabels = bHasLabels && (mNumWaveTracks < 2);
215 mLabel->SetValue(bPreferByLabels);
216 mTrack->SetValue(!bPreferByLabels);
217
219
220 // This is a work around for issue #2909, and ensures that
221 // when the dialog opens, the first control is the focus.
222 // The work around is only needed on Windows.
223#if defined(__WXMSW__)
224 mDir->SetFocus();
225#endif
226
227 return wxDialogWrapper::ShowModal();
228}

References AudacityMessageBox(), EnableControls(), mDir, mLabel, mNumLabels, mNumWaveTracks, mTrack, and XO().

Referenced by anonymous_namespace{FileMenus.cpp}::OnExportMultiple().

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

Member Data Documentation

◆ mBook

wxSimplebook* ExportMultipleDialog::mBook
private

Definition at line 162 of file ExportMultiple.h.

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

◆ mByName

wxRadioButton* ExportMultipleDialog::mByName
private

button to choose naming exported file from label text

Definition at line 151 of file ExportMultiple.h.

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

◆ mByNumber

wxRadioButton* ExportMultipleDialog::mByNumber
private

button to choose numbering exported files

Definition at line 152 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

◆ mByNumberAndName

wxRadioButton* ExportMultipleDialog::mByNumberAndName
private

button to choose number AND name for exported files

Definition at line 150 of file ExportMultiple.h.

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

◆ mCancel

wxButton* ExportMultipleDialog::mCancel
private

Definition at line 159 of file ExportMultiple.h.

◆ mChoose

wxButton* ExportMultipleDialog::mChoose
private

Definition at line 137 of file ExportMultiple.h.

◆ mCreate

wxButton* ExportMultipleDialog::mCreate
private

Definition at line 136 of file ExportMultiple.h.

◆ mDir

wxTextCtrl* ExportMultipleDialog::mDir
private

The directory all the exported files will end up in

Definition at line 134 of file ExportMultiple.h.

Referenced by DirOk(), ExportMultipleByLabel(), ExportMultipleByTrack(), OnChoose(), OnCreate(), OnExport(), PopulateOrExchange(), and ShowModal().

◆ mExport

wxButton* ExportMultipleDialog::mExport
private

Definition at line 160 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

◆ mExported

FilePaths ExportMultipleDialog::mExported
private

Definition at line 128 of file ExportMultiple.h.

Referenced by OnExport().

◆ mExporter

Exporter ExportMultipleDialog::mExporter
private

Definition at line 107 of file ExportMultiple.h.

◆ mFilterIndex

int ExportMultipleDialog::mFilterIndex
private

The index in the drop-down list of export formats (mFormat) of the selected export format. This list includes all possible plug-in - subformat combinations.

Definition at line 117 of file ExportMultiple.h.

Referenced by OnExport(), and PopulateOrExchange().

◆ mFirst

wxCheckBox* ExportMultipleDialog::mFirst
private

Check box to export audio before first label

Definition at line 142 of file ExportMultiple.h.

Referenced by EnableControls(), ExportMultipleByLabel(), and PopulateOrExchange().

◆ mFirstFileLabel

wxStaticText* ExportMultipleDialog::mFirstFileLabel
private

description text for mFirstFileName

Definition at line 143 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

◆ mFirstFileName

wxTextCtrl* ExportMultipleDialog::mFirstFileName
private

Name to use for exporting audio before the first label in the file

Definition at line 144 of file ExportMultiple.h.

Referenced by EnableControls(), ExportMultipleByLabel(), and PopulateOrExchange().

◆ mFormat

wxChoice* ExportMultipleDialog::mFormat
private

Drop-down list of export formats (combinations of plug-in and subformat)

Definition at line 130 of file ExportMultiple.h.

Referenced by OnExport(), OnFormat(), OnOptions(), and PopulateOrExchange().

◆ mInitialized

bool ExportMultipleDialog::mInitialized
private

Definition at line 125 of file ExportMultiple.h.

Referenced by EnableControls().

◆ mLabel

wxRadioButton* ExportMultipleDialog::mLabel
private

button to choose export based on Labels

Definition at line 139 of file ExportMultiple.h.

Referenced by EnableControls(), OnExport(), PopulateOrExchange(), and ShowModal().

◆ mLabelLabel

wxStaticText* ExportMultipleDialog::mLabelLabel
private

description text for mLabel

Definition at line 140 of file ExportMultiple.h.

◆ mLabels

const LabelTrack* ExportMultipleDialog::mLabels
private

Definition at line 113 of file ExportMultiple.h.

Referenced by CountTracksAndLabels(), and ExportMultipleByLabel().

◆ mNumLabels

int ExportMultipleDialog::mNumLabels
private

Definition at line 114 of file ExportMultiple.h.

Referenced by CountTracksAndLabels(), ExportMultipleByLabel(), and ShowModal().

◆ mNumWaveTracks

int ExportMultipleDialog::mNumWaveTracks
private

Definition at line 115 of file ExportMultiple.h.

Referenced by CountTracksAndLabels(), ExportMultipleByTrack(), and ShowModal().

◆ mOptions

wxButton* ExportMultipleDialog::mOptions
private

Definition at line 132 of file ExportMultiple.h.

◆ mOverwrite

wxCheckBox* ExportMultipleDialog::mOverwrite
private

Definition at line 157 of file ExportMultiple.h.

Referenced by DoExport(), and PopulateOrExchange().

◆ mPluginIndex

int ExportMultipleDialog::mPluginIndex
private

The index in mPlugins of the selected export plug-in

Definition at line 121 of file ExportMultiple.h.

Referenced by ExportMultipleByLabel(), ExportMultipleByTrack(), OnExport(), OnOptions(), and PopulateOrExchange().

◆ mPlugins

std::vector<ExportPlugin*> ExportMultipleDialog::mPlugins
private

Array of references to available exporter plug-ins

Definition at line 108 of file ExportMultiple.h.

Referenced by ExportMultipleByLabel(), ExportMultipleByTrack(), OnExport(), OnOptions(), and PopulateOrExchange().

◆ mPrefix

wxTextCtrl* ExportMultipleDialog::mPrefix
private

Definition at line 155 of file ExportMultiple.h.

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

◆ mPrefixLabel

wxStaticText* ExportMultipleDialog::mPrefixLabel
private

Definition at line 154 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

◆ mProject

AudacityProject* ExportMultipleDialog::mProject
private

◆ mSelectionState

SelectionState& ExportMultipleDialog::mSelectionState
private

Definition at line 164 of file ExportMultiple.h.

Referenced by ExportMultipleByTrack().

◆ mSubFormatIndex

int ExportMultipleDialog::mSubFormatIndex
private

The selected subformat number within the selected export plug-in set by mPluginIndex

Definition at line 123 of file ExportMultiple.h.

Referenced by ExportMultipleByLabel(), ExportMultipleByTrack(), OnExport(), OnOptions(), and PopulateOrExchange().

◆ mTrack

wxRadioButton* ExportMultipleDialog::mTrack
private

button to choose export based on tracks

Definition at line 147 of file ExportMultiple.h.

Referenced by PopulateOrExchange(), and ShowModal().

◆ mTrackLabel

wxStaticText* ExportMultipleDialog::mTrackLabel
private

Definition at line 148 of file ExportMultiple.h.

◆ mTracks

TrackList* ExportMultipleDialog::mTracks
private

The list of tracks in the project that is being exported

Definition at line 111 of file ExportMultiple.h.

Referenced by CountTracksAndLabels(), ExportMultipleByLabel(), and ExportMultipleByTrack().


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