Audacity  2.2.0
ExportMultiple.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ExportMultiple.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_EXPORT_MULTIPLE__
12 #define __AUDACITY_EXPORT_MULTIPLE__
13 
14 #include <wx/dialog.h>
15 #include <wx/string.h>
16 #include <wx/dynarray.h> // sadly we are using wx dynamic arrays
17 #include <wx/listctrl.h>
18 #include <wx/simplebook.h>
19 
20 #include "Export.h"
21 #include "../Tags.h" // we need to know about the Tags class for metadata
22 
23 class wxButton;
24 class wxCheckBox;
25 class wxChoice;
26 class wxRadioButton;
27 class wxTextCtrl;
28 
29 class AudacityProject;
30 class LabelTrack;
31 class SelectionState;
32 class ShuttleGui;
33 class Track;
34 
35 class ExportMultiple final : public wxDialogWrapper
36 {
37 public:
38 
40  virtual ~ExportMultiple();
41 
42  int ShowModal();
43 
44 private:
45 
46  // Export
47  void CanExport();
48  void CountTracksAndLabels();
49  bool DirOk();
58  ProgressResult ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber);
59 
66  ProgressResult ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber);
67 
78  ProgressResult DoExport(unsigned channels,
79  const wxFileName &name,
80  bool selectedOnly,
81  double t0,
82  double t1,
83  const Tags &tags);
87  wxString MakeFileName(const wxString &input);
88  // Dialog
90  void EnableControls();
91 
92  void OnFormat(wxCommandEvent& event);
93  void OnOptions(wxCommandEvent& event);
94  void OnCreate(wxCommandEvent& event);
95  void OnChoose(wxCommandEvent& event);
96  void OnLabel(wxCommandEvent& event);
97  void OnFirst(wxCommandEvent& event);
98  void OnFirstFileName(wxCommandEvent& event);
99  void OnTrack(wxCommandEvent& event);
100  void OnByName(wxCommandEvent& event);
101  void OnByNumber(wxCommandEvent& event);
102  void OnPrefix(wxCommandEvent& event);
103  void OnCancel(wxCommandEvent& event);
104  void OnExport(wxCommandEvent& event);
105 
106 private:
108  std::vector<ExportPlugin*> mPlugins;
116 
126 
127  // List of file actually exported
128  wxArrayString mExported;
129 
130  wxChoice *mFormat;
132  wxButton *mOptions;
133 
134  wxTextCtrl *mDir;
136  wxButton *mCreate;
137  wxButton *mChoose;
138 
139  wxRadioButton *mLabel;
140  wxStaticText *mLabelLabel;
142  wxCheckBox *mFirst;
143  wxStaticText *mFirstFileLabel;
144  wxTextCtrl *mFirstFileName;
147  wxRadioButton *mTrack;
148  wxStaticText *mTrackLabel;
149 
150  wxRadioButton *mByNumberAndName;
151  wxRadioButton *mByName;
152  wxRadioButton *mByNumber;
154  wxStaticText *mPrefixLabel;
155  wxTextCtrl *mPrefix;
156 
157  wxCheckBox *mOverwrite;
158 
159  wxButton *mCancel;
160  wxButton *mExport;
161 
162  wxSimplebook *mBook;
163 
165 
166  DECLARE_EVENT_TABLE()
167 
168 };
169 
170 class SuccessDialog final : public wxDialogWrapper
171 {
172 public:
173  SuccessDialog(wxWindow *parent, wxWindowID id, const wxString &title) :
174  wxDialogWrapper(parent, id, title, wxDefaultPosition,
175  wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {};
176  void OnKeyDown(wxListEvent& event); // dismisses dialog when <enter> is pressed with list control having focus
177  void OnItemActivated(wxListEvent& event); // dismisses dialog when <enter> is pressed with list item having focus
178 private:
179  DECLARE_EVENT_TABLE()
180 };
181 
182 class MouseEvtHandler final : public wxEvtHandler
183 {
184 public:
185  void OnMouse(wxMouseEvent& event);
186 private:
187  DECLARE_EVENT_TABLE()
188 };
189 
190 
196  class ExportKit
197  {
198  public:
200  wxFileName destfile;
201  double t0;
202  double t1;
203  unsigned channels;
204  }; // end of ExportKit declaration
205  /* we are going to want an set of these kits, and don't know how many until
206  * runtime. I would dearly like to use a std::vector, but it seems that
207  * this isn't done anywhere else in Audacity, presumably for a reason?, so
208  * I'm stuck with wxArrays, which are much harder, as well as non-standard.
209  */
210  WX_DECLARE_OBJARRAY(ExportKit, ExportKitArray);
211 
212 
213 #endif
void OnByNumber(wxCommandEvent &event)
Definition: ExportMultiple.cpp:516
wxRadioButton * mByNumberAndName
Definition: ExportMultiple.h:150
TrackList * mTracks
Definition: ExportMultiple.h:111
LabelTrack * mLabels
Definition: ExportMultiple.h:113
A list of TrackListNode items.
Definition: Track.h:532
ProgressResult
Definition: ProgressDialog.h:33
wxRadioButton * mTrack
Definition: ExportMultiple.h:147
int ShowModal()
Definition: ExportMultiple.cpp:178
SelectionState & mSelectionState
Definition: ExportMultiple.h:164
void OnFormat(wxCommandEvent &event)
Definition: ExportMultiple.cpp:431
SuccessDialog(wxWindow *parent, wxWindowID id, const wxString &title)
Definition: ExportMultiple.h:173
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:369
wxRadioButton * mLabel
Definition: ExportMultiple.h:139
Definition: SelectionState.h:20
wxTextCtrl * mPrefix
Definition: ExportMultiple.h:155
bool DirOk()
Definition: ExportMultiple.cpp:614
Definition: Export.h:140
double t1
Definition: ExportMultiple.h:202
void OnKeyDown(wxListEvent &event)
Definition: ExportMultiple.cpp:1028
void OnOptions(wxCommandEvent &event)
Definition: ExportMultiple.cpp:438
wxButton * mChoose
Definition: ExportMultiple.h:137
wxTextCtrl * mDir
Definition: ExportMultiple.h:134
int mFilterIndex
Definition: ExportMultiple.h:117
AudacityProject * mProject
Definition: ExportMultiple.h:110
wxString MakeFileName(const wxString &input)
Takes an arbitrary text string and converts it to a form that can be used as a file name...
Definition: ExportMultiple.cpp:986
wxSimplebook * mBook
Definition: ExportMultiple.h:162
Exporter mExporter
Definition: ExportMultiple.h:107
void OnByName(wxCommandEvent &event)
Definition: ExportMultiple.cpp:511
void EnableControls()
Definition: ExportMultiple.cpp:397
wxButton * mOptions
Definition: ExportMultiple.h:132
Definition: ExportMultiple.h:182
wxButton * mExport
Definition: ExportMultiple.h:160
void OnMouse(wxMouseEvent &event)
Definition: ExportMultiple.cpp:1041
Definition: wxPanelWrapper.h:19
void OnCreate(wxCommandEvent &event)
Definition: ExportMultiple.cpp:462
double t0
Definition: ExportMultiple.h:201
void OnPrefix(wxCommandEvent &event)
Definition: ExportMultiple.cpp:521
void CountTracksAndLabels()
Definition: ExportMultiple.cpp:143
wxButton * mCreate
Definition: ExportMultiple.h:136
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:114
wxRadioButton * mByName
Definition: ExportMultiple.h:151
wxButton * mCancel
Definition: ExportMultiple.h:159
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
wxStaticText * mPrefixLabel
Definition: ExportMultiple.h:154
wxTextCtrl * mFirstFileName
Definition: ExportMultiple.h:144
void OnLabel(wxCommandEvent &event)
Definition: ExportMultiple.cpp:491
ProgressResult ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber)
Export each track in the project to a separate file.
Definition: ExportMultiple.cpp:766
wxFileName destfile
Definition: ExportMultiple.h:200
virtual ~ExportMultiple()
Definition: ExportMultiple.cpp:139
wxRadioButton * mByNumber
Definition: ExportMultiple.h:152
WX_DECLARE_OBJARRAY(ExportKit, ExportKitArray)
void OnCancel(wxCommandEvent &event)
Definition: ExportMultiple.cpp:526
wxArrayString mExported
Definition: ExportMultiple.h:128
wxStaticText * mTrackLabel
Definition: ExportMultiple.h:148
Definition: ExportMultiple.h:170
int mSubFormatIndex
Definition: ExportMultiple.h:123
wxCheckBox * mFirst
Definition: ExportMultiple.h:142
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:85
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportMultiple.cpp:216
void OnItemActivated(wxListEvent &event)
Definition: ExportMultiple.cpp:1036
wxChoice * mFormat
Definition: ExportMultiple.h:130
void OnChoose(wxCommandEvent &event)
Definition: ExportMultiple.cpp:481
int mPluginIndex
Definition: ExportMultiple.h:121
ID3 Tags (for MP3)
Definition: Tags.h:76
bool mInitialized
Definition: ExportMultiple.h:125
std::vector< ExportPlugin * > mPlugins
Definition: ExportMultiple.h:108
A private class used to store the information needed to do an export.
Definition: ExportMultiple.h:196
void OnFirst(wxCommandEvent &event)
Definition: ExportMultiple.cpp:496
const wxChar * name
Definition: Distortion.cpp:93
Presents a dialog box allowing the user to export multiple files either by exporting each track as a ...
Definition: ExportMultiple.h:35
int mNumWaveTracks
Definition: ExportMultiple.h:115
wxStaticText * mFirstFileLabel
Definition: ExportMultiple.h:143
void OnExport(wxCommandEvent &event)
Definition: ExportMultiple.cpp:531
Tags filetags
Definition: ExportMultiple.h:199
ExportMultiple(AudacityProject *parent)
unsigned channels
Definition: ExportMultiple.h:203
int mNumLabels
Definition: ExportMultiple.h:114
void OnTrack(wxCommandEvent &event)
Definition: ExportMultiple.cpp:506
ProgressResult DoExport(unsigned channels, const wxFileName &name, bool selectedOnly, double t0, double t1, const Tags &tags)
Definition: ExportMultiple.cpp:932
void OnFirstFileName(wxCommandEvent &event)
Definition: ExportMultiple.cpp:501
wxStaticText * mLabelLabel
Definition: ExportMultiple.h:140
wxCheckBox * mOverwrite
Definition: ExportMultiple.h:157
ProgressResult ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber)
Export multiple labeled regions of the project to separate files.
Definition: ExportMultiple.cpp:640