Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExportMultiple 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 ExportMultiple:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 ExportMultiple (AudacityProject *parent)
 
virtual ~ExportMultiple ()
 
int ShowModal ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 
 ~wxTabTraversalWrapper ()
 

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 (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 OnExport (wxCommandEvent &event)
 

Private Attributes

Exporter mExporter
 
std::vector< ExportPlugin * > mPlugins
 
AudacityProjectmProject
 
TrackListmTracks
 
LabelTrackmLabels
 
int mNumLabels
 
int mNumWaveTracks
 
int mFilterIndex
 
int mPluginIndex
 
int mSubFormatIndex
 
bool mInitialized
 
wxArrayString 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 35 of file ExportMultiple.h.

Constructor & Destructor Documentation

ExportMultiple::ExportMultiple ( AudacityProject parent)
ExportMultiple::~ExportMultiple ( )
virtual

Definition at line 139 of file ExportMultiple.cpp.

140 {
141 }

Member Function Documentation

void ExportMultiple::CanExport ( )
private
void ExportMultiple::CountTracksAndLabels ( )
private

Definition at line 143 of file ExportMultiple.cpp.

References TrackListConstIterator::First(), Track::GetKind(), Track::GetLinked(), LabelTrack::GetNumLabels(), Track::Label, mLabels, mNumLabels, mNumWaveTracks, mTracks, TrackListConstIterator::Next(), and Track::Wave.

144 {
145  mLabels = NULL;
146  mNumLabels = 0;
147  mNumWaveTracks = 0;
148 
149  const Track* pTrack;
151  for (pTrack = iter.First(mTracks); pTrack != NULL; pTrack = iter.Next())
152  {
153  switch (pTrack->GetKind())
154  {
155  // Count WaveTracks, and for linked pairs, count only the second of the pair.
156  case Track::Wave:
157  {
158  auto wt = static_cast<const WaveTrack *>(pTrack);
159  if (!wt->GetMute() && !pTrack->GetLinked()) // Don't count muted tracks.
160  mNumWaveTracks++;
161  break;
162  }
163 
164  // Only support one label track???
165  case Track::Label:
166  {
167  // Supports only one LabelTrack.
168  if (mLabels == NULL) {
169  mLabels = (LabelTrack*)pTrack;
171  }
172  break;
173  }
174  }
175  }
176 }
TrackList * mTracks
LabelTrack * mLabels
const Track * First(const TrackList *val=NULL)
Definition: Track.h:402
bool GetLinked() const
Definition: Track.h:218
int GetNumLabels() const
virtual int GetKind() const
Definition: Track.h:267
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:114
const Track * Next(bool skiplinked=false)
Definition: Track.h:406
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:67
bool ExportMultiple::DirOk ( )
private

Definition at line 614 of file ExportMultiple.cpp.

References _(), AudacityMessageBox(), and mDir.

Referenced by OnExport().

615 {
616  wxFileName fn;
617 
618  fn.AssignDir(mDir->GetValue());
619 
620  if (fn.DirExists()) {
621  return true;
622  }
623 
624  wxString prompt;
625 
626  prompt.Printf(_("\"%s\" doesn't exist.\n\nWould you like to create it?"),
627  fn.GetFullPath());
628 
629  int action = AudacityMessageBox(prompt,
630  wxT("Warning"),
631  wxYES_NO | wxICON_EXCLAMATION);
632  if (action != wxYES) {
633  return false;
634  }
635 
636  return fn.Mkdir(0777, wxPATH_MKDIR_FULL);
637 }
wxTextCtrl * mDir
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
ProgressResult ExportMultiple::DoExport ( 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 932 of file ExportMultiple.cpp.

References Cancelled, AudacityProject::GetDirManager(), mExported, mOverwrite, mPluginIndex, mPlugins, mProject, mSubFormatIndex, name, Stopped, and Success.

Referenced by ExportMultipleByLabel(), and ExportMultipleByTrack().

938 {
939  wxFileName name;
940 
941  wxLogDebug(wxT("Doing multiple Export: File name \"%s\""), (inName.GetFullName()));
942  wxLogDebug(wxT("Channels: %i, Start: %lf, End: %lf "), channels, t0, t1);
943  if (selectedOnly)
944  wxLogDebug(wxT("Selected Region Only"));
945  else
946  wxLogDebug(wxT("Whole Project"));
947 
948  if (mOverwrite->GetValue()) {
949  // Make sure we don't overwrite (corrupt) alias files
950  if (!mProject->GetDirManager()->EnsureSafeFilename(inName)) {
952  }
953  name = inName;
954  }
955  else {
956  name = inName;
957  int i = 2;
958  wxString base(name.GetName());
959  while (name.FileExists()) {
960  name.SetName(wxString::Format(wxT("%s-%d"), base, i++));
961  }
962  }
963 
964  // Call the format export routine
965  const wxString fullPath{name.GetFullPath()};
966  auto success = mPlugins[mPluginIndex]->Export(mProject,
967  channels,
968  fullPath,
969  selectedOnly,
970  t0,
971  t1,
972  NULL,
973  &tags,
975 
976  if (success == ProgressResult::Success || success == ProgressResult::Stopped) {
977  mExported.Add(fullPath);
978  }
979 
980  Refresh();
981  Update();
982 
983  return success;
984 }
AudacityProject * mProject
const std::shared_ptr< DirManager > & GetDirManager()
Definition: Project.cpp:1407
wxArrayString mExported
std::vector< ExportPlugin * > mPlugins
const wxChar * name
Definition: Distortion.cpp:94
wxCheckBox * mOverwrite
void ExportMultiple::EnableControls ( )
private

Definition at line 397 of file ExportMultiple.cpp.

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().

398 {
399  bool enable;
400 
401  if (!mInitialized) {
402  return;
403  }
404 
405  mFirst->Enable(mLabel->GetValue());
406 
407  enable = mLabel->GetValue() &&
408  (mByName->GetValue() || mByNumberAndName->GetValue()) &&
409  mFirst->GetValue();
410  mFirstFileLabel->Enable(enable);
411  mFirstFileName->Enable(enable);
412 
413  enable = mByNumber->GetValue();
414  mPrefixLabel->Enable(enable);
415  mPrefix->Enable(enable);
416 
417  bool ok = true;
418 
419  if (mLabel->GetValue() && mFirst->GetValue() &&
420  mFirstFileName->GetValue() == wxT("") &&
421  mPrefix->GetValue() == wxT(""))
422  ok = false;
423 
424  if (mByNumber->GetValue() &&
425  mPrefix->GetValue() == wxT(""))
426  ok = false;
427 
428  mExport->Enable(ok);
429 }
wxRadioButton * mByNumberAndName
wxRadioButton * mLabel
wxTextCtrl * mPrefix
wxButton * mExport
wxRadioButton * mByName
wxStaticText * mPrefixLabel
wxTextCtrl * mFirstFileName
wxRadioButton * mByNumber
wxCheckBox * mFirst
wxStaticText * mFirstFileLabel
ProgressResult ExportMultiple::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 640 of file ExportMultiple.cpp.

References _(), Cancelled, ExportKit::destfile, DoExport(), ExportKit::filetags, TrackList::GetEndTime(), LabelTrack::GetLabel(), TrackList::GetNumExportChannels(), AudacityProject::GetShowId3Dialog(), AudacityProject::GetTags(), SelectedRegion::isPoint(), MakeFileName(), FileNames::MakeNameUnique(), mDir, mFirst, mFirstFileName, mLabels, mNumLabels, mPluginIndex, mPlugins, mProject, mSubFormatIndex, mTracks, name, LabelStruct::selectedRegion, Tags::SetTag(), Tags::ShowEditDialog(), Stopped, Success, SelectedRegion::t0(), ExportKit::t0, SelectedRegion::t1(), ExportKit::t1, TAG_TITLE, TAG_TRACK, and LabelStruct::title.

Referenced by OnExport().

642 {
643  wxASSERT(mProject);
644  bool tagsPrompt = mProject->GetShowId3Dialog();
645  int numFiles = mNumLabels;
646  int l = 0; // counter for files done
647  ExportKitArray exportSettings; // dynamic array for settings.
648  exportSettings.Alloc(numFiles); // Allocate some guessed space to use.
649 
650  // Account for exporting before first label
651  if( mFirst->GetValue() ) {
652  l--;
653  numFiles++;
654  }
655 
656  // Figure out how many channels we should export.
657  auto channels = mTracks->GetNumExportChannels(false);
658 
659  wxArrayString otherNames; // keep track of file names we will use, so we
660  // don't duplicate them
661  ExportKit setting; // the current batch of settings
662  setting.destfile.SetPath(mDir->GetValue());
663  setting.destfile.SetExt(mPlugins[mPluginIndex]->GetExtension(mSubFormatIndex));
664  wxLogDebug(wxT("Plug-in index = %d, Sub-format = %d"), mPluginIndex, mSubFormatIndex);
665  wxLogDebug(wxT("File extension is %s"), setting.destfile.GetExt());
666  wxString name; // used to hold file name whilst we mess with it
667  wxString title; // un-messed-with title of file for tagging with
668 
669  const LabelStruct *info = NULL;
670  /* Examine all labels a first time, sort out all data but don't do any
671  * exporting yet (so this run is quick but interactive) */
672  while( l < mNumLabels ) {
673 
674  // Get file name and starting time
675  if( l < 0 ) {
676  // create wxFileName for output file
677  name = (mFirstFileName->GetValue());
678  setting.t0 = 0.0;
679  } else {
680  info = mLabels->GetLabel(l);
681  name = (info->title);
682  setting.t0 = info->selectedRegion.t0();
683  }
684 
685  // Figure out the ending time
686  if( info && !info->selectedRegion.isPoint() ) {
687  setting.t1 = info->selectedRegion.t1();
688  } else if( l < mNumLabels-1 ) {
689  // Use start of next label as end
690  const LabelStruct *info1 = mLabels->GetLabel(l+1);
691  setting.t1 = info1->selectedRegion.t0();
692  } else {
693  setting.t1 = mTracks->GetEndTime();
694  }
695 
696  if( name.IsEmpty() )
697  name = _("untitled");
698 
699  // store title of label to use in tags
700  title = name;
701 
702  // Numbering files...
703  if( !byName ) {
704  name.Printf(wxT("%s-%02d"), prefix, l+1);
705  } else if( addNumber ) {
706  // Following discussion with GA, always have 2 digits
707  // for easy file-name sorting (on Windows)
708  name.Prepend(wxString::Format(wxT("%02d-"), l+1));
709  }
710 
711  // store sanitised and user checked name in object
712  setting.destfile.SetName(MakeFileName(name));
713  if( setting.destfile.GetName().IsEmpty() )
714  { // user cancelled dialogue, or deleted everything in field.
715  // or maybe the label was empty??
716  // So we ignore this one and keep going.
717  }
718  else
719  {
720  // FIXME: TRAP_ERR User could have given an illegal filename prefix.
721  // in that case we should tell them, not fail silently.
722  wxASSERT(setting.destfile.IsOk()); // burp if file name is broke
723 
724  // Make sure the (final) file name is unique within the set of exports
725  FileNames::MakeNameUnique(otherNames, setting.destfile);
726 
727  /* do the metadata for this file */
728  // copy project metadata to start with
729  setting.filetags = *(mProject->GetTags());
730  // over-ride with values
731  setting.filetags.SetTag(TAG_TITLE, title);
732  setting.filetags.SetTag(TAG_TRACK, l+1);
733  // let the user have a crack at editing it, exit if cancelled
734  if( !setting.filetags.ShowEditDialog(mProject, _("Edit Metadata Tags"), tagsPrompt) )
736  }
737 
738  /* add the settings to the array of settings to be used for export */
739  exportSettings.Add(setting);
740 
741  l++; // next label, count up one
742  }
743 
744  auto ok = ProgressResult::Success; // did it work?
745  int count = 0; // count the number of sucessful runs
746  ExportKit activeSetting; // pointer to the settings in use for this export
747  /* Go round again and do the exporting (so this run is slow but
748  * non-interactive) */
749  for (count = 0; count < numFiles; count++) {
750  /* get the settings to use for the export from the array */
751  activeSetting = exportSettings[count];
752  // Bug 1440 fix.
753  if( activeSetting.destfile.GetName().IsEmpty() )
754  continue;
755 
756  // Export it
757  ok = DoExport(channels, activeSetting.destfile, false, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
759  break;
760  }
761  }
762 
763  return ok;
764 }
TrackList * mTracks
void SetTag(const wxString &name, const wxString &value)
Definition: Tags.cpp:449
LabelTrack * mLabels
double t0() const
#define TAG_TRACK
Definition: Tags.h:65
bool isPoint() const
wxTextCtrl * mDir
double GetEndTime() const
Definition: Track.cpp:1334
AudacityProject * mProject
wxString MakeFileName(const wxString &input)
Takes an arbitrary text string and converts it to a form that can be used as a file name...
wxString title
Definition: LabelTrack.h:93
#define TAG_TITLE
Definition: Tags.h:62
double t1() const
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:45
wxTextCtrl * mFirstFileName
wxFileName destfile
const LabelStruct * GetLabel(int index) const
bool GetShowId3Dialog()
Definition: Project.h:301
wxCheckBox * mFirst
unsigned GetNumExportChannels(bool selectionOnly) const
Find out how many channels this track list mixes to.
Definition: Track.cpp:1176
std::vector< ExportPlugin * > mPlugins
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
A private class used to store the information needed to do an export.
const wxChar * name
Definition: Distortion.cpp:94
SelectedRegion selectedRegion
Definition: LabelTrack.h:92
const Tags * GetTags()
Definition: Project.cpp:1438
ProgressResult DoExport(unsigned channels, const wxFileName &name, bool selectedOnly, double t0, double t1, const Tags &tags)
bool ShowEditDialog(wxWindow *parent, const wxString &title, bool force=false)
Definition: Tags.cpp:570
static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName)
Definition: FileNames.cpp:92
ProgressResult ExportMultiple::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 766 of file ExportMultiple.cpp.

References _(), Cancelled, ExportKit::channels, ExportKit::destfile, DoExport(), ExportKit::filetags, TrackListIterator::First(), Track::GetChannel(), Track::GetEndTime(), Track::GetKind(), Track::GetLinked(), Track::GetSelected(), AudacityProject::GetShowId3Dialog(), Track::GetStartTime(), AudacityProject::GetTags(), MakeFileName(), FileNames::MakeNameUnique(), mDir, mNumWaveTracks, Track::MonoChannel, mPluginIndex, mPlugins, mProject, mSelectionState, mSubFormatIndex, mTracks, name, TrackListIterator::Next(), Track::SetSelected(), Tags::SetTag(), Tags::ShowEditDialog(), Stopped, Success, ExportKit::t0, ExportKit::t1, TAG_TITLE, TAG_TRACK, and Track::Wave.

Referenced by OnExport().

768 {
769  wxASSERT(mProject);
770  bool tagsPrompt = mProject->GetShowId3Dialog();
771  Track *tr, *tr2;
772  int l = 0; // track counter
773  auto ok = ProgressResult::Success;
774  wxArrayString otherNames;
775  ExportKitArray exportSettings; // dynamic array we will use to store the
776  // settings needed to do the exports with in
777  exportSettings.Alloc(mNumWaveTracks); // Allocate some guessed space to use.
778  ExportKit setting; // the current batch of settings
779  setting.destfile.SetPath(mDir->GetValue());
780  setting.destfile.SetExt(mPlugins[mPluginIndex]->GetExtension(mSubFormatIndex));
781 
782  wxString name; // used to hold file name whilst we mess with it
783  wxString title; // un-messed-with title of file for tagging with
784 
785  /* Remember which tracks were selected, and set them to unselected */
787  TrackListIterator iter;
788  for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
789  if (tr->GetKind() != Track::Wave) {
790  continue;
791  }
792 
793  if (tr->GetSelected())
794  tr->SetSelected(false);
795  }
796 
797  /* Examine all tracks in turn, collecting export information */
798  for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
799 
800  // Want only non-muted wave tracks.
801  auto wt = static_cast<const WaveTrack *>(tr);
802  if ((tr->GetKind() != Track::Wave) ||
803  wt->GetMute())
804  continue;
805 
806  // Get the times for the track
807  setting.t0 = tr->GetStartTime();
808  setting.t1 = tr->GetEndTime();
809 
810  // Check for a linked track
811  tr2 = NULL;
812  if (tr->GetLinked()) {
813  tr2 = iter.Next();
814  if (tr2) {
815 
816  // Make sure it gets included
817  if (tr2->GetStartTime() < setting.t0) {
818  setting.t0 = tr2->GetStartTime();
819  }
820 
821  if (tr2->GetEndTime() > setting.t1) {
822  setting.t1 = tr2->GetEndTime();
823  }
824  }
825  }
826 
827  // number of export channels?
828  // Needs to be per track.
829  if (tr2 == NULL && tr->GetChannel() == WaveTrack::MonoChannel &&
830  ((WaveTrack *)tr)->GetPan() == 0.0)
831  setting.channels = 1;
832  else
833  setting.channels = 2;
834 
835  // Get name and title
836  title = tr->GetName();
837  if( title.IsEmpty() )
838  title = _("untitled");
839 
840  if (byName) {
841  name = title;
842  if (addNumber) {
843  name.Prepend(
844  wxString::Format(wxT("%02d-"), l+1));
845  }
846  }
847  else {
848  name = (wxString::Format(wxT("%s-%02d"), prefix, l+1));
849  }
850 
851  // store sanitised and user checked name in object
852  setting.destfile.SetName(MakeFileName(name));
853 
854  if (setting.destfile.GetName().IsEmpty())
855  { // user cancelled dialogue, or deleted everything in field.
856  // So we ignore this one and keep going.
857  }
858  else
859  {
860 
861  // FIXME: TRAP_ERR User could have given an illegal track name.
862  // in that case we should tell them, not fail silently.
863  wxASSERT(setting.destfile.IsOk()); // burp if file name is broke
864 
865  // Make sure the (final) file name is unique within the set of exports
866  FileNames::MakeNameUnique(otherNames, setting.destfile);
867 
868  /* do the metadata for this file */
869  // copy project metadata to start with
870  setting.filetags = *(mProject->GetTags());
871  // over-ride with values
872  setting.filetags.SetTag(TAG_TITLE, title);
873  setting.filetags.SetTag(TAG_TRACK, l+1);
874  // let the user have a crack at editing it, exit if cancelled
875  if (!setting.filetags.ShowEditDialog(mProject,_("Edit Metadata Tags"), tagsPrompt))
877  }
878  /* add the settings to the array of settings to be used for export */
879  exportSettings.Add(setting);
880 
881  l++; // next track, count up one
882  }
883  // end of user-interactive data gathering loop, start of export processing
884  // loop
885  int count = 0; // count the number of sucessful runs
886  ExportKit activeSetting; // pointer to the settings in use for this export
887  for (tr = iter.First(mTracks); tr != NULL; tr = iter.Next()) {
888 
889  // Want only non-muted wave tracks.
890  auto wt = static_cast<const WaveTrack *>(tr);
891  if ((tr->GetKind() != Track::Wave) || (wt->GetMute())) {
892  continue;
893  }
894 
895  // Bug 1510 possibly increment iter, before deciding whether to export.
896  // Check for a linked track
897  tr2 = NULL;
898  if (tr->GetLinked()) {
899  tr2 = iter.Next();
900  }
901 
902  wxLogDebug( "Get setting %i", count );
903  /* get the settings to use for the export from the array */
904  activeSetting = exportSettings[count];
905  if( activeSetting.destfile.GetName().IsEmpty() ){
906  count++;
907  continue;
908  }
909 
910  /* Select the track */
912  tr->SetSelected(true);
913  if (tr2)
914  // Select it also
915  tr2->SetSelected(true);
916 
917  // Export the data. "channels" are per track.
918  ok = DoExport(activeSetting.channels, activeSetting.destfile, true, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
919 
920  // Stop if an error occurred
922  break;
923  }
924  // increment export counter
925  count++;
926 
927  }
928 
929  return ok ;
930 }
TrackList * mTracks
void SetTag(const wxString &name, const wxString &value)
Definition: Tags.cpp:449
#define TAG_TRACK
Definition: Tags.h:65
SelectionState & mSelectionState
bool GetSelected() const
Definition: Track.h:217
virtual double GetEndTime() const =0
wxTextCtrl * mDir
AudacityProject * mProject
wxString MakeFileName(const wxString &input)
Takes an arbitrary text string and converts it to a form that can be used as a file name...
#define TAG_TITLE
Definition: Tags.h:62
virtual int GetChannel() const
Definition: Track.h:223
bool GetLinked() const
Definition: Track.h:218
virtual double GetStartTime() const =0
virtual void SetSelected(bool s)
Definition: Track.cpp:97
virtual int GetKind() const
Definition: Track.h:267
wxFileName destfile
bool GetShowId3Dialog()
Definition: Project.h:301
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:67
wxString GetName() const
Definition: Track.h:212
virtual Track * First(TrackList *val=nullptr)
Definition: Track.cpp:355
An iterator for a TrackList.
Definition: Track.h:339
std::vector< ExportPlugin * > mPlugins
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
A private class used to store the information needed to do an export.
const wxChar * name
Definition: Distortion.cpp:94
virtual Track * Next(bool skiplinked=false)
Definition: Track.cpp:396
const Tags * GetTags()
Definition: Project.cpp:1438
unsigned channels
ProgressResult DoExport(unsigned channels, const wxFileName &name, bool selectedOnly, double t0, double t1, const Tags &tags)
bool ShowEditDialog(wxWindow *parent, const wxString &title, bool force=false)
Definition: Tags.cpp:570
static void MakeNameUnique(wxArrayString &otherNames, wxFileName &newName)
Definition: FileNames.cpp:92
wxString ExportMultiple::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 986 of file ExportMultiple.cpp.

