Audacity  2.2.2
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
ExportPlugin Class Referenceabstract

#include <Export.h>

Inheritance diagram for ExportPlugin:
ExportCL ExportMP3 ExportPCM

Public Member Functions

 ExportPlugin ()
 
virtual ~ExportPlugin ()
 
int AddFormat ()
 Add a NEW entry to the list of formats this plug-in can export. More...
 
void SetFormat (const wxString &format, int index)
 
void SetDescription (const wxString &description, int index)
 
void AddExtension (const wxString &extension, int index)
 
void SetExtensions (const wxArrayString &extensions, int index)
 
void SetMask (const wxString &mask, int index)
 
void SetMaxChannels (unsigned maxchannels, unsigned index)
 
void SetCanMetaData (bool canmetadata, int index)
 
virtual int GetFormatCount ()
 
virtual wxString GetFormat (int index)
 
virtual wxString GetDescription (int index)
 
virtual wxString GetExtension (int index=0)
 Return the (first) file name extension for the sub-format. More...
 
virtual wxArrayString GetExtensions (int index=0)
 Return all the file name extensions used for the sub-format. More...
 
virtual wxString GetMask (int index)
 
virtual unsigned GetMaxChannels (int index)
 
virtual bool GetCanMetaData (int index)
 
virtual bool IsExtension (const wxString &ext, int index)
 
virtual bool DisplayOptions (wxWindow *parent, int format=0)
 
virtual wxWindow * OptionsCreate (wxWindow *parent, int format)=0
 
virtual bool CheckFileName (wxFileName &filename, int format=0)
 
virtual int SetNumExportChannels ()
 Exporter plug-ins may override this to specify the number of channels in exported file. -1 for unspecified. More...
 
virtual ProgressResult Export (AudacityProject *project, std::unique_ptr< ProgressDialog > &pDialog, unsigned channels, const wxString &fName, bool selectedOnly, double t0, double t1, MixerSpec *mixerSpec=NULL, const Tags *metadata=NULL, int subformat=0)=0
 called to export audio into a file. More...
 

Protected Member Functions

std::unique_ptr< MixerCreateMixer (const WaveTrackConstArray &inputTracks, const TimeTrack *timeTrack, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, bool highQuality=true, MixerSpec *mixerSpec=NULL)
 

Static Protected Member Functions

static void InitProgress (std::unique_ptr< ProgressDialog > &pDialog, const wxString &title, const wxString &message)
 

Private Attributes

std::vector< FormatInfomFormatInfos
 

Detailed Description

Definition at line 60 of file Export.h.

Constructor & Destructor Documentation

ExportPlugin::ExportPlugin ( )

Definition at line 79 of file Export.cpp.

80 {
81 }
ExportPlugin::~ExportPlugin ( )
virtual

Definition at line 83 of file Export.cpp.

84 {
85 }

Member Function Documentation

void ExportPlugin::AddExtension ( const wxString &  extension,
int  index 
)

Definition at line 125 of file Export.cpp.

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

