Audacity 3.2.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ExportCommand Class Reference

Command for exporting audio. More...

#include <ImportExportCommands.h>

Inheritance diagram for ExportCommand:
[legend]
Collaboration diagram for ExportCommand:
[legend]

Public Member Functions

ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
template<bool Const>
bool VisitSettings (SettingsVisitorBase< Const > &S)
 
bool VisitSettings (SettingsVisitor &S) override
 
bool VisitSettings (ConstSettingsVisitor &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
bool Apply (const CommandContext &context) override
 
ManualPageID ManualPage () override
 
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
PluginPath GetPath () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
ComponentInterfaceSymbol GetSymbol () const override=0
 
virtual TranslatableString GetDescription () const override
 
virtual ManualPageID ManualPage ()
 
virtual bool IsBatchProcessing () const
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
bool SaveSettingsAsString (wxString &parms)
 
bool LoadSettingsFromString (const wxString &parms)
 
bool DoAudacityCommand (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
virtual bool CheckWhetherSkipAudacityCommand ()
 
virtual void End ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool VisitSettings (SettingsVisitor &)
 
virtual bool VisitSettings (ConstSettingsVisitor &)
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Public Attributes

wxString mFileName
 
int mnChannels
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Export2") }
 

Additional Inherited Members

- Public Types inherited from AudacityCommand
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 

Detailed Description

Command for exporting audio.

Definition at line 46 of file ImportExportCommands.h.

Member Function Documentation

◆ Apply()

bool ExportCommand::Apply ( const CommandContext context)
override

Definition at line 111 of file ImportExportCommands.cpp.

112{
113 double t0, t1;
114 auto &selectedRegion = ViewInfo::Get( context.project ).selectedRegion;
115 t0 = selectedRegion.t0();
116 t1 = selectedRegion.t1();
117
118 // Find the extension and check it's valid
119 int splitAt = mFileName.Find(wxUniChar('.'), true);
120 if (splitAt < 0)
121 {
122 context.Error(wxT("Export filename must have an extension!"));
123 return false;
124 }
125 wxString extension = mFileName.Mid(splitAt+1).MakeUpper();
126
127 auto [plugin, formatIndex] = ExportPluginRegistry::Get().FindFormat(extension);
128
129 if(plugin != nullptr)
130 {
131 auto editor = plugin->CreateOptionsEditor(formatIndex, nullptr);
132 editor->Load(*gPrefs);
133
134 auto builder = ExportTaskBuilder{}
136 .SetNumChannels(std::max(0, mnChannels))
138 .SetPlugin(plugin)
140 .SetRange(t0, t1, true);
141
142 auto result = ExportResult::Error;
144 {
145 result = ExportProgressUI::Show(builder.Build(context.project));
146 });
147 if (result == ExportResult::Success || result == ExportResult::Stopped)
148 {
149 context.Status(wxString::Format(wxT("Exported to %s format: %s"),
151 return true;
152 }
153 }
154
155 context.Error(wxString::Format(wxT("Could not export to %s format!"), extension));
156 return false;
157}
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual void Error(const wxString &message) const
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
std::tuple< ExportPlugin *, int > FindFormat(const wxString &format, bool compareWithCase=false) const
Returns first pair of [exportPlugin, formatIndex], such that: exportPlugin->GetFormatInfo(formatIndex...
static ExportPluginRegistry & Get()
ExportTaskBuilder & SetPlugin(const ExportPlugin *plugin, int format=0) noexcept
Definition: Export.cpp:59
ExportTaskBuilder & SetParameters(ExportProcessor::Parameters parameters) noexcept
Definition: Export.cpp:47
ExportTaskBuilder & SetNumChannels(unsigned numChannels) noexcept
Definition: Export.cpp:53
ExportTaskBuilder & SetSampleRate(double sampleRate) noexcept
Definition: Export.cpp:72
ExportTaskBuilder & SetFileName(const wxFileName &filename)
Definition: Export.cpp:33
ExportTaskBuilder & SetRange(double t0, double t1, bool selectedOnly=false) noexcept
Definition: Export.cpp:39
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:39
double t0() const
Definition: ViewInfo.h:35
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
void ExceptionWrappedCall(Callable callable)

References Error, CommandContext::Error(), ExportProgressUI::ExceptionWrappedCall(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::extension, ExportPluginRegistry::FindFormat(), ExportPluginRegistry::Get(), ProjectRate::Get(), ViewInfo::Get(), ProjectRate::GetRate(), gPrefs, mFileName, mnChannels, ExportUtils::ParametersFromEditor(), CommandContext::project, ViewInfo::selectedRegion, ExportTaskBuilder::SetFileName(), ExportTaskBuilder::SetNumChannels(), ExportTaskBuilder::SetParameters(), ExportTaskBuilder::SetPlugin(), ExportTaskBuilder::SetRange(), ExportTaskBuilder::SetSampleRate(), ExportProgressUI::Show(), CommandContext::Status(), Stopped, Success, NotifyingSelectedRegion::t0(), and wxT().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString ExportCommand::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 53 of file ImportExportCommands.h.

53{return XO("Exports to a file.");};
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol ExportCommand::GetSymbol ( ) const
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 52 of file ImportExportCommands.h.

52{return Symbol;};
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ ManualPage()

ManualPageID ExportCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 61 of file ImportExportCommands.h.

61{return L"Extra_Menu:_Scriptables_II#export";}

◆ PopulateOrExchange()

void ExportCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 99 of file ImportExportCommands.cpp.

100{
101 S.AddSpace(0, 5);
102
103 S.StartMultiColumn(2, wxALIGN_CENTER);
104 {
105 S.TieTextBox(XXO("File Name:"),mFileName);
106 S.TieTextBox(XXO("Number of Channels:"),mnChannels);
107 }
108 S.EndMultiColumn();
109}
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64

References mFileName, mnChannels, S, and XXO().

Here is the call graph for this function:

◆ VisitSettings() [1/3]

bool ExportCommand::VisitSettings ( ConstSettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 91 of file ImportExportCommands.cpp.

92 { return VisitSettings<true>(S); }

References S.

◆ VisitSettings() [2/3]

bool ExportCommand::VisitSettings ( SettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 88 of file ImportExportCommands.cpp.

89 { return VisitSettings<false>(S); }

References S.

◆ VisitSettings() [3/3]

template<bool Const>
bool ExportCommand::VisitSettings ( SettingsVisitorBase< Const > &  S)

Definition at line 80 of file ImportExportCommands.cpp.

80 {
81 wxFileName fn = FileNames::FindDefaultPath(FileNames::Operation::Export);
82 fn.SetName("exported.wav");
83 S.Define(mFileName, wxT("Filename"), fn.GetFullPath());
84 S.Define( mnChannels, wxT("NumChannels"), 1 );
85 return true;
86}
static const auto fn
FILES_API FilePath FindDefaultPath(Operation op)

References FileNames::FindDefaultPath(), fn, mFileName, mnChannels, S, and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ mFileName

wxString ExportCommand::mFileName

Definition at line 63 of file ImportExportCommands.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mnChannels

int ExportCommand::mnChannels

Definition at line 64 of file ImportExportCommands.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ Symbol

const ComponentInterfaceSymbol ExportCommand::Symbol { XO("Export2") }
static

Definition at line 49 of file ImportExportCommands.h.

Referenced by GetSymbol().


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