References _(), Internat::GetExcludedCharacters(), and Internat::SanitiseFilename().

Referenced by ExportMultipleByLabel(), and ExportMultipleByTrack().

987 {
988  wxString newname = input; // name we are generating
989 
990  // strip out anything that isn't allowed in file names on this platform
991  auto changed = Internat::SanitiseFilename(newname, wxT("_"));
992 
993  if(changed)
994  { // need to get user to fix file name
995  // build the dialog
996  wxString msg;
997  wxString excluded = ::wxJoin( Internat::GetExcludedCharacters(), wxChar(' ') );
998  // TODO: For Russian langauge we should have separate cases for 2 and more than 2 letters.
999  if( excluded.Length() > 1 ){
1000  // i18n-hint: The second %s gives some letters that can't be used.
1001  msg.Printf(_("Label or track \"%s\" is not a legal file name. You cannot use any of: %s\nUse..."), input,
1002  excluded);
1003  } else {
1004  // i18n-hint: The second %s gives a letter that can't be used.
1005  msg.Printf(_("Label or track \"%s\" is not a legal file name. You cannot use \"%s\".\nUse..."), input,
1006  excluded);
1007  }
1008 
1009  AudacityTextEntryDialog dlg( this, msg, _("Save As..."), newname );
1010 
1011 
1012  // And tell the validator about excluded chars
1013  dlg.SetTextValidator( wxFILTER_EXCLUDE_CHAR_LIST );
1014  wxTextValidator *tv = dlg.GetTextValidator();
1015  tv->SetExcludes(Internat::GetExcludedCharacters());
1016 
1017  // Show the dialog and bail if the user cancels
1018  if( dlg.ShowModal() == wxID_CANCEL )
1019  {
1020  return wxEmptyString;
1021  }
1022  // Extract the name from the dialog
1023  newname = dlg.GetValue();
1024  } // phew - end of file name sanitisation procedure
1025  return newname;
1026 }
static const wxArrayString & GetExcludedCharacters()
Definition: Internat.h:134
static bool SanitiseFilename(wxString &name, const wxString &sub)
Protect against Unicode to multi-byte conversion failures on Windows.
Definition: Internat.cpp:266
Definition: ErrorDialog.h:105
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void ExportMultiple::OnByName ( wxCommandEvent &  event)
private