126 {
127  mFormatInfos[index].mExtensions.Add(extension);
128 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
int ExportPlugin::AddFormat ( )

Add a NEW entry to the list of formats this plug-in can export.

To configure the format use SetFormat, SetCanMetaData etc with the index of the format.

Returns
The number of formats currently set up. This is one more than the index of the newly added format.

Definition at line 99 of file Export.cpp.

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

100 {
101  FormatInfo nf;
102  mFormatInfos.push_back(nf);
103  return mFormatInfos.size();
104 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
bool ExportPlugin::CheckFileName ( wxFileName &  filename,
int  format = 0 
)
virtual

Reimplemented in ExportMP3, and ExportPCM.

Definition at line 87 of file Export.cpp.

Referenced by ExportPCM::CheckFileName().

88 {
89  return true;
90 }
std::unique_ptr< Mixer > ExportPlugin::CreateMixer ( const WaveTrackConstArray inputTracks,
const TimeTrack timeTrack,
double  startTime,
double  stopTime,
unsigned  numOutChannels,
size_t  outBufferSize,
bool  outInterleaved,
double  outRate,
sampleFormat  outFormat,
bool  highQuality = true,
MixerSpec mixerSpec = NULL 
)
protected

Definition at line 237 of file Export.cpp.

Referenced by ExportCL::Export(), ExportPCM::Export(), and ExportMP3::Export().

243 {
244  // MB: the stop time should not be warped, this was a bug.
245  return std::make_unique<Mixer>(inputTracks,
246  // Throw, to stop exporting, if read fails:
247  true,
248  Mixer::WarpOptions(timeTrack),
249  startTime, stopTime,
250  numOutChannels, outBufferSize, outInterleaved,
251  outRate, outFormat,
252  highQuality, mixerSpec);
253 }
bool ExportPlugin::DisplayOptions ( wxWindow *  parent,
int  format = 0 
)
virtual

Definition at line 212 of file Export.cpp.

213 {
214  return false;
215 }
virtual ProgressResult ExportPlugin::Export ( AudacityProject project,
std::unique_ptr< ProgressDialog > &  pDialog,
unsigned  channels,
const wxString &  fName,
bool  selectedOnly,
double  t0,
double  t1,
MixerSpec mixerSpec = NULL,
const Tags metadata = NULL,
int  subformat = 0 
)
pure virtual

called to export audio into a file.

Parameters
pDialogTo be initialized with pointer to a NEW ProgressDialog if it was null, otherwise gives an existing dialog to be reused (working around a problem in wxWidgets for Mac; see bug 1600)
selectedOnlySet to true if all tracks should be mixed, to false if only the selected tracks should be mixed and exported.
metadataA Tags object that will over-ride the one in *project and be used to tag the file that is exported.
subformatControl which of the multiple formats this exporter is capable of exporting should be used. Used where a single export plug-in handles a number of related formats, but they have separate entries in the Format drop-down list box. For example, the options to export to "Other PCM", "AIFF 16 Bit" and "WAV 16 Bit" are all the same libsndfile export plug-in, but with subformat set to 0, 1, and 2 respectively.
Returns
ProgressResult::Failed or ProgressResult::Cancelled if export fails to complete for any reason, in which case this function is responsible for alerting the user. Otherwise ProgressResult::Success or ProgressResult::Stopped

Implemented in ExportMP3, ExportPCM, and ExportCL.

bool ExportPlugin::GetCanMetaData ( int  index)
virtual

Definition at line 193 of file Export.cpp.

References mFormatInfos.

194 {
195  return mFormatInfos[index].mCanMetaData;
196 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
wxString ExportPlugin::GetDescription ( int  index)
virtual

Definition at line 155 of file Export.cpp.

References mFormatInfos.

Referenced by GetMask().

156 {
157  return mFormatInfos[index].mDescription;
158 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
wxString ExportPlugin::GetExtension ( int  index = 0)
virtual

Return the (first) file name extension for the sub-format.

Parameters
indexThe sub-format for which the extension is wanted

Reimplemented in ExportPCM.

Definition at line 160 of file Export.cpp.

References mFormatInfos.

Referenced by ExportPCM::GetExtension(), and IsExtension().

161 {
162  return mFormatInfos[index].mExtensions[0];
163 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
wxArrayString ExportPlugin::GetExtensions ( int  index = 0)
virtual

Return all the file name extensions used for the sub-format.

Parameters
indexthe sub-format for which the extension is required

Definition at line 165 of file Export.cpp.

References mFormatInfos.

Referenced by GetMask(), and IsExtension().

166 {
167  return mFormatInfos[index].mExtensions;
168 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
wxString ExportPlugin::GetFormat ( int  index)
virtual

Definition at line 150 of file Export.cpp.

References mFormatInfos.

151 {
152  return mFormatInfos[index].mFormat;
153 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
int ExportPlugin::GetFormatCount ( )
virtual

Definition at line 106 of file Export.cpp.

References mFormatInfos.

Referenced by IsExtension().

107 {
108  return mFormatInfos.size();
109 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
wxString ExportPlugin::GetMask ( int  index)
virtual

Definition at line 170 of file Export.cpp.

References exts, GetDescription(), GetExtensions(), and mFormatInfos.

171 {
172  if (!mFormatInfos[index].mMask.IsEmpty()) {
173  return mFormatInfos[index].mMask;
174  }
175 
176  wxString mask = GetDescription(index) + wxT("|");
177 
178  // Build the mask
179  // wxString ext = GetExtension(index);
180  wxArrayString exts = GetExtensions(index);
181  for (size_t i = 0; i < exts.GetCount(); i++) {
182  mask += wxT("*.") + exts[i] + wxT(";");
183  }
184 
185  return mask;
186 }
static const wxChar * exts[]
Definition: ImportFLAC.cpp:53
virtual wxString GetDescription(int index)
Definition: Export.cpp:155
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
virtual wxArrayString GetExtensions(int index=0)
Return all the file name extensions used for the sub-format.
Definition: Export.cpp:165
unsigned ExportPlugin::GetMaxChannels ( int  index)
virtual

Definition at line 188 of file Export.cpp.

References mFormatInfos.

189 {
190  return mFormatInfos[index].mMaxChannels;
191 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
void ExportPlugin::InitProgress ( std::unique_ptr< ProgressDialog > &  pDialog,
const wxString &  title,
const wxString &  message 
)
staticprotected

Definition at line 255 of file Export.cpp.

References ProgressDialog::Reinit(), and ProgressDialog::SetMessage().

Referenced by ExportCL::Export(), ExportPCM::Export(), and ExportMP3::Export().

257 {
258  if (!pDialog)
259  pDialog = std::make_unique<ProgressDialog>( title, message );
260  else {
261  pDialog->SetTitle( title );
262  pDialog->SetMessage( message );
263  pDialog->Reinit();
264  }
265 }
void SetMessage(const wxString &message)
bool ExportPlugin::IsExtension ( const wxString &  ext,
int  index 
)
virtual

Definition at line 198 of file Export.cpp.

References GetExtension(), GetExtensions(), and GetFormatCount().

Referenced by ExportPCM::CheckFileName().

199 {
200  bool isext = false;
201  for (int i = index; i < GetFormatCount(); i = GetFormatCount())
202  {
203  wxString defext = GetExtension(i);
204  wxArrayString defexts = GetExtensions(i);
205  int indofext = defexts.Index(ext, false);
206  if (defext == wxT("") || (indofext != wxNOT_FOUND))
207  isext = true;
208  }
209  return isext;
210 }
virtual int GetFormatCount()
Definition: Export.cpp:106
virtual wxString GetExtension(int index=0)
Return the (first) file name extension for the sub-format.
Definition: Export.cpp:160
virtual wxArrayString GetExtensions(int index=0)
Return all the file name extensions used for the sub-format.
Definition: Export.cpp:165
wxWindow * ExportPlugin::OptionsCreate ( wxWindow *  parent,
int  format 
)
pure virtual

Implemented in ExportMP3, ExportPCM, and ExportCL.

Definition at line 217 of file Export.cpp.

References _(), ShuttleGuiBase::AddTitle(), eIsCreatingFromPrefs, ShuttleGuiBase::EndHorizontalLay(), ShuttleGui::Prop(), safenew, and ShuttleGuiBase::StartHorizontalLay().

Referenced by ExportPCM::OptionsCreate().

218 {
219  wxASSERT(parent); // To justify safenew
220  wxPanel *p = safenew wxPanelWrapper(parent, wxID_ANY);
222 
223  S.StartHorizontalLay(wxCENTER);
224  {
225  S.StartHorizontalLay(wxCENTER, 0);
226  {
227  S.Prop(1).AddTitle(_("No format specific options"));
228  }
229  S.EndHorizontalLay();
230  }
231  S.EndHorizontalLay();
232 
233  return p;
234 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
#define safenew
Definition: Audacity.h:230
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void ExportPlugin::SetCanMetaData ( bool  canmetadata,
int  index 
)

Definition at line 145 of file Export.cpp.

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

146 {
147  mFormatInfos[index].mCanMetaData = canmetadata;
148 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
void ExportPlugin::SetDescription ( const wxString &  description,
int  index 
)

Definition at line 120 of file Export.cpp.

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

121 {
122  mFormatInfos[index].mDescription = description;
123 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
void ExportPlugin::SetExtensions ( const wxArrayString &  extensions,
int  index 
)

Definition at line 130 of file Export.cpp.

References mFormatInfos.

Referenced by ExportPCM::ExportPCM().

131 {
132  mFormatInfos[index].mExtensions = extensions;
133 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
void ExportPlugin::SetFormat ( const wxString &  format,
int  index 
)
Parameters
indexThe plugin to set the format for (range 0 to one less than the count of formats)

Definition at line 115 of file Export.cpp.

References format, and mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

116 {
117  mFormatInfos[index].mFormat = format;
118 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
int format
Definition: ExportPCM.cpp:56
void ExportPlugin::SetMask ( const wxString &  mask,
int  index 
)

Definition at line 135 of file Export.cpp.

References mFormatInfos.

136 {
137  mFormatInfos[index].mMask = mask;
138 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
void ExportPlugin::SetMaxChannels ( unsigned  maxchannels,
unsigned  index 
)

Definition at line 140 of file Export.cpp.

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportMP3::ExportMP3(), and ExportPCM::ExportPCM().

141 {
142  mFormatInfos[index].mMaxChannels = maxchannels;
143 }
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:146
virtual int ExportPlugin::SetNumExportChannels ( )
inlinevirtual

Exporter plug-ins may override this to specify the number of channels in exported file. -1 for unspecified.

Reimplemented in ExportMP3.

Definition at line 99 of file Export.h.

99 { return -1; }

Member Data Documentation

std::vector<FormatInfo> ExportPlugin::mFormatInfos
private

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