Audacity  2.2.0
Export.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Export.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_EXPORT__
12 #define __AUDACITY_EXPORT__
13 
14 #include "../MemoryX.h"
15 #include <vector>
16 #include <wx/dialog.h>
17 #include <wx/dynarray.h>
18 #include <wx/filename.h>
19 #include <wx/simplebook.h>
20 #include "../Tags.h"
21 #include "../SampleFormat.h"
22 #include "../widgets/wxPanelWrapper.h"
23 
24 class FileDialog;
25 class wxFileCtrlEvent;
26 class wxMemoryDC;
27 class wxStaticText;
28 class AudacityProject;
29 class DirManager;
30 class WaveTrack;
31 class TrackList;
32 class MixerSpec;
33 class TimeTrack;
34 class Mixer;
36 enum class ProgressResult : unsigned;
37 
38 class AUDACITY_DLL_API FormatInfo
39 {
40  public:
43  wxString mFormat;
44  wxString mDescription;
45  // wxString mExtension;
46  wxArrayString mExtensions;
47  wxString mMask;
48  unsigned mMaxChannels;
50 };
51 
52 WX_DECLARE_USER_EXPORTED_OBJARRAY(FormatInfo, FormatInfoArray, AUDACITY_DLL_API);
53 
54 //----------------------------------------------------------------------------
55 // ExportPlugin
56 //----------------------------------------------------------------------------
57 class AUDACITY_DLL_API ExportPlugin /* not final */
58 {
59 public:
60 
61  ExportPlugin();
62  virtual ~ExportPlugin();
63 
64  int AddFormat();
65  void SetFormat(const wxString & format, int index);
66  void SetDescription(const wxString & description, int index);
67  void AddExtension(const wxString &extension,int index);
68  void SetExtensions(const wxArrayString & extensions, int index);
69  void SetMask(const wxString & mask, int index);
70  void SetMaxChannels(unsigned maxchannels, unsigned index);
71  void SetCanMetaData(bool canmetadata, int index);
72 
73  virtual int GetFormatCount();
74  virtual wxString GetFormat(int index);
75  virtual wxString GetDescription(int index);
78  virtual wxString GetExtension(int index = 0);
81  virtual wxArrayString GetExtensions(int index = 0);
82  virtual wxString GetMask(int index);
83  virtual unsigned GetMaxChannels(int index);
84  virtual bool GetCanMetaData(int index);
85 
86  virtual bool IsExtension(const wxString & ext, int index);
87 
88  virtual bool DisplayOptions(wxWindow *parent, int format = 0);
89 
90  // Precondition: parent != NULL
91  virtual wxWindow *OptionsCreate(wxWindow *parent, int format) = 0;
92 
93  virtual bool CheckFileName(wxFileName &filename, int format = 0);
96  virtual int SetNumExportChannels() { return -1; }
97 
112  virtual ProgressResult Export(AudacityProject *project,
113  unsigned channels,
114  const wxString &fName,
115  bool selectedOnly,
116  double t0,
117  double t1,
118  MixerSpec *mixerSpec = NULL,
119  const Tags *metadata = NULL,
120  int subformat = 0) = 0;
121 
122 protected:
123  std::unique_ptr<Mixer> CreateMixer(const WaveTrackConstArray &inputTracks,
124  const TimeTrack *timeTrack,
125  double startTime, double stopTime,
126  unsigned numOutChannels, size_t outBufferSize, bool outInterleaved,
127  double outRate, sampleFormat outFormat,
128  bool highQuality = true, MixerSpec *mixerSpec = NULL);
129 
130 private:
131  FormatInfoArray mFormatInfos;
132 };
133 
134 using ExportPluginArray = std::vector < movable_ptr< ExportPlugin > > ;
135 WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API);
136 
137 //----------------------------------------------------------------------------
138 // Exporter
139 //----------------------------------------------------------------------------
140 class AUDACITY_DLL_API Exporter final : public wxEvtHandler
141 {
142 public:
143 
144  Exporter();
145  virtual ~Exporter();
146 
147  void SetFileDialogTitle( const wxString & DialogTitle );
148  void SetDefaultFormat( const wxString & Format ){ mFormatName = Format;};
149  void RegisterPlugin(movable_ptr<ExportPlugin> &&plugin);
150 
151  bool Process(AudacityProject *project, bool selectedOnly,
152  double t0, double t1);
153  bool Process(AudacityProject *project, unsigned numChannels,
154  const wxChar *type, const wxString & filename,
155  bool selectedOnly, double t0, double t1);
156 
157  void DisplayOptions(int index);
158  int FindFormatIndex(int exportindex);
159 
160  const ExportPluginArray &GetPlugins();
161 
162  // Auto Export from Timer Recording
163  bool ProcessFromTimerRecording(AudacityProject *project,
164  bool selectedOnly,
165  double t0,
166  double t1,
167  wxFileName fnFile,
168  int iFormat,
169  int iSubFormat,
170  int iFilterIndex);
171  bool SetAutoExportOptions(AudacityProject *project);
172  int GetAutoExportFormat();
173  int GetAutoExportSubFormat();
174  int GetAutoExportFilterIndex();
175  wxFileName GetAutoExportFileName();
176 
177 private:
178  bool ExamineTracks();
179  bool GetFilename();
180  bool CheckFilename();
181  bool CheckMix();
182  bool ExportTracks();
183 
184  static void CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata);
185  void CreateUserPane(wxWindow *parent);
186  void OnFilterChanged(wxFileCtrlEvent & evt);
187 
188 private:
189  wxString mFormatName;
190  FileDialog *mDialog;
193  std::unique_ptr<MixerSpec> mMixerSpec;
194 
196 
197  wxFileName mFilename;
198  wxFileName mActualName;
199 
200  double mT0;
201  double mT1;
203  int mFormat;
206  unsigned mNumLeft;
207  unsigned mNumRight;
208  unsigned mNumMono;
209  unsigned mChannels;
211 
212  wxSimplebook *mBook;
213 
214  DECLARE_EVENT_TABLE()
215 };
216 
217 //----------------------------------------------------------------------------
218 // ExportMixerPanel
219 //----------------------------------------------------------------------------
220 class ExportMixerPanel final : public wxPanelWrapper
221 {
222 public:
223  ExportMixerPanel( MixerSpec *mixerSpec, wxArrayString trackNames,
224  wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
225  const wxSize& size = wxDefaultSize);
226  virtual ~ExportMixerPanel();
227 
228  void OnMouseEvent(wxMouseEvent & event);
229  void OnPaint(wxPaintEvent & event);
230 
231 private:
232  std::unique_ptr<wxBitmap> mBitmap;
233  wxRect mEnvRect;
234  int mWidth;
235  int mHeight;
240  wxArrayString mTrackNames;
242 
243  void SetFont( wxMemoryDC &memDC, const wxString &text, int width, int height );
244  double Distance( wxPoint &a, wxPoint &b );
245  bool IsOnLine( wxPoint p, wxPoint la, wxPoint lb );
246 
247  DECLARE_EVENT_TABLE()
248 };
249 
250 //----------------------------------------------------------------------------
251 // ExportMixerDialog
252 //----------------------------------------------------------------------------
253 class ExportMixerDialog final : public wxDialogWrapper
254 {
255 public:
256  // constructors and destructors
257  ExportMixerDialog( const TrackList * tracks, bool selectedOnly, unsigned maxNumChannels,
258  wxWindow *parent, wxWindowID id, const wxString &title,
259  const wxPoint& pos = wxDefaultPosition,
260  const wxSize& size = wxDefaultSize,
261  long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
262  virtual ~ExportMixerDialog();
263 
264  MixerSpec* GetMixerSpec() { return mMixerSpec.get(); }
265 
266 private:
267  wxStaticText *mChannelsText;
268  std::unique_ptr<MixerSpec> mMixerSpec;
269  wxArrayString mTrackNames;
270 
271 private:
272  void OnOk( wxCommandEvent &event );
273  void OnCancel( wxCommandEvent &event );
274  void OnSlider( wxCommandEvent &event );
275  void OnSize( wxSizeEvent &event );
276 
277 private:
278  DECLARE_EVENT_TABLE()
279 };
280 #endif
A list of TrackListNode items.
Definition: Track.h:550
wxFileName mFilename
Definition: Export.h:197
virtual ~ExportMixerDialog()
Definition: Export.cpp:1335
std::unique_ptr< MixerSpec > mMixerSpec
Definition: Export.h:268
Creates and manages BlockFile objects.
Definition: DirManager.h:52
ProgressResult
Definition: ProgressDialog.h:33
std::unique_ptr< T > movable_ptr
Definition: MemoryX.h:683
Abstract base class used in importing a file.
Definition: Import.h:32
wxStaticText * mChannelsText
Definition: Export.h:267
Definition: Export.h:140
double mT1
Definition: Export.h:201
void SetDefaultFormat(const wxString &Format)
Definition: Export.h:148
int mSelectedChannel
Definition: Export.h:239
void OnSize(wxSizeEvent &event)
Definition: Export.cpp:1339
Definition: Export.h:38
ArrayOf< wxRect > mTrackRects
Definition: Export.h:238
bool mSelectedOnly
Definition: Export.h:210
wxString mDescription
Definition: Export.h:44
int mSelectedTrack
Definition: Export.h:239
wxString mFormat
Definition: Export.h:42
wxString mFormatName
Definition: Export.h:189
virtual int SetNumExportChannels()
Exporter plug-ins may override this to specify the number of channels in exported file...
Definition: Export.h:96
void OnCancel(wxCommandEvent &event)
Definition: Export.cpp:1363
std::unique_ptr< MixerSpec > mMixerSpec
Definition: Export.h:193
Main class to control the export function.
void SetFont(wxMemoryDC &memDC, const wxString &text, int width, int height)
Definition: Export.cpp:1029
Definition: Track.h:53
unsigned mChannels
Definition: Export.h:209
unsigned mMaxChannels
Definition: Export.h:48
wxArrayString mTrackNames
Definition: Export.h:269
Definition: wxPanelWrapper.h:19
bool IsOnLine(wxPoint p, wxPoint la, wxPoint lb)
Definition: Export.cpp:1173
FileDialog * mDialog
Definition: Export.h:190
void OnMouseEvent(wxMouseEvent &event)
Definition: Export.cpp:1178
unsigned mNumRight
Definition: Export.h:207
AudacityProject * mProject
Definition: Export.h:192
MixerSpec * GetMixerSpec()
Definition: Export.h:264
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
Definition: Export.h:57
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:29
wxString mFileDialogTitle
Definition: Export.h:191
int format
Definition: ExportPCM.cpp:56
wxArrayString mTrackNames
Definition: Export.h:240
unsigned mNumLeft
Definition: Export.h:206
A Track that contains audio waveform data.
Definition: WaveTrack.h:76
int mSubFormat
Definition: Export.h:204
ExportPluginArray mPlugins
Definition: Export.h:195
virtual ~ExportMixerPanel()
Definition: Export.cpp:1024
wxSimplebook * mBook
Definition: Export.h:212
wxString mMask
Definition: Export.h:47
double Distance(wxPoint &a, wxPoint &b)
Definition: Export.cpp:1167
ID3 Tags (for MP3)
Definition: Tags.h:76
FormatInfo()
Definition: Export.h:41
std::unique_ptr< wxBitmap > mBitmap
Definition: Export.h:232
wxFileName mActualName
Definition: Export.h:198
bool mCanMetaData
Definition: Export.h:49
unsigned mNumMono
Definition: Export.h:208
~FormatInfo()
Definition: Export.h:42
void OnPaint(wxPaintEvent &event)
Definition: Export.cpp:1050
void OnSlider(wxCommandEvent &event)
Definition: Export.cpp:1346
int mWidth
Definition: Export.h:234
ArrayOf< wxRect > mChannelRects
Definition: Export.h:237
double mT0
Definition: Export.h:200
WX_DECLARE_USER_EXPORTED_OBJARRAY(FormatInfo, FormatInfoArray, AUDACITY_DLL_API)
ExportMixerDialog(const TrackList *tracks, bool selectedOnly, unsigned maxNumChannels, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
Definition: Export.cpp:1251
int mFormat
Definition: Export.h:203
int mChannelHeight
Definition: Export.h:241
int mFilterIndex
Definition: Export.h:202
Dialog for advanced mixing.
Definition: Export.h:253
int mBoxWidth
Definition: Export.h:241
wxArrayString mExtensions
Definition: Export.h:46
FormatInfoArray mFormatInfos
Definition: Export.h:131
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxWindow *, WindowPtrArray, class AUDACITY_DLL_API)
wxRect mEnvRect
Definition: Export.h:233
void OnOk(wxCommandEvent &event)
Definition: Export.cpp:1358
Functions for doing the mixdown of the tracks.
Definition: Mix.h:79
int mTrackHeight
Definition: Export.h:241
int mNumSelected
Definition: Export.h:205
std::vector< movable_ptr< ExportPlugin > > ExportPluginArray
Definition: Export.h:134
int mHeight
Definition: Export.h:235
Panel that displays mixing for advanced mixing option.
Definition: Export.h:220
ExportMixerPanel(MixerSpec *mixerSpec, wxArrayString trackNames, wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
Definition: Export.cpp:1008
Class used with Mixer.
Definition: Mix.h:57
MixerSpec * mMixerSpec
Definition: Export.h:236