Definition at line 511 of file ExportMultiple.cpp.

References EnableControls().

512 {
513  EnableControls();
514 }
void ExportMultiple::OnByNumber ( wxCommandEvent &  event)
private

Definition at line 516 of file ExportMultiple.cpp.

References EnableControls().

517 {
518  EnableControls();
519 }
void ExportMultiple::OnCancel ( wxCommandEvent &  event)
private

Definition at line 526 of file ExportMultiple.cpp.

527 {
528  EndModal(0);
529 }
void ExportMultiple::OnChoose ( wxCommandEvent &  event)
private

Definition at line 481 of file ExportMultiple.cpp.

References _(), and mDir.

482 {
483  wxDirDialogWrapper dlog(this,
484  _("Choose a location to save the exported files"),
485  mDir->GetValue());
486  dlog.ShowModal();
487  if (dlog.GetPath() != wxT(""))
488  mDir->SetValue(dlog.GetPath());
489 }
wxTextCtrl * mDir
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void ExportMultiple::OnCreate ( wxCommandEvent &  event)
private

Definition at line 462 of file ExportMultiple.cpp.

References _(), AudacityMessageBox(), and mDir.

463 {
464  wxFileName fn;
465 
466  fn.AssignDir(mDir->GetValue());
467 
468  bool ok = fn.Mkdir(0777, wxPATH_MKDIR_FULL);
469 
470  if (!ok) {
471  // Mkdir will produce an error dialog
472  return;
473  }
474 
475  ::AudacityMessageBox(wxString::Format(_("\"%s\" successfully created."),
476  fn.GetPath()),
477  _("Export Multiple"),
478  wxOK | wxCENTRE, this);
479 }
wxTextCtrl * mDir
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void ExportMultiple::OnExport ( wxCommandEvent &  event)
private

