Audacity  2.3.1
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 80 of file Export.cpp.

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

Definition at line 84 of file Export.cpp.

85 {
86 }

Member Function Documentation

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

Definition at line 126 of file Export.cpp.

References mFormatInfos.

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

127 {
128  mFormatInfos[index].mExtensions.Add(extension);
129 }
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 100 of file Export.cpp.

References mFormatInfos.

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

101 {
102  FormatInfo nf;
103  mFormatInfos.push_back(nf);
104  return mFormatInfos.size();
105 }
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 88 of file Export.cpp.

Referenced by ExportPCM::CheckFileName().

89 {
90  return true;
91 }
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 238 of file Export.cpp.

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

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

Definition at line 213 of file Export.cpp.

214 {
215  return false;
216 }
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 194 of file Export.cpp.

References mFormatInfos.

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

Definition at line 156 of file Export.cpp.

References mFormatInfos.

Referenced by GetMask().

157 {
158  return mFormatInfos[index].mDescription;
159 }
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 161 of file Export.cpp.

References mFormatInfos.

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

162 {
163  return mFormatInfos[index].mExtensions[0];
164 }
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 166 of file Export.cpp.

References mFormatInfos.

Referenced by GetMask(), and IsExtension().

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

Definition at line 151 of file Export.cpp.

References mFormatInfos.

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

Definition at line 107 of file Export.cpp.

References mFormatInfos.

Referenced by IsExtension().

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

Definition at line 171 of file Export.cpp.

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

172 {
173  if (!mFormatInfos[index].mMask.IsEmpty()) {
174  return mFormatInfos[index].mMask;
175  }
176 
177  wxString mask = GetDescription(index) + wxT("|");
178 
179  // Build the mask
180  // wxString ext = GetExtension(index);
181  wxArrayString exts = GetExtensions(index);
182  for (size_t i = 0; i < exts.GetCount(); i++) {
183  mask += wxT("*.") + exts[i] + wxT(";");
184  }
185 
186  return mask;
187 }
static const wxChar * exts[]
Definition: ImportFLAC.cpp:53
virtual wxString GetDescription(int index)
Definition: Export.cpp:156
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:166
unsigned ExportPlugin::GetMaxChannels ( int  index)
virtual

Definition at line 189 of file Export.cpp.

References mFormatInfos.

190 {
191  return mFormatInfos[index].mMaxChannels;
192 }
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 256 of file Export.cpp.

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

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

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

Definition at line 199 of file Export.cpp.

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

Referenced by ExportPCM::CheckFileName().

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

Implemented in ExportMP3, ExportPCM, and ExportCL.

Definition at line 218 of file Export.cpp.

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

Referenced by ExportPCM::OptionsCreate().

219 {
220  wxASSERT(parent); // To justify safenew
221  wxPanel *p = safenew wxPanelWrapper(parent, wxID_ANY);
223 
224  S.StartHorizontalLay(wxCENTER);
225  {
226  S.StartHorizontalLay(wxCENTER, 0);
227  {
228  S.Prop(1).AddTitle(_("No format specific options"));
229  }
230  S.EndHorizontalLay();
231  }
232  S.EndHorizontalLay();
233 
234  return p;
235 }
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 146 of file Export.cpp.

References mFormatInfos.

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

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

Definition at line 121 of file Export.cpp.

References mFormatInfos.

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

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

Definition at line 131 of file Export.cpp.

References mFormatInfos.

Referenced by ExportPCM::ExportPCM().

132 {
133  mFormatInfos[index].mExtensions = extensions;
134 }
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 116 of file Export.cpp.

References format, and mFormatInfos.

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

117 {
118  mFormatInfos[index].mFormat = format;
119 }
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 136 of file Export.cpp.

References mFormatInfos.

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

Definition at line 141 of file Export.cpp.

References mFormatInfos.

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

142 {
143  mFormatInfos[index].mMaxChannels = maxchannels;
144 }
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: