Audacity 3.2.0
Public Types | 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:
[legend]
Collaboration diagram for ExportPlugin:
[legend]

Public Types

using ProgressResult = BasicUI::ProgressResult
 

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 TranslatableString &description, int index)
 
void AddExtension (const FileExtension &extension, int index)
 
void SetExtensions (FileExtensions extensions, int index)
 
void SetMask (FileNames::FileTypes mask, int index)
 
void SetMaxChannels (unsigned maxchannels, unsigned index)
 
void SetCanMetaData (bool canmetadata, int index)
 
virtual int GetFormatCount ()
 
virtual wxString GetFormat (int index)
 
TranslatableString GetDescription (int index)
 
virtual FileExtension GetExtension (int index=0)
 Return the (first) file name extension for the sub-format. More...
 
virtual FileExtensions GetExtensions (int index=0)
 Return all the file name extensions used for the sub-format. More...
 
FileNames::FileTypes GetMask (int index)
 
virtual unsigned GetMaxChannels (int index)
 
virtual bool GetCanMetaData (int index)
 
virtual bool IsExtension (const FileExtension &ext, int index)
 
virtual bool DisplayOptions (wxWindow *parent, int format=0)
 
virtual void OptionsCreate (ShuttleGui &S, 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< BasicUI::ProgressDialog > &pDialog, unsigned channels, const wxFileNameWrapper &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 TrackList &tracks, bool selectionOnly, double startTime, double stopTime, unsigned numOutChannels, size_t outBufferSize, bool outInterleaved, double outRate, sampleFormat outFormat, MixerSpec *mixerSpec)
 

Static Protected Member Functions

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

Private Attributes

std::vector< FormatInfomFormatInfos
 

Detailed Description

Definition at line 70 of file Export.h.

Member Typedef Documentation

◆ ProgressResult

Definition at line 73 of file Export.h.

Constructor & Destructor Documentation

◆ ExportPlugin()

ExportPlugin::ExportPlugin ( )

Definition at line 80 of file Export.cpp.

81{
82}

◆ ~ExportPlugin()

ExportPlugin::~ExportPlugin ( )
virtual

Definition at line 84 of file Export.cpp.

85{
86}

Member Function Documentation

◆ AddExtension()

void ExportPlugin::AddExtension ( const FileExtension extension,
int  index 
)

Definition at line 126 of file Export.cpp.

127{
128 mFormatInfos[index].mExtensions.push_back(extension);
129}
std::vector< FormatInfo > mFormatInfos
Definition: Export.h:158

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ AddFormat()

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.

101{
102 FormatInfo nf;
103 mFormatInfos.push_back(nf);
104 return mFormatInfos.size();
105}

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ CheckFileName()

bool ExportPlugin::CheckFileName ( wxFileName &  filename,
int  format = 0 
)
virtual

Reimplemented in ExportMP3, ExportCL, and ExportFFmpeg.

Definition at line 88 of file Export.cpp.

89{
90 return true;
91}

◆ CreateMixer()

std::unique_ptr< Mixer > ExportPlugin::CreateMixer ( const TrackList tracks,
bool  selectionOnly,
double  startTime,
double  stopTime,
unsigned  numOutChannels,
size_t  outBufferSize,
bool  outInterleaved,
double  outRate,
sampleFormat  outFormat,
MixerSpec mixerSpec 
)
protected

Definition at line 222 of file Export.cpp.

228{
229 Mixer::Inputs inputs;
230
231 bool anySolo = !(( tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo ).empty());
232
233 auto range = tracks.Any< const WaveTrack >()
234 + (selectionOnly ? &Track::IsSelected : &Track::Any )
235 - ( anySolo ? &WaveTrack::GetNotSolo : &WaveTrack::GetMute);
236 for (auto pTrack: range)
237 inputs.emplace_back(
238 pTrack->SharedPointer<const SampleTrack>(), GetEffectStages(*pTrack));
239 // MB: the stop time should not be warped, this was a bug.
240 return std::make_unique<Mixer>(move(inputs),
241 // Throw, to stop exporting, if read fails:
242 true,
243 Mixer::WarpOptions{tracks},
244 startTime, stopTime,
245 numOutChannels, outBufferSize, outInterleaved,
246 outRate, outFormat,
247 true, mixerSpec);
248}
std::vector< MixerOptions::StageSpecification > GetEffectStages(const WaveTrack &track)
std::vector< Input > Inputs
Definition: Mix.h:43
bool GetSolo() const
Definition: PlayableTrack.h:48
bool GetNotSolo() const
Definition: PlayableTrack.h:50
bool GetMute() const
Definition: PlayableTrack.h:47
bool IsSelected() const
Definition: Track.cpp:302
bool Any() const
Definition: Track.cpp:299
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1313
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
Immutable structure is an argument to Mixer's constructor.
Definition: MixerOptions.h:54

References TrackList::Any(), Track::Any(), GetEffectStages(), PlayableTrack::GetMute(), PlayableTrack::GetNotSolo(), PlayableTrack::GetSolo(), and Track::IsSelected().

Referenced by ExportCL::Export(), ExportFFmpeg::Export(), ExportFLAC::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportPCM::Export(), and ExportWavPack::Export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisplayOptions()

bool ExportPlugin::DisplayOptions ( wxWindow *  parent,
int  format = 0 
)
virtual

Definition at line 203 of file Export.cpp.

204{
205 return false;
206}

◆ Export()

virtual ProgressResult ExportPlugin::Export ( AudacityProject project,
std::unique_ptr< BasicUI::ProgressDialog > &  pDialog,
unsigned  channels,
const wxFileNameWrapper 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 ExportCL, ExportFFmpeg, ExportFLAC, ExportMP3, ExportOGG, ExportPCM, and ExportWavPack.

◆ GetCanMetaData()

bool ExportPlugin::GetCanMetaData ( int  index)
virtual

Definition at line 184 of file Export.cpp.

185{
186 return mFormatInfos[index].mCanMetaData;
187}

References mFormatInfos.

Referenced by ExportFFmpeg::Init().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString ExportPlugin::GetDescription ( int  index)

Definition at line 156 of file Export.cpp.

157{
158 return mFormatInfos[index].mDescription;
159}

References mFormatInfos.

Referenced by GetMask().

Here is the caller graph for this function:

◆ GetExtension()

FileExtension 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.

162{
163 return mFormatInfos[index].mExtensions[0];
164}

References mFormatInfos.

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

Here is the caller graph for this function:

◆ GetExtensions()

FileExtensions 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.

167{
168 return mFormatInfos[index].mExtensions;
169}

References mFormatInfos.

Referenced by GetMask(), and IsExtension().

Here is the caller graph for this function:

◆ GetFormat()

wxString ExportPlugin::GetFormat ( int  index)
virtual

Reimplemented in ExportPCM.

Definition at line 151 of file Export.cpp.

152{
153 return mFormatInfos[index].mFormat;
154}

References mFormatInfos.

Referenced by ExportPCM::GetFormat().

Here is the caller graph for this function:

◆ GetFormatCount()

int ExportPlugin::GetFormatCount ( )
virtual

Definition at line 107 of file Export.cpp.

108{
109 return mFormatInfos.size();
110}

References mFormatInfos.

Referenced by IsExtension().

Here is the caller graph for this function:

◆ GetMask()

FileNames::FileTypes ExportPlugin::GetMask ( int  index)

Definition at line 171 of file Export.cpp.

172{
173 if (!mFormatInfos[index].mMask.empty())
174 return mFormatInfos[index].mMask;
175
176 return { { GetDescription(index), GetExtensions(index) } };
177}
virtual FileExtensions GetExtensions(int index=0)
Return all the file name extensions used for the sub-format.
Definition: Export.cpp:166
TranslatableString GetDescription(int index)
Definition: Export.cpp:156

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

Here is the call graph for this function:

◆ GetMaxChannels()

unsigned ExportPlugin::GetMaxChannels ( int  index)
virtual

Reimplemented in ExportPCM.

Definition at line 179 of file Export.cpp.

180{
181 return mFormatInfos[index].mMaxChannels;
182}

References mFormatInfos.

◆ InitProgress() [1/2]

void ExportPlugin::InitProgress ( std::unique_ptr< BasicUI::ProgressDialog > &  pDialog,
const TranslatableString title,
const TranslatableString message 
)
staticprotected

Definition at line 250 of file Export.cpp.

252{
253 if (!pDialog)
254 pDialog = std::make_unique<ProgressDialog>( title, message );
255 else
256 {
257 if (auto pd = dynamic_cast<ProgressDialog*>(pDialog.get()))
258 {
259 pd->SetTitle(title);
260 pd->Reinit();
261 }
262
263 pDialog->SetMessage(message);
264 }
265}
static const auto title
Abstraction of a progress dialog with well defined time-to-completion estimate.
Definition: BasicUI.h:156

References title.

Referenced by ExportCL::Export(), ExportFFmpeg::Export(), ExportFLAC::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportPCM::Export(), ExportWavPack::Export(), and InitProgress().

Here is the caller graph for this function:

◆ InitProgress() [2/2]

void ExportPlugin::InitProgress ( std::unique_ptr< BasicUI::ProgressDialog > &  pDialog,
const wxFileNameWrapper title,
const TranslatableString message 
)
staticprotected

Definition at line 267 of file Export.cpp.

269{
270 return InitProgress(
271 pDialog, Verbatim( title.GetName() ), message );
272}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
static void InitProgress(std::unique_ptr< BasicUI::ProgressDialog > &pDialog, const TranslatableString &title, const TranslatableString &message)
Definition: Export.cpp:250

References InitProgress(), title, and Verbatim().

Here is the call graph for this function:

◆ IsExtension()

bool ExportPlugin::IsExtension ( const FileExtension ext,
int  index 
)
virtual

Definition at line 189 of file Export.cpp.

190{
191 bool isext = false;
192 for (int i = index; i < GetFormatCount(); i = GetFormatCount())
193 {
194 const auto &defext = GetExtension(i);
195 const auto &defexts = GetExtensions(i);
196 int indofext = defexts.Index(ext, false);
197 if (defext.empty() || (indofext != wxNOT_FOUND))
198 isext = true;
199 }
200 return isext;
201}
virtual FileExtension GetExtension(int index=0)
Return the (first) file name extension for the sub-format.
Definition: Export.cpp:161
virtual int GetFormatCount()
Definition: Export.cpp:107

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

Here is the call graph for this function:

◆ OptionsCreate()

void ExportPlugin::OptionsCreate ( ShuttleGui S,
int  format 
)
pure virtual

Implemented in ExportCL, ExportFFmpeg, ExportFLAC, ExportMP3, ExportOGG, ExportPCM, and ExportWavPack.

Definition at line 208 of file Export.cpp.

209{
210 S.StartHorizontalLay(wxCENTER);
211 {
212 S.StartHorizontalLay(wxCENTER, 0);
213 {
214 S.Prop(1).AddTitle(XO("No format specific options"));
215 }
216 S.EndHorizontalLay();
217 }
218 S.EndHorizontalLay();
219}
XO("Cut/Copy/Paste")
#define S(N)
Definition: ToChars.cpp:64

References S, and XO().

Referenced by ExportFFmpeg::OptionsCreate(), and ExportPCM::OptionsCreate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCanMetaData()

void ExportPlugin::SetCanMetaData ( bool  canmetadata,
int  index 
)

Definition at line 146 of file Export.cpp.

147{
148 mFormatInfos[index].mCanMetaData = canmetadata;
149}

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ SetDescription()

void ExportPlugin::SetDescription ( const TranslatableString description,
int  index 
)

Definition at line 121 of file Export.cpp.

122{
123 mFormatInfos[index].mDescription = description;
124}

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ SetExtensions()

void ExportPlugin::SetExtensions ( FileExtensions  extensions,
int  index 
)

Definition at line 131 of file Export.cpp.

132{
133 mFormatInfos[index].mExtensions = std::move(extensions);
134}

References mFormatInfos.

Referenced by ExportPCM::ExportPCM().

Here is the caller graph for this function:

◆ SetFormat()

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.

117{
118 mFormatInfos[index].mFormat = format;
119}
int format
Definition: ExportPCM.cpp:53

References format, and mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ SetMask()

void ExportPlugin::SetMask ( FileNames::FileTypes  mask,
int  index 
)

Definition at line 136 of file Export.cpp.

137{
138 mFormatInfos[index].mMask = std::move( mask );
139}

References mFormatInfos.

◆ SetMaxChannels()

void ExportPlugin::SetMaxChannels ( unsigned  maxchannels,
unsigned  index 
)

Definition at line 141 of file Export.cpp.

142{
143 mFormatInfos[index].mMaxChannels = maxchannels;
144}

References mFormatInfos.

Referenced by ExportCL::ExportCL(), ExportFFmpeg::ExportFFmpeg(), ExportFLAC::ExportFLAC(), ExportMP3::ExportMP3(), ExportOGG::ExportOGG(), ExportPCM::ExportPCM(), and ExportWavPack::ExportWavPack().

Here is the caller graph for this function:

◆ SetNumExportChannels()

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 109 of file Export.h.

109{ return -1; }

Member Data Documentation

◆ mFormatInfos

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

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