Definition at line 531 of file ExportMultiple.cpp.

References _(), Cancelled, DirOk(), eIsSavingToPrefs, ExportMultipleByLabel(), ExportMultipleByTrack(), Failed, gPrefs, GuardedCall(), mBook, mByName, mByNumberAndName, mExported, mFilterIndex, mFormat, mLabel, mPluginIndex, mPlugins, mPrefix, mSubFormatIndex, PopulateOrExchange(), HelpSystem::ShowInfoDialog(), Stopped, and Success.

532 {
533  ShuttleGui S(this, eIsSavingToPrefs);
535 
536  gPrefs->Flush();
537 
538  // Make sure the output directory is in good shape
539  if (!DirOk()) {
540  return;
541  }
542 
543  mFilterIndex = mFormat->GetSelection();
544  if (mFilterIndex != wxNOT_FOUND)
545  {
546  size_t c = 0;
547  int i = -1;
548  for (const auto &pPlugin : mPlugins)
549  {
550  ++i;
551  for (int j = 0; j < pPlugin->GetFormatCount(); j++, c++)
552  {
553  if ((size_t)mFilterIndex == c)
554  { // this is the selected format. Store the plug-in and sub-format
555  // needed to acheive it.
556  mPluginIndex = i;
557  mSubFormatIndex = j;
558  mBook->GetPage(mFilterIndex)->TransferDataFromWindow();
559  }
560  }
561  }
562  }
563 
564 // bool overwrite = mOverwrite->GetValue();
566  mExported.Empty();
567 
568  // Give 'em the result
569  auto cleanup = finally( [&]
570  {
571  wxString msg;
572  msg.Printf(
573  ok == ProgressResult::Success ? _("Successfully exported the following %lld file(s).")
574  : (ok == ProgressResult::Failed ? _("Something went wrong after exporting the following %lld file(s).")
575  : (ok == ProgressResult::Cancelled ? _("Export canceled after exporting the following %lld file(s).")
576  : (ok == ProgressResult::Stopped ? _("Export stopped after exporting the following %lld file(s).")
577  : _("Something went really wrong after exporting the following %lld file(s).")
578  )
579  )
580  ), (long long) mExported.GetCount());
581 
582  wxString FileList;
583  for (size_t i = 0; i < mExported.GetCount(); i++) {
584  FileList += mExported[i];
585  FileList += '\n';
586  }
587 
588  GuardedCall( [&] {
589  // This results dialog is a child of this dialog.
591  _("Export Multiple"),
592  msg,
593  FileList,
594  450,400);
595  } );
596  } );
597 
598  if (mLabel->GetValue()) {
599  ok = ExportMultipleByLabel(mByName->GetValue() || mByNumberAndName->GetValue(),
600  mPrefix->GetValue(),
601  mByNumberAndName->GetValue());
602  }
603  else {
604  ok = ExportMultipleByTrack(mByName->GetValue() || mByNumberAndName->GetValue(),
605  mPrefix->GetValue(),
606  mByNumberAndName->GetValue());
607  }
608 
610  EndModal(1);
611  }
612 }
static void ShowInfoDialog(wxWindow *parent, const wxString &dlogTitle, const wxString &shortMsg, const wxString &message, const int xSize, const int ySize)
Displays cutable information in a text ctrl, with an OK button.
Definition: HelpSystem.cpp:54
wxRadioButton * mByNumberAndName
ProgressResult
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
wxRadioButton * mLabel
wxTextCtrl * mPrefix
wxSimplebook * mBook
wxRadioButton * mByName
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
ProgressResult ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber)
Export each track in the project to a separate file.
wxArrayString mExported
void PopulateOrExchange(ShuttleGui &S)
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), const F3 &delayedHandler={})
wxChoice * mFormat
std::vector< ExportPlugin * > mPlugins
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
ProgressResult ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber)
Export multiple labeled regions of the project to separate files.
void ExportMultiple::OnFirst ( wxCommandEvent &  event)
private

Definition at line 496 of file ExportMultiple.cpp.

References EnableControls().

497 {
498  EnableControls();
499 }
void ExportMultiple::OnFirstFileName ( wxCommandEvent &  event)
private

Definition at line 501 of file ExportMultiple.cpp.

References EnableControls().

502 {
503  EnableControls();
504 }
void ExportMultiple::OnFormat ( wxCommandEvent &  event)
private

Definition at line 431 of file ExportMultiple.cpp.

References EnableControls(), mBook, and mFormat.

432 {
433  mBook->ChangeSelection(mFormat->GetSelection());
434 
435  EnableControls();
436 }
wxSimplebook * mBook
wxChoice * mFormat
void ExportMultiple::OnLabel ( wxCommandEvent &  event)
private

Definition at line 491 of file ExportMultiple.cpp.

References EnableControls().

492 {
493  EnableControls();
494 }
void ExportMultiple::OnOptions ( wxCommandEvent &  event)
private

Definition at line 438 of file ExportMultiple.cpp.

References mFormat, mPluginIndex, mPlugins, and mSubFormatIndex.

439 {
440  const int sel = mFormat->GetSelection();
441  if (sel != wxNOT_FOUND)
442  {
443  size_t c = 0;
444  int i = -1;
445  for (const auto &pPlugin : mPlugins)
446  {
447  ++i;
448  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
449  {
450  if ((size_t)sel == c)
451  {
452  mPluginIndex = i;
453  mSubFormatIndex = j;
454  }
455  c++;
456  }
457  }
458  }
459  mPlugins[mPluginIndex]->DisplayOptions(this,mSubFormatIndex);
460 }
wxChoice * mFormat
std::vector< ExportPlugin * > mPlugins
void ExportMultiple::OnPrefix ( wxCommandEvent &  event)
private

Definition at line 521 of file ExportMultiple.cpp.

References EnableControls().

522 {
523  EnableControls();
524 }
void ExportMultiple::OnTrack ( wxCommandEvent &  event)
private

Definition at line 506 of file ExportMultiple.cpp.

References EnableControls().

507 {
508  EnableControls();
509 }
void ExportMultiple::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 216 of file ExportMultiple.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddRadioButton(), ShuttleGuiBase::AddRadioButtonToGroup(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddVariableText(), ShuttleGuiBase::AddWindow(), ByNameAndNumberID, ByNameID, ByNumberID, ChooseID, CreateID, FileNames::DefaultToDocumentsFolder(), DirID, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndRadioButtonGroup(), ShuttleGuiBase::EndStatic(), FirstFileNameID, FirstID, FormatID, AudacityProject::GetName(), ShuttleGuiBase::GetParent(), gPrefs, ShuttleGui::Id(), 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, ShuttleGui::Prop(), safenew, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartRadioButtonGroup(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieRadioButton(), ShuttleGuiBase::TieTextBox(), and TrackID.

Referenced by OnExport().

217 {
218  wxString name = mProject->GetName();
219  wxString defaultFormat = gPrefs->Read(wxT("/Export/Format"), wxT("WAV"));
220 
221  wxArrayString formats;
222  mPluginIndex = -1;
223  mFilterIndex = 0;
224 
225  {
226  int i = -1;
227  for (const auto &pPlugin : mPlugins)
228  {
229  ++i;
230  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
231  {
232  formats.Add(mPlugins[i]->GetDescription(j));
233  if (mPlugins[i]->GetFormat(j) == defaultFormat) {
234  mPluginIndex = i;
235  mSubFormatIndex = j;
236  }
237  if (mPluginIndex == -1) mFilterIndex++;
238  }
239  }
240  }
241 
242 
243  // Bug 1304: Set the default file path. It's used if none stored in config.
244  auto filename = FileNames::DefaultToDocumentsFolder(wxT("/Export/Path"));
245  wxString DefaultPath = filename.GetPath();
246 
247  if (mPluginIndex == -1)
248  {
249  mPluginIndex = 0;
250  mFilterIndex = 0;
251  mSubFormatIndex = 0;
252  }
253 
254  S.SetBorder(5);
255  S.StartHorizontalLay(wxEXPAND, true);
256  {
257  S.SetBorder(5);
258  S.StartStatic(_("Export files to:"), true);
259  {
260  S.StartMultiColumn(4, true);
261  {
262  mDir = S.Id(DirID)
263  .TieTextBox(_("Folder:"),
264  wxT("/Export/MultiplePath"),
265  DefaultPath,
266  64);
267  S.Id(ChooseID).AddButton(_("Choose..."));
268  S.Id(CreateID).AddButton(_("Create"));
269 
270  mFormat = S.Id(FormatID)
271  .TieChoice(_("Format:"),
272  wxT("/Export/MultipleFormat"),
273  formats[mFilterIndex],
274  formats,
275  formats);
276  S.AddVariableText( {}, false);
277  S.AddVariableText( {}, false);
278 
279  S.AddPrompt(_("Options:"));
280  if (!mBook)
281  {
282  mBook = safenew wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC);
283  for (const auto &pPlugin : mPlugins)
284  {
285  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
286  {
287  mBook->AddPage(pPlugin->OptionsCreate(mBook, j), wxEmptyString);
288  }
289  }
290  mBook->ChangeSelection(mFormat->GetSelection());
291  }
292  S.AddWindow(mBook);
293  S.AddVariableText( {}, false);
294  S.AddVariableText( {}, false);
295  }
296  S.EndMultiColumn();
297  }
298  S.EndStatic();
299  }
300  S.EndHorizontalLay();
301 
302  S.StartHorizontalLay(wxEXPAND, false);
303  {
304  S.SetBorder(5);
305  S.StartStatic(_("Split files based on:"), 1);
306  {
307  // Row 1
308  S.SetBorder(1);
309  mTrack = S.Id(TrackID)
310  .AddRadioButton(_("Tracks"));
311  mTrack->SetName(_("Tracks"));
312 
313  // Row 2
314  S.SetBorder(1);
315  mLabel = S.Id(LabelID).AddRadioButtonToGroup(_("Labels"));
316  mLabel->SetName(_("Labels"));
317  S.SetBorder(3);
318 
319  S.StartMultiColumn(2, wxEXPAND);
320  S.SetStretchyCol(1);
321  {
322  // Row 3 (indented)
323  S.AddVariableText(wxT(" "), false);
324  mFirst = S.Id(FirstID)
325  .AddCheckBox(_("Include audio before first label"), wxT("false"));
326 
327  // Row 4
328  S.AddVariableText( {}, false);
329  S.StartMultiColumn(2, wxEXPAND);
330  S.SetStretchyCol(1);
331  {
332  mFirstFileLabel = S.AddVariableText(_("First file name:"), false);
334  .Prop(1).TieTextBox( {},
335  name,
336  30);
337  mFirstFileName->SetName(_("First file name"));
338  }
339  S.EndMultiColumn();
340  }
341  S.EndMultiColumn();
342 
343  S.SetBorder(3);
344  }
345  S.EndStatic();
346 
347  S.SetBorder(5);
348  S.StartStatic(_("Name files:"), 1);
349  {
350  S.SetBorder(2);
351  S.StartRadioButtonGroup(wxT("/Export/TrackNameWithOrWithoutNumbers"), wxT("labelTrack"));
352  {
353  mByName = S.Id(ByNameID)
354  .TieRadioButton(_("Using Label/Track Name"), wxT("labelTrack"));
355 
357  .TieRadioButton(_("Numbering before Label/Track Name"), wxT("numberBefore"));
358 
359  mByNumber = S.Id(ByNumberID)
360  .TieRadioButton(_("Numbering after File name prefix"), wxT("numberAfter"));
361  }
363 
364  S.StartMultiColumn(3, wxEXPAND);
365  S.SetStretchyCol(2);
366  {
367  // Row 3 (indented)
368  S.AddVariableText(wxT(" "), false);
369  mPrefixLabel = S.AddVariableText(_("File name prefix:"), false);
370  mPrefix = S.Id(PrefixID)
371  .TieTextBox( {},
372  name,
373  30);
374  mPrefix->SetName(_("File name prefix"));
375  }
376  S.EndMultiColumn();
377  }
378  S.EndStatic();
379  }
380  S.EndHorizontalLay();
381 
382  S.SetBorder(5);
383  S.StartHorizontalLay(wxEXPAND, false);
384  {
385  mOverwrite = S.Id(OverwriteID).TieCheckBox(_("Overwrite existing files"),
386  wxT("/Export/OverwriteExisting"),
387  false);
388  }
389  S.EndHorizontalLay();
390 
391  S.AddStandardButtons();
392  mExport = (wxButton *)wxWindow::FindWindowById(wxID_OK, this);
393  mExport->SetLabel(_("Export"));
394 
395 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
wxRadioButton * mByNumberAndName
wxRadioButton * mTrack
void EndRadioButtonGroup()
wxRadioButton * mLabel
wxTextCtrl * mPrefix
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:257
static wxFileNameWrapper DefaultToDocumentsFolder(const wxString &preference)
Definition: FileNames.cpp:348
wxTextCtrl * mDir
AudacityProject * mProject
void EndMultiColumn()
wxSimplebook * mBook
wxButton * mExport
#define safenew
Definition: Audacity.h:223
void EndHorizontalLay()
Definition: ShuttleGui.cpp:975
wxRadioButton * mByName
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:215
wxStaticText * mPrefixLabel
wxTextCtrl * mFirstFileName
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxCheckBox * AddCheckBox(const wxString &Prompt, const wxString &Selected)
Definition: ShuttleGui.cpp:267
wxWindow * GetParent()
Definition: ShuttleGui.h:259
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:966
wxRadioButton * mByNumber
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:998
ShuttleGui & Id(int id)
wxCheckBox * mFirst
wxChoice * mFormat
wxRadioButton * TieRadioButton(const wxString &Prompt, WrappedType &WrappedRef)
std::vector< ExportPlugin * > mPlugins
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
const wxChar * name
Definition: Distortion.cpp:94
wxStaticText * AddVariableText(const wxString &Str, bool bCenter=false, int PositionFlags=0)
Definition: ShuttleGui.cpp:373
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:701
wxString GetName()
Definition: Project.cpp:1443
wxStaticText * mFirstFileLabel
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:374
wxRadioButton * AddRadioButtonToGroup(const wxString &Prompt)
Definition: ShuttleGui.cpp:443
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
void SetBorder(int Border)
Definition: ShuttleGui.h:251
void StartRadioButtonGroup(const wxString &SettingName)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:301
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:192
wxRadioButton * AddRadioButton(const wxString &Prompt)
Definition: ShuttleGui.cpp:427
wxTextCtrl * TieTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)
wxCheckBox * mOverwrite
int ExportMultiple::ShowModal ( )

Definition at line 178 of file ExportMultiple.cpp.

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

Referenced by AudacityProject::OnExportMultiple().

179 {
180  // Cannot export if all audio tracks are muted.
181  if (mNumWaveTracks == 0)
182  {
183  ::AudacityMessageBox(_("All audio is muted."),
184  _("Cannot Export Multiple"),
185  wxOK | wxCENTRE, this);
186  return wxID_CANCEL;
187  }
188 
189  if ((mNumWaveTracks == 1) && (mNumLabels < 1))
190  {
192 "You have only one unmuted Audio Track and no applicable \
193 \nlabels, so you cannot export to separate audio files."),
194  _("Cannot Export Multiple"),
195  wxOK | wxCENTRE, this);
196  return wxID_CANCEL;
197  }
198 
199  if (mNumLabels < 1) {
200  mLabel->Enable(false);
201  mTrack->SetValue(true);
202  mLabel->SetValue(false);
203  }
204 
205  if (mNumWaveTracks < 2) {
206  mTrack->Enable(false);
207  mLabel->SetValue(true);
208  mTrack->SetValue(false);
209  }
210 
211  EnableControls();
212 
213  return wxDialogWrapper::ShowModal();
214 }
wxRadioButton * mTrack
wxRadioButton * mLabel
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)

Member Data Documentation

wxSimplebook* ExportMultiple::mBook
private

Definition at line 162 of file ExportMultiple.h.

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

wxRadioButton* ExportMultiple::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().

wxRadioButton* ExportMultiple::mByNumber
private

button to choose numbering exported files

Definition at line 152 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

wxRadioButton* ExportMultiple::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().

wxButton* ExportMultiple::mCancel
private

Definition at line 159 of file ExportMultiple.h.

wxButton* ExportMultiple::mChoose
private

Definition at line 137 of file ExportMultiple.h.

wxButton* ExportMultiple::mCreate
private

Definition at line 136 of file ExportMultiple.h.

wxTextCtrl* ExportMultiple::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(), and PopulateOrExchange().

wxButton* ExportMultiple::mExport
private

Definition at line 160 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

wxArrayString ExportMultiple::mExported
private

Definition at line 128 of file ExportMultiple.h.

Referenced by DoExport(), and OnExport().

Exporter ExportMultiple::mExporter
private

Definition at line 107 of file ExportMultiple.h.

int ExportMultiple::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().

wxCheckBox* ExportMultiple::mFirst
private

Check box to export audio before first label

Definition at line 142 of file ExportMultiple.h.

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

wxStaticText* ExportMultiple::mFirstFileLabel
private

description text for mFirstFileName

Definition at line 143 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

wxTextCtrl* ExportMultiple::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().

wxChoice* ExportMultiple::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().

bool ExportMultiple::mInitialized
private

Definition at line 125 of file ExportMultiple.h.

Referenced by EnableControls().

wxRadioButton* ExportMultiple::mLabel
private

button to choose export based on Labels

Definition at line 139 of file ExportMultiple.h.

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

wxStaticText* ExportMultiple::mLabelLabel
private

description text for mLabel

Definition at line 140 of file ExportMultiple.h.

LabelTrack* ExportMultiple::mLabels
private

Definition at line 113 of file ExportMultiple.h.

Referenced by CountTracksAndLabels(), and ExportMultipleByLabel().

int ExportMultiple::mNumLabels
private

Definition at line 114 of file ExportMultiple.h.

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

int ExportMultiple::mNumWaveTracks
private

Definition at line 115 of file ExportMultiple.h.

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

wxButton* ExportMultiple::mOptions
private

Definition at line 132 of file ExportMultiple.h.

wxCheckBox* ExportMultiple::mOverwrite
private

Definition at line 157 of file ExportMultiple.h.

Referenced by DoExport(), and PopulateOrExchange().

int ExportMultiple::mPluginIndex
private

The index in mPlugins of the selected export plug-in

Definition at line 121 of file ExportMultiple.h.

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

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

Array of references to available exporter plug-ins

Definition at line 108 of file ExportMultiple.h.

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

wxTextCtrl* ExportMultiple::mPrefix
private

Definition at line 155 of file ExportMultiple.h.

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

wxStaticText* ExportMultiple::mPrefixLabel
private

Definition at line 154 of file ExportMultiple.h.

Referenced by EnableControls(), and PopulateOrExchange().

AudacityProject* ExportMultiple::mProject
private
SelectionState& ExportMultiple::mSelectionState
private

Definition at line 164 of file ExportMultiple.h.

Referenced by ExportMultipleByTrack().

int ExportMultiple::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 DoExport(), ExportMultipleByLabel(), ExportMultipleByTrack(), OnExport(), OnOptions(), and PopulateOrExchange().

wxRadioButton* ExportMultiple::mTrack
private

button to choose export based on tracks

Definition at line 147 of file ExportMultiple.h.

Referenced by PopulateOrExchange(), and ShowModal().

wxStaticText* ExportMultiple::mTrackLabel
private

Definition at line 148 of file ExportMultiple.h.

TrackList* ExportMultiple::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: